@@ -10,11 +10,6 @@ pub(crate) struct DecisionTracker {
10
10
map : DecisionMap ,
11
11
stack : Vec < Decision > ,
12
12
propagate_index : usize ,
13
-
14
- // Fixed assignments are decisions that are true regardless of previous decisions. These
15
- // assignments are not cleared after backtracked.
16
- fixed_assignments : Vec < Decision > ,
17
- fixed_assignment_index : usize ,
18
13
}
19
14
20
15
impl DecisionTracker {
@@ -23,24 +18,13 @@ impl DecisionTracker {
23
18
map : DecisionMap :: new ( ) ,
24
19
stack : Vec :: new ( ) ,
25
20
propagate_index : 0 ,
26
- fixed_assignment_index : 0 ,
27
- fixed_assignments : Vec :: new ( ) ,
28
21
}
29
22
}
30
23
31
24
pub ( crate ) fn clear ( & mut self ) {
32
25
self . map = DecisionMap :: new ( ) ;
33
26
self . stack = Vec :: new ( ) ;
34
27
self . propagate_index = 0 ;
35
-
36
- // The fixed assignment decisions are kept but the propagation index is. This assures that
37
- // during the next propagation all fixed assignment decisions are repropagated.
38
- self . fixed_assignment_index = 0 ;
39
-
40
- // Re-apply all the fixed decisions
41
- for decision in self . fixed_assignments . iter ( ) {
42
- self . map . set ( decision. solvable_id , decision. value , 1 ) ;
43
- }
44
28
}
45
29
46
30
pub ( crate ) fn is_empty ( & self ) -> bool {
@@ -56,10 +40,7 @@ impl DecisionTracker {
56
40
}
57
41
58
42
pub ( crate ) fn stack ( & self ) -> impl Iterator < Item = Decision > + DoubleEndedIterator + ' _ {
59
- self . fixed_assignments
60
- . iter ( )
61
- . copied ( )
62
- . chain ( self . stack . iter ( ) . copied ( ) )
43
+ self . stack . iter ( ) . copied ( )
63
44
}
64
45
65
46
pub ( crate ) fn level ( & self , solvable_id : SolvableId ) -> u32 {
@@ -92,26 +73,6 @@ impl DecisionTracker {
92
73
}
93
74
}
94
75
95
- /// Attempts to add a fixed assignment decision. A fixed assignment is different from a regular
96
- /// decision in that its value is persistent and cannot be reverted by backtracking. This is
97
- /// useful for assertion clauses.
98
- ///
99
- /// Returns true if the solvable was undecided, false if it was already decided to the same
100
- /// value.
101
- ///
102
- /// Returns an error if the solvable was decided to a different value (which means there is a conflict)
103
- pub ( crate ) fn try_add_fixed_assignment ( & mut self , decision : Decision ) -> Result < bool , ( ) > {
104
- match self . map . value ( decision. solvable_id ) {
105
- None => {
106
- self . map . set ( decision. solvable_id , decision. value , 1 ) ;
107
- self . fixed_assignments . push ( decision) ;
108
- Ok ( true )
109
- }
110
- Some ( value) if value == decision. value => Ok ( false ) ,
111
- _ => Err ( ( ) ) ,
112
- }
113
- }
114
-
115
76
pub ( crate ) fn undo_until ( & mut self , level : u32 ) {
116
77
while let Some ( decision) = self . stack . last ( ) {
117
78
if self . level ( decision. solvable_id ) <= level {
@@ -136,14 +97,8 @@ impl DecisionTracker {
136
97
///
137
98
/// Side-effect: the decision will be marked as propagated
138
99
pub ( crate ) fn next_unpropagated ( & mut self ) -> Option < Decision > {
139
- if self . fixed_assignment_index < self . fixed_assignments . len ( ) {
140
- let & decision = & self . fixed_assignments [ self . fixed_assignment_index ] ;
141
- self . fixed_assignment_index += 1 ;
142
- Some ( decision)
143
- } else {
144
- let & decision = self . stack [ self . propagate_index ..] . iter ( ) . next ( ) ?;
145
- self . propagate_index += 1 ;
146
- Some ( decision)
147
- }
100
+ let & decision = self . stack [ self . propagate_index ..] . iter ( ) . next ( ) ?;
101
+ self . propagate_index += 1 ;
102
+ Some ( decision)
148
103
}
149
104
}
0 commit comments