Crates.io | dypdl-heuristic-search |
lib.rs | dypdl-heuristic-search |
version | 0.8.0 |
source | src |
created_at | 2023-02-20 21:16:50.507654 |
updated_at | 2024-06-07 19:12:32.237431 |
description | Heuristic search solvers for Dynamic Programming Description Language (DyPDL). |
homepage | https://didp.ai |
repository | https://github.com/domain-independent-dp/didp-rs |
max_upload_size | |
id | 790160 |
size | 1,081,937 |
dypdl-heuristic-search is a library of heuristic search solvers for DyPDL.
use dypdl::prelude::*;
use dypdl_heuristic_search::{CabsParameters, create_dual_bound_cabs, FEvaluatorType};
use std::rc::Rc;
let mut model = Model::default();
let variable = model.add_integer_variable("variable", 0).unwrap();
model.add_base_case(
vec![Condition::comparison_i(ComparisonOperator::Ge, variable, 1)]
).unwrap();
let mut increment = Transition::new("increment");
increment.set_cost(IntegerExpression::Cost + 1);
increment.add_effect(variable, variable + 1).unwrap();
model.add_forward_transition(increment.clone()).unwrap();
model.add_dual_bound(IntegerExpression::from(0)).unwrap();
let model = Rc::new(model);
let parameters = CabsParameters::default();
let f_evaluator_type = FEvaluatorType::Plus;
let mut solver = create_dual_bound_cabs(model, parameters, f_evaluator_type);
let solution = solver.search().unwrap();
assert_eq!(solution.cost, Some(1));
assert_eq!(solution.transitions, vec![increment]);
assert!(!solution.is_infeasible);