26 #include "ObjCryst/CrystVector/CrystVector.h"
27 #include "ObjCryst/RefinableObj/RefinableObj.h"
41 LSQNumObj(std::string objName=
"Unnamed LSQ object");
96 void Refine (
int nbCycle=1,
bool useLevenbergMarquardt=
false,
97 const bool silent=
false,
const bool callBeginEndOptimization=
true,
98 const float minChi2var=0.01);
111 bool SafeRefine(std::list<RefinablePar*> vnewpar, std::list<const RefParType*> vnewpartype,
112 REAL maxChi2factor=1.01,
113 int nbCycle=1,
bool useLevenbergMarquardt=
false,
114 const bool silent=
false,
const bool callBeginEndOptimization=
true,
115 const float minChi2var=0.01);
116 CrystVector_REAL Sigma()
const;
117 CrystMatrix_REAL CorrelMatrix()
const;
118 void CalcRfactor()
const;
120 void CalcRwFactor()
const;
121 REAL RwFactor()
const;
122 void CalcChiSquare()
const;
123 REAL ChiSquare()
const;
136 void SetRefinedObj(
RefinableObj &obj,
const unsigned int LSQFuncIndex=0,
const bool init=
true,
const bool recursive=
false);
170 void SetUseSaveFileOnEachCycle(
bool yesOrNo=
true);
171 void SetSaveFile(std::string fileName=
"refine.save");
172 void PrintRefResults()
const;
173 void SetDampingFactor(
const REAL newDampFact);
174 void PurgeSaveFile();
175 void WriteReportToFile()
const;
177 void OptimizeDerivativeSteps();
178 const std::map<pair<const RefinablePar*,const RefinablePar*>,REAL > &GetVarianceCovarianceMap()
const;
198 const CrystVector_REAL&
GetLSQObs()
const;
203 const std::map<RefinablePar*,CrystVector_REAL>& GetLSQ_FullDeriv();
206 void BeginOptimization(
const bool allowApproximations=
false,
const bool enableRestraints=
false);
232 mutable REAL mR,mRw,mChiSq;
236 std::map<pair<const RefinablePar*,const RefinablePar*>,REAL >
mvVarCovar;
266 mutable CrystVector_REAL
mLSQObs,mLSQCalc,mLSQWeight,mLSQDeriv;
267 mutable std::map<RefinablePar*,CrystVector_REAL> mLSQ_FullDeriv;
273 void WXNotifyDelete();
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
(Quick & dirty) Least-Squares Refinement Object with Numerical derivatives
CrystVector_REAL mLSQObs
Temporary arrays for LSQ functions evaluation - used when using recursive LSQ function.
bool mSaveReportOnEachCycle
Save result to file after each cycle ?
void SetParIsFixed(const std::string &parName, const bool fix)
Fix one parameter.
bool mCopyRefPar
If true, then parameters to be refined will be copied instead of referenced.
const CrystVector_REAL & GetLSQCalc() const
Get the LSQ calc vector (using either only the top or the hierarchy of object)
ObjRegistry< RefinableObj > mRecursiveRefinedObjList
The recursive list of all refined sub-objects.
void EndOptimization()
Tell all refined object that the refinement is finished.
bool SafeRefine(std::list< RefinablePar * > vnewpar, std::list< const RefParType * > vnewpartype, REAL maxChi2factor=1.01, int nbCycle=1, bool useLevenbergMarquardt=false, const bool silent=false, const bool callBeginEndOptimization=true, const float minChi2var=0.01)
Run a refinement in a 'safe' way: if the Chi2 value increases by more that a given factor the paramet...
void BeginOptimization(const bool allowApproximations=false, const bool enableRestraints=false)
Tell all refined object that the refinement is beginning.
const std::map< RefinableObj *, unsigned int > & GetRefinedObjMap() const
Get the map of refined objects - this is a recursive list of all the objects that are taken into acco...
std::map< pair< const RefinablePar *, const RefinablePar * >, REAL > mvVarCovar
Variance-Covariance matrix, as a std::map.
std::string mName
Name of the refined object.
RefinableObj mRefParList
The refinable par list used during refinement.
CrystMatrix_REAL mCorrelMatrix
Correlation matrix between all refined parameters.
const CrystVector_REAL & GetLSQWeight() const
Get the LSQ weight vector (using either only the top or the hierarchy of object)
const CrystVector_REAL & GetLSQObs() const
Get the LSQ obs vector (using either only the top or the hierarchy of object)
bool mStopAfterCycle
If true, then stop at the end of the cycle. Used in multi-threading environment.
void Refine(int nbCycle=1, bool useLevenbergMarquardt=false, const bool silent=false, const bool callBeginEndOptimization=true, const float minChi2var=0.01)
Do the refinement.
CrystVector_REAL mObs
Observed values.
void SetParIsUsed(const std::string &parName, const bool use)
Set a parameter to be used.
std::map< RefinableObj *, unsigned int > mvRefinedObjLSQSize
Size of each object LSQ data. This is initialized in LSQNumObj::GetLSQObs()
REAL mDampingFactor
Damping factor for the refinement (unused yet...)
std::string mSaveFileName
File name where refinement info is saved.
void SetRefinedObj(RefinableObj &obj, const unsigned int LSQFuncIndex=0, const bool init=true, const bool recursive=false)
Choose the object to refine.
RefinableObj & GetCompiledRefinedObj()
Access to the RefinableObj which is the compilation of all parameters from the object supplied for op...
const CrystVector_REAL & GetLSQDeriv(RefinablePar &par)
Get the LSQ deriv vector (using either only the top or the hierarchy of object)
void UnFixAllPar()
UnFix All parameters.
std::map< RefinableObj *, unsigned int > mvRefinedObjMap
Map of the recursive list of the objects to be refined.
CrystVector_REAL mWeight
Weight corresponding to all observed values.
int mIndexValuesSetInitial
Index of the set of saved values for all refinable parameters, before refinement and before the last ...
void PrepareRefParList(const bool copy_param=false)
Prepare the full parameter list for the refinement.
class of refinable parameter types.
Generic class for parameters of refinable objects.
Generic Refinable Object.
Abstract base class for all objects in wxCryst.