MATLAB Answers

How to write 2 functions both in 2 variables that will be the objective functions of a Multi-objective Genetic Algorithm?

4 views (last 30 days)
Andrea Barison
Andrea Barison on 27 Dec 2019
Answered: Athul Prakash on 2 Jan 2020
This part below is a file code that will be the input for the multi-objective (in my case a bi-objective) genetic algorithm. I don't know exactly who the function should be written. "f1" and "f2" are the function that have to be maximixed/minimized by the algorithm. "x" and "y" are the variables that I want to find as optimum results. Can anyone help me understanding exactly how to write this part?
function z = multiobjective(f1,f2)
Ratio1 = x/(x+y); %D/(D+E)=0.5277
Ratio2 = y/(x+y); %E/(E+D)=0.4723
Re = 0.1022;
Rd = 0.0167;
t = 0.169;
% WACC Formulation:
f1 = Ratio2*Re+Ratio1*Rd*(1-t);
EBT = 3487;
Fc = 231; %finance costs
NI = ((EBT+Fc)-(2*(e-08)*x^3-0.0003*x^2+2.0057*x-3928.9))*(1-(t));
% ROE Formulation:
f2 = NI/y;
end
This part below is instead a simple code where the file "multiobjective" (the code above) is the input. I'm not sure if this is the correct way or if I should create 2 different files (one for each function to maximize or minimize).
FitnessFunction = @multiobjective; % Function handle to the fitness function
numberOfVariables = 2; % Number of decision variables
lb = [0 0]; % Lower bound
ub = [100 100]; % Upper bound
A = []; % No linear inequality constraints
b = []; % No linear inequality constraints
Aeq = []; % No linear equality constraints
beq = []; % No linear equality constraints
options = optimoptions(@gamultiobj,'PlotFcn',@gaplotpareto);
[x,Fval,exitFlag,Output] = gamultiobj(FitnessFunction,numberOfVariables,A,b,Aeq,beq,lb,ub,options);

  0 Comments

Sign in to comment.

Answers (1)

Athul Prakash
Athul Prakash on 2 Jan 2020
Hi Andrea,
I think your approach with the 'multiobjective' function is wrong.
The input 'FitnessFunction' should be returning multiple values - the values of each objective function - aggregated as a vector.
Therefore, in your example, 'multiobjective' should calculate the values of 'f1' and 'f2' from their inputs and return a vector of the calculated values.
Add the line
z = [f1 f2]
to the bottom of the 'multiobjective' function.
Further, the function should accept the variables 'x' and 'y' as inputs, not 'f1' and 'f2'.
Hope it Helps!

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by