run

Class: MultiStart

Run local solver from multiple points

Syntax


x = run(ms,problem,k)
x = run(ms,problem,startpts)
[x,fval] = run(...)
[x,fval,exitflag] = run(...)
[x,fval,exitflag,output] = run(...)
[x,fval,exitflag,output,solutions] = run(...)

Description

x = run(ms,problem,k) runs the ms MultiStart object on the optimization problem specified in problem for a total of k runs. x is the point where the lowest function value was found. For the lsqcurvefit and lsqnonlin solvers, MultiStart minimizes the sum of squares at x, also known as the residual.

x = run(ms,problem,startpts) runs the ms MultiStart object on the optimization problem specified in problem using the start points described in startpts.

[x,fval] = run(...) returns the lowest objective function value fval at x. For the lsqcurvefit and lsqnonlin solvers, fval contains the residual.

[x,fval,exitflag] = run(...) returns an exit flag describing the return condition.

[x,fval,exitflag,output] = run(...) returns an output structure containing statistics of the run.

[x,fval,exitflag,output,solutions] = run(...) returns a vector of solutions containing the distinct local minima found during the run.

Input Arguments

ms

MultiStart object.

problem

Problem structure. Create problem with createOptimProblem or by exporting a problem structure from the Optimization app. problem must contain the following fields:

  • solver

  • objective

  • x0

  • options — Both createOptimProblem and the Optimization app always include an options field in the problem structure.

k

Number of start points to run. MultiStart generates k - 1 start points using the same algorithm as list for a RandomStartPointSet object. MultiStart also uses the x0 point from the problem structure.

startpts

A CustomStartPointSet or RandomStartPointSet object. startpts can also be a cell array of these objects.

Output Arguments

x

Point at which the objective function attained the lowest value during the run. For lsqcurvefit and lsqnonlin, the objective function is the sum of squares, also known as the residual.

fval

Smallest objective function value attained during the run. For lsqcurvefit and lsqnonlin, the objective function is the sum of squares, also known as the residual.

exitflag

Integer describing the return condition:

2At least one local minimum found. Some runs of the local solver converged.
1At least one local minimum found. All runs of the local solver converged.
0No local minimum found. Local solver called at least once, and at least one local solver exceeded the MaxIter or MaxFunEvals tolerances.
-1One or more local solver runs stopped by the local solver output or plot function.
-2No feasible local minimum found.
-5MaxTime limit exceeded.
-8No solution found. All runs had local solver exit flag -2 or smaller, not all equal -2.
-10Failures encountered in user-provided functions.

output

Structure containing statistics of the optimization. Fields in the structure:

funcCountNumber of function evaluations.
localSolverIncompleteNumber of local solver runs with 0 exit flag.
localSolverNoSolutionNumber of local solver runs with negative exit flag.
localSolverSuccessNumber of local solver runs with positive exit flag.
localSolverTotalTotal number of local solver runs.
messageExit message.

solutions

A vector of GlobalOptimSolution objects containing the distinct local solutions found during the run. The vector is sorted by objective function value; the first element is best (smallest value). The object contains:

XSolution point returned by the local solver.
FvalObjective function value at the solution.
ExitflagInteger describing the result of the local solver run.
OutputOutput structure returned by the local solver.
X0Cell array of start points that led to the solution.

Examples

Use a default MultiStart object to solve the six-hump camel back problem (see Run the Solver):

ms = MultiStart;
sixmin = @(x)(4*x(1)^2 - 2.1*x(1)^4 + x(1)^6/3 ...
    + x(1)*x(2) - 4*x(2)^2 + 4*x(2)^4);
problem = createOptimProblem('fmincon','x0',[-1,2],...
    'objective',sixmin,'lb',[-3,-3],'ub',[3,3]);
[xmin,fmin,flag,outpt,allmins] = run(ms,problem,30);

Algorithms

A detailed description of the algorithm appears in MultiStart Algorithm.

Was this topic helpful?