Pallas Solver  0.1
C++ Global Optimization Algorithms
Classes | Public Member Functions | List of all members
pallas::DifferentialEvolution Class Reference

Minimizes an objective function by continuously evolving a population of candidate solutions. More...

#include <differential_evolution.h>

Classes

struct  HistoryOutput
 Stores information about the state of the system for at a given iteration number. More...
 
struct  Options
 
struct  Summary
 Contains a summary of the optimization. More...
 

Public Member Functions

 DifferentialEvolution ()
 Default constructor.
 
void Solve (const DifferentialEvolution::Options &options, const GradientProblem &problem, double *parameters, DifferentialEvolution::Summary *global_summary)
 Minimizes the specified gradient problem. More...
 

Detailed Description

Minimizes an objective function by continuously evolving a population of candidate solutions.

Example

#include "glog/logging.h"
// Each solver is defined in its own header file.
// include the solver you wish you use:
// define a problem you wish to solve by inheriting
// from the pallas::GradientCostFunction interface
// and implementing the Evaluate and NumParameters methods.
class Rosenbrock : public pallas::GradientCostFunction {
public:
virtual ~Rosenbrock() {}
virtual bool Evaluate(const double* parameters,
double* cost,
double* gradient) const {
const double x = parameters[0];
const double y = parameters[1];
cost[0] = (1.0 - x) * (1.0 - x) + 100.0 * (y - x * x) * (y - x * x);
if (gradient != NULL) {
gradient[0] = -2.0 * (1.0 - x) - 200.0 * (y - x * x) * 2.0 * x;
gradient[1] = 200.0 * (y - x * x);
}
return true;
}
virtual int NumParameters() const { return 2; }
};
int main(int argc, char** argv) {
google::InitGoogleLogging(argv[0]);
// define the starting point for the optimization
double parameters[2] = {-1.2, 0.0};
// set up global optimizer options only initialization
// is need to accept the default options
// differential evolution requires that upper
// and lower bounds are placed on the parameters
// in the form of pallas::Vector which is a
// just a typedef of an Eigen::VectorXd.
pallas::Vector upper_bounds(2);
upper_bounds << 5, 5;
pallas::Vector lower_bounds(2);
lower_bounds << -5, -5;
options.upper_bounds = upper_bounds;
options.lower_bounds = lower_bounds;
// initialize a summary object to hold the
// optimization details
// create a problem from your cost function
pallas::GradientProblem problem(new Rosenbrock());
// solve the problem and store the optimal position
// in parameters and the optimization details in
// the summary
pallas::Solve(options, problem, parameters, &summary);
std::cout << summary.FullReport() << std::endl;
std::cout << "Global minimum found at:" << std::endl;
std::cout << "\tx: " << parameters[0] << "\ty: " << parameters[1] << std::endl;
return 0;
}

Member Function Documentation

void pallas::DifferentialEvolution::Solve ( const DifferentialEvolution::Options options,
const GradientProblem &  problem,
double *  parameters,
DifferentialEvolution::Summary global_summary 
)

Minimizes the specified gradient problem.

The specified options are used to setup a differential evolution instance which is then used to minimize the GradientProblem. The optimal solution is stored in parameters and a summary of the global optimization can be found in summary.

Parameters
optionspallas::DifferentialEvolution::Options. Options used to configure the optimization.
problempallas::GradientProblem. The problem to optimize.
parametersdouble*. The starting point for further optimization.
summaryDifferentialEvolution::Summary*. Summary instance to store the optimization details.

Here is the caller graph for this function:


The documentation for this class was generated from the following files: