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 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:

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).

# 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)