add conditional constrain in optimization

5 ビュー (過去 30 日間)
Fathima
Fathima 2023 年 2 月 27 日
コメント済み: Fathima 2023 年 3 月 15 日

if a=0 then q=0
if a=1 then q=24;
if a=2 then q=32;
if a=3 then q=44;

how to write this as constrain for optimization problem?

  5 件のコメント
Torsten
Torsten 2023 年 2 月 27 日
Which optimizer do you use ?
Is a defined to be integer ?
Is q defined to be integer ?
Are a and q solution variables ?
Fathima
Fathima 2023 年 2 月 28 日
編集済み: Fathima 2023 年 2 月 28 日
@Torsten @Rik I will explain my problem more clearly.. I have 3 pumps so number of pumps 'a' working at the time t denoted by a[t] can take values =0,1,2,3. Now supply of water at time t denoted by Q[t] depends on a[t] that is given by if a[t]=0 then Q[t]=0 if a[t]=1 then Q[t]=24; if a[t]=2 then Q[t]=32; if a[t]=3 then Q[t]=44;
Objective is to minimize number of pumps used at time t
My doubt it how to implement this conditional constraint in MATLAB ?

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

採用された回答

Torsten
Torsten 2023 年 2 月 28 日
編集済み: Torsten 2023 年 2 月 28 日
Define x_it be the decision variable if pump i is active at time t. That means x_it can take values 0 and 1 and equals 0 of pump i is off at time t and equals 1 if pump i is on at time t.
Then your problem somehow looks like
min: sum_t (x1t + x2t + x3t)
24*x1t + 32*x2t + 44*x3t >= amount of water needed at time t (t=1,...,T)
0 <= x_it < = 1
x_it integer
You can use "intlinprog" to solve.
  35 件のコメント
Torsten
Torsten 2023 年 3 月 5 日
編集済み: Torsten 2023 年 3 月 5 日
Why should "intlinprog" use the strategy to switch on three pumps if h < 3.5, use 2 pumps of 3.5 < = h < 4.5 and use one pump if h >= 4.5 ? The values 3.5 and 4.5 are absolutely empirical and not optimal.
"Intlinprog" is given the water demands over the time period it optimizes because you use the demands in your constraints. That's why "Intlinprog" can find a much better strategy than the one above.
But usually, the demands are uncertain and not exactly known in advance. That's what the Deep Learning Tool is for. It develops a strategy based on data in the past (learning phase) and uses this strategy to take present decisions (now without knowing what exactly the future will bring). Thus both methods try to optimize the usage of the pumps, but the circumstances under which they optimize, namely exact or uncertain knowledge about the future demands, make the mathematical methods used and the results completely different.
If the future demands are known, "intlinprog" will always give the "best" solution. If the future demands are uncertain, you will have to refer to neural networks, Deep Learning or related methods.
Fathima
Fathima 2023 年 3 月 15 日
@Torsten Thankyou sir . You are truely a good teacher :) ..

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Programming and Mixed-Integer Linear Programming についてさらに検索

Translated by