필터 지우기
필터 지우기

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개)

Community Treasure Hunt

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

Start Hunting!

Translated by