gtsam_unstable/discrete

release/4.3a0
kartik arcot 2023-01-12 13:43:29 -08:00
parent 51e60cc8e0
commit 0ae90f6262
5 changed files with 10 additions and 8 deletions

View File

@ -10,6 +10,7 @@
#include <gtsam_unstable/discrete/Domain.h>
#include <boost/make_shared.hpp>
#include <optional>
namespace gtsam {
@ -64,7 +65,7 @@ bool AllDiff::ensureArcConsistency(Key j, Domains* domains) const {
// a value in domains->at(j) that does not occur in any other connected domain.
// If found, we make this a singleton...
// TODO: make a new constraint where this really is true
boost::optional<Domain> maybeChanged = Dj.checkAllDiff(keys_, *domains);
std::optional<Domain> maybeChanged = Dj.checkAllDiff(keys_, *domains);
if (maybeChanged) {
Dj = *maybeChanged;
return true;

View File

@ -61,7 +61,7 @@ bool Domain::ensureArcConsistency(Key j, Domains* domains) const {
}
/* ************************************************************************* */
boost::optional<Domain> Domain::checkAllDiff(const KeyVector keys,
std::optional<Domain> Domain::checkAllDiff(const KeyVector keys,
const Domains& domains) const {
Key j = key();
// for all values in this domain
@ -74,7 +74,7 @@ boost::optional<Domain> Domain::checkAllDiff(const KeyVector keys,
return Domain(this->discreteKey(), value);
found:;
}
return boost::none; // we did not change it
return {}; // we did not change it
}
/* ************************************************************************* */

View File

@ -9,6 +9,7 @@
#include <gtsam/discrete/DiscreteKey.h>
#include <gtsam_unstable/discrete/Constraint.h>
#include <optional>
namespace gtsam {
@ -100,7 +101,7 @@ class GTSAM_UNSTABLE_EXPORT Domain : public Constraint {
* @param keys connected domains through alldiff
* @param keys other domains
*/
boost::optional<Domain> checkAllDiff(const KeyVector keys,
std::optional<Domain> checkAllDiff(const KeyVector keys,
const Domains& domains) const;
/// Partially apply known values

View File

@ -79,7 +79,7 @@ void Scheduler::addStudent(const string& studentName, const string& area1,
/** get key for student and area, 0 is time slot itself */
const DiscreteKey& Scheduler::key(size_t s,
boost::optional<size_t> area) const {
std::optional<size_t> area) const {
return area ? students_[s].keys_[*area] : students_[s].key_;
}
@ -100,7 +100,7 @@ const string& Scheduler::studentArea(size_t i, size_t area) const {
/** Add student-specific constraints to the graph */
void Scheduler::addStudentSpecificConstraints(size_t i,
boost::optional<size_t> slot) {
std::optional<size_t> slot) {
bool debug = ISDEBUG("Scheduler::buildGraph");
assert(i < nrStudents());

View File

@ -108,7 +108,7 @@ class GTSAM_UNSTABLE_EXPORT Scheduler : public CSP {
/** get key for student and area, 0 is time slot itself */
const DiscreteKey& key(size_t s,
boost::optional<size_t> area = boost::none) const;
std::optional<size_t> area = {}) const;
/** addStudent has to be called after adding slots and faculty */
void addStudent(const std::string& studentName, const std::string& area1,
@ -124,7 +124,7 @@ class GTSAM_UNSTABLE_EXPORT Scheduler : public CSP {
/** Add student-specific constraints to the graph */
void addStudentSpecificConstraints(
size_t i, boost::optional<size_t> slot = boost::none);
size_t i, std::optional<size_t> slot = {});
/** Main routine that builds factor graph */
void buildGraph(size_t mutexBound = 7);