solving constrait optimization using external varibales
Info
This question is closed. Reopen it to edit or answer.
Show older comments
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 Comment
Sinem Senel
on 11 Aug 2020
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!