I am facing difficulty in displaying output of multi objective genetic algorithm.

This is my fitness function
function t=strength(x)
t(1) = -138.012+0.173.*x(1)+0.113.*x(2)+0.107.*x(3)+0.715.*x(4)-0.301.*x(5)-0.072.*x(6)+0.036.*x(7)+0.083.*x(8)+15.557.*x(9);
t(2) = 0.350-0.002.*x(1)-0.002.*x(2)+0.0.*x(3)+0.0.*x(4)-0.015.*x(5)+0.004.*x(6)-0.001.*x(7)-0.00000827.*x(8)-0.910.*x(9)+0.058.*x(10)+0.008.*x(11)+0.090.*x(12)-0.458.*x(13);
end
and this is my calling function
clear all
clc
opts.PopulationSize = 1000;
rng default;
options = optimoptions('gamultiobj','MutationFcn',@mutationadaptfeasible, 'CrossoverFcn', {@crossoverarithmetic}, 'SelectionFcn', {@selectiontournament,3}, 'PlotFcn', {@gaplotselection, @gaplotscorediversity, @gaplotbestindiv, @gaplotdistance, @gaplotpareto}, 'MaxGenerations', 1e5);
A = []; b = []; Aeq = []; beq = []; lb = [350 0 0 50 2 180 806 983 0.45 5 27.5 23.96 0]; ub = [350 0 0 50 2 180 806 983 0.45 5 27.5 23.96 0]; nonlcon = [];
obj = @(x) (strength(x));
bestx = gamultiobj(obj, 13, A, b, Aeq, beq, lb, ub, nonlcon, options);
format long g
Is their any way i can minimize the t(2), and simultaneous maximize t(1) and also
I want to show the final output of t(1) and t(2) and respective value of their variables ( x(1),x(2),x(3).....etc).

Answers (2)

obj = @(x) [-1 1].*strength(x);

3 Comments

hey walter! thanks for the answer but can you please explain it and also can you help me displaying the output
Maximizing a function is the same as minimizing the negative of the function.
[bestx, fval] = gamultiobj(obj, 13, A, b, Aeq, beq, lb, ub, nonlcon, options);
fval = [-1 1].*fval;
The t1 values are now fval(:, 1) and the t2 values are fval(:, 2). For any given row fval(K, :) corresponds to bestx(K, :)
Remember that gamultiobj returns a set of Pareto solutions, places where you cannot improve one of the functions without making the other worse. It is not necessarily possible for there to be a global best solution.
Imagine for example if the equations described a circle and you were trying to maximize x while minimizing y: maximum x is the right of the circle but minimum y is the bottom of the circle, and you cannot have both simultaneously.
You can, of course, min() and max() the fval columns and you might happen to get lucky and find a location that has both at the same time. You just cannot count on it.

Sign in to comment.

thank you for the information, walter!
but as an output i have been shown this. Is there any way i can get single value of the variable rather than many values of same variable. for instance x(1)=350, x(2)=0...etc.
Optimization terminated: average change in the spread of Pareto solutions less than options.FunctionTolerance.
bestx =
Columns 1 through 5
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
350 0 0 50 2
Columns 6 through 10
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
180 806 983 0.45 5
Columns 11 through 13
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
27.5 23.96 0
fval =
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059
62.33165 1.78277059

1 Comment

Is there any way i can get single value of the variable
Maybe, but perhaps not.
gamultiobj() would not normally generate duplicates, which suggests to me that the values you are seeing are possibly non-unique in decimal places not shown. For example there might be differences in the 7th decimal place. gamultiobj() would assume those differences are important, since you did not use options to increase the tolerance.
You could try reducing the list by
[~, ia] = uniquetol(bestx, 'byrows', true);
reduced_bestx = bestx(ia,:);
reduced_fval = fval(ia,:);

Sign in to comment.

Products

Release

R2018a

Asked:

on 17 Apr 2022

Commented:

on 18 Apr 2022

Community Treasure Hunt

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

Start Hunting!