ProblemMetadata

Trait ProblemMetadata 

Source
pub trait ProblemMetadata {
    // Required methods
    fn problem_info() -> ProblemInfo;
    fn category() -> ProblemCategory;
}
Expand description

Trait for problems that provide static metadata.

Implement this trait to enable introspection and discovery for problem types. The GraphProblem template automatically implements this trait based on the constraint type.

§Example

use problemreductions::registry::{ProblemMetadata, ProblemInfo, ProblemCategory};
use problemreductions::models::graph::IndependentSetT;
use problemreductions::topology::SimpleGraph;

// Get problem metadata
let info = IndependentSetT::<SimpleGraph, i32>::problem_info();
assert_eq!(info.name, "Independent Set");

let category = IndependentSetT::<SimpleGraph, i32>::category();
assert_eq!(category.path(), "graph/independent");

§Implementing for Custom Problems

use problemreductions::registry::{
    ProblemMetadata, ProblemInfo, ProblemCategory,
    GraphSubcategory, ComplexityClass
};

struct MyProblem;

impl ProblemMetadata for MyProblem {
    fn problem_info() -> ProblemInfo {
        ProblemInfo::new("My Problem", "Description of my problem")
            .with_complexity(ComplexityClass::NpComplete)
    }

    fn category() -> ProblemCategory {
        ProblemCategory::Graph(GraphSubcategory::Independent)
    }
}

Required Methods§

Source

fn problem_info() -> ProblemInfo

Returns the problem info for this problem type.

This includes the problem name, description, aliases, complexity class, and known reductions.

Source

fn category() -> ProblemCategory

Returns the problem category.

This is a hierarchical classification like “graph/independent” or “satisfiability/sat”.

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<C, G, W> ProblemMetadata for GraphProblem<C, G, W>
where C: GraphConstraint, G: Graph, W: Clone + Default,