How can i formulate this fitness function ?

3 次查看(过去 30 天)
I just started studying Matlab and I need help.
I would like to represent a fitness function and then perform a genetic algorithm.
The function I have to script is the following in the picture:
To begin with, only the first part of the function would be enough. Once I understand the process of representation of the first part, I think I will be able to script the rest.
So it would be enough to understand how to script the following part.
Only the capital letters are variable, and the lower case letters are constant.
So the variable are the parts circled in red. The other are costants, also in the rest of the Function.
So for exemple i need to formulate a Fitness Function like that:
FF1_es.PNG
With N=16 and T=12
Thankyou very much.
  3 个评论
Jon
Jon 2019-8-2
In your last expression, are P and O N by T arrays, and so for example if in the summation we were at i = 2, t = 3 then Pi2t would be P(2,3) and Oi2t would be O(2,3)?
Nicolò Sgarabotto
编辑:Nicolò Sgarabotto 2019-8-2
The function to be minimized is a cost function.
So, is COST = ∑(i=1)^N ∑(t=1)^T〖50 * Pk1t + 70 * Ok1t〗
Where the independent variables are Pk1t and Ok1t.
The dependent variable is the COST.
I want to optimize the variables of the model so as to obtain a minimum cost.
For Jon:
Yeah, exactly as you said.
For example P =[10 , 20 , 12; 15 , 17 , 21]
This is an APP (Aggregate Production Planning) Model.
I am attaching the description of the model variables so maybe it becomes easier to understand what I'm talking about.
And this is some parameters:

请先登录,再进行评论。

回答(1 个)

Navya Seelam
Navya Seelam 2019-8-7
Hi,
In this case P and O are variables of the order 16-by-12. Use syms to create the symbolic variables and nested for-loop to create the symbolic expression. If function handle is required “matlabFunction” can be used.
syms P O [16 12] % creating symboloc variables
h=0;
for i=1:16
for t=1:12
h=h+50*P(i,t)+70*O(i,t); %creating symbolic expression
end
end
FitnessFunction=matlabFunction(h); %converting symbolic expression to function handle

类别

Help CenterFile Exchange 中查找有关 Linear Programming and Mixed-Integer Linear Programming 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by