示例#1
0
 void operator() (const parallel::range_t& range) const {
   assert(n.size() == pop.size());
   assert(s.size() == pop.size());
   for (size_t p = range.begin(); p != range.end(); ++p) {
     assert(s[p].empty());
     n[p] = 0;
     for (size_t q = 0; q < pop.size(); ++q) {
       int flag = fit::dominate_flag(pop[p], pop[q]);
       if (flag > 0)
         s[p].push_back(q);
       else if (flag < 0)
         ++n[p];
     }
     if (n[p] == 0)
       r[p] = 0;
   }
 }
                void operator() (const parallel::range_t& r) const
                {
                    for (size_t i = r.begin(); i != r.end(); ++i)
                    {
                        float d = 0.0f;
                        if (_pop[i]->fit().objs()[0] <= -10000)
                            d=-1000;
                        else
                        {

                            for (size_t j = 0; j < _pop.size(); ++j)
                                d += euclidean_dist(_pop[i]->data(),_pop[j]->data());
                            d /= (float)_pop.size();
                        }
                        int l =  _pop[i]->fit().objs().size()-1;
                        _pop[i]->fit().set_obj(l, d);
                    }
                }
示例#3
0
        void operator() (const parallel::range_t& r) const {
          for (size_t i = r.begin(); i != r.end(); ++i) {
            for (size_t j = 0; j < _archive.size(); ++j)
            {
            	float d = 0;

            	// Check if they are not the same image
            	if ((_pop[i] != _archive[j]) && (_pop[i]->id() != _archive[j]->id()))
            	{
#ifdef EUCLIDEAN_DISTANCE
            		// Euclidean distance
            		d = _pop[i]->dist(*_archive[j]);

            		#else
            		// Regular distance
            		d = _pop[i]->fit().dist(*_archive[j]);
#endif
            	}

              distances(i, j) = d;
            }
          }
        }
示例#4
0
 void operator() (const parallel::range_t& r) const {
   for (size_t i = r.begin(); i != r.end(); ++i)
     _pop[i]->mutate();
 }
示例#5
0
 void operator() (const parallel::range_t& r) const {
   for (size_t i = r.begin(); i != r.end(); ++i) {
     _pop[i] = boost::shared_ptr<Phen>(new Phen());
     _pop[i]->random();
   }
 }