Problem

Trait Problem 

Source
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§

Source

const NAME: &'static str

Base name of this problem type (e.g., “IndependentSet”).

Required Associated Types§

Source

type GraphType: GraphMarker

The graph type this problem operates on.

Source

type Weight: NumericWeight

The weight type for this problem.

Source

type Size: Clone + PartialOrd + Num + Zero + AddAssign

The type used for objective/size values.

Required Methods§

Source

fn num_variables(&self) -> usize

Returns the number of variables in the problem.

Source

fn num_flavors(&self) -> usize

Returns the number of possible values (flavors) for each variable. For binary problems, this is 2.

Source

fn problem_size(&self) -> ProblemSize

Returns metadata about the problem size.

Source

fn energy_mode(&self) -> EnergyMode

Returns whether larger or smaller objective values are better.

Source

fn solution_size(&self, config: &[usize]) -> SolutionSize<Self::Size>

Evaluate the solution size for a given configuration.

§Arguments
  • config - A slice of variable assignments, where each value is in 0..num_flavors.
§Returns

A SolutionSize containing the objective value and validity.

Provided Methods§

Source

fn variables(&self) -> Range<usize>

Returns the range of variable indices.

Source

fn flavors(&self) -> Vec<usize>

Returns the possible flavors as a vector.

Source

fn is_valid_config(&self, config: &[usize]) -> bool

Check if a configuration is valid for this problem.

Source

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.

Implementors§

Source§

impl Problem for Coloring

Source§

const NAME: &'static str = "Coloring"

Source§

type GraphType = SimpleGraph

Source§

type Weight = i32

Source§

type Size = i32

Source§

impl Problem for MaximalIS

Source§

const NAME: &'static str = "MaximalIS"

Source§

type GraphType = SimpleGraph

Source§

type Weight = i32

Source§

type Size = i32

Source§

impl Problem for ILP

Source§

impl Problem for BMF

Source§

impl Problem for BicliqueCover

Source§

const NAME: &'static str = "BicliqueCover"

Source§

type GraphType = SimpleGraph

Source§

type Weight = i32

Source§

type Size = i32

Source§

impl Problem for Factoring

Source§

const NAME: &'static str = "Factoring"

Source§

type GraphType = SimpleGraph

Source§

type Weight = i32

Source§

type Size = i32

Source§

impl Problem for PaintShop

Source§

const NAME: &'static str = "PaintShop"

Source§

type GraphType = SimpleGraph

Source§

type Weight = i32

Source§

type Size = i32

Source§

impl<C, G, W> Problem for GraphProblem<C, G, W>
where C: GraphConstraint, G: Graph, W: Clone + Default + PartialOrd + Num + Zero + AddAssign + 'static,

Source§

const NAME: &'static str = C::NAME

Source§

type GraphType = SimpleGraph

Source§

type Weight = W

Source§

type Size = W

Source§

impl<W> Problem for DominatingSet<W>
where W: Clone + Default + PartialOrd + Num + Zero + AddAssign + 'static,

Source§

const NAME: &'static str = "DominatingSet"

Source§

type GraphType = SimpleGraph

Source§

type Weight = W

Source§

type Size = W

Source§

impl<W> Problem for IndependentSet<W>
where W: Clone + Default + PartialOrd + Num + Zero + AddAssign + 'static,

Source§

const NAME: &'static str = "IndependentSet"

Source§

type GraphType = SimpleGraph

Source§

type Weight = W

Source§

type Size = W

Source§

impl<W> Problem for Matching<W>
where W: Clone + Default + PartialOrd + Num + Zero + AddAssign + 'static,

Source§

const NAME: &'static str = "Matching"

Source§

type GraphType = SimpleGraph

Source§

type Weight = W

Source§

type Size = W

Source§

impl<W> Problem for MaxCut<W>
where W: Clone + Default + PartialOrd + Num + Zero + AddAssign + 'static,

Source§

const NAME: &'static str = "MaxCut"

Source§

type GraphType = SimpleGraph

Source§

type Weight = W

Source§

type Size = W

Source§

impl<W> Problem for VertexCovering<W>
where W: Clone + Default + PartialOrd + Num + Zero + AddAssign + 'static,

Source§

const NAME: &'static str = "VertexCovering"

Source§

type GraphType = SimpleGraph

Source§

type Weight = W

Source§

type Size = W

Source§

impl<W> Problem for QUBO<W>
where W: Clone + Default + PartialOrd + Num + Zero + AddAssign + Mul<Output = W> + 'static,

Source§

const NAME: &'static str = "QUBO"

Source§

type GraphType = SimpleGraph

Source§

type Weight = W

Source§

type Size = W

Source§

impl<W> Problem for SpinGlass<W>
where W: Clone + Default + PartialOrd + Num + Zero + AddAssign + Mul<Output = W> + From<i32> + 'static,

Source§

const NAME: &'static str = "SpinGlass"

Source§

type GraphType = SimpleGraph

Source§

type Weight = W

Source§

type Size = W

Source§

impl<W> Problem for Satisfiability<W>
where W: Clone + Default + PartialOrd + Num + Zero + AddAssign + 'static,

Source§

const NAME: &'static str = "Satisfiability"

Source§

type GraphType = SimpleGraph

Source§

type Weight = W

Source§

type Size = W

Source§

impl<W> Problem for SetCovering<W>
where W: Clone + Default + PartialOrd + Num + Zero + AddAssign + 'static,

Source§

const NAME: &'static str = "SetCovering"

Source§

type GraphType = SimpleGraph

Source§

type Weight = W

Source§

type Size = W

Source§

impl<W> Problem for SetPacking<W>
where W: Clone + Default + PartialOrd + Num + Zero + AddAssign + 'static,

Source§

const NAME: &'static str = "SetPacking"

Source§

type GraphType = SimpleGraph

Source§

type Weight = W

Source§

type Size = W

Source§

impl<W> Problem for CircuitSAT<W>
where W: Clone + Default + PartialOrd + Num + Zero + AddAssign + 'static,

Source§

const NAME: &'static str = "CircuitSAT"

Source§

type GraphType = SimpleGraph

Source§

type Weight = W

Source§

type Size = W

Source§

impl<const K: usize, W> Problem for KSatisfiability<K, W>
where W: Clone + Default + PartialOrd + Num + Zero + AddAssign + 'static,

Source§

const NAME: &'static str = "KSatisfiability"

Source§

type GraphType = SimpleGraph

Source§

type Weight = W

Source§

type Size = W