kindly help in debugging the following code for optimization
Show older comments
function [ f, g ] = problem_function( x ) D1=x(1);D2=x(2);D3=x(3);D4=x(4);D5=x(5);P1=x(6);P2=x(7);P3=x(8);P4=x(9);P5=x(10);V1=x(11);V2=x(12);V3=x(13);V4=x(14);V5=x(15); L1=2;L2=3;L3=4;L4=5;L5=6; L=[L1 L2 L3 L4 L5]; D=[D1 D2 D3 D4 D5]; %%%%%%%%%%%%%%%%%%%%%%%%% Q1=V1*(3.14/4)*D1^2; Q2=V2*(3.14/4)*D2^2; Q3=V3*(3.14/4)*D3^2; Q4=V4*(3.14/4)*D4^2; Q5=V5*(3.14/4)*D5^2; % Objective functions F(X) CT=2.05*L*D'.^3; %%%%%%%%%%%%%%%%%%%%%%% if all(P(1:5)>=18) CPP=0; else CPP=(CT/5)*sum(18-P(1:5)); end %%%%%%%%%%%%%%%%%%%% if all(V(1:5)<=10) CPV=0; else CPV=(CT/5)*sum(V(1:5).^2-100); end %%%%%% f=CT+CPV+CPP; % Equality constraints G(X) = 0 MUST COME FIRST in g(1:me) g(1)=P1-P2-11.7*(L1*Q1^3/D1^5); g(2)=P2-P3-11.7*(L2*Q2^3/D2^5); g(3)=P3-P4-11.7*(L3*Q3^3/D3^5); g(4)=P2-P4-11.7*(L4*Q4^3/D4^5); g(5)=P4-P5-11.7*(L5*Q5^3/D5^5); g(6)= 40-Q1; g(7)=Q1-Q2-Q4; g(8)=Q2-14-Q3; g(9)=Q3+Q4-Q5;
end %%%% the result say Undefined function or variable 'P'.
Error in example>problem_function (line 82) if all(P(1:5)>=18) any helps plz.
Accepted Answer
More Answers (1)
Munna
on 11 Jul 2024
0 votes
function [M,V,G,F]= fcn(t,q1,q2,q3,q4,q5,qd1,qd2,qd3,qd4,qd5)
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!