Hi this code is working fine and got this answer, the blank one is ZERO
1 2 3 4 5
1.1 1.000
here person number 1 at room number 1 is located for interval 2 that is for time slot 10-12 am while for other time slot it is zero!!
---- 55 VARIABLE x.L 1 if x is asssigned otherwise 0
1 2 3 4 5
1.1 1.000
1.2 1.000 1.000
1.5 1.000 1.000 1.000 1.000 1.000
2.3 1.000 1.000 1.000 1.000
3.4 1.000 1.000 1.000 1.000 1.000
4.2 1.000 1.000 1.000
4.3 1.000
5.1 1.000 1.000 1.000 1.000
On Thu, Jul 11, 2013 at 10:35 AM, ì†¡ì² í˜¸ wrote:
Could you correct the gams code?
$title assigning rooms
$offsymxref
$offsymlist
set
i person /15/
j room /15/
k time slot “ex : 8~10am 10~12 12~14 14~16 16~18” /1*5/
j1(j) union of room1 /1,2/
j2(j) union of room1 /2,3/
j3(j) union of room1 /3,4/
j4(j) union of room1 /3,4,5/
alias(i,ip);
alias(j,jp);
alias(k,kp);
parameter
demand(i) demand for room in a day
/1 3, 2 4, 3 5, 4 2, 5 2/
dist(i) maximum distance to walk
/1 0.5, 2 0.8, 3 1, 4 0.5, 5 0.5/
demand_uni(i) demand for union-room at the same timeslot in a day
/1 1, 2 1, 3 1, 4 1, 5 1/
table
d(i,j)
1 2 3 4 5
1 0.2 0.5 0.6 0.8 0.1
2 1 0.9 0.4 0.6 0.7
3 0.3 0.9 0.4 0.2 0.5
4 0.6 0.5 0.1 0.8 0.9
5 0.2 0.6 0.7 0.9 0.3
variable z minimizing distance;
binary variable x 1 if x is asssigned otherwise 0;
equation
obj objective function(minimizing distance)
no_overlap(i,j,k) not allowed 1 more person in a room
demandfor(i) demand for room in a day
distance(i,j,k) maximum distance to walk
demandfor_uni(i) demand for union-room at the same timeslot in a day
;
obj… z =e= sum(i, sum(j, sum(k, d(i,j)*x(i,j,k))));
no_overlap(i,j,k)… sum(ip, x(ip,j,k)) =e= 1;
demandfor(i)… sum(jp, sum(kp, x(i,jp,kp))) =g= demand(i);
distance(i,j,k)… d(i,j)*x(i,j,k) =l= Dist(i);
demandfor_uni(i)… sum(jp, sum(kp, x(i,jp,kp))) =g= demand_uni(i);
model assign /all/;
solve assign using mip minimizing z;
display x.l, z.l;
option
mip=xa;
Regards,
Owais Nooruddin
+358465700556
–
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.
\