fn optimize_independent_column<OF>(
    objective: Objective,
    cost: &OF,
    (lower_bound, upper_bound): (Option<&OF>, Option<&OF>),
) -> Result<OF, LinearProgramType<OF>>
where
    OF: OrderedField,
    for<'r> &'r OF: OrderedFieldRef<OF>,
{
    let cost_sign = cost.cmp(&OF::zero());

    match (objective, cost_sign) {
        (Objective::Minimize, Ordering::Greater) | (Objective::Maximize, Ordering::Less) => {
            lower_bound.ok_or(LinearProgramType::Unbounded)
        },
        (Objective::Maximize, Ordering::Greater) | (Objective::Minimize, Ordering::Less) => {
            upper_bound.ok_or(LinearProgramType::Unbounded)
        },
        (_, Ordering::Equal) => panic!("Should not be called if there is no cost"),
    }.map(OF::clone)
}
/// Determine the optimal, or just any, feasible value for a variable.
///
/// # Arguments
///
/// * `objective`: Optimization direction.
/// * `cost`: Coefficient of the variable in the cost function.
/// * `bounds`: The lower and / or upper bound, if there are any.
///
/// # Returns
///
/// The optimal value if the variable appears in the objective function. Otherwise, any feasible
/// value.
///
/// # Errors
///
/// The problem might be unbounded.
Determine the optimal, or just any, feasible value for a variable.
Determine the optimal or just any feasible value for a variable .
fn optimize_independent_column<OF>(
    objective: Objective,
    cost: &OF,
    (lower_bound, upper_bound): (Option<&OF>, Option<&OF>),
) -> Result<OF, LinearProgramType<OF>>
where
    OF: OrderedField,
    for<'r> &'r OF: OrderedFieldRef<OF>,
{
    let cost_sign = cost.cmp(&OF::zero());
    match (objective, cost_sign) {
        (Objective::Minimize, Ordering::Greater) | (Objective::Maximize, Ordering::Less) => {
            lower_bound.ok_or(LinearProgramType::Unbounded)
        },
        (Objective::Maximize, Ordering::Greater) | (Objective::Minimize, Ordering::Less) => {
            upper_bound.ok_or(LinearProgramType::Unbounded)
        },
        (_, Ordering::Equal) => panic!("Should not be called if there is no cost"),
    }.map(OF::clone)
}
fn optimize_independent_column < OF > ( objective : Objective , cost : & OF , ( lower_bound , upper_bound ) : ( Option < & OF > , Option < & OF > ) , ) -> Result < OF , LinearProgramType < OF > > where OF : OrderedField , for < ' r > & ' r OF : OrderedFieldRef < OF > , { let cost_sign = cost . cmp ( & OF :: zero ( ) ) ; match ( objective , cost_sign ) { ( Objective :: Minimize , Ordering :: Greater ) | ( Objective :: Maximize , Ordering :: Less ) => { lower_bound . ok_or ( LinearProgramType :: Unbounded ) } , ( Objective :: Maximize , Ordering :: Greater ) | ( Objective :: Minimize , Ordering :: Less ) => { upper_bound . ok_or ( LinearProgramType :: Unbounded ) } , ( _ , Ordering :: Equal ) => panic ! ( " " ) , } . map ( OF :: clone ) }
Determine the optimal, or just any, feasible value for a variable.
Determine the optimal or just any feasible value for a variable .
objective
Objective
cost
(Option<&OF>, Option<&OF>)
The optimal value if the variable appears in the objective function. Otherwise, any feasible
value.
The optimal value if the variable appears in the objective function . Otherwise any feasible value .
objective
Objective
cost
(Option<&OF>, Option<&OF>)
errors
The problem might be unbounded.
The problem might be unbounded .