BuecheRastriginFunction::BuecheRastriginFunction(
        const arma::uword numberOfDimensions)
        : BlackBoxOptimisationBenchmark(numberOfDimensions),
          parameterConditioning_(getParameterConditioning(std::sqrt(10.0))) {
      if (numberOfDimensions_ < 2) {
        throw std::domain_error("BuecheRastriginFunction: The number of dimensions must be greater than 1.");
      } else if (!isRepresentableAsFloatingPoint(numberOfDimensions_)) {
        throw std::overflow_error("BuecheRastriginFunction: The number of elements must be representable as a floating point.");
      }

      arma::vec parameterTranslation = getRandomParameterTranslation();
      for (arma::uword n = 0; n < parameterTranslation.n_elem; n += 2) {
        parameterTranslation(n) = std::abs(parameterTranslation(n));
      }
      setParameterTranslation(parameterTranslation);

      setObjectiveFunctions({{[this](
                                  const arma::vec& parameter_) {
                                assert(parameter_.n_elem == numberOfDimensions_);

                                arma::vec z = parameterConditioning_ % getOscillatedParameter(parameter_);
                                for (arma::uword n = 0; n < z.n_elem; n += 2) {
                                  if (z(n) > 0.0) {
                                    z(n) *= 10.0;
                                  }
                                }

                                return 10.0 * (static_cast<double>(numberOfDimensions_) - arma::accu(arma::cos(2.0 * arma::datum::pi * z))) + std::pow(arma::norm(z), 2.0);
                              },
          "BBOB Büche-Rastrigin Function (f4)"}});
    }
Esempio n. 2
0
    EllipsoidalFunction::EllipsoidalFunction(
        const arma::uword numberOfDimensions)
        : BlackBoxOptimisationBenchmark(numberOfDimensions),
          parameterConditioning_(getParameterConditioning(1000000.0)) {
      if (numberOfDimensions_ < 2) {
        throw std::domain_error("EllipsoidalFunction: The number of dimensions must be greater than 1.");
      }

      setParameterTranslation(getRandomParameterTranslation());

      setObjectiveFunctions({{[this](
                                  const arma::vec& parameter_) {
                                assert(parameter_.n_elem == numberOfDimensions_);

                                return arma::dot(parameterConditioning_, arma::square(getOscillatedParameter(parameter_)));
                              },
          "BBOB Ellipsoidal Function (f2)"}});
    }
Esempio n. 3
0
    double WeierstrassFunction::getObjectiveValueImplementation(
        const arma::Col<double>& parameter) const {
      assert(parameter.n_elem == numberOfDimensions_);

      const arma::Col<double>& z = rotationR_ * (parameterConditioning_ % (rotationQ_ * getOscillatedParameter(rotationR_ * parameter)));

      double sum = 0.0;
      for (arma::uword n = 0; n < z.n_elem; ++n) {
        for (arma::uword k = 0; k < 12; ++k) {
          sum += std::pow(0.5, k) * std::cos(2.0 * arma::datum::pi * std::pow(3.0, k) * (z(n) + 0.5));
        }
      }

      return 10.0 * std::pow(sum / static_cast<double>(numberOfDimensions_) - f0_, 3.0);
    }
    RastriginFunctionRotated::RastriginFunctionRotated(
        const arma::uword numberOfDimensions)
        : BlackBoxOptimisationBenchmark(numberOfDimensions),
          parameterConditioning_(getParameterConditioning(std::sqrt(10.0))),
          rotationR_(synchronise(randomRotationMatrix(numberOfDimensions_))),
          rotationQ_(synchronise(randomRotationMatrix(numberOfDimensions_))) {
      if (numberOfDimensions_ < 2) {
        throw std::domain_error("RastriginFunctionRotated: The number of dimensions must be greater than 1.");
      } else if (!isRepresentableAsFloatingPoint(numberOfDimensions_)) {
        throw std::overflow_error("RastriginFunctionRotated: The number of elements must be representable as a floating point.");
      }

      setParameterTranslation(getRandomParameterTranslation());

      setObjectiveFunctions({{[this](
                                  const arma::vec& parameter_) {
                                assert(parameter_.n_elem == numberOfDimensions_);

                                const arma::vec& z = rotationR_ * (parameterConditioning_ % (rotationQ_ * getAsymmetricParameter(0.2, getOscillatedParameter(rotationR_ * parameter_))));
                                return 10.0 * (static_cast<double>(numberOfDimensions_) - arma::accu(arma::cos(2.0 * arma::datum::pi * z))) + std::pow(arma::norm(z), 2.0);
                              },
          "BBOB Rastrigin Function, rotated (f15)"}});
    }
Esempio n. 5
0
    WeierstrassFunction::WeierstrassFunction(
        const arma::uword numberOfDimensions)
        : BlackBoxOptimisationBenchmark(numberOfDimensions),
          parameterConditioning_(getParameterConditioning(std::sqrt(0.01))),
          rotationR_(randomRotationMatrix(numberOfDimensions_)),
          rotationQ_(randomRotationMatrix(numberOfDimensions_)) {
      setParameterTranslation(getRandomParameterTranslation());

#if defined(SUPPORT_MPI)
      MPI_Bcast(rotationR_.memptr(), static_cast<int>(rotationR_.n_elem), MPI_DOUBLE, 0, MPI_COMM_WORLD);
      MPI_Bcast(rotationQ_.memptr(), static_cast<int>(rotationQ_.n_elem), MPI_DOUBLE, 0, MPI_COMM_WORLD);
#endif

      setObjectiveFunction(
          [this](
              const arma::Col<double>& parameter_) {
            assert(parameter_.n_elem == numberOfDimensions_);
              
            const arma::Col<double>& z = rotationR_ * (parameterConditioning_ % (rotationQ_ * getOscillatedParameter(rotationR_ * parameter_)));

            double sum = 0.0;
            for (arma::uword n = 0; n < z.n_elem; ++n) {
              for (arma::uword k = 0; k < 12; ++k) {
                sum += std::pow(0.5, k) * std::cos(2.0 * arma::datum::pi * std::pow(3.0, k) * (z(n) + 0.5));
              }
            }

            return 10.0 * std::pow(sum / static_cast<double>(numberOfDimensions_) +1.99951171875, 3.0);
          },
          "BBOB Weierstrass Function (f16)");
    }