Skip to main content

Module registry

Module registry 

Source
Expand description

Problem registry and metadata types.

This module provides types for problem introspection and discovery.

§Overview

§Example

use problemreductions::registry::{ProblemInfo, ComplexityClass};

// Create problem metadata
let info = ProblemInfo::new("Independent Set", "Find maximum non-adjacent vertices")
    .with_aliases(&["MIS", "Stable Set"])
    .with_complexity(ComplexityClass::NpComplete)
    .with_reduction_from("3-SAT");

assert!(info.is_np_complete());

§Implementing for Custom Problems

Problems can implement ProblemMetadata to provide introspection:

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

struct MyProblem;

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

let info = MyProblem::problem_info();
println!("Problem: {}", info.name);

Re-exports§

pub use problem_ref::parse_catalog_problem_ref;
pub use problem_ref::require_graph_variant;
pub use problem_ref::ProblemRef;
pub use problem_type::find_problem_type;
pub use problem_type::find_problem_type_by_alias;
pub use problem_type::problem_types;
pub use problem_type::ProblemType;
pub use variant::find_variant_by_alias;
pub use variant::find_variant_entry;
pub use variant::validate_create_inputs;
pub use variant::validate_direct_create_inputs;
pub use variant::validate_variant_aliases;
pub use variant::validate_variant_parameter_schemas;
pub use variant::variant_entries;
pub use variant::ConstructProblemFn;
pub use variant::ConstructionError;
pub use variant::CreateInputCodec;
pub use variant::CreateInputInfo;
pub use variant::CreateSpec;
pub use variant::RandomGenerate;
pub use variant::RandomRegistration;
pub use variant::VariantEntry;

Modules§

problem_ref
Typed internal problem references with catalog-validated variants.
problem_type
Problem type catalog: runtime lookup by name, alias, and variant validation.
variant
Explicit variant registration via inventory.

Structs§

FieldInfo
Description of a problem construction input for schema export.
FieldInfoJson
JSON-serializable field info.
LoadedDynProblem
A loaded type-erased problem.
ParseProblemCategoryError
Error returned when a catalog category is not one of the five supported values.
ProblemInfo
Metadata about a problem type.
ProblemSchemaEntry
A registered problem schema entry for static inventory registration.
ProblemSchemaJson
JSON-serializable problem schema.
VariantDimension
A declared variant dimension for a problem type.

Enums§

ComplexityClass
Computational complexity class of a problem.
ProblemCategory
Structural category used to organize problem implementations and catalog output.

Traits§

DynProblem
Type-erased problem interface for dynamic dispatch.
ProblemMetadata
Trait for problems that provide static metadata.

Functions§

collect_schemas
Collect all registered problem schemas into JSON-serializable form.
construct_dyn
Construct a problem from normalized construction inputs using the exact registered problem name and variant.
format_metric
Format a metric for CLI- and registry-facing dynamic dispatch.
load_dyn
Load a problem from JSON by exact problem name and exact variant map.
serialize_any
Serialize a &dyn Any by exact problem name and exact variant map.