discrete folder

release/4.3a0
kartik arcot 2023-01-11 15:07:25 -08:00
parent 18562e97ae
commit 3ebada2dc4
4 changed files with 12 additions and 11 deletions

View File

@ -26,6 +26,7 @@
#include <string> #include <string>
#include <typeinfo> #include <typeinfo>
#include <exception> #include <exception>
#include <optional>
#ifdef GTSAM_USE_TBB #ifdef GTSAM_USE_TBB
#include <tbb/tbb_allocator.h> #include <tbb/tbb_allocator.h>
@ -53,7 +54,7 @@ protected:
protected: protected:
bool dynamic_; ///< Whether this object was moved bool dynamic_; ///< Whether this object was moved
mutable boost::optional<String> description_; ///< Optional description mutable std::optional<String> description_; ///< Optional description
/// Default constructor is protected - may only be created from derived classes /// Default constructor is protected - may only be created from derived classes
ThreadsafeException() : ThreadsafeException() :

View File

@ -24,7 +24,6 @@
#include <algorithm> #include <algorithm>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <boost/optional.hpp>
#include <cmath> #include <cmath>
#include <fstream> #include <fstream>
@ -34,6 +33,7 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
#include <optional>
namespace gtsam { namespace gtsam {
@ -563,7 +563,7 @@ namespace gtsam {
typename DecisionTree<L, Y>::NodePtr DecisionTree<L, Y>::compose( typename DecisionTree<L, Y>::NodePtr DecisionTree<L, Y>::compose(
Iterator begin, Iterator end, const L& label) const { Iterator begin, Iterator end, const L& label) const {
// find highest label among branches // find highest label among branches
boost::optional<L> highestLabel; std::optional<L> highestLabel;
size_t nrChoices = 0; size_t nrChoices = 0;
for (Iterator it = begin; it != end; it++) { for (Iterator it = begin; it != end; it++) {
if (it->root_->isLeaf()) if (it->root_->isLeaf())
@ -571,7 +571,7 @@ namespace gtsam {
boost::shared_ptr<const Choice> c = boost::shared_ptr<const Choice> c =
boost::dynamic_pointer_cast<const Choice>(it->root_); boost::dynamic_pointer_cast<const Choice>(it->root_);
if (!highestLabel || c->label() > *highestLabel) { if (!highestLabel || c->label() > *highestLabel) {
highestLabel.reset(c->label()); highestLabel = c->label();
nrChoices = c->nrChoices(); nrChoices = c->nrChoices();
} }
} }

View File

@ -137,14 +137,14 @@ namespace gtsam {
} }
Signature& Signature::operator=(const string& spec) { Signature& Signature::operator=(const string& spec) {
spec_.reset(spec); spec_ = spec;
Table table; Table table;
parser::It f = spec.begin(), l = spec.end(); parser::It f = spec.begin(), l = spec.end();
bool success = bool success =
qi::phrase_parse(f, l, parser::grammar.table, qi::space, table); qi::phrase_parse(f, l, parser::grammar.table, qi::space, table);
if (success) { if (success) {
for (Row& row : table) normalize(row); for (Row& row : table) normalize(row);
table_.reset(table); table_ = table;
} }
return *this; return *this;
} }
@ -153,7 +153,7 @@ namespace gtsam {
Table table = t; Table table = t;
for(Row& row: table) for(Row& row: table)
normalize(row); normalize(row);
table_.reset(table); table_ = table;
return *this; return *this;
} }

View File

@ -19,7 +19,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <vector> #include <vector>
#include <boost/optional.hpp> #include <optional>
#include <gtsam/discrete/DiscreteKey.h> #include <gtsam/discrete/DiscreteKey.h>
namespace gtsam { namespace gtsam {
@ -68,10 +68,10 @@ namespace gtsam {
DiscreteKeys parents_; DiscreteKeys parents_;
// the given CPT specification string // the given CPT specification string
boost::optional<std::string> spec_; std::optional<std::string> spec_;
// the CPT as parsed, if successful // the CPT as parsed, if successful
boost::optional<Table> table_; std::optional<Table> table_;
public: public:
/** /**
@ -124,7 +124,7 @@ namespace gtsam {
KeyVector indices() const; KeyVector indices() const;
// the CPT as parsed, if successful // the CPT as parsed, if successful
const boost::optional<Table>& table() const { return table_; } const std::optional<Table>& table() const { return table_; }
// the CPT as a vector of doubles, with key's values most rapidly changing // the CPT as a vector of doubles, with key's values most rapidly changing
std::vector<double> cpt() const; std::vector<double> cpt() const;