Removed obsolete optimize call and documented better
parent
4d9ff77249
commit
626d06905c
|
@ -474,6 +474,14 @@
|
||||||
<useDefaultCommand>true</useDefaultCommand>
|
<useDefaultCommand>true</useDefaultCommand>
|
||||||
<runAllBuilders>true</runAllBuilders>
|
<runAllBuilders>true</runAllBuilders>
|
||||||
</target>
|
</target>
|
||||||
|
<target name="testChordalBayesNet.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
|
<buildCommand>make</buildCommand>
|
||||||
|
<buildArguments/>
|
||||||
|
<buildTarget>testChordalBayesNet.run</buildTarget>
|
||||||
|
<stopOnError>true</stopOnError>
|
||||||
|
<useDefaultCommand>true</useDefaultCommand>
|
||||||
|
<runAllBuilders>true</runAllBuilders>
|
||||||
|
</target>
|
||||||
<target name="install" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="install" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>make</buildCommand>
|
<buildCommand>make</buildCommand>
|
||||||
<buildTarget>install</buildTarget>
|
<buildTarget>install</buildTarget>
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
|
|
||||||
#include "ChordalBayesNet.h"
|
#include "ChordalBayesNet.h"
|
||||||
|
#include "VectorConfig.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace gtsam;
|
using namespace gtsam;
|
||||||
|
@ -58,27 +60,16 @@ void ChordalBayesNet::erase(const string& key)
|
||||||
nodes.erase(key);
|
nodes.erase(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
|
||||||
// optimize, i.e. return x = inv(R)*d
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
boost::shared_ptr<VectorConfig> ChordalBayesNet::optimize() const
|
boost::shared_ptr<VectorConfig> ChordalBayesNet::optimize() const
|
||||||
{
|
{
|
||||||
boost::shared_ptr<VectorConfig> result(new VectorConfig);
|
boost::shared_ptr<VectorConfig> result(new VectorConfig);
|
||||||
result = optimize(result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ************************************************************************* */
|
|
||||||
boost::shared_ptr<VectorConfig> ChordalBayesNet::optimize(const boost::shared_ptr<VectorConfig> &c) const
|
|
||||||
{
|
|
||||||
boost::shared_ptr<VectorConfig> result(new VectorConfig);
|
|
||||||
result = c;
|
|
||||||
|
|
||||||
/** solve each node in turn in topological sort order (parents first)*/
|
/** solve each node in turn in topological sort order (parents first)*/
|
||||||
BOOST_FOREACH(string key, keys) {
|
BOOST_FOREACH(string key, keys) {
|
||||||
const_iterator cg = nodes.find(key); // get node
|
const_iterator cg = nodes.find(key); // get node
|
||||||
assert( cg != nodes.end() );
|
assert( cg != nodes.end() ); // make sure it exists
|
||||||
Vector x = cg->second->solve(*result); // Solve it
|
Vector x = cg->second->solve(*result); // Solve for that variable
|
||||||
result->insert(key,x); // store result in partial solution
|
result->insert(key,x); // store result in partial solution
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include <boost/serialization/list.hpp>
|
#include <boost/serialization/list.hpp>
|
||||||
|
|
||||||
#include "ConditionalGaussian.h"
|
#include "ConditionalGaussian.h"
|
||||||
#include "VectorConfig.h"
|
|
||||||
#include "Testable.h"
|
#include "Testable.h"
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
@ -77,9 +76,10 @@ public:
|
||||||
const_iterator const begin() const {return nodes.begin();}
|
const_iterator const begin() const {return nodes.begin();}
|
||||||
const_iterator const end() const {return nodes.end();}
|
const_iterator const end() const {return nodes.end();}
|
||||||
|
|
||||||
/** optimize */
|
/**
|
||||||
|
* optimize, i.e. return x = inv(R)*d
|
||||||
|
*/
|
||||||
boost::shared_ptr<VectorConfig> optimize() const;
|
boost::shared_ptr<VectorConfig> optimize() const;
|
||||||
boost::shared_ptr<VectorConfig> optimize(const boost::shared_ptr<VectorConfig> &c) const;
|
|
||||||
|
|
||||||
/** size is the number of nodes */
|
/** size is the number of nodes */
|
||||||
size_t size() const {return nodes.size();}
|
size_t size() const {return nodes.size();}
|
||||||
|
|
Loading…
Reference in New Issue