MATLAB Answers

How to add constraints to simulannealbnd minimization

8 views (last 30 days)
Ole on 14 Apr 2021
Commented: Ole on 14 Apr 2021
How to add constraint to minimization problem?
Simply x(3) >10*x(4)
ConstraintFunction = @simple_constraint; %constraint here does not affect minimization
hybridopts = optimoptions('fmincon','OptimalityTolerance',1e-14);
options = optimoptions(@simulannealbnd,'InitialTemperature',[1e4 1e4 1e4 1e4 ],...
options.ReannealInterval = 400;
[x,fval] = simulannealbnd(ObjectiveFunction,X0,LB,UB,options);
function [c, ceq] = simple_constraint(x)
c = [-x(3) + 10*x(4)];
% c = [];
ceq = [];

Answers (1)

Walter Roberson
Walter Roberson on 14 Apr 2021
You cannot add constraints directly. However you can set AnnealingFcn to the handle of a function that only generates points that meet the constraints.
Alternately you could permit those points to be generated, but set the AcceptanceFcn to reject them.

Sign in to comment.


Community Treasure Hunt

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

Start Hunting!

Translated by