model ModelName options noimplicit uses "mmxprs" declarations box = 1..2 !tipi di scatole res = 1..2 !risorse disponibili x: array(box) of mpvar !vettore var. dec. c: array(box) of integer !coeff. f.o. b: array(res) of integer !termini noti A: array(res,box) of integer !matrice dei coeff. tecnologici ! xg, xp : mpvar Objective:linctr end-declarations c::[20, 5] b::[160, 200] A::[2, 3, 3, 1] writeln("Begin running model") forall(i in res) sum(j in box) A(i,j)*x(j) <= b(i) ! 2*xg + 3*xp <= 160 ! 3*xg + xp <= 200 ! Objective := 20*xg + 5*xp Objective := sum(j in box) c(j)*x(j) ! xp is_integer !xg is_integer forall(j in box) x(j) is_integer !setparam("XPRS_VERBOSE",TRUE) writeln("Risultato = ",getobjval) maximize(Objective) writeln("Risultato = ",getobjval) !writeln("xp = ",getsol(x(1))," xg = ", getsol(x(2))) forall(j in box) writeln("x(",j,") = ",getsol(x(j))) writeln("End running model") end-model