|
Full 3/4 1/2 1/4 Empty
Son 1 3 1 1 1 3
Son 2 2 2 1 2 2
Son 3 2 1 3 1 2
Son 4 1 3 1 3 1
Son 5 1 2 3 2 1
Xpress-Mosel Model
model 'casks'
! Description : Wine cask puzzle
! Source : M Kraitchik - Mathematical Recreations (p 31)
! Date written : MAGIC 17/11/92, Xpress-MP 5/4/98, Mosel 16/4/03
! Written by : M J Chlond
uses 'mmxprs'
parameters
nephew = 5
casktype = 5
end-parameters
declarations
N = 1..nephew
C = 1.. casktype
howfull: array(C) of real
cdum: array(C) of real
x: array(N,C) of mpvar
dtot: array(N) of mpvar
end-declarations
howfull:= [0,.25,.5,.75,1]
cdum:= [10000,1000,100,10,1]
any:= x(1,1)
forall(i in N)
nocon(i):= sum(j in C) x(i,j) = 9
forall(i in N)
amcon(i):= sum(j in C) howfull(j)*x(i,j) = 4.5
forall(j in C)
nccon(j):= sum(i in N) x(i,j) = 9
forall(i in N)
cdummy(i):= sum(j in C) cdum(j)*x(i,j) = dtot(i)
forall(i in 2..nephew)
order(i):= dtot(i-1) - dtot(i) >= 1
forall(i in N, j in C) do
x(i,j) is_integer
x(i,j) >= 1
end-do
maximise(any)
forall(i in N) do
forall(j in C)
write(getsol(x(i,j)),' ')
writeln
end-do
end-model
|