pub struct Objective {
pub sense: Sense,
pub expr: LinExpr,
pub name: Option<String>,
pub priority: Option<u32>,
}Expand description
Represents an objective function in a model.
Contains the linear expression to optimize, the optimization sense (min/max), an optional name, and an optional priority (useful for multi-objective problems).
§Examples
let x = model.add_var().finish(); // VarId
let objective = Objective::maximize(3.0 * x).name("Profit");Fields§
§sense: SenseWhether to minimize or maximize the objective.
expr: LinExprThe linear expression representing the objective.
name: Option<String>Optional human-readable name.
priority: Option<u32>Optional priority for multi-objective optimization (not used)
Implementations§
Source§impl Objective
impl Objective
Sourcepub fn minimize(expr: LinExpr) -> ObjectiveBuilder
pub fn minimize(expr: LinExpr) -> ObjectiveBuilder
Creates a minimization objective.
Returns an ObjectiveBuilder to optionally set name or priority.
§Example
let x = model.add_var().finish(); // VarId
let obj = Objective::minimize(3.0 * x).name("Cost");Sourcepub fn maximize(expr: LinExpr) -> ObjectiveBuilder
pub fn maximize(expr: LinExpr) -> ObjectiveBuilder
Creates a maximization objective.
Returns an ObjectiveBuilder to optionally set name or priority.
§Example
let x = model.add_var().finish(); // VarId
let obj = Objective::maximize(3.0 * x).name("Profit");Trait Implementations§
Auto Trait Implementations§
impl Freeze for Objective
impl RefUnwindSafe for Objective
impl Send for Objective
impl Sync for Objective
impl Unpin for Objective
impl UnsafeUnpin for Objective
impl UnwindSafe for Objective
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more