Skip to content

Commit 80ea5a4

Browse files
committed
reduced verbosity
1 parent 1dc6aab commit 80ea5a4

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

src/semigroup.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rayon::prelude::*;
1010
use std::collections::HashSet; // for distinct method
1111
use std::collections::VecDeque;
1212
use std::fmt;
13+
use std::io::{self, Write};
1314

1415
pub struct FlowSemigroup {
1516
//invariant: all flows have the same dimension
@@ -60,10 +61,10 @@ impl FlowSemigroup {
6061
///non-deterministic product
6162
fn get_products(left: &Flow, right: &Flow, maximal_finite_coordinate: u16) -> HashSet<Flow> {
6263
debug_assert_eq!(left.nb_rows, right.nb_rows);
63-
debug!("get_products\nleft\n{}\nright\n{}", left, right);
64+
//debug!("get_products\nleft\n{}\nright\n{}", left, right);
6465
let dim = left.nb_rows;
6566
let omega_part = Flow::get_omega_entries(left, right);
66-
debug!("omega part\n{}\n", omega_part);
67+
//debug!("omega part\n{}\n", omega_part);
6768
let left = &mut left.clone();
6869
let right = &mut right.clone();
6970

@@ -90,10 +91,10 @@ impl FlowSemigroup {
9091
flow_accumulator: &mut HashSet<Flow>,
9192
) {
9293
debug_assert!(k < dim);
93-
debug!(
94+
/*debug!(
9495
"k={}\nleft\n{}\nright\n{}\ncurrent_flow\n{}\n\n",
9596
k, left, right, current_flow
96-
);
97+
);*/
9798
let left_edges = left.edges_to(k);
9899
let right_edges = right.edges_from(k);
99100
debug_assert!(k < dim);
@@ -122,17 +123,19 @@ impl FlowSemigroup {
122123
//todo compute left stuff once at a time with a single into_iter
123124
let left_coefs = left_edges.iter().map(|&(_, c)| c).collect::<Vec<_>>();
124125
let right_coefs = right_edges.iter().map(|&(_, c)| c).collect::<Vec<_>>();
126+
/*
125127
debug!(
126128
"left_coefs\n\t{:?}\nright_coefs\n\t{:?}\n",
127129
left_coefs, right_coefs
128-
);
130+
);*/
129131
let left_indices = left_edges.into_iter().map(|(i, _)| i).collect::<Vec<_>>();
130132
//todo compute right stuff once at a time with a single into_iter
131133
let right_indices = right_edges.into_iter().map(|(j, _)| j).collect::<Vec<_>>();
134+
/*
132135
debug!(
133136
"left_indices\n\t{:?}\nright_indices\n\t{:?}\n",
134137
left_indices, right_indices
135-
);
138+
);*/
136139
let all_indices = left_indices
137140
.iter()
138141
.enumerate()
@@ -147,8 +150,8 @@ impl FlowSemigroup {
147150
let mut left = left.clone();
148151
let mut right = right.clone();
149152
let mut current_flow = current_flow.clone();
150-
debug!("k={}\ntransport\n{}\n", k, t);
151-
debug!("current_flow before\n{}\n", current_flow);
153+
//debug!("k={}\ntransport\n{}\n", k, t);
154+
//debug!("current_flow before\n{}\n", current_flow);
152155
for ((subi, reali), (subj, realj)) in &all_indices {
153156
let cf = current_flow.get(reali, realj);
154157
let tij: Coef = t.get(&subi, &subj);
@@ -165,7 +168,7 @@ impl FlowSemigroup {
165168
right.set(&k, realj, cr - tij);
166169
}
167170
}
168-
debug!("current_flow after\n{}\n", current_flow);
171+
//debug!("current_flow after\n{}\n", current_flow);
169172
let k1 = k + 1;
170173
if k1 >= dim {
171174
flow_accumulator.insert(current_flow);
@@ -194,12 +197,14 @@ impl FlowSemigroup {
194197
let mut processed = HashSet::<Flow>::new();
195198
while !to_process.is_empty() {
196199
let flow = to_process.pop_front().unwrap();
200+
print!(".");
201+
io::stdout().flush().unwrap();
197202
debug!(
198203
"\nClose_by_product_and_iteration processing flow\n{}\n",
199204
flow
200205
);
201206
if Self::is_covered(&flow, &processed) {
202-
debug!("Skipped inqueue\n{}", flow);
207+
//debug!("Skipped inqueue\n{}", flow);
203208
continue;
204209
}
205210
processed.insert(flow.clone());
@@ -210,7 +215,7 @@ impl FlowSemigroup {
210215
self.flows.insert(iteration.clone());
211216
to_process.push_back(iteration);
212217
} else {
213-
debug!("\n\nSkipped iteration\n{}", iteration);
218+
//debug!("\n\nSkipped iteration\n{}", iteration);
214219
}
215220
{
216221
let right_products = self

src/solver.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,27 @@ pub fn solve(nfa: &nfa::Nfa) -> Solution {
3434
);
3535
step += 1;
3636
let action_flows = compute_action_flows(&strategy, &edges);
37-
print!("\nAction flows:\n{}", flows_to_string(&action_flows));
37+
debug!("\nAction flows:\n{}", flows_to_string(&action_flows));
38+
println!("Computing semigroup");
3839
let semigroup = semigroup::FlowSemigroup::compute(&action_flows, dim as u16);
39-
print!("Semigroup:\n{}", semigroup);
40+
debug!("Semigroup:\n{}", semigroup);
41+
println!("Computing winning ideal");
4042
let mut winning_ideal = semigroup.get_path_problem_solution(&final_states);
4143
winning_ideal.insert(&final_ideal);
4244
//non-omega stay below dim
4345
let dim16: u16 = dim.try_into().unwrap();
44-
print!(
46+
debug!(
4547
"Winning ideal for the path problem before rounding down\n{}",
4648
winning_ideal
4749
);
4850
winning_ideal.round_down(dim16, dim); //backed by the small constants theorem
49-
print!(
51+
debug!(
5052
"Winning ideal for the path problem before minimize\n{}",
5153
winning_ideal
5254
);
5355
winning_ideal.minimize();
5456
debug!("Winning ideal for the path problem:\n{}", winning_ideal);
57+
println!("Restricting strategy");
5558
let changed = strategy.restrict_to(winning_ideal, &edges);
5659
debug!("Strategy after restriction:\n{}", strategy);
5760
if !changed {

src/strategy.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::graph::Graph;
33
use crate::ideal::Ideal;
44
use crate::nfa;
55
use crate::sheep::Sheep;
6+
use std::io::{self, Write};
67

78
use std::collections::HashMap;
89
use std::fmt;
@@ -35,6 +36,8 @@ impl Strategy {
3536
) -> bool {
3637
let mut result = false;
3738
for (a, ideal) in self.0.iter_mut() {
39+
print!(".");
40+
io::stdout().flush().unwrap();
3841
let edges = edges_per_letter.get(a).unwrap();
3942
let very_safe = safe.safe_pre_image(edges);
4043
result |= ideal.restrict_to(&very_safe);

0 commit comments

Comments
 (0)