フィルターのクリア

How to display the value of a specific component of the objective function after computation is done?

1 回表示 (過去 30 日間)
Good evening,
I was looking through Matlab documentation for genetic algorithm and I found the following example: "Plan Nuclear Fuel Disposal Using Multiobjective Optimization" https://www.mathworks.com/help/gads/multiobjective-nuclear-fuel-disposal.html
After reading through that example, I have a question. Is it possible to display/know the value of a specific component of the objective function for a certain point on the Pareto front after the computation is over?
For instance, if I want to know the value of the objective function "cost" for the first point on the front, the command is:
display(sol(1).cost)
But through this command I get the total cost calculated for the first point.
What if I want to know the value for the third cost component? Is there any way to determine it or not? I tried the following: display(sol(1).cost(3)) but apparently it doesn't work.
Do you have any pointers?
I hope my question is clear. If you need any clarification let me know. I will gladly answer any question and I will be really thankful for any suggestions.
Kind regards,
William
  2 件のコメント
Walter Roberson
Walter Roberson 2023 年 1 月 22 日
(I am trying to investigate this, but the script is running very slowly on my machine :( :( :( )
William
William 2023 年 1 月 22 日
@Walter Roberson unfortunately, I'm aware that that script runs very slowly. In the meantime I tried looking everywhere for similar questions but I couldn't find anything. Please, let me know if you manage to find out something about it. I will greatly appreciate it.

サインインしてコメントする。

採用された回答

Alan Weiss
Alan Weiss 2023 年 1 月 23 日
I'd be very interested to know what you think of the nuclear fuel disposal example.
But to answer your question, let's look at an example that is faster to compute.
x = optimvar("x",1,2,LowerBound=-50,UpperBound=50);
fun(1) = x(1)^4 + x(2)^4 + x(1)*x(2) - x(1)^2*x(2)^2 - 9*x(1)^2;
fun(2) = x(1)^4 + x(2)^4 + x(1)*x(2) - x(1)^2*x(2)^2 + 3*x(2)^3;
prob = optimproblem("Objective",fun);
rng default % For reproducibility
sol = solve(prob)
Solving problem using gamultiobj. Optimization terminated: average change in the spread of Pareto solutions less than options.FunctionTolerance.
sol =
1×18 OptimizationValues vector with properties: Variables properties: x: [2×18 double] Objective properties: Objective: [2×18 double]
Look at the two objective components at the first solution point.
t = sol(1).Objective
Cannot find function "solution.mlx".

Error in ()
Look at just the second objective component at the first solution point.
ob = sol(1).Objective(2)
This is exactly what you tried, and it works fine for me.
Alan Weiss
MATLAB mathematical toolbox documentation
  13 件のコメント
William
William 2023 年 1 月 30 日
@Alan Weiss thank you again for your help! I really appreciate it.
William
William 2023 年 1 月 30 日
@Walter Roberson thank you for your suggestions. They work perfectly as intended.
Have a good day!

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by