1
0
mirror of https://github.com/ellmau/adf-obdd.git synced 2025-12-19 09:29:36 +01:00

fixed all warnings

Signed-off-by: Stefan Ellmauthaler <stefan.ellmauthaler@tu-dresden.de>
This commit is contained in:
Stefan Ellmauthaler 2021-06-30 10:17:39 +02:00
parent d4cbec0a76
commit ee1e1bd1bf
3 changed files with 13 additions and 15 deletions

View File

@ -1,7 +1,5 @@
use std::{ use std::{
collections::HashMap, collections::HashMap,
num::ParseFloatError,
ops::Deref,
str::{self, FromStr}, str::{self, FromStr},
}; };
@ -22,7 +20,8 @@ impl Statement {
} }
} }
pub fn add_ac(&mut self, ac: usize) {
pub fn _add_ac(&mut self, ac: usize) {
self.ac = Some(ac); self.ac = Some(ac);
} }
} }
@ -70,7 +69,8 @@ impl Adf {
/// This ac needs to be in the prefix notation for ADFs as defined by the DIAMOND implementation. /// This ac needs to be in the prefix notation for ADFs as defined by the DIAMOND implementation.
pub fn add_ac(&mut self, statement: &str, ac: &str) { pub fn add_ac(&mut self, statement: &str, ac: &str) {
if let Some(stmt) = self.dict.get(statement) { if let Some(stmt) = self.dict.get(statement) {
self.add_ac_by_number(*stmt, ac) let st = *stmt;
self.add_ac_by_number(st, ac)
} }
} }
@ -85,7 +85,7 @@ impl Adf {
pub fn grounded(&mut self) -> Vec<usize> { pub fn grounded(&mut self) -> Vec<usize> {
let mut interpretation: Vec<usize> = Vec::new(); let mut interpretation: Vec<usize> = Vec::new();
let mut change:bool = false; let mut change:bool;
for it in self.stmts.iter(){ for it in self.stmts.iter(){
interpretation.push((*it).ac.unwrap()) interpretation.push((*it).ac.unwrap())
@ -119,7 +119,7 @@ impl Adf {
fn setvarvalue(&mut self,interpretation:Vec<usize>, var:usize, val:bool) -> Option<Vec<usize>>{ fn setvarvalue(&mut self,interpretation:Vec<usize>, var:usize, val:bool) -> Option<Vec<usize>>{
let mut interpretation2:Vec<usize> = vec![0;interpretation.len()]; let mut interpretation2:Vec<usize> = vec![0;interpretation.len()];
let mut change: bool = false; let mut change: bool = false;
for (pos,it) in interpretation.iter().enumerate(){ for (pos,_it) in interpretation.iter().enumerate(){
interpretation2[pos] = self.bdd.restrict(interpretation[pos], var, val); interpretation2[pos] = self.bdd.restrict(interpretation[pos], var, val);
if interpretation[pos] != interpretation2[pos]{ if interpretation[pos] != interpretation2[pos]{
change = true change = true

View File

@ -1,4 +1,3 @@
use std::borrow::Borrow;
use std::{env, process::exit}; use std::{env, process::exit};
use std::fs::File; use std::fs::File;
use std::io::{self, BufRead}; use std::io::{self, BufRead};
@ -37,13 +36,13 @@ fn main() {
println!("parsed {} statements", statements.len()); println!("parsed {} statements", statements.len());
if statements.len() > 0 && ac.len() > 0 { if statements.len() > 0 && ac.len() > 0 {
let mut myAdf = Adf::new(); let mut my_adf = Adf::new();
myAdf.init_statements(statements.iter().map(AsRef::as_ref).collect()); my_adf.init_statements(statements.iter().map(AsRef::as_ref).collect());
for (s,c) in ac { for (s,c) in ac {
myAdf.add_ac(s.as_str(), c.as_str()); my_adf.add_ac(s.as_str(), c.as_str());
} }
let result = myAdf.grounded(); let result = my_adf.grounded();
println!("{:?}",result); println!("{:?}",result);
for (p,s) in statements.iter().enumerate(){ for (p,s) in statements.iter().enumerate(){
match result[p] { match result[p] {

View File

@ -143,13 +143,13 @@ impl Bdd {
self.if_then_else(terma, BDD_TOP, termb) self.if_then_else(terma, BDD_TOP, termb)
} }
fn printtree(&self, tree: Term) { fn _printtree(&self, tree: Term) {
let node = self.nodes[tree]; let node = self.nodes[tree];
println!("Index: {}, Node: {}", tree, node); println!("Index: {}, Node: {}", tree, node);
if tree > BDD_TOP { if tree > BDD_TOP {
self.printtree(node.lo); self._printtree(node.lo);
self.printtree(node.hi); self._printtree(node.hi);
} }
} }
} }
@ -238,7 +238,6 @@ mod test {
let b = bdd.or(v2, v1); let b = bdd.or(v2, v1);
let con1 = bdd.and(a, conj); let con1 = bdd.and(a, conj);
let con2 = bdd.and(v1, v3);
let end = bdd.or(con1, b); let end = bdd.or(con1, b);
let x = bdd.restrict(end, 1, false); let x = bdd.restrict(end, 1, false);