|
0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 Xpress-Mosel Model
model 'abbott'
! Description : The Abbott's Window
! Source : Dudeney, H.E., (1917), Amusements in Mathematics, Thomas Nelson and Sons.
! Date written : 29/11/99
! Written by : M J Chlond
uses 'mmxprs'
parameters
row = 8
col = 8
end-parameters
declarations
R = 1..row
C = 1..col
x: array(R,C) of mpvar ! x(i,j) = 1 if window {i,j} open, else 0
a: array(R) of mpvar
b: array(C) of mpvar
c: array(1..row-2) of mpvar
d: array(1..col-1) of mpvar
e: array(1..col-1) of mpvar
f: array(1..row-2) of mpvar
end-declarations
open:= sum(i in R,j in C) x(i,j)
forall(i in R)
rcon(i):= sum(j in C) x(i,j) = 2*a(i)
forall(j in C)
ccon(j):= sum(i in R) x(i,j) =2*b(j)
forall(i in 2..row-1)
sum(k in 1..i) x(k,i-k+1) = 2*c(i-1)
forall(j in 1..col-1) do
ddcon(j):= sum(k in j..row) x(k,col-k+j) = 2*d(j)
decon(j):= sum(k in 1..row-j+1) x(k,j+k-1) = 2*e(j)
end-do
forall(i in 2..row-1)
dfcon(i):= sum(k in i..row) x(k,k-i+1) = 2*f(i-1)
ca:= x(1,1) = 1
cb:= x(row,1) = 1
cc:= x(1,col) = 1
cd:= x(row,col) = 1
forall(i in R,j in C)
x(i,j) is_binary
forall(i in R) do
a(i) is_integer
a(i) <= 4
end-do
forall(j in C) do
b(j) is_integer
b(j) <= 4
end-do
forall(i in 1..row-2) do
c(i) is_integer
c(i) <= 4
e(i) is_integer
e(i) <= 4
end-do
forall(j in 1..col-2) do
d(j) is_integer
d(j) <= 4
f(j) is_integer
f(j) <= 4
end-do
maximise(open)
forall(i in R) do
forall(j in C)
write(getsol(x(i,j)),' ')
writeln
end-do
end-model
|