pub fn into_changes(mut self) -> Changes<OF> {
        // Remove changes from rows and columns that are deleted anyway
        for constraint in &self.constraints_marked_removed {
            self.b.remove(constraint);
            self.constraints.remove(constraint);
        }
        for variable in self.removed_variables.iter().map(|&(j, _)| j) {
            self.bounds.remove(&(variable, BoundDirection::Lower));
            self.bounds.remove(&(variable, BoundDirection::Upper));

            self.activity_bounds.remove(&(variable, BoundDirection::Lower));
            self.activity_bounds.remove(&(variable, BoundDirection::Upper));
        }

        // Keep derived variable bounds only when they help eliminate free variables
        let free_to_be_restricted = self.activity_bounds.iter()
            .map(|(&(variable, _), _)| variable)
            .filter(|&variable| {
                // Was initially free?
                self.general_form.variables[variable].is_free() &&
                    // No new bounds derived?
                    self.bounds.get(&(variable, BoundDirection::Lower)).is_none() &&
                    self.bounds.get(&(variable, BoundDirection::Upper)).is_none()
            })
            .collect::<HashSet<_>>();
        for ((variable, direction), bound_value) in self.activity_bounds {
            if free_to_be_restricted.contains(&variable) {
                self.bounds.insert((variable, direction), bound_value);
            }
        }

        // Remove changes that are not actually changes (might have been changed back and forth)
        let existing_b = &self.general_form.b;
        let b = self.b.into_iter()
            .filter(|&(i, ref new_b)| new_b != &existing_b[i])
            .collect();

        let existing_constraint_types = &self.general_form.constraint_types;
        let constraints = self.constraints.into_iter()
            .filter(|(constraint, constraint_type)| {
                &existing_constraint_types[*constraint] != constraint_type
            })
            .collect();

        self.removed_variables.sort_unstable_by_key(|&(j, _)| j);
        self.constraints_marked_removed.sort_unstable();

        Changes {
            b,
            constraints,
            fixed_cost: self.fixed_cost,
            bounds: self.bounds,
            removed_variables: self.removed_variables,
            constraints_marked_removed: self.constraints_marked_removed,
        }
    }
/// Get all changes that the presolving resulted in.
///
/// This method only exists because this struct also holds a borrow to the original problem,
/// the caller of this method.
///
/// # Return value
///
/// Almost all values of this struct; just not the borrow to the original problem.
Get all changes that the presolving resulted in.
This method only exists because this struct also holds a borrow to the original problem,
the caller of this method.
Get all changes that the presolving resulted in . This method only exists because this struct also holds a borrow to the original problem the caller of this method .
pub fn into_changes(mut self) -> Changes<OF> {
        // Remove changes from rows and columns that are deleted anyway
        for constraint in &self.constraints_marked_removed {
            self.b.remove(constraint);
            self.constraints.remove(constraint);
        }
        for variable in self.removed_variables.iter().map(|&(j, _)| j) {
            self.bounds.remove(&(variable, BoundDirection::Lower));
            self.bounds.remove(&(variable, BoundDirection::Upper));
            self.activity_bounds.remove(&(variable, BoundDirection::Lower));
            self.activity_bounds.remove(&(variable, BoundDirection::Upper));
        }
        // Keep derived variable bounds only when they help eliminate free variables
        let free_to_be_restricted = self.activity_bounds.iter()
            .map(|(&(variable, _), _)| variable)
            .filter(|&variable| {
                // Was initially free?
                self.general_form.variables[variable].is_free() &&
                    // No new bounds derived?
                    self.bounds.get(&(variable, BoundDirection::Lower)).is_none() &&
                    self.bounds.get(&(variable, BoundDirection::Upper)).is_none()
            })
            .collect::<HashSet<_>>();
        for ((variable, direction), bound_value) in self.activity_bounds {
            if free_to_be_restricted.contains(&variable) {
                self.bounds.insert((variable, direction), bound_value);
            }
        }
        // Remove changes that are not actually changes (might have been changed back and forth)
        let existing_b = &self.general_form.b;
        let b = self.b.into_iter()
            .filter(|&(i, ref new_b)| new_b != &existing_b[i])
            .collect();
        let existing_constraint_types = &self.general_form.constraint_types;
        let constraints = self.constraints.into_iter()
            .filter(|(constraint, constraint_type)| {
                &existing_constraint_types[*constraint] != constraint_type
            })
            .collect();
        self.removed_variables.sort_unstable_by_key(|&(j, _)| j);
        self.constraints_marked_removed.sort_unstable();
        Changes {
            b,
            constraints,
            fixed_cost: self.fixed_cost,
            bounds: self.bounds,
            removed_variables: self.removed_variables,
            constraints_marked_removed: self.constraints_marked_removed,
        }
    }
pub fn into_changes ( mut self ) -> Changes < OF > { // Remove changes from rows and columns that are deleted anyway for constraint in & self . constraints_marked_removed { self . b . remove ( constraint ) ; self . constraints . remove ( constraint ) ; } for variable in self . removed_variables . iter ( ) . map ( | & ( j , _ ) | j ) { self . bounds . remove ( & ( variable , BoundDirection :: Lower ) ) ; self . bounds . remove ( & ( variable , BoundDirection :: Upper ) ) ; self . activity_bounds . remove ( & ( variable , BoundDirection :: Lower ) ) ; self . activity_bounds . remove ( & ( variable , BoundDirection :: Upper ) ) ; } // Keep derived variable bounds only when they help eliminate free variables let free_to_be_restricted = self . activity_bounds . iter ( ) . map ( | ( & ( variable , _ ) , _ ) | variable ) . filter ( | & variable | { // Was initially free? self . general_form . variables [ variable ] . is_free ( ) && // No new bounds derived? self . bounds . get ( & ( variable , BoundDirection :: Lower ) ) . is_none ( ) && self . bounds . get ( & ( variable , BoundDirection :: Upper ) ) . is_none ( ) } ) . collect :: < HashSet < _ > > ( ) ; for ( ( variable , direction ) , bound_value ) in self . activity_bounds { if free_to_be_restricted . contains ( & variable ) { self . bounds . insert ( ( variable , direction ) , bound_value ) ; } } // Remove changes that are not actually changes (might have been changed back and forth) let existing_b = & self . general_form . b ; let b = self . b . into_iter ( ) . filter ( | & ( i , ref new_b ) | new_b != & existing_b [ i ] ) . collect ( ) ; let existing_constraint_types = & self . general_form . constraint_types ; let constraints = self . constraints . into_iter ( ) . filter ( | ( constraint , constraint_type ) | { & existing_constraint_types [ * constraint ] != constraint_type } ) . collect ( ) ; self . removed_variables . sort_unstable_by_key ( | & ( j , _ ) | j ) ; self . constraints_marked_removed . sort_unstable ( ) ; Changes { b , constraints , fixed_cost : self . fixed_cost , bounds : self . bounds , removed_variables : self . removed_variables , constraints_marked_removed : self . constraints_marked_removed , } }
Get all changes that the presolving resulted in.
Get all changes that the presolving resulted in .
mut self
mut self
return value
Almost all values of this struct; just not the borrow to the original problem.
Almost all values of this struct ; just not the borrow to the original problem .