フィルターのクリア

use fmincon with 0<x1<x2<x3

1 回表示 (過去 30 日間)
xone92_
xone92_ 2022 年 10 月 27 日
回答済み: Steven Lord 2023 年 10 月 22 日
Hello there,
I would be interested if I can use fmincon in a way that 0<x1<x2<x3 when i have a function f(x) with x=[x1 x2 x3....]
Greetings

採用された回答

Torsten
Torsten 2022 年 10 月 27 日
編集済み: Torsten 2022 年 10 月 27 日
Strict inequality is not possible. If you are satified with <= instead of <, use
-x1 <= 0
x1 - x2 <= 0
x2 - x3 <= 0
or in the A,b setting of fmincon
A = [-1 0 0;1 -1 0;0 1 -1]
b = [0;0;0]
  3 件のコメント
Matt J
Matt J 2022 年 10 月 28 日
@xone92_ If it worked, then you should Accept-click Torsten's answer.
Marko
Marko 2023 年 10 月 22 日
This thread is "solved" and almost 1year old.
But maybe, somebody need a solution which is strictly "<" instead of "<=".
I suggest this workaround: choose a small number as delta, e.g.:
dx = 2*eps
-x1 <= dx
x1 - x2 <= dx
x2 - x3 <= dx
or in the syntax for fmincon:
dx = eps;
A = [-1 0 0;1 -1 0;0 1 -1];
b = [dx;dx;dx];

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2023 年 10 月 22 日
Another possible solution is to redefine your code in terms of d(1), d(2), d(3), etc. Constrain all the elements of the d vector to be greater than eps (or some other small value, whatever difference you want to be the minimum that the elements of x can be separated by) using a lower bound. Inside your objective function compute the x vector as cumsum(d) and use it in your calculations.
d = [1 0.25 3]
d = 1×3
1.0000 0.2500 3.0000
x = cumsum(d)
x = 1×3
1.0000 1.2500 4.2500
If you want to allow some of the consecutive elements of x to be equal, the lower bound for that element in d is 0.
d = [1 0.25 0 3]
d = 1×4
1.0000 0.2500 0 3.0000
x = cumsum(d)
x = 1×4
1.0000 1.2500 1.2500 4.2500

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by