How to write an inequality constraint to solve NLP problem by fmincon

6 ビュー (過去 30 日間)
Rajkumar Verma
Rajkumar Verma 2023 年 1 月 8 日
コメント済み: Rajkumar Verma 2023 年 1 月 8 日
Dear all,
I am solving a non-linear optimization problem. My problem has following constraints:
I need your help in wtiting first two constraints. How to express first two constraints in fmincon?

採用された回答

John D'Errico
John D'Errico 2023 年 1 月 8 日
編集済み: John D'Errico 2023 年 1 月 8 日
They are NOT TWO constraints. They are FOUR constraints. Just because you want to be efficient in how you write them in terms of the mathematics, the fact remains, they are four constraints. Just write them as 4 separate constraints. There is no additional charge. ;-)
How do you express them? Just use the linear constraints, so you will create a matrix of coefficients, just as you must do for the constraint x(1) + x(2) == 1. The inequality constraint array will be of size 4 by 6. So you have 4 constraints, and 6 unknowns.
  5 件のコメント
John D'Errico
John D'Errico 2023 年 1 月 8 日
編集済み: John D'Errico 2023 年 1 月 8 日
Suppose you have the following run-on constraints:
x1 <= x2 <= x3
They are very simply written, and use a scheme that many use and understand in mathematics. But it is not one that MATLAB uses. What do they mean? Start with the first one. We understand that
x1 < x2
or
x1 - x2 <= 0
similarly, the second inequality is just another constraint, that involves ONLY x2 and x3.
x2 <= x3
or
x2 - x3 <= 0
Similarly, the set of constraints you have are just as easy to expand. Start with the first inequality. It reduces to (after re-arrangment)
-x1 -x3 <= -0.15
Th second constraint becomes
x1 - x4 <= 0.70
etc.
Now you write this in a matrix form, as
A = [-1 0 -1 0 0 0;
1 0 0 -1 0 0;
0 -1 0 0 -1 0;
0 1 0 0 0 -1];
b = [-0.15;0.7;-0.25;0.65];
If you multiply A by a vector of the unknowns, it will generate exactly those constraints. For example
syms x [6 1]
A*x<=b
ans = 
Rajkumar Verma
Rajkumar Verma 2023 年 1 月 8 日
Thanks for this clarification

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by