Constraint condition and IF statement
이전 댓글 표시
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
James Tursa
2015년 7월 8일
What are c and ceq? They are returned from your function but it is not clear what they are supposed to be.
tahseen90 abd
2015년 7월 9일
채택된 답변
추가 답변 (1개)
Azzi Abdelmalek
2015년 7월 8일
편집: Azzi Abdelmalek
2015년 7월 8일
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
카테고리
도움말 센터 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!