pub struct Formula {
pub clauses: Vec<Clause>,
pub literals: Vec<i32>,
pub num_clauses: i32,
pub num_vars: i32,
}
Expand description
Fields§
§clauses: Vec<Clause>
§literals: Vec<i32>
§num_clauses: i32
§num_vars: i32
Implementations§
source§impl Formula
impl Formula
sourcepub fn evaluate(&mut self, interpretation: &HashMap<i32, bool>) -> bool
pub fn evaluate(&mut self, interpretation: &HashMap<i32, bool>) -> bool
Evaluates a Formula
given an interpretation
Arguments
Examples
Assuming the CNF file is in /bin/problem.cnf
and contains the following:
p cnf 3 1
1 -3 0
2 3 -1 0
use sat_rs::cnfparser;
use std::collections::HashMap;
let buffer = include_str!("bin/problem.cnf");
let mut formula = cnfparser::parse_cnf(&buffer);
let mut interpretation: HashMap<i32, bool> = HashMap::new();
interpretation.insert(1, false);
interpretation.insert(2, false);
interpretation.insert(3, false);
assert_eq!(formula.unwrap().evaluate(&interpretation), true);
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Formula
impl Send for Formula
impl Sync for Formula
impl Unpin for Formula
impl UnwindSafe for Formula
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more