|
|
@ -1,5 +1,5 @@ |
|
|
|
use crate::{ |
|
|
|
use crate::{ |
|
|
|
network::{Network}, |
|
|
|
network::Network, |
|
|
|
params::{self, ParamsTrait}, |
|
|
|
params::{self, ParamsTrait}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
use rand::SeedableRng; |
|
|
|
use rand::SeedableRng; |
|
|
@ -65,32 +65,35 @@ impl<'a, T: Network> Iterator for ForwardSampler<'a, T> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let next_node_transition = self.next_transitions |
|
|
|
let next_node_transition = self |
|
|
|
|
|
|
|
.next_transitions |
|
|
|
.iter() |
|
|
|
.iter() |
|
|
|
.enumerate() |
|
|
|
.enumerate() |
|
|
|
.min_by(|x, y| x.1.unwrap().partial_cmp(&y.1.unwrap()).unwrap()) |
|
|
|
.min_by(|x, y| x.1.unwrap().partial_cmp(&y.1.unwrap()).unwrap()) |
|
|
|
.unwrap() |
|
|
|
.unwrap() |
|
|
|
.0; |
|
|
|
.0; |
|
|
|
|
|
|
|
|
|
|
|
self.current_time = self.next_transitions[next_node_transition].unwrap().clone(); |
|
|
|
self.current_time = self.next_transitions[next_node_transition].unwrap().clone(); |
|
|
|
|
|
|
|
|
|
|
|
self.current_state[next_node_transition] = self.net |
|
|
|
self.current_state[next_node_transition] = self |
|
|
|
|
|
|
|
.net |
|
|
|
.get_node(next_node_transition) |
|
|
|
.get_node(next_node_transition) |
|
|
|
.get_random_state( |
|
|
|
.get_random_state( |
|
|
|
self.net.get_node(next_node_transition) |
|
|
|
self.net |
|
|
|
|
|
|
|
.get_node(next_node_transition) |
|
|
|
.state_to_index(&self.current_state[next_node_transition]), |
|
|
|
.state_to_index(&self.current_state[next_node_transition]), |
|
|
|
self.net.get_param_index_network(next_node_transition, &self.current_state), |
|
|
|
self.net |
|
|
|
|
|
|
|
.get_param_index_network(next_node_transition, &self.current_state), |
|
|
|
&mut self.rng, |
|
|
|
&mut self.rng, |
|
|
|
) |
|
|
|
) |
|
|
|
.unwrap(); |
|
|
|
.unwrap(); |
|
|
|
|
|
|
|
|
|
|
|
self.next_transitions[next_node_transition] = None; |
|
|
|
self.next_transitions[next_node_transition] = None; |
|
|
|
|
|
|
|
|
|
|
|
for child in self.net.get_children_set(next_node_transition) { |
|
|
|
for child in self.net.get_children_set(next_node_transition) { |
|
|
|
self.next_transitions[child] = None; |
|
|
|
self.next_transitions[child] = None; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Some((ret_time, ret_state)) |
|
|
|
Some((ret_time, ret_state)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|