00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _GLOBALOPTIMOBJ_H
00014 #define _GLOBALOPTIMOBJ_H
00015
00016 #include "ObjCryst/General.h"
00017
00018 #ifdef __WX__CRYST__
00019 namespace ObjCryst
00020 {
00021 class GlobalOptimObj;
00022 }
00023
00024 #include "wxCryst/wxGlobalOptimObj.h"
00025 #endif
00026
00027 #include "RefinableObj/RefinableObj.h"
00028 #include "RefinableObj/IO.h"
00029 #include <string>
00030 #include <iostream>
00031
00032 namespace ObjCryst
00033 {
00051 enum AnnealingSchedule
00052 {
00053 ANNEALING_CONSTANT,
00054 ANNEALING_BOLTZMANN,
00055 ANNEALING_CAUCHY,
00056
00057 ANNEALING_EXPONENTIAL,
00058 ANNEALING_SMART
00059 };
00060
00066 enum GlobalOptimType
00067 {
00068 GLOBAL_OPTIM_SIMULATED_ANNEALING,
00069 GLOBAL_OPTIM_PARALLEL_TEMPERING,
00070 GLOBAL_OPTIM_GENETIC
00071 };
00072
00089 class GlobalOptimObj
00090 {
00091 public:
00093 GlobalOptimObj(const string name="");
00095 virtual ~GlobalOptimObj();
00096
00099 void RandomizeStartingConfig();
00100
00128 void SetAlgorithmSimulAnnealing(const AnnealingSchedule scheduleTemp,
00129 const double tMax, const double tMin,
00130 const AnnealingSchedule scheduleMutation=ANNEALING_CONSTANT,
00131 const double mutMax=16., const double mutMin=.125,
00132 const long nbTrialRetry=0,const double minCostRetry=0.,
00133 const long maxNbTrialSinceBest=0);
00152 void SetAlgorithmParallTempering(const AnnealingSchedule scheduleTemp,
00153 const double tMax, const double tMin,
00154 const AnnealingSchedule scheduleMutation=ANNEALING_CONSTANT,
00155 const double mutMax=16., const double mutMin=.125);
00156
00160 void Optimize(long &nbSteps);
00161
00162
00163
00164
00166
00168
00170
00172
00174
00176
00178
00180
00182
00184
00185
00186
00187
00188
00189
00193
00199 virtual double GetCostFunctionValue();
00201 void StopAfterCycle();
00203 virtual void DisplayReport();
00205 void AddRefinableObj(RefinableObj &);
00210 void AddCostFunction(RefinableObj &,const unsigned int id, const double weight=1.);
00217 virtual void XMLOutput(ostream &os,int indent=0)const;
00223 virtual void XMLInput(istream &is,const XMLCrystTag &tag);
00224
00226
00228
00230
00232
00233 protected:
00234
00248 virtual void NewConfiguration();
00249
00251 void PrepareRefParList();
00252
00254 void InitRandomSeedFromTime()const;
00255
00257 void InitOptions();
00260 void UpdateDisplay();
00261
00266 mutable RefinableObj mRefParList;
00268 string mName;
00270 string mSaveFileName;
00271
00274 RefObjOpt mGlobalOptimType;
00275
00276
00278
00280
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00294
00296
00298
00300
00302
00304
00305
00307 long mBestParSavedSetIndex;
00309 long mLastParSavedSetIndex;
00310
00311
00313
00315
00317
00318
00323
00325
00327
00329
00330
00333
00335
00340
00342
00344
00345
00346
00348
00350
00352
00354
00356
00358
00360
00361 private:
00362 #ifdef __WX__CRYST__
00363 public:
00365 virtual WXCrystObj* WXCreate(wxWindow*);
00366 WXCrystObj* WXGet();
00367 void WXDelete();
00368 void WXNotifyDelete();
00369 protected:
00370 WXGlobalOptimObj *mpWXGlobalOptimObj;
00371 friend class ObjCryst::WXGlobalOptimObj;
00372 #endif
00373 };
00374
00376 extern ObjRegistry<GlobalOptimObj> gGlobalOptimObjRegistry;
00377
00378 }
00379
00380 #endif