public class LinearFVVFA extends java.lang.Object implements DifferentiableStateValue, DifferentiableStateActionValue
StateToFeatureVectorGenerator which defines
the state features on which linear function approximation is performed. In the case of Q-value
function approximation, the state features are replicated for each action with all other action's associated
state features set to zero, thereby allowing for unique predictions for each action.
evaluate(burlap.oomdp.core.states.State) method or the evaluate(burlap.oomdp.core.states.State, burlap.oomdp.core.AbstractGroundedAction)
method.ParametricFunction.ParametricStateActionFunction, ParametricFunction.ParametricStateFunction| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<AbstractGroundedAction,java.lang.Integer> |
actionOffset
A feature index offset for each action when using Q-value function approximation.
|
protected int |
currentActionOffset |
protected FunctionGradient |
currentGradient |
protected double[] |
currentStateFeatures |
protected double |
currentValue |
protected double |
defaultWeight
A default weight value for the functions weights.
|
protected StateToFeatureVectorGenerator |
fvGen
The state feature vector generator used for linear value function approximation.
|
protected State |
lastState |
protected double[] |
stateActionWeights
The function weights when performing Q-value function approximation.
|
protected double[] |
stateWeights
The function weights when performing state value function approximation.
|
| Constructor and Description |
|---|
LinearFVVFA(StateToFeatureVectorGenerator fvGen,
double defaultWeightValue)
Initializes.
|
| Modifier and Type | Method and Description |
|---|---|
LinearFVVFA |
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,
AbstractGroundedAction a)
Sets the input of this function to the given
State and
AbstractGroundedAction and returns the value of it. |
protected void |
expandStateActionWeights(int num)
Expands the state-action function weight vector by a fixed sized and initializes their value
to the default weight value set for this object.
|
java.util.Map<AbstractGroundedAction,java.lang.Integer> |
getActionOffset()
Returns the
Map of feature index offsets into the full feature vector for each action |
int |
getActionOffset(AbstractGroundedAction a) |
double |
getDefaultWeight() |
StateToFeatureVectorGenerator |
getFvGen() |
double |
getParameter(int i)
Returns the value of the ith parameter value
|
FunctionGradient |
gradient(State s)
Returns the gradient of this function
|
FunctionGradient |
gradient(State s,
AbstractGroundedAction a)
Returns the gradient of this function.
|
void |
initializeStateActionWeightVector(int size,
double v)
Resets the state-action function weight array to a new array of the given sized and default value.
|
void |
initializeStateWeightVector(int size,
double v)
Resets the state function weight array to a new array of the given sized and default value.
|
int |
numParameters()
Returns the number of parameters defining this function.
|
void |
resetParameters()
Resets the parameters of this function to default values.
|
void |
setActionOffset(AbstractGroundedAction a,
int offset)
Sets the
Map of feature index offset into the full feature vector for the given action |
void |
setActionOffset(java.util.Map<AbstractGroundedAction,java.lang.Integer> actionOffset)
Sets the
Map of feature index offsets into the full feature vector for each action |
void |
setParameter(int i,
double p)
Sets the value of the ith parameter to given value
|
protected StateToFeatureVectorGenerator fvGen
protected java.util.Map<AbstractGroundedAction,java.lang.Integer> actionOffset
protected double[] stateWeights
protected double[] stateActionWeights
protected double defaultWeight
protected double[] currentStateFeatures
protected int currentActionOffset
protected double currentValue
protected FunctionGradient currentGradient
protected State lastState
public LinearFVVFA(StateToFeatureVectorGenerator fvGen, double defaultWeightValue)
evaluate(burlap.oomdp.core.states.State)
or evaluate(burlap.oomdp.core.states.State, burlap.oomdp.core.AbstractGroundedAction) is made.
If the former method is called
first, then this object will be tasked with state value function approximation. If the latter
method is called first, then this object will be tasked with state-action value function approximation.fvGen - The state feature vector generator that produces the features used for either linear state value function approximation or state-action-value function approximation.defaultWeightValue - The default weight value of all function weights.public double evaluate(State s, AbstractGroundedAction a)
ParametricFunction.ParametricStateActionFunctionState and
AbstractGroundedAction and returns the value of it.evaluate in interface ParametricFunction.ParametricStateActionFunctions - the input Statea - the input actionState and AbstractGroundedActionpublic 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, AbstractGroundedAction a)
DifferentiableStateActionValuegradient in interface DifferentiableStateActionValues - the input Statea - the input AbstractGroundedActionFunctionGradient 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 setpublic void resetParameters()
ParametricFunctionresetParameters in interface ParametricFunctionpublic int getActionOffset(AbstractGroundedAction a)
protected void expandStateActionWeights(int num)
num - the number of function weights to add to the state-action function weight vectorpublic StateToFeatureVectorGenerator getFvGen()
public double getDefaultWeight()
public void initializeStateWeightVector(int size,
double v)
size - the dimensionality of the weightsv - the default value to which the weights will be setpublic void initializeStateActionWeightVector(int size,
double v)
size - the dimensionality of the weightsv - the default value to which the weights will be setpublic java.util.Map<AbstractGroundedAction,java.lang.Integer> getActionOffset()
Map of feature index offsets into the full feature vector for each actionMap of feature index offsets into the full feature vector for each actionpublic void setActionOffset(java.util.Map<AbstractGroundedAction,java.lang.Integer> actionOffset)
Map of feature index offsets into the full feature vector for each actionactionOffset - the Map of feature index offsets into the full feature vector for each actionpublic void setActionOffset(AbstractGroundedAction a, int offset)
Map of feature index offset into the full feature vector for the given actiona - the action whose feature vector index is to be setoffset - the feature index offset for the actionpublic LinearFVVFA copy()
ParametricFunctionParametricFunction.copy in interface ParametricFunctionParametricFunction.