COPASI API  4.16.103
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
COptMethodCoranaWalk Class Reference

#include <COptMethodCoranaWalk.h>

Inheritance diagram for COptMethodCoranaWalk:
Inheritance graph
[legend]
Collaboration diagram for COptMethodCoranaWalk:
Collaboration graph
[legend]

Public Member Functions

 COptMethodCoranaWalk (const COptMethodCoranaWalk &src, const CCopasiContainer *pParent=NULL)
 
virtual bool optimise ()
 
virtual ~COptMethodCoranaWalk ()
 
- Public Member Functions inherited from COptMethod
 COptMethod (const COptMethod &src, const CCopasiContainer *pParent=NULL)
 
bool isBounded (void)
 
virtual bool isValidProblem (const CCopasiProblem *pProblem)
 
void setProblem (COptProblem *problem)
 
virtual ~COptMethod ()
 
- Public Member Functions inherited from CCopasiMethod
 CCopasiMethod (const CCopasiMethod &src, const CCopasiContainer *pParent=NULL)
 
const CCopasiMethod::SubTypegetSubType () const
 
const CCopasiTask::TypegetType () const
 
virtual void load (CReadConfig &configBuffer, CReadConfig::Mode mode=CReadConfig::SEARCH)
 
virtual void print (std::ostream *ostream) const
 
virtual void printResult (std::ostream *ostream) const
 
virtual bool setCallBack (CProcessReport *pCallBack)
 
virtual ~CCopasiMethod ()
 
- Public Member Functions inherited from CCopasiParameterGroup
bool addGroup (const std::string &name)
 
bool addParameter (const CCopasiParameter &parameter)
 
bool addParameter (const std::string &name, const CCopasiParameter::Type type)
 
template<class CType >
bool addParameter (const std::string &name, const CCopasiParameter::Type type, const CType &value)
 
void addParameter (CCopasiParameter *pParameter)
 
CCopasiParameterGroupassertGroup (const std::string &name)
 
template<class CType >
CCopasiParameterassertParameter (const std::string &name, const CCopasiParameter::Type type, const CType &defaultValue)
 
index_iterator beginIndex () const
 
name_iterator beginName () const
 
 CCopasiParameterGroup (const CCopasiParameterGroup &src, const CCopasiContainer *pParent=NULL)
 
 CCopasiParameterGroup (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &objectType="ParameterGroup")
 
void clear ()
 
virtual bool elevateChildren ()
 
index_iterator endIndex () const
 
name_iterator endName () const
 
CCopasiParameterGroupgetGroup (const std::string &name)
 
const CCopasiParameterGroupgetGroup (const std::string &name) const
 
CCopasiParameterGroupgetGroup (const size_t &index)
 
const CCopasiParameterGroupgetGroup (const size_t &index) const
 
size_t getIndex (const std::string &name) const
 
std::string getKey (const std::string &name) const
 
std::string getKey (const size_t &index) const
 
virtual const std::string & getName (const size_t &index) const
 
virtual const CObjectInterfacegetObject (const CCopasiObjectName &cn) const
 
CCopasiParametergetParameter (const std::string &name)
 
const CCopasiParametergetParameter (const std::string &name) const
 
CCopasiParametergetParameter (const size_t &index)
 
const CCopasiParametergetParameter (const size_t &index) const
 
CCopasiParameter::Type getType (const std::string &name) const
 
CCopasiParameter::Type getType (const size_t &index) const
 
std::string getUniqueParameterName (const CCopasiParameter *pParameter) const
 
const CCopasiParameter::ValuegetValue (const std::string &name) const
 
const CCopasiParameter::ValuegetValue (const size_t &index) const
 
CCopasiParameter::ValuegetValue (const std::string &name)
 
CCopasiParameter::ValuegetValue (const size_t &index)
 
CCopasiParameterGroupoperator= (const CCopasiParameterGroup &rhs)
 
bool removeParameter (const std::string &name)
 
bool removeParameter (const size_t &index)
 
template<class CType >
bool setValue (const std::string &name, const CType &value)
 
template<class CType >
bool setValue (const size_t &index, const CType &value)
 
size_t size () const
 
bool swap (const size_t &iFrom, const size_t &iTo)
 
bool swap (index_iterator &from, index_iterator &to)
 
virtual ~CCopasiParameterGroup ()
 
- Public Member Functions inherited from CCopasiParameter
 CCopasiParameter (const CCopasiParameter &src, const CCopasiContainer *pParent=NULL)
 
 CCopasiParameter (const std::string &name, const Type &type, const void *pValue=NULL, const CCopasiContainer *pParent=NULL, const std::string &objectType="Parameter")
 
virtual CCopasiObjectName getCN () const
 
virtual const std::string & getKey () const
 
virtual std::string getObjectDisplayName (bool regular=true, bool richtext=false) const
 
const CCopasiParameter::TypegetType () const
 
const ValuegetValue () const
 
ValuegetValue ()
 
virtual voidgetValuePointer () const
 
CCopasiObjectgetValueReference () const
 
bool isValidValue (const C_FLOAT64 &value) const
 
bool isValidValue (const C_INT32 &value) const
 
bool isValidValue (const unsigned C_INT32 &value) const
 
bool isValidValue (const bool &value) const
 
bool isValidValue (const std::string &value) const
 
bool isValidValue (const CCopasiObjectName &value) const
 
bool isValidValue (const std::vector< CCopasiParameter * > &value) const
 
CCopasiParameteroperator= (const CCopasiParameter &rhs)
 
template<class CType >
bool setValue (const CType &value)
 
bool setValue (const std::vector< CCopasiParameter * > &value)
 
virtual ~CCopasiParameter ()
 
- Public Member Functions inherited from CCopasiContainer
virtual bool add (CCopasiObject *pObject, const bool &adopt=true)
 
 CCopasiContainer (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=CCopasiObject::Container)
 
 CCopasiContainer (const CCopasiContainer &src, const CCopasiContainer *pParent=NULL)
 
virtual std::string getChildObjectUnits (const CCopasiObject *pObject) const
 
virtual const objectMapgetObjects () const
 
virtual std::string getUnits () const
 
virtual const CCopasiObjectgetValueObject () const
 
virtual bool remove (CCopasiObject *pObject)
 
virtual ~CCopasiContainer ()
 
- Public Member Functions inherited from CCopasiObject
void addDirectDependency (const CCopasiObject *pObject)
 
 CCopasiObject (const CCopasiObject &src, const CCopasiContainer *pParent=NULL)
 
void clearDirectDependencies ()
 
void clearRefresh ()
 
bool dependsOn (DataObjectSet candidates, const DataObjectSet &context=DataObjectSet()) const
 
void getAllDependencies (DataObjectSet &dependencies, const DataObjectSet &context) const
 
virtual const DataObjectSetgetDirectDependencies (const DataObjectSet &context=DataObjectSet()) const
 
CCopasiContainergetObjectAncestor (const std::string &type) const
 
CCopasiDataModelgetObjectDataModel ()
 
const CCopasiDataModelgetObjectDataModel () const
 
const std::string & getObjectName () const
 
CCopasiContainergetObjectParent () const
 
const std::string & getObjectType () const
 
virtual const
CObjectInterface::ObjectSet
getPrerequisites () const
 
virtual RefreshgetRefresh () const
 
UpdateMethodgetUpdateMethod () const
 
bool hasCircularDependencies (DataObjectSet &candidates, DataObjectSet &verified, const DataObjectSet &context) const
 
bool hasUpdateMethod () const
 
bool isArray () const
 
bool isContainer () const
 
bool isDataModel () const
 
bool isMatrix () const
 
bool isNameVector () const
 
bool isNonUniqueName () const
 
virtual bool isPrerequisiteForContext (const CObjectInterface *pObject, const CMath::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const
 
bool isReference () const
 
bool isRoot () const
 
bool isSeparator () const
 
bool isStaticString () const
 
bool isValueBool () const
 
bool isValueDbl () const
 
bool isValueInt () const
 
bool isValueInt64 () const
 
bool isValueString () const
 
bool isVector () const
 
virtual bool mustBeDeleted (const DataObjectSet &deletedObjects) const
 
void removeDirectDependency (const CCopasiObject *pObject)
 
void setDirectDependencies (const DataObjectSet &directDependencies)
 
bool setObjectName (const std::string &name)
 
virtual bool setObjectParent (const CCopasiContainer *pParent)
 
void setObjectValue (const C_FLOAT64 &value)
 
void setObjectValue (const C_INT32 &value)
 
void setObjectValue (const bool &value)
 
template<class CType >
void setRefresh (CType *pType, void(CType::*method)(void))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_FLOAT64 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_INT32 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const bool &))
 
virtual ~CCopasiObject ()
 
- Public Member Functions inherited from CObjectInterface
 CObjectInterface ()
 
virtual ~CObjectInterface ()
 

Private Member Functions

virtual bool cleanup ()
 
 COptMethodCoranaWalk (const CCopasiContainer *pParent=NULL)
 
const C_FLOAT64evaluate ()
 
virtual bool initialize ()
 
void initObjects ()
 

Private Attributes

CVector< size_t > mAccepted
 
C_FLOAT64 mBestValue
 
bool mContinue
 
CVector< C_FLOAT64mCurrent
 
unsigned C_INT32 mCurrentIteration
 
C_FLOAT64 mCurrentValue
 
C_FLOAT64 mEvaluationValue
 
size_t mhIterations
 
unsigned C_INT32 mIterations
 
CRandommpRandom
 
CVector< C_FLOAT64mStep
 
C_FLOAT64 mTemperature
 
size_t mVariableSize
 

Friends

COptMethodCOptMethod::createMethod (CCopasiMethod::SubType subType)
 

Additional Inherited Members

- Public Types inherited from CCopasiMethod
enum  SubType {
  unset = 0, RandomSearch, RandomSearchMaster, SimulatedAnnealing,
  CoranaWalk, DifferentialEvolution, ScatterSearch, GeneticAlgorithm,
  EvolutionaryProgram, SteepestDescent, HybridGASA, GeneticAlgorithmSR,
  HookeJeeves, LevenbergMarquardt, NelderMead, SRES,
  Statistics, ParticleSwarm, Praxis, TruncatedNewton,
  Newton, deterministic, LSODAR, directMethod,
  stochastic, tauLeap, adaptiveSA, hybrid,
  hybridLSODA, hybridODE45, DsaLsodar, tssILDM,
  tssILDMModified, tssCSP, mcaMethodReder, scanMethod,
  lyapWolf, sensMethod, EFMAlgorithm, EFMBitPatternTreeAlgorithm,
  EFMBitPatternAlgorithm, Householder, crossSectionMethod, linearNoiseApproximation
}
 
- Public Types inherited from CCopasiParameterGroup
typedef parameterGroup::iterator index_iterator
 
typedef
CCopasiContainer::objectMap::iterator 
name_iterator
 
typedef std::vector
< CCopasiParameter * > 
parameterGroup
 
- Public Types inherited from CCopasiParameter
enum  Type {
  DOUBLE = 0, UDOUBLE, INT, UINT,
  BOOL, GROUP, STRING, CN,
  KEY, FILE, EXPRESSION, INVALID
}
 
- Public Types inherited from CCopasiContainer
typedef std::multimap
< std::string, CCopasiObject * > 
objectMap
 
- Public Types inherited from CCopasiObject
typedef std::set< const
CCopasiObject * > 
DataObjectSet
 
typedef std::vector< Refresh * > DataUpdateSequence
 
- Public Types inherited from CObjectInterface
typedef std::set< const
CObjectInterface * > 
ObjectSet
 
typedef std::vector
< CObjectInterface * > 
UpdateSequence
 
- Static Public Member Functions inherited from COptMethod
static COptMethodcreateMethod (CCopasiMethod::SubType subType=CCopasiMethod::RandomSearch)
 
- Static Public Member Functions inherited from CCopasiObject
static std::vector< Refresh * > buildUpdateSequence (const DataObjectSet &objects, const DataObjectSet &uptoDateObjects, const DataObjectSet &context=DataObjectSet())
 
static void setRenameHandler (CRenameHandler *rh)
 
- Static Public Attributes inherited from CCopasiMethod
static const std::string SubTypeName []
 
static const char * XMLSubType []
 
- Static Public Attributes inherited from CCopasiParameter
static const std::string TypeName []
 
static const char * XMLType []
 
- Static Public Attributes inherited from CCopasiContainer
static const std::vector
< CCopasiContainer * > 
EmptyList
 
- Protected Types inherited from CCopasiObject
enum  Flag {
  Container = 0x1, Vector = 0x2, Matrix = 0x4, NameVector = 0x8,
  Reference = 0x10, ValueBool = 0x20, ValueInt = 0x40, ValueInt64 = 0x80,
  ValueDbl = 0x100, NonUniqueName = 0x200, StaticString = 0x400, ValueString = 0x800,
  Separator = 0x1000, ModelEntity = 0x2000, Array = 0x4000, DataModel = 0x8000,
  Root = 0x10000, Gui = 0x20000
}
 
- Protected Member Functions inherited from COptMethod
 COptMethod (const CCopasiTask::Type &taskType, const SubType &subType, const CCopasiContainer *pParent=NULL)
 
- Protected Member Functions inherited from CCopasiMethod
 CCopasiMethod (const CCopasiTask::Type &taskType, const SubType &subType, const CCopasiContainer *pParent=NULL)
 
- Protected Member Functions inherited from CCopasiParameterGroup
 CCopasiParameterGroup ()
 
- Protected Member Functions inherited from CCopasiContainer
template<class CType >
CCopasiObjectaddMatrixReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddObjectReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddVectorReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
void initObjects ()
 
- Protected Member Functions inherited from CCopasiObject
 CCopasiObject ()
 
 CCopasiObject (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=0)
 
- Protected Attributes inherited from COptMethod
const bool mBounds
 
const std::vector< COptItem * > * mpOptContraints
 
const std::vector< COptItem * > * mpOptItem
 
COptProblemmpOptProblem
 
COptTaskmpParentTask
 
const std::vector
< UpdateMethod * > * 
mpSetCalculateVariable
 
- Protected Attributes inherited from CCopasiMethod
CProcessReportmpCallBack
 
- Protected Attributes inherited from CCopasiParameter
std::string mKey
 
CCopasiObjectmpValueReference
 
size_t mSize
 
Value mValue
 
- Protected Attributes inherited from CCopasiContainer
objectMap mObjects
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

Detailed Description

Definition at line 31 of file COptMethodCoranaWalk.h.

Constructor & Destructor Documentation

COptMethodCoranaWalk::COptMethodCoranaWalk ( const COptMethodCoranaWalk src,
const CCopasiContainer pParent = NULL 
)

Copy Constructor

Parameters
constCOptMethodCoranaWalk & src
constCCopasiContainer * pParent (default: NULL)

Definition at line 38 of file COptMethodCoranaWalk.cpp.

References initObjects().

39  :
40  COptMethod(src, pParent)
41 {initObjects();}
COptMethodCoranaWalk::~COptMethodCoranaWalk ( )
virtual

Destructor

Definition at line 43 of file COptMethodCoranaWalk.cpp.

References cleanup().

44 {cleanup();}
COptMethodCoranaWalk::COptMethodCoranaWalk ( const CCopasiContainer pParent = NULL)
private

Default Constructor

Parameters
constCCopasiContainer * pParent (default: NULL)

Definition at line 27 of file COptMethodCoranaWalk.cpp.

References CCopasiParameterGroup::addParameter(), C_FLOAT64, C_INT32, initObjects(), CRandom::mt19937, CCopasiParameter::UDOUBLE, and CCopasiParameter::UINT.

27  :
29 {
30  addParameter("Temperature", CCopasiParameter::UDOUBLE, (C_FLOAT64) 1.0);
31  addParameter("Iterations", CCopasiParameter::UINT, (unsigned C_INT32) 100);
32  addParameter("Random Number Generator", CCopasiParameter::UINT, (unsigned C_INT32) CRandom::mt19937);
33  addParameter("Seed", CCopasiParameter::UINT, (unsigned C_INT32) 0);
34 
35  initObjects();
36 }
#define C_INT32
Definition: copasi.h:90
#define C_FLOAT64
Definition: copasi.h:92
bool addParameter(const CCopasiParameter &parameter)

Member Function Documentation

bool COptMethodCoranaWalk::cleanup ( )
privatevirtual

Cleanup arrays and pointers.

Returns
bool success

Reimplemented from COptMethod.

Definition at line 245 of file COptMethodCoranaWalk.cpp.

Referenced by initialize(), and ~COptMethodCoranaWalk().

246 {
247  return true;
248 }
const C_FLOAT64 & COptMethodCoranaWalk::evaluate ( )
private

Evaluate the objective function

Returns
bool continue

Definition at line 250 of file COptMethodCoranaWalk.cpp.

References COptProblem::calculate(), COptProblem::checkFunctionalConstraints(), COptProblem::getCalculateValue(), mContinue, mEvaluationValue, and COptMethod::mpOptProblem.

Referenced by optimise().

251 {
252  // We do not need to check whether the parametric constraints are fulfilled
253  // since the parameters are created within the bounds.
254 
257 
258  // When we leave the either functional domain
259  // we set the objective value +Inf
261  mEvaluationValue = std::numeric_limits<C_FLOAT64>::infinity();
262 
263  return mEvaluationValue;
264 }
COptProblem * mpOptProblem
Definition: COptMethod.h:56
virtual bool calculate()
virtual bool checkFunctionalConstraints()
const C_FLOAT64 & getCalculateValue() const
bool COptMethodCoranaWalk::initialize ( )
privatevirtual

Initialize arrays and pointer.

Returns
bool success

Reimplemented from COptMethod.

Definition at line 266 of file COptMethodCoranaWalk.cpp.

References CProcessReport::addItem(), cleanup(), CRandom::createGenerator(), CCopasiParameter::getValue(), COptMethod::initialize(), mAccepted, mBestValue, mContinue, mCurrent, mCurrentIteration, mhIterations, mIterations, CCopasiMethod::mpCallBack, COptMethod::mpOptItem, mpRandom, mStep, mTemperature, mVariableSize, CCopasiParameter::Value::pUDOUBLE, CCopasiParameter::Value::pUINT, and CVector< CType >::resize().

Referenced by optimise().

267 {
268  cleanup();
269 
270  if (!COptMethod::initialize()) return false;
271 
272  mTemperature = * getValue("Temperature").pUDOUBLE;
273  mIterations = * getValue("Iterations").pUINT;
274  mpRandom =
275  CRandom::createGenerator(* (CRandom::Type *) getValue("Random Number Generator").pUINT,
276  * getValue("Seed").pUINT);
277 
278  mCurrentIteration = 0;
279 
280  if (mpCallBack)
281  mhIterations =
282  mpCallBack->addItem("Iterations",
284 
285  mBestValue = std::numeric_limits<C_FLOAT64>::infinity();
286  mContinue = true;
287 
288  mVariableSize = mpOptItem->size();
289 
293 
294  return true;
295 }
unsigned C_INT32 mIterations
virtual bool initialize()
Definition: COptMethod.cpp:189
unsigned C_INT32 mCurrentIteration
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
static CRandom * createGenerator(CRandom::Type type=CRandom::mt19937, unsigned C_INT32 seed=0)
Definition: CRandom.cpp:49
size_t addItem(const std::string &name, const std::string &value, const std::string *pEndValue=NULL)
const Value & getValue() const
CVector< size_t > mAccepted
unsigned C_INT32 * pUINT
const std::vector< COptItem * > * mpOptItem
Definition: COptMethod.h:70
CVector< C_FLOAT64 > mCurrent
CVector< C_FLOAT64 > mStep
CProcessReport * mpCallBack
void COptMethodCoranaWalk::initObjects ( )
private

Initialize contained objects.

Definition at line 46 of file COptMethodCoranaWalk.cpp.

References CCopasiContainer::addObjectReference(), mCurrentIteration, and CCopasiObject::ValueInt.

Referenced by COptMethodCoranaWalk().

47 {
49 }
unsigned C_INT32 mCurrentIteration
CCopasiObject * addObjectReference(const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
bool COptMethodCoranaWalk::optimise ( void  )
virtual

Execute the optimization algorithm calling simulation routine when needed. It is noted that this procedure can give feedback of its progress by the callback function set with SetCallback. @ return success;

Reimplemented from COptMethod.

Definition at line 51 of file COptMethodCoranaWalk.cpp.

References C_FLOAT64, COptItem::checkConstraint(), COptProblem::checkFunctionalConstraints(), COptProblem::checkParametricConstraints(), COutputInterface::DURING, evaluate(), CProcessReport::finishItem(), COptItem::getLowerBoundValue(), CRandom::getRandomCC(), CRandom::getRandomCO(), COptProblem::getSolutionVariables(), COptItem::getStartValue(), COptItem::getUpperBoundValue(), initialize(), K, mAccepted, max, mBestValue, mContinue, mCurrent, mCurrentIteration, mCurrentValue, mEvaluationValue, mhIterations, mIterations, CCopasiMethod::mpCallBack, COptMethod::mpOptProblem, COptMethod::mpParentTask, mpRandom, COptMethod::mpSetCalculateVariable, mStep, mTemperature, mVariableSize, NS, CCopasiTask::output(), CProcessReport::progressItem(), and COptProblem::setSolution().

52 {
53  if (!initialize())
54  {
55  if (mpCallBack)
57 
58  return false;
59  }
60 
61  size_t i, j;
62 
63  size_t h, a;
64  C_FLOAT64 xc, p, c, New, minstep;
65  bool processing;
66 
67  // set the minimum step size as being the average of step sizes
68  // or 100*DBL_EPSILON if average is zero
69  for (i = 0, minstep = 0.0; i < mVariableSize; i++)
70  {
71  minstep += mCurrent[i];
72  }
73 
74  if (minstep > std::numeric_limits< C_FLOAT64 >::epsilon())
75  minstep /= i;
76  else
77  minstep = 100 * std::numeric_limits< C_FLOAT64 >::epsilon();
78 
79  // initial point is first guess but we have to make sure that we
80  // are within the parameter domain
81  for (i = 0; i < mVariableSize; i++)
82  {
83  const COptItem & OptItem = *(*mpOptItem)[i];
84 
85  switch (OptItem.checkConstraint(OptItem.getStartValue()))
86  {
87  case - 1:
88  mCurrent[i] = *OptItem.getLowerBoundValue();
89  break;
90 
91  case 1:
92  mCurrent[i] = *OptItem.getUpperBoundValue();
93  break;
94 
95  case 0:
96  mCurrent[i] = OptItem.getStartValue();
97  break;
98  }
99 
100  (*(*mpSetCalculateVariable)[i])(mCurrent[i]);
101 
102  // The step must not contain any zeroes
103  mStep[i] = std::max(fabs(mCurrent[i]), minstep);
104  }
105 
106  // find the objective function value at the start
108  // count it
109  mCurrentIteration = 1;
110 
111  if (!isnan(mEvaluationValue))
112  {
113  // and store that value
116 
117  // We found a new best value lets report it.
119 
120  if (mpCallBack)
122  }
123 
124  mAccepted = 0;
125 
126  processing = true; // we want to do some work
127 
128  do
129  {
130  for (j = 0; j < NS && mContinue && processing; j++) // adjustment in all directions
131  {
132  for (h = 0; h < mVariableSize && mContinue && processing; h++) // adjustment in one direction
133  {
134  // Calculate the step
135  xc = (2.0 * mpRandom->getRandomCC() - 1) * mStep[h];
136  New = mCurrent[h] + xc;
137 
138  // Set the new parameter value
139  (*(*mpSetCalculateVariable)[h])(New);
140 
141  // Check all parametric constraints
143  {
144  // Undo since not accepted
145  (*(*mpSetCalculateVariable)[h])(mCurrent[h]);
146  continue;
147  }
148 
149  // evaluate the function
150  evaluate();
151  // count it
153 
154  if (mpCallBack)
156 
157  // Check all functional constraints
159  {
160  // Undo since not accepted
161  (*(*mpSetCalculateVariable)[h])(mCurrent[h]);
162 
163  continue;
164  }
165 
166  // here we have a completely feasible point
167  // keep if energy is reduced
169  {
170  // only one value has changed...
171  mCurrent[h] = New;
173  i++; // a new point
174  mAccepted[h]++; // a new point in this coordinate
175 
177  {
178  // and store that value
181 
182  // We found a new best value lets report it.
184  }
185  }
186  else
187  {
188  // keep with probability p, if energy is increased
189  p = exp((mCurrentValue - mEvaluationValue) / (K * mTemperature));
190 
191  if (p > mpRandom->getRandomCO())
192  {
193  // only one value has changed...
194  mCurrent[h] = New;
196  i++; // a new point
197  mAccepted[h]++; // a new point in this coordinate
198  }
199  else
200  // Undo since not accepted
201  (*(*mpSetCalculateVariable)[h])(mCurrent[h]);
202  }
203 
204  // check if it is time to stop
205  if (mCurrentIteration == mIterations) processing = false;
206  }
207  }
208 
209  // update the step sizes
210  for (a = 0; a < mVariableSize; a++)
211  {
212  c = (C_FLOAT64) mAccepted[a] / (C_FLOAT64) NS;
213 
214  if (c > 0.6)
215  mStep[a] *= 1 + 5 * (c - 0.6);
216  else if (c < 0.4)
217  mStep[a] /= 1 + 5 * (0.4 - c);
218 
219  mAccepted[a] = 0;
220  }
221 
222  // the equilibrium energy
223 
224  if (processing)
225  {
227 
228  for (a = 0; a < mVariableSize; a++)
229  (*(*mpSetCalculateVariable)[a])(mCurrent[a]);
230 
232  }
233 
234  if (mpCallBack)
236  }
237  while (processing && mContinue);
238 
239  if (mpCallBack)
241 
242  return true;
243 }
unsigned C_INT32 mIterations
virtual C_INT32 checkConstraint() const
Definition: COptItem.cpp:401
COptTask * mpParentTask
Definition: COptMethod.h:58
#define K
unsigned C_INT32 mCurrentIteration
COptProblem * mpOptProblem
Definition: COptMethod.h:56
virtual void output(const COutputInterface::Activity &activity)
virtual bool progressItem(const size_t &handle)
virtual C_FLOAT64 getRandomCC()
Definition: CRandom.cpp:235
const std::vector< UpdateMethod * > * mpSetCalculateVariable
Definition: COptMethod.h:65
const C_FLOAT64 * getLowerBoundValue() const
Definition: COptItem.h:191
CVector< size_t > mAccepted
const CVector< C_FLOAT64 > & getSolutionVariables() const
virtual bool setSolution(const C_FLOAT64 &value, const CVector< C_FLOAT64 > &variables)
virtual bool finishItem(const size_t &handle)
virtual bool checkFunctionalConstraints()
const C_FLOAT64 & getStartValue() const
Definition: COptItem.cpp:199
virtual C_FLOAT64 getRandomCO()
Definition: CRandom.cpp:245
#define C_FLOAT64
Definition: copasi.h:92
CVector< C_FLOAT64 > mCurrent
const C_FLOAT64 * getUpperBoundValue() const
Definition: COptItem.h:198
CVector< C_FLOAT64 > mStep
const C_FLOAT64 & evaluate()
virtual bool checkParametricConstraints()
#define NS
CProcessReport * mpCallBack
#define max(a, b)
Definition: f2c.h:176

Friends And Related Function Documentation

Member Data Documentation

CVector< size_t > COptMethodCoranaWalk::mAccepted
private

The number of accepted steps

Definition at line 154 of file COptMethodCoranaWalk.h.

Referenced by initialize(), and optimise().

C_FLOAT64 COptMethodCoranaWalk::mBestValue
private

The best value found so far

Definition at line 124 of file COptMethodCoranaWalk.h.

Referenced by initialize(), and optimise().

bool COptMethodCoranaWalk::mContinue
private

Flag indicating whether the computation shall continue

Definition at line 134 of file COptMethodCoranaWalk.h.

Referenced by evaluate(), initialize(), and optimise().

CVector< C_FLOAT64 > COptMethodCoranaWalk::mCurrent
private

The current solution guess

Definition at line 139 of file COptMethodCoranaWalk.h.

Referenced by initialize(), and optimise().

unsigned C_INT32 COptMethodCoranaWalk::mCurrentIteration
private

The current iteration

Definition at line 109 of file COptMethodCoranaWalk.h.

Referenced by initialize(), initObjects(), and optimise().

C_FLOAT64 COptMethodCoranaWalk::mCurrentValue
private

The result of a function evaluation for mCurrent

Definition at line 144 of file COptMethodCoranaWalk.h.

Referenced by optimise().

C_FLOAT64 COptMethodCoranaWalk::mEvaluationValue
private

The result of a function evaluation

Definition at line 129 of file COptMethodCoranaWalk.h.

Referenced by evaluate(), and optimise().

size_t COptMethodCoranaWalk::mhIterations
private

Handle to the process report item "iterations"

Definition at line 99 of file COptMethodCoranaWalk.h.

Referenced by initialize(), and optimise().

unsigned C_INT32 COptMethodCoranaWalk::mIterations
private

number of iterations

Definition at line 104 of file COptMethodCoranaWalk.h.

Referenced by initialize(), and optimise().

CRandom* COptMethodCoranaWalk::mpRandom
private

a pointer to the randomnumber generator.

Definition at line 114 of file COptMethodCoranaWalk.h.

Referenced by initialize(), and optimise().

CVector< C_FLOAT64 > COptMethodCoranaWalk::mStep
private

The step taken

Definition at line 149 of file COptMethodCoranaWalk.h.

Referenced by initialize(), and optimise().

C_FLOAT64 COptMethodCoranaWalk::mTemperature
private

The current temperature

Definition at line 94 of file COptMethodCoranaWalk.h.

Referenced by initialize(), and optimise().

size_t COptMethodCoranaWalk::mVariableSize
private

number of parameters

Definition at line 119 of file COptMethodCoranaWalk.h.

Referenced by initialize(), and optimise().


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