Use evaluate not value
parent
ebc37eeba5
commit
f59342882a
|
@ -84,7 +84,7 @@ public:
|
|||
virtual double operator()(const DiscreteValues&) const = 0;
|
||||
|
||||
/// Synonym for operator(), mostly for wrapper
|
||||
double value(const DiscreteValues& values) const { return operator()(values); }
|
||||
double evaluate(const DiscreteValues& values) const { return operator()(values); }
|
||||
|
||||
/// Multiply in a DecisionTreeFactor and return the result as DecisionTreeFactor
|
||||
virtual DecisionTreeFactor operator*(const DecisionTreeFactor&) const = 0;
|
||||
|
|
|
@ -137,7 +137,7 @@ public:
|
|||
double operator()(const DiscreteValues& values) const;
|
||||
|
||||
/// Synonym for operator(), mostly for wrapper
|
||||
double value(const DiscreteValues& values) const { return operator()(values); }
|
||||
double evaluate(const DiscreteValues& values) const { return operator()(values); }
|
||||
|
||||
/// print
|
||||
void print(
|
||||
|
|
|
@ -25,7 +25,7 @@ class DiscreteFactor {
|
|||
gtsam::DefaultKeyFormatter) const;
|
||||
bool equals(const gtsam::DiscreteFactor& other, double tol = 1e-9) const;
|
||||
bool empty() const;
|
||||
double value(const gtsam::DiscreteValues& values) const;
|
||||
double evaluate(const gtsam::DiscreteValues& values) const;
|
||||
};
|
||||
|
||||
#include <gtsam/discrete/DiscreteConditional.h>
|
||||
|
@ -42,7 +42,7 @@ virtual class DecisionTreeFactor: gtsam::DiscreteFactor {
|
|||
const gtsam::KeyFormatter& keyFormatter =
|
||||
gtsam::DefaultKeyFormatter) const;
|
||||
bool equals(const gtsam::DecisionTreeFactor& other, double tol = 1e-9) const;
|
||||
double value(const gtsam::DiscreteValues& values) const; // TODO(dellaert): why do I have to repeat???
|
||||
double evaluate(const gtsam::DiscreteValues& values) const; // TODO(dellaert): why do I have to repeat???
|
||||
};
|
||||
|
||||
#include <gtsam/discrete/DiscreteFactorGraph.h>
|
||||
|
@ -55,7 +55,7 @@ class DiscreteFactorGraph {
|
|||
bool equals(const gtsam::DiscreteFactorGraph& fg, double tol = 1e-9) const;
|
||||
gtsam::KeySet keys() const;
|
||||
gtsam::DecisionTreeFactor product() const;
|
||||
double value(const gtsam::DiscreteValues& values) const;
|
||||
double evaluate(const gtsam::DiscreteValues& values) const;
|
||||
DiscreteValues optimize() const;
|
||||
};
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class TestDiscreteFactorGraph(GtsamTestCase):
|
|||
assignment[1] = 1
|
||||
|
||||
# Check if graph evaluation works ( 0.3*0.6*4 )
|
||||
self.assertAlmostEqual(.72, graph.value(assignment))
|
||||
self.assertAlmostEqual(.72, graph.evaluate(assignment))
|
||||
|
||||
# Creating a new test with third node and adding unary and ternary factors on it
|
||||
graph.add(P3, "0.9 0.2 0.5")
|
||||
|
@ -60,7 +60,7 @@ class TestDiscreteFactorGraph(GtsamTestCase):
|
|||
assignment[2] = 1
|
||||
|
||||
# Check if graph evaluation works (0.3*0.9*1*0.2*8)
|
||||
self.assertAlmostEqual(4.32, graph.value(assignment))
|
||||
self.assertAlmostEqual(4.32, graph.evaluate(assignment))
|
||||
|
||||
# Below assignment lead to selecting the 3rd index in the ternary factor table
|
||||
assignment[0] = 0
|
||||
|
@ -68,11 +68,11 @@ class TestDiscreteFactorGraph(GtsamTestCase):
|
|||
assignment[2] = 0
|
||||
|
||||
# Check if graph evaluation works (0.9*0.6*1*0.9*4)
|
||||
self.assertAlmostEqual(1.944, graph.value(assignment))
|
||||
self.assertAlmostEqual(1.944, graph.evaluate(assignment))
|
||||
|
||||
# Check if graph product works
|
||||
product = graph.product()
|
||||
self.assertAlmostEqual(1.944, product.value(assignment))
|
||||
self.assertAlmostEqual(1.944, product.evaluate(assignment))
|
||||
|
||||
def test_optimize(self):
|
||||
"""Test constructing and optizing a discrete factor graph."""
|
||||
|
@ -94,7 +94,6 @@ class TestDiscreteFactorGraph(GtsamTestCase):
|
|||
expectedValues[1] = 0
|
||||
expectedValues[2] = 0
|
||||
actualValues = graph.optimize()
|
||||
print(list(actualValues.items()))
|
||||
self.assertEqual(list(actualValues.items()),
|
||||
list(expectedValues.items()))
|
||||
|
||||
|
|
Loading…
Reference in New Issue