pub trait ConstraintSatisfactionProblem: Problem {
// Required methods
fn constraints(&self) -> Vec<LocalConstraint>;
fn objectives(&self) -> Vec<LocalSolutionSize<Self::Size>>;
fn weights(&self) -> Vec<Self::Size>;
fn set_weights(&mut self, weights: Vec<Self::Size>);
fn is_weighted(&self) -> bool;
// Provided methods
fn is_satisfied(&self, config: &[usize]) -> bool { ... }
fn compute_objective(&self, config: &[usize]) -> Self::Size { ... }
}Expand description
Trait for constraint satisfaction problems.
These problems have explicit constraints that must be satisfied, and objectives that contribute to the solution size.
Required Methods§
Sourcefn constraints(&self) -> Vec<LocalConstraint>
fn constraints(&self) -> Vec<LocalConstraint>
Returns the hard constraints that must be satisfied.
Sourcefn objectives(&self) -> Vec<LocalSolutionSize<Self::Size>>
fn objectives(&self) -> Vec<LocalSolutionSize<Self::Size>>
Returns the local objectives that contribute to solution size.
Sourcefn weights(&self) -> Vec<Self::Size>
fn weights(&self) -> Vec<Self::Size>
Returns the weights for the problem (e.g., vertex weights).
Sourcefn set_weights(&mut self, weights: Vec<Self::Size>)
fn set_weights(&mut self, weights: Vec<Self::Size>)
Set new weights for the problem.
Sourcefn is_weighted(&self) -> bool
fn is_weighted(&self) -> bool
Returns whether the problem has non-uniform weights.
Provided Methods§
Sourcefn is_satisfied(&self, config: &[usize]) -> bool
fn is_satisfied(&self, config: &[usize]) -> bool
Check if all constraints are satisfied by a configuration.
Sourcefn compute_objective(&self, config: &[usize]) -> Self::Size
fn compute_objective(&self, config: &[usize]) -> Self::Size
Compute the total objective value from all local objectives.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.