|
A is a knight and a werewolf, and B and C are both knaves and not werewolves.
Xpress-Mosel Model
model 'were4'
! Description : Werewolves IV
! Source : Smullyan, R., (1978), What is the Name of this Book?, Prentice-Hall
! Date written : Xpress-MP 20/12/99, Mosel 19/4/03
! Written by : M J Chlond
uses 'mmxprs'
parameters
person = 3
end-parameters
declarations
x: array(1..person) of mpvar ! x(i) = 1 if person i is a knight, 0 if a knave
y: array(1..person) of mpvar ! y(i) = 1 if person i is a werewolf, 0 otherwise
end-declarations
any:= x(1)
! if statement 1 is true then x(1) = 1, else 0
lca1:= sum(i in 1..person) x(i)+3*x(1) >= 3
lca2:= sum(i in 1..person) x(i)+3*x(1) <= 5
! if statement 2 is true then x(2) = 1, else 0
lcb:= x(3) = x(2)
! only one is a werewolf
pca:= sum(i in 1..person) y(i) = 1
! werewolf is a knight
forall(i in 1..person)
pcb(i):= x(i) >= y(i)
forall(i in 1..person) do
x(i) is_binary
y(i) is_binary
end-do
minimise(any)
! display results
forall(i in 1..person) do
write(getsol(x(i)),' ',getsol(y(i)))
writeln
end-do
end-model
|