You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
I am facing difficulty in displaying output of multi objective genetic algorithm.
1 view (last 30 days)
Show older comments
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)
Walter Roberson
on 17 Apr 2022
obj = @(x) [-1 1].*strength(x);
3 Comments
harsh Brar
on 17 Apr 2022
hey walter! thanks for the answer but can you please explain it and also can you help me displaying the output
Walter Roberson
on 17 Apr 2022
Maximizing a function is the same as minimizing the negative of the function.
Walter Roberson
on 17 Apr 2022
[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.
harsh Brar
on 18 Apr 2022
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
Walter Roberson
on 18 Apr 2022
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,:);
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)