fn process_bounds<FI, FO: From<FI> + Zero + One + Ord + Clone>(
    variable_info: &mut Vec<ShiftedVariable<FO>>,
    bounds: Vec<Bound<FI>>,
) -> Result<(), Inconsistency> {
    // Variables should not have existing bounds in them, because a default bound will be substituted
    // in this function. Note that this debug statement doesn't entirely cover that, in theory, all
    // variables could be completely free (unlikely).
    debug_assert!(variable_info.iter().all(|variable| {
        variable.lower_bound.is_none() && variable.upper_bound.is_none()
    }));

    // Variables that "have been touched" will not get a default bound substituted.
    let mut needs_default_lower_bound = vec![true; variable_info.len()];
    let mut variable_is_free = vec![false; variable_info.len()];

    // Bound names are irrelevant, treat them all the same
    for bound in bounds {
        for (variable_index, bound_type) in bound.values {
            let variable = &mut variable_info[variable_index];
            let (needs_default_lower, is_free) = process_bound(bound_type, variable)?;
            variable_is_free[variable_index] |= is_free;
            needs_default_lower_bound[variable_index] &= needs_default_lower;
        }
    }

    let any_free_has_bound = variable_info.iter().enumerate().any(|(j, variable)| {
        variable_is_free[j] && {
            variable.lower_bound.is_some() || variable.upper_bound.is_some()
        }
    });
    if any_free_has_bound {
        return Err(Inconsistency::new("A variable is both free and bounded."));
    }

    fill_in_default_lower_bounds(variable_info, needs_default_lower_bound);

    Ok(())
}
/// Modify the variable info bounds to contain the bound information.
///
/// # Arguments
///
/// * `variable_info`: Variables to add the bounds to.
/// * `bounds`: Bounds organized by name (this organization is not relevant and discarded).
///
/// # Errors
///
/// If there is a trivial infeasibility (a variable has no feasible values).
/// TODO(CORRECTNESS): Consider changing this into an "this LP is infeasible" return type
Modify the variable info bounds to contain the bound information.
Modify the variable info bounds to contain the bound information .
fn process_bounds<FI, FO: From<FI> + Zero + One + Ord + Clone>(
    variable_info: &mut Vec<ShiftedVariable<FO>>,
    bounds: Vec<Bound<FI>>,
) -> Result<(), Inconsistency> {
    // Variables should not have existing bounds in them, because a default bound will be substituted
    // in this function. Note that this debug statement doesn't entirely cover that, in theory, all
    // variables could be completely free (unlikely).
    debug_assert!(variable_info.iter().all(|variable| {
        variable.lower_bound.is_none() && variable.upper_bound.is_none()
    }));
    // Variables that "have been touched" will not get a default bound substituted.
    let mut needs_default_lower_bound = vec![true; variable_info.len()];
    let mut variable_is_free = vec![false; variable_info.len()];
    // Bound names are irrelevant, treat them all the same
    for bound in bounds {
        for (variable_index, bound_type) in bound.values {
            let variable = &mut variable_info[variable_index];
            let (needs_default_lower, is_free) = process_bound(bound_type, variable)?;
            variable_is_free[variable_index] |= is_free;
            needs_default_lower_bound[variable_index] &= needs_default_lower;
        }
    }
    let any_free_has_bound = variable_info.iter().enumerate().any(|(j, variable)| {
        variable_is_free[j] && {
            variable.lower_bound.is_some() || variable.upper_bound.is_some()
        }
    });
    if any_free_has_bound {
        return Err(Inconsistency::new("A variable is both free and bounded."));
    }
    fill_in_default_lower_bounds(variable_info, needs_default_lower_bound);
    Ok(())
}
fn process_bounds < FI , FO : From < FI > + Zero + One + Ord + Clone > ( variable_info : & mut Vec < ShiftedVariable < FO > > , bounds : Vec < Bound < FI > > , ) -> Result < ( ) , Inconsistency > { // Variables should not have existing bounds in them, because a default bound will be substituted // in this function. Note that this debug statement doesn't entirely cover that, in theory, all // variables could be completely free (unlikely). debug_assert ! ( variable_info iter ( ) all ( variable { variable lower_bound is_none ( ) variable upper_bound is_none ( ) } ) ) ; // Variables that "have been touched" will not get a default bound substituted. let mut needs_default_lower_bound = vec ! [ true variable_info len ( ) ] ; let mut variable_is_free = vec ! [ false variable_info len ( ) ] ; // Bound names are irrelevant, treat them all the same for bound in bounds { for ( variable_index , bound_type ) in bound . values { let variable = & mut variable_info [ variable_index ] ; let ( needs_default_lower , is_free ) = process_bound ( bound_type , variable ) ? ; variable_is_free [ variable_index ] |= is_free ; needs_default_lower_bound [ variable_index ] &= needs_default_lower ; } } let any_free_has_bound = variable_info . iter ( ) . enumerate ( ) . any ( | ( j , variable ) | { variable_is_free [ j ] && { variable . lower_bound . is_some ( ) || variable . upper_bound . is_some ( ) } } ) ; if any_free_has_bound { return Err ( Inconsistency :: new ( " " ) ) ; } fill_in_default_lower_bounds ( variable_info , needs_default_lower_bound ) ; Ok ( ( ) ) }
Modify the variable info bounds to contain the bound information.
Modify the variable info bounds to contain the bound information .
variable_info
&mut Vec<ShiftedVariable<FO>>
bounds
Vec<Bound<FI>>
variable_info
&mut Vec<ShiftedVariable<FO>>
bounds
Vec<Bound<FI>>
errors
If there is a trivial infeasibility (a variable has no feasible values).
TODO(CORRECTNESS): Consider changing this into an "this LP is infeasible" return type
If there is a trivial infeasibility ( a variable has no feasible values ) . TODO ( CORRECTNESS ) : Consider changing this into an " this LP is infeasible " return type