pub trait Problem: Clone {
type GraphType: GraphMarker;
type Weight: NumericWeight;
type Size: Clone + PartialOrd + Num + Zero + AddAssign;
const NAME: &'static str;
// Required methods
fn num_variables(&self) -> usize;
fn num_flavors(&self) -> usize;
fn problem_size(&self) -> ProblemSize;
fn energy_mode(&self) -> EnergyMode;
fn solution_size(&self, config: &[usize]) -> SolutionSize<Self::Size>;
// Provided methods
fn variables(&self) -> Range<usize> { ... }
fn flavors(&self) -> Vec<usize> { ... }
fn is_valid_config(&self, config: &[usize]) -> bool { ... }
fn solution_size_multiple(
&self,
configs: &[Vec<usize>],
) -> Vec<SolutionSize<Self::Size>> { ... }
}Expand description
The core trait that all problems must implement.
This trait defines the interface for computational problems that can be solved by enumeration or reduction to other problems.
Required Associated Constants§
Required Associated Types§
Sourcetype GraphType: GraphMarker
type GraphType: GraphMarker
The graph type this problem operates on.
Sourcetype Weight: NumericWeight
type Weight: NumericWeight
The weight type for this problem.
Required Methods§
Sourcefn num_variables(&self) -> usize
fn num_variables(&self) -> usize
Returns the number of variables in the problem.
Sourcefn num_flavors(&self) -> usize
fn num_flavors(&self) -> usize
Returns the number of possible values (flavors) for each variable. For binary problems, this is 2.
Sourcefn problem_size(&self) -> ProblemSize
fn problem_size(&self) -> ProblemSize
Returns metadata about the problem size.
Sourcefn energy_mode(&self) -> EnergyMode
fn energy_mode(&self) -> EnergyMode
Returns whether larger or smaller objective values are better.
Sourcefn solution_size(&self, config: &[usize]) -> SolutionSize<Self::Size>
fn solution_size(&self, config: &[usize]) -> SolutionSize<Self::Size>
Provided Methods§
Sourcefn is_valid_config(&self, config: &[usize]) -> bool
fn is_valid_config(&self, config: &[usize]) -> bool
Check if a configuration is valid for this problem.
Sourcefn solution_size_multiple(
&self,
configs: &[Vec<usize>],
) -> Vec<SolutionSize<Self::Size>>
fn solution_size_multiple( &self, configs: &[Vec<usize>], ) -> Vec<SolutionSize<Self::Size>>
Evaluate multiple configurations at once (batch evaluation).
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.