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
problem
structure, 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
problem
structure.
Examples of Choosing Problem Options
To start your local solver at points only satisfying inequality constraints, set the
StartPointsToRun
property 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
fmincon
interior-point
algorithm, set the local solverAlgorithm
option 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
problem
structure. Examine different regions by setting bounds.To see every solution that has positive local exit flag, set the
XTolerance
property 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
sqp
algorithm infmincon
:problem.options.Algorithm = 'sqp';
Update the problem to use the gradient in the objective function, have a
FunctionTolerance
value of1e-8
, and aXTolerance
value 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
MultiStart
object:ms = MultiStart
ms = MultiStart with properties: UseParallel: 0 Display: 'final' FunctionTolerance: 1.0000e-06 MaxTime: Inf OutputFcn: [] PlotFcn: [] StartPointsToRun: 'all' XTolerance: 1.0000e-06
To change
ms
to have itsXTolerance
value equal to1e-3
, update theXTolerance
field: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-03
Reconstruct the object starting from the current settings. For example, to set the
FunctionTolerance
field inms
to1e-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-03
Convert a
GlobalSearch
object to aMultiStart
object, or vice-versa. For example, with thems
object from the previous example, create aGlobalSearch
object with the same values ofXTolerance
andFunctionTolerance
: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