How can write code of multi objective functions with using optimproblem format?
2 次查看(过去 30 天)
显示 更早的评论
How can I define functions of multi objective problem with optimproblem format? My mean is using problem based method not using solver based method. ?
For example I have this optimization model:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/252053/1.png)
That this model has two objectives.
I want to write the code of this model with optomproblem.
So I attach my model as above:
prob.Objective = x(1) + 2*x(2);
But above formolation is for one objective function not multi objective problems.
But I have two objective function in my model and I don't know how can I coded them with this method ☹
3 个评论
Star Strider
2019-12-2
My pleasure.
That could help, providing your code is well-documented so we can understand what it does.
采纳的回答
Walter Roberson
2019-12-3
You cannot. Examine https://www.mathworks.com/help/optim/ug/problem-based-optimization-algorithms.html and observe that none of the algorithms are multi-objective . Or look at https://www.mathworks.com/help/optim/ug/optimproblem.html#d117e128953 and see that for problem based optimization, the objective must be scalar.
5 个评论
Walter Roberson
2019-12-3
Look at the example for problem2struct() .
%bunch of code
steelprob.Constraints.conswt = totalweight == 25;
steelprob.Constraints.conscarb = totalCarbon == 1.25;
steelprob.Constraints.consmolyb = totalMolyb == 1.25;
problem = prob2struct(steelprob);
Now
>> problem
problem =
struct with fields:
intcon: [5 6 7 8]
lb: [8×1 double]
ub: [8×1 double]
x0: []
f0: 0
f: [8×1 double]
solver: 'intlinprog'
Aineq: []
bineq: []
Aeq: [3×8 double]
beq: [3×1 double]
options: []
You would do the same thing for each of the optimproblem that you created. You would need to compare that lb contained the same thing for each, and that ub contained the same thing for each, and likewise Aineq and bineq and Aeq and beq and intcon . Then having verified that those were all the same, you would extract the common ones into variables
joint_A = problem.Aineq;
joint_b = problem.Bineq;
and so on
and you would extract the various f fields describing the objective functions and merge them together into one, that might look something like
joint_obj = @(x) [problem.f(x), problem2.f(x)];
I think you would be ending up with the same nonlcon for all of them rather than having to merge them
and then call
gamultiobj(joint_obj, length(joint_lb), joint_A, joint_b, joint_Aeq, joint_beq, joint_lb, joint_ub, joint_nlcon, joint_options)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!