Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8a93aae
add: File horizon that implements the horizon extraction when the str…
danielkocher Jan 9, 2023
c3cd965
add: Stride option
danielkocher Jan 9, 2023
f70de50
feat: Exponential search when the stride option is enabled (up to a m…
danielkocher Jan 9, 2023
1cf0b8c
fix: Remove Clone from Node type
danielkocher Jan 12, 2023
29efb58
fix: Use absolute depth during unrolling and simplify print_reasoning…
danielkocher Jan 12, 2023
127d2a9
feat: adds --one-query flag
Jan 20, 2023
a20b44a
feat: --one-query flag implemented for sat solvers
Jan 20, 2023
cdc6d11
fix: tiny fix sat_solvers
Jan 20, 2023
66fd804
feat: --one-query implemented for smt solvers
Jan 20, 2023
9ebe416
fix: add Node::or handle for smt solvers
Jan 20, 2023
5f7d495
fix: Node::Bad is now reachable in solvers
Jan 20, 2023
53e5203
fix: --one-query does not checks on bad states sequential
smml1996 Jan 22, 2023
c0757df
refactor: cargo fmt
smml1996 Jan 22, 2023
920c499
chore: add assertion for minimize when --one-query flag is used
smml1996 Jan 22, 2023
f892b6e
chore: Merge feat-one-query into feat/exp-search WIP
danielkocher Jan 23, 2023
3088960
chore: Resolve merge conflict
danielkocher Jan 23, 2023
9d798de
chore: Resolve merge conflict
danielkocher Jan 24, 2023
8c23cf0
chore: Resolve merge conflict
danielkocher Jan 24, 2023
fa39d57
feat: Draft of reasoning horizon for a give time budget in ms (exp. s…
danielkocher Jan 24, 2023
992b02b
fix: Quick fix that respect the stride option when the SMT solver is …
danielkocher Jan 24, 2023
ab2ef8f
iter: Fix reasoning horizon functionality (deal with updated order of…
danielkocher Mar 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Use absolute depth during unrolling and simplify print_reasoning…
…_horizon
  • Loading branch information
danielkocher committed Jan 12, 2023
commit 29efb58c0992f6ddc47da77956c3db21ce1c65f8
12 changes: 7 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,16 @@ fn main() -> Result<()> {

let timeout = solver_timeout.map(|&ms| Duration::from_millis(ms));

let mut n: usize = if stride { 1 } else { unroll_depth };
let mut n: usize = if stride { 0 } else { unroll_depth };
let mut prev_n: usize = 0;
loop {
// TODO: Maybe we can get rid of this clone for each
// iteration, which is basically required if pruning is
// enabled. However, it is much faster this way than
// without pruning and not cloning the model.
let mut model_copy = model.clone();

for m in 0..n {
for m in prev_n..n {
unroll_model(&mut model_copy, m);
Copy link
Collaborator

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. the m) 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 make print_reasoning_horizon simpler.

Copy link
Collaborator Author

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_horizon did simplify significantly (as expected).


if has_concrete_inputs {
Expand All @@ -135,7 +136,7 @@ fn main() -> Result<()> {
}

if prune {
prune_model(&mut model_copy);
prune_model(&mut model_copy);
}

match smt_solver {
Expand All @@ -157,13 +158,14 @@ fn main() -> Result<()> {

if !stride || !model_copy.bad_states_initial.is_empty() {
if !model_copy.bad_states_initial.is_empty() {
print_reasoning_horizon(&mut model_copy, n, stride);
print_reasoning_horizon(&mut model_copy);
}

break;
}

n = min(2 * n, unroll_depth);
prev_n = n;
n = min(2*n, unroll_depth);
}

if renumber {
Expand Down
15 changes: 3 additions & 12 deletions src/unicorn/horizon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,13 @@ use log::warn;
// Public Interface
//

pub fn print_reasoning_horizon(model: &mut Model, depth: usize, stride: bool) {
pub fn print_reasoning_horizon(model: &mut Model) {
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 }
);
}

}
let bad_state = v.as_ref().expect("Bad state must have an unrolling depth");
warn!("(Initial) Bad state '{}' is satisfiable.", bad_state);
}