Mathematical Modeling with LPL : Explain and run a Model
Problem Statement
Modeling Description
||
Back to MatMod
model wolves "Werewolves"; set p := [A B C] "Persons"; binary variable x{p} "The person p is a knight"; y{p} "The person p is a werewolf"; constraint A: xor{p} y "Exactly one is a werewolf"; Asays: x[1] <-> y[1]; Bsays: x[2] <-> y[2]; Csays: x[3] <-> atmost(1){p} x; minimize Cknight: x[3]; Write{p}('%s is a %5s\n', p, if (x,'knight','knave')); Write{p|y}('%s is a werewolf\n', p); end
Problem Statement
Modeling Description
Back to model
The solution is as follows:
The LOG-File output of LPL is as follows: