Main Content

Initial Points for Global Optimization Toolbox Solvers

Some Global Optimization Toolbox solvers require an initial point x0: patternsearch, simulannealbnd, GlobalSearch, and MultiStart. When solving optimization problems using the problem-based approach, you specify x0 in the second argument for solve and for prob2struct. To specify an initial point, create a structure with the variable names as fields and variable values as structure values. For example, for a scalar variable x and a 2-by-2 matrix y for the patternsearch solver, enter the following code.

x0.x = 5;
x0.y = eye(2) + 0.1*randn(2);
[sol,fval] = solve(prob,x0,"Solver","patternsearch")

You can also specify an initial point for these solvers using optimvalues, as shown next.

Other Global Optimization Toolbox solvers do not require an initial point, but can accept an initial point or set of initial points: ga, gamultiobj, paretosearch, and surrogateopt. To pass initial points to these solvers, create the points using optimvalues.


When using the problem-based approach, you cannot pass an initial point or initial population using options such as:

For example, take a 2-D variable x and a 2-by-2 matrix y for the ga solver.

x = optimvar('x',2,"LowerBound",-1,"UpperBound",1);
y = optimvar('y',2,2,"LowerBound",-1,"UpperBound",1);
prob = optimproblem("Objective",...
    cosh(dot(y*x,[2;-1])) - sinh(dot(y*x,[1;-2])));
prob.Constraints = y(1,2) == y(2,1);
% Set initial population: x0x for x, x0y for y
rng default
x0x = [1;1/2];
x0y = eye(2)/2 + 0.1*randn(2);
x0 = optimvalues(prob,'x',x0x,'y',x0y);
% Solve problem
[sol,fval] = solve(prob,Solver="ga")
ga stopped because the average change in the fitness value is less than options.FunctionTolerance.

sol = 

  struct with fields:

    x: [2×1 double]
    y: [2×2 double]

fval =


The solution satisfies the constraint y(1,2) == y(2,1) only to within the constraint tolerance 1e-3: sol.y(2,1) = -1.0000, but sol.y(1,2) = -0.9990.

See Also


Related Topics