Topic
  • 5 replies
  • Latest Post - ‏2013-09-07T21:18:58Z by PaulRubin
Puppy26
Puppy26
4 Posts

Pinned topic Including Time Period in Optimization Model

‏2013-08-31T10:25:29Z |

Hi all,

I'm a new user of CPLEX and using it for my thesis work. I would like to model a program in the following way. Say for example, I have two warehouses with time period of 5 months. One warehouse will be opened throughout the 5 months and other warehouse will be opened for the first 3 months and will be closed for the rest of the time period. Could some one please help me how I should write the code now. I tried to look in google but I couldn't get any sample model.

Any sample example would be really helpful. 

Many thanks!

 

 

  • PaulRubin
    PaulRubin
    58 Posts

    Re: Including Time Period in Optimization Model

    ‏2013-08-31T20:27:33Z  

    The most straightforward approach is to treat the two warehouses the same way. Somewhere in the constraints of your model you will presumably use parameters (data) representing the capacity of each warehouse in each month. Just set the capacity to zero in months where the warehouse is closed.

    Paul

  • Puppy26
    Puppy26
    4 Posts

    Re: Including Time Period in Optimization Model

    ‏2013-09-01T10:32:32Z  
    • PaulRubin
    • ‏2013-08-31T20:27:33Z

    The most straightforward approach is to treat the two warehouses the same way. Somewhere in the constraints of your model you will presumably use parameters (data) representing the capacity of each warehouse in each month. Just set the capacity to zero in months where the warehouse is closed.

    Paul

    Dear Paul,

    Thanks for your response but the problem is I'm initializing the capacity of the warehouse based on the warehouse name(location) and not based on the month. In this case, I think I need to find some other solution like using If condition to supply for the first 3 months when the warehouse is opened and close the supply for the rest of the period when the warehouse is closed. I hope you understand this problem.

    Can you help in this case please.

    Prabhu

     

  • PaulRubin
    PaulRubin
    58 Posts

    Re: Including Time Period in Optimization Model

    ‏2013-09-01T14:26:19Z  
    • Puppy26
    • ‏2013-09-01T10:32:32Z

    Dear Paul,

    Thanks for your response but the problem is I'm initializing the capacity of the warehouse based on the warehouse name(location) and not based on the month. In this case, I think I need to find some other solution like using If condition to supply for the first 3 months when the warehouse is opened and close the supply for the rest of the period when the warehouse is closed. I hope you understand this problem.

    Can you help in this case please.

    Prabhu

     

    Create a boolean/logical parameter (call it "open") indexed by warehouse name and month. Set it true in months that warehouse is open, false when closed. In the place where you would use the capacity (right hand side of a constraint, typically) say something like "if open(name, month) then capacity(name) else 0". Precise syntax depends on what language you are using, and is best asked on a forum specific to that language.

    Paul

  • Puppy26
    Puppy26
    4 Posts

    Re: Including Time Period in Optimization Model

    ‏2013-09-04T19:12:40Z  
    • PaulRubin
    • ‏2013-09-01T14:26:19Z

    Create a boolean/logical parameter (call it "open") indexed by warehouse name and month. Set it true in months that warehouse is open, false when closed. In the place where you would use the capacity (right hand side of a constraint, typically) say something like "if open(name, month) then capacity(name) else 0". Precise syntax depends on what language you are using, and is best asked on a forum specific to that language.

    Paul

    Paul,

    Thanks for your feedback. I'm bit lost in your concept. I saw some example models in the OPL directory and some forum help, I have developed the model for opening and closing of depots but I still didnt get the answer I was looking for.

    As said earlier, I have operations period of 5 years and 3 depots for an example. 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. 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];

    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:49Z at 2013-09-04T22:03:49Z by Puppy26
  • PaulRubin
    PaulRubin
    58 Posts

    Re: Including Time Period in Optimization Model

    ‏2013-09-07T21:18:58Z  
    • Puppy26
    • ‏2013-09-04T19:12:40Z

    Paul,

    Thanks for your feedback. I'm bit lost in your concept. I saw some example models in the OPL directory and some forum help, I have developed the model for opening and closing of depots but I still didnt get the answer I was looking for.

    As said earlier, I have operations period of 5 years and 3 depots for an example. 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. 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];

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

    Many thanks!

    If the purpose of your "Depotstaysclosed" constraint is to say that once a depot closes it stays closed, and if you expect Open[d][y] to be 1 if depot d is open in year y and 0 if it is closed, then you have written the constraint incorrectly. Try substituting the values from your table into the constraint and you should quickly identify the error.