Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ObjCryst::MonteCarloObj Class Reference

Base object for Monte-Carlo Global Optimization methods. More...

Inheritance diagram for ObjCryst::MonteCarloObj:

Inheritance graph
[legend]
Collaboration diagram for ObjCryst::MonteCarloObj:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MonteCarloObj (const string name="")
 Constructor.

 MonteCarloObj (const bool internalUseOnly)
 Constructor.

virtual ~MonteCarloObj ()
 Destructor.

void SetAlgorithmSimulAnnealing (const AnnealingSchedule scheduleTemp, const REAL tMax, const REAL tMin, const AnnealingSchedule scheduleMutation=ANNEALING_CONSTANT, const REAL mutMax=16., const REAL mutMin=.125, const long nbTrialRetry=0, const REAL minCostRetry=0.)
 Set the refinement method to simulated Annealing. Note that Parellel Tempering is more efficient to get out of local minima, so you sould rather use that method.

void SetAlgorithmParallTempering (const AnnealingSchedule scheduleTemp, const REAL tMax, const REAL tMin, const AnnealingSchedule scheduleMutation=ANNEALING_CONSTANT, const REAL mutMax=16., const REAL mutMin=.125)
 Set the refinement method to Parallel Tempering.

virtual void Optimize (long &nbSteps, const bool silent=false, const REAL finalcost=0, const REAL maxTime=-1)
 Launch optimization (a single run) for N steps.

virtual void MultiRunOptimize (long &nbCycle, long &nbSteps, const bool silent=false, const REAL finalcost=0, const REAL maxTime=-1)
 Launch optimization for multiple runs of N steps.

void RunSimulatedAnnealing (long &nbSteps, const bool silent=false, const REAL finalcost=0, const REAL maxTime=-1)
void RunParallelTempering (long &nbSteps, const bool silent=false, const REAL finalcost=0, const REAL maxTime=-1)
virtual void XMLOutput (ostream &os, int indent=0) const
 Output a description of the object in XML format to a stream.

virtual void XMLInput (istream &is, const XMLCrystTag &tag)
 Input in XML format from a stream, restoring the set of refined objects and the associated cost functions. Note that the corresponding objects must have been loaded in memory before, else shit happens.

virtual const string GetClassName () const
 Get the name for this class type.


Protected Member Functions

virtual void NewConfiguration (const RefParType *type=gpRefParTypeObjCryst)
 Make a random change in the configuration.

virtual void InitOptions ()
 Initialization of options.


Protected Attributes

RefObjOpt mGlobalOptimType
 Method used for the global optimization.

REAL mCurrentCost
 Current value of the cost function.

RefObjOpt mSaveTrackedData
 Option to save the evolution of tracked data (cost functions, likelihhod, individual parameters,...).

REAL mTemperature
 Current temperature for annealing.

REAL mTemperatureMax
 Beginning temperature for annealing.

REAL mTemperatureMin
 Lower temperature.

RefObjOpt mAnnealingScheduleTemp
 Schedule for the annealing.

REAL mTemperatureGamma
 Gamma for the 'gamma' temperature schedule.

REAL mMutationAmplitude
 Mutation amplitude.

REAL mMutationAmplitudeMax
 Mutation amplitude at the beginning of the optimization.

REAL mMutationAmplitudeMin
 Mutation amplitude at the end of the optimization.

RefObjOpt mAnnealingScheduleMutation
 Schedule for the annealing.

REAL mMutationAmplitudeGamma
 Gamma for the 'gamma' Mutation amplitude schedule.

long mNbTrialRetry
 Number of trials before testing if we are below the given minimum cost.

REAL mMinCostRetry
 Cost to reach unless an automatic randomization and retry is done.


Detailed Description

Base object for Monte-Carlo Global Optimization methods.

The algorithm is quite simple, whith two type of optimizations, either simulated Annealing or Parallel Tempering, the latter being recommanded for most real-world optimizations.


Constructor & Destructor Documentation

ObjCryst::MonteCarloObj::MonteCarloObj const string  name = ""  ) 
 

Constructor.

ObjCryst::MonteCarloObj::MonteCarloObj const bool  internalUseOnly  ) 
 

Constructor.

Using internalUseOnly=true will avoid registering the the object to any registry, and thus (for example) no display will be created, nor will this object be automatically be saved.

virtual ObjCryst::MonteCarloObj::~MonteCarloObj  )  [virtual]
 

Destructor.


Member Function Documentation

virtual const string ObjCryst::MonteCarloObj::GetClassName  )  const [virtual]
 

Get the name for this class type.

Reimplemented from ObjCryst::OptimizationObj.

virtual void ObjCryst::MonteCarloObj::InitOptions  )  [protected, virtual]
 

Initialization of options.

Reimplemented from ObjCryst::OptimizationObj.

virtual void ObjCryst::MonteCarloObj::MultiRunOptimize long &  nbCycle,
long &  nbSteps,
const bool  silent = false,
const REAL  finalcost = 0,
const REAL  maxTime = -1
[virtual]
 

Launch optimization for multiple runs of N steps.

Parameters:
nbCycle: the number of runs (cycles) to perform. The structure is randomized at the beginning of each cycle. If nbCycle==-1, this will run indefinitely. The nbCycle parameter is decreased after each run.
nbSteps: the number of steps to go. This number is modified (decreases!) as the refinement goes on.
silent : if true, absolutely no message should be printed (except debugging)
finalcost: the optimization will stop if overall cost fallse below this value
maxTime: the optimization will stop after the given number of seconds has been spent optimizing (ignored if <0).

Implements ObjCryst::OptimizationObj.

virtual void ObjCryst::MonteCarloObj::NewConfiguration const RefParType type = gpRefParTypeObjCryst  )  [protected, virtual]
 

Make a random change in the configuration.

For internal use only.

This just generates a new configuration with random changes (according to current parameters). The new configuration is not tested in this function vs temperature: this should be done in the OptimizationObj::Optimize() function, which also chooses whether to revert to the previous configuration.

Random moves are made by the objects and not by this function, because the new configuration can be specific (like, for example, permutations between some of the parameters (atoms)).

Parameters:
type: can be used to restrict the move to a given category of parameters.

virtual void ObjCryst::MonteCarloObj::Optimize long &  nbSteps,
const bool  silent = false,
const REAL  finalcost = 0,
const REAL  maxTime = -1
[virtual]
 

Launch optimization (a single run) for N steps.

Parameters:
nbSteps: the number of steps to go. This number is modified (decreases!) as the refinement goes on.
silent : if true, absolutely no message should be printed (except debugging)
finalcost: the optimization will stop if overall cost fallse below this value
maxTime: the optimization will stop after the given number of seconds has been spent optimizing (ignored if <0).

Implements ObjCryst::OptimizationObj.

void ObjCryst::MonteCarloObj::RunParallelTempering long &  nbSteps,
const bool  silent = false,
const REAL  finalcost = 0,
const REAL  maxTime = -1
 

For internal use only.

Do a single Parallel Tempering run. This is called by Optimize(...) and MultiRunOptimize(), which must also prepare the optimization (PrepareRefParList(), etc..).

void ObjCryst::MonteCarloObj::RunSimulatedAnnealing long &  nbSteps,
const bool  silent = false,
const REAL  finalcost = 0,
const REAL  maxTime = -1
 

For internal use only.

Do a single simulated annealing run. This is called by Optimize(...) and MultiRunOptimize(), which must also prepare the optimization (PrepareRefParList(), etc..).

void ObjCryst::MonteCarloObj::SetAlgorithmParallTempering const AnnealingSchedule  scheduleTemp,
const REAL  tMax,
const REAL  tMin,
const AnnealingSchedule  scheduleMutation = ANNEALING_CONSTANT,
const REAL  mutMax = 16.,
const REAL  mutMin = .125
 

Set the refinement method to Parallel Tempering.

The refinement begins at max and finishes at min temperature.

Parameters:
scheduleTemp: temperature schedule
tMax,tMin: Max and Min temperatures. See AnnealingSchedule.
scheduleMutation: the mutation schedule. For each new configuration, the variation of each refinable parameter is less than its RefinablePar::GlobalOptimStep(), multiplied by the current mutation amplitude. By default this mutation is equal to 1., but making bigger steps can be a good idea at the beginning of the refinement. Thus you can choose a schedule for the amplitude, exactly like for the temperature.
mutMax,mutMin: Max and Min mutation amplitudes.
Warning:
do not use the 'smart' option for the temperature schedule, it is not yet implemented. Later it will be used to set the temperatures as a function of the amplitude schedule, so that we keep accepted move between 30% and 70%.
Note:
this will be removed when we separate the different algorithms in different classes.

void ObjCryst::MonteCarloObj::SetAlgorithmSimulAnnealing const AnnealingSchedule  scheduleTemp,
const REAL  tMax,
const REAL  tMin,
const AnnealingSchedule  scheduleMutation = ANNEALING_CONSTANT,
const REAL  mutMax = 16.,
const REAL  mutMin = .125,
const long  nbTrialRetry = 0,
const REAL  minCostRetry = 0.
 

Set the refinement method to simulated Annealing. Note that Parellel Tempering is more efficient to get out of local minima, so you sould rather use that method.

The refinement begins at max and finishes at min temperature.

Parameters:
scheduleTemp: temperature schedule. See AnnealingSchedule.
tMax,tMin: Max and Min temperatures.
scheduleMutation: the mutation schedule. For each new configuration, the variation of each refinable parameter is less than its RefinablePar::GlobalOptimStep(), multiplied by the current mutation amplitude. By default this mutation is equal to 1., but making bigger steps is a good idea at the beginning of the refinement (for higher temperatures). See AnnealingSchedule. See AnnealingSchedule.
mutMax,mutMin: Max and Min mutation amplitudes.
minCostRetry,nbTrialRetry: if after nbTrialRetry, the cost function is still above minCostRetry, then start again from a random configuration. No randomization is made if nbTrialRetry <= 0.
maxNbTrialSinceBest: if more than maxNbTrialSinceBest trials have been made since the best configuration was recorded, then revert to that configuration. This should be large enough to have an ergodic search (the default is never to revert..)
Warning:
do not use the 'smart' option for the temperature schedule, it is not yet implemented. Later it will be used to set the temperatures as a function of the amplitude schedule, so that we accept between 30% and 70% moves.
Note:
this will be removed when we separate the different algorithms in different classes.

virtual void ObjCryst::MonteCarloObj::XMLInput istream &  is,
const XMLCrystTag tag
[virtual]
 

Input in XML format from a stream, restoring the set of refined objects and the associated cost functions. Note that the corresponding objects must have been loaded in memory before, else shit happens.

Implements ObjCryst::OptimizationObj.

virtual void ObjCryst::MonteCarloObj::XMLOutput ostream &  os,
int  indent = 0
const [virtual]
 

Output a description of the object in XML format to a stream.

This saves the list of refined object and the cost functions, as well as options for the refinement. The refined objects are not saved, so this must be done somewhere else (they must be reloaded before this object).

Implements ObjCryst::OptimizationObj.


Member Data Documentation

RefObjOpt ObjCryst::MonteCarloObj::mAnnealingScheduleMutation [protected]
 

Schedule for the annealing.

RefObjOpt ObjCryst::MonteCarloObj::mAnnealingScheduleTemp [protected]
 

Schedule for the annealing.

REAL ObjCryst::MonteCarloObj::mCurrentCost [protected]
 

Current value of the cost function.

RefObjOpt ObjCryst::MonteCarloObj::mGlobalOptimType [protected]
 

Method used for the global optimization.

Should be removed when we switch to using several classes for different algorithms.

REAL ObjCryst::MonteCarloObj::mMinCostRetry [protected]
 

Cost to reach unless an automatic randomization and retry is done.

REAL ObjCryst::MonteCarloObj::mMutationAmplitude [protected]
 

Mutation amplitude.

From .25 to 64. Random moves will have a maximum amplitude equal to this amplitude multiplied by the Global optimization step defined for each RefinablePar. Large amplitude should be used at the beginning of the refinement (high temeratures).

REAL ObjCryst::MonteCarloObj::mMutationAmplitudeGamma [protected]
 

Gamma for the 'gamma' Mutation amplitude schedule.

REAL ObjCryst::MonteCarloObj::mMutationAmplitudeMax [protected]
 

Mutation amplitude at the beginning of the optimization.

REAL ObjCryst::MonteCarloObj::mMutationAmplitudeMin [protected]
 

Mutation amplitude at the end of the optimization.

long ObjCryst::MonteCarloObj::mNbTrialRetry [protected]
 

Number of trials before testing if we are below the given minimum cost.

If <=0, this will be ignored.

RefObjOpt ObjCryst::MonteCarloObj::mSaveTrackedData [protected]
 

Option to save the evolution of tracked data (cost functions, likelihhod, individual parameters,...).

REAL ObjCryst::MonteCarloObj::mTemperature [protected]
 

Current temperature for annealing.

REAL ObjCryst::MonteCarloObj::mTemperatureGamma [protected]
 

Gamma for the 'gamma' temperature schedule.

REAL ObjCryst::MonteCarloObj::mTemperatureMax [protected]
 

Beginning temperature for annealing.

REAL ObjCryst::MonteCarloObj::mTemperatureMin [protected]
 

Lower temperature.


The documentation for this class was generated from the following file:
Generated on Tue Nov 14 15:05:45 2006 for ObjCryst++ by doxygen 1.3.6