pub(super) fn new(
        general_form: &'a GeneralForm<OF>,
        counters: &Counters<OF>,
    ) -> Result<Self, LinearProgramType<OF>> {
        let mut fixed_cost = OF::zero();
        let removed_variables = counters.variable.iter().enumerate()
            .filter(|&(_, &count)| count == 0)
            .map(|(j, _)| {
                let variable = &general_form.variables[j];
                // There should be a feasible value, otherwise, reading of the problem should have
                // been ended due to a trivial infeasibility.
                debug_assert!(variable.has_feasible_value());

                let value = if variable.cost.is_zero() {
                    variable.get_feasible_value().unwrap()
                } else {
                    let value = optimize_independent_column(
                        general_form.objective,
                        &variable.cost,
                        (variable.lower_bound.as_ref(), variable.upper_bound.as_ref()),
                    )?;
                    fixed_cost += &variable.cost * &value;
                    value
                };

                Ok((j, RemovedVariable::Solved(value)))
            }).collect::<Result<_, _>>()?;

        let constraints_marked_removed = counters.constraint.iter().enumerate()
            .filter(|&(_, &count)| count == 0)
            .map(|(constraint, _)| {
                let right_hand_side = &general_form.b[constraint];
                let constraint_type = &general_form.constraint_types[constraint];
                if is_empty_constraint_feasible(right_hand_side, constraint_type) {
                    Ok(constraint)
                } else {
                    Err(LinearProgramType::Infeasible)
                }
            })
            .collect::<Result<_, _>>()?;

        Ok(Self {
            b: HashMap::new(),
            constraints: HashMap::new(),
            fixed_cost,
            bounds: HashMap::new(),
            // Variables that don't appear in any constraint are removed right away.
            removed_variables,
            constraints_marked_removed,

            activity_bounds: HashMap::new(),

            general_form,
        })
    }
/// Create a new instance.
///
/// Requires iteration over all counters.
///
/// TODO(OPTIMIZATION): Are these iterations efficiently done after compiler optimizations?
///
/// # Arguments
///
/// * `general_form`: Problem being presolved.
/// * `counters`: Counters initialized on the problem in the other argument.
///
/// # Return value
///
/// A new instance.
Create a new instance.
Requires iteration over all counters.


Create a new instance . Requires iteration over all counters .
pub(super) fn new(
        general_form: &'a GeneralForm<OF>,
        counters: &Counters<OF>,
    ) -> Result<Self, LinearProgramType<OF>> {
        let mut fixed_cost = OF::zero();
        let removed_variables = counters.variable.iter().enumerate()
            .filter(|&(_, &count)| count == 0)
            .map(|(j, _)| {
                let variable = &general_form.variables[j];
                // There should be a feasible value, otherwise, reading of the problem should have
                // been ended due to a trivial infeasibility.
                debug_assert!(variable.has_feasible_value());
                let value = if variable.cost.is_zero() {
                    variable.get_feasible_value().unwrap()
                } else {
                    let value = optimize_independent_column(
                        general_form.objective,
                        &variable.cost,
                        (variable.lower_bound.as_ref(), variable.upper_bound.as_ref()),
                    )?;
                    fixed_cost += &variable.cost * &value;
                    value
                };
                Ok((j, RemovedVariable::Solved(value)))
            }).collect::<Result<_, _>>()?;
        let constraints_marked_removed = counters.constraint.iter().enumerate()
            .filter(|&(_, &count)| count == 0)
            .map(|(constraint, _)| {
                let right_hand_side = &general_form.b[constraint];
                let constraint_type = &general_form.constraint_types[constraint];
                if is_empty_constraint_feasible(right_hand_side, constraint_type) {
                    Ok(constraint)
                } else {
                    Err(LinearProgramType::Infeasible)
                }
            })
            .collect::<Result<_, _>>()?;
        Ok(Self {
            b: HashMap::new(),
            constraints: HashMap::new(),
            fixed_cost,
            bounds: HashMap::new(),
            // Variables that don't appear in any constraint are removed right away.
            removed_variables,
            constraints_marked_removed,
            activity_bounds: HashMap::new(),
            general_form,
        })
    }
pub ( super ) fn new ( general_form : & ' a GeneralForm < OF > , counters : & Counters < OF > , ) -> Result < Self , LinearProgramType < OF > > { let mut fixed_cost = OF :: zero ( ) ; let removed_variables = counters . variable . iter ( ) . enumerate ( ) . filter ( | & ( _ , & count ) | count == 0 ) . map ( | ( j , _ ) | { let variable = & general_form . variables [ j ] ; // There should be a feasible value, otherwise, reading of the problem should have // been ended due to a trivial infeasibility. debug_assert ! ( variable has_feasible_value ( ) ) ; let value = if variable . cost . is_zero ( ) { variable . get_feasible_value ( ) . unwrap ( ) } else { let value = optimize_independent_column ( general_form . objective , & variable . cost , ( variable . lower_bound . as_ref ( ) , variable . upper_bound . as_ref ( ) ) , ) ? ; fixed_cost += & variable . cost * & value ; value } ; Ok ( ( j , RemovedVariable :: Solved ( value ) ) ) } ) . collect :: < Result < _ , _ > > ( ) ? ; let constraints_marked_removed = counters . constraint . iter ( ) . enumerate ( ) . filter ( | & ( _ , & count ) | count == 0 ) . map ( | ( constraint , _ ) | { let right_hand_side = & general_form . b [ constraint ] ; let constraint_type = & general_form . constraint_types [ constraint ] ; if is_empty_constraint_feasible ( right_hand_side , constraint_type ) { Ok ( constraint ) } else { Err ( LinearProgramType :: Infeasible ) } } ) . collect :: < Result < _ , _ > > ( ) ? ; Ok ( Self { b : HashMap :: new ( ) , constraints : HashMap :: new ( ) , fixed_cost , bounds : HashMap :: new ( ) , // Variables that don't appear in any constraint are removed right away. removed_variables , constraints_marked_removed , activity_bounds : HashMap :: new ( ) , general_form , } ) }
Create a new instance.
Create a new instance .
general_form
&'a GeneralForm<OF>
counters
&Counters<OF>
general_form
&'a GeneralForm<OF>
counters
&Counters<OF>
return value
A new instance.
A new instance .