From dece879b279cbae6440aaf898a9f051ee11d9912 Mon Sep 17 00:00:00 2001 From: Stefan Ellmauthaler Date: Tue, 21 Jun 2022 16:10:26 +0200 Subject: [PATCH] Add missing heuristics module to git --- lib/src/adf/heuristics.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/src/adf/heuristics.rs diff --git a/lib/src/adf/heuristics.rs b/lib/src/adf/heuristics.rs new file mode 100644 index 0000000..301dc3d --- /dev/null +++ b/lib/src/adf/heuristics.rs @@ -0,0 +1,34 @@ +/*! +This module contains all the crate-wide defined heuristic functions. +In addition there is the public enum [Heuristic], which allows to set a heuristic function with the public API. + */ +use super::Adf; +use crate::datatypes::{Term, Var}; + +pub(crate) fn heu_simple(_adf: &Adf, interpr: &[Term]) -> Option<(Var, Term)> { + for (idx, term) in interpr.iter().enumerate() { + if !term.is_truth_value() { + return Some((Var(idx), Term::TOP)); + } + } + None +} + +type RetVal = Option<(Var, Term)>; + +/// Enumeration of all currently implemented heuristics. +/// It represents a public view on the crate-view implementations of heuristics. +#[derive(Debug, Clone, Copy)] +pub enum Heuristic { + /// Implementation of a simple heuristic. + /// This will just take the first not decided variable and maps it value to (`true`)[Term::TOP]. + Simple, +} + +impl Heuristic { + pub(crate) fn get_heuristic(&self) -> Box RetVal> { + match self { + Heuristic::Simple => Box::new(heu_simple), + } + } +}