LabelType - The labels that can be assigned to nodesNodeNameType - The type used to name nodespublic class CostSpeedupEnergyFunction<LabelType,NodeNameType> extends java.lang.Object implements NodeNameAwareEnergyFunction<LabelType,NodeNameType>
| Constructor and Description |
|---|
CostSpeedupEnergyFunction(NodeNameAwareEnergyFunction<LabelType,NodeNameType> wrapme)
Initializes this with the wrapped function and empty values for the
pairwise costs (which are only computed and stored as needed).
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearStoredCosts()
Clears the pre-computed costs that were stored to keep from calling log
and potential each time.
|
java.util.Map<LabelType,java.lang.Double> |
getBeliefs(NodeNameType node,
EnergyFunctionSolver<LabelType> bp)
Get the probabilities for each label for the input node as produced by
the input belief propagation run.
|
Pair<java.lang.Integer,java.lang.Integer> |
getEdge(int i)
Returns the indices for the two endpoints in the specified path.
|
double |
getPairwiseCost(int edgeId,
LabelType ilabel,
LabelType jlabel)
This is the -log(getPairwisePotential(.)).
|
double |
getPairwisePotential(int edgeId,
LabelType ilabel,
LabelType jlabel)
Returns the pairwise cost of node i being assigned label_i and node j
being assigned label_j.
|
java.util.Collection<LabelType> |
getPossibleLabels(int nodeId)
Returns the set of labels that this message passer supports
|
double |
getUnaryCost(int i,
LabelType label)
This is the -log(getUnaryPotential(.)).
|
double |
getUnaryPotential(int i,
LabelType label)
Returns the unary cost for node i having the input label.
|
int |
numEdges()
Returns the number of paths that messages should be passed down.
|
int |
numNodes()
Returns the number of nodes in the energy function.
|
void |
setLabel(NodeNameType node,
LabelType label)
Set the label for the input node
|
public CostSpeedupEnergyFunction(NodeNameAwareEnergyFunction<LabelType,NodeNameType> wrapme)
wrapme - The function to wrap with this onepublic void clearStoredCosts()
public void setLabel(NodeNameType node, LabelType label)
NodeNameAwareEnergyFunctionsetLabel in interface NodeNameAwareEnergyFunction<LabelType,NodeNameType>NodeNameAwareEnergyFunction.setLabel(java.lang.Object,
java.lang.Object)public java.util.Map<LabelType,java.lang.Double> getBeliefs(NodeNameType node, EnergyFunctionSolver<LabelType> bp)
NodeNameAwareEnergyFunctiongetBeliefs in interface NodeNameAwareEnergyFunction<LabelType,NodeNameType>NodeNameAwareEnergyFunction#getBeliefs(java.lang.Object,
gov.sandia.cognition.graph.inference.BeliefPropagation)public java.util.Collection<LabelType> getPossibleLabels(int nodeId)
EnergyFunctiongetPossibleLabels in interface EnergyFunction<LabelType>nodeId - The node whose labels is wantedEnergyFunction.getPossibleLabels(int)public int numEdges()
EnergyFunctionEnergyFunction.getEdge(int) method, all paths can be
retrieved.numEdges in interface EnergyFunction<LabelType>EnergyFunction.numEdges()public int numNodes()
EnergyFunctionnumNodes in interface EnergyFunction<LabelType>EnergyFunction.numNodes()public Pair<java.lang.Integer,java.lang.Integer> getEdge(int i)
EnergyFunctionEnergyFunction.numEdges()
- 1) should return a non-null value. All path IDs outside that range
should throw an Exception.getEdge in interface EnergyFunction<LabelType>i - The path ID (should be in [0 ... EnergyFunction.numEdges()) ).#getUnaryCost(int)
and #getPairwisePotential(int, int, Object, Object))EnergyFunction.getEdge(int)public double getUnaryPotential(int i,
LabelType label)
EnergyFunctionEnergyFunction.getEdge(int). If not, an exception
should be thrown.getUnaryPotential in interface EnergyFunction<LabelType>i - The index of the node whose unary cost should be returnedlabel - The label that could be applied to the nodeEnergyFunction.getUnaryPotential(int, java.lang.Object)public double getPairwisePotential(int edgeId,
LabelType ilabel,
LabelType jlabel)
EnergyFunctionEnergyFunction.getEdge(int) in the ordere specified by the returned pair (i
= getFirst, j = getSecond). If not, an exception should be thrown.getPairwisePotential in interface EnergyFunction<LabelType>edgeId - The id for the edge being requestedilabel - The label being (possibly) assigned to node ijlabel - The label being (possibly) assigned to node jEnergyFunction.getPairwisePotential(int, java.lang.Object,
java.lang.Object)public double getUnaryCost(int i,
LabelType label)
EnergyFunctiongetUnaryCost in interface EnergyFunction<LabelType>EnergyFunction.getUnaryCost(int, java.lang.Object)public double getPairwiseCost(int edgeId,
LabelType ilabel,
LabelType jlabel)
EnergyFunctiongetPairwiseCost in interface EnergyFunction<LabelType>EnergyFunction.getPairwiseCost(int, java.lang.Object,
java.lang.Object)