How to skip an optimization iteration if the constraint is violated ?
6 views (last 30 days)
Show older comments
Hello, I am trying to minimizing an objectif function with Surrogate optimisation.
The objectif function depends on 2 parameters
, having the following lower and upper limits:
lb = [10, 2 ];
ub = [20, 4 ];
And I have a constraint
, which, if it is not complied with, prevents the proper functioning of the function objective. The problem with surrogate optimisation is that the constraint is only check after the objectif function was evaluated. So my question is "how can I forbid certain combinations of parameters"? As proposed in this answer (https://nl.mathworks.com/matlabcentral/answers/49677-how-to-make-optimization-to-redo-or-skip-one-iteration), I tried to add in my objectif function, an if statement:
if
then output.Fval = NaN
Hower this does not seems to work for surrogate optimisation. So if you have any idea how i could solve this problem I am a taker. Thanks.
0 Comments
Accepted Answer
Matt J
on 1 Jan 2021
Edited: Matt J
on 1 Jan 2021
And I have a constraint , which, if it is not complied with, prevents the proper functioning of the function objective.
In your objective function, make the execution of the main routine conditional on the constraints being satisfied.
if x1<3*x2
fval=inf; return
else
fval=...%evaluate normaly
end
or you can post-correct the output,
fval=%evaluate normally
if ~(isfinite(fval)&&isreal(fval))
fval=inf; return
end
21 Comments
Walter Roberson
on 31 Aug 2021
If the optimization returns nan in that setup, it means that the optmizer did not find even one point that satisfied all of your constraints.
Weihan Lin
on 31 Aug 2021
Yeah, I see. It couldn't find any feasible point when the population size is small. I change th population size from 50 to 1000 and only one point was found in the feasible region after 30 iterations. I probably will increase the population size more and see if the results will get any better and I'm so appreciate for your help.
More Answers (0)
See Also
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!