Scheduling problem - cost function
Philippe Jugla <[email protected]> Thu, 1 Apr 2021 15:07:25 +0000
| Newsgroups | gmane.comp.gnu.glpk |
|---|---|
| Message-ID | <PA4PR09MB4781AB3D30B0C704A717F9F0F07B9@PA4PR09MB4781.eurprd09.prod.outlook.com> |
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
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;
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