fn create_variable_bound(
        &mut self,
        constraint: usize,
        activity_direction: BoundDirection,
    ) -> Change {
        // We should be exactly one variable bound away from being able to compute an activity
        // bound, otherwise, a different rule should be applied.
        debug_assert_eq!(
            match activity_direction {
                BoundDirection::Lower => self.counters.activity[constraint].0,
                BoundDirection::Upper => self.counters.activity[constraint].1,
            },
            1,
        );

        let right_hand_side = match self.can_variable_rule_be_applied(constraint, activity_direction) {
            None => return Change::None,
            Some(value) => value,
        };

        // Compute the activity bound and notice to which variable it can be applied (because it
        // is the only one that doesn't have the relevant bound yet).
        let total_activity = self.counters.iter_active_row(constraint)
            .filter_map(|(variable, coefficient)| {
                let bound_direction = activity_direction * NonZeroSign::from(coefficient);
                self.updates.variable_bound(variable, bound_direction).map(|bound| coefficient * bound)
            })
            .sum::<OF>();
        let (target_column, target_coefficient) = self.counters.iter_active_row(constraint)
            .find(|&(variable, coefficient)| {
                let bound_direction = activity_direction * NonZeroSign::from(coefficient);
                self.updates.variable_bound(variable, bound_direction).is_none()
            }).unwrap();

        // Compute the variable bound and apply the change.
        let value = (right_hand_side - total_activity) / target_coefficient;
        let bound_direction = !activity_direction * NonZeroSign::from(target_coefficient);
        match self.updates.update_activity_variable_bound(target_column, bound_direction, value) {
            BoundChange::None => Change::None,
            BoundChange::NewBound => {
                self.after_bound_change(target_column, bound_direction, None);
                Change::Meaningful
            },
            BoundChange::BoundShift(shift) => {
                self.after_bound_change(target_column, bound_direction, Some(shift));
                Change::NotMeaningful
            },
        }
    }
/// Apply domain propagation through activation bounds for a constraint where all but one of the
/// relevant variable bounds are known.
///
/// # Arguments
///
/// * `constraint`: Index of the constraint under consideration.
/// * `direction`: Whether the activity lower- or upperbound should be used.
Apply domain propagation through activation bounds for a constraint where all but one of the
relevant variable bounds are known.
Apply domain propagation through activation bounds for a constraint where all but one of the relevant variable bounds are known .
fn create_variable_bound(
        &mut self,
        constraint: usize,
        activity_direction: BoundDirection,
    ) -> Change {
        // We should be exactly one variable bound away from being able to compute an activity
        // bound, otherwise, a different rule should be applied.
        debug_assert_eq!(
            match activity_direction {
                BoundDirection::Lower => self.counters.activity[constraint].0,
                BoundDirection::Upper => self.counters.activity[constraint].1,
            },
            1,
        );
        let right_hand_side = match self.can_variable_rule_be_applied(constraint, activity_direction) {
            None => return Change::None,
            Some(value) => value,
        };
        // Compute the activity bound and notice to which variable it can be applied (because it
        // is the only one that doesn't have the relevant bound yet).
        let total_activity = self.counters.iter_active_row(constraint)
            .filter_map(|(variable, coefficient)| {
                let bound_direction = activity_direction * NonZeroSign::from(coefficient);
                self.updates.variable_bound(variable, bound_direction).map(|bound| coefficient * bound)
            })
            .sum::<OF>();
        let (target_column, target_coefficient) = self.counters.iter_active_row(constraint)
            .find(|&(variable, coefficient)| {
                let bound_direction = activity_direction * NonZeroSign::from(coefficient);
                self.updates.variable_bound(variable, bound_direction).is_none()
            }).unwrap();
        // Compute the variable bound and apply the change.
        let value = (right_hand_side - total_activity) / target_coefficient;
        let bound_direction = !activity_direction * NonZeroSign::from(target_coefficient);
        match self.updates.update_activity_variable_bound(target_column, bound_direction, value) {
            BoundChange::None => Change::None,
            BoundChange::NewBound => {
                self.after_bound_change(target_column, bound_direction, None);
                Change::Meaningful
            },
            BoundChange::BoundShift(shift) => {
                self.after_bound_change(target_column, bound_direction, Some(shift));
                Change::NotMeaningful
            },
        }
    }
fn create_variable_bound ( & mut self , constraint : usize , activity_direction : BoundDirection , ) -> Change { // We should be exactly one variable bound away from being able to compute an activity // bound, otherwise, a different rule should be applied. debug_assert_eq ! ( match activity_direction { BoundDirection Lower self counters activity [ constraint ] 0 BoundDirection Upper self counters activity [ constraint ] 1 } 1 ) ; let right_hand_side = match self . can_variable_rule_be_applied ( constraint , activity_direction ) { None => return Change :: None , Some ( value ) => value , } ; // Compute the activity bound and notice to which variable it can be applied (because it // is the only one that doesn't have the relevant bound yet). let total_activity = self . counters . iter_active_row ( constraint ) . filter_map ( | ( variable , coefficient ) | { let bound_direction = activity_direction * NonZeroSign :: from ( coefficient ) ; self . updates . variable_bound ( variable , bound_direction ) . map ( | bound | coefficient * bound ) } ) . sum :: < OF > ( ) ; let ( target_column , target_coefficient ) = self . counters . iter_active_row ( constraint ) . find ( | & ( variable , coefficient ) | { let bound_direction = activity_direction * NonZeroSign :: from ( coefficient ) ; self . updates . variable_bound ( variable , bound_direction ) . is_none ( ) } ) . unwrap ( ) ; // Compute the variable bound and apply the change. let value = ( right_hand_side - total_activity ) / target_coefficient ; let bound_direction = ! activity_direction * NonZeroSign :: from ( target_coefficient ) ; match self . updates . update_activity_variable_bound ( target_column , bound_direction , value ) { BoundChange :: None => Change :: None , BoundChange :: NewBound => { self . after_bound_change ( target_column , bound_direction , None ) ; Change :: Meaningful } , BoundChange :: BoundShift ( shift ) => { self . after_bound_change ( target_column , bound_direction , Some ( shift ) ) ; Change :: NotMeaningful } , } }
Apply domain propagation through activation bounds for a constraint where all but one of the
relevant variable bounds are known.
Apply domain propagation through activation bounds for a constraint where all but one of the relevant variable bounds are known .
&mut self
constraint
usize
activity_direction
BoundDirection
&mut self
constraint
usize
activity_direction
BoundDirection