public class LinearVFA extends java.lang.Object implements DifferentiableStateValue, DifferentiableStateActionValue
SparseStateFeatures object that will be used to store
 retrieve state features. For every feature returned by the feature functions, this class will automatically create a weight associated with it.
 The returned approximated value for any state is the linear combination of state features and weights.
 This class can also be used for state-action value function approximation, which it will perform by creating state-action features as a cross product of the state features and action set. You should only ever using this class for state-values or state-action values, not both.
ParametricFunction.ParametricStateActionFunction, ParametricFunction.ParametricStateFunction| Modifier and Type | Field and Description | 
|---|---|
protected java.util.List<StateFeature> | 
currentFeatures  | 
protected FunctionGradient | 
currentGradient  | 
protected double | 
currentValue  | 
protected double | 
defaultWeight
A default weight for the functions 
 | 
protected Action | 
lastAction  | 
protected State | 
lastState  | 
protected SparseStateFeatures | 
sparseStateFeatures
The state features 
 | 
protected SparseCrossProductFeatures | 
stateActionFeatures
The State-action features based on the cross product of state features and actions 
 | 
protected java.util.Map<java.lang.Integer,java.lang.Double> | 
weights
A map from feature identifiers to function weights 
 | 
| Constructor and Description | 
|---|
LinearVFA(SparseStateFeatures sparseStateFeatures)
Initializes with a feature database; the default weight value will be zero 
 | 
LinearVFA(SparseStateFeatures sparseStateFeatures,
         double defaultWeight)
Initializes 
 | 
| Modifier and Type | Method and Description | 
|---|---|
LinearVFA | 
copy()
Returns a copy of this  
ParametricFunction. | 
double | 
evaluate(State s)
Sets the input of this function to the given  
State and returns
 the value of it. | 
double | 
evaluate(State s,
        Action a)
 | 
double | 
getParameter(int i)
Returns the value of the ith parameter value 
 | 
protected double | 
getWeight(int weightId)  | 
FunctionGradient | 
gradient(State s)
Returns the gradient of this function 
 | 
FunctionGradient | 
gradient(State s,
        Action a)
Returns the gradient of this function. 
 | 
int | 
numParameters()
Returns the number of parameters defining this function. 
 | 
void | 
resetParameters()
Resets the parameters of this function to default values. 
 | 
void | 
setParameter(int i,
            double p)
Sets the value of the ith parameter to given value 
 | 
protected SparseStateFeatures sparseStateFeatures
protected SparseCrossProductFeatures stateActionFeatures
protected java.util.Map<java.lang.Integer,java.lang.Double> weights
protected double defaultWeight
protected java.util.List<StateFeature> currentFeatures
protected double currentValue
protected FunctionGradient currentGradient
protected State lastState
protected Action lastAction
public LinearVFA(SparseStateFeatures sparseStateFeatures)
sparseStateFeatures - the feature database to usepublic LinearVFA(SparseStateFeatures sparseStateFeatures, double defaultWeight)
sparseStateFeatures - the feature database to usedefaultWeight - the default feature weight to initialize feature weights topublic double evaluate(State s, Action a)
ParametricFunction.ParametricStateActionFunctionevaluate in interface ParametricFunction.ParametricStateActionFunctions - the input Statea - the input actionState and Actionpublic double evaluate(State s)
ParametricFunction.ParametricStateFunctionState and returns
 the value of it.evaluate in interface ParametricFunction.ParametricStateFunctions - the State to input to the functionStatepublic FunctionGradient gradient(State s)
DifferentiableStateValuegradient in interface DifferentiableStateValues - the input statepublic FunctionGradient gradient(State s, Action a)
DifferentiableStateActionValuegradient in interface DifferentiableStateActionValues - the input Statea - the input ActionFunctionGradient of this function at the inputpublic int numParameters()
ParametricFunctionnumParameters in interface ParametricFunctionpublic double getParameter(int i)
ParametricFunctiongetParameter in interface ParametricFunctioni - the parameter indexpublic void setParameter(int i,
                         double p)
ParametricFunctionsetParameter in interface ParametricFunctioni - the index of the parameter to setp - the parameter value to which it should be setprotected double getWeight(int weightId)
public void resetParameters()
ParametricFunctionresetParameters in interface ParametricFunctionpublic LinearVFA copy()
ParametricFunctionParametricFunction.copy in interface ParametricFunctionParametricFunction.