/* ---------------------------------------------------------------------------- * GTSAM Copyright 2010, Georgia Tech Research Corporation, * Atlanta, Georgia 30332-0415 * All Rights Reserved * Authors: Frank Dellaert, et al. (see THANKS for the full author list) * See LICENSE for the license information * -------------------------------------------------------------------------- */ /** * @file timeSLAMlike.cpp * @brief Times solving of random SLAM-like graphs * @author Richard Roberts * @date Aug 30, 2010 */ #include #include #include #include #include #include #include using namespace gtsam; using namespace std; using namespace boost::lambda; typedef EliminationTree GaussianEliminationTree; static boost::variate_generator > rg(boost::mt19937(), boost::uniform_real<>(0.0, 1.0)); bool _pair_compare(const pair& a1, const pair& a2) { return a1.first < a2.first; } int main(int argc, char *argv[]) { size_t vardim = 3; size_t blockdim = 3; int nVars = 500; size_t blocksPerVar = 5; size_t varsPerBlock = 2; size_t varSpread = 10; size_t nTrials = 10; double blockbuild, blocksolve; cout << "\n" << nVars << " variables of dimension " << vardim << ", " << blocksPerVar << " blocks for each variable, blocks of dimension " << blockdim << " measure " << varsPerBlock << " variables\n"; cout << nTrials << " trials\n"; boost::variate_generator > ri(boost::mt19937(), boost::uniform_int<>(-varSpread, varSpread)); ///////////////////////////////////////////////////////////////////////////// // Timing test with blockwise Gaussian factor graphs { // Build GFG's cout << "Building SLAM-like Gaussian factor graphs... "; cout.flush(); boost::timer timer; timer.restart(); vector blockGfgs; blockGfgs.reserve(nTrials); for(size_t trial=0; trial > terms; terms.reserve(varsPerBlock); if(c == 0 && d == 0) // If it's the first factor, just make a prior terms.push_back(make_pair(0, eye(vardim))); else if(c != 0) { // Generate a random Gaussian factor for(size_t h=0; h nVars-1 || find_if(terms.begin(), terms.end(), boost::bind(&pair::first, boost::lambda::_1) == Index(var)) != terms.end()); Matrix A(blockdim, vardim); for(size_t j=0; j