フィルターのクリア

Solving equation problem with constrains using the Optimization Toolbox

1 回表示 (過去 30 日間)
MENGZE WU
MENGZE WU 2021 年 11 月 12 日
コメント済み: Matt J 2021 年 11 月 12 日
I have a problem with handful of variables and constrains, it look a lot like this one:
However, instead of finding the minimum cost like the problem above, I already have a target cost, but find the variables that fits this target cost. So I look at the equation problems:
But it seems that the equation problem wouldn't allow me to add constrains, what should I do?

採用された回答

Matt J
Matt J 2021 年 11 月 12 日
編集済み: Matt J 2021 年 11 月 12 日
Use your first approach except specify a least squares objective, like below.
x=optimvar('x','lower',0);
y=optimvar('y','lower',0);
target=10; %target cost
con(1)=x>=y;
con(2)=x+y>=1;
solve( optimproblem('Objective', (x+2*y-target).^2,'Constraints',con) )
Solving problem using lsqlin. Minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
ans = struct with fields:
x: 3.8238 y: 3.0881
Be mindful, however, that the solution will probably be non-unique. For example, another solution to the example problem above is x=10, y=0.
  7 件のコメント
Walter Roberson
Walter Roberson 2021 年 11 月 12 日
If the set of solutions is all points on a particular line or particular plane, then you cannot return them all -- not unless you want to iterate over each distinguishable floating point number in the range.
That is why I was suggesting that the system needed to be integer constrained variables: for those it is possible to list all of the solutions (but it might need a lot of memory if the set of points is large enough.)
Matt J
Matt J 2021 年 11 月 12 日
If the set of solutions is all points on a particular line or particular plane, then you cannot return them all
No, you can't, but it will be a convex polyhedral region and, if bounded, you can use its vertices both to plot the region and to sample an arbitrary number of points from its interior.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNonlinear Optimization についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by