model a constraint

Problems with modeling
Post Reply
Gunners
User
User
Posts: 3
Joined: 1 year ago

model a constraint

Post by Gunners » 4 months ago

I would like to go and model this constraint but I don't know how to write it on gams.
the variable considered is a binary variable X (j, d, h) which is equal to one if the machinery j on day d and at hour h is active. I would like to model a constraint that tells me that if X (j, d, h) = 1 this variable is equal to 1 also in the following 5 periods.
i speculated to write it like this but i don't know how to implement it on gams.

summation on t, with t going from h ..... (h + 5-1) of X (j, d, t)>= 5 * X (j, d, h).
the constraint must be written for every d and every h that goes from 1 ... (| h | -5 + 1).

I would like an answer both if this constraint fits my problem and how I can implement these conditions on gams anyway.
thanks in advance for the reply.

abhosekar
Moderator
Moderator
Posts: 120
Joined: 5 months ago

Re: model a constraint

Post by abhosekar » 4 months ago

You want to write a constraint that states x(j, d, h1) is 1 then all x(j, d, h) for h = h1, h1+1,.. , h1+5 are 1. This seems to have a logical flaw since usingthis definition, all x(j, d, h) following h1 will be 1.

In this case, I think it is better to differentiate between the time period in which the machine was assigned, and the time periods in which the machine is active.

Let's say y(j, d, h) is a binary variable that states the period in which machine j is assigned a task. You would want
1. all x(j, d, h) to be 1 for the following 5 periods when y(j, d, h) is 1.
2. A machine can be assigned only once in 5 periods. Which means if y(j, d, h1) is 1, then y(j, d, h) for the following 5 periods is 0.

This can be achieved as follows:
1. x(j, d, h + 1) =g= y(j, d, h);
x(j, d, h + 2) =g= y(j, d, h);
x(j, d, h + 3) =g= y(j, d, h);
x(j, d, h + 4) =g= y(j, d, h);
x(j, d, h + 5) =g= y(j, d, h);
You can use $(ord(h) le card(h) - 5 + 1) when defining equations.

2.y(j, d, h +1) =l= 1 - y(j, d, h)
y(j, d, h +2) =l= 1 - y(j, d, h)
y(j, d, h +3) =l= 1 - y(j, d, h)
y(j, d, h +4) =l= 1 - y(j, d, h)
y(j, d, h +5) =l= 1 - y(j, d, h)
Again you can use dollar control options https://www.gams.com/latest/docs/UG_Dol ... tions.html
You may also want to check if you need h + 5 in both cases. The code is untested and may be syntactically incorrect.

Post Reply