Fixed examples from timing statement change (missed)
parent
4876cc7ff7
commit
c44f8f7f80
|
@ -79,7 +79,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
|
|
||||||
cout << "\nComputing Node Marginals ..(Sequential Elimination)" << endl;
|
cout << "\nComputing Node Marginals ..(Sequential Elimination)" << endl;
|
||||||
tic_(1, "Sequential");
|
tic_(Sequential);
|
||||||
for (vector<DiscreteKey>::iterator itr = nodes.begin(); itr != nodes.end();
|
for (vector<DiscreteKey>::iterator itr = nodes.begin(); itr != nodes.end();
|
||||||
++itr) {
|
++itr) {
|
||||||
//Compute the marginal
|
//Compute the marginal
|
||||||
|
@ -89,14 +89,14 @@ int main(int argc, char** argv) {
|
||||||
cout << "Node#" << setw(4) << itr->first << " : ";
|
cout << "Node#" << setw(4) << itr->first << " : ";
|
||||||
print(margProbs);
|
print(margProbs);
|
||||||
}
|
}
|
||||||
toc_(1, "Sequential");
|
toc_(Sequential);
|
||||||
|
|
||||||
// Here we'll make use of DiscreteMarginals class, which makes use of
|
// Here we'll make use of DiscreteMarginals class, which makes use of
|
||||||
// bayes-tree based shortcut evaluation of marginals
|
// bayes-tree based shortcut evaluation of marginals
|
||||||
DiscreteMarginals marginals(graph);
|
DiscreteMarginals marginals(graph);
|
||||||
|
|
||||||
cout << "\nComputing Node Marginals ..(BayesTree based)" << endl;
|
cout << "\nComputing Node Marginals ..(BayesTree based)" << endl;
|
||||||
tic_(2, "Multifrontal");
|
tic_(Multifrontal);
|
||||||
for (vector<DiscreteKey>::iterator itr = nodes.begin(); itr != nodes.end();
|
for (vector<DiscreteKey>::iterator itr = nodes.begin(); itr != nodes.end();
|
||||||
++itr) {
|
++itr) {
|
||||||
//Compute the marginal
|
//Compute the marginal
|
||||||
|
@ -106,7 +106,7 @@ int main(int argc, char** argv) {
|
||||||
cout << "Node#" << setw(4) << itr->first << " : ";
|
cout << "Node#" << setw(4) << itr->first << " : ";
|
||||||
print(margProbs);
|
print(margProbs);
|
||||||
}
|
}
|
||||||
toc_(2, "Multifrontal");
|
toc_(Multifrontal);
|
||||||
|
|
||||||
tictoc_print_();
|
tictoc_print_();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -82,51 +82,55 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
int n = 10000000;
|
int n = 10000000;
|
||||||
|
|
||||||
|
{
|
||||||
VirtualBase** b = new VirtualBase*[n];
|
VirtualBase** b = new VirtualBase*[n];
|
||||||
tic_(0, "Virtual");
|
tic_(Virtual);
|
||||||
tic_(0, "new");
|
tic_(new);
|
||||||
for(int i=0; i<n; ++i)
|
for(int i=0; i<n; ++i)
|
||||||
b[i] = new VirtualDerived();
|
b[i] = new VirtualDerived();
|
||||||
toc_(0, "new");
|
toc_(new);
|
||||||
tic_(1, "method");
|
tic_(method);
|
||||||
for(int i=0; i<n; ++i)
|
for(int i=0; i<n; ++i)
|
||||||
b[i]->method();
|
b[i]->method();
|
||||||
toc_(1, "method");
|
toc_(method);
|
||||||
tic_(2, "dynamic_cast");
|
tic_(dynamic_cast);
|
||||||
for(int i=0; i<n; ++i) {
|
for(int i=0; i<n; ++i) {
|
||||||
VirtualDerived* d = dynamic_cast<VirtualDerived*>(b[i]);
|
VirtualDerived* d = dynamic_cast<VirtualDerived*>(b[i]);
|
||||||
if(d)
|
if(d)
|
||||||
d->method();
|
d->method();
|
||||||
}
|
}
|
||||||
toc_(2, "dynamic_cast");
|
toc_(dynamic_cast);
|
||||||
tic_(3, "delete");
|
tic_(delete);
|
||||||
for(int i=0; i<n; ++i)
|
for(int i=0; i<n; ++i)
|
||||||
delete b[i];
|
delete b[i];
|
||||||
toc_(3, "delete");
|
toc_(delete);
|
||||||
toc_(0, "Virtual");
|
toc_(Virtual);
|
||||||
delete[] b;
|
delete[] b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
NonVirtualDerived** d = new NonVirtualDerived*[n];
|
NonVirtualDerived** d = new NonVirtualDerived*[n];
|
||||||
tic_(1, "NonVirtual");
|
tic_(NonVirtual);
|
||||||
tic_(0, "new");
|
tic_(new);
|
||||||
for(int i=0; i<n; ++i)
|
for(int i=0; i<n; ++i)
|
||||||
d[i] = new NonVirtualDerived();
|
d[i] = new NonVirtualDerived();
|
||||||
toc_(0, "new");
|
toc_(new);
|
||||||
tic_(1, "method");
|
tic_(method);
|
||||||
for(int i=0; i<n; ++i)
|
for(int i=0; i<n; ++i)
|
||||||
d[i]->method();
|
d[i]->method();
|
||||||
toc_(1, "method");
|
toc_(method);
|
||||||
tic_(2, "dynamic_cast (does nothing)");
|
tic_(dynamic_cast (does nothing));
|
||||||
for(int i=0; i<n; ++i)
|
for(int i=0; i<n; ++i)
|
||||||
d[i]->method();
|
d[i]->method();
|
||||||
toc_(2, "dynamic_cast (does nothing)");
|
toc_(dynamic_cast (does nothing));
|
||||||
tic_(3, "delete");
|
tic_(delete);
|
||||||
for(int i=0; i<n; ++i)
|
for(int i=0; i<n; ++i)
|
||||||
delete d[i];
|
delete d[i];
|
||||||
toc_(3, "delete");
|
toc_(delete);
|
||||||
toc_(1, "NonVirtual");
|
toc_(NonVirtual);
|
||||||
delete[] d;
|
delete[] d;
|
||||||
|
}
|
||||||
|
|
||||||
tictoc_finishedIteration_();
|
tictoc_finishedIteration_();
|
||||||
tictoc_print_();
|
tictoc_print_();
|
||||||
|
|
|
@ -151,9 +151,9 @@ void solveStaged(size_t addMutex = 2) {
|
||||||
scheduler.buildGraph(addMutex);
|
scheduler.buildGraph(addMutex);
|
||||||
|
|
||||||
// Do EXACT INFERENCE
|
// Do EXACT INFERENCE
|
||||||
tic_(3,"eliminate");
|
tic_(eliminate);
|
||||||
DiscreteBayesNet::shared_ptr chordal = scheduler.eliminate();
|
DiscreteBayesNet::shared_ptr chordal = scheduler.eliminate();
|
||||||
toc_(3,"eliminate");
|
toc_(eliminate);
|
||||||
|
|
||||||
// find root node
|
// find root node
|
||||||
DiscreteConditional::shared_ptr root = *(chordal->rbegin());
|
DiscreteConditional::shared_ptr root = *(chordal->rbegin());
|
||||||
|
|
|
@ -178,9 +178,9 @@ void solveStaged(size_t addMutex = 2) {
|
||||||
scheduler.buildGraph(addMutex);
|
scheduler.buildGraph(addMutex);
|
||||||
|
|
||||||
// Do EXACT INFERENCE
|
// Do EXACT INFERENCE
|
||||||
tic_(3,"eliminate");
|
tic_(eliminate);
|
||||||
DiscreteBayesNet::shared_ptr chordal = scheduler.eliminate();
|
DiscreteBayesNet::shared_ptr chordal = scheduler.eliminate();
|
||||||
toc_(3,"eliminate");
|
toc_(eliminate);
|
||||||
|
|
||||||
// find root node
|
// find root node
|
||||||
DiscreteConditional::shared_ptr root = *(chordal->rbegin());
|
DiscreteConditional::shared_ptr root = *(chordal->rbegin());
|
||||||
|
|
|
@ -46,11 +46,11 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
cout << "Loading data..." << endl;
|
cout << "Loading data..." << endl;
|
||||||
|
|
||||||
tic_(1, "Find datafile (script only)");
|
tic_(Find_datafile);
|
||||||
string datasetFile = findExampleDataFile("w10000-odom");
|
string datasetFile = findExampleDataFile("w10000-odom");
|
||||||
std::pair<NonlinearFactorGraph::shared_ptr, Values::shared_ptr> data =
|
std::pair<NonlinearFactorGraph::shared_ptr, Values::shared_ptr> data =
|
||||||
load2D(datasetFile);
|
load2D(datasetFile);
|
||||||
toc_(1, "Find datafile (script only)");
|
toc_(Find_datafile);
|
||||||
|
|
||||||
NonlinearFactorGraph measurements = *data.first;
|
NonlinearFactorGraph measurements = *data.first;
|
||||||
Values initial = *data.second;
|
Values initial = *data.second;
|
||||||
|
@ -66,7 +66,7 @@ int main(int argc, char *argv[]) {
|
||||||
NonlinearFactorGraph newFactors;
|
NonlinearFactorGraph newFactors;
|
||||||
|
|
||||||
// Collect measurements and new variables for the current step
|
// Collect measurements and new variables for the current step
|
||||||
tic_(2, "Collect measurements (script only)");
|
tic_(Collect_measurements);
|
||||||
if(step == 1) {
|
if(step == 1) {
|
||||||
// cout << "Initializing " << 0 << endl;
|
// cout << "Initializing " << 0 << endl;
|
||||||
newVariables.insert(0, Pose());
|
newVariables.insert(0, Pose());
|
||||||
|
@ -114,19 +114,19 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
++ nextMeasurement;
|
++ nextMeasurement;
|
||||||
}
|
}
|
||||||
toc_(2, "Collect measurements (script only)");
|
toc_(Collect_measurements);
|
||||||
|
|
||||||
// Update iSAM2
|
// Update iSAM2
|
||||||
tic_(3, "Update ISAM2");
|
tic_(Update_ISAM2);
|
||||||
isam2.update(newFactors, newVariables);
|
isam2.update(newFactors, newVariables);
|
||||||
toc_(3, "Update ISAM2");
|
toc_(Update_ISAM2);
|
||||||
|
|
||||||
if(step % 100 == 0) {
|
if(step % 100 == 0) {
|
||||||
tic_(4, "chi2 (script only)");
|
tic_(chi2);
|
||||||
Values estimate(isam2.calculateEstimate());
|
Values estimate(isam2.calculateEstimate());
|
||||||
double chi2 = chi2_red(isam2.getFactorsUnsafe(), estimate);
|
double chi2 = chi2_red(isam2.getFactorsUnsafe(), estimate);
|
||||||
cout << "chi2 = " << chi2 << endl;
|
cout << "chi2 = " << chi2 << endl;
|
||||||
toc_(4, "chi2 (script only)");
|
toc_(chi2);
|
||||||
}
|
}
|
||||||
|
|
||||||
tictoc_finishedIteration_();
|
tictoc_finishedIteration_();
|
||||||
|
@ -141,9 +141,9 @@ int main(int argc, char *argv[]) {
|
||||||
Marginals marginals(isam2.getFactorsUnsafe(), isam2.calculateEstimate());
|
Marginals marginals(isam2.getFactorsUnsafe(), isam2.calculateEstimate());
|
||||||
int i=0;
|
int i=0;
|
||||||
BOOST_FOREACH(Key key, initial.keys()) {
|
BOOST_FOREACH(Key key, initial.keys()) {
|
||||||
tic_(5, "marginalInformation");
|
tic_(marginalInformation);
|
||||||
Matrix info = marginals.marginalInformation(key);
|
Matrix info = marginals.marginalInformation(key);
|
||||||
toc_(5, "marginalInformation");
|
toc_(marginalInformation);
|
||||||
tictoc_finishedIteration_();
|
tictoc_finishedIteration_();
|
||||||
if(i % 1000 == 0)
|
if(i % 1000 == 0)
|
||||||
tictoc_print_();
|
tictoc_print_();
|
||||||
|
|
Loading…
Reference in New Issue