public class LinearVFA extends java.lang.Object implements DifferentiableStateValue, DifferentiableStateActionValue
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 FeatureDatabase |
featureDatabase
A feature database for which a unique function weight will be associated
|
protected AbstractGroundedAction |
lastAction |
protected State |
lastState |
protected java.util.Map<java.lang.Integer,java.lang.Double> |
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 |
---|---|
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,
AbstractGroundedAction a)
Sets the input of this function to the given
State and
AbstractGroundedAction and returns the value of it. |
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,
AbstractGroundedAction 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 FeatureDatabase featureDatabase
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 AbstractGroundedAction lastAction
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 double evaluate(State s, AbstractGroundedAction a)
ParametricFunction.ParametricStateActionFunction
State
and
AbstractGroundedAction
and returns the value of it.evaluate
in interface ParametricFunction.ParametricStateActionFunction
s
- the input State
a
- the input actionState
and AbstractGroundedAction
public double evaluate(State s)
ParametricFunction.ParametricStateFunction
State
and returns
the value of it.evaluate
in interface ParametricFunction.ParametricStateFunction
s
- the State
to input to the functionState
public FunctionGradient gradient(State s)
DifferentiableStateValue
gradient
in interface DifferentiableStateValue
s
- the input statepublic FunctionGradient gradient(State s, AbstractGroundedAction a)
DifferentiableStateActionValue
gradient
in interface DifferentiableStateActionValue
s
- the input State
a
- the input AbstractGroundedAction
FunctionGradient
of this function at the inputpublic int numParameters()
ParametricFunction
numParameters
in interface ParametricFunction
public double getParameter(int i)
ParametricFunction
getParameter
in interface ParametricFunction
i
- the parameter indexpublic void setParameter(int i, double p)
ParametricFunction
setParameter
in interface ParametricFunction
i
- the index of the parameter to setp
- the parameter value to which it should be setprotected double getWeight(int weightId)
public void resetParameters()
ParametricFunction
resetParameters
in interface ParametricFunction
public LinearVFA copy()
ParametricFunction
ParametricFunction
.copy
in interface ParametricFunction
ParametricFunction
.