FOX/ObjCryst++  1.10.X (development)
RefinableObj.cpp
1 /* ObjCryst++ Object-Oriented Crystallographic Library
2  (c) 2000-2002 Vincent Favre-Nicolin vincefn@users.sourceforge.net
3  2000-2001 University of Geneva (Switzerland)
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 /*
20 * source file for the RefinablePar and RefinableObj classes
21 *
22 */
23 #include <ctime>
24 #include "ObjCryst/RefinableObj/RefinableObj.h"
25 #include "ObjCryst/Quirks/VFNStreamFormat.h"
26 #include "ObjCryst/Quirks/VFNDebug.h"
27 #ifdef __WX__CRYST__
28  #include "ObjCryst/wxCryst/wxRefinableObj.h"
29  #undef GetClassName // Conflict from wxMSW headers ? (cygwin)
30 #endif
31 #include <algorithm>
32 
33 #define POSSIBLY_UNUSED(expr) (void)(expr);
34 
35 namespace ObjCryst
36 {
37 //######################################################################
38 //
39 // RefParType
40 //
41 //######################################################################
42 RefParType::RefParType(const string &name):
43 mpParent(0),mName(name),mId(0)
44 {
45  this->InitId();
46 }
47 
48 RefParType::RefParType(const RefParType *parent,const string &name):
49 mpParent(parent),mName(name),mId(0)
50 {
51  this->InitId();
52 }
53 
55 
57 {
58  VFN_DEBUG_MESSAGE("RefParType::IsDescendantFromOrSameAs(RefParType*): "<<this<<" : "<<mpParent,1)
59  if(type->mId==mId) return true;
60  if(0==mpParent) return false;
61  return mpParent->IsDescendantFromOrSameAs(type);
62 }
63 
64 bool RefParType::operator==(const RefParType *type) const
65 {
66  if(this==type) return true;
67  return false;
68 }
69 const string& RefParType::GetName() const{ return mName;}
70 
72 {
73  static unsigned long nbRefParType=0;
74  mId=nbRefParType++;
75 }
76 
78 long NiftyStaticGlobalObjectsInitializer_RefinableObj::mCount=0;
79 //######################################################################
80 //
81 //
82 //
83 //######################################################################
84 
85 unsigned long RefinableObjClock::msTick0=0;
86 unsigned long RefinableObjClock::msTick1=0;
87 RefinableObjClock::RefinableObjClock()
88 {
89  //this->Click();
90  mTick0=0;
91  mTick1=0;
92 }
93 RefinableObjClock::~RefinableObjClock()
94 {
95  // first copy & clear sets to avoid possible loops in RemoveChild()
96  set<const RefinableObjClock*> vChild=mvChild;
97  set<RefinableObjClock*> vParent=mvParent;
98  mvChild.clear();
99  mvParent.clear();
100  for(std::set<const RefinableObjClock*>::iterator pos=vChild.begin();
101  pos!=vChild.end();++pos) (*pos)->RemoveParent(*this);
102  for(std::set<RefinableObjClock*>::iterator pos=vParent.begin();
103  pos!=vParent.end();++pos) (*pos)->RemoveChild(*this);
104 }
105 
106 bool RefinableObjClock::operator< (const RefinableObjClock &rhs)const
107 {
108  if(mTick1<rhs.mTick1) return true;
109  if(mTick1==rhs.mTick1) {if(mTick0<rhs.mTick0) return true;}
110  return false;
111 }
112 bool RefinableObjClock::operator<=(const RefinableObjClock &rhs)const
113 {
114  if(mTick1<rhs.mTick1) return true;
115  if(mTick1==rhs.mTick1) if(mTick0<=rhs.mTick0) return true;
116  return false;
117 }
118 bool RefinableObjClock::operator> (const RefinableObjClock &rhs)const
119 {
120  if(mTick1>rhs.mTick1) return true;
121  if(mTick1==rhs.mTick1) if(mTick0>rhs.mTick0) return true;
122  return false;
123 }
124 bool RefinableObjClock::operator>=(const RefinableObjClock &rhs)const
125 {
126  if(mTick1>rhs.mTick1) return true;
127  if(mTick1==rhs.mTick1) if(mTick0>=rhs.mTick0) return true;
128  return false;
129 }
131 {
132  //return;
133  if(++msTick0==0) ++msTick1;//Update ObjCryst++ static event counter
134  mTick0=msTick0;
135  mTick1=msTick1;
136  for(std::set<RefinableObjClock*>::iterator pos=mvParent.begin();
137  pos!=mvParent.end();++pos) (*pos)->Click();
138  VFN_DEBUG_MESSAGE("RefinableObjClock::Click():"<<mTick1<<":"<<mTick0<<"(at "<<this<<")",0)
139  //this->Print();
140 }
142 {
143  mTick0=0;
144  mTick1=0;
145 }
147 {
148  cout <<"Clock():"<<mTick1<<":"<<mTick0;
149  VFN_DEBUG_MESSAGE_SHORT(" (at "<<this<<")",4)
150  cout <<endl;
151 }
153 {
154  cout <<"RefinableObj class Clock():"<<msTick1<<":"<<msTick0<<endl;
155 }
157 {mvChild.insert(&clock);clock.AddParent(*this);this->Click();}
159 {
160  const unsigned int i = mvChild.erase(&clock); POSSIBLY_UNUSED(i);
161  VFN_DEBUG_MESSAGE("RefinableObjClock::RemoveChild():"<<i,5)
162  clock.RemoveParent(*this);
163  this->Click();
164 }
166 {
167  // First check for loop
168  if(&clock==this)
169  throw ObjCrystException("RefinableObjClock::AddParent(..) child == Parent !!");
170  if(clock.HasParent(*this)==true)
171  throw ObjCrystException("RefinableObjClock::AddParent(..) Loop in clock tree !!");
172  mvParent.insert(&clock);
173 }
175 {
176  // avoid warnings about unused i when not debugging.
177  const unsigned int i = mvParent.erase(&clock); POSSIBLY_UNUSED(i);
178  VFN_DEBUG_MESSAGE("RefinableObjClock::RemoveParent():"<<i,5)
179 }
180 
182 {
183  mTick0=rhs.mTick0;
184  mTick1=rhs.mTick1;
185  for(std::set<RefinableObjClock*>::iterator pos=mvParent.begin();
186  pos!=mvParent.end();++pos) if( (*this) > (**pos) ) **pos = *this;
187 }
188 
189 bool RefinableObjClock::HasParent(const RefinableObjClock &clock) const
190 {
191  for(std::set<RefinableObjClock*>::iterator pos=mvParent.begin();
192  pos!=mvParent.end();++pos)
193  {
194  if((*pos)==&clock) return true;
195  if((*pos)->HasParent(clock)) return true;
196  }
197  return false;
198 }
199 //######################################################################
200 // Restraint
201 //######################################################################
203 mpRefParType(gpRefParTypeObjCryst)
204 {}
205 
207 mpRefParType(type)
208 {}
209 
210 Restraint::~Restraint()
211 {}
212 
213 const RefParType* Restraint::GetType()const{return mpRefParType;}
214 
215 void Restraint::SetType(const RefParType *type){mpRefParType=type;}
216 
217 REAL Restraint::GetLogLikelihood()const{return 0.;}
218 
219 //######################################################################
220 // RefinablePar
221 //######################################################################
222 
224 Restraint(),
225 mName(""),mpValue(0),mMin(0),mMax(0),
226 mHasLimits(false),mIsFixed(true),mIsUsed(true),mIsPeriodic(false),
227 mPeriod(0.),mGlobalOptimStep(1.),mDerivStep(1e-5),mRefParDerivStepModel(REFPAR_DERIV_STEP_ABSOLUTE),
228 mSigma(0.),mHumanScale(1.),mHasAssignedClock(false),mpClock(0)
229 #ifdef __WX__CRYST__
230 ,mpWXFieldRefPar(0)
231 #endif
232 {}
233 
234 RefinablePar::RefinablePar( const string &name,
235  REAL *refPar,
236  const REAL min,
237  const REAL max,
238  const RefParType *type,
239  RefParDerivStepModel derivMode,
240  const bool hasLimits,
241  const bool isFixed,
242  const bool isUsed,
243  const bool isPeriodic,
244  const REAL humanScale,
245  REAL period):
246 Restraint(type),
247 mName(name),mpValue(refPar),mMin(min),mMax(max),
248 mHasLimits(hasLimits),mIsFixed(isFixed),mIsUsed(isUsed),mIsPeriodic(isPeriodic),mPeriod(period),
249 mGlobalOptimStep((max-min)/100.),mDerivStep(1e-5),mRefParDerivStepModel(derivMode),
250 mSigma(0.),mHumanScale(humanScale),
251 #if 0
252 mUseEquation(false),mEquationNbRefPar(0),mEquationCoeff(0),
253 #endif
254 mHasAssignedClock(false),mpClock(0)
255 #ifdef __WX__CRYST__
256 ,mpWXFieldRefPar(0)
257 #endif
258 {}
259 
260 RefinablePar::~RefinablePar()
261 {
262  #ifdef __WX__CRYST__
263  this->WXDelete();
264  #endif
265 }
266 
267 void RefinablePar::Init(const string &name,
268  REAL *refPar,
269  const REAL min,
270  const REAL max,
271  const RefParType *type,
272  RefParDerivStepModel derivMode,
273  const bool hasLimits,
274  const bool isFixed,
275  const bool isUsed,
276  const bool isPeriodic,
277  const REAL humanScale,
278  REAL period)
279 {
280  mName=name;
281  mpValue=refPar;
282  mMin=min;
283  mMax=max;
284  Restraint::SetType(type);
285  mHasLimits=hasLimits;
286  mIsFixed=isFixed;
287  mIsUsed=isUsed;
288  mIsPeriodic=isPeriodic;
289  mPeriod=period;
290  mGlobalOptimStep=(max-min)/100.;
291  mDerivStep=1e-5;
292  mRefParDerivStepModel=derivMode;
293  mSigma=0.;
294  mHumanScale=humanScale;
295  #if 0
296  mUseEquation=false;
297  mEquationNbRefPar=0;
298  mEquationCoeff=0;
299  #endif
300  mHasAssignedClock=false;
301  mpClock=0;
302 }
304 Restraint(old)
305 {
306  mpValue=old.mpValue;
307  #ifdef __WX__CRYST__
308  mpWXFieldRefPar=0;
309  #endif
310  this->CopyAttributes(old);
312  mpClock=old.mpClock;
313 }
314 
316 {
317  mName=old.mName;
318  mMin=old.GetMin();
319  mMax=old.GetMax();
321  mIsFixed=old.mIsFixed;
322  mIsUsed=old.mIsUsed;
324  mPeriod=old.mPeriod;
328  mSigma=old.mSigma;
330  #if 0
331  mUseEquation=old.mUseEquation;
332  mEquationNbRefPar=old.mEquationNbRefPar;
333  mEquationCoeff=old.mEquationCoeff;
334  #endif
335 }
336 
338 {
339  #if 0
340  if(true==mUseEquation)
341  {
342  VFN_DEBUG_MESSAGE("RefinablePar::Value():Evaluating Equation",0)
343  REAL tmp=mEquationCoeff(0);
344  for(int i=0;i<mEquationNbRefPar;i++)
345  tmp += mEquationCoeff(i+1) * mEquationRefPar[i]->GetValue();
346  *mpValue = tmp;
347  }
348  #endif
349  return *mpValue;
350 }
351 
352 const REAL* RefinablePar::GetPointer()const
353 {
354  return mpValue;
355 }
356 
357 void RefinablePar::SetValue(const REAL value)
358 {
359  if(*mpValue == value) return;
360  this->Click();
361  VFN_DEBUG_MESSAGE("RefinablePar::SetValue()",2)
362  #if 0
363  if(true==mUseEquation)
364  {
365  cout << "RefinablePar::SetValue(): this parameter is defined by an equation !!" <<endl;
366  throw 0;
367  }
368  #endif
369  *mpValue = value;
370  /*
371  if(this->IsLimited() ==true)
372  {
373  if(true==this->IsPeriodic())
374  {
375  if(*mpValue > this->GetMax()) *mpValue -= this->GetMax()-this->GetMin();
376  if(*mpValue < this->GetMin()) *mpValue += this->GetMax()-this->GetMin();
377  }
378  else
379  {
380  if(*mpValue > this->GetMax()) *mpValue=this->GetMax();
381  if(*mpValue < this->GetMin()) *mpValue=this->GetMin();
382  }
383  }
384  */
385  if(this->IsLimited() ==true)
386  {
387  if(*mpValue > this->GetMax()) *mpValue=this->GetMax();
388  if(*mpValue < this->GetMin()) *mpValue=this->GetMin();
389  }
390  else if(true==this->IsPeriodic())
391  {
392  if(*mpValue > mPeriod) *mpValue -= mPeriod;
393  if(*mpValue < 0) *mpValue += mPeriod;
394  }
395 }
396 
397 const REAL& RefinablePar::GetHumanValue() const
398 {
399  static REAL val;
400  val = *mpValue * mHumanScale;
401  return val;
402 }
403 
404 void RefinablePar::SetHumanValue(const REAL &value)
405 {
406  if(*mpValue == (value/mHumanScale)) return;
407  this->Click();
408  VFN_DEBUG_MESSAGE("RefinablePar::SetHumanValue()",2)
409  #if 0
410  if(true==mUseEquation)
411  {
412  cout << "RefinablePar::SetValue(): this parameter is defined by an equation !!" <<endl;
413  throw 0;
414  }
415  #endif
416  *mpValue = value/mHumanScale;
417  /*
418  if(this->IsLimited() ==true)
419  {
420  if(true==this->IsPeriodic())
421  {
422  if(*mpValue > this->GetMax()) *mpValue -= this->GetMax()-this->GetMin();
423  if(*mpValue < this->GetMin()) *mpValue += this->GetMax()-this->GetMin();
424  }
425  else
426  {
427  if(*mpValue > this->GetMax()) *mpValue=this->GetMax();
428  if(*mpValue < this->GetMin()) *mpValue=this->GetMin();
429  }
430  }
431  */
432  if(this->IsLimited() ==true)
433  {
434  if(*mpValue > this->GetMax()) *mpValue=this->GetMax();
435  if(*mpValue < this->GetMin()) *mpValue=this->GetMin();
436  }
437  else if(true==this->IsPeriodic())
438  {
439  if(*mpValue > mPeriod) *mpValue -= mPeriod;
440  if(*mpValue < 0) *mpValue += mPeriod;
441  }
442 }
443 
444 void RefinablePar::Mutate(const REAL mutateValue)
445 {
446  if(0==mutateValue) return;
447  VFN_DEBUG_MESSAGE("RefinablePar::Mutate():"<<this->GetName(),1)
448  if(true==mIsFixed) return;
449  this->Click();
450  #if 0
451  if(true==mUseEquation)
452  {
453  cout << "RefinablePar::Mutate(): this parameter is defined by an equation !!" <<endl;
454  throw 0;
455  }
456  #endif
457  *mpValue += mutateValue;
458  /*
459  if(this->IsLimited() ==true)
460  {
461  if(true==this->IsPeriodic())
462  {
463  if(*mpValue > this->GetMax()) *mpValue -= this->GetMax()-this->GetMin();
464  if(*mpValue < this->GetMin()) *mpValue += this->GetMax()-this->GetMin();
465  }
466  else
467  {
468  if(*mpValue > this->GetMax()) *mpValue=this->GetMax();
469  if(*mpValue < this->GetMin()) *mpValue=this->GetMin();
470  }
471  }
472  */
473  if(this->IsLimited() ==true)
474  {
475  if(*mpValue > this->GetMax()) *mpValue=this->GetMax();
476  if(*mpValue < this->GetMin()) *mpValue=this->GetMin();
477  }
478  else if(true==this->IsPeriodic())
479  {
480  //if(*mpValue > mPeriod) *mpValue -= mPeriod;
481  *mpValue=fmod((REAL)*mpValue,(REAL)mPeriod);
482  if(*mpValue < 0) *mpValue += mPeriod;
483  }
484  VFN_DEBUG_MESSAGE("RefinablePar::Mutate():End",0)
485 }
486 
487 void RefinablePar::MutateTo(const REAL mutateValue)
488 {
489  VFN_DEBUG_MESSAGE("RefinablePar::MutateTo()",2)
490  if(true==mIsFixed) return;
491  if(*mpValue == mutateValue)return;
492  this->Click();
493  #if 0
494  if(true==mUseEquation)
495  {
496  cout << "RefinablePar::Mutate(): this parameter is defined by an equation !!" <<endl;
497  throw 0;
498  }
499  #endif
500  *mpValue = mutateValue;
501  /*
502  if(this->IsLimited() ==true)
503  {
504  if(true==this->IsPeriodic())
505  {
506  if(*mpValue > this->GetMax()) *mpValue -= this->GetMax()-this->GetMin();
507  if(*mpValue < this->GetMin()) *mpValue += this->GetMax()-this->GetMin();
508  }
509  else
510  {
511  if(*mpValue > this->GetMax()) *mpValue=this->GetMax();
512  if(*mpValue < this->GetMin()) *mpValue=this->GetMin();
513  }
514  }
515  */
516  if(this->IsLimited() ==true)
517  {
518  if(*mpValue > this->GetMax()) *mpValue=this->GetMax();
519  if(*mpValue < this->GetMin()) *mpValue=this->GetMin();
520  }
521  else if(true==this->IsPeriodic())
522  {
523  if(*mpValue > mPeriod) *mpValue -= mPeriod;
524  if(*mpValue < 0) *mpValue += mPeriod;
525  }
526 }
527 
528 REAL RefinablePar::GetSigma()const {return mSigma;}
529 REAL RefinablePar::GetHumanSigma()const {return mSigma*mHumanScale;}
530 void RefinablePar::SetSigma(const REAL sigma) {mSigma=sigma; this->Click();}
531 
532 void RefinablePar::Print() const
533 {
534  cout << this->GetName() << " : " << this->GetHumanValue()
535  << " Fixed:"<< mIsFixed <<" Periodic:"<<mIsPeriodic<<" Limited:"<<mHasLimits
536  << " Min:" << this->GetHumanMin() << " Max:" << this->GetHumanMax()
537  << " Step:" <<GetGlobalOptimStep()
538  #ifdef __DEBUG__
539  << ",HasClock=" << mHasAssignedClock << " at " << mpClock
540  #endif
541  <<endl;
542 }
543 
544 string RefinablePar::GetName()const {return mName;}
545 void RefinablePar::SetName(const string &name) {mName=name;}
546 
547 bool RefinablePar::IsFixed()const {return mIsFixed;}
548 void RefinablePar::SetIsFixed(const bool b)
549 {
550  VFN_DEBUG_MESSAGE("RefinablePar::SetIsFixed():"<<this->GetName(),1)
551  mIsFixed=b;
552 }
553 
554 bool RefinablePar::IsLimited()const {return mHasLimits;}
555 void RefinablePar::SetIsLimited(const bool b) {mHasLimits=b;this->Click();}
556 
557 bool RefinablePar::IsUsed()const {return mIsUsed;}
558 void RefinablePar::SetIsUsed(const bool b) {mIsUsed=b;this->Click();}
559 
560 bool RefinablePar::IsPeriodic()const {return mIsPeriodic;}
561 void RefinablePar::SetIsPeriodic(const bool b,REAL period)
562 {mIsPeriodic=b;mPeriod=period;this->Click();}
563 
564 
565 REAL RefinablePar::GetMin()const {return mMin;}
566 void RefinablePar::SetMin(const REAL min) { mMin=min;this->Click();}
568 void RefinablePar::SetHumanMin(const REAL min) { mMin=min/mHumanScale;this->Click();}
569 
570 REAL RefinablePar::GetMax()const {return mMax;}
571 void RefinablePar::SetMax(const REAL max) { mMax=max;this->Click();}
572 REAL RefinablePar::GetHumanMax()const {return mMax * mHumanScale;}
573 void RefinablePar::SetHumanMax(const REAL max) { mMax=max/mHumanScale;this->Click();}
574 
575 REAL RefinablePar::GetPeriod()const {return mPeriod;}
576 void RefinablePar::SetPeriod(const REAL period)
577 { mPeriod=period;this->Click();}
578 
580 {
581  if(REFPAR_DERIV_STEP_ABSOLUTE==mRefParDerivStepModel) return mDerivStep;
582  REAL d=mDerivStep* (*mpValue);
583 
584  //:KLUDGE: Parameter will probably has a singular value, so it should not matter..
585  if(d == 0.) return 1e-8;
586  return d;
587 }
588 
589 void RefinablePar::SetDerivStep(const REAL step)
590 {
591  this->Click();
592  mDerivStep = step;
593 }
594 
597 
599 void RefinablePar::SetHumanScale(const REAL scale) {mHumanScale=scale;}
600 #if 0
601 void RefinablePar::SetUseEquation(const bool useItOrNot,const REAL c0)
602 {
603  this->Click();
604  mUseEquation=useItOrNot;
605  if(true==mUseEquation)
606  {
607  mEquationCoeff.resize(mEquationMaxRefPar);
608  mEquationCoeff(0)=c0;
609  }
610 }
611 
612 void RefinablePar::SetUseEquation(const bool useItOrNot,const REAL c0,
613  const REAL c1, const RefinablePar &refpar1)
614 {
615  this->Click();
616  mUseEquation=useItOrNot;
617  if(true==mUseEquation)
618  {
619  mEquationCoeff.resize(mEquationMaxRefPar);
620  mEquationCoeff(0)=c0;
621  mEquationCoeff(1)=c1;
622  mEquationRefPar[0]=&refpar1;
623  }
624 }
625 
626 void RefinablePar::SetUseEquation(const bool useItOrNot,const REAL c0,
627  const REAL c1, const RefinablePar &refpar1,
628  const REAL c2, const RefinablePar &refpar2)
629 {
630  this->Click();
631  mUseEquation=useItOrNot;
632  if(true==mUseEquation)
633  {
634  mEquationCoeff.resize(mEquationMaxRefPar);
635  mEquationCoeff(0)=c0;
636  mEquationCoeff(1)=c1;
637  mEquationCoeff(2)=c2;
638  mEquationRefPar[0]=&refpar1;
639  mEquationRefPar[1]=&refpar2;
640  }
641 }
642 
643 void RefinablePar::SetUseEquation(const bool useItOrNot,const REAL c0,
644  const REAL c1, const RefinablePar &refpar1,
645  const REAL c2, const RefinablePar &refpar2,
646  const REAL c3, const RefinablePar &refpar3)
647 {
648  this->Click();
649  mUseEquation=useItOrNot;
650  if(true==mUseEquation)
651  {
652  mEquationCoeff.resize(mEquationMaxRefPar);
653  mEquationCoeff(0)=c0;
654  mEquationCoeff(1)=c1;
655  mEquationCoeff(2)=c2;
656  mEquationCoeff(3)=c2;
657  mEquationRefPar[0]=&refpar1;
658  mEquationRefPar[1]=&refpar2;
659  mEquationRefPar[2]=&refpar2;
660  }
661 }
662 #endif
664 {
665  VFN_DEBUG_MESSAGE("RefinablePar::AssignClock() for "<<this->GetName()<< "at "<<&clock,4)
666  mpClock=&clock;
667  mHasAssignedClock=true;
668 }
670 {
671  if(false==mHasAssignedClock) return;
672  VFN_DEBUG_MESSAGE("RefinablePar::Click():"<<this->GetName(),1)
673  mpClock->Click();
674  //mpClock->Print();
675  //VFN_DEBUG_MESSAGE("RefinablePar::Click():End",2)
676 }
677 
678 void RefinablePar::SetLimitsAbsolute(const REAL min, const REAL max)
679 {
680  //:TODO: check limits
681  mMin=min;
682  mMax=max;
683  mHasLimits=true;
684 }
685 void RefinablePar::SetLimitsRelative(const REAL min, const REAL max)
686 {
687  VFN_DEBUG_MESSAGE("RefinablePar::SetLimitsRelative():"<<this->GetName(),1)
688  //:TODO: check limits
689  mMin=this->GetValue()+min;
690  mMax=this->GetValue()+max;
691  this->SetIsLimited(true);
692 }
693 void RefinablePar::SetLimitsProportional(const REAL min, const REAL max)
694 {
695  //:TODO: check limits
696  mMin=this->GetValue()*min;
697  mMax=this->GetValue()*max;
698  this->SetIsLimited(true);
699 }
700 #ifdef __WX__CRYST__
701 WXCrystObjBasic* RefinablePar::WXCreate(wxWindow *parent)
702 {
703  VFN_DEBUG_MESSAGE("RefinablePar::WXCreate()",8)
704  if(mpWXFieldRefPar!=0)
705  {
706  throw ObjCrystException((string)"RefinablePar::WXCreate():"+this->GetName()+(string)" WXFieldRefPar already exists !");
707  }
708  mpWXFieldRefPar=new WXFieldRefPar (parent,this->GetName(),this);
709  return (WXCrystObjBasic*) mpWXFieldRefPar;
710 }
711 WXCrystObjBasic* RefinablePar::WXGet()
712 {
713  return (WXCrystObjBasic*) mpWXFieldRefPar;
714 }
715 void RefinablePar::WXDelete()
716 {
717  if(0!=mpWXFieldRefPar)
718  {
719  VFN_DEBUG_MESSAGE("RefinablePar::WXDelete():"<<mName,5)
720  delete mpWXFieldRefPar;
721  }
722  mpWXFieldRefPar=0;
723 }
724 void RefinablePar::WXNotifyDelete()
725 {
726  VFN_DEBUG_MESSAGE("RefinablePar::WXNotifyDelete():"<<mName,5)
727  mpWXFieldRefPar=0;
728 }
729 #endif
730 
731 //######################################################################
732 // RefObjOpt
733 //######################################################################
735 {
736  #ifdef __WX__CRYST__
737  mpWXFieldOption=0;
738  #endif
739 }
740 
741 RefObjOpt::~RefObjOpt()
742 {}
743 
744 void RefObjOpt::Init(const int nbChoice,
745  const string *name,
746  const string *choiceNames)
747 {
748  VFN_DEBUG_MESSAGE("RefObjOpt::Init()"<<*name,5)
749  mNbChoice=nbChoice;
750  mChoice=0;
751  mpName=name;
752  mpChoiceName=choiceNames;
753 }
754 
755 int RefObjOpt::GetNbChoice()const
756 { return mNbChoice;}
757 
758 int RefObjOpt::GetChoice()const
759 { return mChoice;}
760 
761 void RefObjOpt::SetChoice(const int choice)
762 {
763  if(mChoice==choice)return;
764  VFN_DEBUG_MESSAGE("RefObjOpt::SetChoice()"<<this->GetName()<< \
765  " to "<<this->GetChoiceName(choice),5)
766  mChoice=choice;
767  mClock.Click();
768 }
769 void RefObjOpt::SetChoice(const string &choiceName)
770 {
771  int choice;
772  for(choice=0;choice<mNbChoice;choice++) if(choiceName==*(mpChoiceName+choice)) break;
773  if(choice==mNbChoice) choice=0;
774  this->SetChoice(choice);
775 }
776 
777 const string& RefObjOpt::GetName()const
778 {
779  return *mpName;
780 }
781 
782 const string& RefObjOpt::GetClassName()const
783 {
784  static string className="Option";
785  return className;
786 }
787 
788 const string& RefObjOpt::GetChoiceName(const int i)const
789 {
790  return *(mpChoiceName+i);
791 }
792 
793 const RefinableObjClock& RefObjOpt::GetClock()const{return mClock;}
794 
795 #ifdef __WX__CRYST__
796 WXCrystObjBasic* RefObjOpt::WXCreate(wxWindow *parent)
797 {
798  VFN_DEBUG_MESSAGE("RefObjOpt::WXCreate()",8)
799  mpWXFieldOption=new WXFieldOption (parent,-1,this);
800  return mpWXFieldOption;
801 }
802 WXCrystObjBasic* RefObjOpt::WXGet()
803 {
804  return mpWXFieldOption;
805 }
806 void RefObjOpt::WXDelete()
807 {
808  if(0!=mpWXFieldOption)
809  {
810  VFN_DEBUG_MESSAGE("RefObjOpt::WXDelete()",5)
811  delete mpWXFieldOption;
812  }
813  mpWXFieldOption=0;
814 }
815 void RefObjOpt::WXNotifyDelete()
816 {
817  VFN_DEBUG_MESSAGE("RefObjOpt::WXNotifyDelete()",5)
818  mpWXFieldOption=0;
819 }
820 #endif
821 
822 //######################################################################
823 // RefObjOption
824 //######################################################################
825 template<class T> RefObjOption<T>::RefObjOption(T* obj):
826 mpObj(obj)
827 {}
828 
829 template<class T> RefObjOption<T>::~RefObjOption()
830 {}
831 
832 template<class T> void RefObjOption<T>::SetChoice(const int choice)
833 {
834  if(mChoice==choice)return;
835  VFN_DEBUG_MESSAGE("RefObjOption<T>::SetChoice()"<<this->GetName()<< \
836  " to "<<this->GetChoiceName(choice),5)
837  mChoice=choice;
838  mClock.Click();
839  if(mfpSetNewValue !=0) (mpObj->*mfpSetNewValue)(choice);
840 }
841 
842 template<class T> void RefObjOption<T>::Init(const int nbChoice,
843  const string *name,
844  const string *choiceNames,
845  void (T::*fp)(const int))
846 {
847  this->RefObjOpt::Init(nbChoice,name,choiceNames);
848  mfpSetNewValue=fp;
849 }
850 
851 //######################################################################
852 // ObjRegistry
853 //######################################################################
854 #ifdef __WX__CRYST__
855 bool operator==(const wxString&wx,const string&str)
856 {
857  return wx==str.c_str();
858 }
859 bool operator==(const string&str,const wxString&wx)
860 {
861  return wx==str.c_str();
862 }
863 #endif
864 
865 template<class T> ObjRegistry<T>::ObjRegistry():
866 mName(""),mAutoUpdateUI(true)
867 #ifdef __WX__CRYST__
868 ,mpWXRegistry(0)
869 #endif
870 {
871  VFN_DEBUG_MESSAGE("ObjRegistry::ObjRegistry()",5)
872 }
873 
874 template<class T> ObjRegistry<T>::ObjRegistry(const string &name):
875 mName(name),mAutoUpdateUI(true)
876 #ifdef __WX__CRYST__
877 ,mpWXRegistry(0)
878 #endif
879 {
880  VFN_DEBUG_MESSAGE("ObjRegistry::ObjRegistry(name):"<<mName,5)
881 }
882 
883 //:TODO: a copy constructor
884 template<class T> ObjRegistry<T>::~ObjRegistry()
885 {
886  VFN_DEBUG_MESSAGE("ObjRegistry::~ObjRegistry():"<<mName,5)
887  #ifdef __WX__CRYST__
888  this->WXDelete();
889  #endif
890 }
891 
892 template<class T> void ObjRegistry<T>::Register(T &obj)
893 {
894  VFN_DEBUG_ENTRY("ObjRegistry("<<mName<<")::Register():"<<obj.GetName(),2)
895  typename vector<T*>::iterator pos=find(mvpRegistry.begin(),mvpRegistry.end(),&obj);
896  if(pos!=mvpRegistry.end())
897  {
898  VFN_DEBUG_EXIT("ObjRegistry("<<mName<<")::Register():"<<obj.GetName()<<"Already registered!",2)
899  return;
900  }
901  mvpRegistry.push_back(&obj);
902  mListClock.Click();
903  #ifdef __WX__CRYST__
904  if((0!=mpWXRegistry) && mAutoUpdateUI)
905  mpWXRegistry->Add(obj.WXCreate(mpWXRegistry));
906  #endif
907  //this->Print();
908  VFN_DEBUG_EXIT("ObjRegistry("<<mName<<")::Register():"<<obj.GetName(),2)
909 }
910 
911 template<class T> void ObjRegistry<T>::DeRegister(T &obj)
912 {
913  VFN_DEBUG_ENTRY("ObjRegistry("<<mName<<")::Deregister(&obj)"<<mvpRegistry.size(),2)
914  if (mvpRegistry.size() == 0)
915  {// This may happen if an object is deleted several times due to inherited destructors
916  // :TODO: make sure it does not happen, while making sure WXGet() below
917  //is not pure virtual because the child destructor has already done its job...
918  VFN_DEBUG_EXIT("ObjRegistry(" << mName << ")::Deregister(&obj): EMPTY registry", 2)
919  return;
920  }
921  //this->Print();
922  typename vector<T*>::iterator pos=find(mvpRegistry.begin(),mvpRegistry.end(),&obj);
923  if(pos==mvpRegistry.end())
924  {
925  VFN_DEBUG_EXIT("ObjRegistry("<<mName<<")::Deregister(&obj):NOT FOUND !!!",2)
926  return; //:TODO: throw something ?
927  }
928  #ifdef __WX__CRYST__
929  if(0!=mpWXRegistry) mpWXRegistry->Remove(obj.WXGet());
930  #endif
931  mvpRegistry.erase(pos);
932  mListClock.Click();
933  VFN_DEBUG_EXIT("ObjRegistry("<<mName<<")::Deregister(&obj)",2)
934 }
935 
936 template<class T> void ObjRegistry<T>::DeRegister(const string &objName)
937 {
938  VFN_DEBUG_ENTRY("ObjRegistry("<<mName<<")::Deregister(name):"<<objName,2)
939 
940  const long i=this->Find(objName);
941  if(-1==i)
942  {
943  VFN_DEBUG_EXIT("ObjRegistry("<<mName<<")::Deregister(name): NOT FOUND !!!",2)
944  return; //:TODO: throw something ?
945  }
946  //:KLUDGE: should directly do an iterator search on the name...
947  typename vector<T*>::iterator pos=find(mvpRegistry.begin(),mvpRegistry.end(),mvpRegistry[i]);
948 
949  #ifdef __WX__CRYST__
950  if(0!=mpWXRegistry) mpWXRegistry->Remove((*pos)->WXGet());
951  #endif
952  mvpRegistry.erase(pos);
953  mListClock.Click();
954  VFN_DEBUG_EXIT("ObjRegistry("<<mName<<")::Deregister(name):",2)
955 }
956 
957 template<class T> void ObjRegistry<T>::DeRegisterAll()
958 {
959  VFN_DEBUG_ENTRY("ObjRegistry("<<mName<<")::DeRegisterAll():",5)
960  #ifdef __WX__CRYST__
961  if(0!=mpWXRegistry)
962  {
963  typename vector<T*>::iterator pos;
964  for(pos=mvpRegistry.begin();pos!=mvpRegistry.end();++pos)
965  mpWXRegistry->Remove((*pos)->WXGet());
966  }
967  #endif
968  mvpRegistry.clear();
969  mListClock.Click();
970  VFN_DEBUG_EXIT("ObjRegistry("<<mName<<")::DeRegisterAll():",5)
971 }
972 
973 template<class T> void ObjRegistry<T>::DeleteAll()
974 {
975  VFN_DEBUG_ENTRY("ObjRegistry("<<mName<<")::DeleteAll():",5)
976  vector<T*> reg=mvpRegistry;//mvpRegistry will be modified as objects are deleted, so use a copy
977  typename vector<T*>::iterator pos;
978  for(pos=reg.begin();pos!=reg.end();++pos) delete *pos;
979  mvpRegistry.clear();
980  mListClock.Click();
981  VFN_DEBUG_EXIT("ObjRegistry("<<mName<<")::DeleteAll():",5)
982 }
983 
984 template<class T> T& ObjRegistry<T>::GetObj(const unsigned int i)
985 {
986  return *(mvpRegistry[i]);
987 }
988 
989 template<class T> const T& ObjRegistry<T>::GetObj(const unsigned int i) const
990 {
991  return *(mvpRegistry[i]);
992 }
993 
994 template<class T> T& ObjRegistry<T>::GetObj(const string &objName)
995 {
996  const long i=this->Find(objName);
997  return *(mvpRegistry[i]);
998 }
999 
1000 template<class T> const T& ObjRegistry<T>::GetObj(const string &objName) const
1001 {
1002  const long i=this->Find(objName);
1003  return *(mvpRegistry[i]);
1004 }
1005 
1006 template<class T> T& ObjRegistry<T>::GetObj(const string &objName,
1007  const string& className)
1008 {
1009  const long i=this->Find(objName,className);
1010  return *(mvpRegistry[i]);
1011 }
1012 
1013 template<class T> const T& ObjRegistry<T>::GetObj(const string &objName,
1014  const string& className) const
1015 {
1016  const long i=this->Find(objName,className);
1017  return *(mvpRegistry[i]);
1018 }
1019 
1020 template<class T> long ObjRegistry<T>::GetNb()const{return (long)mvpRegistry.size();}
1021 
1022 template<class T> void ObjRegistry<T>::Print()const
1023 {
1024  VFN_DEBUG_MESSAGE("ObjRegistry::Print():",2)
1025  cout <<mName<<" :"<<this->GetNb()<<" object registered:" <<endl;
1026 
1027  for(long i=0;i<this->GetNb();++i)
1028  cout <<i<<"("<<this->GetObj(i).GetName()<<")"<<endl;
1029 }
1030 
1031 template<class T> void ObjRegistry<T>::SetName(const string &name){ mName=name;}
1032 
1033 template<class T> const string& ObjRegistry<T>::GetName()const { return mName;}
1034 
1035 template<class T> long ObjRegistry<T>::Find(const string &objName) const
1036 {
1037  VFN_DEBUG_MESSAGE("ObjRegistry::Find(objName)",2)
1038  long index=-1;
1039  //bool error=false;
1040  for(long i=this->GetNb()-1;i>=0;i--)
1041  if( mvpRegistry[i]->GetName() == objName) return i;
1042  // if(-1 != index) error=true ;else index=i;
1043  //if(true == error)
1044  //{
1045  // cout << "ObjRegistry::Find(name) : ";
1046  // cout << "found duplicate name ! This *cannot* be !!" ;
1047  // cout << objName <<endl;
1048  // this->Print();
1049  // throw 0;
1050  //}
1051  cout << "ObjRegistry<T>::Find("<<objName<<"): Not found !!"<<endl;
1052  this->Print();
1053  throw ObjCrystException("ObjRegistry<T>::Find("+objName+"): Not found !!");
1054  return index;
1055 }
1056 
1057 template<class T> long ObjRegistry<T>::Find(const string &objName,
1058  const string &className,
1059  const bool nothrow) const
1060 {
1061  VFN_DEBUG_MESSAGE("ObjRegistry::Find(objName,className)",2)
1062  long index=-1;
1063  //bool error=false;
1064  for(long i=this->GetNb()-1;i>=0;i--)
1065  if( mvpRegistry[i]->GetName() == objName)
1066  if(className==mvpRegistry[i]->GetClassName()) return i;
1067  // if(-1 != index) error=true ;else index=i;
1068  //if(true == error)
1069  //{
1070  // cout << "ObjRegistry::Find(name) : ";
1071  // cout << "found duplicate name ! This *cannot* be !!" ;
1072  // cout << objName <<endl;
1073  // this->Print();
1074  // throw 0;
1075  //}
1076  cout << "ObjRegistry<T>::Find("<<objName<<","<<className<<"): Not found !!"<<endl;
1077  this->Print();
1078  if(nothrow==false)
1079  throw ObjCrystException("ObjRegistry<T>::Find("+objName+","+className+"): Not found !!");
1080  return index;
1081 }
1082 
1083 template<class T> long ObjRegistry<T>::Find(const T &obj) const
1084 {
1085  VFN_DEBUG_MESSAGE("ObjRegistry::Find(&obj)",2)
1086  for(long i=this->GetNb()-1;i>=0;i--)
1087  if( mvpRegistry[i]== &obj) return i;
1088  //:TODO: throw something
1089  return -1;
1090 }
1091 
1092 template<class T> long ObjRegistry<T>::Find(const T *pobj) const
1093 {
1094  VFN_DEBUG_MESSAGE("ObjRegistry::Find(&obj)",2)
1095  for(long i=this->GetNb()-1;i>=0;i--)
1096  if( mvpRegistry[i]== pobj) return i;
1097  //:TODO: throw something
1098  return -1;
1099 }
1100 
1101 template<class T> const RefinableObjClock& ObjRegistry<T>::GetRegistryClock()const{return mListClock;}
1102 
1103 template<class T> void ObjRegistry<T>::AutoUpdateUI(const bool autoup)
1104 {
1105  mAutoUpdateUI=autoup;
1106 }
1107 
1108 template<class T> void ObjRegistry<T>::UpdateUI()
1109 {
1110  #ifdef __WX__CRYST__
1111  for(unsigned int i=0;i<this->GetNb();i++)
1112  {
1113  if((this->GetObj(i).WXGet()==NULL) && (0!=mpWXRegistry))
1114  mpWXRegistry->Add(this->GetObj(i).WXCreate(mpWXRegistry));
1115  }
1116  #endif
1117 }
1118 
1119 #ifdef __WX__CRYST__
1120 template<class T> WXRegistry<T>* ObjRegistry<T>::WXCreate(wxWindow *parent)
1121 {
1122  VFN_DEBUG_MESSAGE("ObjRegistry<T>::WXCreate()",2)
1123  mpWXRegistry=new WXRegistry<T> (parent,this);
1124  for(int i=0;i<this->GetNb();i++)
1125  mpWXRegistry->Add(this->GetObj(i).WXCreate(mpWXRegistry));
1126  return mpWXRegistry;
1127 }
1128 template<class T> void ObjRegistry<T>::WXDelete()
1129 {
1130  if(0!=mpWXRegistry)
1131  {
1132  VFN_DEBUG_MESSAGE("ObjRegistry<T>::WXDelete()",2)
1133  delete mpWXRegistry;
1134  }
1135  mpWXRegistry=0;
1136 }
1137 template<class T> void ObjRegistry<T>::WXNotifyDelete()
1138 {
1139  VFN_DEBUG_MESSAGE("ObjRegistry<T>::WXNotifyDelete()",2)
1140  mpWXRegistry=0;
1141 }
1142 #endif
1143 
1144 //######################################################################
1145 // function RefObjRegisterRecursive
1146 //######################################################################
1147 template<class T> void RefObjRegisterRecursive(T &obj,ObjRegistry<T> &reg)
1148 {
1149  VFN_DEBUG_MESSAGE("RefObjRegisterRecursive()",3)
1150  reg.Register(obj);
1151  ObjRegistry<T> *pObjReg=&(obj.GetSubObjRegistry());
1152  for(int i=0;i<pObjReg->GetNb();i++)
1153  RefObjRegisterRecursive(pObjReg->GetObj(i),reg);
1154  return;
1155 }
1156 //######################################################################
1157 // function RefObjRegisterRecursive
1158 //######################################################################
1159 
1161 {
1162  if(reg.GetRegistryClock()>clock) clock=reg.GetRegistryClock();
1163  for(int i=0;i<reg.GetNb();i++)
1165 }
1166 
1167 //######################################################################
1168 // RefinableObj
1169 //######################################################################
1170 
1171 ObjRegistry<RefinableObj> gRefinableObjRegistry("Global RefinableObj registry");
1172 ObjRegistry<RefinableObj> gTopRefinableObjRegistry("Global Top RefinableObj registry");
1173 
1175 mName(""),
1176 mNbRefParNotFixed(-1),mOptimizationDepth(0),mDeleteRefParInDestructor(true)
1177 #ifdef __WX__CRYST__
1178 ,mpWXCrystObj(0)
1179 #endif
1180 {
1181  VFN_DEBUG_MESSAGE("RefinableObj::RefinableObj()",3)
1182  gRefinableObjRegistry.Register(*this);
1183  mSubObjRegistry.SetName("Registry for sub-objects");
1184  mClientObjRegistry.SetName("Registry for Clients");
1185 
1186  VFN_DEBUG_MESSAGE("RefinableObj::RefinableObj():End",2)
1187 }
1188 RefinableObj::RefinableObj(const bool internalUseOnly):
1189 mName(""),
1190 mNbRefParNotFixed(-1),mOptimizationDepth(0),mDeleteRefParInDestructor(true)
1191 #ifdef __WX__CRYST__
1192 ,mpWXCrystObj(0)
1193 #endif
1194 {
1195  VFN_DEBUG_MESSAGE("RefinableObj::RefinableObj(bool)",3)
1196  if(false==internalUseOnly) gRefinableObjRegistry.Register(*this);
1197  mSubObjRegistry.SetName("Registry for sub-objects");
1198  mClientObjRegistry.SetName("Registry for Clients");
1199 
1200  VFN_DEBUG_MESSAGE("RefinableObj::RefinableObj(bool):End",2)
1201 }
1202 
1204 /*
1205 RefinableObj::RefinableObj(const RefinableObj &old):
1206 mName(old.mName),mMaxNbRefPar(old.mMaxNbRefPar),mSavedValuesSetIsUsed(mMaxNbSavedSets),
1207 mOptimizationDepth(0),mDeleteRefParInDestructor(true)
1208 #ifdef __WX__CRYST__
1209 ,mpWXCrystObj(0)
1210 #endif
1211 {
1212  VFN_DEBUG_MESSAGE("RefinableObj::RefinableObj(RefinableObj&)",3)
1213  mpRefPar = new RefinablePar*[mMaxNbRefPar];
1214  mpSavedValuesSet = new CrystVector_REAL* [mMaxNbSavedSets];
1215  mpSavedValuesSetName = new string* [mMaxNbSavedSets];
1216  mSavedValuesSetIsUsed=false;
1217  *this=old;
1218  mSubObjRegistry.SetName("Registry for sub-objects of "+mName);
1219  mClientObjRegistry.SetName("Registry for Clients of "+mName);
1220  gRefinableObjRegistry.Register(*this);
1221 }
1222 */
1224 {
1225  VFN_DEBUG_MESSAGE("RefinableObj::~RefinableObj():"<<this->GetName(),5)
1226  if(mvpRefPar.size()>0)
1227  {
1228  if(true==mDeleteRefParInDestructor)
1229  {
1230  vector<RefinablePar*>::iterator pos;
1231  for(pos=mvpRefPar.begin();pos!=mvpRefPar.end();pos++) delete *pos;
1232  }
1233  }
1234  gRefinableObjRegistry.DeRegister(*this);
1235  for(int i=0;i<mSubObjRegistry.GetNb();i++)
1236  mSubObjRegistry.GetObj(i).DeRegisterClient(*this);
1237  VFN_DEBUG_MESSAGE("RefinableObj::~RefinableObj():End",4)
1238  #ifdef __WX__CRYST__
1239  this->WXDelete();
1240  #endif
1241 }
1242 
1243 const string& RefinableObj::GetClassName() const
1244 {
1245  const static string className="RefinableObj";
1246  return className;
1247 }
1248 
1249 const string& RefinableObj::GetName() const {return mName;}
1250 void RefinableObj::SetName(const string &name)
1251 {
1252  VFN_DEBUG_MESSAGE("RefinableObj::SetName()to :"<<name,6)
1253  mName=name;
1254  mSubObjRegistry.SetName("Registry for sub-objects of "+mName);
1255 }
1256 /*
1257 void RefinableObj::operator=(const RefinableObj &old)
1258 {
1259  VFN_DEBUG_MESSAGE("RefinableObj::operator=(RefinableObj&)",3)
1260  this->ResetParList();
1261  //this->AddPar(old);
1262  // Do not copy old saved sets
1263  //... but erase any that may be stored
1264  for(long i=0;i<mMaxNbSavedSets;i++)
1265  if(true==mSavedValuesSetIsUsed(i))
1266  {
1267  delete *(mpSavedValuesSetName+i);
1268  delete *(mpSavedValuesSet+i);
1269  }
1270  mSavedValuesSetIsUsed=false;
1271 }
1272 */
1274 {
1275  VFN_DEBUG_MESSAGE("RefinableObj::PrepareForRefinement()",5)
1277  mRefparNotFixedIndex.resize(this->GetNbPar());
1278  for(long i=0;i<this->GetNbPar();i++)
1279  if ( (this->GetPar(i).IsFixed() == false) && (this->GetPar(i).IsUsed() == true))
1280  {
1283  }
1284  //this->Print();
1285  VFN_DEBUG_MESSAGE("RefinableObj::PrepareForRefinement():End",5)
1286 }
1287 
1289 {
1290  VFN_DEBUG_ENTRY("RefinableObj("<<this->GetClassName()<<":"
1291  <<this->GetName()<<")::FixAllPar()",4)
1292  for(long i=0;i<this->GetNbPar();i++) this->GetPar(i).SetIsFixed(true);
1293  for(int i=0;i<this->GetSubObjRegistry().GetNb();i++)
1294  this->GetSubObjRegistry().GetObj(i).FixAllPar();
1295  VFN_DEBUG_EXIT("RefinableObj("<<this->GetName()<<")::FixAllPar()",4)
1296 }
1297 
1299 {
1300  for(long i=0;i<this->GetNbPar();i++) this->GetPar(i).SetIsFixed(false);
1301  for(int i=0;i<this->GetSubObjRegistry().GetNb();i++)
1302  this->GetSubObjRegistry().GetObj(i).UnFixAllPar();
1303 }
1304 
1305 void RefinableObj::SetParIsFixed(const long parIndex,const bool fix)
1306 {
1307  this->GetPar(parIndex).SetIsFixed(fix);
1308 }
1309 
1310 void RefinableObj::SetParIsFixed(const string& name,const bool fix)
1311 {
1312  for(long i=this->GetNbPar()-1;i>=0;i--)
1313  if( this->GetPar(i).GetName() == name)
1314  this->GetPar(i).SetIsFixed(fix);
1315 }
1316 
1317 void RefinableObj::SetParIsFixed(const RefParType *type,const bool fix)
1318 {
1319  for(long i=0;i<this->GetNbPar();i++)
1320  if( this->GetPar(i).GetType()->IsDescendantFromOrSameAs(type))
1321  {
1322  //cout << " Fixing ..." << this->GetPar(i).Name()<<endl;
1323  this->GetPar(i).SetIsFixed(fix);
1324  }
1325  for(int i=0;i<this->GetSubObjRegistry().GetNb();i++)
1326  this->GetSubObjRegistry().GetObj(i).SetParIsFixed(type,fix);
1327 }
1328 
1329 void RefinableObj::SetParIsUsed(const string& name,const bool use)
1330 {
1331  for(long i=this->GetNbPar()-1;i>=0;i--)
1332  if( this->GetPar(i).GetName() == name)
1333  this->GetPar(i).SetIsUsed(use);
1334 }
1335 
1336 void RefinableObj::SetParIsUsed(const RefParType *type,const bool use)
1337 {
1338  for(long i=0;i<this->GetNbPar();i++)
1339  if( this->GetPar(i).GetType()->IsDescendantFromOrSameAs(type))
1340  {
1341  //cout << " Now used (Waow!) : ..." << this->GetPar(i).Name()<<endl;
1342  this->GetPar(i).SetIsUsed(use);
1343  }
1344  for(int i=0;i<this->GetSubObjRegistry().GetNb();i++)
1345  this->GetSubObjRegistry().GetObj(i).SetParIsUsed(type,use);
1346 }
1347 
1348 long RefinableObj::GetNbPar()const { return mvpRefPar.size();}
1349 
1351 
1353 {
1354  return *(mvpRefPar[i]);
1355 }
1356 
1357 const RefinablePar& RefinableObj::GetPar(const long i) const
1358 {
1359  return *(mvpRefPar[i]);
1360 }
1361 
1362 RefinablePar& RefinableObj::GetPar(const string & name)
1363 {
1364  const long i=this->FindPar(name);
1365  if(-1==i)
1366  {
1367  this->Print();
1368  throw ObjCrystException("RefinableObj::GetPar(): cannot find parameter: "+name+" in object:"+this->GetName());
1369  }
1370  return *(mvpRefPar[i]);
1371 }
1372 
1373 const RefinablePar& RefinableObj::GetPar(const string & name) const
1374 {
1375  const long i=this->FindPar(name);
1376  if(-1==i)
1377  {
1378  this->Print();
1379  throw ObjCrystException("RefinableObj::GetPar(): cannot find parameter: "+name+" in object:"+this->GetName());
1380  }
1381  return *(mvpRefPar[i]);
1382 }
1383 
1385 {
1386  const long i=this->FindPar(p);
1387  if(-1==i)
1388  {
1389  this->Print();
1390  throw ObjCrystException("RefinableObj::GetPar(*p): cannot find parameter in object:"+this->GetName());
1391  }
1392  return *(mvpRefPar[i]);
1393 }
1394 
1395 const RefinablePar& RefinableObj::GetPar(const REAL *p) const
1396 {
1397  const long i=this->FindPar(p);
1398  if(-1==i)
1399  {
1400  this->Print();
1401  throw ObjCrystException("RefinableObj::GetPar(*p): cannot find parameter in object:"+this->GetName());
1402  }
1403  return *(mvpRefPar[i]);
1404 }
1405 
1407 {
1408  return *(mvpRefPar[mRefparNotFixedIndex(i)]);
1409 }
1410 
1411 const RefinablePar& RefinableObj::GetParNotFixed(const long i) const
1412 {
1413  return *(mvpRefPar[mRefparNotFixedIndex(i)]);
1414 }
1415 
1416 void RefinableObj::AddPar(const RefinablePar &newRefPar)
1417 {
1418  VFN_DEBUG_MESSAGE("RefinableObj::AddPar(RefPar&)",2)
1419  string name=newRefPar.GetName();
1420  long ct=0;
1421  if(this->FindPar(name)>=0)
1422  while(this->FindPar(name)!=-1)
1423  {// KLUDGE ? Extend name if another parameter already exists with the same name
1424  VFN_DEBUG_MESSAGE("RefinableObj::AddPar(): need to change name ?! -> "<<name<<","<<this->FindPar(name),10)
1425  name += "~";
1426  if(++ct==100) break;// KLUDGE, let go and hope for the best...
1427  }
1428 
1429  mvpRefPar.push_back(new RefinablePar(newRefPar));
1430  mvpRefPar.back()->SetName(name);
1432 }
1433 
1435 {
1436  VFN_DEBUG_MESSAGE("RefinableObj::AddPar(RefPar&)",2)
1437  string name=newRefPar->GetName();
1438  long ct=0;
1439  if(this->FindPar(name)>=0)
1440  while(this->FindPar(name)!=-1)
1441  {// KLUDGE ? Extend name if another parameter already exists with the same name
1442  VFN_DEBUG_MESSAGE("RefinableObj::AddPar(): need to change name ?! -> "<<name<<","<<this->FindPar(name),10)
1443  name += "~";
1444  if(++ct==100) break;// KLUDGE, let go and hope for the best...
1445  }
1446  mvpRefPar.push_back(newRefPar);
1447  mvpRefPar.back()->SetName(name);
1449 }
1450 
1451 void RefinableObj::AddPar(RefinableObj &newRefParList,const bool copyParam)
1452 {
1453  VFN_DEBUG_MESSAGE("RefinableObj::AddPar(RefParList&)" <<newRefParList.GetNbPar() ,2)
1454  RefinablePar *p;
1455  for(long i=0;i<newRefParList.GetNbPar();i++)
1456  {
1457  if(copyParam) p=new RefinablePar(newRefParList.GetPar(i));
1458  else p=&(newRefParList.GetPar(i));
1459  this->AddPar(p);
1460  }
1461 }
1462 
1463 vector<RefinablePar *>::iterator RefinableObj::RemovePar(RefinablePar *refPar)
1464 {
1465  VFN_DEBUG_MESSAGE("RefinableObj::RemovePar(RefPar&)",2)
1466  vector<RefinablePar *>::iterator pos=find(mvpRefPar.begin(),mvpRefPar.end(),refPar);
1467  if(pos==mvpRefPar.end())
1468  {
1469  throw ObjCrystException("RefinableObj::RemovePar():"+refPar->GetName()
1470  +"is not in this object:"+this->GetName());
1471  }
1472  return mvpRefPar.erase(pos);
1473 }
1474 
1475 void RefinableObj::Print() const
1476 {
1477  VFN_DEBUG_ENTRY("RefinableObj::Print()",2)
1478  cout << "Refinable Object:"<<this->GetName()
1479  <<", with " << this->GetNbPar() << " parameters" <<endl;
1480  for(int i=0;i<this->GetNbPar();i++)
1481  {
1482  if(this->GetPar(i).IsUsed() == false) continue;
1483  cout << "#"<<i<<"#" << this->GetPar(i).GetName() << ": " ;
1484  cout << FormatFloat(this->GetPar(i).GetHumanValue(),18,12) << " ";
1485  if(true == this->GetPar(i).IsFixed()) cout << "Fixed";
1486  else
1487  if(true == this->GetPar(i).IsLimited())
1488  {
1489  cout << "Limited (" << this->GetPar(i).GetHumanMin()<<","
1490  <<this->GetPar(i).GetHumanMax()<<")";
1491  if(true == this->GetPar(i).IsPeriodic()) cout << ",Periodic" ;
1492  }
1493  VFN_DEBUG_MESSAGE_SHORT(" (at "<<this->GetPar(i).mpValue<<")",5)
1494  if(true == this->GetPar(i).mHasAssignedClock)
1495  {
1496  VFN_DEBUG_MESSAGE_SHORT(" (Clock at "<<this->GetPar(i).mpClock<<")",5)
1497  }
1498  cout << endl;
1499  }
1500  VFN_DEBUG_EXIT("RefinableObj::Print()",2)
1501 }
1502 
1503 unsigned long RefinableObj::CreateParamSet(const string name) const
1504 {
1505  VFN_DEBUG_ENTRY("RefinableObj::CreateParamSet()",3)
1506  unsigned long id;
1507  for(id=0;id<=mvpSavedValuesSet.size();id++)
1508  if(mvpSavedValuesSet.end()==mvpSavedValuesSet.find(id)) break;
1509 
1510  pair< CrystVector_REAL ,string> p;
1511  p.second=name;
1512  mvpSavedValuesSet.insert(make_pair(id,p));
1513 
1514  this->SaveParamSet(id);
1515  VFN_DEBUG_MESSAGE("RefinableObj::CreateParamSet(): new parameter set with id="<<id<<" and name:"<<name,2)
1516  VFN_DEBUG_EXIT("RefinableObj::CreateParamSet()",3)
1517  return id;
1518 }
1519 
1520 void RefinableObj::ClearParamSet(const unsigned long id)const
1521 {
1522  VFN_DEBUG_ENTRY("RefinableObj::ClearParamSet()",2)
1523  mvpSavedValuesSet.erase(this->FindParamSet(id));
1524  VFN_DEBUG_EXIT("RefinableObj::ClearParamSet()",2)
1525 }
1526 
1527 void RefinableObj::SaveParamSet(const unsigned long id)const
1528 {
1529  VFN_DEBUG_MESSAGE("RefinableObj::SaveRefParSet()",2)
1530  map<unsigned long,pair<CrystVector_REAL,string> >::iterator pos=this->FindParamSet(id);
1531  pos->second.first.resize(mvpRefPar.size());
1532  REAL *p=pos->second.first.data();
1533  for(long i=0;i<this->GetNbPar();i++) *p++ = this->GetPar(i).GetValue();
1534 }
1535 
1536 void RefinableObj::RestoreParamSet(const unsigned long id)
1537 {
1538  VFN_DEBUG_MESSAGE("RefinableObj::RestoreRefParSet()",2)
1539  map<unsigned long,pair<CrystVector_REAL,string> >::iterator pos=this->FindParamSet(id);
1540  REAL *p=pos->second.first.data();
1541  for(long i=0;i<this->GetNbPar();i++)
1542  {
1543  //if( !this->GetPar(i).IsFixed() && this->GetPar(i).IsUsed())
1544  if(this->GetPar(i).IsUsed())
1545  this->GetPar(i).SetValue(*p);
1546  p++;
1547  }
1548 }
1549 
1550 const CrystVector_REAL & RefinableObj::GetParamSet(const unsigned long id)const
1551 {
1552  VFN_DEBUG_MESSAGE("RefinableObj::GetParamSet() const",2)
1553  map<unsigned long,pair<CrystVector_REAL,string> >::const_iterator pos=this->FindParamSet(id);
1554  return pos->second.first;
1555 }
1556 
1557 CrystVector_REAL & RefinableObj::GetParamSet(const unsigned long id)
1558 {
1559  VFN_DEBUG_MESSAGE("RefinableObj::GetParamSet()",2)
1560  map<unsigned long,pair<CrystVector_REAL,string> >::iterator pos=this->FindParamSet(id);
1561  return pos->second.first;
1562 }
1563 
1565  const long par)const
1566 {
1567  VFN_DEBUG_MESSAGE("RefinableObj::RefParSetNotFixedHumanValue()",0)
1568  map<unsigned long,pair<CrystVector_REAL,string> >::iterator pos=this->FindParamSet(id);
1569  return pos->second.first(mRefparNotFixedIndex(par));
1570 }
1571 
1573 {
1574  mvpSavedValuesSet.clear();
1575 }
1576 
1577 const string& RefinableObj::GetParamSetName(const unsigned long id)const
1578 {
1579  VFN_DEBUG_MESSAGE("RefinableObj::GetParamSetName()",2)
1580  map<unsigned long,pair<CrystVector_REAL,string> >::const_iterator pos=this->FindParamSet(id);
1581  return pos->second.second;
1582 }
1583 
1584 void RefinableObj::SetLimitsAbsolute(const string &name,const REAL min,const REAL max)
1585 {
1586  for(long i=this->GetNbPar()-1;i>=0;i--)
1587  if( this->GetPar(i).GetName() == name)
1588  this->GetPar(i).SetLimitsAbsolute(min,max);
1589 }
1591  const REAL min,const REAL max)
1592 {
1593  for(long i=0;i<this->GetNbPar();i++)
1594  if(this->GetPar(i).GetType()->IsDescendantFromOrSameAs(type))
1595  this->GetPar(i).SetLimitsAbsolute(min,max);
1596  for(int i=0;i<this->GetSubObjRegistry().GetNb();i++)
1597  this->GetSubObjRegistry().GetObj(i).SetLimitsAbsolute(type,min,max);
1598 }
1599 void RefinableObj::SetLimitsRelative(const string &name, const REAL min, const REAL max)
1600 {
1601  for(long i=this->GetNbPar()-1;i>=0;i--)
1602  if( this->GetPar(i).GetName() == name)
1603  this->GetPar(i).SetLimitsRelative(min,max);
1604 }
1606  const REAL min, const REAL max)
1607 {
1608  VFN_DEBUG_MESSAGE("RefinableObj::SetLimitsRelative(RefParType*):"<<this->GetName(),2)
1609  for(long i=0;i<this->GetNbPar();i++)
1610  {
1611  VFN_DEBUG_MESSAGE("RefinableObj::SetLimitsRelative(RefParType*):par #"<<i,2)
1612  if(this->GetPar(i).GetType()->IsDescendantFromOrSameAs(type))
1613  this->GetPar(i).SetLimitsRelative(min,max);
1614  }
1615  for(int i=0;i<this->GetSubObjRegistry().GetNb();i++)
1616  this->GetSubObjRegistry().GetObj(i).SetLimitsRelative(type,min,max);
1617 }
1618 void RefinableObj::SetLimitsProportional(const string &name,const REAL min,const REAL max)
1619 {
1620  for(long i=this->GetNbPar()-1;i>=0;i--)
1621  if( this->GetPar(i).GetName() == name)
1622  this->GetPar(i).SetLimitsProportional(min,max);
1623 }
1625  const REAL min, const REAL max)
1626 {
1627  for(long i=0;i<this->GetNbPar();i++)
1628  if(this->GetPar(i).GetType()->IsDescendantFromOrSameAs(type))
1629  this->GetPar(i).SetLimitsProportional(min,max);
1630  for(int i=0;i<this->GetSubObjRegistry().GetNb();i++)
1631  this->GetSubObjRegistry().GetObj(i).SetLimitsProportional(type,min,max);
1632 }
1633 void RefinableObj::SetGlobalOptimStep(const RefParType *type, const REAL step)
1634 {
1635  for(long i=0;i<this->GetNbPar();i++)
1636  if(this->GetPar(i).GetType()->IsDescendantFromOrSameAs(type))
1637  this->GetPar(i).SetGlobalOptimStep(step);
1638  for(int i=0;i<this->GetSubObjRegistry().GetNb();i++)
1639  this->GetSubObjRegistry().GetObj(i).SetGlobalOptimStep(type,step);
1640 }
1641 
1643 {return mSubObjRegistry;}
1644 
1646 {return mSubObjRegistry;}
1647 
1649 {mClientObjRegistry.Register(obj);}
1650 
1652 {mClientObjRegistry.DeRegister(obj);}
1653 
1656 
1658 
1659 extern const long ID_WXOBJ_ENABLE; //These are defined in wxCryst/wxCryst.cpp
1660 extern const long ID_WXOBJ_DISABLE;
1661 void RefinableObj::BeginOptimization(const bool allowApproximations,
1662  const bool enableRestraints)
1663 {
1665  if(mOptimizationDepth>1) return;
1666  this->Prepare();
1667  for(int i=0;i<mSubObjRegistry.GetNb();i++)
1668  mSubObjRegistry.GetObj(i).BeginOptimization(allowApproximations);
1669  #ifdef __WX__CRYST__
1670  if(0!=mpWXCrystObj)
1671  {
1672  if(true==wxThread::IsMain()) mpWXCrystObj->Enable(false);
1673  else
1674  {
1675  wxUpdateUIEvent event(ID_WXOBJ_DISABLE);
1676  wxPostEvent(mpWXCrystObj,event);
1677  }
1678  }
1679  #endif
1680 }
1681 
1683 {
1685  if(mOptimizationDepth<0) throw ObjCrystException("RefinableObj::EndOptimization(): mOptimizationDepth<0 !!");
1686 
1687  if(mOptimizationDepth>0) return;
1688  for(int i=0;i<mSubObjRegistry.GetNb();i++)
1689  mSubObjRegistry.GetObj(i).EndOptimization();
1690  #ifdef __WX__CRYST__
1691  if(0!=mpWXCrystObj)
1692  {
1693  if(true==wxThread::IsMain()) mpWXCrystObj->Enable(true);
1694  else
1695  {
1696  wxUpdateUIEvent event(ID_WXOBJ_ENABLE);
1697  wxPostEvent(mpWXCrystObj,event);
1698  }
1699  }
1700  #endif
1701 }
1702 
1704 {
1705 for(int i=0;i<mSubObjRegistry.GetNb();i++)
1706  mSubObjRegistry.GetObj(i).SetApproximationFlag(allow);
1707 }
1708 
1710 {
1711  VFN_DEBUG_ENTRY("RefinableObj::RandomizeConfiguration():"<<mName,5)
1712  this->PrepareForRefinement();
1713  for(int j=0;j<this->GetNbParNotFixed();j++)
1714  {
1715  if(true==this->GetParNotFixed(j).IsLimited())
1716  {
1717  const REAL min=this->GetParNotFixed(j).GetMin();
1718  const REAL max=this->GetParNotFixed(j).GetMax();
1719  this->GetParNotFixed(j).MutateTo(min+(max-min)*(rand()/(REAL)RAND_MAX) );
1720  }
1721  else
1722  if(true==this->GetParNotFixed(j).IsPeriodic())
1723  {
1724 
1725  this->GetParNotFixed(j).MutateTo((rand()/(REAL)RAND_MAX)
1726  * this->GetParNotFixed(j).GetPeriod());
1727  }
1728  }
1729  for(int i=0;i<this->GetSubObjRegistry().GetNb();i++)
1730  this->GetSubObjRegistry().GetObj(i).RandomizeConfiguration();
1731  VFN_DEBUG_EXIT("RefinableObj::RandomizeConfiguration():Finished",5)
1732 }
1733 
1734 void RefinableObj::GlobalOptRandomMove(const REAL mutationAmplitude,
1735  const RefParType *type)
1736 {
1737  if(mRandomMoveIsDone) return;
1738  VFN_DEBUG_ENTRY("RefinableObj::GlobalOptRandomMove()",2)
1739  for(int j=0;j<this->GetNbParNotFixed();j++)
1740  {
1741  if(this->GetParNotFixed(j).GetType()->IsDescendantFromOrSameAs(type))
1742  this->GetParNotFixed(j).Mutate( this->GetParNotFixed(j).GetGlobalOptimStep()
1743  *2*(rand()/(REAL)RAND_MAX-0.5)*mutationAmplitude);
1744  }
1745  for(int i=0;i<mSubObjRegistry.GetNb();i++)
1746  mSubObjRegistry.GetObj(i).GlobalOptRandomMove(mutationAmplitude,type);
1747  mRandomMoveIsDone=true;
1748  VFN_DEBUG_EXIT("RefinableObj::GlobalOptRandomMove()",2)
1749 }
1751 {
1752  mRandomMoveIsDone=false;
1753  for(int i=0;i<mSubObjRegistry.GetNb();i++)
1754  mSubObjRegistry.GetObj(i).BeginGlobalOptRandomMove();
1755 }
1756 
1757 unsigned int RefinableObj::GetNbLSQFunction()const{return 0;}
1758 
1760 {
1761  VFN_DEBUG_ENTRY("RefinableObj::GetLogLikelihood()",3)
1762  if(0==mvpRestraint.size())
1763  {
1764  VFN_DEBUG_EXIT("RefinableObj::GetLogLikelihood()=0",3)
1765  return 0;
1766  }
1767  VFN_DEBUG_MESSAGE("RefinableObj::GetLogLikelihood()there are restraints...",2)
1768  REAL loglike=0;
1769  vector< Restraint * >::const_iterator pos;
1770  for(pos=mvpRestraint.begin();pos!=mvpRestraint.end();pos++)
1771  {
1772  VFN_DEBUG_MESSAGE("RefinableObj::GetLogLikelihood()Restraint: "<<*pos,2)
1773  loglike+= (*pos)->GetLogLikelihood();
1774  }
1775  VFN_DEBUG_EXIT("RefinableObj::GetLogLikelihood()="<<loglike,3)
1776  return loglike;
1777 }
1778 
1779 // std::map<RefinablePar*, REAL>& RefinableObj::GetLogLikelihood_FullDeriv(std::set<RefinablePar *> &vPar)
1780 // {
1781 // //TODO
1782 // return mLogLikelihood_FullDeriv;
1783 // }
1784 
1785 const CrystVector_REAL& RefinableObj::GetLSQCalc(const unsigned int) const
1786 {
1787  throw ObjCrystException("Error: called RefinableObj::GetLSQCalc()");
1788  CrystVector_REAL *noWarning=new CrystVector_REAL;
1789  return *noWarning;
1790 }
1791 
1792 const CrystVector_REAL& RefinableObj::GetLSQObs(const unsigned int) const
1793 {
1794  throw ObjCrystException("Error: called RefinableObj::GetLSQObs()");
1795  CrystVector_REAL *noWarning=new CrystVector_REAL;
1796  return *noWarning;
1797 }
1798 
1799 const CrystVector_REAL& RefinableObj::GetLSQWeight(const unsigned int) const
1800 {
1801  throw ObjCrystException("Error: called RefinableObj::GetLSQWeight()");
1802  CrystVector_REAL *noWarning=new CrystVector_REAL;
1803  return *noWarning;
1804 }
1805 
1806 const CrystVector_REAL& RefinableObj::GetLSQDeriv(const unsigned int n, RefinablePar&par)
1807 {
1808  // By default, use numerical derivatives
1809  const REAL step=par.GetDerivStep();
1810  par.Mutate(step);
1811  mLSQDeriv =this->GetLSQCalc(n);
1812  par.Mutate(-2*step);
1813  mLSQDeriv -=this->GetLSQCalc(n);
1814  par.Mutate(step);
1815  mLSQDeriv /= step*2;
1816  return mLSQDeriv;
1817 }
1818 
1819 std::map<RefinablePar*, CrystVector_REAL> & RefinableObj::GetLSQ_FullDeriv(const unsigned int n,std::set<RefinablePar *> &vPar)
1820 {
1821  mLSQ_FullDeriv[n].clear();
1822  mLSQ_FullDeriv[n][(RefinablePar*)0]=this->GetLSQCalc(n);
1823  for(std::set<RefinablePar *>::const_iterator pos=vPar.begin();pos!=vPar.end();pos++)
1824  mLSQ_FullDeriv[n][*pos]=this->GetLSQDeriv(n,**pos);
1825 
1826  return mLSQ_FullDeriv[n];
1827 }
1828 
1830 {
1831  VFN_DEBUG_MESSAGE("RefinableObj::ResetParList()",3)
1832  if(mvpRefPar.size()>0)
1833  {
1834  if(true==mDeleteRefParInDestructor)
1835  {
1836  vector<RefinablePar*>::iterator pos;
1837  for(pos=mvpRefPar.begin();pos!=mvpRefPar.end();pos++) delete *pos;
1838  }
1839  mvpRefPar.clear();
1840  }
1841  mNbRefParNotFixed=-1;
1842 
1843  VFN_DEBUG_MESSAGE("RefinableObj::ResetParList():Deleting Saved Sets....",2)
1844  this->EraseAllParamSet();
1846  VFN_DEBUG_MESSAGE("RefinableObj::ResetParList():End.",3)
1847 }
1848 
1849 unsigned int RefinableObj::GetNbOption()const
1850 {
1851  return mOptionRegistry.GetNb();
1852 }
1853 
1854 RefObjOpt& RefinableObj::GetOption(const unsigned int i)
1855 {
1856  VFN_DEBUG_MESSAGE("RefinableObj::GetOption()"<<i,3)
1857  //:TODO: Check
1858  return mOptionRegistry.GetObj(i);
1859 }
1860 
1861 const RefObjOpt& RefinableObj::GetOption(const unsigned int i)const
1862 {
1863  //:TODO: Check
1864  return mOptionRegistry.GetObj(i);
1865 }
1866 
1868  CrystVector_uint & groupIndex,
1869  unsigned int &first) const
1870 {
1871  VFN_DEBUG_MESSAGE("RefinableObj::GetGeneGroup()",4)
1872  for(long i=0;i<obj.GetNbPar();i++)
1873  for(long j=0;j<this->GetNbPar();j++)
1874  if(&(obj.GetPar(i)) == &(this->GetPar(j))) groupIndex(i)= first++;
1875 }
1877 
1879 
1881 {
1882  vector<Restraint*>::const_iterator pos;
1883  REAL cost(0);
1884  for(pos=mvpRestraint.begin();pos != mvpRestraint.end();++pos)
1885  cost += (*pos)->GetLogLikelihood();
1886  return 0;
1887 }
1888 
1890 {
1891  VFN_DEBUG_MESSAGE("RefinableObj::AddRestraint(Restraint*)",2)
1892  mvpRestraint.push_back(pNewRestraint);
1893 }
1894 
1895 vector<Restraint*>::iterator RefinableObj::RemoveRestraint(Restraint *pRestraint)
1896 {
1897  VFN_DEBUG_MESSAGE("RefinableObj::RemoveRestraint(Restraint*)",2)
1898  vector<Restraint*>::iterator pos=find(mvpRestraint.begin(),mvpRestraint.end(),pRestraint);
1899  if(mvpRestraint.end() != pos)
1900  {
1901  return mvpRestraint.erase(pos);
1902  }
1903  else
1904  {
1905  cout <<"RefinableObj::RemoveRestraint(..)"
1906  <<" Whoops... tried to remove a Restraint which does not exist..."<<endl;
1907  }
1908  return pos;
1909 }
1910 
1912 {
1913 }
1915 
1916 
1918 {
1919  #ifdef __WX__CRYST__
1920  VFN_DEBUG_ENTRY("RefinableObj::UpdateDisplay()",3)
1921  if(0!=mpWXCrystObj) mpWXCrystObj->CrystUpdate(true,true);
1922  VFN_DEBUG_EXIT("RefinableObj::UpdateDisplay()",3)
1923  #endif
1924 }
1925 
1926 long RefinableObj::FindPar(const string &name) const
1927 {
1928  long index=-1;
1929  bool warning=false;
1930  for(long i=this->GetNbPar()-1;i>=0;i--)
1931  if( this->GetPar(i).GetName() == name)
1932  {
1933  if(-1 != index) warning=true ;else index=i;
1934  }
1935  if(true == warning)
1936  {
1937  throw ObjCrystException("RefinableObj::FindPar("+name+"): found duplicate refinable variable name in object:"+this->GetName());
1938  }
1939  return index;
1940 }
1941 
1942 long RefinableObj::FindPar(const REAL *p) const
1943 {
1944  long index=-1;
1945  bool warning=false;
1946  for(long i=this->GetNbPar()-1;i>=0;i--)
1947  if( p == mvpRefPar[i]->mpValue ) //&(this->GetPar(i).GetValue())
1948  {
1949  if(-1 != index) warning=true ;else index=i;
1950  }
1951  if(true == warning)
1952  {
1953  throw ObjCrystException("RefinableObj::FindPar(*p): Found duplicate parameter in object:"+this->GetName());
1954  }
1955 
1956  return index;
1957 }
1958 
1960 {
1961  VFN_DEBUG_MESSAGE("RefinableObj::AddSubRefObj()",3)
1962  mSubObjRegistry.Register(obj);
1964 }
1965 
1967 {
1968  VFN_DEBUG_MESSAGE("RefinableObj::RemoveSubRefObj()",3)
1969  mSubObjRegistry.DeRegister(obj);
1971 }
1972 
1974 {
1975  VFN_DEBUG_MESSAGE("RefinableObj::AddOption()",5)
1976  //:TODO: automagically resize the option array if necessary
1977  mOptionRegistry.Register(*opt);
1978  mClockMaster.AddChild(opt->GetClock());
1979  VFN_DEBUG_MESSAGE("RefinableObj::AddOption():End",5)
1980 }
1981 
1983 {
1984  VFN_DEBUG_MESSAGE("RefinableObj::Prepare()",5)
1985  for(int i=0;i<this->GetSubObjRegistry().GetNb();i++)
1986  this->GetSubObjRegistry().GetObj(i).Prepare();
1987 }
1988 
1989 map<unsigned long,pair<CrystVector_REAL,string> >::iterator
1990  RefinableObj:: FindParamSet(const unsigned long id)const
1991 {
1992  VFN_DEBUG_ENTRY("RefinableObj::FindParamSet()",2)
1993  map<unsigned long,pair<CrystVector_REAL,string> >::iterator pos;
1994  pos=mvpSavedValuesSet.find(id);
1995  if(mvpSavedValuesSet.end() == pos)
1996  {//throw up
1997  throw ObjCrystException("RefinableObj::FindParamSet(long): Unknown saved set ! In object:"+this->GetName());
1998  }
1999  VFN_DEBUG_EXIT("RefinableObj::FindParamSet()",2)
2000  return pos;
2001 }
2002 
2003 #ifdef __WX__CRYST__
2004 WXCrystObjBasic* RefinableObj::WXCreate(wxWindow *parent)
2005 {
2006  VFN_DEBUG_MESSAGE("RefinableObj::WXCreate()",8)
2007  mpWXCrystObj=new WXRefinableObj (parent,this);
2008  return mpWXCrystObj;
2009 }
2010 WXCrystObjBasic* RefinableObj::WXGet()
2011 {
2012  return mpWXCrystObj;
2013 }
2014 void RefinableObj::WXDelete()
2015 {
2016  if(0!=mpWXCrystObj)
2017  {
2018  VFN_DEBUG_MESSAGE("RefinableObj::WXDelete()",5)
2019  delete mpWXCrystObj;
2020  }
2021  mpWXCrystObj=0;
2022 }
2023 void RefinableObj::WXNotifyDelete()
2024 {
2025  VFN_DEBUG_MESSAGE("RefinableObj::WXNotifyDelete():"<<mName,5)
2026  mpWXCrystObj=0;
2027 }
2028 #endif
2029 //######################################################################
2030 // function GetRefParListClockRecursive
2031 //######################################################################
2032 
2034 {
2035  for(int i=0;i<reg.GetNb();i++)
2036  {
2037  if(reg.GetObj(i).GetRefParListClock()>clock)
2038  clock=reg.GetObj(i).GetRefParListClock();
2040  }
2041 }
2042 
2043 //***********EXPLICIT INSTANTIATION*******************//
2045 }//namespace
2046 #include "ObjCryst/ObjCryst/Crystal.h"
2047 #include "ObjCryst/ObjCryst/Scatterer.h"
2048 #include "ObjCryst/ObjCryst/ScatteringPower.h"
2049 #include "ObjCryst/ObjCryst/ZScatterer.h"
2050 #include "ObjCryst/ObjCryst/PowderPattern.h"
2051 #include "ObjCryst/ObjCryst/DiffractionDataSingleCrystal.h"
2052 #include "ObjCryst/ObjCryst/ScatteringCorr.h"
2053 #include "ObjCryst/RefinableObj/GlobalOptimObj.h"
2054 #include "ObjCryst/RefinableObj/IO.h"
2055 #include "ObjCryst/ObjCryst/ReflectionProfile.h"
2056 using namespace ObjCryst;
2057 template class ObjRegistry<RefObjOpt>;
2058 template class ObjRegistry<RefinableObj>;
2059 template class ObjRegistry<Crystal>;
2060 template class ObjRegistry<Scatterer>;
2061 template class ObjRegistry<ScatteringPower>;
2062 template class ObjRegistry<ScatteringPowerAtom>;
2063 template class ObjRegistry<PowderPattern>;
2066 template class ObjRegistry<OptimizationObj>;
2067 //template class ObjRegistry<IOCrystTag>;//to be removed
2068 template class ObjRegistry<XMLCrystTag>;
2069 template class ObjRegistry<ZAtom>;
2071 template class ObjRegistry<TextureEllipsoid>;
2072 template class ObjRegistry<ReflectionProfile>;
2073 
2074 template class RefObjOption<RefinableObj>;
2075 template class RefObjOption<Crystal>;
2076 template class RefObjOption<Radiation>;
2077 template class RefObjOption<Scatterer>;
2078 template class RefObjOption<ScatteringPower>;
2079 template class RefObjOption<ScatteringPowerAtom>;
2080 template class RefObjOption<PowderPattern>;
2085 //template class RefObjOption<GlobalOptimObj>;
2086 //template class RefObjOption<IOCrystTag>;
void UpdateUI()
Manually update the UI, making sure all objects in the registry are displayed This is useful when the...
REAL mGlobalOptimStep
Step to use for global method search (simulated annealing,...)
Definition: RefinableObj.h:506
void SetDerivStep(const REAL)
Fixed step to use to compute numerical derivative.
T & GetObj(const unsigned int i)
Get object #i in the registry.
REAL GetHumanMin() const
Get the minimum value allowed (if limited)
void Print() const
Print clock value. Only for debugging purposes.
virtual REAL GetRestraintCost() const
Get the restraint cost (overall penalty of all restraints)
void AddSubRefObj(RefinableObj &)
CrystVector_long mRefparNotFixedIndex
Index of not-fixed parameters.
void AddPar(const RefinablePar &newRefPar)
Add a refinable parameter.
virtual const ObjRegistry< RefinableObj > & GetClientRegistry() const
Get the list of clients.
RefinableObjClock mRefParListClock
Last time the RefinableParList was modified (a parameter added or removed).
virtual void UpdateDisplay() const
If there is an interface, this should be automatically be called each time there is a 'new...
REAL GetMin() const
Minimum value allowed (if limited or periodic)
void SetLimitsRelative(const string &parName, const REAL min, const REAL max)
Change the limits for a given parameter, giving relative new limits (eg giving -.1 and +...
bool mIsFixed
is the parameter currently fixed ?
Definition: RefinableObj.h:496
const RefinableObjClock & GetRegistryClock() const
Last time an object was added or removed from the registry.
void SetParIsUsed(const string &parName, const bool use)
Set whether a parameter is used.
WX representation of a RefObj option. This displays the names of the different choices.
void AutoUpdateUI(const bool autoup=true)
Enable the UI automatic update, so that objects in the registry are automatically added to the UI...
long GetNb() const
Get the index of an object in the registry, from its name Warning: it can change if an object is remo...
string GetName() const
Get the parameter's name.
void Register(T &obj)
Register a new object. Already registered objects are skipped.
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
Definition: RefinableObj.h:138
bool IsBeingRefined() const
Is the object being refined ? (Can be refined by one algorithm at a time only.)
virtual void GlobalOptRandomMove(const REAL mutationAmplitude, const RefParType *type=gpRefParTypeObjCryst)
Make a random move of the current configuration.
REAL * mpValue
Pointer to the refinable value.
Definition: RefinableObj.h:490
const REAL * GetPointer() const
Access to a const pointer to the refined value.
void FixAllPar()
Fix All parameters.
virtual void BeginOptimization(const bool allowApproximations=false, const bool enableRestraints=false)
This should be called by any optimization class at the begining of an optimization.
void SaveParamSet(const unsigned long id) const
Save the current set of refined values over a previously-created set of saved values.
void RemoveParent(RefinableObjClock &) const
remove a parent clock
A field for a RefinablePar.
const string & GetName() const
Get the name for this parameter.
map< unsigned long, pair< CrystVector_REAL, string > >::iterator FindParamSet(unsigned long id) const
Find a parameter set with a given id (and check if it is there)
void SetParIsFixed(const long parIndex, const bool fix)
Fix/un-fix one parameter from its #.
void operator=(const RefinableObjClock &rhs)
This will (i) set the clock to the same values as the rhs clock, but will not change the list of chil...
long Find(const string &objName) const
Find the number of an object in the registry from its name (slow !) The search starts at the end of t...
RefParType(const string &name)
Create a top parameter type.
void RefObjRegisterRecursive(T &obj, ObjRegistry< T > &reg)
Register a new object in a registry, and recursively include all included (sub)objects.
void Click()
Record an event for this clock (generally, the 'time' an object has been modified, or some computation has been made)
vector< Restraint * >::iterator RemoveRestraint(Restraint *pRestraint)
Remove a restraint from the list of known restraints.
void RemoveSubRefObj(RefinableObj &)
long GetNbPar() const
Total number of refinable parameter in the object.
void AddChild(const RefinableObjClock &)
Add a 'child' clock.
long mNbRefParNotFixed
Total of not-fixed parameters.
Class for options of RefinableObj, templated so that we can warn the object that something has been c...
Definition: RefinableObj.h:606
const CrystVector_REAL & GetParamSet(const unsigned long setId) const
Access one save refpar set.
RefinablePar & GetParNotFixed(const long i)
Access all parameters in the order they were inputted, skipping fixed parameters. ...
void SetLimitsRelative(const REAL min, const REAL max)
Change the limits for this object, giving relative new limits (eg giving -.1 and +.1 will set new limits at the current value + min and current value + max) Thus min should logically be <0 and max >0.
long GetNbParNotFixed() const
Total number of non-fixed parameters. Is initialized by PrepareForRefinement()
RefinablePar & GetPar(const long i)
Access all parameters in the order they were inputted.
std::set< RefinableObjClock * > mvParent
List of parent clocks, which will be clicked whenever this one is.
Definition: RefinableObj.h:179
unsigned long mId
The unique number identifying this type.
Definition: RefinableObj.h:102
void SetIsUsed(const bool)
Is the parameter used (if not, it is simply irrelevant in the model) ?
void PrintStatic() const
Print current general clock value. Only for debugging purposes.
REAL mDerivStep
Step to use for numerical derivative calculation.
Definition: RefinableObj.h:508
void InitId()
Get a Unique id (RefParType::mId)
void BeginGlobalOptRandomMove()
Raise a flag, to be sure not to make a random change more than once in each RefinableObj.
void Mutate(const REAL mutateValue)
Add the given amount to the parameter current value.
virtual void RegisterClient(RefinableObj &) const
Register a new object using this object.
This displays all components of a ObjCryst++ Registry.
virtual REAL GetLogLikelihood() const
Get -ln(likelihood) for this restraint.
virtual void GetGeneGroup(const RefinableObj &obj, CrystVector_uint &groupIndex, unsigned int &firstGroup) const
Get the gene group assigned to each parameter.
void SetLimitsProportional(const string &parName, const REAL min, const REAL max)
Change the limits for a given parameter, proportionnaly to the current value.
ObjRegistry< RefinableObj > gTopRefinableObjRegistry("Global Top RefinableObj registry")
This is a special registry for 'top' object for an optimization.
RefinableObjClock mClockMaster
Master clock, which is changed whenever the object has been altered.
virtual void SetApproximationFlag(const bool allow)
Enable or disable numerical approximations.
unsigned int GetNbOption() const
Number of Options for this object.
const REAL & GetHumanValue() const
Current value of parameter, scaled if necessary (for angles) to a human-understandable value...
RefObjOpt & GetOption(const unsigned int i)
Access to the options.
RefParDerivStepModel
How do we compute steps h for numerical derivative calculation : d=f(x+h)-f(x-h)/h/2 either h is fixe...
Definition: RefinableObj.h:54
REAL mHumanScale
Scale to be used to display 'human' value.
Definition: RefinableObj.h:516
Generic Refinable Object.
Definition: RefinableObj.h:752
void SetMin(const REAL)
Set the Minimum value allowed (if limited)
REAL mPeriod
Period value (if relevant)
Definition: RefinableObj.h:504
void SetLimitsProportional(const REAL min, const REAL max)
Change the limits for this object, proportionnaly to the current value.
void ResetParList()
Re-init the list of refinable parameters, removing all parameters.
const RefinableObjClock & GetClockMaster() const
This clocks records any change in the object. See refinableObj::mClockMaster.
virtual std::map< RefinablePar *, CrystVector_REAL > & GetLSQ_FullDeriv(const unsigned int, std::set< RefinablePar * > &vPar)
Get the first derivative for the LSQ function for each parameter supplied in a list.
ObjRegistry< RefinableObj > gRefinableObjRegistry("Global RefinableObj registry")
Global Registry for all RefinableObj.
RefObjOption(T *obj)
Constructor for the option.
Abstract base class for all objects in wxCryst.
Definition: wxCryst.h:127
map< unsigned long, pair< CrystVector_REAL, string > > mvpSavedValuesSet
Map of (index,pointers to arrays) used to save sets of values for all parameters. ...
void GetRefParListClockRecursive(ObjRegistry< RefinableObj > &reg, RefinableObjClock &clock)
Get the last time any RefinablePar was added in a recursive list of objects.
string mName
Name for this RefinableObject. Should be unique, at least in the same scope.+.
void PrepareForRefinement() const
Find which parameters are used and not fixed, for a refinement /optimization.
virtual const CrystVector_REAL & GetLSQDeriv(const unsigned int, RefinablePar &)
Get the first derivative values for the LSQ function, for a given parameter.
bool mHasLimits
Does the refinable parameter need limits (min and max) ?
Definition: RefinableObj.h:494
const void EraseAllParamSet()
Erase all saved refpar sets.
Base class for options.
Definition: RefinableObj.h:550
bool mDeleteRefParInDestructor
If true (the default), then all RefinablePar will be deleted when the the object is deleted...
void RestoreParamSet(const unsigned long id)
Restore a saved set of values.
void AssignClock(RefinableObjClock &clock)
~RefParType()
Destructor.
REAL GetMax() const
Get the maximum value allowed (if limited)
vector< Restraint * > mvpRestraint
Vector of pointers to the restraints for this object.
REAL GetPeriod() const
Get the period (if periodic)
void RemoveChild(const RefinableObjClock &)
remove a child clock. This also tells the child clock to remove the parent.
RefParDerivStepModel mRefParDerivStepModel
Model followed for derivation.
Definition: RefinableObj.h:510
void Init(const string &name, REAL *refPar, const REAL min, const REAL max, const RefParType *type, RefParDerivStepModel derivMode=REFPAR_DERIV_STEP_RELATIVE, const bool hasLimits=true, const bool isFixed=false, const bool isUsed=true, const bool isPeriodic=false, const REAL humanScale=1., REAL period=1.)
Constructor.
RefinablePar()
Default Constructor.
bool mIsPeriodic
Is the parameter periodic ? If this is the case, then when using the RefinablePar::Mutate() function...
Definition: RefinableObj.h:502
virtual const CrystVector_REAL & GetLSQCalc(const unsigned int) const
Get the current calculated value for the LSQ function.
const string & GetParamSetName(const unsigned long setId) const
Get the name associated to a refpar set.
const RefinableObjClock & GetRefParListClock() const
What was the last time a RefinablePar was added/removed ?
void DeRegister(T &obj)
De-register an object.
void Click()
Click the Clock ! to telle the RefinableObj it has been modified.
void AddParent(RefinableObjClock &) const
Add a 'parent' clock.
ObjRegistry< RefinableObj > & GetSubObjRegistry()
Access to the registry of RefinableObj used by this object.
void CopyAttributes(const RefinablePar &)
Copy all attributes (limits, flags, etc...) from another RefinablePar object.
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
output a number as a formatted float:
bool mIsUsed
Is the parameter currently used ?
Definition: RefinableObj.h:498
void DeleteAll()
Delete all objects in the registry.. Use with caution !!
virtual void RandomizeConfiguration()
Randomize Configuration (before a global optimization).
ObjRegistry< RefinableObj > mClientObjRegistry
Registry of RefinableObject using this object.
RefinableObj()
Constructor.
void SetHumanValue(const REAL &)
Current value of parameter, scaled if necessary (for angles) to a human-understandable value...
Restraint: generic class for a restraint of a given model.
Definition: RefinableObj.h:199
ObjRegistry< RefinableObj > mSubObjRegistry
Registry of RefinableObject needed for this object (owned by this object or not)
The base wxCryst class for all RefinableObj objects.
CrystVector_REAL mLSQDeriv
Temporary array used to return derivative values of the LSQ function for given parameters.
const string mName
The name/description for this parameter type.
Definition: RefinableObj.h:100
void MutateTo(const REAL newValue)
Change the current value to the given one.
void ClearParamSet(const unsigned long id) const
Erase the param set with the given id, releasing memory.
virtual const CrystVector_REAL & GetLSQWeight(const unsigned int) const
Get the weight values for the LSQ function.
void SetValue(const REAL value)
of the parameter.
REAL GetHumanScale() const
Human scale for this parameter : for angles, this is equal to 180/pi.
bool operator==(const RefParType *parent) const
returns true if the two types are the same.
bool IsDescendantFromOrSameAs(const RefParType *type) const
Returns true if the parameter is a descendant of 'type'.
void Reset()
Reset a Clock to 0, to force an update.
REAL GetHumanMax() const
Get the maximum value allowed (if limited)
Exception class for ObjCryst++ library.
Definition: General.h:119
virtual void EndOptimization()
This should be called by any optimization class at the end of an optimization.
long FindPar(const string &name) const
Find a refinable parameter with a given name.
virtual unsigned int GetNbLSQFunction() const
Number of LSQ functions.
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: Atom.cpp:47
void SetHumanMin(const REAL)
Set the minimum value allowed (if limited)
void SetMax(const REAL)
Get the maximum value allowed (if limited)
const RefParType * mpParent
the parent for this RefParType (we could easily allow several...)
Definition: RefinableObj.h:98
REAL GetDerivStep() const
Fixed step to use to compute numerical derivative.
virtual REAL GetLogLikelihood() const
Get -log(likelihood) of the current configuration for the object.
Generic class for parameters of refinable objects.
Definition: RefinableObj.h:223
RefObjOpt()
Constructor for the option.
virtual const string & GetName() const
Name of the object.
REAL GetGlobalOptimStep() const
Maximum step to use during Global Optimization algorithms.
bool mHasAssignedClock
Is there a clock associated with this parameter ? If yes, then it must Click() it each time it is mod...
Definition: RefinableObj.h:532
string mName
name of the refinable parameter
Definition: RefinableObj.h:488
void SetHumanMax(const REAL)
Get the maximum value allowed (if limited)
void GetSubRefObjListClockRecursive(ObjRegistry< RefinableObj > &reg, RefinableObjClock &clock)
Get the last time any object was added in the recursive list of objects.
void AddRestraint(Restraint *pNewRestraint)
Add a new restraint.
REAL GetParamSet_ParNotFixedHumanValue(const unsigned long setId, const long parNumber) const
Access the (human) value of one refined parameter in a saved set of parameters.
REAL GetValue() const
of the parameter.
vector< RefinablePar * >::iterator RemovePar(RefinablePar *refPar)
Remove a refinable parameter.
Restraint()
Default constructor, sets RefParType to gpRefParTypeObjCryst.
virtual const CrystVector_REAL & GetLSQObs(const unsigned int) const
Get the observed values for the LSQ function.
void SetGlobalOptimStep(const RefParType *type, const REAL step)
Change the maximum step to use during Global Optimization algorithms.
void SetLimitsAbsolute(const string &parName, const REAL min, const REAL max)
Change the limits for a given parameter, giving absolute new limits.
vector< RefinablePar * > mvpRefPar
Vector of pointers to the refinable parameters.
ObjRegistry< RefObjOpt > mOptionRegistry
List of options for this object.
void SetDeleteRefParInDestructor(const bool b)
Set this object not to delete its list of parameters when destroyed.
void SetPeriod(const REAL)
Set the period value (if periodic)
std::map< unsigned int, std::map< RefinablePar *, CrystVector_REAL > > mLSQ_FullDeriv
Temporary map to return the derivative of the LSQ function versus a list of parameters.
void DeRegisterAll()
De-register all objects from the list.
virtual void TagNewBestConfig() const
During a global optimization, tells the object that the current config is the latest "best" config...
void SetHumanScale(const REAL)
Human scale for this parameter : for angles, this is equal to 180/pi.
bool IsUsed() const
Is the parameter used (if not, it is simply irrelevant in the model) ?
class of refinable parameter types.
Definition: RefinableObj.h:78
virtual ~RefinableObj()
Destructor.
virtual void DeRegisterClient(RefinableObj &) const
Deregister an object (which not any more) using this object.
unsigned long CreateParamSet(const string name="") const
Save the current set of refined values in a new set.
void SetName(const string &)
Set the name of the parameter. It should be unique in the RefinableObj.
std::set< const RefinableObjClock * > mvChild
List of 'child' clocks, which will click this clock whenever they are clicked.
Definition: RefinableObj.h:175
int mOptimizationDepth
Is the object being refined or optimized ? if mOptimizationDepth=0, no optimization is taking place...
void UnFixAllPar()
UnFix All parameters.
const RefParType * gpRefParTypeObjCryst
Top RefParType for the ObjCryst++ library.
Object Registry.
Definition: RefinableObj.h:643
void AddOption(RefObjOpt *opt)
void SetGlobalOptimStep(const REAL)
Maximum step to use during Global Optimization algorithms.
REAL mSigma
Calculated sigma on value.
Definition: RefinableObj.h:512
virtual void SetName(const string &name)
Name of the object.
void SetLimitsAbsolute(const REAL min, const REAL max)
Change the limits for this object, giving absolute new limits.
REAL mMin
Hard lower and upper limits.
Definition: RefinableObj.h:492