How to display the value of a specific component of the objective function after computation is done?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
William
am 20 Jan. 2023
Kommentiert: William
am 30 Jan. 2023
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 Kommentare
Walter Roberson
am 22 Jan. 2023
(I am trying to investigate this, but the script is running very slowly on my machine :( :( :( )
Akzeptierte Antwort
Alan Weiss
am 23 Jan. 2023
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)
Look at the two objective components at the first solution point.
t = sol(1).Objective
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 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!