pub struct InstanceBuilder { /* private fields */ }Expand description
Builder for creating Instance with validation.
This builder allows constructing an Instance step by step,
with optional fields that can be set before calling build().
§Example
use ommx::{Instance, Sense, Function};
use std::collections::BTreeMap;
let instance = Instance::builder()
.sense(Sense::Minimize)
.objective(Function::Zero)
.decision_variables(BTreeMap::new())
.constraints(BTreeMap::new())
.build()
.unwrap();Implementations§
Source§impl InstanceBuilder
impl InstanceBuilder
Sourcepub fn decision_variables(
self,
decision_variables: BTreeMap<VariableID, DecisionVariable>,
) -> Self
pub fn decision_variables( self, decision_variables: BTreeMap<VariableID, DecisionVariable>, ) -> Self
Sets the decision variables.
Sourcepub fn constraints(
self,
constraints: BTreeMap<ConstraintID, Constraint>,
) -> Self
pub fn constraints( self, constraints: BTreeMap<ConstraintID, Constraint>, ) -> Self
Sets the constraints.
Sourcepub fn named_functions(
self,
named_functions: BTreeMap<NamedFunctionID, NamedFunction>,
) -> Self
pub fn named_functions( self, named_functions: BTreeMap<NamedFunctionID, NamedFunction>, ) -> Self
Sets the named functions.
Sourcepub fn removed_constraints(
self,
removed_constraints: BTreeMap<ConstraintID, RemovedConstraint>,
) -> Self
pub fn removed_constraints( self, removed_constraints: BTreeMap<ConstraintID, RemovedConstraint>, ) -> Self
Sets the removed constraints.
Sourcepub fn decision_variable_dependency(
self,
decision_variable_dependency: AcyclicAssignments,
) -> Self
pub fn decision_variable_dependency( self, decision_variable_dependency: AcyclicAssignments, ) -> Self
Sets the decision variable dependency.
Sourcepub fn constraint_hints(self, constraint_hints: ConstraintHints) -> Self
pub fn constraint_hints(self, constraint_hints: ConstraintHints) -> Self
Sets the constraint hints.
Sourcepub fn parameters(self, parameters: Parameters) -> Self
pub fn parameters(self, parameters: Parameters) -> Self
Sets the parameters.
Sourcepub fn description(self, description: Description) -> Self
pub fn description(self, description: Description) -> Self
Sets the description.
Sourcepub fn build(self) -> Result<Instance>
pub fn build(self) -> Result<Instance>
Builds the Instance with validation.
§Errors
Returns an error if:
- Required fields (
sense,objective,decision_variables,constraints) are not set - Map keys don’t match their value’s ID (decision_variables, constraints, removed_constraints)
- The objective function or constraints reference undefined variable IDs
- The keys of
constraintsandremoved_constraintsare not disjoint - The keys of
decision_variable_dependencyare not indecision_variables used,fixed, anddependentare not pairwise disjoint (seeDecisionVariableAnalysis)
Trait Implementations§
Source§impl Clone for InstanceBuilder
impl Clone for InstanceBuilder
Source§fn clone(&self) -> InstanceBuilder
fn clone(&self) -> InstanceBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InstanceBuilder
impl Debug for InstanceBuilder
Source§impl Default for InstanceBuilder
impl Default for InstanceBuilder
Source§fn default() -> InstanceBuilder
fn default() -> InstanceBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for InstanceBuilder
impl RefUnwindSafe for InstanceBuilder
impl Send for InstanceBuilder
impl Sync for InstanceBuilder
impl Unpin for InstanceBuilder
impl UnsafeUnpin for InstanceBuilder
impl UnwindSafe for InstanceBuilder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more