Skip to main content

VarBuilder

Struct VarBuilder 

Source
pub struct VarBuilder<'a> {
    pub model: &'a mut Model,
    pub var: VarId,
}
Expand description

A builder for setting properties of a variable using a fluent API.

Returned by Model::add_var(), this allows setting bounds, integrality, and other properties before finalizing the variable with finish().

§Examples

let mut model = Model::new();
let x = model
    .add_var()
    .integer()
    .finish();

Fields§

§model: &'a mut Model§var: VarId

Implementations§

Source§

impl<'a> VarBuilder<'a>

Methods for configuring a variable using a fluent API.

Returned by Model::add_var(). Use these methods to set bounds, integrality, or mark a variable as binary before calling finish().

Source

pub fn lower_bound(self, lb: f64) -> Self

Sets a lower bound for the variable.

This method currently panics because lower bounds are not yet implemented.

§Examples
let mut model = Model::new();
let x = model.add_var().lower_bound(0.0).finish();
Source

pub fn upper_bound(self, ub: f64) -> Self

Sets an upper bound for the variable.

This method currently panics because upper bounds are not yet implemented.

§Examples
let mut model = Model::new();
let x = model.add_var().upper_bound(10.0).finish();
Source

pub fn integer(self) -> Self

Mark the variable as an integer.

§Examples
let mut model = Model::new();
let x = model.add_var().integer().finish();
Source

pub fn binary(self) -> Self

Mark the variable as binary (0 or 1).

§Examples
let mut model = Model::new();
let x = model.add_var().binary().finish();
Source

pub fn finish(self) -> VarId

Finalizes the variable and returns its VarId.

Must be called after setting any desired properties on the variable.

§Examples
let mut model = Model::new();
let x = model.add_var().integer().finish();

Auto Trait Implementations§

§

impl<'a> Freeze for VarBuilder<'a>

§

impl<'a> RefUnwindSafe for VarBuilder<'a>

§

impl<'a> Send for VarBuilder<'a>

§

impl<'a> Sync for VarBuilder<'a>

§

impl<'a> Unpin for VarBuilder<'a>

§

impl<'a> UnsafeUnpin for VarBuilder<'a>

§

impl<'a> !UnwindSafe for VarBuilder<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.