- Timestamp:
- 06/09/08 16:46:15 (4 months ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
examples/searching/salt3.lgt (modified) (6 diffs)
-
RELEASE_NOTES.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/searching/salt3.lgt
r4307 r4308 26 26 27 27 :- object(salt(_Acumulator, _Measure1, _Measure2), 28 instantiates( state_space)).28 instantiates(heuristic_state_space)). 29 29 30 30 :- info([ … … 32 32 author is 'Paula Marisa Sampaio', 33 33 date is 2008/6/9, 34 comment is 'Salt state-space search problem .']).34 comment is 'Salt state-space search problem (updated from the original 1.0 version to support heuristics).']). 35 35 36 36 % each state is represented by a compound term with four arguments: (Acumulator, Measure1, Measure2, Step) … … 44 44 45 45 % emptying a measure into the accumulator 46 next_state((Acc, X, Y, _), (NewAcc, 0, Y, transfer(m1, acc)) ) :-46 next_state((Acc, X, Y, _), (NewAcc, 0, Y, transfer(m1, acc)), 1) :- 47 47 X > 0, 48 48 NewAcc is Acc + X. 49 next_state((Acc, X, Y, _), (NewAcc, X, 0, transfer(m2, acc)) ) :-49 next_state((Acc, X, Y, _), (NewAcc, X, 0, transfer(m2, acc)), 1) :- 50 50 Y > 0, 51 51 NewAcc is Acc + Y. 52 52 53 53 % filling up of one of the measures 54 next_state((Acc, X, Y, Step), (Acc, MaxX, Y, fill(m1)) ) :-54 next_state((Acc, X, Y, Step), (Acc, MaxX, Y, fill(m1)), 1) :- 55 55 parameter(2, MaxX), 56 56 X < MaxX, 57 57 Step \= empty(m1). 58 next_state((Acc, X, Y, Step), (Acc, X, MaxY, fill(m2)) ) :-58 next_state((Acc, X, Y, Step), (Acc, X, MaxY, fill(m2)), 1) :- 59 59 parameter(3, MaxY), 60 60 Y < MaxY, … … 63 63 % either pouring of a measure into the other till it is filled up 64 64 % or all content of a measure into the other one 65 next_state((Acc, X, Y, _), (Acc, W, Z, transfer(m2, m1)) ) :-65 next_state((Acc, X, Y, _), (Acc, W, Z, transfer(m2, m1)), 1) :- 66 66 parameter(2, MaxX), 67 67 Y > 0, … … 74 74 Z = 0 75 75 ). 76 next_state((Acc, X, Y, _), (Acc, W, Z, transfer(m1, m2)) ) :-76 next_state((Acc, X, Y, _), (Acc, W, Z, transfer(m1, m2)), 1) :- 77 77 parameter(3, MaxY), 78 78 X > 0, … … 87 87 88 88 % throwing out the contents of a measure; does not afect the accumulator 89 next_state((Acc, X, Y, Step), (Acc, 0, Y, empty(m1)) ) :-89 next_state((Acc, X, Y, Step), (Acc, 0, Y, empty(m1)), 1) :- 90 90 X > 0, 91 91 Step \= fill(m1). 92 next_state((Acc, X, Y, Step), (Acc, X, 0, empty(m2)) ) :-92 next_state((Acc, X, Y, Step), (Acc, X, 0, empty(m2)), 1) :- 93 93 Y > 0, 94 94 Step \= fill(m2). 95 96 heuristic((Acc, Acc, _, _), 0.1) :- 97 parameter(1, Acc), 98 !. 99 heuristic((Acc, _, Acc, _), 0.1) :- 100 parameter(1, Acc), 101 !. 102 heuristic((Acc, X, Y, _), 0.2) :- 103 parameter(1, Acc), 104 Acc is abs(X - Y), 105 !. 106 heuristic((Acc, X, _, _), 0.3) :- 107 parameter(1, Acc), 108 ( X mod Acc =:= 0 -> 109 Cost is X // Acc 110 ; Acc mod X =:= 0 -> 111 Cost is Acc // X 112 ), 113 !. 114 heuristic((Acc, _, Y, _), 0.3) :- 115 parameter(1, Acc), 116 ( Y mod Acc =:= 0 -> 117 Cost is Y // Acc 118 ; Acc mod Y =:= 0 -> 119 Cost is Acc // Y 120 ), 121 !. 122 heuristic((Acc, X, Y, _), 0.4) :- 123 parameter(1, Acc), 124 Diff is abs(X - Y), 125 ( Diff mod Acc =:= 0 -> 126 Cost is Diff // Acc 127 ; Acc mod Diff =:= 0 -> 128 Cost is Acc // Diff 129 ), 130 !. 131 heuristic((_, _, _, _), 0.5). 95 132 96 133 member_path((Acc, X, Y, _), [(Acc, X, Y, _)| _]) :- -
trunk/RELEASE_NOTES.txt
r4307 r4308 25 25 Corrected two bugs in the implementation of the built-in meta-predicate 26 26 threaded/1 when canceling individual threads. The first bug resulted from 27 out-of-order thread status messages. The second bug result d from a leak27 out-of-order thread status messages. The second bug resulted from a leak 28 28 of thread results between calls to the threaded/1 predicate. 29 29 … … 47 47 checking for cycles to the state space being searched (thus allowing 48 48 state descriptions to carry additional information that should not be 49 taken into account when comparing states). 49 taken into account when comparing states). Updated the "salt" example 50 to support heuristics. 50 51 51 52 Updated the syntax coloring support for the Vim text editor to properly
