Change Options
How to Determine Which Options to Change
After you run a global solver, you might want to change some global or local options. To determine which options to change, the guiding principle is:
To affect the local solver, set local solver options.
To affect the start points or solution set, change the
problemstructure, or set the global solver object properties.
For example, to obtain:
More local minima — Set global solver object properties.
Faster local solver iterations — Set local solver options.
Different tolerances for considering local solutions identical (to obtain more or fewer local solutions) — Set global solver object properties.
Different information displayed at the command line — Decide if you want iterative display from the local solver (set local solver options) or global information (set global solver object properties).
Different bounds, to examine different regions — Set the bounds in the
problemstructure.
Examples of Choosing Problem Options
To start your local solver at points only satisfying inequality constraints, set the
StartPointsToRunproperty in the global solver object to'bounds-ineqs'. This setting can speed your solution, since local solvers do not have to attempt to find points satisfying these constraints. However, the setting can result in many fewer local solver runs, since the global solver can reject many start points. For an example, see Optimize Using Only Feasible Start Points.To use the
fminconinterior-pointalgorithm, set the local solverAlgorithmoption to'interior-point'. For an example showing how to do this, see Examples of Updating Problem Options.For your local solver to have different bounds, set the bounds in the
problemstructure. Examine different regions by setting bounds.To see every solution that has positive local exit flag, set the
XToleranceproperty in the global solver object to0. For an example showing how to do this, see Changing Global Options.
Changing Local Solver Options
There are several ways to change values in local options:
Update the values using dot notation and
optimoptions. The syntax isproblem.options = optimoptions(problem.options,'Parameter',value,...);
You can also replace the local options entirely:
problem.options = optimoptions(@solvername,'Parameter',value,...);
Use dot notation on one local option. The syntax is
problem.options.Parameter = newvalue;
Recreate the entire problem structure. For details, see Create Problem Structure.
Examples of Updating Problem Options
Create a problem structure:
problem = createOptimProblem('fmincon','x0',[-1 2], ... 'objective',@rosenboth);
Set the problem to use the
sqpalgorithm infmincon:problem.options.Algorithm = 'sqp';Update the problem to use the gradient in the objective function, have a
FunctionTolerancevalue of1e-8, and aXTolerancevalue of1e-7:problem.options = optimoptions(problem.options,'GradObj','on', ... 'FunctionTolerance',1e-8,'XTolerance',1e-7);
Changing Global Options
There are several ways to change characteristics of a GlobalSearch or MultiStart object:
Use dot notation. For example, suppose you have a default
MultiStartobject:ms = MultiStart
ms = MultiStart with properties: UseParallel: 0 Display: 'final' FunctionTolerance: 1.0000e-06 MaxTime: Inf OutputFcn: [] PlotFcn: [] StartPointsToRun: 'all' XTolerance: 1.0000e-06To change
msto have itsXTolerancevalue equal to1e-3, update theXTolerancefield:ms.XTolerance = 1e-3
ms = MultiStart with properties: UseParallel: 0 Display: 'final' FunctionTolerance: 1.0000e-06 MaxTime: Inf OutputFcn: [] PlotFcn: [] StartPointsToRun: 'all' XTolerance: 1.0000e-03Reconstruct the object starting from the current settings. For example, to set the
FunctionTolerancefield inmsto1e-3, retaining the nondefault value forXTolerance:ms = MultiStart(ms,'FunctionTolerance',1e-3)ms = MultiStart with properties: UseParallel: 0 Display: 'final' FunctionTolerance: 1.0000e-03 MaxTime: Inf OutputFcn: [] PlotFcn: [] StartPointsToRun: 'all' XTolerance: 1.0000e-03Convert a
GlobalSearchobject to aMultiStartobject, or vice-versa. For example, with themsobject from the previous example, create aGlobalSearchobject with the same values ofXToleranceandFunctionTolerance:gs = GlobalSearch(ms)
gs = GlobalSearch with properties: NumTrialPoints: 1000 BasinRadiusFactor: 0.2000 DistanceThresholdFactor: 0.7500 MaxWaitCycle: 20 NumStageOnePoints: 200 PenaltyThresholdFactor: 0.2000 Display: 'final' FunctionTolerance: 1.0000e-03 MaxTime: Inf OutputFcn: [] PlotFcn: [] StartPointsToRun: 'all' XTolerance: 1.0000e-03