Removed some obsolete code in discrete
parent
88b46000e5
commit
29ea1450eb
|
|
@ -793,6 +793,14 @@
|
|||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="check" path="build/gtsam/discrete" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j5</buildArguments>
|
||||
<buildTarget>check</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="vSFMexample.run" path="build/examples/vSLAMexample" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j2</buildArguments>
|
||||
|
|
|
|||
|
|
@ -33,9 +33,6 @@ namespace gtsam {
|
|||
typedef DiscreteConditional ConditionalType;
|
||||
typedef boost::shared_ptr<DecisionTreeFactor> shared_ptr;
|
||||
|
||||
/// Index label and cardinality
|
||||
typedef std::pair<Index,size_t> IndexC;
|
||||
|
||||
public:
|
||||
|
||||
/// @name Standard Constructors
|
||||
|
|
|
|||
|
|
@ -14,19 +14,6 @@ namespace gtsam {
|
|||
|
||||
using namespace std;
|
||||
|
||||
bool OldDiscreteKey::equals(const OldDiscreteKey& other, double tol) const {
|
||||
return (*this == other);
|
||||
}
|
||||
|
||||
void OldDiscreteKey::print(const string& s) const {
|
||||
cout << s << *this;
|
||||
}
|
||||
|
||||
ostream& operator <<(ostream &os, const OldDiscreteKey &key) {
|
||||
os << key.name_;
|
||||
return os;
|
||||
}
|
||||
|
||||
DiscreteKeys::DiscreteKeys(const vector<int>& cs) {
|
||||
for (size_t i = 0; i < cs.size(); i++) {
|
||||
string name = boost::str(boost::format("v%1%") % i);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <gtsam/base/types.h>
|
||||
#include <gtsam/discrete/label_traits.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
|
@ -16,65 +15,11 @@
|
|||
|
||||
namespace gtsam {
|
||||
|
||||
typedef std::pair<Index,size_t> DiscreteKey;
|
||||
|
||||
/**
|
||||
* Key type for discrete conditionals
|
||||
* Includes name and cardinality
|
||||
*/
|
||||
class OldDiscreteKey : std::pair<Index,size_t> {
|
||||
|
||||
private:
|
||||
|
||||
std::string name_;
|
||||
|
||||
public:
|
||||
|
||||
/** Default constructor */
|
||||
OldDiscreteKey() :
|
||||
std::pair<Index,size_t>(0,0), name_("default") {
|
||||
}
|
||||
|
||||
/** Constructor, defaults to binary */
|
||||
OldDiscreteKey(Index j, const std::string& name, size_t cardinality = 2) :
|
||||
std::pair<Index,size_t>(j,cardinality), name_(name) {
|
||||
}
|
||||
|
||||
virtual ~OldDiscreteKey() {
|
||||
}
|
||||
|
||||
// Testable
|
||||
bool equals(const OldDiscreteKey& other, double tol = 1e-9) const;
|
||||
void print(const std::string& s = "") const;
|
||||
|
||||
operator Index() const { return first; }
|
||||
|
||||
const std::string& name() const {
|
||||
return name_;
|
||||
}
|
||||
|
||||
size_t cardinality() const {
|
||||
return second;
|
||||
}
|
||||
|
||||
/** compare 2 keys by their name */
|
||||
bool operator <(const OldDiscreteKey& other) const {
|
||||
return name_ < other.name_;
|
||||
}
|
||||
|
||||
/** equality */
|
||||
bool operator==(const OldDiscreteKey& other) const {
|
||||
return (first == other.first) && (second == other.second) && (name_ == other.name_);
|
||||
}
|
||||
|
||||
bool operator!=(const OldDiscreteKey& other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
/** provide streaming */
|
||||
friend std::ostream& operator <<(std::ostream &os, const OldDiscreteKey &key);
|
||||
|
||||
}; // OldDiscreteKey
|
||||
typedef std::pair<Index,size_t> DiscreteKey;
|
||||
|
||||
/// DiscreteKeys is a set of keys that can be assembled using the & operator
|
||||
struct DiscreteKeys: public std::vector<DiscreteKey> {
|
||||
|
|
@ -111,23 +56,4 @@ namespace gtsam {
|
|||
|
||||
/// Create a list from two keys
|
||||
DiscreteKeys operator&(const DiscreteKey& key1, const DiscreteKey& key2);
|
||||
|
||||
/// traits class for DiscreteKey for use with DecisionTree/DecisionDiagram
|
||||
template<>
|
||||
struct label_traits<OldDiscreteKey> {
|
||||
/** get cardinality from type */
|
||||
static size_t cardinality(const OldDiscreteKey& key) {
|
||||
return key.cardinality();
|
||||
}
|
||||
/** compare 2 keys by their name */
|
||||
static bool higher(const OldDiscreteKey& a, const OldDiscreteKey& b) {
|
||||
return a.name() < b.name();
|
||||
}
|
||||
/** hash function */
|
||||
static size_t hash_value(const OldDiscreteKey& a) {
|
||||
boost::hash<std::string> hasher;
|
||||
return hasher(a.name());
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* label_traits.h
|
||||
* @brief traits class for labels used in Decision Diagram
|
||||
* @author Frank Dellaert
|
||||
* @date Mar 22, 2011
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
namespace gtsam {
|
||||
|
||||
/**
|
||||
* Default traits class for label type, http://www.cantrip.org/traits.html
|
||||
* Override to provide non-default behavior, see example in Index
|
||||
*/
|
||||
template<typename T>
|
||||
struct label_traits {
|
||||
/** default = binary label */
|
||||
static size_t cardinality(const T&) {
|
||||
return 2;
|
||||
}
|
||||
/** default higher(a,b) = a<b */
|
||||
static bool higher(const T& a, const T& b) {
|
||||
return a < b;
|
||||
}
|
||||
/** hash function */
|
||||
static size_t hash_value(const T& a) {
|
||||
boost::hash<T> hasher;
|
||||
return hasher(a);
|
||||
}
|
||||
};
|
||||
|
||||
/* custom hash function for labels, no need to specialize this */
|
||||
template<typename T>
|
||||
std::size_t hash_value(const T& a) {
|
||||
return label_traits<T>::hash_value(a);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue