fn compute_variable_info<FI, FO: From<FI> + NotZero + Zero + One + Ord + Display + Debug + Clone>(
    columns: Vec<Column<FI>>,
    cost_values: Vec<SparseTuple<FI>>,
    bounds: Vec<Bound<FI>>,
    nr_rows: usize,
) -> Result<(Vec<ShiftedVariable<FO>>, Sparse<FO, FO, ColumnMajor>, Vec<String>), Inconsistency> {
    // Reorder the column names.
    debug_assert_eq!(
        columns.iter().map(|variable| variable.name.as_str()).collect::<HashSet<_>>().len(),
        columns.len(),
    );

    // Read in the sparse cost values
    debug_assert!(cost_values.is_sorted_by_key(|&(j, _)| j));
    let mut cost_values = cost_values.into_iter().peekable();
    let (mut info, values_names): (Vec<_>, Vec<_>) = columns.into_iter()
        .enumerate()
        .map(|(j, variable)| {
            let cost = cost_values.next_if(|&(jj, _)| jj == j)
                .map_or(FO::zero(), |(_, v)| v.into());

            (ShiftedVariable {
                variable_type: variable.variable_type,
                cost,
                upper_bound: None,
                lower_bound: None,
                shift: FO::zero(),
                flipped: false,
            }, (variable.values, variable.name))
        }).unzip();
    process_bounds(&mut info, bounds)?;
    let (values, names): (Vec<_>, Vec<_>) = values_names.into_iter()
        .map(|(collection, names)| {
            (collection.into_iter().map(|(i, v)| (i, v.into())).collect(), names)
        })
        .unzip();

    let columns = ColumnMajor::new(values, nr_rows, names.len());

    Ok((info, columns, names))
}
/// Convert the variable oriented information of a MPS into `GeneralForm` fields.
///
/// # Arguments
///
/// * `columns`: MPS columns used to get the name index and cost value from.
/// * `cost_values`: Coefficients in cost function.
/// * `bounds`: Variable bounds.
/// * `nr_rows`: Amount of rows, excluding the cost row, read.
///
/// # Return value
///
/// Collection of variable info's as used in the `GeneralForm` and a collection of the column names.
///
/// # Errors
///
/// If there is an inconsistency in bound information, such as a trivial infeasibility.
Convert the variable oriented information of a MPS into `GeneralForm` fields.
Convert the variable oriented information of a MPS into ` GeneralForm ` fields .
fn compute_variable_info<FI, FO: From<FI> + NotZero + Zero + One + Ord + Display + Debug + Clone>(
    columns: Vec<Column<FI>>,
    cost_values: Vec<SparseTuple<FI>>,
    bounds: Vec<Bound<FI>>,
    nr_rows: usize,
) -> Result<(Vec<ShiftedVariable<FO>>, Sparse<FO, FO, ColumnMajor>, Vec<String>), Inconsistency> {
    // Reorder the column names.
    debug_assert_eq!(
        columns.iter().map(|variable| variable.name.as_str()).collect::<HashSet<_>>().len(),
        columns.len(),
    );
    // Read in the sparse cost values
    debug_assert!(cost_values.is_sorted_by_key(|&(j, _)| j));
    let mut cost_values = cost_values.into_iter().peekable();
    let (mut info, values_names): (Vec<_>, Vec<_>) = columns.into_iter()
        .enumerate()
        .map(|(j, variable)| {
            let cost = cost_values.next_if(|&(jj, _)| jj == j)
                .map_or(FO::zero(), |(_, v)| v.into());
            (ShiftedVariable {
                variable_type: variable.variable_type,
                cost,
                upper_bound: None,
                lower_bound: None,
                shift: FO::zero(),
                flipped: false,
            }, (variable.values, variable.name))
        }).unzip();
    process_bounds(&mut info, bounds)?;
    let (values, names): (Vec<_>, Vec<_>) = values_names.into_iter()
        .map(|(collection, names)| {
            (collection.into_iter().map(|(i, v)| (i, v.into())).collect(), names)
        })
        .unzip();
    let columns = ColumnMajor::new(values, nr_rows, names.len());
    Ok((info, columns, names))
}
fn compute_variable_info < FI , FO : From < FI > + NotZero + Zero + One + Ord + Display + Debug + Clone > ( columns : Vec < Column < FI > > , cost_values : Vec < SparseTuple < FI > > , bounds : Vec < Bound < FI > > , nr_rows : usize , ) -> Result < ( Vec < ShiftedVariable < FO > > , Sparse < FO , FO , ColumnMajor > , Vec < String > ) , Inconsistency > { // Reorder the column names. debug_assert_eq ! ( columns iter ( ) map ( variable variable name as_str ( ) ) collect HashSet ( ) len ( ) columns len ( ) ) ; // Read in the sparse cost values debug_assert ! ( cost_values is_sorted_by_key ( ( j ) j ) ) ; let mut cost_values = cost_values . into_iter ( ) . peekable ( ) ; let ( mut info , values_names ) : ( Vec < _ > , Vec < _ > ) = columns . into_iter ( ) . enumerate ( ) . map ( | ( j , variable ) | { let cost = cost_values . next_if ( | & ( jj , _ ) | jj == j ) . map_or ( FO :: zero ( ) , | ( _ , v ) | v . into ( ) ) ; ( ShiftedVariable { variable_type : variable . variable_type , cost , upper_bound : None , lower_bound : None , shift : FO :: zero ( ) , flipped : false , } , ( variable . values , variable . name ) ) } ) . unzip ( ) ; process_bounds ( & mut info , bounds ) ? ; let ( values , names ) : ( Vec < _ > , Vec < _ > ) = values_names . into_iter ( ) . map ( | ( collection , names ) | { ( collection . into_iter ( ) . map ( | ( i , v ) | ( i , v . into ( ) ) ) . collect ( ) , names ) } ) . unzip ( ) ; let columns = ColumnMajor :: new ( values , nr_rows , names . len ( ) ) ; Ok ( ( info , columns , names ) ) }
Convert the variable oriented information of a MPS into `GeneralForm` fields.
Convert the variable oriented information of a MPS into ` GeneralForm ` fields .
columns
Vec<Column<FI>>
cost_values
Vec<SparseTuple<FI>>
bounds
Vec<Bound<FI>>
nr_rows
usize
columns
Vec<Column<FI>>
cost_values
Vec<SparseTuple<FI>>
bounds
Vec<Bound<FI>>
nr_rows
usize
return value
Collection of variable info's as used in the `GeneralForm` and a collection of the column names.
Collection of variable info ' s as used in the ` GeneralForm ` and a collection of the column names .
errors
If there is an inconsistency in bound information, such as a trivial infeasibility.
If there is an inconsistency in bound information such as a trivial infeasibility .