model ModelName uses "mmxprs"; !gain access to the Xpress-Optimizer solver declarations anni = 1..4 zone = 1..3 A: array(zone,anni) of integer !disponibilitą d: array(anni) of integer !domanda x: array(zone,anni) of mpvar! quantitą raccolta per bosco e per anno y: array(anni) of mpvar !quantitą raccolta per anno z: array(anni) of mpvar !quantitą in eccesso end-declarations writeln("Begin running model") A::[10,12,7,16, 4,2,10,9, 6,8,11,5] d::[16,23,26,25] forall(j in anni) do y(j) = sum(i in zone) x(i,j) y(j) + if(j>1,sum(k in 2..j) (y(k-1) - d(k-1)),0) >= d(j) end-do forall(i in zone, j in anni) do x(i,j) <= if(j=1,A(i,j),A(i,j)+A(i,j-1)-x(i,j-1)) end-do forall(j in anni) do z(j) >= y(j) - d(j) z(j) >= -(y(j) - d(j)) end-do mincost := sum(j in anni) z(j) minimize(mincost) writeln("End running model") end-model