Use nonterminal fd_put//3 in mod from clpz
This commit is contained in:
@@ -4944,16 +4944,16 @@ run_propagator(pmod(X,Y,Z), MState) -->
|
||||
; XMin is XL
|
||||
),
|
||||
{ fd_get(X, XD0, XPs),
|
||||
domain_remove_smaller_than(XD0, XMin, XD2),
|
||||
fd_put(X, XD2, XPs) }
|
||||
domain_remove_smaller_than(XD0, XMin, XD2) },
|
||||
fd_put(X, XD2, XPs)
|
||||
% queue_goal(X #>= XMin)
|
||||
; true
|
||||
),
|
||||
( { fd_get(X, _, _, n(XU), _) } ->
|
||||
XMax is Z + Y * ((XU - Z) div Y),
|
||||
{ fd_get(X, XD1, XPs),
|
||||
domain_remove_greater_than(XD1, XMax, XD3),
|
||||
fd_put(X, XD3, XPs) }
|
||||
domain_remove_greater_than(XD1, XMax, XD3) },
|
||||
fd_put(X, XD3, XPs)
|
||||
% queue_goal(X #=< XMax)
|
||||
; true
|
||||
)
|
||||
@@ -4973,14 +4973,14 @@ run_propagator(pmod(X,Y,Z), MState) -->
|
||||
( Z > 0 ->
|
||||
{ fd_get(Y, YD, YPs),
|
||||
YMin is Z + 1,
|
||||
domain_remove_smaller_than(YD, YMin, YD1),
|
||||
fd_put(Y, YD1, YPs) }
|
||||
domain_remove_smaller_than(YD, YMin, YD1) },
|
||||
fd_put(Y, YD1, YPs)
|
||||
% queue_goal(Y #> Z)
|
||||
; Z < 0 ->
|
||||
{ fd_get(Y, YD, YPs),
|
||||
YMax is Z - 1,
|
||||
domain_remove_greater_than(YD, YMax, YD1),
|
||||
fd_put(Y, YD1, YPs) }
|
||||
domain_remove_greater_than(YD, YMax, YD1) },
|
||||
fd_put(Y, YD1, YPs)
|
||||
% queue_goal(Y #< Z)
|
||||
; true
|
||||
)
|
||||
@@ -4998,8 +4998,8 @@ run_propagator(pmodz(X,Y,Z), MState) -->
|
||||
kill(MState),
|
||||
queue_goal(Z = X)
|
||||
; { fd_get(Z, ZD0, ZPs),
|
||||
domain_remove_greater_than(ZD0, X, ZD2),
|
||||
fd_put(Z, ZD2, ZPs) }
|
||||
domain_remove_greater_than(ZD0, X, ZD2) },
|
||||
fd_put(Z, ZD2, ZPs)
|
||||
% queue_goal(Z #=< X)
|
||||
)
|
||||
; X < 0 ->
|
||||
@@ -5007,8 +5007,8 @@ run_propagator(pmodz(X,Y,Z), MState) -->
|
||||
kill(MState),
|
||||
queue_goal(Z = X)
|
||||
; { fd_get(Z, ZD0, ZPs),
|
||||
domain_remove_smaller_than(ZD0, X, ZD2),
|
||||
fd_put(Z, ZD2, ZPs) }
|
||||
domain_remove_smaller_than(ZD0, X, ZD2) },
|
||||
fd_put(Z, ZD2, ZPs)
|
||||
% queue_goal(Z #>= X)
|
||||
)
|
||||
),
|
||||
@@ -5016,15 +5016,15 @@ run_propagator(pmodz(X,Y,Z), MState) -->
|
||||
ZMax is YU - 1,
|
||||
{ fd_get(Z, ZD1, ZPs),
|
||||
domain_remove_smaller_than(ZD1, 0, ZD3),
|
||||
domain_remove_greater_than(ZD3, ZMax, ZD5),
|
||||
fd_put(Z, ZD5, ZPs) }
|
||||
domain_remove_greater_than(ZD3, ZMax, ZD5) },
|
||||
fd_put(Z, ZD5, ZPs)
|
||||
% queue_goal(Z in 0..ZMax)
|
||||
; { fd_get(Y, _, n(YL), n(YU), _), YU < 0 } ->
|
||||
ZMin is YL + 1,
|
||||
{ fd_get(Z, ZD1, ZPs),
|
||||
domain_remove_greater_than(ZD1, 0, ZD3),
|
||||
domain_remove_smaller_than(ZD3, ZMin, ZD5),
|
||||
fd_put(Z, ZD5, ZPs) }
|
||||
domain_remove_smaller_than(ZD3, ZMin, ZD5) },
|
||||
fd_put(Z, ZD5, ZPs)
|
||||
% queue_goal(Z in ZMin..0)
|
||||
; true
|
||||
)
|
||||
@@ -5038,8 +5038,8 @@ run_propagator(pmodz(X,Y,Z), MState) -->
|
||||
; ZMin is Y + 1,
|
||||
{ fd_get(Z, ZD1, ZPs),
|
||||
domain_remove_greater_than(ZD1, 0, ZD3),
|
||||
domain_remove_smaller_than(ZD3, ZMin, ZD5),
|
||||
fd_put(Z, ZD5, ZPs) }
|
||||
domain_remove_smaller_than(ZD3, ZMin, ZD5) },
|
||||
fd_put(Z, ZD5, ZPs)
|
||||
% queue_goal(Z in ZMin..0)
|
||||
)
|
||||
; Y > 0 ->
|
||||
@@ -5049,8 +5049,8 @@ run_propagator(pmodz(X,Y,Z), MState) -->
|
||||
; ZMax is Y - 1,
|
||||
{ fd_get(Z, ZD1, ZPs),
|
||||
domain_remove_smaller_than(ZD1, 0, ZD3),
|
||||
domain_remove_greater_than(ZD3, ZMax, ZD5),
|
||||
fd_put(Z, ZD5, ZPs) }
|
||||
domain_remove_greater_than(ZD3, ZMax, ZD5) },
|
||||
fd_put(Z, ZD5, ZPs)
|
||||
% queue_goal(Z in 0..ZMax)
|
||||
)
|
||||
)
|
||||
@@ -5064,13 +5064,13 @@ run_propagator(pmodz(X,Y,Z), MState) -->
|
||||
queue_goal(Z = X)
|
||||
; ( { fd_get(X, _, n(XL), n(XU), _), XL >= 0 } ->
|
||||
{ fd_get(Z, ZD0, ZPs),
|
||||
domain_remove_greater_than(ZD0, XU, ZD2),
|
||||
fd_put(Z, ZD2, ZPs) }
|
||||
domain_remove_greater_than(ZD0, XU, ZD2) },
|
||||
fd_put(Z, ZD2, ZPs)
|
||||
% queue_goal(Z #=< XU)
|
||||
; { fd_get(X, _, n(XL), n(XU), _), XU =< 0 } ->
|
||||
{ fd_get(Z, ZD0, ZPs),
|
||||
domain_remove_smaller_than(ZD0, XL, ZD2),
|
||||
fd_put(Z, ZD2, ZPs) }
|
||||
domain_remove_smaller_than(ZD0, XL, ZD2) },
|
||||
fd_put(Z, ZD2, ZPs)
|
||||
% queue_goal(Z #>= XL)
|
||||
; true
|
||||
),
|
||||
@@ -5078,36 +5078,36 @@ run_propagator(pmodz(X,Y,Z), MState) -->
|
||||
ZMax is YU - 1,
|
||||
{ fd_get(Z, ZD1, ZPs),
|
||||
domain_remove_smaller_than(ZD1, 0, ZD3),
|
||||
domain_remove_greater_than(ZD3, ZMax, ZD5),
|
||||
fd_put(Z, ZD5, ZPs) }
|
||||
domain_remove_greater_than(ZD3, ZMax, ZD5) },
|
||||
fd_put(Z, ZD5, ZPs)
|
||||
% queue_goal(Z in 0..ZMax)
|
||||
; { fd_get(Y, _, n(YL), n(YU), _), YU < 0 } ->
|
||||
ZMin is YL + 1,
|
||||
{ fd_get(Z, ZD1, ZPs),
|
||||
domain_remove_greater_than(ZD1, 0, ZD3),
|
||||
domain_remove_smaller_than(ZD3, ZMin, ZD5),
|
||||
fd_put(Z, ZD5, ZPs) }
|
||||
domain_remove_smaller_than(ZD3, ZMin, ZD5) },
|
||||
fd_put(Z, ZD5, ZPs)
|
||||
% queue_goal(Z in ZMin..0)
|
||||
; { fd_get(Y, _, n(YL), n(YU), _) } ->
|
||||
ZMin is YL + 1,
|
||||
ZMax is YU - 1,
|
||||
{ fd_get(Z, ZD1, ZPs),
|
||||
domain_remove_greater_than(ZD1, ZMax, ZD3),
|
||||
domain_remove_smaller_than(ZD3, ZMin, ZD5),
|
||||
fd_put(Z, ZD5, ZPs) }
|
||||
domain_remove_smaller_than(ZD3, ZMin, ZD5) },
|
||||
fd_put(Z, ZD5, ZPs)
|
||||
% queue_goal(Z in ZMin..ZMax)
|
||||
%/* This doesn't work very well.
|
||||
; { fd_get(Y, _, _, n(YU), _), YU > 0 } ->
|
||||
{ fd_get(Z, ZD1, ZPs),
|
||||
ZMax is YU - 1,
|
||||
domain_remove_greater_than(ZD1, ZMax, ZD3),
|
||||
fd_put(Z, ZD3, ZPs) }
|
||||
domain_remove_greater_than(ZD1, ZMax, ZD3) },
|
||||
fd_put(Z, ZD3, ZPs)
|
||||
% queue_goal(Z #< YU)
|
||||
; { fd_get(Y, _, n(YL), _, _), YL < 0 } ->
|
||||
{ fd_get(Z, ZD1, ZPs),
|
||||
ZMin is YL + 1,
|
||||
domain_remove_smaller_than(ZD1, ZMin, ZD3),
|
||||
fd_put(Z, ZD3, ZPs) }
|
||||
domain_remove_smaller_than(ZD1, ZMin, ZD3) },
|
||||
fd_put(Z, ZD3, ZPs)
|
||||
% queue_goal(Z #> YL)
|
||||
% * /
|
||||
; true
|
||||
@@ -5122,26 +5122,26 @@ run_propagator(pmody(X,Y,Z), MState) -->
|
||||
( Z > 0 -> % queue_goal(Y #> Z)
|
||||
{ fd_get(Y, YD, YPs),
|
||||
YMin is Z + 1,
|
||||
domain_remove_smaller_than(YD, YMin, YD1),
|
||||
fd_put(Y, YD1, YPs) }
|
||||
domain_remove_smaller_than(YD, YMin, YD1) },
|
||||
fd_put(Y, YD1, YPs)
|
||||
; Z < 0 -> % queue_goal(Y #< Z)
|
||||
{ fd_get(Y, YD, YPs),
|
||||
YMax is Z - 1,
|
||||
domain_remove_greater_than(YD, YMax, YD1),
|
||||
fd_put(Y, YD1, YPs) }
|
||||
domain_remove_greater_than(YD, YMax, YD1) },
|
||||
fd_put(Y, YD1, YPs)
|
||||
; Z =:= 0 -> kill(MState), queue_goal(X / Y #= _)
|
||||
)
|
||||
; ( { fd_get(Z, _, n(ZL), _, _), ZL > 0 } ->
|
||||
{ fd_get(Y, YD, YPs),
|
||||
YMin is ZL + 1,
|
||||
domain_remove_smaller_than(YD, YMin, YD1),
|
||||
fd_put(Y, YD1, YPs) }
|
||||
domain_remove_smaller_than(YD, YMin, YD1) },
|
||||
fd_put(Y, YD1, YPs)
|
||||
% queue_goal(Y #> ZL)
|
||||
; { fd_get(Z, _, _, n(ZU), _), ZU < 0 } ->
|
||||
{ fd_get(Y, YD, YPs),
|
||||
YMax is ZU - 1,
|
||||
domain_remove_greater_than(YD, YMax, YD1),
|
||||
fd_put(Y, YD1, YPs) }
|
||||
domain_remove_greater_than(YD, YMax, YD1) },
|
||||
fd_put(Y, YD1, YPs)
|
||||
% queue_goal(Y #< ZU)
|
||||
; true
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user