Topic
1 reply Latest Post - ‏2013-09-09T07:27:56Z by Paul Shaw
Puppy26
Puppy26
1 Post
ACCEPTED ANSWER

Pinned topic constraint for opening/closing of depots

‏2013-09-04T19:19:53Z |

Hi all,

I need some help in developing a constraint for opening and closing of depots.

say for an example, I have operations period of 5 years and 3 depots. I want to develop a constraint in which 2 depots are opened  on all the 5 years and 1 depot should be opened on first 3 years and on the 4th and 5th year, it should be closed. In general, the logic should be once the depot is closed, it should be closed forever. Ideally the result should be

 

Name        Year 1     Year 2       Year 3        Year 4       Year 5
Depot1      Open       Open         Open          Open         Open
Depot 2     Open       Open         Open          Open         Open
Depot 3     Open       Open         Open          Closed       Closed

 

Right now, my constraint looks like this 

forall (d in Depots, y in 1..NbYears-1)
    Depotstaysclosed:
      Open [d][y]<= Open[d] [y+1]; but I'm not getting the desired result with this constraint.

Please advise me how I should modify to get the results as I mentioned. For your reference, I have attached my code.

Many thanks!

Attachments

Updated on 2013-09-04T22:03:24Z at 2013-09-04T22:03:24Z by Puppy26
  • Paul Shaw
    Paul Shaw
    6 Posts
    ACCEPTED ANSWER

    Re: constraint for opening/closing of depots

    ‏2013-09-09T07:27:56Z  in response to Puppy26

    Hello,

    This constraint actually says that if a depot is open in year y, then it will also be open in year y+1, which is not what you want.  You need to write >= instead of <=.  However, when you do this, it means that if a depot is open at all, it will be open in the first year.  I'm not sure that's what you want.  If you want to have the possibility of opening the depot after year 1 but then not allowing it to re-open, you will need a constraint like the one below:

    (Open[d][NbYears] + sum (y in 2..NbYears)
                        ((1 - Open[d][y]) * Open[d][y-1])) <= 1;

    This says that you can have only one occurence of Open->Closed in the sequence, except if the depot is open in the last year, in which case the sequence Open->Closed is disallowed.