Mathematical Modeling with LPL : Explain and run a Model
Problem Statement
Modeling Description
||
Back to MatMod
model Puzzle7 "The 7-Digits Puzzle"; set i,j := ['A','B','C','D','E','F','G']; alldiff variable x{i} [1..7]; variable z; constraint L1: x['A'] + x['D'] + x['G'] = z; L2: x['A'] + x['C'] + x['F'] = z; L3: x['B'] + x['E'] + x['G'] = z; L4: x['B'] + x['D'] + x['F'] = z; L5: x['C'] + x['D'] + x['E'] = z; solve; Write('%s , z=%d\n',{i} Format('%s=%d ', i, x), z)); --draw the solution parameter X{i}:=[10 50 10 30 50 10 50]; Y{i}:=[10 10 50 50 50 90 90]; set li{i,j}:=[('A','F') ('A','G') ('B','F') ('B','G') ('C','E')]; Draw.Scale(10,5); Draw.DefFont('Verdana',20,0,2); {li[i,j]} Draw.Line(X[i],Y[i],X[j],Y[j]); {i} Draw.Circle(i&'='&x,X,Y,3,1,0); --{i} Draw.Circle(i&'',X,Y,3,1,0); end
Problem Statement
Modeling Description
Back to model
The solution is as follows:
The LOG-File output of LPL is as follows: