Constraint condition and IF statement
Afficher commentaires plus anciens
hi all I need help to write a constraint condition used if statement as seen below i have error when put (if) after Ceq . how write it and sovled the error?
function [c,ceq]=bb12(x)
.
.
.
ceq=if (((0.025*(x(1)^2)*(1-exp((-1.025*x(3))/x(1))))/(((x(2)^2)/(x(1)+x(2)))*(1-exp((-0.513*x(3)*(x(1)+x(2)))/(x(1)*x(2))))))) <=(0.5*x(7)-0.025)
x(9)=((13.91*((x(1)*(x(2)^2))/(x(1)+x(2)))*(1-exp((-0.513*x(3)*(x(1)+x(2)))/(x(1)*x(2))))*(0.5*x(7)+((((0.025*(x(1)^2)*(1-exp((-1.025*x(3))/x(1))))/(((x(2)^2)/(x(1)+x(2)))*(1-exp((-0.513*x(3)*(x(1)+x(2)))/(x(1)*x(2))))))))-0.025))/(0.9*1000*275*(x(7)-0.05)));
else if (((0.025*(x(1)^2)*(1-exp((-1.025*x(3))/x(1))))/(((x(2)^2)/(x(1)+x(2)))*(1-exp((-0.513*x(3)*(x(1)+x(2)))/(x(1)*x(2))))))) > (0.5*x(7)-0.025)
x(9)=(((13.91*((x(1)*(x(2)^2))/(x(1)+x(2)))*(1-exp((-0.513*x(3)*(x(1)+x(2)))/(x(1)*x(2)))))/0.9)+(0.85*35*1000*x(2)*0.411*(x(7)-0.025))+(x(10)*((600083*(0.411*(x(7)-0.025)-(0.85*0.025))/(0.411*(x(7)-0.025)))-(849.77*35))));
else
x(9)=(0.0025*x(7));
end
end;
Error:Illegal use of reserved keyword "if".
2 commentaires
James Tursa
le 8 Juil 2015
What are c and ceq? They are returned from your function but it is not clear what they are supposed to be.
tahseen90 abd
le 9 Juil 2015
Réponse acceptée
Plus de réponses (1)
Azzi Abdelmalek
le 8 Juil 2015
Modifié(e) : Azzi Abdelmalek
le 8 Juil 2015
Remove ceq= from your If expression
a=(((0.025*(x(1)^2)*(1-exp((-1.025*x(3))/x(1))))/(((x(2)^2)/(x(1)+x(2)))*(1-exp((-0.513*x(3)*(x(1)+x(2)))/(x(1)*x(2)))))))
if a<=(0.5*x(7)-0.025)
x(9)=((13.91*((x(1)*(x(2)^2))/(x(1)+x(2)))*(1-exp((-0.513*x(3)*(x(1)+x(2)))/(x(1)*x(2))))*(0.5*x(7)+((((0.025*(x(1)^2)*(1-exp((-1.025*x(3))/x(1))))/(((x(2)^2)/(x(1)+x(2)))*(1-exp((-0.513*x(3)*(x(1)+x(2)))/(x(1)*x(2))))))))-0.025))/(0.9*1000*275*(x(7)-0.05)));
else if a > (0.5*x(7)-0.025)
x(9)=(((13.91*((x(1)*(x(2)^2))/(x(1)+x(2)))*(1-exp((-0.513*x(3)*(x(1)+x(2)))/(x(1)*x(2)))))/0.9)+(0.85*35*1000*x(2)*0.411*(x(7)-0.025))+(x(10)*((600083*(0.411*(x(7)-0.025)-(0.85*0.025))/(0.411*(x(7)-0.025)))-(849.77*35))));
else
x(9)=(0.0025*x(7));
end
Catégories
En savoir plus sur Genetic Algorithm dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!