(calibration_minimisation_optimisation_properties)= # 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: ````{only} cpp ```cpp // Prototype for NLopt void setOptimProperties(URANIE::Reoptimizer::TNloptSolver *solv, Option_t *option=""); // Prototype for Vizir void setOptimProperties(URANIE::Reoptimizer::TVizirSolverShare *solv, Option_t *option=""); ``` ```` ````{only} py ```python # Prototype for NLopt or Vizir setOptimProperties(solv, 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: - **TNlopt**: the optimisation master used for any `TNloptSolver` instance. An example can be found in [](#use_cases_macro_calibration_minimisation); - **TVizir2**: the optimisation master used for any `TVizirSolverShare` instance. Even though the optimisation will remain mono-criterion, this might be useful for certain complex problems, as discussed in [](#use_cases_macro_calibration_minimisation_vizir). 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). `````{only} cpp ````{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. ```cpp // 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); ``` ```` ````` ````{only} py ```py # Set the calibration object cal = Calibration.TMinimisation(tdsPar,runner,1) cal.setDistance("relativeLS",tdsRef,"rw:l","Qexp") # Set Vizir optimisation properties solv = Reoptimizer.TVizirGenetic() solv.setSize(24,15000,100) cal.setOptimProperties(solv) optimMaster = cal.getOptimMaster() optimMaster.setTolerance(1e-6) # Set Nlopt optimisation properties solv = Reoptimizer.TNloptSubplexe() cal.setOptimProperties(solv) optimMaster = cal.getOptimMaster() optimMaster.setTolerance(1e-6) ``` ````