Topic
8 replies Latest Post - ‏2013-07-18T15:57:41Z by AlexFleischer
prasenjit mandal
prasenjit mandal
5 Posts
ACCEPTED ANSWER

Pinned topic Constraint labeling in multiple summation

‏2013-07-17T08:48:49Z |

I stuck to model a constraint using OPL.

The constraint is like

sum (t = 1 to t_p) x_(pt)  >= (1 - y_(p,t_p) )* D_p, forall (p in Projects, t_p in deadline_p)

 

where x_(kpt) and y_(p,t_p)  are binary variables and D_p, deadline_p are the parameters.

This is a linking constraint.

I cant model this constraint using OPL.

Could you please help me to model this?

 

 

  • AlexFleischer
    AlexFleischer
    981 Posts
    ACCEPTED ANSWER

    Re: Constraint labeling in multiple summation

    ‏2013-07-17T11:33:10Z  in response to prasenjit mandal

    Hi,

     

    have you tried

     

    forall (p in Projects, t_p in deadline_p) sum (t in  1 .. t_p) x_[pt]  >= (1 - y_[p,t_p] )* D_p ;

    regards

    • prasenjit mandal
      prasenjit mandal
      5 Posts
      ACCEPTED ANSWER

      Re: Constraint labeling in multiple summation

      ‏2013-07-17T18:06:12Z  in response to AlexFleischer

      Yes, i have tried that. But OPL is showing some error, like, "Constraint labeling not supported for dimensions with variable sizeuse named constraints instead". I tried other ways, even every way is showing some errors.

      It's like 

      ****************************************

      code blocks: Sample code in C\C++

      ******************************************

      for (p in Projects)

      {

             for (t_p= dealinep; t_p <T+1; t_p++)  

             {

                      for (t = 1; t< t_p, t++)

                      {

                              sum =sum + xp,t ;

                       }

                       sum >= (1 - yp,t_p)*D(p);

             }

      }

      ***************************************************

      How can I write these constraints in OPL? I searched even OLP documentation, but dint get any clue.

  • AlexFleischer
    AlexFleischer
    981 Posts
    ACCEPTED ANSWER

    Re: Constraint labeling in multiple summation

    ‏2013-07-18T07:35:05Z  in response to prasenjit mandal

    Hi,

     

    "Constraint labeling not supported for dimensions with variable sizeuse named constraints instead"

     

    means you labeled your constraint, ie you wrote something like

     

    forall (p in Projects, t_p in deadline_p) ctName: sum (t in  1 .. t_p) x_[pt]  >= (1 - y_[p,t_p] )* D_p ;

     

    can you try to remove that label ?

    Do not hesitate to attach your model.

    regards

     

     

    Alex Fleischer

    • prasenjit mandal
      prasenjit mandal
      5 Posts
      ACCEPTED ANSWER

      Re: Constraint labeling in multiple summation

      ‏2013-07-18T10:14:56Z  in response to AlexFleischer
      **********************************

      code block used by me

      **********************************

      //Escalation constrints

        forall(p in Projects,t_p in DeadlineProj[p]..NbPeriods)
         constName1:
        sum(k in Resources, t in 1..t_p)
         Assign[k][p][t] >= (1 - Escalation[p][t_p])*Demand[p];

      **********************************

      I had already tried this code, what you have suggested, but it was giving the following error.

      "Constraint labeling not supported for dimensions with variable size, use named constraints instead."

      But, I follow what you have tried to suggest (perhaps) - without <constraint_name>...

      **********************************

      //Escalation constrints

        forall(p in Projects,t_p in DeadlineProj[p]..NbPeriods)
        sum(k in Resources, t in 1..t_p)
          Assign[k][p][t] >= (1 - Escalation[p][t_p])*Demand[p];

      **********************************

      In this case it's running fine.

      *** 

      Also, do you have any idea how to use named constraint!!!! Also i tried to use following block of codes after going through the documentation.

      **********************************

      code block 2

      **********************************

      //declaration

      constraint constName1[Projects][Periods];

      //Escalation constrints

        forall(p in Projects,t_p in DeadlineProj[p]..NbPeriods)
          constName1[p][t_p]:
        sum(k in Resources, t in 1..t_p)
          Assign[k][p][t] >= (1 - Escalation[p][t_p])*Demand[p];

      **********************************

      Is it OK also?

      • prasenjit mandal
        prasenjit mandal
        5 Posts
        ACCEPTED ANSWER

        Re: Constraint labeling in multiple summation

        ‏2013-07-18T10:15:33Z  in response to prasenjit mandal

        Thanks a lot Alex...

        • AlexFleischer
          AlexFleischer
          981 Posts
          ACCEPTED ANSWER

          Re: Constraint labeling in multiple summation

          ‏2013-07-18T13:09:03Z  in response to prasenjit mandal

          Hi,

           

          in the doc you should have a look at

           

          Labels and a variable size indexer

          Constraint labels with a variable size indexer are not allowed. For example, this model generates an error message.

          
          tuple RangeTuple 
          {     int i;     int j;     string k; }; 
          {RangeTuple} RT = {<1, 2, "bla">};  
          minimize 1;  
          subject to {    
           forall(<p1, p2, p3> in RT)         
          forall(i in p1..p2)     
          rangeLabel:    
           1 == 1;
          }
          

          Write the following code instead.

          
          tuple RangeTuple{    int i;    int j;    string k;};
          {RangeTuple} RT = {<1, 2, "bla">};
          {int} s={1,2};
          constraint rangeLabel[RT][s];
          minimize 1;
          subject to{   
           forall(<p1, p2, p3> in RT)     
             forall(i in p1..p2)   
           rangeLabel[<p1, p2, p3>,i]:     
          1 == 1;
          }
          

          regards

           

           

           

          Updated on 2013-07-18T13:10:47Z at 2013-07-18T13:10:47Z by AlexFleischer