craam/algorithms/values.hpp
inline prec_t value_action(const WeightedOutcomeAction& action, numvec const& valuefunction,
                    prec_t discount, const numvec& distribution) {

    assert(distribution.size() == action.get_outcomes().size());
    if(action.get_outcomes().empty()) throw invalid_argument("WeightedOutcomeAction with no outcomes");

    prec_t averagevalue = 0.0;
    // TODO: simd?
    for(size_t i = 0; i < action.get_outcomes().size(); i++)
        averagevalue += distribution[i] * action[i].value(valuefunction, discount);
    return averagevalue;
}
/**
Computes the action value for a fixed index outcome.

\param action Action for which the value is computed
\param valuefunction Updated value function
\param discount Discount factor
\param distribution Custom distribution that is selected by nature.
\return Value of the action
 */
Computes the action value for a fixed index outcome.
\param action Action for which the value is computed
\param valuefunction Updated value function
\param discount Discount factor
\param distribution Custom distribution that is selected by nature.
\return Value of the action
Computes the action value for a fixed index outcome . \ param action Action for which the value is computed \ param valuefunction Updated value function \ param discount Discount factor \ param distribution Custom distribution that is selected by nature . \ return Value of the action
inline prec_t value_action(const WeightedOutcomeAction& action, numvec const& valuefunction,
                    prec_t discount, const numvec& distribution) {
    assert(distribution.size() == action.get_outcomes().size());
    if(action.get_outcomes().empty()) throw invalid_argument("WeightedOutcomeAction with no outcomes");
    prec_t averagevalue = 0.0;
    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 , const numvec & distribution ) { assert ( distribution . size ( ) == action . get_outcomes ( ) . size ( ) ) ; if ( action . get_outcomes ( ) . empty ( ) ) throw invalid_argument ( " " ) ; prec_t averagevalue = 0.0 ; for ( size_t i = 0 ; i < action . get_outcomes ( ) . size ( ) ; i ++ ) averagevalue += distribution [ i ] * action [ i ] . value ( valuefunction , discount ) ; return averagevalue ; }
Computes the action value for a fixed index outcome.
Computes the action value for a fixed index outcome .
// TODO: simd?