Topic
  • 1 reply
  • Latest Post - ‏2013-09-12T06:17:36Z by AlexFleischer
qtbgo
qtbgo
116 Posts

Pinned topic how to express set with subscript?

‏2013-09-12T05:34:41Z |

Hi, How to express something  like the following in OPL:

forall( i in 1..n)

   sum(j in M[i]) x[j] >=1;

 

Where M[i] is a set dependent on i.

 

Thanks in advance.

 

 

 

 

  • AlexFleischer
    AlexFleischer
    77 Posts
    ACCEPTED ANSWER

    Re: how to express set with subscript?

    ‏2013-09-12T06:17:36Z  

    Hi,

     

    what you wrote is correct and let me give you a full example that works fine:

     

    int n=10;
     {int} M[i in 1..n]={1,i};
     
     
     dvar int x[1..10] in 1..10;
     
     subject to
     {
     forall( i in 1..n)

       sum(j in M[i]) x[j] >=1;
       
     } 

     

    regards

  • AlexFleischer
    AlexFleischer
    77 Posts

    Re: how to express set with subscript?

    ‏2013-09-12T06:17:36Z  

    Hi,

     

    what you wrote is correct and let me give you a full example that works fine:

     

    int n=10;
     {int} M[i in 1..n]={1,i};
     
     
     dvar int x[1..10] in 1..10;
     
     subject to
     {
     forall( i in 1..n)

       sum(j in M[i]) x[j] >=1;
       
     } 

     

    regards