IMP  2.0.1
The Integrative Modeling Platform
IMP::kernel::Optimizer Class Referenceabstract

Base class for all optimizers. More...

#include <IMP/kernel/Optimizer.h>

+ Inheritance diagram for IMP::kernel::Optimizer:

Public Member Functions

 Optimizer (Model *m, std::string name="Optimizer %1%")
 
double get_last_score () const
 Return the score found in the last evaluate.
 
Modelget_model () const
 Get the model being optimized.
 
ScoringFunctionget_scoring_function () const
 Return the scoring function that is being used.
 
bool get_stop_on_good_score () const
 
double optimize (unsigned int max_steps)
 Optimize the model for up to max_steps iterations. More...
 
void set_model (Model *m)
 Set the model being optimized. More...
 
virtual void set_scoring_function (ScoringFunctionAdaptor sf)
 
void set_stop_on_good_score (bool tf)
 
virtual void show (std::ostream &out=std::cout) const
 Print info about the optimizer state. More...
 
- Public Member Functions inherited from IMP::base::Object
virtual void clear_caches ()
 
virtual IMP::base::VersionInfo get_version_info () const =0
 Get information about the module and version of the object.
 
void set_check_level (CheckLevel l)
 
void set_log_level (LogLevel l)
 Set the logging level used in this object. More...
 
void set_was_used (bool tf) const
 
void show (std::ostream &out=std::cout) const
 
const std::string & get_name () const
 
void set_name (std::string name)
 

Protected Member Functions

virtual double do_optimize (unsigned int ns)=0
 override this function to do actual optimization
 
void update_states () const
 Update optimizer states, should be called at each successful step. More...
 
double width (FloatKey k) const
 
- Protected Member Functions inherited from IMP::base::Object
 Object (std::string name)
 Construct an object with the given name. More...
 

Related Functions

(Note that these are not member functions.)

typedef IMP::base::Vector
< IMP::base::WeakPointer
< Optimizer > > 
OptimizersTemp
 

States

The stored OptimizerState objects are updated each time the Optimizer decides to accept a new configuration of the Model. To manipulate the list of optimizer states use the methods below.

void remove_optimizer_state (OptimizerState *d)
 
void remove_optimizer_states (const OptimizerStates &d)
 
void set_optimizer_states (const OptimizerStates &ps)
 
void set_optimizer_states_order (const OptimizerStates &objs)
 
unsigned int add_optimizer_state (OptimizerState *obj)
 
void add_optimizer_states (const OptimizerStates &objs)
 
void clear_optimizer_states ()
 
unsigned int get_number_of_optimizer_states () const
 
bool get_has_optimizer_states ()
 
OptimizerStateget_optimizer_state (unsigned int i) const
 
OptimizerStates get_optimizer_states () const
 
void reserve_optimizer_states (unsigned int sz)
 

Methods for getting and setting optimized attributes

Optimizers don't have to go through the particles themselves looking for values to optimize unless they care about special properties of the optimized values. Instead they can iterate through the list of optimized attributes, each of which is identified by a FloatIndex. With these FloatIndex objects they can get and set the values and derivatives as needed.

FloatIndexes get_optimized_attributes () const
 
void set_value (FloatIndex fi, double v) const
 
Float get_value (FloatIndex fi) const
 
Float get_derivative (FloatIndex fi) const
 

Methods to get and set scaled optimizable values

Certain optimizers benefit from having all the optimized values scaled to vary over a similar range. These accessors use the Model::get_range ranges to scale the values before returning them and unscale them before setting them.

void set_scaled_value (FloatIndex fi, Float v) const
 
double get_scaled_value (FloatIndex fi) const
 
double get_scaled_derivative (FloatIndex fi) const
 
void clear_range_cache ()
 Clear the cache of range information. Do this at the start of optimization.
 

Detailed Description

An optimizer attempts to improve the current configuration of the Model by moving particles around so as to lower the score.

The Optimizer maintains a list of OptimizerStates which are updated each time the conformation is changed.

The optimizers have one key method Optimizer::optimize() which takes the number of steps to perform. The optimizers can have other stopping conditions as appropriate.

A typical optimization loop proceeds by:

  • the optimizer calls Model::evaluate() to compute the score (and possibly the derivatives) of the current conformation of the Model.
  • the optimizer uses this information to update the optimizeable parameters of the Particles contained in the Model.
Implementors
Developers who wish to implement a Optimizer should inherit from this class and use the IMP_OPTIMIZER() macro to help define the needed functions. Lamentably, we do not provide an example.

Definition at line 46 of file kernel/Optimizer.h.

Member Function Documentation

double IMP::kernel::Optimizer::optimize ( unsigned int  max_steps)

Optimize the model

Parameters
[in]max_stepsThe maximum number of iterations of the optimizer to perform. Increasing this number will generally make the optimizer spend more time searching for a solution, but beyond that, the details of what changes will vary.
Returns
The final score.
void IMP::kernel::Optimizer::set_model ( Model m)
Note
The model is not owned by the optimizer and so is not deleted when the optimizer is deleted. Further, the Optimizer does not prevent the model from being deleted when all Python references go away.
virtual void IMP::kernel::Optimizer::set_scoring_function ( ScoringFunctionAdaptor  sf)
virtual

By default, the Optimizer uses the scoring function provided by the model, but you can use another scoring function instead.

void IMP::kernel::Optimizer::set_stop_on_good_score ( bool  tf)

Optimization can be stopped if all the thresholds in the Model are satisfied.

Definition at line 78 of file kernel/Optimizer.h.

virtual void IMP::kernel::Optimizer::show ( std::ostream &  out = std::cout) const
virtual

It should end in a newline

Definition at line 110 of file kernel/Optimizer.h.

void IMP::kernel::Optimizer::update_states ( ) const
protected

Make sure the scoring function restraints are up to date before this is called (eg by calling evaluate).

Friends And Related Function Documentation

Pass a set of objects.

Definition at line 242 of file kernel/Optimizer.h.


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