IMP logo

IMP::Optimizer Class Reference


Detailed Description

Base class for all optimizers.

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:

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.
Inheritance diagram for IMP::Optimizer:

Inheritance graph
[legend]

Public Member Functions

def __del__
def __disown__
Modelget_model () const
 Get the model being optimized.
virtual VersionInfo get_version_info () const =0
virtual Float optimize (unsigned int max_steps)=0
 Optimizer (Model *m=NULL, std::string name="Optimizer %1%")
void set_model (Model *m)
 Set the model being optimized.
virtual void show (std::ostream &out=std::cout) const
 Print info about the optimizer state.

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.

unsigned int add_optimizer_state (OptimizerState *obj)
void add_optimizer_states (const OptimizerStates &obj)
void clear_optimizer_states ()
bool get_has_optimizer_states () const
 return true if there are any objects in the container
unsigned int get_number_of_optimizer_states () const
OptimizerStateget_optimizer_state (unsigned int i) const
OptimizerStateConstIterator optimizer_states_begin () const
OptimizerStateIterator optimizer_states_begin ()
OptimizerStateConstIterator optimizer_states_end () const
OptimizerStateIterator optimizer_states_end ()
void remove_optimizer_state (OptimizerState *d)
 Remove any occurences of d from the container.
void remove_optimizer_states (const OptimizerStates &d)
 Remove any occurences of each item in d.
template<class F >
void remove_optimizer_states_if (const F &f)
 Remove any occurrences for which f is true.
void reserve_optimizer_states (unsigned int sz)
void set_optimizer_states (const OptimizerStates &ps)

Protected Types

typedef std::vector< FloatIndex > FloatIndexes

Protected Member Functions

void update_states () const
 Update optimizer state, should be called at each successful step.
double width (FloatKey k) 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 clear_range_cache ()
 Clear the cache of range information. Do this at the start of optimization.
double get_scaled_derivative (FloatIndex fi) const
double get_scaled_value (FloatIndex fi) const
void set_scaled_value (FloatIndex fi, Float v) const
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.

FloatIndexIterator float_indexes_begin () const
FloatIndexIterator float_indexes_end () const
Float get_derivative (FloatIndex fi) const
Float get_value (FloatIndex fi) const
void set_value (FloatIndex fi, Float v) const

Package Attributes

 __pad0__:VectorStorage<internal::FloatAttributeTableTraits> FloatTable
WeakPointer< Modelmodel_
FloatTable widths_

Friends

template<class T >
void IMP::internal::unref (T *)

Related Functions

(Note that these are not member functions.)

 IMP_OPTIMIZER(Name)
 Define the basic things you need for an Optimizer.

Member Function Documentation

unsigned int IMP::Optimizer::add_optimizer_state ( OptimizerState obj  ) 

Returns:
index of object within the object

void IMP::Optimizer::add_optimizer_states ( const OptimizerStates obj  ) 

Add several objects to the container. They are not necessarily added at the end.

OptimizerState* IMP::Optimizer::get_optimizer_state ( unsigned int  i  )  const

Get the object refered to by the index

Exceptions:
IndexException in Python if the index is out of range

virtual VersionInfo IMP::Optimizer::get_version_info (  )  const [pure virtual]

Returns:
version and authorship information.

Implements IMP::Object.

virtual Float IMP::Optimizer::optimize ( unsigned int  max_steps  )  [pure virtual]

Optimize the model

Parameters:
[in] max_steps The 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::Optimizer::set_model ( Model m  ) 

Set the model being optimized.

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.

void IMP::Optimizer::set_optimizer_states ( const OptimizerStates ps  ) 

Set the contents of the container to ps removing all its current contents.

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

Print info about the optimizer state.

It should end in a newline

Reimplemented from IMP::Object.


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

Generated on Mon Mar 8 23:08:42 2010 for IMP by doxygen 1.5.8