How can round up a variable ???

Problems with modeling
Post Reply
i201824
User
User
Posts: 4
Joined: 3 years ago

How can round up a variable ???

Post by i201824 »

Hello everybody, I encountered a problem in my model below. I try to define N(k) as a positive and integer variable but in gams, I can define a variable as one type. How can I define it both positive and integer variable and how can I round up i?

sets
i tum noktalar kumesı /0*6/
A1(i) baslangıc noktası /0/
A2(i) atık toplama noktaları kumesı /1*5/
A3(i) bosaltma noktaları kumesı /6/
k cop toplama aracları /1/
Alias (i,j,m);

parameter
table Y(i,j) dügümler arası mesaeler

0 1 2 3 4 5 6
0 999 100 140 100 30 110 60
1 100 999 140 100 30 110 60
2 140 150 999 120 40 100 120
3 100 150 90 999 100 40 20
4 30 120 90 80 999 30 50
5 110 40 100 80 60 999 80
6 60 100 40 30 60 20 999 ;

Parameter
p(i) cop mıktarı /
0 0
1 300
2 700
3 600
4 500
5 500
6 0 /;

Parameter
C arac kapasitesi /1500/;

variables z;
binary variables x(i,j,k);
positive variables N(k);
Equations amac, eq1(i), eq2(k),eq6(k), eq9(k), eq12(k,j);

amac..z=e=sum((k,i,j), x(i,j,k)*Y(i,j));
eq1(i)$(A2(i))..sum((j,k), x(i,j,k))=e=1;
eq2(k)..sum(j $ A2(j), x('0',j,k))=e=1;
eq6(k)..sum(j $ A2(j),(p(j)* sum((i)$(ord(i) gt 0),x(i,j,k)))) =l= C*N(k);
eq9(k)..sum(m $ A3(m), x(m,'0',k)) =e= 1 ;
eq12(k,j)..sum(i, x(i,j,k)) =e= sum(i, x(j,i,k));

model Wastecol1/all/;
Solve Wastecol1 using MIP minimizing z;
display z.l, x.l, N.l;
Fred
Posts: 372
Joined: 7 years ago

Re: How can round up a variable ???

Post by Fred »

Hi,

Integer variables are non-negative by default (see documentation). You can also always change variable bounds via variable attributes .lo and .up (see documentation).

Not sure what exactly you want to round. There are functions round, ceil and floor for rounding (see documentation). Be careful using these functions in your model.

I hope this helps!

Fred
Post Reply