Mathematical Modeling with LPL : Explain and run a Model
Problem Statement
Modeling Description
||
Back to MatMod
model Solitaire "The Solitaire Board Game"; set i,j := [1..7] "Seven rows and seven columns"; r{i,j}:= 3<=i<=5 or 3<=j<=5 "Grid points that are used in the game"; parameter A{i,j}:= [. . 0 0 0 . . . . 0 1 0 . . 0 0 1 1 1 0 0 0 1 1 1 1 1 0 1 1 1 1 1 1 1 . . 1 1 1 . . . . 1 1 1 . .] "Initial configuration"; Z{i,j}:= [. . 1 0 1 . . . . 0 0 0 . . 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 . . 0 0 0 . . . . 0 0 0 . .] "Goal configuration"; variable x{i,j|r} [-3..3] "Value in each (i,j) point"; constraint H1{i,j|r and r[i,j+1] and r[i,j+2]}: x[i,j]+x[i,j+1] >= x[i,j+2]; H2{i,j|r and r[i,j+1] and r[i,j+2]}: x[i,j+2]+x[i,j+1] >= x[i,j]; V1{i,j|r and r[i,j+1] and r[i+2,j]}: x[i,j]+x[i+1,j] >= x[i+2,j]; V2{i,j|r and r[i+1,j] and r[i+2,j]}: x[i+2,j]+x[i+1,j] >= x[i,j]; maximize obj: sum{i,j} Z*x - sum{i,j} A*x; if obj>0 then Write('The problem is infeasible\n'); else Write('The problem may be possible, but I am not sure\n'); end; end
Problem Statement
Modeling Description
Back to model
The solution is as follows:
The LOG-File output of LPL is as follows: