[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scheduling problem - cost function
From: |
Heinrich Schuchardt |
Subject: |
Re: Scheduling problem - cost function |
Date: |
Thu, 1 Apr 2021 17:45:39 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 |
On 01.04.21 17:07, Philippe Jugla wrote:
> Hello everyone,
>
>
>
> I have some difficulties to add a cost parameter that depends on 2
> variables to a scheduling model in GLPK.
>
>
>
> The problem is as follows :
>
>
>
> If the unit has started up and been active for less than k hours than
> the cost follows a certain cost function, if it has been more than k
> hours then the cost follows another function.
>
>
>
> I have tried the following example but doesn’t seem to work :
>
>
>
> #set
T has to be defined before defining the set.
>
> set TIME:=0...T
>
>
> #binary variables (already defined and working)
>
> var start_up {TIME} binary;
>
> var unit_on {TIME} binary;
>
>
> #parameters
>
> param T:=10;
>
> param price {TIME};
>
> param k:=2;
>
>
> #this is what I’ve tried :
>
> param cost {t in TIME} :=
>
> if sum { s in TIME : s = t - k and s >= 0 } start_up[s] +
> unit_on[s] < k+1 then 2.5*price[t] + 5 else 3.0*price[t] + 10;
You cannot define a parameter as a function of variables. You will have
to make cost a variable and use a constraint.
In a constraint you cannot use "if then else". But you might use
multiple constraints using the binaries.
Best regards
Heinrich
>
>
>
> The following error is thrown : « operand preceding < has invalid
> type ». I guess it is because of the variables ? I tried to define cost
> as a variable but with no success as well..
>
>
> I am also trying to workaround things by defining another binary
> variable X {TIME} that I would constrain, and then define the cost with
> something like cost[t] = (1-X)*(cost_function_1) + X*cost_function_2 but
> it seems quite complicated for this type of problem.
>
>
> Does anyone know what is the issue ? How could I work things out ?
>
>
> Any help or advice would be greatly appreciated !
>
>
> Best regards
>
>
>
> Philippe
>
>