現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
I am facing difficulty in displaying output of multi objective genetic algorithm.
1 回表示 (過去 30 日間)
古いコメントを表示
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).
回答 (2 件)
Walter Roberson
2022 年 4 月 17 日
obj = @(x) [-1 1].*strength(x);
3 件のコメント
harsh Brar
2022 年 4 月 17 日
hey walter! thanks for the answer but can you please explain it and also can you help me displaying the output
Walter Roberson
2022 年 4 月 17 日
Maximizing a function is the same as minimizing the negative of the function.
Walter Roberson
2022 年 4 月 17 日
[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
2022 年 4 月 18 日
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 件のコメント
Walter Roberson
2022 年 4 月 18 日
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,:);
参考
カテゴリ
Help Center および File Exchange で Genetic Algorithm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)