8 5 3 8
3
8 8
5 3
(x, y, z) x 8
y 5 z 3 (8, 0, 0)
(4, 4, 0)
(8, 5, 3)
216
(x, y, z) 0 x 8 0 y 5 0 z 3 9 · 6 · 4 = 216
x + y + z = 8
x = 0 x = 8 y = 0 y = 5 z = 0 z = 3
16
{(0, 5, 3), (1, 4, 3), (1, 5, 2), (2, 3, 3), (2, 5, 1), (3, 2, 3), (3, 5, 0), (4, 1, 3),
(4, 4, 0), (5, 0, 3), (5, 3, 0), (6, 0, 2), (6, 2, 0), (7, 0, 1), (7, 1, 0), (8, 0, 0)}
(4, 4, 0) (8, 0, 0)
(8, 0, 0)
(4, 4, 0)
(0,5,3)
(1,4,3)
(1,5,2)
(2,3,3)
(2,5,1)
(3,2,3)
(3,5,0)
(4,1,3)(4,4,0)
(5,0,3)
(5,3,0)
(6,0,2)
(6,2,0)
(7,0,1)
(7,1,0)
(8,0,0)
3
EnumerateStates S
i
e
i,j
i j k k%N +1 (k +1)%N +1
i j k%N + 1
(k + 1)%N + 1 k x
k,i
= x
k,j
(k + 1)%N + 1 j x
(k+1)%N +1,j
= C
(k+1)%N +1]
k%N + 1 j x
k%N +1,j
= 0
e{i,j}:=...
Graph.SPath
model jug ;
set k ;
i,j ;
e{i,j} ;
p{i,j} ;
parameter N ;
T ;
C{k} ;
x{k,i} ;
string S{i} ;
InitState ;
GoalState ;
;EnumerateStates;
S{i}:='('&x[1,i]&','&x[2,i]&','&x[3,i]&')';
e{i,j}:= or{k} (
x[k,i]=x[k,j] and (x[k%N+1,j]=C[k%N+1] or x[(k+1)%N+1,j]=0) or
x[k,i]=x[k,j] and (x[k%N+1,j]=0 or x[(k+1)%N+1,j]=C[(k+1)%N+1]));
parameter s:=argmax{i} (S=InitState) ;
t:=argmax{i} (S=GoalState) ;
if Graph.SPath(e,p,s,t)>=99999999 then Write('No path exists\n'); end
;
DrawJug(8,0,0, 0,0);
DrawJug(4,4,0, 25,0);
Draw.Arrow(16,4,23,4,-2,0,3);
Draw.Text('Abstraction',15,-3.5,16,0,3,1.3);
parameter SPdraw{i}:=[16,7,6,13,12,3,2,9]; n;
parameter SPdraw1{i}:=[16,9];
{i|SPdraw1} (n:=n+1, Draw.Ellipse(S[SPdraw1],if(n>4,(n-4)
*
10-5,n
*
25-17),if(n>4,-10,-6),3,1,1,0));
Draw.Arrow(16,-6,23,-6,-2,0,3);
model data;
T:=8;
InitState:='(8,0,0)';
GoalState:='(4,4,0)';
N:=3;
k:=1..N;
C{k}:=[8,5,3];
end;
model EnumerateStates;
{a in 0..C[1],b in 0..C[2], c in 0..C[3]}
if(a+b+c=T and (a=0 or a=C[1] or b=0 or b=C[2] or c=0 or c=C[3]),
(Addm(i,#i+1), x[1,#i]:=a,x[2,#i]:=b,x[3,#i]:=c)
);
end
model DrawGraph;
parameter
PI:=3.14159;
xa{i}:=15
*
Sin(PI/#i+2
*
PI
*
(i-1)/#i);
ya{i}:=15
*
Cos(PI/#i+2
*
PI
*
(i-1)/#i);
Draw.Scale(15,15);
Draw.DefFont('Verdana',10);
{e[i,j]} Draw.Arrow(xa[i],ya[i],xa[j],ya[j],2);
{i}Draw.Ellipse(S,xa,ya,2,1,1,0);
end
model DrawJug(integer a;b;c; x;y);
Draw.Scale(10,-15);
Draw.DefFont('Verdana',12);
model oneJug(integer h;a; x;y);
Draw.Ellipse(x+2,y,2,.5,if(a>0,5,1),0);
Draw.Rect(x,y,4,1,1,1);
if a>0 then
Draw.Rect(x,y,4,y+a,5,5);
Draw.Ellipse(x+2,a,2,.5,5,1);
end;
Draw.Ellipse(x+2,h,2,.5,1,0));
Draw.Line(x,h,x,0);
Draw.Line(x+4,h,x+4,0);
Draw.Text(h&'L',x+1.5,-1.3);
Draw.Text(a&'L',x+1.5,1);
end;
oneJug(8,a,x,y);
oneJug(5,b,x+5,y);
oneJug(3,c,x+10,y);
end
end
T:=9; InitState:='(8,1,0)'; GoalState:='(2,5,2)';
T:=10; InitState:='(10,0,0)'; GoalState:='(3,4,3)';
C{k}:=[10 5 3];
T:=12; InitState:='(10,2,0)'; GoalState:='(5,6,1)';
C{k}:=[12 6 3];
https://matmod.ch/lpl/doc/manual.pdf