# Design Optimization Toolbox MATLAB based on 2 or more outputs

1 view (last 30 days)
Hi,
I want to carry out a design optimization task. I have a code which has a set of input variables and using different formulas it gives me different outputs but the ones I want to optimize are only 2 specific outputs. It works fine when I want to optimize one output but it doesn't do it for 2.
I created an objective function which starts like this:
function [pressure_drop,Max_walltemp]=codeNoc(noc)
....
and then i created and optimization file to run fmincon
%----------------------------------------------------
objFcn = @(noc) codeNoc(noc);
noc0 = 80;
lb = 2;
ub = 110;
options = optimset('Algorithm','interior-point','Disp','iter');
[xOpt, fVal] = fmincon(objFcn, noc0,[],[],[],[],lb,ub,[],options);
%----------------------------------------------------
Unfortuantely it only optimizes based the first output which is 'pressure_drop' but i want to find the optimum 'noc' to minimize both the 'pressure_drop' and 'Max_walltemp'.
Am I using the right solver and algorithm?
Thank you!!

Mario Malic on 8 Nov 2020
Edited: Mario Malic on 8 Nov 2020
Use fgoalattain to minimise both functions
function fobj = codeNoc(noc)
%Code
fobj(1) = pressure_drop;
fobj(2) = Max_walltemp
end
You could also do it with fmincon, but it's better not to, unless you really have to do it with it. However, keep in mind, fmincon accepts only scalar as the value of objective function.
Please read the documentation on fgoalattain as you should define few other parameters such as weight and goals.

Steve Grikschat on 14 Nov 2020
Most solvers in Optimization and Global Optimization toolboxes are for single objectives.
As Mario shared, you can use a "goal-attainment" formulation (fgoalattain) to try to minimize both simultaneously, or you can look for *Pareto optimal* solutions using a Global Optimization toolbox solver like gamultiobj or paretosearch.
*These are a set of solutions where none is said to "dominate" the other. That is, you must give up a little bit in one objective in order to improve the other, and vice versa. Note: this only applies if your 2 objectives "compete" with each other and you must explore trade-offs. This is most often the case in design problems.
If, by the way, your objectives are completely independent, then the best way to solve them is to do 2 separate optimizations.

R2020b

### Community Treasure Hunt

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

Start Hunting!