Quick substitution of all multi-objective optimization results (gamultiobj) into optimization expressions

23 次查看(过去 30 天)
I'm using problem-based optimization formulation for the first time (it's great!) and I've been struggling a bit with how to interact seamlessly with the results. My optimization is multi-objective and the setup has the following characteristics:
  • Using problem-based optimization formulation, I'm defining many variables using optimvar (e.g., rho, D, W)
  • From there I'm defining objective and constraint functions as OptimizationExpression objects, e.g. V=pi*(D/2)^2*W, M=rho*V (simplified but still relevant to my actual problem)
  • In my case, minimizing volume V is one of the objectives, but M is a part of another objective as well as some constraints, so I would like to quickly evaluate the OptimizationExpression M over the optimization results (Pareto front) returned within sol and use it in some post-processing plots.
After much experimentation, I did find that I can substitute a particular result by index into an existing OptimizationExpression object using the following syntax:
ii=10; % Index of solution I'm interested in
solStruct=struct(sol(ii));
Mval=evaluate(M,solStruct.Values);
Obviously I can build a loop over ii to get an array Mval, but is there a way to do it more elegantly? (And am I using the intended method to evaluate a single solution from the optimization?)

回答(1 个)

Matt J
Matt J about 11 hours 前
编辑:Matt J about 2 hours 前
Obviously I can build a loop over ii to get an array Mval, but is there a way to do it more elegantly?
Doesn't seem it like it. If "more elegantly" means doing it in one line of code, you can make your own mfile function to hide the loop, or you can use arrayfun,
Mval=arrayfun( @(s) evaluate(M,struct(s).Values) ,sol);

类别

Help CenterFile Exchange 中查找有关 Multiobjective Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by