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

Minimizes an objective function by sequentially hopping between minima in the objective's energy landscape. More...

#include <basinhopping.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

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

Detailed Description

Minimizes an objective function by sequentially hopping between minima in the objective's energy landscape.

Basin-hopping is a stochastic algorithm that attempts to find the global minimum of a smooth scalar function of one or more variables. The algorithm in its current form was described by David Wales and Jonathan Doye http://www-wales.ch.cam.ac.uk/.
The algorithm is iterative with each cycle composed of the following features

  1. random perturbation of the coordinates
  2. local minimization
  3. accept or reject the new coordinates based on the minimized function value

The acceptance test used here is the Metropolis criterion of standard Monte Carlo algorithms.

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
// 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::Basinhopping::Solve ( const Basinhopping::Options options,
const GradientProblem &  problem,
double *  parameters,
Basinhopping::Summary global_summary 
)

Minimizes the specified gradient problem.

The specified options are used to setup a basinhopping 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::Basinhopping::Options. Options used to configure the optimization.
problempallas::GradientProblem. The problem to optimize.
parametersdouble*. The starting point for further optimization.
summaryBasinhopping::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: