#include <GlobalOptimObj.h>
Public Methods | |||
GlobalOptimObj (const string name="") | |||
Constructor. | |||
virtual | ~GlobalOptimObj () | ||
Destructor. | |||
void | RandomizeStartingConfig () | ||
Randomize starting configuration. Only affects limited and periodic parameters. | |||
void | SetAlgorithmSimulAnnealing (const AnnealingSchedule scheduleTemp, const double tMax, const double tMin, const AnnealingSchedule scheduleMutation=ANNEALING_CONSTANT, const double mutMax=16., const double mutMin=.125, const long nbTrialRetry=0, const double minCostRetry=0., const long maxNbTrialSinceBest=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. More... | |||
void | SetAlgorithmParallTempering (const AnnealingSchedule scheduleTemp, const double tMax, const double tMin, const AnnealingSchedule scheduleMutation=ANNEALING_CONSTANT, const double mutMax=16., const double mutMin=.125) | ||
Set the refinement method to Parallel Tempering. More... | |||
void | Optimize (long &nbSteps) | ||
Launch optimization for N steps
| |||
void | FixAllPar () | ||
Fix all parameters. | |||
void | SetParIsFixed (const string &parName, const bool fix) | ||
Fix one parameter. | |||
void | SetParIsFixed (const RefParType *type, const bool fix) | ||
Fix one family of parameters. | |||
void | UnFixAllPar () | ||
UnFix All parameters. | |||
void | SetParIsUsed (const string &parName, const bool use) | ||
Set a parameter to be used. | |||
void | SetParIsUsed (const RefParType *type, const bool use) | ||
Set a family of parameters to be used. | |||
void | SetLimitsRelative (const string &parName, const double min, const double max) | ||
Change the relative limits for a parameter from its name. | |||
void | SetLimitsRelative (const RefParType *type, const double min, const double max) | ||
Change the relative limits for a family of parameter. | |||
void | SetLimitsAbsolute (const string &parName, const double min, const double max) | ||
Change the absolute limits for a parameter from its name. | |||
void | SetLimitsAbsolute (const RefParType *type, const double min, const double max) | ||
Change the absolute limits for a family of parameter. | |||
void | SaveOptimHistory () const | ||
Save history of the evolution of parameters to a file. Only non-fixed parameters are saved. This saves a very crude array in which can bve found the value of all non-fixed parameters for successive "best" configurations. | |||
virtual double | GetCostFunctionValue () | ||
The optimized (minimized, actually) function. More... | |||
void | StopAfterCycle () | ||
Stop after the current cycle. USed for interactive refinement. | |||
virtual void | DisplayReport () | ||
Show report to the user during refinement. Used for GUI update. | |||
void | AddRefinableObj (RefinableObj &) | ||
Add a refined object. All sub-objects are also added. | |||
void | AddCostFunction (RefinableObj &, const unsigned int id, const double weight=1.) | ||
Add a cost function, with a given weight. This cost function should be strictly positive, and ideally should behave like a R/Rw function, ie a value above 0.50 corresponds to a very inadequate configuration, while 0.05 is excellent. | |||
virtual void | XMLOutput (ostream &os, int indent=0) const | ||
Output a description of the object in XML format to a stream. More... | |||
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. | |||
const string & | GetName () const | ||
Get the name for this object. | |||
void | SetName (const string &) | ||
Set the name for this object. | |||
const string | GetClassName () const | ||
Get the name for this class type. | |||
void | Print () const | ||
Print some information about this object. | |||
Protected Methods | |||
virtual void | NewConfiguration () | ||
Make a random change in the configuration. More... | |||
void | PrepareRefParList () | ||
Prepare mRefParList for the refinement. | |||
void | InitRandomSeedFromTime () const | ||
Initialize random seed from time. | |||
void | InitOptions () | ||
Initialization of options. | |||
void | UpdateDisplay () | ||
Update Display (if any display is available), when a new 'relevant' configuration is reached. This calls all RefinableObj::UpdateDisplay(). | |||
Protected Attributes | |||
RefinableObj | mRefParList | ||
The refinable par list used during refinement. Only a condensed version of all objects. This is useful to keep an history of modifications, and to restore previous values.
| |||
string | mName | ||
Name of the GlobalOptimization object. | |||
string | mSaveFileName | ||
File name where refinement info is saved (NOT USED so far...). | |||
RefObjOpt | mGlobalOptimType | ||
Method used for the global optimization. Should be removed when we switch to using several classes for different algorithms. | |||
long | mNbTrial | ||
Number of trials so far. | |||
double | mCurrentCost | ||
Current value of the cost function. | |||
double | mBestCost | ||
Best value of the cost function so far. | |||
long | mHistoryNb | ||
Total number of saved configurations. | |||
CrystVector_long | mHistoryTrialNumber | ||
Trials corresponding to each stored values. | |||
CrystVector_double | mHistoryCostFunction | ||
Evolution of cost function. | |||
CrystVector_long | mHistorySavedParamSetIndex | ||
Index of saved parameters set in mRefParList for each saved trial. | |||
bool | mHistorySaveAfterEachOptim | ||
Save the evolution of refined parameters after optimization ? | |||
string | mHistorySaveFileName | ||
Save the evolution of refined parameters after optimization ? | |||
long | mBestParSavedSetIndex | ||
Index of the 'best' saved parameter set. | |||
long | mLastParSavedSetIndex | ||
Index of the 'last' parameter set. | |||
double | mTemperatureMax | ||
Beginning temperature for annealing. | |||
double | mTemperatureMin | ||
Lower temperature. | |||
RefObjOpt | mAnnealingScheduleTemp | ||
Schedule for the annealing. | |||
double | mMutationAmplitude | ||
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). | |||
double | mMutationAmplitudeMax | ||
Mutation amplitude at the beginning of the optimization. | |||
double | mMutationAmplitudeMin | ||
Mutation amplitude at the end of the optimization. | |||
RefObjOpt | mAnnealingScheduleMutation | ||
Schedule for the annealing. | |||
long | mNbTrialRetry | ||
Number of trials before testing if we are below the given minimum cost. If <=0, this will be ignored. | |||
double | mMinCostRetry | ||
Cost to reach unless an automatic randomization and retry is done. | |||
long | mMaxNbTrialSinceBest | ||
If more than mMaxNbTrialSinceBest trials have been made since the best configuration has been found, then revert to the best configuration. If <=0, then this is ignored. This must be large enough to have an ergodic algorithm (more strictly, should not be used ?). | |||
bool | mIsOptimizing | ||
True if a refinement is being done. For multi-threaded environment. | |||
bool | mStopAfterCycle | ||
If true, then stop at the end of the cycle. Used in multi-threaded environment. | |||
ObjRegistry< RefinableObj > | mRefinedObjList | ||
The refined objects. | |||
ObjRegistry< RefinableObj > | mRecursiveRefinedObjList | ||
The refined objects, recursively including all sub-objects. | |||
unsigned int | mNbCostFunction | ||
Number of Cost Functions used. | |||
unsigned int | mMaxNbCostFunction | ||
Max number of Cost Functions (dynamically adjusted). | |||
RefinableObj * | mpCostFunctionRefinableObj [20] | ||
The objects with the Cost functions. | |||
CrystVector_int | mpCostFunctionId | ||
The id of the cost functions in each RefinableObj. | |||
CrystVector_double | mCostFunctionWeight | ||
The weight associated with each cost function. |
The algorithm is quite simple, whith two type of optimization, either simulated Annealing or Parallel Tempering, the latter being recommanded for most real-world optimizations
|
The optimized (minimized, actually) function. This function is the weighted sum of the chosen Cost Functions for the refined objects. All Cost Functions must be strictly positive. |
|
Make a random change in the configuration. This just generates a new configuration with random changes (according to current parameters). The old config is stored in mRefParList as the last config (index mLastParSavedSetIndex). The new one is not tested in this function vs temperature: this should be done in the GlobalOptimObj::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)). |
|
Set the refinement method to Parallel Tempering. The refinement begins at max and finishes at min temperature.
|
|
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.
|
|
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). |