model ModelName uses "mmxprs"; !gain access to the Xpress-Optimizer solver !optional parameters section setparam("XPRS_VERBOSE",true) !sample declarations section declarations I = 1..15 J = 1..15 L: array(I) of integer W = 26 x: array(I,J) of mpvar y: array(J) of mpvar end-declarations L::[10,22,20,5,8,7,15,11,9,10,7,9,12,5,6] forall(i in I, j in J) x(i,j) is_binary forall(j in J) y(j) is_binary numscaffali := sum(j in J) y(j) forall(i in I) sum(j in J) x(i,j) = 1 forall(j in J) sum(i in I) L(i)*x(i,j) <= W*y(j) minimize(numscaffali) NS := floor(getobjval) writeln(NS) declarations K = 1..NS A: array(I) of integer z: array(I,K) of mpvar h: array(K) of mpvar end-declarations A::[2,10,10,10,8,12,18,9,15,13,8,7,7,10,5] forall(i in I, k in K) z(i,k) is_binary forall(i in I) sum(k in K) z(i,k) = 1 forall(i in I,k in K) h(k) >= A(i)*z(i,k) forall(k in K) sum(i in I) L(i)*z(i,k) <= W altezza:=sum(k in K) h(k) minimize(altezza) forall(k in K) writeln(getsol(h(k))) end-model