-
Notifications
You must be signed in to change notification settings - Fork 792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discrete Elimination Refactor #1919
Merged
Merged
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
d1d440a
add nrValues method
varunagrawal a68da21
operator* version which accepts DiscreteFactor
varunagrawal a09b77e
return DiscreteFactor shared_ptr as leftover from elimination
varunagrawal 27bbce1
generalize DiscreteFactorGraph::product to DiscreteFactor
varunagrawal 84e4194
make normalization code common
varunagrawal 4dac37c
make sum and max DiscreteFactor methods
varunagrawal 6c45467
add timing info
varunagrawal b0ad350
add note about toDecisionTreeFactor
varunagrawal 306a3ba
kill toDecisionTreeFactor to force rethink
varunagrawal 2cd2ab0
DiscreteDistribution from TableFactor
varunagrawal 9f88a36
make evaluate use the Assignment<Key> base class
varunagrawal 2a3b5e6
use Assignment<Key> for evaluate since it is the base class
varunagrawal fff8458
remove TableFactor constructor in DiscreteDistribution
varunagrawal 295b965
use Assignment<Key> since it is a base class
varunagrawal 261038f
fix DiscreteConditional constructor
varunagrawal 20d6d09
use DiscreteFactor everywhere in DiscreteFactorGraph.cpp
varunagrawal 32b6bc0
update DiscreteConditional
varunagrawal 38563da
Revert "kill toDecisionTreeFactor to force rethink"
varunagrawal 9633ad1
make DiscreteConditional::likelihood match the declaration
varunagrawal 0b3477f
get different classes to play nicely
varunagrawal 1d79188
compiles
varunagrawal 7757851
timing
varunagrawal 9844a55
move evaluate and operator() next to each other
varunagrawal aa25ccf
implement evaluate in DiscreteFactor
varunagrawal 90d7e21
change from DiscreteValues to Assignment<Key>
varunagrawal 6665659
use BaseFactor instead of DecisionTreeFactor
varunagrawal f9a9801
Merge branch 'ring' into discrete-elimination-refactor
varunagrawal e6b6528
common definitions of Unary, UnaryAssignment and Binary
varunagrawal f85284a
some cleanup based on previous commit
varunagrawal 5e86f7e
remove previously added code
varunagrawal 1c14a56
revert changes to make code generic
varunagrawal b325150
revert DiscreteFactorGraph::product
varunagrawal 0afc198
revert some DiscreteFactorGraph changes
varunagrawal 975fe62
add methods in gtsam_unstable
varunagrawal fc2d33f
add division with DiscreteFactor::shared_ptr for convenience
varunagrawal 2c02efc
fix tests
varunagrawal 360598d
undo uncomment
varunagrawal 853241c
add evaluate to DiscreteConditional
varunagrawal 199c0a0
keep using DecisionTreeFactor for DiscreteConditional
varunagrawal 214bf4e
more fixes
varunagrawal 0de114f
Merge branch 'develop' into discrete-elimination-refactor
varunagrawal e46cd54
TableFactor cleanup
varunagrawal 52c8034
add division by DiscreteFactor in TableFactor
varunagrawal e0e833c
cleanup
varunagrawal 84627c0
fix error
varunagrawal cc4e9cb
Merge branch 'develop' into discrete-elimination-refactor
varunagrawal 0b3f058
Merge branch 'develop' into discrete-elimination-refactor
varunagrawal 22d11d7
don't print timing info by default
varunagrawal 90d8486
Merge branch 'develop' into discrete-elimination-refactor
varunagrawal d3901be
Merge branch 'develop' into discrete-elimination-refactor
varunagrawal 5fa04d7
small improvements
varunagrawal 268290d
multiply method for DiscreteFactor
varunagrawal 2f09e86
remove override from definition
varunagrawal 5e9c130
Merge branch 'discrete-multiply' into discrete-elimination-refactor
varunagrawal b5128b2
use DecisionTreeFactor version of sum and max where not available
varunagrawal 4ebca71
divide operator for DiscreteFactor::shared_ptr
varunagrawal fb1d52a
fix constructor
varunagrawal e9822a7
update DiscreteFactorGraph to use DiscreteFactor::shared_ptr for elim…
varunagrawal 2f8c8dd
update tests
varunagrawal 2434e24
undo print change in DiscreteLookupTable
varunagrawal ab2fe37
Merge branch 'discrete-multiply' into discrete-elimination-refactor
varunagrawal 7561da4
move operator/ to Constraint.h
varunagrawal ff5371f
move sum, max and nrValues to Constraint class as well
varunagrawal f932945
check pointer casts
varunagrawal f8dedb5
use DiscreteFactor for DiscreteConditional constructor
varunagrawal c754f9b
add comments
varunagrawal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,13 +24,13 @@ | |
#include <gtsam/hybrid/HybridValues.h> | ||
|
||
#include <algorithm> | ||
#include <cassert> | ||
#include <random> | ||
#include <set> | ||
#include <stdexcept> | ||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
#include <cassert> | ||
|
||
using namespace std; | ||
using std::pair; | ||
|
@@ -44,8 +44,9 @@ template class GTSAM_EXPORT | |
|
||
/* ************************************************************************** */ | ||
DiscreteConditional::DiscreteConditional(const size_t nrFrontals, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this now be a DiscreetFactor& ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it can! |
||
const DecisionTreeFactor& f) | ||
: BaseFactor(f / (*f.sum(nrFrontals))), BaseConditional(nrFrontals) {} | ||
const DiscreteFactor& f) | ||
: BaseFactor((f / f.sum(nrFrontals))->toDecisionTreeFactor()), | ||
BaseConditional(nrFrontals) {} | ||
|
||
/* ************************************************************************** */ | ||
DiscreteConditional::DiscreteConditional(size_t nrFrontals, | ||
|
@@ -150,11 +151,11 @@ void DiscreteConditional::print(const string& s, | |
/* ************************************************************************** */ | ||
bool DiscreteConditional::equals(const DiscreteFactor& other, | ||
double tol) const { | ||
if (!dynamic_cast<const DecisionTreeFactor*>(&other)) { | ||
if (!dynamic_cast<const BaseFactor*>(&other)) { | ||
return false; | ||
} else { | ||
const DecisionTreeFactor& f(static_cast<const DecisionTreeFactor&>(other)); | ||
return DecisionTreeFactor::equals(f, tol); | ||
const BaseFactor& f(static_cast<const BaseFactor&>(other)); | ||
return BaseFactor::equals(f, tol); | ||
} | ||
} | ||
|
||
|
@@ -375,7 +376,7 @@ std::string DiscreteConditional::markdown(const KeyFormatter& keyFormatter, | |
ss << "*\n" << std::endl; | ||
if (nrParents() == 0) { | ||
// We have no parents, call factor method. | ||
ss << DecisionTreeFactor::markdown(keyFormatter, names); | ||
ss << BaseFactor::markdown(keyFormatter, names); | ||
return ss.str(); | ||
} | ||
|
||
|
@@ -427,7 +428,7 @@ string DiscreteConditional::html(const KeyFormatter& keyFormatter, | |
ss << "</i></p>\n"; | ||
if (nrParents() == 0) { | ||
// We have no parents, call factor method. | ||
ss << DecisionTreeFactor::html(keyFormatter, names); | ||
ss << BaseFactor::html(keyFormatter, names); | ||
return ss.str(); | ||
} | ||
|
||
|
@@ -475,7 +476,7 @@ string DiscreteConditional::html(const KeyFormatter& keyFormatter, | |
|
||
/* ************************************************************************* */ | ||
double DiscreteConditional::evaluate(const HybridValues& x) const { | ||
return this->evaluate(x.discrete()); | ||
return this->operator()(x.discrete()); | ||
} | ||
|
||
/* ************************************************************************* */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comments