model ModelName uses "mmxprs"; !gain access to the Xpress-Optimizer solver !sample declarations section declarations siti = 1..6 fattorie = 1..7 A: array(siti, fattorie) of integer c: array(siti, fattorie) of real richiesta: array(fattorie) of integer disp: array(siti) of integer cfisso: array(siti) of integer cmedio,cday: array(siti) of real x: array(siti,fattorie) of mpvar y: array(siti) of mpvar ! vinc: array(alcolici) of linctr Objective:linctr end-declarations richiesta::[36,42,34,50,27,30,43] disp::[89,90,110,120,100,120] cfisso::[321420,350640,379860,401775,350640,336030] cmedio::[0.15,0.18,0.20,0.18,0.15,0.17] A::[18, 23, 19, 21, 24, 17, 9, 21, 18, 17, 23, 11, 18, 20, 27, 18, 17, 20, 23, 9, 18, 16, 23, 9, 31, 21, 23, 10, 31, 20, 18, 19, 10, 17, 18, 18, 17, 29, 21, 22, 18, 8] forall(i in siti) cday(i) := cfisso(i)/1461 forall(i in siti, j in fattorie) c(i,j) := 0.06*2*A(i,j) + cmedio(i) forall(i in siti) y(i) is_binary writeln("******* Punto A *******") forall(j in fattorie) sum(i in siti) x(i,j) = richiesta(j) forall(i in siti) sum(j in fattorie) x(i,j) <= disp(i)*y(i) costo := sum(i in siti, j in fattorie) c(i,j)*x(i,j) + sum(i in siti) cday(i)*y(i) minimize(costo) writeln("obj1: ", getobjval) forall(i in siti, j in fattorie) do if getsol(x(i,j)) > 0.1 then writeln("i:",i," j:",j," ",getsol(x(i,j))) end-if end-do forall(i in siti) writeln("i:", i," ",getsol(y(i))) writeln("******* Punto B *******") sum(j in fattorie) x(6,j) >= 90*y(6) minimize(costo) writeln("obj2: ", getobjval) forall(i in siti, j in fattorie) do if getsol(x(i,j)) > 0.1 then writeln("i:",i," j:",j," ",getsol(x(i,j))) end-if end-do forall(i in siti) writeln("i:", i," ",getsol(y(i))) end-model