-
Notifications
You must be signed in to change notification settings - Fork 9
Exponential search / Reasoning horizon #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
8a93aae
c3cd965
f70de50
1cf0b8c
29efb58
127d2a9
a20b44a
cdc6d11
66fd804
9ebe416
5f7d495
53e5203
c0757df
920c499
f892b6e
3088960
9d798de
8c23cf0
fa39d57
992b02b
ab2ef8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| use crate::unicorn::{Node, Model}; | ||
| use log::warn; | ||
|
|
||
| // | ||
| // Public Interface | ||
| // | ||
|
|
||
| pub fn print_reasoning_horizon(model: &mut Model, depth: usize, stride: bool) { | ||
| let v: Option<String>; | ||
| v = match &*model.bad_states_initial[0].borrow() { | ||
| Node::Bad { name, ..} => name.clone(), | ||
| _ => None | ||
| }; | ||
|
|
||
| let ss = v.as_ref().expect("Bad state must have an unrolling depth"); | ||
| if let (Some(start), Some(end)) = (ss.find("[n="), ss.find("]")) { | ||
| if let (reason, Ok(remainder)) = (ss[..start].to_string(), ss[start+"[n=".len()..end].to_string().parse::<usize>()) { | ||
| warn!( | ||
| "(Initial) Bad state '{}[n={:#?}]' is satisfiable.", | ||
| reason, | ||
| if stride { (depth - 1) + remainder } else { remainder } | ||
| ); | ||
| } | ||
|
|
||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,11 +24,12 @@ pub mod qubot; | |
| pub mod sat_solver; | ||
| pub mod smt_solver; | ||
| pub mod unroller; | ||
| pub mod horizon; | ||
|
|
||
| pub type Nid = u64; | ||
| pub type NodeRef = Rc<RefCell<Node>>; | ||
|
|
||
| #[derive(Debug)] | ||
| #[derive(Clone,Debug)] | ||
|
||
| pub enum Node { | ||
| Const { | ||
| nid: Nid, | ||
|
|
@@ -176,7 +177,7 @@ pub fn get_nodetype(n: usize) -> NodeType { | |
| } | ||
| } | ||
|
|
||
| #[derive(Debug)] | ||
| #[derive(Clone, Debug)] | ||
| pub struct Model { | ||
| pub lines: Vec<NodeRef>, | ||
| pub sequentials: Vec<NodeRef>, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second parameter to
unroll_model(i.e. them) is only used to construct the names of bad-state nodes and input nodes in the current unrolling step. Would it make the algorithm simpler if we were to pass the correct absolute depth at this point already? I think this could makeprint_reasoning_horizonsimpler.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good pointer, thanks.
I adapted the implementation accordingly and
print_reasoning_horizondid simplify significantly (as expected).