SOS1 variable modelling

Problems with syntax of GAMS
Post Reply
Nikou
User
User
Posts: 33
Joined: 4 years ago

SOS1 variable modelling

Post by Nikou »

I cannot figure out how to correctly define the following SOS1 variable.

SOS1 Variable W(j,m,i) ;

where

Code: Select all

Set j /U1,U2/  ; 
Set i /T1,T2/  ;

Set t  /1*10/ ;
Set m /t * t+p(i,j)-1/ ; 

SOS1 Variable W(i,m,j) ;   
For example,

Code: Select all

If p(i,U1) = 2 and t = 1  the SOS1 set should comprise the variables   W(T1,1,U1), W(T1,2,U1), W(T2,1,U1), W(T2,2,U1)
If p(i,U1) = 2 and t = 2  the SOS1 set should comprise the variables   W(T1,2,U1), W(T1,3,U1), W(T2,2,U1), W(T2,3,U1)    
If p(i,U1) = 2 and t = 3  the SOS1 set should comprise the variables   W(T1,3,U1), W(T1,4,U1), W(T2,3,U1), W(T2,4,U1)    
...


So the problem is how to model the set m.
User avatar
bussieck
Moderator
Moderator
Posts: 1042
Joined: 7 years ago

Re: SOS1 variable modelling

Post by bussieck »

GAMS defines the membership of a variable to a SOS set by the last index in the SOS variable declaration. As a consequence of this you can't have a variable appear in two SOS sets. Your model has this (e.g. W(T2,2,U1) shows up in the first and second SOS set in your example). I have not seen models that need that before, so perhaps you can share more details on where this comes from and what you try to accomplish before I suggest sophisticated ways to get around this GAMS limitation.

-Michael
Nikou
User
User
Posts: 33
Joined: 4 years ago

Re: SOS1 variable modelling

Post by Nikou »

Hello Michael

Thank you very much for your help.

Perhaps it is better to show what I intend to do.

I would like to implmenet the following constraints.

Code: Select all

Constr(j,t)..
   sum(i,sum(m$((ord(m) ge ord(t)) and (ord(m) le (ord(t) + d(i,j) - 1))), W(i,m,j))) =L= C(j)     

Set  j   /U1, U2/ ; 
Set  i   /T1, T2/  ; 
Set  t  /1*10/    ; 

Parameter C(j) 
    / U1 = 10
      U2 = 20
    / ;    

Parameter d(i,j)
       /
       T1.U1 = 4.0
       T1.U2 = 5.0
       T2.U1 = 4.0
       T2.U2 = 5.0
      / ;

All variables contained within one realisation of the constraints (say Constr(U1,5) ) form a SOS1 because only one W(i,m,j) can be > 0.

The question is how to define these sets.
Post Reply