Expand description
Problem registry and metadata types.
This module provides types for problem introspection and discovery.
§Overview
ProblemInfo- Rich metadata (name, description, complexity, reductions)ProblemMetadata- Trait for problems to provide their own metadataComplexityClass- Computational complexity classification
§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§
- Field
Info - Description of a problem construction input for schema export.
- Field
Info Json - JSON-serializable field info.
- Loaded
DynProblem - A loaded type-erased problem.
- Parse
Problem Category Error - Error returned when a catalog category is not one of the five supported values.
- Problem
Info - Metadata about a problem type.
- Problem
Schema Entry - A registered problem schema entry for static inventory registration.
- Problem
Schema Json - JSON-serializable problem schema.
- Variant
Dimension - A declared variant dimension for a problem type.
Enums§
- Complexity
Class - Computational complexity class of a problem.
- Problem
Category - Structural category used to organize problem implementations and catalog output.
Traits§
- DynProblem
- Type-erased problem interface for dynamic dispatch.
- Problem
Metadata - 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 Anyby exact problem name and exact variant map.