Need to show solutions (x) per iteration

조회 수: 1 (최근 30일)
Roberto Louis
Roberto Louis 2024년 9월 16일
댓글: Sergio E. Obando 2024년 9월 17일
I am using this optimizer tool since Matlab obliterated the old one ---->
It has all these options, shown in the image bellow, to display many different values per iteration, except an option to display each value of the solution, x, at each iteration - which is what I need.
I have noticed that a lot of people have already asked the same question, but all the answers don't seem to apply to the code I'm using (generated by the new optimization tool). While answers related to the old tool box do not apply anymore. The code the new tool generates looks a bit like this:
% Pass fixed parameters to objfun
objfun19 = @(x)LDR(x);
% Set nondefault solver options
options20 = optimoptions("gamultiobj","ConstraintTolerance",1e-05,"Display",...
"iter");
% Solve
[solution0,objectiveValue0] = gamultiobj(objfun19,v0,[],[],[],[],min,max,[],[],...
options20);
Where x is an array. I have been using multi-objective genetic algorithm, pareto search, and fmincon, which all look almost the same.
Appreciate any help. Please and thank you.
  댓글 수: 1
Ayush Aniket
Ayush Aniket 2024년 9월 16일
Hi Roberto,
I am assuming by old answers you mean defining a custom 'OutputFcn' in the 'optimoptions' function. Why do you think its not applicable here?

댓글을 달려면 로그인하십시오.

답변 (1개)

Sergio E. Obando
Sergio E. Obando 2024년 9월 16일
Hi Roberto,
I am curious what information or capability from the "optimtool" you feel is missing in the "optimize" live task?
Are you interested in the function and decision variable display in red below?
If you need additional information, the outputFcn is the right approach. This is a good example, where you could set to save every iteration rather than 10:
  댓글 수: 2
Roberto Louis
Roberto Louis 2024년 9월 17일
Yes! This is what I'm looking for. I will try the outputFcn the way described
Sergio E. Obando
Sergio E. Obando 2024년 9월 17일
The output on the optimtool is only the last population/scores, the outputFnc could give you that and the full history. For just the last values, you could also add those outputs to the function call:
[solution,objectiveValue,~,~,pop,scores] = gamultiobj(fitnessfcn,N,[],[],[],[],[],[],[],[], options);
FYI: you can turn the live task permanently into code if you no longer need to modify things from the UI.

댓글을 달려면 로그인하십시오.

태그

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by