fn reorder_constraints_by_type(&mut self) -> (usize, usize, usize, usize) {
        let (mut e_counter, mut r_counter, mut l_counter, mut g_counter) = (0, 0, 0, 0);
        let map = self.constraint_types.iter().map(|constraint_type| {
            match constraint_type {
                RangedConstraintRelation::Equal => { e_counter += 1; e_counter - 1 },
                RangedConstraintRelation::Range(_) => { r_counter += 1; r_counter - 1 }
                RangedConstraintRelation::Less => { l_counter += 1; l_counter - 1 },
                RangedConstraintRelation::Greater => { g_counter += 1; g_counter - 1 },
            }
        }).collect::<Vec<usize>>();

        let old_constraint_types = self.constraint_types.iter()
            .map(From::from)
            .collect::<Vec<RangedConstraintRelationKind>>();
        self.constraint_types.sort_by(|a, b| {
            // Ordering is: ==  <  =r= < <=  <  >=
            // Sorting needs to be stable for the range constraints.
            match a {
                RangedConstraintRelation::Equal => match b {
                    RangedConstraintRelation::Equal => Ordering::Equal,
                    _ => Ordering::Less,
                },
                RangedConstraintRelation::Range(_) => match b {
                    RangedConstraintRelation::Range(_) => Ordering::Equal,
                    RangedConstraintRelation::Equal => Ordering::Greater,
                    _ => Ordering::Less,
                },
                RangedConstraintRelation::Less => match b {
                    RangedConstraintRelation::Less => Ordering::Equal,
                    RangedConstraintRelation::Greater => Ordering::Less,
                    _ => Ordering::Greater,
                },
                RangedConstraintRelation::Greater => match b {
                    RangedConstraintRelation::Greater => Ordering::Equal,
                    _ => Ordering::Greater,
                },
            }
        });

        let get_destination = |source| {
            match old_constraint_types[source] {
                RangedConstraintRelationKind::Equal => map[source],
                RangedConstraintRelationKind::Range => e_counter + map[source],
                RangedConstraintRelationKind::Less => e_counter + r_counter + map[source],
                RangedConstraintRelationKind::Greater => e_counter + r_counter + l_counter + map[source],
            }
        };

        let mut new_b = vec![None; self.b.len()];
        for i in 0..self.b.len() {
            // TODO(ARCHITECTURE): Avoid this mem::replace
            new_b[get_destination(i)] = Some(mem::replace(&mut self.b[i], OF::zero()));
        }
        self.b = DenseVector::new(new_b.into_iter().collect::<Option<Vec<_>>>().unwrap(), self.b.len());

        for column in &mut self.constraints.data {
            for (i, _) in column.iter_mut() {
                *i = get_destination(*i);
            }
            column.sort_unstable_by_key(|&(i, _)| i);
        }

        debug_assert!(is_consistent(&self));

        (e_counter, r_counter, l_counter, g_counter)
    }
/// Split the constraints out per type.
///
/// The constraints in a `GeneralForm` linear program are mixed; the of the constraint is saved
/// in `self.constraint_types`. A standard form linear program has a separate data structure
/// for each constraint type. This to facilitate the easy creation of a `MatrixData` data
/// struct, which "simulates" the presence of slack variables based on those different
/// constraint types.
///
/// The constraints are sorted as:
///
/// 1. Equality,
/// 2. Range,
/// 3. Upper bounded,
/// 4. Lower bounded.
///
/// # Return value
///
/// The number of equality, range, upper and lower bounds.
Split the constraints out per type.
The constraints in a `GeneralForm` linear program are mixed; the of the constraint is saved
in `self.constraint_types`. A standard form linear program has a separate data structure
for each constraint type. This to facilitate the easy creation of a `MatrixData` data
struct, which "simulates" the presence of slack variables based on those different
constraint types.

The constraints are sorted as.

1. Equality,
2. Range,
3. Upper bounded,
4. Lower bounded.
Split the constraints out per type . The constraints in a ` GeneralForm ` linear program are mixed ; the of the constraint is saved in ` self . constraint_types ` . A standard form linear program has a separate data structure for each constraint type . This to facilitate the easy creation of a ` MatrixData ` data struct which " simulates " the presence of slack variables based on those different constraint types . The constraints are sorted as . 1 . Equality 2 . Range 3 . Upper bounded 4 . Lower bounded .
fn reorder_constraints_by_type(&mut self) -> (usize, usize, usize, usize) {
        let (mut e_counter, mut r_counter, mut l_counter, mut g_counter) = (0, 0, 0, 0);
        let map = self.constraint_types.iter().map(|constraint_type| {
            match constraint_type {
                RangedConstraintRelation::Equal => { e_counter += 1; e_counter - 1 },
                RangedConstraintRelation::Range(_) => { r_counter += 1; r_counter - 1 }
                RangedConstraintRelation::Less => { l_counter += 1; l_counter - 1 },
                RangedConstraintRelation::Greater => { g_counter += 1; g_counter - 1 },
            }
        }).collect::<Vec<usize>>();
        let old_constraint_types = self.constraint_types.iter()
            .map(From::from)
            .collect::<Vec<RangedConstraintRelationKind>>();
        self.constraint_types.sort_by(|a, b| {
            // Ordering is: ==  <  =r= < <=  <  >=
            // Sorting needs to be stable for the range constraints.
            match a {
                RangedConstraintRelation::Equal => match b {
                    RangedConstraintRelation::Equal => Ordering::Equal,
                    _ => Ordering::Less,
                },
                RangedConstraintRelation::Range(_) => match b {
                    RangedConstraintRelation::Range(_) => Ordering::Equal,
                    RangedConstraintRelation::Equal => Ordering::Greater,
                    _ => Ordering::Less,
                },
                RangedConstraintRelation::Less => match b {
                    RangedConstraintRelation::Less => Ordering::Equal,
                    RangedConstraintRelation::Greater => Ordering::Less,
                    _ => Ordering::Greater,
                },
                RangedConstraintRelation::Greater => match b {
                    RangedConstraintRelation::Greater => Ordering::Equal,
                    _ => Ordering::Greater,
                },
            }
        });
        let get_destination = |source| {
            match old_constraint_types[source] {
                RangedConstraintRelationKind::Equal => map[source],
                RangedConstraintRelationKind::Range => e_counter + map[source],
                RangedConstraintRelationKind::Less => e_counter + r_counter + map[source],
                RangedConstraintRelationKind::Greater => e_counter + r_counter + l_counter + map[source],
            }
        };
        let mut new_b = vec![None; self.b.len()];
        for i in 0..self.b.len() {
            // TODO(ARCHITECTURE): Avoid this mem::replace
            new_b[get_destination(i)] = Some(mem::replace(&mut self.b[i], OF::zero()));
        }
        self.b = DenseVector::new(new_b.into_iter().collect::<Option<Vec<_>>>().unwrap(), self.b.len());
        for column in &mut self.constraints.data {
            for (i, _) in column.iter_mut() {
                *i = get_destination(*i);
            }
            column.sort_unstable_by_key(|&(i, _)| i);
        }
        debug_assert!(is_consistent(&self));
        (e_counter, r_counter, l_counter, g_counter)
    }
fn reorder_constraints_by_type ( & mut self ) -> ( usize , usize , usize , usize ) { let ( mut e_counter , mut r_counter , mut l_counter , mut g_counter ) = ( 0 , 0 , 0 , 0 ) ; let map = self . constraint_types . iter ( ) . map ( | constraint_type | { match constraint_type { RangedConstraintRelation :: Equal => { e_counter += 1 ; e_counter - 1 } , RangedConstraintRelation :: Range ( _ ) => { r_counter += 1 ; r_counter - 1 } RangedConstraintRelation :: Less => { l_counter += 1 ; l_counter - 1 } , RangedConstraintRelation :: Greater => { g_counter += 1 ; g_counter - 1 } , } } ) . collect :: < Vec < usize > > ( ) ; let old_constraint_types = self . constraint_types . iter ( ) . map ( From :: from ) . collect :: < Vec < RangedConstraintRelationKind > > ( ) ; self . constraint_types . sort_by ( | a , b | { // Ordering is: ==  <  =r= < <=  <  >= // Sorting needs to be stable for the range constraints. match a { RangedConstraintRelation :: Equal => match b { RangedConstraintRelation :: Equal => Ordering :: Equal , _ => Ordering :: Less , } , RangedConstraintRelation :: Range ( _ ) => match b { RangedConstraintRelation :: Range ( _ ) => Ordering :: Equal , RangedConstraintRelation :: Equal => Ordering :: Greater , _ => Ordering :: Less , } , RangedConstraintRelation :: Less => match b { RangedConstraintRelation :: Less => Ordering :: Equal , RangedConstraintRelation :: Greater => Ordering :: Less , _ => Ordering :: Greater , } , RangedConstraintRelation :: Greater => match b { RangedConstraintRelation :: Greater => Ordering :: Equal , _ => Ordering :: Greater , } , } } ) ; let get_destination = | source | { match old_constraint_types [ source ] { RangedConstraintRelationKind :: Equal => map [ source ] , RangedConstraintRelationKind :: Range => e_counter + map [ source ] , RangedConstraintRelationKind :: Less => e_counter + r_counter + map [ source ] , RangedConstraintRelationKind :: Greater => e_counter + r_counter + l_counter + map [ source ] , } } ; let mut new_b = vec ! [ None self b len ( ) ] ; for i in 0 .. self . b . len ( ) { // TODO(ARCHITECTURE): Avoid this mem::replace new_b [ get_destination ( i ) ] = Some ( mem :: replace ( & mut self . b [ i ] , OF :: zero ( ) ) ) ; } self . b = DenseVector :: new ( new_b . into_iter ( ) . collect :: < Option < Vec < _ > > > ( ) . unwrap ( ) , self . b . len ( ) ) ; for column in & mut self . constraints . data { for ( i , _ ) in column . iter_mut ( ) { * i = get_destination ( * i ) ; } column . sort_unstable_by_key ( | & ( i , _ ) | i ) ; } debug_assert ! ( is_consistent ( self ) ) ; ( e_counter , r_counter , l_counter , g_counter ) }
Split the constraints out per type.
Split the constraints out per type .
&mut self
&mut self
return value
The number of equality, range, upper and lower bounds.
The number of equality range upper and lower bounds .