solving constrait optimization using external varibales
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
Hi i am trying to solve constarint optimization usinf for loop, Actually i trying to maximize x with this constrains but olsa i have external variable that has some interval. Therefore i tyr to determined them using for loop but it is not working . What am i doing wrong?
for g=0:.1:0.5 % start at 0, step by 0.1 up to 1
for t = 0.5:.1:1
if g +t <= 0.5
fun = @(x)-((1-x)+ log(x)+log(g)+0*t);
lb = 0;
ub = 1;
A = [];
b = [];
Aeq = [];
beq = [];
x0 = (lb+ub)/2;
nonlcon = [];
options = optimoptions('fmincon','Algorithm','interior-point',...
'OptimalityTolerance',1e-20, ...
'StepTolerance', 1e-20, ...
'ConstraintTolerance', 1e-20, ...
'Display', 'iter' );
[x, fval] = fmincon(fun, x0, A, b, Aeq, beq, lb, ub, nonlcon, options);
disp(x)
disp(fval)
else
fprintf('\nThe number of people who agree is\n',x);
end
end
1 个评论
Sinem Senel
2020-8-11
回答(0 个)
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
