Constraint condition and IF statement
Mostrar comentarios más antiguos
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 comentarios
James Tursa
el 8 de Jul. de 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
el 9 de Jul. de 2015
Respuesta aceptada
Más respuestas (1)
Azzi Abdelmalek
el 8 de Jul. de 2015
Editada: Azzi Abdelmalek
el 8 de Jul. de 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
Categorías
Más información sobre Genetic Algorithm en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!