help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Constraint modelling on a subset


From: Heinrich Schuchardt
Subject: Re: Constraint modelling on a subset
Date: Wed, 24 Mar 2021 00:05:47 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0

On 23.03.21 22:28, Philippe Jugla wrote:
> Hello, 
>
>  
>
> I am rather new to GLPK and I am seeking help regarding the modelling of
> a constraint in a unit commitment problem. 
>
> I hope someone will kindly help me on this one. 
>
>  
>
> I am trying to model a constraint which constrains a sum, but on a
> sequence of subsets of an initial set TIME. 
>
> A bit of context with a simple example below : 
>
>  
>
> *#sets *
>
> set TIME := 1..T; 
>
> set PLANTS :=P1, P2; 
>
> * *
>
> *#parameters *
>
> param T; 
>
> param max_startups_year {PLANTS}; 
>
> param max_startups_week {PLANTS}; 
>
> * *
>
> *#variable *
>
> var startup {p in PLANTS, t in TIME} binary; 
>
> * *
>
> *#constraint 1 *
>
> subject to C1 {p in PLANTS}: 
>
> sum {t in TIME} startup[p,t] <= max_startups_year[p]; 
>
> *_ _*
>
> *Now this is where I am struggling : I would like to constrain sum of
> startup[p,t] with parameter max_startups_week[p] but on subsets of the
> set TIME with step k (let’s say k=5). *
>
> * *
>
> *The following works but obviously is not flexible at all. *
>
> *It gives you the idea of what I would like to do : *
>
>  
>
> sum {t in 0..5} startup[p,t] <= max_startups_week[p]; 
>
> sum {t in 6..10} startup[p,t] <= max_startups_week[p];
>
> … 
>
> Etc… 
>
> … 
>
> sum {t in T-5..T} startup[p,t] <= max_startups_week[p]; 
>
>  
>
>
> I have tried to define another set TIME_2 but it’s not satisfying as it
> is hard-coded as well… 
>
>  
>
> *Set TIME_2 := (0..5 union 6..10.. union /[etc]/ union T-5..T)  *
>
> *subject to C2 {p in PLANTS}: *
>
> *sum {s in TIME_2} startup[p,s] <= max_startups_week[p]; *
>
>  
>
> How would you work this constraint out to be robust and flexible ? At
> the end, the number of steps k should be a parameter. 
>
> To simplify things, let’s say that k divides exactly set TIME. 
>
>  
>
> Thanks very much for your help, 
>
>  
>
> Philippe 
>
>

All you need is an indexed constraint like:

s.t. constraint{w in WEEKS}:
max_startups_week[w] >=
sum{d in DAYS_OF_WEEK} startup[d + days_per_week * w];

Best regards

Heinrich



reply via email to

[Prev in Thread] Current Thread [Next in Thread]