craam/algorithms/values.hpp
inline prec_t value_action(const WeightedOutcomeAction& action, numvec const& valuefunction,
            prec_t discount) {
    assert(action.get_distribution().size() == action.get_outcomes().size());

    if(action.get_outcomes().empty())
        throw invalid_argument("WeightedOutcomeAction with no outcomes");

    prec_t averagevalue = 0.0;
    const numvec& distribution = action.get_distribution();
    for(size_t i = 0; i < action.get_outcomes().size(); i++)
        averagevalue += distribution[i] * action[i].value(valuefunction, discount);
    return averagevalue;
}
/**
Computes the average outcome using the provided distribution.

\param action Action for which the value is computed
\param valuefunction Updated value function
\param discount Discount factor
\return Mean value of the action
 */
Computes the average outcome using the provided distribution.
\param action Action for which the value is computed
\param valuefunction Updated value function
\param discount Discount factor
\return Mean value of the action
Computes the average outcome using the provided distribution . \ param action Action for which the value is computed \ param valuefunction Updated value function \ param discount Discount factor \ return Mean value of the action
inline prec_t value_action(const WeightedOutcomeAction& action, numvec const& valuefunction,
            prec_t discount) {
    assert(action.get_distribution().size() == action.get_outcomes().size());
    if(action.get_outcomes().empty())
        throw invalid_argument("WeightedOutcomeAction with no outcomes");
    prec_t averagevalue = 0.0;
    const numvec& distribution = action.get_distribution();
    for(size_t i = 0; i < action.get_outcomes().size(); i++)
        averagevalue += distribution[i] * action[i].value(valuefunction, discount);
    return averagevalue;
}
inline prec_t value_action ( const WeightedOutcomeAction & action , numvec const & valuefunction , prec_t discount ) { assert ( action . get_distribution ( ) . size ( ) == action . get_outcomes ( ) . size ( ) ) ; if ( action . get_outcomes ( ) . empty ( ) ) throw invalid_argument ( " " ) ; prec_t averagevalue = 0.0 ; const numvec & distribution = action . get_distribution ( ) ; for ( size_t i = 0 ; i < action . get_outcomes ( ) . size ( ) ; i ++ ) averagevalue += distribution [ i ] * action [ i ] . value ( valuefunction , discount ) ; return averagevalue ; }
Computes the average outcome using the provided distribution.
Computes the average outcome using the provided distribution .