surrogateoptSolution or Process
When you have both linear constraints and integer constraints,
surrogateopt can fail to find any feasible points or enough distinct
feasible points to create a surrogate. In these cases, the solver exits with exit flag
2 (no feasible point found) or
3 (too few feasible
points). For details on exit flag –
2, see No Feasible Point Found.
3 can occur in two different ways:
There were too few feasible points to construct an initial surrogate.
There were too few feasible points to construct a surrogate after a surrogate reset.
You can see which case applies by using the
options = optimoptions('surrogateopt','PlotFcn','surrogateoptplot'); [sol,fval,exitflag] = surrogateopt(arguments,options);
After each surrogate reset,
surrogateopt requires more feasible
points to construct the next surrogate. When there are integer constraints,
surrogateopt can exhaust the set of feasible points, or can fail to
find new feasible points even when some remain
surrogateopt has performed at least one reset, then it has
successfully searched for a solution. In this case, you might have the solution to the
surrogateopt was unable to create an initial surrogate, or if
surrogateopt reset and you want to try to find another solution,
perform the following steps.
Relax some constraints.
Change some linear constraints to nonlinear, which causes the solver to not
insist on strict feasibility. This can give
feasible points to use in constructing surrogates.
Relax some linear inequality constraints by choosing larger values for the
b vector. You can relax all
b values at once
by adding a scalar:
b = b + 5;
Similarly, if your bound constraints are causing the problem to have too few feasible points, and if it makes sense for your problem, relax the bounds. Take larger upper bounds or smaller lower bounds or both. You can relax all bounds at once by adding or subtracting a scalar.
ub = ub + 3; lb = lb - 1;
surrogateopt cannot find a point that is feasible with respect
to bounds, integer constraints, and linear constraints, it returns exit flag
2. In this case, the problem is truly infeasible.
However, the solver can also return exit flag –
2 when it cannot
locate a point that is feasible with respect to nonlinear inequality constraints. This can
sometimes occur even when feasible points exist. To proceed, follow the steps in Converged to an Infeasible Point.
surrogateopt stops when it runs out of function
evaluations. This means that
surrogateopt does not stop because it
reaches an optimal solution. However, when a surrogate reset occurs, the current solution is
usually near a local optimum.
How can you evaluate the quality of a solution? Generally, this is difficult to do. Here are some steps for investigating a solution to help determine its local quality. However, there is no procedure that guarantees that a point is a global solution. See Can You Certify That a Solution Is Global?.
If the problem has no integer constraints, look at nearby points. To do so, call
patternsearch on the returned solution. Set the
InitialMeshSize option to the size of the search step you want to
use. To keep
patternsearch from taking too much time, set the
MaxIterations option to
1 and the
UseCompletePoll option to
options = optimoptions('patternsearch',... 'InitialMeshSize',1e-3,... 'MaxIterations',1,'UseCompletePoll',true);
If your problem has nonlinear constraints, first convert the constraints to the form
patternsearch accepts using Convert Nonlinear Constraints Between surrogateopt Form and Other Solver Forms.
If the problem has no integer constraints, try running
starting from the solution. Again, if your problem has nonlinear constraints, first
convert the constraints to the form that
fmincon accepts using
Convert Nonlinear Constraints Between surrogateopt Form and Other Solver Forms. If the problem uses a
simulation or ODE solver, you might need to set larger finite difference options for
fmincon. See Optimizing a Simulation or Ordinary Differential Equation.
If the problem has integer constraints, then there is little to do except to try to
surrogateopt for more function evaluations. Do so most
efficiently by using a checkpoint file. See Work with Checkpoint Files. If you did not use a
checkpoint file, you can also give a set of initial points using the