MATLAB Answers

Optimisation with patternsearch solver evaluates objective function for same variable values twice

2 views (last 30 days)
Mario Malic
Mario Malic on 13 Oct 2020
Edited: Mario Malic on 13 Oct 2020
Hello everyone,
As the title states, I have an issue with patternsearch, it evaluates the same values for optimisation variables twice in a row. Solver options are default, except for FunctionTolerance, StepTolerance, InitialMeshSize (as it matters here, it's 5e-4, and poll has been successful so it's twice the size in iteration shown).
% Problem statement
problem.options = app.Optim_Options.Solver_Options; % optimoptitons
problem.solver = app.Optim_Options.Solver_Choice; % patternsearch
problem.objective = @(x)Fun_Optim(x);
problem.x0 = [app.Coordinates(1) app.Coordinates(3:8) app.Coordinates(10)]; % X1, X2, Y2, X3, Y3, X4, Y4, Y5
problem.lb = app.Optimisation_Vars.lb.*problem.x0;
problem.ub = app.Optimisation_Vars.ub.*problem.x0;
problem.Aeq = [1 -1 0 0 0 0 0 0;
0 0 0 0 0 0 1 -1];
problem.beq = [0; 0];
% In Fun_Optim(x) if it matters
function fobj = Fun_Optim(x)
% code
x = [x(1), x(2), x(3), x(4), x(5), x(6), x(7), x(8)];
X = [x(1) , x(2), x(4), x(6), Coordinates(9)];
Y = [Coordinates(2), x(3), x(5), x(7), x(8) ];
disp([X;Y]);
fobj = someotherfun(x, arg1, arg2)
end
What I could see from function evaluations, is that solver evaluates at x+InitialMeshSize twice, and that is something that I do not prefer as it's time expensive. Why would this even happen? I do have equality constraints x(1) = x(2) and x(7) = x(8) as seen in Aeq and Beq, and these are respected. Rest of the solver options are default.
Function evaluation : 7
0.042840000000000 0.042840000000000 0.036280000000000 0.021000000000000 0
0 0.021710000000000 0.034440000000000 0.042000000000000 0.042000000000000
fobj = 0.001044300000000
Command window display
2 7 0.0010443 0.002 Successful Poll
Function evaluation: 8
0.043840000000000 0.043840000000000 0.036280000000000 0.021000000000000 0 % Notice the first two numbers
0 0.021710000000000 0.034440000000000 0.042000000000000 0.042000000000000
fobj = 0.001474400000000
Function evaluation: 9
0.043840000000000 0.043840000000000 0.036280000000000 0.021000000000000 0 % Numbers did not change
0 0.021710000000000 0.034440000000000 0.042000000000000 0.042000000000000
fobj = 0.001474400000000
Function evaluation: 10
0.042840000000000 0.042840000000000 0.036280000000000 0.021000000000000 0
0 0.021710000000000 0.034440000000000 0.043000000000000 0.043000000000000 % Last two Numbers changed
fobj = 0.001755000000000
Function evaluation: 11
0.042840000000000 0.042840000000000 0.036280000000000 0.021000000000000 0
0 0.021710000000000 0.034440000000000 0.043000000000000 0.043000000000000 % Numbers did not change
fobj = 0.001755000000000
Function evaluation : 12
0.041840000000000 0.041840000000000 0.036280000000000 0.021000000000000 0
0 0.021710000000000 0.034440000000000 0.042000000000000 0.042000000000000
fobj = 7.588000000000008e-04
3 12 0.0007588 0.004 Successful Poll
Stop requested.
I am curious why is this happening? I also ran the same problem without equality constraints and it seems that such issues do not exist.

  0 Comments

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!