use emplace_shared
parent
fa28bbb925
commit
0c6d5d438f
|
@ -101,25 +101,27 @@ public:
|
|||
|
||||
/// @}
|
||||
|
||||
template<class SOURCE>
|
||||
// Add single key decision-tree factor.
|
||||
template <class SOURCE>
|
||||
void add(const DiscreteKey& j, SOURCE table) {
|
||||
DiscreteKeys keys;
|
||||
keys.push_back(j);
|
||||
push_back(boost::make_shared<DecisionTreeFactor>(keys, table));
|
||||
emplace_shared<DecisionTreeFactor>(keys, table);
|
||||
}
|
||||
|
||||
template<class SOURCE>
|
||||
// Add binary key decision-tree factor.
|
||||
template <class SOURCE>
|
||||
void add(const DiscreteKey& j1, const DiscreteKey& j2, SOURCE table) {
|
||||
DiscreteKeys keys;
|
||||
keys.push_back(j1);
|
||||
keys.push_back(j2);
|
||||
push_back(boost::make_shared<DecisionTreeFactor>(keys, table));
|
||||
emplace_shared<DecisionTreeFactor>(keys, table);
|
||||
}
|
||||
|
||||
/** add shared discreteFactor immediately from arguments */
|
||||
template<class SOURCE>
|
||||
// Add shared discreteFactor immediately from arguments.
|
||||
template <class SOURCE>
|
||||
void add(const DiscreteKeys& keys, SOURCE table) {
|
||||
push_back(boost::make_shared<DecisionTreeFactor>(keys, table));
|
||||
emplace_shared<DecisionTreeFactor>(keys, table);
|
||||
}
|
||||
|
||||
/** Return the set of variables involved in the factors (set union) */
|
||||
|
|
|
@ -21,32 +21,22 @@ namespace gtsam {
|
|||
class GTSAM_UNSTABLE_EXPORT CSP : public DiscreteFactorGraph {
|
||||
public:
|
||||
/** A map from keys to values */
|
||||
typedef KeyVector Indices;
|
||||
typedef Assignment<Key> Values;
|
||||
typedef boost::shared_ptr<Values> sharedValues;
|
||||
|
||||
public:
|
||||
// /// Constructor
|
||||
// CSP() {
|
||||
// }
|
||||
|
||||
/// Add a unary constraint, allowing only a single value
|
||||
void addSingleValue(const DiscreteKey& dkey, size_t value) {
|
||||
boost::shared_ptr<SingleValue> factor(new SingleValue(dkey, value));
|
||||
push_back(factor);
|
||||
emplace_shared<SingleValue>(dkey, value);
|
||||
}
|
||||
|
||||
/// Add a binary AllDiff constraint
|
||||
void addAllDiff(const DiscreteKey& key1, const DiscreteKey& key2) {
|
||||
boost::shared_ptr<BinaryAllDiff> factor(new BinaryAllDiff(key1, key2));
|
||||
push_back(factor);
|
||||
emplace_shared<BinaryAllDiff>(key1, key2);
|
||||
}
|
||||
|
||||
/// Add a general AllDiff constraint
|
||||
void addAllDiff(const DiscreteKeys& dkeys) {
|
||||
boost::shared_ptr<AllDiff> factor(new AllDiff(dkeys));
|
||||
push_back(factor);
|
||||
}
|
||||
void addAllDiff(const DiscreteKeys& dkeys) { emplace_shared<AllDiff>(dkeys); }
|
||||
|
||||
// /** return product of all factors as a single factor */
|
||||
// DecisionTreeFactor product() const {
|
||||
|
@ -56,10 +46,10 @@ class GTSAM_UNSTABLE_EXPORT CSP : public DiscreteFactorGraph {
|
|||
// return result;
|
||||
// }
|
||||
|
||||
/// Find the best total assignment - can be expensive
|
||||
/// Find the best total assignment - can be expensive.
|
||||
sharedValues optimalAssignment() const;
|
||||
|
||||
/// Find the best total assignment - can be expensive
|
||||
/// Find the best total assignment, with given ordering - can be expensive.
|
||||
sharedValues optimalAssignment(const Ordering& ordering) const;
|
||||
|
||||
// /*
|
||||
|
@ -78,7 +68,7 @@ class GTSAM_UNSTABLE_EXPORT CSP : public DiscreteFactorGraph {
|
|||
* Apply arc-consistency ~ Approximate loopy belief propagation
|
||||
* We need to give the domains to a constraint, and it returns
|
||||
* a domain whose values don't conflict in the arc-consistency way.
|
||||
* TODO: should get cardinality from Indices
|
||||
* TODO: should get cardinality from DiscreteKeys
|
||||
*/
|
||||
void runArcConsistency(size_t cardinality, size_t nrIterations = 10,
|
||||
bool print = false) const;
|
||||
|
|
Loading…
Reference in New Issue