solving constrait optimization using external varibales
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
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 commentaire
Sinem Senel
le 11 Août 2020
Réponses (0)
Cette question est clôturée.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
