Mathematical Modeling with LPL : Explain and run a Model
Problem Statement
Modeling Description
||
Back to MatMod
model einstein "Einstein's Puzzle"; set a := [Norwegian, Dane, Briton, Swede, German]; b := [yellow blue red green white]; c := [cat bird dog horse fish]; d := [coffee tea milk juice water]; e := [Dunhill Marlboro 'Pall-Mall' Bluemaster Prince]; alldiff variable A{a} [1..5]; B{b} [1..5]; C{c} [1..5]; D{d} [1..5]; E{e} [1..5]; constraint R1: A[3]=B[3]; -- or: A['Briton'] = B['red']; R2: A[4]=C[3]; R3: A[2]=D[2]; R4: B[4]+1=B[5]; R5: B[4]=D[1]; R6: E[3]=C[2]; R7: D[3]=3; R8: B[1]=E[1]; R9: A[1]=1; R10: E[2]=C[1]+1 or E[2]=C[1]-1; R11: C[4]=E[1]+1 or C[4]=E[1]-1; R12: E[4]=D[4]; R13: B[2]=2; -- A[1]=B[2]+1 or A[1]=B[2]-1; R14: A[5]=E[5]; R15: E[2]=D[5]+1 or E[2]=D[5]-1; solve; Write{a|A[a]=C[5]}('The %s owns the fish\n', a); end
Problem Statement
Modeling Description
Back to model
The solution is as follows:
The LOG-File output of LPL is as follows: