parallelized re

pull/87/head
Alessandro Bregoli 2 years ago
parent ff235b4b77
commit 5d676be180
  1. 3
      reCTBN/src/reward.rs
  2. 5
      reCTBN/src/reward/reward_evaluation.rs

@ -4,7 +4,6 @@ pub mod reward_evaluation;
use std::collections::HashMap;
use crate::process;
use ndarray;
/// Instantiation of reward function and instantaneous reward
///
@ -22,7 +21,7 @@ pub struct Reward {
/// The trait RewardFunction describe the methods that all the reward functions must satisfy
pub trait RewardFunction {
pub trait RewardFunction: Sync {
/// Given the current state and the previous state, it compute the reward.
///
/// # Arguments

@ -1,8 +1,11 @@
use std::collections::HashMap;
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
use crate::params::{self, ParamsTrait};
use crate::process;
use crate::{
process::NetworkProcessState,
reward::RewardEvaluation,
@ -55,7 +58,7 @@ impl RewardEvaluation for MonteCarloReward {
let n_states: usize = variables_domain.iter().map(|x| x.len()).product();
(0..n_states)
(0..n_states).into_par_iter()
.map(|s| {
let state: process::NetworkProcessState = variables_domain
.iter()

Loading…
Cancel
Save