LabelType - The type for labels assigned to nodesNodeNameType - The type for names of nodespublic class GraphWrappingEnergyFunction<LabelType,NodeNameType> extends java.lang.Object implements NodeNameAwareEnergyFunction<LabelType,NodeNameType>
| Modifier and Type | Class and Description |
|---|---|
static interface |
GraphWrappingEnergyFunction.PotentialHandler<LabelType,NodeNameType>
This interface defines the problem-specific methods this class requires
as input
|
| Constructor and Description |
|---|
GraphWrappingEnergyFunction(DirectedNodeEdgeGraph<NodeNameType> graph,
GraphWrappingEnergyFunction.PotentialHandler<LabelType,NodeNameType> handler)
Creates a new instance of this class containing the input graph (shallow
copy -- don't change it after this!) and the handler for problem-specific
details (also only a shallow copy).
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearLabels()
Clears labels previously set.
|
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 GraphWrappingEnergyFunction(DirectedNodeEdgeGraph<NodeNameType> graph, GraphWrappingEnergyFunction.PotentialHandler<LabelType,NodeNameType> handler)
graph - The graph this containshandler - The handler for problem-specific methodspublic java.util.Collection<LabelType> getPossibleLabels(int nodeId)
EnergyFunctiongetPossibleLabels in interface EnergyFunction<LabelType>nodeId - The node whose labels is wantedEnergyFunction.getPossibleLabels(int)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 getUnaryCost(int i,
LabelType label)
EnergyFunctiongetUnaryCost in interface EnergyFunction<LabelType>EnergyFunction.getUnaryCost(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 getPairwiseCost(int edgeId,
LabelType ilabel,
LabelType jlabel)
EnergyFunctiongetPairwiseCost in interface EnergyFunction<LabelType>EnergyFunction.getPairwiseCost(int, java.lang.Object,
java.lang.Object)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 void setLabel(NodeNameType node, LabelType label)
NodeNameAwareEnergyFunctionsetLabel in interface NodeNameAwareEnergyFunction<LabelType,NodeNameType>NodeTypeAwareEnergyFunction#setLabel(java.lang.Object,
java.lang.Object)public void clearLabels()
public java.util.Map<LabelType,java.lang.Double> getBeliefs(NodeNameType node, EnergyFunctionSolver<LabelType> bp)
NodeNameAwareEnergyFunctiongetBeliefs in interface NodeNameAwareEnergyFunction<LabelType,NodeNameType>NodeTypeAwareEnergyFunction#getBeliefs(java.lang.Object,
gov.sandia.cognition.graph.inference.BeliefPropagation)