objective function - genetic algorithm - fitness - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# objective function - genetic algorithm - fitness

Posts: 2Member
hi
I'm going to optimal under function with algorithm genetic in matlab

tc =p.*u.*q*0.5 + A.*D./Q +yy.*b.*b*0.5/Q

I wrote a function for objective function.
my fun have three unknown and some known parameters.

how do I write function for matlab genetic tool objective function that gatools do optimal my fun.

function TC = TC_fitness(Q,b,q)

m=5; %number of item;
Q=zeros(1,m); %unknown ;
q=zeros(1,m); %unknown ;
b=zeros(1,m); %unknown ;
u=zeros(1,m); %variable ;
A=zeros(1,m); %variable ;
D=zeros(1,m); %variable ;

yy=zeros(1,m); %variable ;
p=zeros(1,m); %variable ;
tc=zeros(1,m); %cost per item ;
TC=zeros(1,1); %total cost ;
p=[0.3 0.3 0.3 0.3 0.3]; %variable ;
A=[3 4 5 3 3]; %value parameter;
D=[420 360 540 390 480]; %value parameter;

u=[13 30 23 6 13]; %value parameter;
q=Q./N;

tc =p.*u.*q*0.5 + A.*D./Q +yy.*b.*b*0.5/Q
TC= sum(tc);

end

thanks a lot
[email protected]