**************************************************************************** * * Mining example illustrating two different formulations. * * Gams model written by Anders Forsgren, November 16 2001. * **************************************************************************** sets i level / i1*i3 / j blocknumber / j1*j4 /; table value(i,j) values of the blocks j1 j2 j3 j4 i1 -1 -2 -3 -7 i2 0 1 2 i3 6 4 ; variables totvalue total value x(i,j) decision variable for the blocks; binary variable x; equations obj objective function cons1left(i,j) first constraint for model 1 cons1right(i,j) second constraint for model 1 cons2(i,j) constraint for model 2; obj .. totvalue =e= sum((i,j),value(i,j)*x(i,j)); cons1left(i,j)$(ord(i) gt 1 and ord(i)+ord(j) le 5) .. x(i,j) =l= x(i-1,j); cons1right(i,j)$(ord(i) gt 1 and ord(i)+ord(j) le 5) .. x(i,j) =l= x(i-1,j+1); cons2(i,j)$(ord(i) gt 1 and ord(i)+ord(j) le 5) .. 2*x(i,j) =l= x(i-1,j) + x(i-1,j+1); parameter report(i,j,*); * Create models model ip1 / obj, cons1left, cons1right /; model ip2 / obj, cons2 /; * Solve the models solve ip1 using mip maximizing totvalue; report(i,j,'ip1') = x.l(i,j); solve ip2 using mip maximizing totvalue; report(i,j,'ip2') = x.l(i,j); * Solve the LP-relaxations of the models solve ip1 using rmip maximizing totvalue; report(i,j,'rip1') = x.l(i,j); solve ip2 using rmip maximizing totvalue; report(i,j,'rip2') = x.l(i,j); * Display the results display report;