1

I want to write two objective functions based on NSGA2 genetic algorithm in Matlab, However, i'm confusing to input chromosomes to evaluate my objectives, and in my objective function, the chromosomes are unused, I don't know how to evaluate Objective function according to chromosomes where my function call is evaluateObjective(chromosome(ii,:), V) and I'v following parameters to input.

S = [0.9 0.8 0.3 0.3];
W = [0.9 0.7 0.4 0.1];
P = [15 17 18];
T = [13 14 13];
V=4;  

My desire Function:

Obj1: for all w belongs to W and p belongs to P
summation of (w*p)

Obj2: for all t belongs to T and s belongs to S
summation of (t*s)

And the objective function:

function f = evaluateObjective(x, V) %x is the choromosome
        % Objective function 1
        sum = 0;
        for i = 1 : V - 1
            sum = sum - W((i))*P;
        end
        f(1) = sum;
        % Objective function 2
        sum = 0;
        for i = 1 : V
            sum =  sum + S*S(i);
        end
        f(2) = sum;

    end 
OnABauer
  • 609
  • 4
  • 18
user3593525
  • 253
  • 3
  • 16

1 Answers1

0

It's not clear from the code what exactly you are doing, so I can't be specific. However:

If f(X) = Y is the function to be optimized, the function maps a X vector (in the decision space) of the problem to a Y vector (in the objective space)

The cloning and mutation of chromosomes happens is done in decision space, while the evaluation is done in the objective space of the problem. That is, if X is a chromosome, you don't pass the chromosome itself to the evaluation function, but its mapping in the objective space. that is

fitness = evaluate(X, ...) //wrong
fitness = evaluate(f(X), ...) // correct

The NSGA2 algorithm in particular selects only non-dominated chromosomes, so a chromosome is not evaluated by itself, but in comparison to the other chromosomes in your population. So you have to pass all the all the chromosomes, and keep only these for which

all(f(X) <= f(X_i))

for every X_i in the population.

blue_note
  • 27,712
  • 9
  • 72
  • 90