How to add constraints to simulannealbnd minimization

4 ビュー (過去 30 日間)
Ole
Ole 2021 年 4 月 14 日
コメント済み: Ole 2021 年 4 月 14 日
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 ],...
'PlotFcn',{@saplotbestf,@saplottemperature,@saplotf,@saplotstopping},'HybridFcn',{'fmincon',hybridopts},...
'AnnealingFcn','annealingboltz','TemperatureFcn','temperatureboltz');
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 = [];

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 4 月 14 日
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.
  3 件のコメント
Walter Roberson
Walter Roberson 2021 年 4 月 14 日
No, nothing like that. AnnealFcn needs to return data points; it is not designed as a constraint function.
Give the command
type annealingboltz
to see the code for the default function.
You would need to add a loop that generated new y and newx and keep going generating new ones if the constraint was not met.
Ole
Ole 2021 年 4 月 14 日
thank you

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeParticle Swarm についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by