Commit e7ec69c7 authored by Bharat Garhewal's avatar Bharat Garhewal
Browse files

More cleanup

parent c9260906
Pipeline #60787 passed with stages
in 6 minutes and 31 seconds
......@@ -90,7 +90,7 @@ pub fn learn_fsm<S: ::std::hash::BuildHasher + Default>(
0,
0,
rev_input_map.clone(),
rev_output_map.clone(),
rev_output_map,
);
let mut iads_oracle = IadsEO::new(Rc::clone(&oq_oracle), options.extra_states, rng.gen());
let mut seq_oracle = SequenceOracle::new(Rc::clone(&oq_oracle), 10, rng.gen());
......
......@@ -31,7 +31,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
)))
.build(format!("log/{}.log", chrono::Utc::now()))?;
let matches = cli::parse().unwrap();
let matches = cli::parse()?;
let rule2_mode = match matches.value_of("rule2").unwrap() {
"none" => Rule2::Nothing,
"ads" => Rule2::Ads,
......
......@@ -21,19 +21,14 @@ pub struct External<S> {
impl<S: std::hash::BuildHasher + std::default::Default> External<S> {
#[must_use]
pub fn new(
fsm: Arc<Mealy>,
input_map: &HashMap<String, InputSymbol, S>,
output_map: &HashMap<String, OutputSymbol, S>,
) -> Self {
pub fn new(fsm: Arc<Mealy>, input_map: &HashMap<String, InputSymbol, S>) -> Self {
let i_m = input_map.iter().map(|(s, i)| (s.clone(), *i)).collect();
let o_m = output_map.iter().map(|(s, o)| (s.clone(), *o)).collect();
Self {
fsm,
cnt_inputs: 0,
cnt_resets: 0,
input_map: i_m,
output_map: o_m,
output_map: BiHashMap::default(),
}
}
}
......@@ -43,7 +38,9 @@ impl<S: std::hash::BuildHasher> SystemUnderLearning for External<S> {
let i_s = input_seq
.iter()
.map(|i| self.input_map.get_by_right(i).expect("Safe"))
.cloned()
.collect_vec();
let word: String = Itertools::intersperse(i_s.into_iter(), String::from(" ")).collect();
let (_dest, out_seq) = self.fsm.trace_from(State::new(0), input_seq);
self.cnt_inputs += input_seq.len();
log::trace!(" {:?} / {:?}", input_seq, out_seq);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment