Solving an optimization problem using fmincon

Can anyone help me to solve this? I do not know how to use the contraint on C3 and how to implement ri in it!

 採用された回答

Alan Weiss
Alan Weiss 2021 年 8 月 22 日

1 投票

I think that this is a straightforward problem is you use the problem-based optimization workflow, which requires a relatively recent version of Optimization Toolbox™.
Alan Weiss
MATLAB mathematical toolbox documentation

3 件のコメント

Behzad Eydiyoon
Behzad Eydiyoon 2021 年 8 月 23 日
thank you for the reply
I wrote this code for it
clc
clear
close all
prob = optimproblem('ObjectiveSense','min');
x = optimvar('x',3,1,'LowerBound',0,'UpperBound',inf);
i=[1:3];
j=[1:3];
a=rand(3,1);
a1=diag(a)';
r=rand(3,1);
cons1 = sum(x(i)) <= 10;
cons2 = sum(r(i).*x(i)) >= 10;
prob.Constraints.cons1 = cons1;
prob.Constraints.cons2 = cons2;
prob.Objective = sum(sum(a1(i,j),2).*x(i).*x(j));
[sol,fval] = solve(prob);
disp(sol.x)
disp(fval)
seems to be okay. it worked but also it said : "quadprog stopped because it was unable to find a point that satisfies the constraints within the value of the constraint tolerance"
Alan Weiss
Alan Weiss 2021 年 8 月 23 日
So you were able to program it. Good for you!
Now let's look at your constraints:
cons1 = sum(x) <= 10;
cons2 = sum(r.*x) >= 10;
The r variable has all entries between 0 and 1, and the x variable is nonnegative. Therefore, for any x satisfying cons1, the value of sum(r.*x) is smaller. Therefore your constraints are inconsistent.
Alan Weiss
MATLAB mathematical toolbox documentation
Behzad Eydiyoon
Behzad Eydiyoon 2021 年 8 月 23 日
you are right!
thank you a lot.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeNonlinear Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by