Formatting only
parent
dd50975668
commit
b7f43906bc
|
@ -5,26 +5,23 @@
|
||||||
* @author Frank Dellaert
|
* @author Frank Dellaert
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtsam_unstable/discrete/Domain.h>
|
|
||||||
#include <gtsam_unstable/discrete/AllDiff.h>
|
|
||||||
#include <gtsam/base/Testable.h>
|
#include <gtsam/base/Testable.h>
|
||||||
|
#include <gtsam_unstable/discrete/AllDiff.h>
|
||||||
|
#include <gtsam_unstable/discrete/Domain.h>
|
||||||
|
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
AllDiff::AllDiff(const DiscreteKeys& dkeys) :
|
AllDiff::AllDiff(const DiscreteKeys& dkeys) : Constraint(dkeys.indices()) {
|
||||||
Constraint(dkeys.indices()) {
|
for (const DiscreteKey& dkey : dkeys) cardinalities_.insert(dkey);
|
||||||
for(const DiscreteKey& dkey: dkeys)
|
|
||||||
cardinalities_.insert(dkey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void AllDiff::print(const std::string& s,
|
void AllDiff::print(const std::string& s, const KeyFormatter& formatter) const {
|
||||||
const KeyFormatter& formatter) const {
|
|
||||||
std::cout << s << "AllDiff on ";
|
std::cout << s << "AllDiff on ";
|
||||||
for (Key dkey: keys_)
|
for (Key dkey : keys_) std::cout << formatter(dkey) << " ";
|
||||||
std::cout << formatter(dkey) << " ";
|
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +38,8 @@ namespace gtsam {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
DecisionTreeFactor AllDiff::toDecisionTreeFactor() const {
|
DecisionTreeFactor AllDiff::toDecisionTreeFactor() const {
|
||||||
// We will do this by converting the allDif into many BinaryAllDiff constraints
|
// We will do this by converting the allDif into many BinaryAllDiff
|
||||||
|
// constraints
|
||||||
DecisionTreeFactor converted;
|
DecisionTreeFactor converted;
|
||||||
size_t nrKeys = keys_.size();
|
size_t nrKeys = keys_.size();
|
||||||
for (size_t i1 = 0; i1 < nrKeys; i1++)
|
for (size_t i1 = 0; i1 < nrKeys; i1++)
|
||||||
|
@ -109,8 +107,7 @@ namespace gtsam {
|
||||||
DiscreteFactor::Values known;
|
DiscreteFactor::Values known;
|
||||||
for (Key k : keys_) {
|
for (Key k : keys_) {
|
||||||
const Domain& Dk = domains[k];
|
const Domain& Dk = domains[k];
|
||||||
if (Dk.isSingleton())
|
if (Dk.isSingleton()) known[k] = Dk.firstValue();
|
||||||
known[k] = Dk.firstValue();
|
|
||||||
}
|
}
|
||||||
return partiallyApply(known);
|
return partiallyApply(known);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gtsam_unstable/discrete/BinaryAllDiff.h>
|
|
||||||
#include <gtsam/discrete/DiscreteKey.h>
|
#include <gtsam/discrete/DiscreteKey.h>
|
||||||
|
#include <gtsam_unstable/discrete/BinaryAllDiff.h>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ namespace gtsam {
|
||||||
* Returns 1 if values for all keys are different, 0 otherwise.
|
* Returns 1 if values for all keys are different, 0 otherwise.
|
||||||
*/
|
*/
|
||||||
class GTSAM_UNSTABLE_EXPORT AllDiff : public Constraint {
|
class GTSAM_UNSTABLE_EXPORT AllDiff : public Constraint {
|
||||||
|
|
||||||
std::map<Key, size_t> cardinalities_;
|
std::map<Key, size_t> cardinalities_;
|
||||||
|
|
||||||
DiscreteKey discreteKey(size_t i) const {
|
DiscreteKey discreteKey(size_t i) const {
|
||||||
|
@ -26,13 +25,12 @@ namespace gtsam {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// Construct from keys.
|
/// Construct from keys.
|
||||||
AllDiff(const DiscreteKeys& dkeys);
|
AllDiff(const DiscreteKeys& dkeys);
|
||||||
|
|
||||||
// print
|
// print
|
||||||
void print(const std::string& s = "",
|
void print(const std::string& s = "", const KeyFormatter& formatter =
|
||||||
const KeyFormatter& formatter = DefaultKeyFormatter) const override;
|
DefaultKeyFormatter) const override;
|
||||||
|
|
||||||
/// equals
|
/// equals
|
||||||
bool equals(const DiscreteFactor& other, double tol) const override {
|
bool equals(const DiscreteFactor& other, double tol) const override {
|
||||||
|
@ -40,8 +38,8 @@ namespace gtsam {
|
||||||
return false;
|
return false;
|
||||||
else {
|
else {
|
||||||
const AllDiff& f(static_cast<const AllDiff&>(other));
|
const AllDiff& f(static_cast<const AllDiff&>(other));
|
||||||
return cardinalities_.size() == f.cardinalities_.size()
|
return cardinalities_.size() == f.cardinalities_.size() &&
|
||||||
&& std::equal(cardinalities_.begin(), cardinalities_.end(),
|
std::equal(cardinalities_.begin(), cardinalities_.end(),
|
||||||
f.cardinalities_.begin());
|
f.cardinalities_.begin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gtsam_unstable/discrete/Domain.h>
|
|
||||||
#include <gtsam_unstable/discrete/Constraint.h>
|
|
||||||
#include <gtsam/discrete/DecisionTreeFactor.h>
|
#include <gtsam/discrete/DecisionTreeFactor.h>
|
||||||
|
#include <gtsam_unstable/discrete/Constraint.h>
|
||||||
|
#include <gtsam_unstable/discrete/Domain.h>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
@ -18,19 +18,18 @@ namespace gtsam {
|
||||||
* Returns 1 if values for two keys are different, 0 otherwise.
|
* Returns 1 if values for two keys are different, 0 otherwise.
|
||||||
*/
|
*/
|
||||||
class BinaryAllDiff : public Constraint {
|
class BinaryAllDiff : public Constraint {
|
||||||
|
|
||||||
size_t cardinality0_, cardinality1_; /// cardinality
|
size_t cardinality0_, cardinality1_; /// cardinality
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
BinaryAllDiff(const DiscreteKey& key1, const DiscreteKey& key2) :
|
BinaryAllDiff(const DiscreteKey& key1, const DiscreteKey& key2)
|
||||||
Constraint(key1.first, key2.first),
|
: Constraint(key1.first, key2.first),
|
||||||
cardinality0_(key1.second), cardinality1_(key2.second) {
|
cardinality0_(key1.second),
|
||||||
}
|
cardinality1_(key2.second) {}
|
||||||
|
|
||||||
// print
|
// print
|
||||||
void print(const std::string& s = "",
|
void print(
|
||||||
|
const std::string& s = "",
|
||||||
const KeyFormatter& formatter = DefaultKeyFormatter) const override {
|
const KeyFormatter& formatter = DefaultKeyFormatter) const override {
|
||||||
std::cout << s << "BinaryAllDiff on " << formatter(keys_[0]) << " and "
|
std::cout << s << "BinaryAllDiff on " << formatter(keys_[0]) << " and "
|
||||||
<< formatter(keys_[1]) << std::endl;
|
<< formatter(keys_[1]) << std::endl;
|
||||||
|
@ -42,7 +41,8 @@ namespace gtsam {
|
||||||
return false;
|
return false;
|
||||||
else {
|
else {
|
||||||
const BinaryAllDiff& f(static_cast<const BinaryAllDiff&>(other));
|
const BinaryAllDiff& f(static_cast<const BinaryAllDiff&>(other));
|
||||||
return (cardinality0_==f.cardinality0_) && (cardinality1_==f.cardinality1_);
|
return (cardinality0_ == f.cardinality0_) &&
|
||||||
|
(cardinality1_ == f.cardinality1_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +58,7 @@ namespace gtsam {
|
||||||
keys.push_back(DiscreteKey(keys_[1], cardinality1_));
|
keys.push_back(DiscreteKey(keys_[1], cardinality1_));
|
||||||
std::vector<double> table;
|
std::vector<double> table;
|
||||||
for (size_t i1 = 0; i1 < cardinality0_; i1++)
|
for (size_t i1 = 0; i1 < cardinality0_; i1++)
|
||||||
for (size_t i2 = 0; i2 < cardinality1_; i2++)
|
for (size_t i2 = 0; i2 < cardinality1_; i2++) table.push_back(i1 != i2);
|
||||||
table.push_back(i1 != i2);
|
|
||||||
DecisionTreeFactor converted(keys, table);
|
DecisionTreeFactor converted(keys, table);
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gtsam_unstable/dllexport.h>
|
|
||||||
#include <gtsam/discrete/DiscreteFactor.h>
|
#include <gtsam/discrete/DiscreteFactor.h>
|
||||||
|
#include <gtsam_unstable/dllexport.h>
|
||||||
|
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
@ -30,36 +31,26 @@ namespace gtsam {
|
||||||
* Derived classes include SingleValue, BinaryAllDiff, and AllDiff.
|
* Derived classes include SingleValue, BinaryAllDiff, and AllDiff.
|
||||||
*/
|
*/
|
||||||
class GTSAM_EXPORT Constraint : public DiscreteFactor {
|
class GTSAM_EXPORT Constraint : public DiscreteFactor {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef boost::shared_ptr<Constraint> shared_ptr;
|
typedef boost::shared_ptr<Constraint> shared_ptr;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/// Construct unary constraint factor.
|
/// Construct unary constraint factor.
|
||||||
Constraint(Key j) :
|
Constraint(Key j) : DiscreteFactor(boost::assign::cref_list_of<1>(j)) {}
|
||||||
DiscreteFactor(boost::assign::cref_list_of<1>(j)) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Construct binary constraint factor.
|
/// Construct binary constraint factor.
|
||||||
Constraint(Key j1, Key j2) :
|
Constraint(Key j1, Key j2)
|
||||||
DiscreteFactor(boost::assign::cref_list_of<2>(j1)(j2)) {
|
: DiscreteFactor(boost::assign::cref_list_of<2>(j1)(j2)) {}
|
||||||
}
|
|
||||||
|
|
||||||
/// Construct n-way constraint factor.
|
/// Construct n-way constraint factor.
|
||||||
Constraint(const KeyVector& js) :
|
Constraint(const KeyVector& js) : DiscreteFactor(js) {}
|
||||||
DiscreteFactor(js) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// construct from container
|
/// construct from container
|
||||||
template <class KeyIterator>
|
template <class KeyIterator>
|
||||||
Constraint(KeyIterator beginKey, KeyIterator endKey) :
|
Constraint(KeyIterator beginKey, KeyIterator endKey)
|
||||||
DiscreteFactor(beginKey, endKey) {
|
: DiscreteFactor(beginKey, endKey) {}
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// @name Standard Constructors
|
/// @name Standard Constructors
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
|
@ -85,7 +76,6 @@ namespace gtsam {
|
||||||
/// Partially apply known values
|
/// Partially apply known values
|
||||||
virtual shared_ptr partiallyApply(const Values&) const = 0;
|
virtual shared_ptr partiallyApply(const Values&) const = 0;
|
||||||
|
|
||||||
|
|
||||||
/// Partially apply known values, domain version
|
/// Partially apply known values, domain version
|
||||||
virtual shared_ptr partiallyApply(const std::vector<Domain>&) const = 0;
|
virtual shared_ptr partiallyApply(const std::vector<Domain>&) const = 0;
|
||||||
/// @}
|
/// @}
|
||||||
|
|
|
@ -5,9 +5,10 @@
|
||||||
* @author Frank Dellaert
|
* @author Frank Dellaert
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtsam_unstable/discrete/Domain.h>
|
|
||||||
#include <gtsam/discrete/DecisionTreeFactor.h>
|
|
||||||
#include <gtsam/base/Testable.h>
|
#include <gtsam/base/Testable.h>
|
||||||
|
#include <gtsam/discrete/DecisionTreeFactor.h>
|
||||||
|
#include <gtsam_unstable/discrete/Domain.h>
|
||||||
|
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
@ -15,10 +16,9 @@ namespace gtsam {
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void Domain::print(const string& s,
|
void Domain::print(const string& s, const KeyFormatter& formatter) const {
|
||||||
const KeyFormatter& formatter) const {
|
cout << s << ": Domain on " << formatter(keys_[0])
|
||||||
cout << s << ": Domain on " << formatter(keys_[0]) << " (j=" <<
|
<< " (j=" << formatter(keys_[0]) << ") with values";
|
||||||
formatter(keys_[0]) << ") with values";
|
|
||||||
for (size_t v : values_) cout << " " << v;
|
for (size_t v : values_) cout << " " << v;
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,7 @@ namespace gtsam {
|
||||||
DiscreteKeys keys;
|
DiscreteKeys keys;
|
||||||
keys += DiscreteKey(keys_[0], cardinality_);
|
keys += DiscreteKey(keys_[0], cardinality_);
|
||||||
vector<double> table;
|
vector<double> table;
|
||||||
for (size_t i1 = 0; i1 < cardinality_; ++i1)
|
for (size_t i1 = 0; i1 < cardinality_; ++i1) table.push_back(contains(i1));
|
||||||
table.push_back(contains(i1));
|
|
||||||
DecisionTreeFactor converted(keys, table);
|
DecisionTreeFactor converted(keys, table);
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
|
@ -73,11 +72,10 @@ namespace gtsam {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
Constraint::shared_ptr Domain::partiallyApply(
|
Constraint::shared_ptr Domain::partiallyApply(const Values& values) const {
|
||||||
const Values& values) const {
|
|
||||||
Values::const_iterator it = values.find(keys_[0]);
|
Values::const_iterator it = values.find(keys_[0]);
|
||||||
if (it != values.end() && !contains(it->second)) throw runtime_error(
|
if (it != values.end() && !contains(it->second))
|
||||||
"Domain::partiallyApply: unsatisfiable");
|
throw runtime_error("Domain::partiallyApply: unsatisfiable");
|
||||||
return boost::make_shared<Domain>(*this);
|
return boost::make_shared<Domain>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,8 +83,8 @@ namespace gtsam {
|
||||||
Constraint::shared_ptr Domain::partiallyApply(
|
Constraint::shared_ptr Domain::partiallyApply(
|
||||||
const vector<Domain>& domains) const {
|
const vector<Domain>& domains) const {
|
||||||
const Domain& Dk = domains[keys_[0]];
|
const Domain& Dk = domains[keys_[0]];
|
||||||
if (Dk.isSingleton() && !contains(*Dk.begin())) throw runtime_error(
|
if (Dk.isSingleton() && !contains(*Dk.begin()))
|
||||||
"Domain::partiallyApply: unsatisfiable");
|
throw runtime_error("Domain::partiallyApply: unsatisfiable");
|
||||||
return boost::make_shared<Domain>(Dk);
|
return boost::make_shared<Domain>(Dk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gtsam_unstable/discrete/Constraint.h>
|
|
||||||
#include <gtsam/discrete/DiscreteKey.h>
|
#include <gtsam/discrete/DiscreteKey.h>
|
||||||
|
#include <gtsam_unstable/discrete/Constraint.h>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
* @author Frank Dellaert
|
* @author Frank Dellaert
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtsam_unstable/discrete/SingleValue.h>
|
|
||||||
#include <gtsam_unstable/discrete/Domain.h>
|
|
||||||
#include <gtsam/discrete/DecisionTreeFactor.h>
|
|
||||||
#include <gtsam/base/Testable.h>
|
#include <gtsam/base/Testable.h>
|
||||||
|
#include <gtsam/discrete/DecisionTreeFactor.h>
|
||||||
|
#include <gtsam_unstable/discrete/Domain.h>
|
||||||
|
#include <gtsam_unstable/discrete/SingleValue.h>
|
||||||
|
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
@ -16,10 +17,9 @@ namespace gtsam {
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void SingleValue::print(const string& s,
|
void SingleValue::print(const string& s, const KeyFormatter& formatter) const {
|
||||||
const KeyFormatter& formatter) const {
|
cout << s << "SingleValue on "
|
||||||
cout << s << "SingleValue on " << "j=" << formatter(keys_[0])
|
<< "j=" << formatter(keys_[0]) << " with value " << value_ << endl;
|
||||||
<< " with value " << value_ << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
@ -32,8 +32,7 @@ namespace gtsam {
|
||||||
DiscreteKeys keys;
|
DiscreteKeys keys;
|
||||||
keys += DiscreteKey(keys_[0], cardinality_);
|
keys += DiscreteKey(keys_[0], cardinality_);
|
||||||
vector<double> table;
|
vector<double> table;
|
||||||
for (size_t i1 = 0; i1 < cardinality_; i1++)
|
for (size_t i1 = 0; i1 < cardinality_; i1++) table.push_back(i1 == value_);
|
||||||
table.push_back(i1 == value_);
|
|
||||||
DecisionTreeFactor converted(keys, table);
|
DecisionTreeFactor converted(keys, table);
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
|
@ -61,8 +60,8 @@ namespace gtsam {
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
Constraint::shared_ptr SingleValue::partiallyApply(const Values& values) const {
|
Constraint::shared_ptr SingleValue::partiallyApply(const Values& values) const {
|
||||||
Values::const_iterator it = values.find(keys_[0]);
|
Values::const_iterator it = values.find(keys_[0]);
|
||||||
if (it != values.end() && it->second != value_) throw runtime_error(
|
if (it != values.end() && it->second != value_)
|
||||||
"SingleValue::partiallyApply: unsatisfiable");
|
throw runtime_error("SingleValue::partiallyApply: unsatisfiable");
|
||||||
return boost::make_shared<SingleValue>(keys_[0], cardinality_, value_);
|
return boost::make_shared<SingleValue>(keys_[0], cardinality_, value_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,8 +69,8 @@ namespace gtsam {
|
||||||
Constraint::shared_ptr SingleValue::partiallyApply(
|
Constraint::shared_ptr SingleValue::partiallyApply(
|
||||||
const vector<Domain>& domains) const {
|
const vector<Domain>& domains) const {
|
||||||
const Domain& Dk = domains[keys_[0]];
|
const Domain& Dk = domains[keys_[0]];
|
||||||
if (Dk.isSingleton() && !Dk.contains(value_)) throw runtime_error(
|
if (Dk.isSingleton() && !Dk.contains(value_))
|
||||||
"SingleValue::partiallyApply: unsatisfiable");
|
throw runtime_error("SingleValue::partiallyApply: unsatisfiable");
|
||||||
return boost::make_shared<SingleValue>(discreteKey(), value_);
|
return boost::make_shared<SingleValue>(discreteKey(), value_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <gtsam/discrete/DiscreteKey.h>
|
||||||
#include <gtsam_unstable/discrete/Constraint.h>
|
#include <gtsam_unstable/discrete/Constraint.h>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
@ -16,7 +17,6 @@ namespace gtsam {
|
||||||
* This could of course also be implemented by changing its `Domain`.
|
* This could of course also be implemented by changing its `Domain`.
|
||||||
*/
|
*/
|
||||||
class GTSAM_UNSTABLE_EXPORT SingleValue : public Constraint {
|
class GTSAM_UNSTABLE_EXPORT SingleValue : public Constraint {
|
||||||
|
|
||||||
size_t cardinality_; /// < Number of values
|
size_t cardinality_; /// < Number of values
|
||||||
size_t value_; ///< allowed value
|
size_t value_; ///< allowed value
|
||||||
|
|
||||||
|
@ -25,22 +25,19 @@ namespace gtsam {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef boost::shared_ptr<SingleValue> shared_ptr;
|
typedef boost::shared_ptr<SingleValue> shared_ptr;
|
||||||
|
|
||||||
/// Construct from key, cardinality, and given value.
|
/// Construct from key, cardinality, and given value.
|
||||||
SingleValue(Key key, size_t n, size_t value) :
|
SingleValue(Key key, size_t n, size_t value)
|
||||||
Constraint(key), cardinality_(n), value_(value) {
|
: Constraint(key), cardinality_(n), value_(value) {}
|
||||||
}
|
|
||||||
|
|
||||||
/// Construct from DiscreteKey and given value.
|
/// Construct from DiscreteKey and given value.
|
||||||
SingleValue(const DiscreteKey& dkey, size_t value) :
|
SingleValue(const DiscreteKey& dkey, size_t value)
|
||||||
Constraint(dkey.first), cardinality_(dkey.second), value_(value) {
|
: Constraint(dkey.first), cardinality_(dkey.second), value_(value) {}
|
||||||
}
|
|
||||||
|
|
||||||
// print
|
// print
|
||||||
void print(const std::string& s = "",
|
void print(const std::string& s = "", const KeyFormatter& formatter =
|
||||||
const KeyFormatter& formatter = DefaultKeyFormatter) const override;
|
DefaultKeyFormatter) const override;
|
||||||
|
|
||||||
/// equals
|
/// equals
|
||||||
bool equals(const DiscreteFactor& other, double tol) const override {
|
bool equals(const DiscreteFactor& other, double tol) const override {
|
||||||
|
|
Loading…
Reference in New Issue