Struct dypdl::Model

source ·
pub struct Model {
Show 13 fields pub state_metadata: StateMetadata, pub target: State, pub table_registry: TableRegistry, pub state_constraints: Vec<GroundedCondition>, pub base_cases: Vec<BaseCase>, pub base_states: Vec<(State, Option<CostExpression>)>, pub reduce_function: ReduceFunction, pub cost_type: CostType, pub forward_transitions: Vec<Transition>, pub forward_forced_transitions: Vec<Transition>, pub backward_transitions: Vec<Transition>, pub backward_forced_transitions: Vec<Transition>, pub dual_bounds: Vec<CostExpression>,
}
Expand description

DyPDL model.

Fields§

§state_metadata: StateMetadata

Information about state variables.

§target: State

Target state.

§table_registry: TableRegistry

Tables of constants.

§state_constraints: Vec<GroundedCondition>

State constraints.

§base_cases: Vec<BaseCase>

Base cases.

§base_states: Vec<(State, Option<CostExpression>)>

Explicit definitions of base states.

§reduce_function: ReduceFunction

Specifying how to compute the value of a state from applicable transitions.

§cost_type: CostType

Type of the cost.

§forward_transitions: Vec<Transition>

Forward transitions.

§forward_forced_transitions: Vec<Transition>

Forward forced transitions.

§backward_transitions: Vec<Transition>

Backward transitions.

§backward_forced_transitions: Vec<Transition>

Backward forced transitions.

§dual_bounds: Vec<CostExpression>

Dual bounds.

Implementations§

source§

impl Model

source

pub fn check_constraints<U: StateInterface>(&self, state: &U) -> bool

Returns true if a state satisfies all state constraints and false otherwise.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let variable = model.add_integer_variable("variable", 2).unwrap();
let state = model.target.clone();

let condition = Condition::comparison_i(ComparisonOperator::Ge, variable, 0);
model.add_state_constraint(condition).unwrap();
assert!(model.check_constraints(&state));

let condition = Condition::comparison_i(ComparisonOperator::Ge, variable, 3);
model.add_state_constraint(condition).unwrap();
assert!(!model.check_constraints(&state));
source

pub fn is_base<U: StateInterface>(&self, state: &U) -> bool

Returns true if a state satisfies any of base cases and false otherwise.

§Panics

Panics if the cost of the transitioned state is used or a min/max reduce operation is performed on an empty set or vector in a base case.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let variable = model.add_integer_variable("variable", 2).unwrap();
let state = model.target.clone();

let a = Condition::comparison_i(ComparisonOperator::Ge, variable, 0);
let b = Condition::comparison_i(ComparisonOperator::Le, variable, 1);
model.add_base_case(vec![a, b]).unwrap();
assert!(!model.is_base(&state));

let a = Condition::comparison_i(ComparisonOperator::Ge, variable, 0);
let b = Condition::comparison_i(ComparisonOperator::Le, variable, 2);
model.add_base_case(vec![a, b]).unwrap();
assert!(model.is_base(&state));
source

pub fn eval_base_cost<T: Numeric + Ord, U: StateInterface>( &self, state: &U, ) -> Option<T>

Evaluates the base cost given a state.

Returns None if the state does not satisfy any base case.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let variable = model.add_integer_variable("variable", 2).unwrap();
let state = model.target.clone();

let a = Condition::comparison_i(ComparisonOperator::Ge, variable, 0);
let b = Condition::comparison_i(ComparisonOperator::Le, variable, 1);
model.add_base_case(vec![a, b]).unwrap();
assert!(!model.is_base(&state));

let a = Condition::comparison_i(ComparisonOperator::Ge, variable, 0);
let b = Condition::comparison_i(ComparisonOperator::Le, variable, 2);
model.add_base_case(vec![a, b]).unwrap();
assert!(model.is_base(&state));
source

pub fn eval_dual_bound<U: StateInterface, T: Numeric + Ord>( &self, state: &U, ) -> Option<T>

Evaluates the dual bound given a state.

§Panics

Panics if the cost of the transitioned state is used or a min/max reduce operation is performed on an empty set or vector in a dual bound.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
model.set_minimize();
let variable = model.add_integer_variable("variable", 2).unwrap();
let state = model.target.clone();
assert_eq!(model.eval_dual_bound::<_, Integer>(&state), None);

model.add_dual_bound(IntegerExpression::from(0)).unwrap();
model.add_dual_bound(IntegerExpression::from(variable)).unwrap();
assert_eq!(model.eval_dual_bound::<_, Integer>(&state), Some(2));
source

pub fn generate_successor_state<S: StateInterface, R: StateInterface + From<State>, T: TransitionInterface, U: Numeric>( &self, state: &S, cost: U, transition: &T, cost_bound: Option<U>, ) -> Option<(R, U)>

Returns the successor state and the cost of a state, given a transition and the cost of the successor state.

Returns None if the cost is greater than or equal to the bound.

§Panics

Panics if the cost of the transitioned state is used or a min/max reduce operation is performed on an empty set or vector in a precondition or an effect of the transition.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let variable = model.add_integer_variable("variable", 2).unwrap();
let state = model.target.clone();

let mut transition = Transition::new("transition");
transition.add_effect(variable, variable + 1);
transition.set_cost(IntegerExpression::Cost + 1);

let (successor, cost): (State, _) = model.generate_successor_state(&state, 0, &transition, None).unwrap();
assert_eq!(successor.get_integer_variable(variable.id()), 3);
assert_eq!(cost, 1);

let result: Option<(State, _)> = model.generate_successor_state(&state, 0, &transition, Some(1));
assert_eq!(result, None);
source

pub fn validate_forward<T: Numeric + Display + Ord>( &self, transitions: &[Transition], cost: T, show_message: bool, ) -> bool

Validate a solution consists of forward transitions.

§Panics

Panics if the cost of the transitioned state is used or a min/max reduce operation is performed on an empty set or vector in a precondition or an effect of a transition.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let variable = model.add_integer_variable("variable", 1).unwrap();
model.add_base_case(vec![Condition::comparison_i(ComparisonOperator::Eq, variable, 0)]).unwrap();
let mut transition = Transition::new("decrement");
transition.add_effect(variable, variable - 1).unwrap();
transition.set_cost(IntegerExpression::Cost + 1);

let transitions = [transition];
let cost = 1;

assert!(model.validate_forward(&transitions, cost, true));
source

pub fn has_resource_variables(&self) -> bool

Returns true if there is a resource variable and false otherwise.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let variable = model.add_integer_variable("variable", 2).unwrap();
assert!(!model.has_resource_variables());

let variable = model.add_integer_resource_variable("variable", true, 2).unwrap();
assert!(model.has_resource_variables());
source

pub fn has_dual_bounds(&self) -> bool

Returns true if a dual bound is defined and false otherwise.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
assert!(!model.has_dual_bounds());

model.add_dual_bound(IntegerExpression::from(0)).unwrap();
assert!(model.has_dual_bounds());
source

pub fn integer_cost_model() -> Model

Creates a model whose cost is integer.

source

pub fn continuous_cost_model() -> Model

Creates a model whose cost is continuous.

source

pub fn set_minimize(&mut self)

Set the objective to minimization.

source

pub fn set_maximize(&mut self)

Set the objective to maximization.

source

pub fn get_object_type(&self, name: &str) -> Result<ObjectType, ModelErr>

Returns object type given a name.

§Errors

If no object type with the name.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
model.add_object_type("object", 1).unwrap();

assert!(model.get_object_type("object").is_ok());
source

pub fn add_object_type<T>( &mut self, name: T, number: usize, ) -> Result<ObjectType, ModelErr>
where String: From<T>,

Adds an object type and returns it.

§Errors

If the name is already used.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
assert!(model.add_object_type("object", 4).is_ok());
source

pub fn get_number_of_objects(&self, ob: ObjectType) -> Result<usize, ModelErr>

Returns the number of objects associated with the type.

§Errors

If the object type is not in the model.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();

assert_eq!(model.get_number_of_objects(object_type).unwrap(), 4);
source

pub fn create_set( &self, ob: ObjectType, array: &[Element], ) -> Result<Set, ModelErr>

Create a set of objects associated with the type.

§Errors

If the object type is not in the model or an input value is greater than or equal to the number of the objects.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();

assert!(model.create_set(object_type, &[0, 1, 2, 3]).is_ok());
source

pub fn get_element_variable( &self, name: &str, ) -> Result<ElementVariable, ModelErr>

Returns an element variable given a name.

§Errors

If no such variable.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
model.add_element_variable("variable", object_type, 0).unwrap();

assert!(model.get_element_variable("variable").is_ok());
source

pub fn add_element_variable<T>( &mut self, name: T, ob: ObjectType, target: Element, ) -> Result<ElementVariable, ModelErr>
where String: From<T>,

Adds and returns an element variable.

The value in the target state must be specified.

§Errors

If the name is already used, or the object type is not in the model.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();

assert!(model.add_element_variable("variable", object_type, 0).is_ok());
source

pub fn get_element_resource_variable( &self, name: &str, ) -> Result<ElementResourceVariable, ModelErr>

Returns an element resource variable given a name.

§Errors

If no such variable.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
model.add_element_resource_variable("variable", object_type, false, 0).unwrap();

assert!(model.get_element_resource_variable("variable").is_ok());
source

pub fn add_element_resource_variable<T>( &mut self, name: T, ob: ObjectType, less_is_better: bool, target: Element, ) -> Result<ElementResourceVariable, ModelErr>
where String: From<T>,

Adds and returns an element resource variable.

The value in the target state must be specified.

§Errors

If the name is already used, or the object type is not in the model.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();

assert!(model.add_element_resource_variable("variable", object_type, false, 0).is_ok());
source

pub fn get_set_variable(&self, name: &str) -> Result<SetVariable, ModelErr>

Returns a set variable given a name.

§Errors

If no such variable.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
let set = model.create_set(object_type, &[0, 1, 2, 3]).unwrap();
model.add_set_variable("variable", object_type, set).unwrap();

assert!(model.get_set_variable("variable").is_ok());
source

pub fn add_set_variable<T>( &mut self, name: T, ob: ObjectType, target: Set, ) -> Result<SetVariable, ModelErr>
where String: From<T>,

Adds and returns a set variable.

The value in the target state must be specified.

§Errors

If the name is already used, the object type is not in the model, or the target contains a value greater than or equal to the number of the objects.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
let set = model.create_set(object_type, &[0, 1, 2, 3]).unwrap();

assert!(model.add_set_variable("variable", object_type, set).is_ok());
source

pub fn get_vector_variable( &self, name: &str, ) -> Result<VectorVariable, ModelErr>

Returns a vector variable given a name.

§Errors

If no such variable.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
model.add_vector_variable("variable", object_type, vec![0, 1, 2, 3]).unwrap();

assert!(model.get_vector_variable("variable").is_ok());
source

pub fn add_vector_variable<T>( &mut self, name: T, ob: ObjectType, target: Vector, ) -> Result<VectorVariable, ModelErr>
where String: From<T>,

Adds and returns a vector variable.

The value in the target state must be specified.

§Errors

If the name is already used, the object type is not in the model, or the target contains a value greater than or equal to the number of the objects.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();

assert!(model.add_vector_variable("variable", object_type, vec![0, 1, 2, 3]).is_ok());
source

pub fn get_integer_variable( &self, name: &str, ) -> Result<IntegerVariable, ModelErr>

Returns an integer variable given a name.

§Errors

If no such variable.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
model.add_integer_variable("variable", 0).unwrap();

assert!(model.get_integer_variable("variable").is_ok());
source

pub fn add_integer_variable<T>( &mut self, name: T, target: Integer, ) -> Result<IntegerVariable, ModelErr>
where String: From<T>,

Adds and returns an integer variable.

The value in the target state must be specified.

§Errors

If the name is already used.

use dypdl::prelude::*;

let mut model = Model::default();

assert!(model.add_integer_variable("variable", 0).is_ok());
source

pub fn get_integer_resource_variable( &self, name: &str, ) -> Result<IntegerResourceVariable, ModelErr>

Returns an integer resource variable given a name.

§Errors

If no such variable.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
model.add_integer_resource_variable("variable", false, 0).unwrap();

assert!(model.get_integer_resource_variable("variable").is_ok());
source

pub fn add_integer_resource_variable<T>( &mut self, name: T, less_is_better: bool, target: Integer, ) -> Result<IntegerResourceVariable, ModelErr>
where String: From<T>,

Adds and returns an integer resource variable.

The value in the target state must be specified.

§Errors

If the name is already used.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();

assert!(model.add_integer_resource_variable("variable", false, 0).is_ok());
source

pub fn get_continuous_variable( &self, name: &str, ) -> Result<ContinuousVariable, ModelErr>

Returns a continuous variable given a name.

§Errors

If no such variable.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
model.add_continuous_variable("variable", 0.5).unwrap();

assert!(model.get_continuous_variable("variable").is_ok());
source

pub fn add_continuous_variable<T>( &mut self, name: T, target: Continuous, ) -> Result<ContinuousVariable, ModelErr>
where String: From<T>,

Adds and returns a continuous variable.

The value in the target state must be specified.

§Errors

If the name is already used.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();

assert!(model.add_continuous_variable("variable", 0.5).is_ok());
source

pub fn get_continuous_resource_variable( &self, name: &str, ) -> Result<ContinuousResourceVariable, ModelErr>

Returns a continuous resource variable given a name.

§Errors

If no such variable.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
model.add_continuous_resource_variable("variable", false, 0.5).unwrap();

assert!(model.get_continuous_resource_variable("variable").is_ok());
source

pub fn add_continuous_resource_variable<T>( &mut self, name: T, less_is_better: bool, target: Continuous, ) -> Result<ContinuousResourceVariable, ModelErr>
where String: From<T>,

Adds and returns a continuous resource variable.

The value in the target state must be specified.

§Errors

If the name is already used.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();

assert!(model.add_continuous_resource_variable("variable", false, 0.5).is_ok());
source

pub fn add_state_constraint( &mut self, condition: Condition, ) -> Result<(), ModelErr>

Adds a state constraint.

§Errors

If the condition is invalid, e.., it uses not existing variables or the state of the transitioned state.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let variable = model.add_integer_variable("variable", 2).unwrap();

let constraint = Condition::comparison_i(ComparisonOperator::Ge, variable, 0);
assert!(model.add_state_constraint(constraint).is_ok());
source

pub fn add_base_case( &mut self, conditions: Vec<Condition>, ) -> Result<(), ModelErr>

Adds a base case.

The cost of a base case is assumed to be zero.

§Errors

If a condition is invalid, e.g., it uses variables not existing in this model or the state of the transitioned state.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let variable = model.add_integer_variable("variable", 2).unwrap();

let a = Condition::comparison_i(ComparisonOperator::Ge, variable, 0);
let b = Condition::comparison_i(ComparisonOperator::Le, variable, 1);
assert!(model.add_base_case(vec![a, b]).is_ok());
source

pub fn add_base_case_with_cost<T>( &mut self, conditions: Vec<Condition>, cost: T, ) -> Result<(), ModelErr>
where CostExpression: From<T>,

Adds a base case with its cost.

§Errors

If a condition is invalid, e.g., it uses variables not existing in this model or the state of the transitioned state.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let variable = model.add_integer_variable("variable", 2).unwrap();

let a = Condition::comparison_i(ComparisonOperator::Ge, variable, 0);
let b = Condition::comparison_i(ComparisonOperator::Le, variable, 1);
let cost = 1;
assert!(model.add_base_case_with_cost(vec![a, b], 1).is_ok());
source

pub fn check_state<'a, T: StateInterface>( &self, state: &'a T, ) -> Result<(), ModelErr>

Check if a state is valid.

§Errors

If a state is invalid, e.g., it contains variables not existing in this model.

source

pub fn add_base_state(&mut self, state: State) -> Result<(), ModelErr>

Adds a base state.

The cost of the state is assumed to be zero.

§Errors

If a state is invalid, e.g., it contains variables not existing in this model.

source

pub fn add_base_state_with_cost<T>( &mut self, state: State, cost: T, ) -> Result<(), ModelErr>
where CostExpression: From<T>,

Adds a base state with its cost.

§Errors

If a state is invalid, e.g., it contains variables not existing in this model.

source

pub fn get_reduce_function(&self) -> ReduceFunction

Returns the reduce function.

source

pub fn set_reduce_function(&mut self, reduce_function: ReduceFunction)

Changes the reduce function.

source

pub fn add_forward_transition( &mut self, transition: Transition, ) -> Result<(), ModelErr>

Adds a forward transition.

§Errors

If it uses an invalid expression, e.g., it uses variables not existing in this model or the state of the transitioned state.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let transition = Transition::new("transition");

assert!(model.add_forward_transition(transition).is_ok());
source

pub fn add_forward_forced_transition( &mut self, transition: Transition, ) -> Result<(), ModelErr>

Adds a forward forced transition.

§Errors

If it uses an invalid expression, e.g., it uses variables not existing in this model or the state of the transitioned state.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let transition = Transition::new("transition");

assert!(model.add_forward_forced_transition(transition).is_ok());
source

pub fn add_backward_transition( &mut self, transition: Transition, ) -> Result<(), ModelErr>

Adds a backward transition.

§Errors

If it uses an invalid expression, e.g., it uses variables not existing in this model or the state of the transitioned state.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let transition = Transition::new("transition");

assert!(model.add_backward_transition(transition).is_ok());
source

pub fn add_backward_forced_transition( &mut self, transition: Transition, ) -> Result<(), ModelErr>

Adds a backward forced transition.

§Errors

If it uses an invalid expression, e.g., it uses variables not existing in this model or the state of the transitioned state.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let transition = Transition::new("transition");

assert!(model.add_backward_forced_transition(transition).is_ok());
source

pub fn get_capacity_of_set_in_1d_table( &self, table: Table1DHandle<Set>, ) -> Result<usize, ModelErr>

Returns the capacity of a set constant in a 1D table.

§Errors

Errors if the table does not exist in the model.

§Panics

Panics if the table is empty.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
let set = model.create_set(object_type, &[0, 1, 2, 3]).unwrap();
let table = model.add_table_1d("table", vec![set]).unwrap();

assert_eq!(model.get_capacity_of_set_in_1d_table(table).unwrap(), 4);
source

pub fn get_capacity_of_set_in_2d_table( &self, table: Table2DHandle<Set>, ) -> Result<usize, ModelErr>

Returns the capacity of a set constant in a 2D table.

§Errors

Errors if the table does not exist in the model.

§Panics

Panics if the table is empty.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
let set = model.create_set(object_type, &[0, 1, 2, 3]).unwrap();
let table = model.add_table_2d("table", vec![vec![set]]).unwrap();

assert_eq!(model.get_capacity_of_set_in_2d_table(table).unwrap(), 4);
source

pub fn get_capacity_of_set_in_3d_table( &self, table: Table3DHandle<Set>, ) -> Result<usize, ModelErr>

Returns the capacity of a set constant in a 3D table.

§Errors

Errors if the table does not exist in the model.

§Panics

Panics if the table is empty.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
let set = model.create_set(object_type, &[0, 1, 2, 3]).unwrap();
let table = model.add_table_3d("table", vec![vec![vec![set]]]).unwrap();

assert_eq!(model.get_capacity_of_set_in_3d_table(table).unwrap(), 4);
source

pub fn get_capacity_of_set_in_table( &self, table: TableHandle<Set>, ) -> Result<usize, ModelErr>

Returns the capacity of a set constant in a table.

§Errors

Errors if the table does not exist in the model.

§Panics

Panics if the table is empty.

§Examples
use dypdl::prelude::*;
use rustc_hash::FxHashMap;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
let set = model.create_set(object_type, &[0, 1, 2, 3]).unwrap();
let map = FxHashMap::from_iter(vec![(vec![0, 0, 0, 0], set.clone())]);
let table = model.add_table("table", map, set.clone()).unwrap();

assert_eq!(model.get_capacity_of_set_in_table(table).unwrap(), 4);

Trait Implementations§

source§

impl AccessPreference<ContinuousResourceVariable> for Model

source§

fn get_preference( &self, v: ContinuousResourceVariable, ) -> Result<bool, ModelErr>

Returns the preference of a resource variable. Read more
source§

fn set_preference( &mut self, v: ContinuousResourceVariable, less_is_better: bool, ) -> Result<(), ModelErr>

Sets the preference of a resource variable. Read more
source§

impl AccessPreference<ElementResourceVariable> for Model

source§

fn get_preference(&self, v: ElementResourceVariable) -> Result<bool, ModelErr>

Returns the preference of a resource variable. Read more
source§

fn set_preference( &mut self, v: ElementResourceVariable, less_is_better: bool, ) -> Result<(), ModelErr>

Sets the preference of a resource variable. Read more
source§

impl AccessPreference<IntegerResourceVariable> for Model

source§

fn get_preference(&self, v: IntegerResourceVariable) -> Result<bool, ModelErr>

Returns the preference of a resource variable. Read more
source§

fn set_preference( &mut self, v: IntegerResourceVariable, less_is_better: bool, ) -> Result<(), ModelErr>

Sets the preference of a resource variable. Read more
source§

impl AccessTarget<ContinuousResourceVariable, f64> for Model

source§

fn get_target( &self, v: ContinuousResourceVariable, ) -> Result<Continuous, ModelErr>

Returns the value in the target state. Read more
source§

fn set_target( &mut self, v: ContinuousResourceVariable, target: Continuous, ) -> Result<(), ModelErr>

Set the value in the target state Read more
source§

impl AccessTarget<ContinuousVariable, f64> for Model

source§

fn get_target(&self, v: ContinuousVariable) -> Result<Continuous, ModelErr>

Returns the value in the target state. Read more
source§

fn set_target( &mut self, v: ContinuousVariable, target: Continuous, ) -> Result<(), ModelErr>

Set the value in the target state Read more
source§

impl AccessTarget<ElementResourceVariable, usize> for Model

source§

fn get_target( &self, variable: ElementResourceVariable, ) -> Result<Element, ModelErr>

Returns the value in the target state. Read more
source§

fn set_target( &mut self, variable: ElementResourceVariable, target: Element, ) -> Result<(), ModelErr>

Set the value in the target state Read more
source§

impl AccessTarget<ElementVariable, usize> for Model

source§

fn get_target(&self, variable: ElementVariable) -> Result<Element, ModelErr>

Returns the value in the target state. Read more
source§

fn set_target( &mut self, variable: ElementVariable, target: Element, ) -> Result<(), ModelErr>

Set the value in the target state Read more
source§

impl AccessTarget<IntegerResourceVariable, i32> for Model

source§

fn get_target(&self, v: IntegerResourceVariable) -> Result<Integer, ModelErr>

Returns the value in the target state. Read more
source§

fn set_target( &mut self, v: IntegerResourceVariable, target: Integer, ) -> Result<(), ModelErr>

Set the value in the target state Read more
source§

impl AccessTarget<IntegerVariable, i32> for Model

source§

fn get_target(&self, v: IntegerVariable) -> Result<Integer, ModelErr>

Returns the value in the target state. Read more
source§

fn set_target( &mut self, v: IntegerVariable, target: Integer, ) -> Result<(), ModelErr>

Set the value in the target state Read more
source§

impl AccessTarget<SetVariable, FixedBitSet> for Model

source§

fn get_target(&self, variable: SetVariable) -> Result<Set, ModelErr>

Returns the value in the target state. Read more
source§

fn set_target( &mut self, variable: SetVariable, target: Set, ) -> Result<(), ModelErr>

Set the value in the target state Read more
source§

impl AccessTarget<VectorVariable, Vec<usize>> for Model

source§

fn get_target(&self, variable: VectorVariable) -> Result<Vector, ModelErr>

Returns the value in the target state. Read more
source§

fn set_target( &mut self, variable: VectorVariable, target: Vector, ) -> Result<(), ModelErr>

Set the value in the target state Read more
source§

impl AddDualBound<ContinuousExpression> for Model

source§

fn add_dual_bound( &mut self, bound: ContinuousExpression, ) -> Result<(), ModelErr>

Adds a dual bound.

§Errors

If the expression is invalid, e.g., it uses not existing variables or the state of the transitioned state. If the cost type is integer.

§Examples
use dypdl::prelude::*;

let mut model = Model::continuous_cost_model();

assert!(model.add_dual_bound(ContinuousExpression::from(0.0)).is_ok());
source§

impl AddDualBound<IntegerExpression> for Model

source§

fn add_dual_bound(&mut self, bound: IntegerExpression) -> Result<(), ModelErr>

Adds a dual bound.

§Errors

If the expression is invalid, e.g., it uses not existing variables or the state of the transitioned state.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();

assert!(model.add_dual_bound(IntegerExpression::from(0)).is_ok());
source§

impl CheckExpression<ArgumentExpression> for Model

source§

fn check_expression( &self, expression: &ArgumentExpression, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<Condition> for Model

source§

fn check_expression( &self, condition: &Condition, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<ContinuousExpression> for Model

source§

fn check_expression( &self, expression: &ContinuousExpression, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<ContinuousVectorExpression> for Model

source§

fn check_expression( &self, expression: &ContinuousVectorExpression, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<ElementExpression> for Model

source§

fn check_expression( &self, expression: &ElementExpression, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<IntegerExpression> for Model

source§

fn check_expression( &self, expression: &IntegerExpression, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<IntegerVectorExpression> for Model

source§

fn check_expression( &self, expression: &IntegerVectorExpression, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<NumericTableExpression<f64>> for Model

source§

fn check_expression( &self, expression: &NumericTableExpression<Continuous>, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<NumericTableExpression<i32>> for Model

source§

fn check_expression( &self, expression: &NumericTableExpression<Integer>, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<SetExpression> for Model

source§

fn check_expression( &self, expression: &SetExpression, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<SetReduceExpression> for Model

source§

fn check_expression( &self, expression: &SetReduceExpression, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<TableExpression<FixedBitSet>> for Model

source§

fn check_expression( &self, expression: &TableExpression<Set>, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<TableExpression<Vec<usize>>> for Model

source§

fn check_expression( &self, expression: &TableExpression<Vector>, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<TableExpression<bool>> for Model

source§

fn check_expression( &self, expression: &TableExpression<bool>, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<TableExpression<usize>> for Model

source§

fn check_expression( &self, expression: &TableExpression<Element>, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<TableVectorExpression<f64>> for Model

source§

fn check_expression( &self, expression: &TableVectorExpression<Continuous>, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<TableVectorExpression<i32>> for Model

source§

fn check_expression( &self, expression: &TableVectorExpression<Integer>, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<VectorExpression> for Model

source§

fn check_expression( &self, expression: &VectorExpression, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl CheckExpression<VectorOrElementExpression> for Model

source§

fn check_expression( &self, expression: &VectorOrElementExpression, allow_cost: bool, ) -> Result<(), ModelErr>

Checks if an expression is valid. Read more
source§

impl Clone for Model

source§

fn clone(&self) -> Model

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Model

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Model

source§

fn default() -> Model

Returns the “default value” for a type. Read more
source§

impl GetObjectTypeOf<ElementResourceVariable> for Model

source§

fn get_object_type_of( &self, v: ElementResourceVariable, ) -> Result<ObjectType, ModelErr>

Returns the object type of the variable. Read more
source§

impl GetObjectTypeOf<ElementVariable> for Model

source§

fn get_object_type_of(&self, v: ElementVariable) -> Result<ObjectType, ModelErr>

Returns the object type of the variable. Read more
source§

impl GetObjectTypeOf<SetVariable> for Model

source§

fn get_object_type_of(&self, v: SetVariable) -> Result<ObjectType, ModelErr>

Returns the object type of the variable. Read more
source§

impl GetObjectTypeOf<VectorVariable> for Model

source§

fn get_object_type_of(&self, v: VectorVariable) -> Result<ObjectType, ModelErr>

Returns the object type of the variable. Read more
source§

impl PartialEq for Model

source§

fn eq(&self, other: &Model) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TableInterface<FixedBitSet> for Model

source§

fn add_table_1d<U>( &mut self, name: U, v: Vec<Set>, ) -> Result<Table1DHandle<Set>, ModelErr>
where String: From<U>,

Adds and returns a 1D table. Read more
source§

fn add_table_2d<U>( &mut self, name: U, v: Vec<Vec<Set>>, ) -> Result<Table2DHandle<Set>, ModelErr>
where String: From<U>,

Adds and returns a 2D table. Read more
source§

fn add_table_3d<U>( &mut self, name: U, v: Vec<Vec<Vec<Set>>>, ) -> Result<Table3DHandle<Set>, ModelErr>
where String: From<U>,

Adds and returns a 3D table. Read more
source§

fn add_table<U>( &mut self, name: U, map: FxHashMap<Vec<Element>, Set>, default: Set, ) -> Result<TableHandle<Set>, ModelErr>
where String: From<U>,

Adds and returns a 3D table. Read more
source§

impl TableInterface<Vec<usize>> for Model

source§

fn add_table_1d<U>( &mut self, name: U, v: Vec<Vector>, ) -> Result<Table1DHandle<Vector>, ModelErr>
where String: From<U>,

Adds and returns a 1D table. Read more
source§

fn add_table_2d<U>( &mut self, name: U, v: Vec<Vec<Vector>>, ) -> Result<Table2DHandle<Vector>, ModelErr>
where String: From<U>,

Adds and returns a 2D table. Read more
source§

fn add_table_3d<U>( &mut self, name: U, v: Vec<Vec<Vec<Vector>>>, ) -> Result<Table3DHandle<Vector>, ModelErr>
where String: From<U>,

Adds and returns a 3D table. Read more
source§

fn add_table<U>( &mut self, name: U, map: FxHashMap<Vec<Element>, Vector>, default: Vector, ) -> Result<TableHandle<Vector>, ModelErr>
where String: From<U>,

Adds and returns a 3D table. Read more
source§

impl TableInterface<bool> for Model

source§

fn add_table_1d<U>( &mut self, name: U, v: Vec<bool>, ) -> Result<Table1DHandle<bool>, ModelErr>
where String: From<U>,

Adds and returns a 1D table. Read more
source§

fn add_table_2d<U>( &mut self, name: U, v: Vec<Vec<bool>>, ) -> Result<Table2DHandle<bool>, ModelErr>
where String: From<U>,

Adds and returns a 2D table. Read more
source§

fn add_table_3d<U>( &mut self, name: U, v: Vec<Vec<Vec<bool>>>, ) -> Result<Table3DHandle<bool>, ModelErr>
where String: From<U>,

Adds and returns a 3D table. Read more
source§

fn add_table<U>( &mut self, name: U, map: FxHashMap<Vec<Element>, bool>, default: bool, ) -> Result<TableHandle<bool>, ModelErr>
where String: From<U>,

Adds and returns a 3D table. Read more
source§

impl TableInterface<f64> for Model

source§

fn add_table_1d<U>( &mut self, name: U, v: Vec<Continuous>, ) -> Result<Table1DHandle<Continuous>, ModelErr>
where String: From<U>,

Adds and returns a 1D table. Read more
source§

fn add_table_2d<U>( &mut self, name: U, v: Vec<Vec<Continuous>>, ) -> Result<Table2DHandle<Continuous>, ModelErr>
where String: From<U>,

Adds and returns a 2D table. Read more
source§

fn add_table_3d<U>( &mut self, name: U, v: Vec<Vec<Vec<Continuous>>>, ) -> Result<Table3DHandle<Continuous>, ModelErr>
where String: From<U>,

Adds and returns a 3D table. Read more
source§

fn add_table<U>( &mut self, name: U, map: FxHashMap<Vec<Element>, Continuous>, default: Continuous, ) -> Result<TableHandle<Continuous>, ModelErr>
where String: From<U>,

Adds and returns a 3D table. Read more
source§

impl TableInterface<i32> for Model

source§

fn add_table_1d<U>( &mut self, name: U, v: Vec<Integer>, ) -> Result<Table1DHandle<Integer>, ModelErr>
where String: From<U>,

Adds and returns a 1D table. Read more
source§

fn add_table_2d<U>( &mut self, name: U, v: Vec<Vec<Integer>>, ) -> Result<Table2DHandle<Integer>, ModelErr>
where String: From<U>,

Adds and returns a 2D table. Read more
source§

fn add_table_3d<U>( &mut self, name: U, v: Vec<Vec<Vec<Integer>>>, ) -> Result<Table3DHandle<Integer>, ModelErr>
where String: From<U>,

Adds and returns a 3D table. Read more
source§

fn add_table<U>( &mut self, name: U, map: FxHashMap<Vec<Element>, Integer>, default: Integer, ) -> Result<TableHandle<Integer>, ModelErr>
where String: From<U>,

Adds and returns a 3D table. Read more
source§

impl TableInterface<usize> for Model

source§

fn add_table_1d<U>( &mut self, name: U, v: Vec<Element>, ) -> Result<Table1DHandle<Element>, ModelErr>
where String: From<U>,

Adds and returns a 1D table. Read more
source§

fn add_table_2d<U>( &mut self, name: U, v: Vec<Vec<Element>>, ) -> Result<Table2DHandle<Element>, ModelErr>
where String: From<U>,

Adds and returns a 2D table. Read more
source§

fn add_table_3d<U>( &mut self, name: U, v: Vec<Vec<Vec<Element>>>, ) -> Result<Table3DHandle<Element>, ModelErr>
where String: From<U>,

Adds and returns a 3D table. Read more
source§

fn add_table<U>( &mut self, name: U, map: FxHashMap<Vec<Element>, Element>, default: Element, ) -> Result<TableHandle<Element>, ModelErr>
where String: From<U>,

Adds and returns a 3D table. Read more
source§

impl StructuralPartialEq for Model

Auto Trait Implementations§

§

impl Freeze for Model

§

impl RefUnwindSafe for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnwindSafe for Model

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.