Browse Source

Made main actually attempt to MAXSAT

master
Cameron Weinfurt 3 years ago
parent
commit
1a7fe70dc2
  1. 13
      src/clause.rs
  2. 9
      src/main.rs

13
src/clause.rs

@ -264,12 +264,12 @@ impl core::ops::IndexMut<usize> for Clause {
impl Display for Clause {
fn fmt(&self, fmt: &mut Formatter) -> core::fmt::Result {
if self.literals.len() == 0 {
write!(fmt, "")
write!(fmt, "NULL")
} else {
let mut iter = self.literals.iter();
write!(fmt, "{}", iter.next().unwrap())?;
for lit in iter {
write!(fmt, " {}", lit)?;
write!(fmt, " V {}", lit)?;
}
Ok(())
}
@ -375,6 +375,15 @@ impl core::ops::IndexMut<usize> for ClauseList {
}
}
impl Display for ClauseList {
fn fmt(&self, fmt: &mut Formatter) -> core::fmt::Result {
for clause in self.iter() {
write!(fmt, "{}\n", clause);
}
Ok(())
}
}
/// Defines a DSL which allows for the declaration of many variables at once. See the unit tests
/// for examples.
#[macro_export]

9
src/main.rs

@ -8,5 +8,12 @@ pub mod hash_wrapper;
mod messy_minsat;
mod maxsat;
mod clause_gen;
use crate::clause_gen::*;
use crate::maxsat::*;
fn main() {}
fn main() {
let rand_clause_list = gen_clause_list(5, 5);
println!("{}", rand_clause_list);
println!("MAXSAT (By BFS): {}", solve_by_bfs(&rand_clause_list));
}
Loading…
Cancel
Save