@@ -79,9 +79,15 @@ impl<S: SimplificationActions> Constraint<S> for IntDecisionArrayElement {
79
79
}
80
80
81
81
fn simplify ( & mut self , actions : & mut S ) -> Result < SimplificationStatus , ReformulationError > {
82
- // make sure idx is within the range of args
82
+ // Fix the bounds of the index is to the length of the array
83
83
actions. set_int_lower_bound ( self . index , 0 ) ?;
84
84
actions. set_int_upper_bound ( self . index , self . array . len ( ) as IntVal - 1 ) ?;
85
+ // Unify if the index is already fixed
86
+ if let Some ( idx) = actions. get_int_val ( self . index ) {
87
+ actions. unify_int ( self . array [ idx as usize ] , self . result ) ?;
88
+ return Ok ( SimplificationStatus :: Subsumed ) ;
89
+ }
90
+ // Match the bounds of the array elements to the result and vice versa
85
91
let ( min_lb, max_ub) =
86
92
self . array
87
93
. iter ( )
@@ -319,6 +325,18 @@ where
319
325
}
320
326
321
327
impl < S : SimplificationActions > Constraint < S > for IntValArrayElement {
328
+ fn simplify ( & mut self , actions : & mut S ) -> Result < SimplificationStatus , ReformulationError > {
329
+ // Fix the bounds of the index is to the length of the array
330
+ actions. set_int_lower_bound ( self . index , 0 ) ?;
331
+ actions. set_int_upper_bound ( self . index , self . array . len ( ) as IntVal - 1 ) ?;
332
+ // Unify if the index is already fixed
333
+ if let Some ( idx) = actions. get_int_val ( self . index ) {
334
+ actions. set_int_val ( self . result , self . array [ idx as usize ] ) ?;
335
+ return Ok ( SimplificationStatus :: Subsumed ) ;
336
+ }
337
+ Ok ( SimplificationStatus :: Fixpoint )
338
+ }
339
+
322
340
fn to_solver ( & self , slv : & mut dyn ReformulationActions ) -> Result < ( ) , ReformulationError > {
323
341
let index = slv. get_solver_int ( self . index ) ;
324
342
let result = slv. get_solver_int ( self . result ) ;
0 commit comments