public class LinearVFA extends java.lang.Object implements ValueFunctionApproximation
Modifier and Type | Field and Description |
---|---|
protected double |
defaultWeight
A default weight for the functions
|
protected FeatureDatabase |
featureDatabase
A feature database for which a unique function weight will be associated
|
protected java.util.Map<java.lang.Integer,FunctionWeight> |
weights
A map from feature identifiers to function weights
|
Constructor and Description |
---|
LinearVFA(FeatureDatabase featureDatabase)
Initializes with a feature database; the default weight value will be zero
|
LinearVFA(FeatureDatabase featureDatabase,
double defaultWeight)
Initializes
|
Modifier and Type | Method and Description |
---|---|
protected ApproximationResult |
getApproximationResultFrom(java.util.List<StateFeature> features)
Computes the linear function over the given features and the stored feature weights.
|
FunctionWeight |
getFunctionWeight(int featureId)
Returns the FunctionWeight for the given function's feature id.
|
java.util.List<ActionApproximationResult> |
getStateActionValues(State s,
java.util.List<GroundedAction> gas)
Returns a state-value (e.g., Q-value) approximation for the query state.
|
ApproximationResult |
getStateValue(State s)
Returns a state value approximation for the query state.
|
WeightGradient |
getWeightGradient(ApproximationResult approximationResult)
Returns the function weight gradient of the given approximation result.
|
int |
numFeatures()
Returns the number of features used in this approximator.
|
void |
resetWeights()
Resets the weights as is learning had never been performed.
|
void |
setWeight(int featureId,
double w)
Sets the weight for a features
|
protected FeatureDatabase featureDatabase
protected java.util.Map<java.lang.Integer,FunctionWeight> weights
protected double defaultWeight
public LinearVFA(FeatureDatabase featureDatabase)
featureDatabase
- the feature database to usepublic LinearVFA(FeatureDatabase featureDatabase, double defaultWeight)
featureDatabase
- the feature database to usedefaultWeight
- the default feature weight to initialize feature weights topublic ApproximationResult getStateValue(State s)
ValueFunctionApproximation
getStateValue
in interface ValueFunctionApproximation
s
- the query state whose state value should be approximatedpublic java.util.List<ActionApproximationResult> getStateActionValues(State s, java.util.List<GroundedAction> gas)
ValueFunctionApproximation
getStateActionValues
in interface ValueFunctionApproximation
s
- the query state of the state-action pair to be approximatedgas
- the query action of the state-action pair to be approximtedpublic WeightGradient getWeightGradient(ApproximationResult approximationResult)
ValueFunctionApproximation
getWeightGradient
in interface ValueFunctionApproximation
approximationResult
- the approximation result whose weight gradient should be returnedprotected ApproximationResult getApproximationResultFrom(java.util.List<StateFeature> features)
features
- List of the StateFeature
obejcts defining the state features of this approximator.ApproximationResult
.public void resetWeights()
ValueFunctionApproximation
resetWeights
in interface ValueFunctionApproximation
public void setWeight(int featureId, double w)
ValueFunctionApproximation
setWeight
in interface ValueFunctionApproximation
featureId
- the feature id whose weight should be setw
- the weight value to usepublic int numFeatures()
ValueFunctionApproximation
numFeatures
in interface ValueFunctionApproximation
public FunctionWeight getFunctionWeight(int featureId)
ValueFunctionApproximation
getFunctionWeight
in interface ValueFunctionApproximation
featureId
- the id of function's feature whose weight is returned.