11.3.2. Defining the TMinimisation properties

Once the TMinimisation instance is created along with its associated TDistanceLikelihoodFunction, the optimisation properties must be defined to specify which algorithm will be used. This is done by calling the setOptimProperties, whose prototype is:

// Prototype for NLopt
void setOptimProperties(URANIE::Reoptimizer::TNloptSolver *solv, Option_t *option="");
// Prototype for Vizir
void setOptimProperties(URANIE::Reoptimizer::TVizirSolverShare *solv, Option_t *option="");

The option field is reserved for future use and is currently non-functional. It is advisable to prepare the solver before integrating it into the TCalibration object, as modifying it afterwards may be difficult (as shown in the example below). For example, it may be preferable to set the population size, number of iterations, and number of steps using the setSize method on the TVizirGenetic object before to provide it to TMinimisation (via setOptimProperties), which will then automatically create the appropriate optimisation master based on the solver type:

It is also possible to access the optimisation master by calling the getOptimMaster method. This method returns a pointer to the newly created TOptimShare instance. This might be useful to set some properties (for instance the tolerance).

Warning

It might be useful to cast the pointer returned by this method, when calling getOptimMaster, as the pointer can be either a TNlopt or TVizir2 instance.

// Set the calibration object
TMinimisation *cal = new TMinimisation(tdsPar,runner,1);
cal->setDistance("relativeLS",tdsRef,"rw:l","Qexp");

// Set Vizir optimisation properties
TVizirGenetic solv;
solv.setSize(24,15000,100);
cal->setOptimProperties(&solv);
TVizir2 *optimMaster = ((TVizir2*)cal->getOptimMaster());
optimMaster->setTolerance(1e-6);

// Set Nlopt optimisation properties
TNloptSubplexe solv;
cal->setOptimProperties(&solv);
TNlopt *optimMaster = ((TNlopt*)cal->getOptimMaster());
optimMaster->setTolerance(1e-6);