void FireflyAlgorithm::startState(Problem &P, const EndCriteria &endCriteria) {
        N_ = P.currentValue().size();
        x_.reserve(M_);
        xI_.reserve(M_);
        xRW_.reserve(M_);
        values_.reserve(M_);
        uX_ = P.constraint().upperBound(P.currentValue());
        lX_ = P.constraint().lowerBound(P.currentValue());
        Array bounds = uX_ - lX_;

        //Random initialization is done by Sobol sequence
        SobolRsg sobol(N_);

        //Prepare containers
        for (Size i = 0; i < M_; i++) {
            const SobolRsg::sample_type::value_type &sample = sobol.nextSequence().value;
            x_.push_back(Array(N_, 0.0));
            xI_.push_back(Array(N_, 0.0));
            xRW_.push_back(Array(N_, 0.0));
            Array& x = x_.back();
            for (Size j = 0; j < N_; j++) {
                //Assign X=lb+(ub-lb)*random
                x[j] = lX_[j] + bounds[j] * sample[j];
            }
            //Evaluate point
            values_.push_back(std::make_pair(P.value(x), i));
        }

        //init intensity & randomWalk
        intensity_->init(this);
        randomWalk_->init(this);
    }
Example #2
0
    void samplePoints(M& xPoints, int method,
		     randEngine& mtRandom)
    {
      if (method == 1) 
	{
	  FILE_LOG(logINFO) << "Latin hypercube sampling";
	  lhs(xPoints, mtRandom);
	}
      else if (method == 2)
	{
#if defined (USE_SOBOL)
	  FILE_LOG(logINFO) << "Sobol sampling";
	  sobol(xPoints, 0);
#else
	  FILE_LOG(logINFO) << "Latin hypercube sampling";
	  lhs(xPoints, mtRandom);
#endif
	}
      else
	{
	  FILE_LOG(logINFO) << "Uniform sampling";
	  uniformSampling(xPoints, mtRandom);
	}
    }
Example #3
0
BOOST_FORCEINLINE typename meta::call<tag::sobol_(size_t,meta::as_<T>)>::type
sobol(size_t const & a0)
{
    return sobol(a0, nt2::meta::as_<T>());
}