a set with changing upper bound

Problems with modeling
Post Reply
farnazbs
User
User
Posts: 1
Joined: 7 years ago

a set with changing upper bound

Post by farnazbs »

Hi,

I am working on cutting stock problem and trying to model it is GAMS. In my formulation I have three main sets, i,j and k.
i=1,...,10;
j=1,...,10;
and k= 1,...,N(i);
It means my set k in going to have different upper bounds for each i in the problem. I do not know how to model it in GAMS. Hope you can help me. Thanks in Advance.

Code: Select all

Set
i  raw types   /1*10/
j  final types  /1*10/
k  k th raw type  ;

Parameter

q   number of raw types /10/
p  number of final types /10/
W(i) width of raw type i
 /1  78
  2  65
  3  55
  4  47
  5  35
  6  30
  7  30
  8  27
  9  25
  10 24 /
d(j)  demand of final type j
 /1  40
  2  40
  3  29
  4  27
  5  34
  6  20
  7  24
  8  42
  9  46
  10 33 /
s(j) width of final type j
 /1  17
  2  17
  3  16
  4  16
  5  13
  6  6
  7  5
  8  4
  9  2
  10 2 /
N(i) number of type i
 /1  9
  2  7
  3  13
  4  7
  5  14
  6  10
  7  13
  8  13
  9  6
  10 14 /  ;

positive Variable x(k,i,j) number of finals of length sj cut from the kth raw of type i
                  y(k,i) a binary varable- 1 if kth raw of type i is being used or not;
free variable     z1   objective variable for minimizing raw usage
                  z2   objective variable for minimizing total waste ;

Equation obj1
         obj2
         equ1(j) demand
         equ2(k,i) width ;

obj1..z1=e=sum(i,sum(k,y(k,i)));
obj2..z2=e=sum((i,k),W(i)*y(k,i))-sum((i,k,j),x(k,i,j)*s(j));
equ1(j)..sum((i,k),x(k,i,j))=e=d(j);
equ2(k,i).. sum(j,x(k,i,j)*s(j))=l=W(i)*y(k,i);

model cuttingstock1 /obj1,equ1,equ2/;
model cuttingstock2 /obj2,equ1,equ2/;

solve cuttingstock1 using LP minimizing z1;

solve cuttingstock2 using LP minimizing z2;
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: a set with changing upper bound

Post by bussieck »

You do this typically with a two dimensional map ik(i,k). You need to know the larges N(i) at compile time (just make it large but not too large):

set k / k1*k1000 /;
set ik(i,k) map;

After read N(i) you calculate ik:

ik(i,k) = ord(k)<=N(i);

Now in your equation logic you use, e.g. "obj1..z1=e=sum(i,sum(ik(i,k),y(k,i)));"

-Michael
Suresh Jakhar
User
User
Posts: 5
Joined: 7 years ago

Re: a set with changing upper bound

Post by Suresh Jakhar »

My query is regarding an extension of this post. three summation operators i,j,k are sequential as in Sigma_i[Sigma_j{Sigma_k (expression)}].
i and j are sets with elements say /1*4/ each. k is supposed to be /0*(i-j)/ for every value of i and j. For instance, if i=3, j=2 then k is /0*1/ and when i =4, j=2 then k is /0*2/. That is, k changes depending upon the value of i and j in the nested summated expression. I have tried using dynamic sets, ord(), mapping sets kmap(i,j,k) but i am unable to capture this particular feature of upper bound of k changing with i and j.Please help.
P.S what is suggested as a solution in this problem is ingenious when dependence is one one set. In my case dependence is on two sets, namely i and j.
Post Reply