Setting conditions for optimization variables

1 ビュー (過去 30 日間)
A.O.
A.O. 2022 年 8 月 19 日
コメント済み: A.O. 2022 年 8 月 22 日
We are now setting the conditions for the following optimization variables.
x = optimvar('x', 100, 'LowerBound', 0)
showbounds(x)
Then,
0<=x(1)
0<=x(2)
・・・
0<=x(100).
How do we write the code to add the following condition?
We want to add an upperbond=0 in the interval 1 < x < 10.
0<=x(1)<=0
0<=x(2)<=0
・・・
0<=x(10)<=0
0<=x(11)
0<=x(12)
・・・
0<=x(100)
  1 件のコメント
A.O.
A.O. 2022 年 8 月 22 日
Thank you for your nice answer!!

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

採用された回答

Alan Weiss
Alan Weiss 2022 年 8 月 19 日
x = optimvar('x', 100, 'LowerBound', 0);
ub = Inf(100,1);
ub(1:10) = zeros(10,1);
x.UpperBound = ub;
showbounds(x)
0 <= x(1) <= 0 0 <= x(2) <= 0 0 <= x(3) <= 0 0 <= x(4) <= 0 0 <= x(5) <= 0 0 <= x(6) <= 0 0 <= x(7) <= 0 0 <= x(8) <= 0 0 <= x(9) <= 0 0 <= x(10) <= 0 0 <= x(11) 0 <= x(12) 0 <= x(13) 0 <= x(14) 0 <= x(15) 0 <= x(16) 0 <= x(17) 0 <= x(18) 0 <= x(19) 0 <= x(20) 0 <= x(21) 0 <= x(22) 0 <= x(23) 0 <= x(24) 0 <= x(25) 0 <= x(26) 0 <= x(27) 0 <= x(28) 0 <= x(29) 0 <= x(30) 0 <= x(31) 0 <= x(32) 0 <= x(33) 0 <= x(34) 0 <= x(35) 0 <= x(36) 0 <= x(37) 0 <= x(38) 0 <= x(39) 0 <= x(40) 0 <= x(41) 0 <= x(42) 0 <= x(43) 0 <= x(44) 0 <= x(45) 0 <= x(46) 0 <= x(47) 0 <= x(48) 0 <= x(49) 0 <= x(50) 0 <= x(51) 0 <= x(52) 0 <= x(53) 0 <= x(54) 0 <= x(55) 0 <= x(56) 0 <= x(57) 0 <= x(58) 0 <= x(59) 0 <= x(60) 0 <= x(61) 0 <= x(62) 0 <= x(63) 0 <= x(64) 0 <= x(65) 0 <= x(66) 0 <= x(67) 0 <= x(68) 0 <= x(69) 0 <= x(70) 0 <= x(71) 0 <= x(72) 0 <= x(73) 0 <= x(74) 0 <= x(75) 0 <= x(76) 0 <= x(77) 0 <= x(78) 0 <= x(79) 0 <= x(80) 0 <= x(81) 0 <= x(82) 0 <= x(83) 0 <= x(84) 0 <= x(85) 0 <= x(86) 0 <= x(87) 0 <= x(88) 0 <= x(89) 0 <= x(90) 0 <= x(91) 0 <= x(92) 0 <= x(93) 0 <= x(94) 0 <= x(95) 0 <= x(96) 0 <= x(97) 0 <= x(98) 0 <= x(99) 0 <= x(100)
It would probably be better to remove x(1) through x(10) from your problem, but suit yourself.
Alan Weiss
MATLAB mathematical toolbox documentation

その他の回答 (0 件)

カテゴリ

Find more on Problem-Based Optimization Setup in Help Center and File Exchange

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by