fn constraint_update(
        &self,
        constraint: usize,
        bound_value: &OF,
        direction: BoundDirection,
    ) -> Result<Option<ConstraintUpdate<OF>>, LinearProgramType<OF>> {
        use RangedConstraintRelation::{Equal, Range, Less, Greater};

        let rhs = self.updates.b(constraint);
        let constraint_type = self.updates.constraint_type(constraint);

        match (direction, constraint_type, rhs.cmp(bound_value)) {
            // `<a, x> (== =r= <=) b < l`
            (BoundDirection::Lower, Equal | Range(_) | Less, Ordering::Less) |
            // `<a, x> (== =r= >=) b > u`
            (BoundDirection::Upper, Equal | Greater, Ordering::Greater) => {
                Err(LinearProgramType::Infeasible)
            },

            // `l <= <a, x> (== <=) b == l`
            (BoundDirection::Lower, Equal | Less, Ordering::Equal) |
            // `u >= <a, x> (== >=) b = u`
            (BoundDirection::Upper, Equal | Greater, Ordering::Equal) => {
                Ok(Some(ConstraintUpdate::SetVariablesToBound))
            },

            // `<a, x> <= u (= <) b`
            (BoundDirection::Upper, Less, Ordering::Equal | Ordering::Greater) |
            // `<a, x> >= l (= >) b`
            (BoundDirection::Lower, Greater, Ordering::Less | Ordering::Equal) => {
                Ok(Some(ConstraintUpdate::Remove))
            },

            // `b - r <= <a, x> <= b = u`
            (BoundDirection::Upper, Range(range), Ordering::Equal) => {
                Ok(Some(ConstraintUpdate::Replace(InequalityRelation::Greater, -range)))
            },

            (BoundDirection::Lower, Range(range), Ordering::Greater) => {
                let lower_bound = rhs - range;
                Ok(match bound_value.cmp(&lower_bound) {
                    // `l < b - r <= <a, x> <= b`
                    Ordering::Less => None,
                    // `b - r <= l <= <a, x> <= b`
                    Ordering::Equal | Ordering::Greater => {
                        Some(ConstraintUpdate::Replace(InequalityRelation::Less, OF::zero()))
                    },
                })
            },
            (BoundDirection::Upper, Range(range), Ordering::Greater) => {
                let lower_bound = rhs - range;
                match bound_value.cmp(&lower_bound) {
                    Ordering::Less => Err(LinearProgramType::Infeasible),
                    // `u >= <a, x> <= b == u`
                    Ordering::Equal => Ok(Some(ConstraintUpdate::SetVariablesToBound)),
                    // `b - r <= <a, x> <= u < b`
                    Ordering::Greater => {
                        // Keep only lower bound
                        Ok(Some(ConstraintUpdate::Replace(InequalityRelation::Greater, -range)))
                    }
                }
            },

            // `<a, x> (== <= >=) b > l`
            (BoundDirection::Lower, Equal | Less | Greater, Ordering::Greater) |
            // `<a, x> (== =r= <= >=) b < u`
            (BoundDirection::Upper, Equal | Range(_) | Less | Greater, Ordering::Less) => {
                Ok(None)
            },

            // `l <= <a, x> =r= b == l`
            (BoundDirection::Lower, Range(_), Ordering::Equal) => {
                unreachable!("Would require the range to be zero, in which case it should be an \
                              equality bound instead.")
            },
        }
    }
/// Whether a constraint can be removed.
///
/// We start with `<a, x> (== =r= <= >=) b`, `l <= <a, x>` or `<a, x> <= u` and `a (= < >) b`
/// where `a` is one of `l` and `u`. This results in `4x2x3 = 24` combinations, all of which
/// are cases below.
///
/// Note that always `l < u`, because otherwise there there would be fixed variables (and they
/// are presolved in a rule with higher priority). This is not directly relevant though, as we
/// treat only one side at the time.
///
/// # Arguments
///
/// * `constraint`: Index of the constraint under consideration.
/// * `value`: Value of the activity lower- or upperbound.
/// * `direction`: Whether it's the activity lower- or upperbound.
///
/// # Return value
///
/// Whether a change needs to be made, and if so, which one.
///
/// # Errors
///
/// If the constraint can't be satisfied anymore.
Whether a constraint can be removed.

Note that always `l < u`, because otherwise there there would be fixed variables (and they
are presolved in a rule with higher priority). This is not directly relevant though, as we
treat only one side at the time.
Whether a constraint can be removed . Note that always ` l < u ` because otherwise there there would be fixed variables ( and they are presolved in a rule with higher priority ) . This is not directly relevant though as we treat only one side at the time .
fn constraint_update(
        &self,
        constraint: usize,
        bound_value: &OF,
        direction: BoundDirection,
    ) -> Result<Option<ConstraintUpdate<OF>>, LinearProgramType<OF>> {
        use RangedConstraintRelation::{Equal, Range, Less, Greater};
        let rhs = self.updates.b(constraint);
        let constraint_type = self.updates.constraint_type(constraint);
        match (direction, constraint_type, rhs.cmp(bound_value)) {
            // `<a, x> (== =r= <=) b < l`
            (BoundDirection::Lower, Equal | Range(_) | Less, Ordering::Less) |
            // `<a, x> (== =r= >=) b > u`
            (BoundDirection::Upper, Equal | Greater, Ordering::Greater) => {
                Err(LinearProgramType::Infeasible)
            },
            // `l <= <a, x> (== <=) b == l`
            (BoundDirection::Lower, Equal | Less, Ordering::Equal) |
            // `u >= <a, x> (== >=) b = u`
            (BoundDirection::Upper, Equal | Greater, Ordering::Equal) => {
                Ok(Some(ConstraintUpdate::SetVariablesToBound))
            },
            // `<a, x> <= u (= <) b`
            (BoundDirection::Upper, Less, Ordering::Equal | Ordering::Greater) |
            // `<a, x> >= l (= >) b`
            (BoundDirection::Lower, Greater, Ordering::Less | Ordering::Equal) => {
                Ok(Some(ConstraintUpdate::Remove))
            },
            // `b - r <= <a, x> <= b = u`
            (BoundDirection::Upper, Range(range), Ordering::Equal) => {
                Ok(Some(ConstraintUpdate::Replace(InequalityRelation::Greater, -range)))
            },
            (BoundDirection::Lower, Range(range), Ordering::Greater) => {
                let lower_bound = rhs - range;
                Ok(match bound_value.cmp(&lower_bound) {
                    // `l < b - r <= <a, x> <= b`
                    Ordering::Less => None,
                    // `b - r <= l <= <a, x> <= b`
                    Ordering::Equal | Ordering::Greater => {
                        Some(ConstraintUpdate::Replace(InequalityRelation::Less, OF::zero()))
                    },
                })
            },
            (BoundDirection::Upper, Range(range), Ordering::Greater) => {
                let lower_bound = rhs - range;
                match bound_value.cmp(&lower_bound) {
                    Ordering::Less => Err(LinearProgramType::Infeasible),
                    // `u >= <a, x> <= b == u`
                    Ordering::Equal => Ok(Some(ConstraintUpdate::SetVariablesToBound)),
                    // `b - r <= <a, x> <= u < b`
                    Ordering::Greater => {
                        // Keep only lower bound
                        Ok(Some(ConstraintUpdate::Replace(InequalityRelation::Greater, -range)))
                    }
                }
            },
            // `<a, x> (== <= >=) b > l`
            (BoundDirection::Lower, Equal | Less | Greater, Ordering::Greater) |
            // `<a, x> (== =r= <= >=) b < u`
            (BoundDirection::Upper, Equal | Range(_) | Less | Greater, Ordering::Less) => {
                Ok(None)
            },
            // `l <= <a, x> =r= b == l`
            (BoundDirection::Lower, Range(_), Ordering::Equal) => {
                unreachable!("Would require the range to be zero, in which case it should be an \
                              equality bound instead.")
            },
        }
    }
fn constraint_update ( & self , constraint : usize , bound_value : & OF , direction : BoundDirection , ) -> Result < Option < ConstraintUpdate < OF > > , LinearProgramType < OF > > { use RangedConstraintRelation :: { Equal , Range , Less , Greater } ; let rhs = self . updates . b ( constraint ) ; let constraint_type = self . updates . constraint_type ( constraint ) ; match ( direction , constraint_type , rhs . cmp ( bound_value ) ) { // `<a, x> (== =r= <=) b < l` ( BoundDirection :: Lower , Equal | Range ( _ ) | Less , Ordering :: Less ) | // `<a, x> (== =r= >=) b > u` ( BoundDirection :: Upper , Equal | Greater , Ordering :: Greater ) => { Err ( LinearProgramType :: Infeasible ) } , // `l <= <a, x> (== <=) b == l` ( BoundDirection :: Lower , Equal | Less , Ordering :: Equal ) | // `u >= <a, x> (== >=) b = u` ( BoundDirection :: Upper , Equal | Greater , Ordering :: Equal ) => { Ok ( Some ( ConstraintUpdate :: SetVariablesToBound ) ) } , // `<a, x> <= u (= <) b` ( BoundDirection :: Upper , Less , Ordering :: Equal | Ordering :: Greater ) | // `<a, x> >= l (= >) b` ( BoundDirection :: Lower , Greater , Ordering :: Less | Ordering :: Equal ) => { Ok ( Some ( ConstraintUpdate :: Remove ) ) } , // `b - r <= <a, x> <= b = u` ( BoundDirection :: Upper , Range ( range ) , Ordering :: Equal ) => { Ok ( Some ( ConstraintUpdate :: Replace ( InequalityRelation :: Greater , - range ) ) ) } , ( BoundDirection :: Lower , Range ( range ) , Ordering :: Greater ) => { let lower_bound = rhs - range ; Ok ( match bound_value . cmp ( & lower_bound ) { // `l < b - r <= <a, x> <= b` Ordering :: Less => None , // `b - r <= l <= <a, x> <= b` Ordering :: Equal | Ordering :: Greater => { Some ( ConstraintUpdate :: Replace ( InequalityRelation :: Less , OF :: zero ( ) ) ) } , } ) } , ( BoundDirection :: Upper , Range ( range ) , Ordering :: Greater ) => { let lower_bound = rhs - range ; match bound_value . cmp ( & lower_bound ) { Ordering :: Less => Err ( LinearProgramType :: Infeasible ) , // `u >= <a, x> <= b == u` Ordering :: Equal => Ok ( Some ( ConstraintUpdate :: SetVariablesToBound ) ) , // `b - r <= <a, x> <= u < b` Ordering :: Greater => { // Keep only lower bound Ok ( Some ( ConstraintUpdate :: Replace ( InequalityRelation :: Greater , - range ) ) ) } } } , // `<a, x> (== <= >=) b > l` ( BoundDirection :: Lower , Equal | Less | Greater , Ordering :: Greater ) | // `<a, x> (== =r= <= >=) b < u` ( BoundDirection :: Upper , Equal | Range ( _ ) | Less | Greater , Ordering :: Less ) => { Ok ( None ) } , // `l <= <a, x> =r= b == l` ( BoundDirection :: Lower , Range ( _ ) , Ordering :: Equal ) => { unreachable ! ( " \
 " ) } , } }
Whether a constraint can be removed.
Whether a constraint can be removed .
&self
constraint
usize
bound_value
&OF
direction
BoundDirection
&self
constraint
usize
bound_value
&OF
direction
BoundDirection
return value
Whether a change needs to be made, and if so, which one.
Whether a change needs to be made and if so which one .
errors
If the constraint can't be satisfied anymore.
If the constraint can ' t be satisfied anymore .