/** * Adds a new CPD to the transition model. * @param factor * A factor that represents the conditional probability distribution. * The arguments of this factor must be either time-t or time-t+1 * arguments of one or more timed processes. * @param p * The process, for which the CPD is being added. The argument * factor must contain the t+1-step argument of process p. */ void add_factor(process_type p, const F& factor) { assert(factor.arguments().count(p->next()) > 0); for (argument_type v : factor.arguments()) { int t = boost::any_cast<int>(v.index()); assert(t == current_step || t == next_step); } processes_.insert(p); transition.add_factor(p->next(), factor); }
//! Initialize the oracle void init() { assert(params.valid()); // Initialize the random number generator rng.seed(static_cast<unsigned>(params.random_seed)); uniform_prob = boost::uniform_real<double>(0,1); // Construct the graph and make CPTs if (num_finite() > 2 * params.num_parents) { for (size_t j = 2 * params.num_parents; j < num_finite(); ++j) { // Choose NUM_PARENTS random parents finite_domain parents; std::vector<size_t> r(randperm(j, rng)); for (size_t k = 0; k < params.num_parents; ++k) parents.insert(finite_seq[r[k]]); parents.insert(finite_seq[j]); tablef f(parents.plus(finite_seq[j])); // RIGHT HERE NOW: MAKE FACTOR bn.add_factor(parents, finite_seq[j]); } } }
/** * Adds a new factor to the prior distribution. * @param factor * A factor that represents the conditional probability distribution. * The arguments of this factor must be time-t arguments of one or * more timed processes. * @param v * The head of the conditional probability distribution. */ void add_factor(argument_type head, const F& factor) { assert(factor.arguments().count(head) > 0); check_index(factor.arguments(), current_step); prior.add_factor(head, factor); }