model 'es_day1_3'
uses "mmxprs"
!Declarations of which variables, data arrays
!index sets and constants are present in
!our model
declarations
!Constants
!Index sets
STOFFE = 1..9
MAC = {"A","B","C","D","E"}
!Data arrays
ORE: array(MAC,STOFFE) of real
DISP: array(MAC) of real
PROF: array(STOFFE) of real
!Decision variables
unita: array(STOFFE) of mpvar
end-declarations
!Data initialization
ORE := [15.8 ,0 ,17.6 ,18.9 ,0 ,0 ,15.6 ,0 ,0,
0 ,20.2 ,0 ,0 ,21.6 ,21.6 ,0 ,17.9 ,17.9,
0.30 ,0.30 ,0.36 ,0.36 ,0.36 ,0.45 ,0.31 ,0.31 ,0.34,
0 ,0 ,820 ,830 ,830 ,950 ,705 ,705 ,725,
550 ,550 ,0 ,0 ,0 ,0 ,0 ,0 ,0]
DISP := [2900,900,120,125000,20000]
PROF:=[101,98,60,68,1,81,55,52,58]
!Objective function
Profitto := sum(i in STOFFE) unita(i)*PROF(i)
!Constraints
forall (j in MAC)
sum(i in STOFFE) unita(i)*ORE(j,i) <= DISP(j)
unita(7)+unita(8)+unita(9)<=70
unita(7)+unita(8)+unita(9)>=15
unita(4)+unita(5)+unita(6)>=7
!Decision variable type
!Solver call
maximize(Profitto)
!Output representation
writeln("Profitto totale: ",getobjval)
writeln("Unita' di stoffe prodotte:")
forall (i in STOFFE) do
writeln(i,": ",getsol(unita(i)))
end-do
end-model