diff --git a/.cproject b/.cproject index 0f9a11611..efdaf0c8a 100644 --- a/.cproject +++ b/.cproject @@ -21,7 +21,7 @@ - + @@ -149,57 +149,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -644,6 +593,38 @@ true true + + make + -j5 + testBTree.run + true + true + true + + + make + -j5 + testDSF.run + true + true + true + + + make + -j5 + testDSFVector.run + true + true + true + + + make + -j5 + testFixedVector.run + true + true + true + make -j2 @@ -796,18 +777,58 @@ true true - + make -j5 - nonlinear.testValues.run + testValues.run true true true - + make -j5 - nonlinear.testOrdering.run + testOrdering.run + true + true + true + + + make + -j5 + schedulingExample.run + true + true + true + + + make + -j5 + testCSP.run + true + true + true + + + make + -j5 + testScheduler.run + true + true + true + + + make + -j5 + schedulingQuals12.run + true + true + true + + + make + -j5 + testSudoku.run true true true @@ -844,26 +865,10 @@ true true - + make - -j2 - install - true - true - true - - - make - -j2 - check - true - true - true - - - make - -j2 - clean + -j5 + testDiscreteFactor.run true true true @@ -1044,14 +1049,6 @@ true true - - make - -j2 - SimpleRotation.run - true - true - true - make -j2 @@ -1657,82 +1654,82 @@ true true - - make - -j2 - tests/testVectorValues.run - true - true - true - - + make -j5 - linear.testNoiseModel.run + testVector.run true true true - - make - -j2 - tests/testGaussianFactor.run - true - true - true - - - make - -j2 - tests/testHessianFactor.run - true - true - true - - - make - -j2 - tests/testGaussianConditional.run - true - true - true - - - make - -j2 - tests/testGaussianFactorGraph.run - true - true - true - - - make - -j2 - tests/testGaussianJunctionTree.run - true - true - true - - - make - -j2 - tests/testKalmanFilter.run - true - true - true - - - make - -j2 - tests/testGaussianDensity.run - true - true - true - - + make -j5 - linear.testSerializationLinear.run + testVectorValues.run + true + true + true + + + make + -j5 + testNoiseModel.run + true + true + true + + + make + -j5 + testHessianFactor.run + true + true + true + + + make + -j5 + testGaussianConditional.run + true + true + true + + + make + -j5 + testGaussianFactorGraph.run + true + true + true + + + make + -j5 + testGaussianJunctionTree.run + true + true + true + + + make + -j5 + testKalmanFilter.run + true + true + true + + + make + -j5 + testGaussianDensity.run + true + true + true + + + make + -j5 + testSerializationLinear.run true true true @@ -1817,6 +1814,14 @@ true true + + make + -j5 + UGM_small.run + true + true + true + make -j2 @@ -2031,18 +2036,58 @@ true true - + make - -j8 - testMarginals.run + -j5 + wrap_gtsam true true true - + make - -j8 - testNonlinearOptimizer.run + VERBOSE=1 + wrap_gtsam + true + false + true + + + cpack + + -G DEB + true + false + true + + + cpack + + -G RPM + true + false + true + + + cpack + + -G TGZ + true + false + true + + + cpack + + --config CPackSourceConfig.cmake + true + false + true + + + make + -j5 + check.discrete true true true diff --git a/CMakeLists.txt b/CMakeLists.txt index 22713c6a4..e6c9bc422 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,8 @@ project(GTSAM CXX C) cmake_minimum_required(VERSION 2.6) # Set the version number for the library -set (GTSAM_VERSION_MAJOR 1) -set (GTSAM_VERSION_MINOR 9) +set (GTSAM_VERSION_MAJOR 2) +set (GTSAM_VERSION_MINOR 0) set (GTSAM_VERSION_PATCH 0) # Set the default install path to home diff --git a/README b/README index 595bbccf4..d7a2184e2 100644 --- a/README +++ b/README @@ -1,7 +1,18 @@ README - Georgia Tech Smoothing and Mapping library --------------------------------------------------- -What is GTSAM ? +Quickstart + +In the root library folder execute: + +$] mkdir build +$] cd build +$] cmake .. +$] make check (optional, runs unit tests) +$] make install + +--------------------------------------------------- +What is GTSAM? GTSAM is a library of C++ classes that implement smoothing and mapping (SAM) in robotics and vision, using factor graphs and Bayes @@ -11,10 +22,7 @@ What is GTSAM ? GTSAM is not (yet) open source: See COPYING & LICENSE Please see USAGE for an example on how to use GTSAM. -The core GTSAM code within the folder gtsam, with source, headers, and -unit tests. After building, this will generate a single library "libgtsam" - -The libgtsam code is organized according to the following directory structure: +The library is organized according to the following directory structure: 3rdparty local copies of third party libraries - Eigen3 and CCOLAMD base provides some base Math and data structures, as well as test-related utilities @@ -24,12 +32,6 @@ The libgtsam code is organized according to the following directory structure: nonlinear non-linear factor graphs and non-linear optimization slam SLAM and visual SLAM application code -Additionally, in the SVN development version of GTSAM, there is an area for -unstable code directly under development in the folder gtsam_unstable, which contains -a directory structuring mirroring the libgtsam structure as necessary. This section produces -a single library "libgtsam_unstable". Building of gtsam_unstable is disabled by default, see -CMake configuration options for information on enabling building. - This library contains unchanged copies of two third party libraries, with documentation of licensing in LICENSE and as follows: - CCOLAMD 2.73: Tim Davis' constrained column approximate minimum degree ordering library @@ -38,26 +40,19 @@ of licensing in LICENSE and as follows: - Eigen 3.0.5: General C++ matrix and linear algebra library - Licenced under LGPL v3, provided in gtsam/3rdparty/Eigen/COPYING.LGPL -After this is built, you can also run the more involved tests, which test the entire library: - - tests More involved unit tests that depend on slam - examples Demo applications as a tutorial for using gtsam - cmake CMake scripts used within the library, as well as for finding GTSAM by dependent projects -Finally, there are some local libraries built needed in the rest of the code: +There are two supporting libraries: CppUnitLite unit test library customized for use with gtsam wrap code generation utility for the Matlab interface to gtsam -Important Installation Notes Specific to GTSAM ----------------------------------------------- +Important Installation Notes +---------------------------- 1) GTSAM requires the following libraries to be installed on your system: - BOOST version 1.40 or greater (install through Linux repositories or MacPorts) - -GTSAM uses CMake (http://www.cmake.org/) for build automation - - Installed cmake version must be 2.6 or higher + - Cmake version 2.6 or higher Tested compilers - gcc @@ -65,44 +60,20 @@ Tested compilers - OSX gcc 2) -GTSAM makes extensive use of debug assertions, even for checking input of -the functions you will call. These assertions are disabled when NDEBUG is -defined. Thus, we strongly recommend compiling GTSAM and your own code without -this symbol during debugging. - -After debugging, GTSAM will run much faster when compiled with NDEBUG defined, -so that debug checks are disabled. - -Another useful debugging symbol is _GLIBCXX_DEBUG, which enables debug checks -and safe containers in the standard C++ library and makes problems much easier -to find. - -NOTE: The native Snow Leopard g++ compiler/library contains a bug that makes -it impossible to use _GLIBCXX_DEBUG. MacPorts g++ compilers do work with it though. - -NOTE: If _GLIBCXX_DEBUG is used to compile gtsam, anything that links against -gtsam will need to be compiled with _GLIBCXX_DEBUG as well, due to the use of -header-only Eigen. +GTSAM makes extensive use of debug assertions, and we highly recommend you work +in Debug mode while developing (enabled by default). Likewise, it is imperative +that you switch to release mode when running finished code and for timing. GTSAM +will run up to 10x faster in Release mode! See the end of this document for +additional debugging tips. 3) -GTSAM has been written to support the creation of API documentation using -doxygen. To create html documentation for GTSAM, run the the script +GTSAM has Doxygen documentation. To generate, run the the script makedoc.sh. 4) -For developers, we primarily use the Eclipse IDE for development, and provide -an Eclipse project file with a variety of make targets to build and debug -from within Eclipse. - -5) -After installing prerequisites for building GTSAM, you can configure and build -GTSAM using CMake with the default options with the quickstart options. For -details on the full functionality of CMake, see the CMake documentation. - -- CMake Quickstart -Installs to the default system install path and builds all components. From a terminal, -starting in the root library folder, execute commands as follows for an out-of-source -build: +The instructions below install the library to the default system install path and +build all components. From a terminal, starting in the root library folder, +execute commands as follows for an out-of-source build: $] mkdir build $] cd build @@ -110,47 +81,33 @@ $] cmake .. $] make check (optional, runs unit tests) $] make install -This will build the library and unit tests, run all of the unit tests, and then install -the library itself, as well as the Matlab toolbox. +This will build the library and unit tests, run all of the unit tests, +and then install the library itself. -- Additional CMake Options and Details +- CMake Configuration Options and Details -The cmake scripts force a out-of-source build, so inside gtsam, -create a new folder called "build", and run cmake. From the command line: +GTSAM has a number of options that can be configured, which is best done with +one of the following: -$] mkdir build -$] cd build -$] cmake .. + ccmake the curses GUI for cmake + cmake-gui a real GUI for cmake -Note the ".." after the cmake command - it tells cmake to look for the -root CMakeLists.txt file in the root gtsam folder instead of in the build folder. -This is a necessary argument for starting cmake in all of its variations. -There a few ways of actually doing the configuration to make adjusting options easier. +Important Options: - cmake the regular command-line version of cmake, allows configuration with scripts - ccmake the curses GUI for cmake, which lets you see the various options, change them, and run configuration. - cmake-gui a real GUI for cmake, which has a similar interface to ccmake, but with easier controls. +CMAKE_BUILD_TYPE: We support several build configurations for GTSAM (case insensitive) + Debug (default) All error checking options on, no optimization. Use for development. + Release Optimizations turned on, no debug symbols. + Timing Adds ENABLE_TIMING flag to provide statistics on operation + Profiling Standard configuration for use during profiling + RelWithDebInfo Same as Release, but with the -g flag for debug symbols -Note that during configuration, the settings get cached so if you rerun cmake later, -it will keep your previous settings. In particular, you can use the "cmake" build target -within the Eclipse project to update the configuration, which will be necessary -when file structures change. - -While it is possible to use command-line arguments to cmake to change configuration -options, it is usually easier to use cmake-gui or ccmake to set parameters and use the other flags. - -Important CMake configuration options: - -CMAKE_INSTALL_PREFIX: this is the folder where installed files will go, and for -our development purposes, should be set to the home folder, like so +CMAKE_INSTALL_PREFIX: The install folder. The default is typically /usr/local/ +To configure to install to your home directory, you could execute: $] cmake -DCMAKE_INSTALL_PREFIX:PATH=$HOME .. -GTSAM_TOOLBOX_INSTALL_PATH: When the library is installed with "make install", -the generated matlab toolbox code (created by wrap) gets installed as well in -this path. For example, use "/home/username/borg/toolbox" to install the -toolbox in your borg/toolbox folder. The matlab toolbox will get installed -into borg/toolbox/gtsam. -$] cmake -DGTSAM_TOOLBOX_INSTALL_PATH:PATH=$HOME/borg/toolbox .. +GTSAM_TOOLBOX_INSTALL_PATH: The Matlab toolbox will be installed in a subdirectory +of this folder, called 'gtsam'. +$] cmake -DGTSAM_TOOLBOX_INSTALL_PATH:PATH=$HOME/toolbox .. GTSAM_BUILD_CONVENIENCE_LIBRARIES: This is a build option to allow for tests in subfolders to be linked against convenience libraries rather than the full libgtsam. @@ -176,35 +133,25 @@ $] cmake -DGTSAM_BUILD_UNSTABLE:OPTION=ON .. folder called "gtsam_unstable". OFF (Default) If disabled, no gtsam_unstable code will be included in build or install. -CMAKE_BUILD_TYPE: We support several build configurations for GTSAM (case insensitive) - Debug (default) All error checking options on, no optimization. Use for development. - Release Optimizations turned on, no debug symbols. - Timing Adds ENABLE_TIMING flag to provide statistics on operation - Profiling Standard configuration for use during profiling - RelWithDebInfo Same as Release, but with the -g flag for debug symbols - - -Build and Install - -After configuring, you use make just as you normally would, and the all, check and -install targets work as in autotools. Note that all targets are at the root level -of the build folder. You can also build any of the subfolders individually as -individual targets, such as "make geometry slam" to build both geometry and slam. -Running "make install" will install the library to the prefix location. - Check -As with autotools, "make check" will build and run all of the tests. Note that the -tests will only be built when using the "check" targets, to prevent "make install" from -building the tests unnecessarily. You can also run "make timing" to build all of -the timing scripts. To run check on a particular subsection, there is a convention -of "make check.[subfolder]", so to run just the geometry tests, -run "make check.geometry". Individual tests can be run by appending ".run" to the -name of the test, for example, to run testMatrix, run "make testMatrix.run". +"make check" will build and run all of the tests. Note that the tests will only be +built when using the "check" targets, to prevent "make install" from building the tests +unnecessarily. You can also run "make timing" to build all of the timing scripts. +To run check on a particular module only, run "make check.[subfolder]", so to run +just the geometry tests, run "make check.geometry". Individual tests can be run by +appending ".run" to the name of the test, for example, to run testMatrix, run +"make testMatrix.run". -The make target "wrap" will build the wrap binary, and the "wrap_gtsam" target will -generate code for the toolbox. By default, the toolbox will be created and installed -by the install target for the library. To change the install folder for the toolbox, -choose a different setting during cmake settings for the toolbox install path. +Debugging tips: +Another useful debugging symbol is _GLIBCXX_DEBUG, which enables debug checks +and safe containers in the standard C++ library and makes problems much easier +to find. +NOTE: The native Snow Leopard g++ compiler/library contains a bug that makes +it impossible to use _GLIBCXX_DEBUG. MacPorts g++ compilers do work with it though. + +NOTE: If _GLIBCXX_DEBUG is used to compile gtsam, anything that links against +gtsam will need to be compiled with _GLIBCXX_DEBUG as well, due to the use of +header-only Eigen. diff --git a/gtsam/CMakeLists.txt b/gtsam/CMakeLists.txt index dcbd10075..b3e639917 100644 --- a/gtsam/CMakeLists.txt +++ b/gtsam/CMakeLists.txt @@ -1,5 +1,6 @@ -# Build full gtsam library as a single library -# and also build tests +# We split the library in to separate subfolders, each containing +# tests, timing, and an optional convenience library. +# The following variable is the master list of subdirs to add set (gtsam_subdirs base geometry @@ -26,12 +27,14 @@ if (GTSAM_BUILD_CONVENIENCE_LIBRARIES) add_library(ccolamd STATIC ${3rdparty_srcs}) endif() +# To exclude a source from the library build (in any subfolder) +# Add the full name to this list, as in the following example # Sources to remove from builds -set (excluded_sources - "${CMAKE_CURRENT_SOURCE_DIR}/discrete/TypedDiscreteFactor.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/discrete/TypedDiscreteFactorGraph.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/discrete/parseUAI.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/discrete/PotentialTable.cpp") +set (excluded_sources "") +# "${CMAKE_CURRENT_SOURCE_DIR}/discrete/TypedDiscreteFactor.cpp" +# "${CMAKE_CURRENT_SOURCE_DIR}/discrete/TypedDiscreteFactorGraph.cpp" +# "${CMAKE_CURRENT_SOURCE_DIR}/discrete/parseUAI.cpp" +# "${CMAKE_CURRENT_SOURCE_DIR}/discrete/PotentialTable.cpp") if(GTSAM_USE_QUATERNIONS) set(excluded_sources ${excluded_sources} "${CMAKE_CURRENT_SOURCE_DIR}/geometry/Rot3M.cpp") @@ -55,7 +58,8 @@ foreach(subdir ${gtsam_subdirs}) add_subdirectory(${subdir}) endforeach(subdir) -# assemble gtsam components +# To add additional sources to gtsam when building the full library (static or shared) +# Add the subfolder with _srcs appended to the end to this list set(gtsam_srcs ${3rdparty_srcs} ${base_srcs} diff --git a/gtsam/discrete/AlgebraicDecisionTree.h b/gtsam/discrete/AlgebraicDecisionTree.h index 029223ef3..8afb2d617 100644 --- a/gtsam/discrete/AlgebraicDecisionTree.h +++ b/gtsam/discrete/AlgebraicDecisionTree.h @@ -1,4 +1,15 @@ -/* +/* ---------------------------------------------------------------------------- + + * 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 AlgebraicDecisionTree.h * @brief Algebraic Decision Trees * @author Frank Dellaert diff --git a/gtsam/discrete/Assignment.h b/gtsam/discrete/Assignment.h index 0150f6ff9..06e2ac137 100644 --- a/gtsam/discrete/Assignment.h +++ b/gtsam/discrete/Assignment.h @@ -1,4 +1,15 @@ -/* +/* ---------------------------------------------------------------------------- + + * 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 Assignment.h * @brief An assignment from labels to a discrete value index (size_t) * @author Frank Dellaert diff --git a/gtsam/discrete/CMakeLists.txt b/gtsam/discrete/CMakeLists.txt index d45340990..9e4647f80 100644 --- a/gtsam/discrete/CMakeLists.txt +++ b/gtsam/discrete/CMakeLists.txt @@ -13,24 +13,13 @@ set (discrete_local_libs ) # Exclude tests that don't work -set (discrete_excluded_tests -"${CMAKE_CURRENT_SOURCE_DIR}/tests/testTypedDiscreteFactor.cpp" -"${CMAKE_CURRENT_SOURCE_DIR}/tests/testTypedDiscreteFactorGraph.cpp" -"${CMAKE_CURRENT_SOURCE_DIR}/tests/testPotentialTable.cpp") +set (discrete_excluded_tests "") # Add all tests if (GTSAM_BUILD_TESTS) gtsam_add_subdir_tests(discrete "${discrete_local_libs}" "gtsam-static" "${discrete_excluded_tests}") endif() -# add examples -foreach(example schedulingExample schedulingQuals12) - add_executable(${example} "examples/${example}.cpp") - add_dependencies(${example} gtsam-static) - target_link_libraries(${example} gtsam-static) - add_custom_target(${example}.run ${EXECUTABLE_OUTPUT_PATH}${example} ${ARGN}) -endforeach(example) - # Build timing scripts #if (GTSAM_BUILD_TIMING) # gtsam_add_timing(discrete "${discrete_local_libs}") diff --git a/gtsam/discrete/DecisionTree-inl.h b/gtsam/discrete/DecisionTree-inl.h index 867a9c824..1fa750ace 100644 --- a/gtsam/discrete/DecisionTree-inl.h +++ b/gtsam/discrete/DecisionTree-inl.h @@ -1,4 +1,15 @@ -/* +/* ---------------------------------------------------------------------------- + + * 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 DecisionTree.h * @brief Decision Tree for use in DiscreteFactors * @author Frank Dellaert diff --git a/gtsam/discrete/DecisionTree.h b/gtsam/discrete/DecisionTree.h index 003656945..8fabd6e82 100644 --- a/gtsam/discrete/DecisionTree.h +++ b/gtsam/discrete/DecisionTree.h @@ -1,4 +1,15 @@ -/* +/* ---------------------------------------------------------------------------- + + * 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 DecisionTree.h * @brief Decision Tree for use in DiscreteFactors * @author Frank Dellaert diff --git a/gtsam/discrete/DecisionTreeFactor.cpp b/gtsam/discrete/DecisionTreeFactor.cpp index d66d16d99..23b761b3b 100644 --- a/gtsam/discrete/DecisionTreeFactor.cpp +++ b/gtsam/discrete/DecisionTreeFactor.cpp @@ -1,6 +1,17 @@ -/* - * DecisionTreeFactor.cpp - * @brief: discrete factor +/* ---------------------------------------------------------------------------- + + * 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 DecisionTreeFactor.cpp + * @brief discrete factor * @date Feb 14, 2011 * @author Duy-Nguyen Ta * @author Frank Dellaert diff --git a/gtsam/discrete/DecisionTreeFactor.h b/gtsam/discrete/DecisionTreeFactor.h index e98c7020b..c63e59517 100644 --- a/gtsam/discrete/DecisionTreeFactor.h +++ b/gtsam/discrete/DecisionTreeFactor.h @@ -1,8 +1,19 @@ -/* - * DecisionTreeFactor.h - * - * @date Feb 14, 2011 - * @author Duy-Nguyen Ta +/* ---------------------------------------------------------------------------- + + * 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 DecisionTreeFactor.h + * @date Feb 14, 2011 + * @author Duy-Nguyen Ta + * @author Frank Dellaert */ #pragma once @@ -116,28 +127,6 @@ namespace gtsam { */ shared_ptr combine(size_t nrFrontals, ADT::Binary op) const; - /* - * Ensure Arc-consistency - * @param j domain to be checked - * @param domains all other domains - */ - /// - bool ensureArcConsistency(size_t j, std::vector& domains) const { -// throw std::runtime_error( -// "DecisionTreeFactor::ensureArcConsistency not implemented"); - return false; - } - - /// Partially apply known values - virtual DiscreteFactor::shared_ptr partiallyApply(const Values&) const { - throw std::runtime_error("DecisionTreeFactor::partiallyApply not implemented"); - } - - /// Partially apply known values, domain version - virtual DiscreteFactor::shared_ptr partiallyApply( - const std::vector&) const { - throw std::runtime_error("DecisionTreeFactor::partiallyApply not implemented"); - } /// @} }; // DecisionTreeFactor diff --git a/gtsam/discrete/DiscreteBayesNet.cpp b/gtsam/discrete/DiscreteBayesNet.cpp index c7f09d3c2..67f4e4333 100644 --- a/gtsam/discrete/DiscreteBayesNet.cpp +++ b/gtsam/discrete/DiscreteBayesNet.cpp @@ -1,9 +1,19 @@ -/* - * DiscreteBayesNet.cpp - * - * @date Feb 15, 2011 - * @author Duy-Nguyen Ta - * @author Frank Dellaert +/* ---------------------------------------------------------------------------- + + * 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 DiscreteBayesNet.cpp + * @date Feb 15, 2011 + * @author Duy-Nguyen Ta + * @author Frank Dellaert */ #include diff --git a/gtsam/discrete/DiscreteBayesNet.h b/gtsam/discrete/DiscreteBayesNet.h index 418a7aa2d..a7c35e135 100644 --- a/gtsam/discrete/DiscreteBayesNet.h +++ b/gtsam/discrete/DiscreteBayesNet.h @@ -1,8 +1,18 @@ -/* - * DiscreteBayesNet.h - * - * @date Feb 15, 2011 - * @author Duy-Nguyen Ta +/* ---------------------------------------------------------------------------- + + * 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 DiscreteBayesNet.h + * @date Feb 15, 2011 + * @author Duy-Nguyen Ta */ #pragma once diff --git a/gtsam/discrete/DiscreteConditional.cpp b/gtsam/discrete/DiscreteConditional.cpp index 4791af6e8..73649dce6 100644 --- a/gtsam/discrete/DiscreteConditional.cpp +++ b/gtsam/discrete/DiscreteConditional.cpp @@ -1,6 +1,16 @@ -/* - * DiscreteConditional.cpp - * +/* ---------------------------------------------------------------------------- + + * 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 DiscreteConditional.cpp * @date Feb 14, 2011 * @author Duy-Nguyen Ta * @author Frank Dellaert diff --git a/gtsam/discrete/DiscreteConditional.h b/gtsam/discrete/DiscreteConditional.h index a11a6368f..f6603c195 100644 --- a/gtsam/discrete/DiscreteConditional.h +++ b/gtsam/discrete/DiscreteConditional.h @@ -1,6 +1,16 @@ -/* - * DiscreteConditional.h - * +/* ---------------------------------------------------------------------------- + + * 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 DiscreteConditional.h * @date Feb 14, 2011 * @author Duy-Nguyen Ta * @author Frank Dellaert diff --git a/gtsam/discrete/DiscreteFactor.cpp b/gtsam/discrete/DiscreteFactor.cpp index 6112cfea9..caec9788f 100644 --- a/gtsam/discrete/DiscreteFactor.cpp +++ b/gtsam/discrete/DiscreteFactor.cpp @@ -1,6 +1,17 @@ -/* - * DiscreteFactor.cpp - * @brief: discrete factor +/* ---------------------------------------------------------------------------- + + * 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 DiscreteFactor.cpp + * @brief discrete factor * @date Feb 14, 2011 * @author Duy-Nguyen Ta * @author Frank Dellaert diff --git a/gtsam/discrete/DiscreteFactor.h b/gtsam/discrete/DiscreteFactor.h index a66d5b522..8152ff726 100644 --- a/gtsam/discrete/DiscreteFactor.h +++ b/gtsam/discrete/DiscreteFactor.h @@ -1,8 +1,19 @@ -/* - * DiscreteFactor.h - * +/* ---------------------------------------------------------------------------- + + * 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 DiscreteFactor.h * @date Feb 14, 2011 * @author Duy-Nguyen Ta + * @author Frank Dellaert */ #pragma once @@ -14,7 +25,6 @@ namespace gtsam { class DecisionTreeFactor; class DiscreteConditional; - class Domain; /** * Base class for discrete probabilistic factors @@ -88,19 +98,6 @@ namespace gtsam { virtual operator DecisionTreeFactor() const = 0; - /* - * Ensure Arc-consistency - * @param j domain to be checked - * @param domains all other domains - */ - virtual bool ensureArcConsistency(size_t j, std::vector& domains) const = 0; - - /// Partially apply known values - virtual shared_ptr partiallyApply(const Values&) const = 0; - - - /// Partially apply known values, domain version - virtual shared_ptr partiallyApply(const std::vector&) const = 0; /// @} }; // DiscreteFactor diff --git a/gtsam/discrete/DiscreteFactorGraph.cpp b/gtsam/discrete/DiscreteFactorGraph.cpp index 479bcc45a..f5fc7533d 100644 --- a/gtsam/discrete/DiscreteFactorGraph.cpp +++ b/gtsam/discrete/DiscreteFactorGraph.cpp @@ -1,8 +1,19 @@ -/* - * DiscreteFactorGraph.cpp - * +/* ---------------------------------------------------------------------------- + + * 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 DiscreteFactorGraph.cpp * @date Feb 14, 2011 * @author Duy-Nguyen Ta + * @author Frank Dellaert */ //#define ENABLE_TIMING diff --git a/gtsam/discrete/DiscreteFactorGraph.h b/gtsam/discrete/DiscreteFactorGraph.h index 83a065361..eefdfaf1d 100644 --- a/gtsam/discrete/DiscreteFactorGraph.h +++ b/gtsam/discrete/DiscreteFactorGraph.h @@ -1,8 +1,19 @@ -/* - * DiscreteFactorGraph.h - * - * @date Feb 14, 2011 - * @author Duy-Nguyen Ta +/* ---------------------------------------------------------------------------- + + * 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 DiscreteFactorGraph.h + * @date Feb 14, 2011 + * @author Duy-Nguyen Ta + * @author Frank Dellaert */ #pragma once diff --git a/gtsam/discrete/DiscreteKey.cpp b/gtsam/discrete/DiscreteKey.cpp index 01b025d80..9db8bee79 100644 --- a/gtsam/discrete/DiscreteKey.cpp +++ b/gtsam/discrete/DiscreteKey.cpp @@ -1,5 +1,16 @@ -/* - * DiscreteKey.h +/* ---------------------------------------------------------------------------- + + * 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 DiscreteKey.h * @brief specialized key for discrete variables * @author Frank Dellaert * @date Feb 28, 2011 diff --git a/gtsam/discrete/DiscreteKey.h b/gtsam/discrete/DiscreteKey.h index 87e6e96a6..488240286 100644 --- a/gtsam/discrete/DiscreteKey.h +++ b/gtsam/discrete/DiscreteKey.h @@ -1,5 +1,16 @@ -/* - * DiscreteKey.h +/* ---------------------------------------------------------------------------- + + * 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 DiscreteKey.h * @brief specialized key for discrete variables * @author Frank Dellaert * @date Feb 28, 2011 diff --git a/gtsam/discrete/DiscreteSequentialSolver.cpp b/gtsam/discrete/DiscreteSequentialSolver.cpp index b4d16a24f..1ca00875a 100644 --- a/gtsam/discrete/DiscreteSequentialSolver.cpp +++ b/gtsam/discrete/DiscreteSequentialSolver.cpp @@ -1,13 +1,23 @@ -/* - * DiscreteSequentialSolver.cpp - * - * @date Feb 16, 2011 - * @author Duy-Nguyen Ta +/* ---------------------------------------------------------------------------- + + * 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 DiscreteSequentialSolver.cpp + * @date Feb 16, 2011 + * @author Duy-Nguyen Ta + * @author Frank Dellaert */ //#define ENABLE_TIMING #include -#include #include #include diff --git a/gtsam/discrete/DiscreteSequentialSolver.h b/gtsam/discrete/DiscreteSequentialSolver.h index 60512b873..c453f5b96 100644 --- a/gtsam/discrete/DiscreteSequentialSolver.h +++ b/gtsam/discrete/DiscreteSequentialSolver.h @@ -1,8 +1,19 @@ -/* - * DiscreteSequentialSolver.h - * - * @date Feb 16, 2011 - * @author Duy-Nguyen Ta +/* ---------------------------------------------------------------------------- + + * 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 DiscreteSequentialSolver.h + * @date Feb 16, 2011 + * @author Duy-Nguyen Ta + * @author Frank Dellaert */ #pragma once diff --git a/gtsam/discrete/Potentials.cpp b/gtsam/discrete/Potentials.cpp index 2684e6cce..ac6ecde10 100644 --- a/gtsam/discrete/Potentials.cpp +++ b/gtsam/discrete/Potentials.cpp @@ -1,5 +1,16 @@ -/* - * Potentials.cpp +/* ---------------------------------------------------------------------------- + + * 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 Potentials.cpp * @date March 24, 2011 * @author Frank Dellaert */ diff --git a/gtsam/discrete/Potentials.h b/gtsam/discrete/Potentials.h index 9468745e1..8a8c2e3bc 100644 --- a/gtsam/discrete/Potentials.h +++ b/gtsam/discrete/Potentials.h @@ -1,5 +1,16 @@ -/* - * Potentials.h +/* ---------------------------------------------------------------------------- + + * 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 Potentials.h * @date March 24, 2011 * @author Frank Dellaert */ diff --git a/gtsam/discrete/Signature.cpp b/gtsam/discrete/Signature.cpp index 4d808543a..ee7c1e59a 100644 --- a/gtsam/discrete/Signature.cpp +++ b/gtsam/discrete/Signature.cpp @@ -1,7 +1,18 @@ -/* - * Signature.cpp - * @brief: signatures for conditional densities - * @author: Frank dellaert +/* ---------------------------------------------------------------------------- + + * 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 Signature.cpp + * @brief signatures for conditional densities + * @author Frank dellaert * @date Feb 27, 2011 */ diff --git a/gtsam/discrete/Signature.h b/gtsam/discrete/Signature.h index 84d34c1fa..873365c24 100644 --- a/gtsam/discrete/Signature.h +++ b/gtsam/discrete/Signature.h @@ -1,7 +1,18 @@ -/* - * Signature.h - * @brief: signatures for conditional densities - * @author: Frank dellaert +/* ---------------------------------------------------------------------------- + + * 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 Signature.h + * @brief signatures for conditional densities + * @author Frank dellaert * @date Feb 27, 2011 */ diff --git a/gtsam/discrete/RefCounted.cpp b/gtsam/unstable/base/RefCounted.cpp similarity index 100% rename from gtsam/discrete/RefCounted.cpp rename to gtsam/unstable/base/RefCounted.cpp diff --git a/gtsam/discrete/RefCounted.h b/gtsam/unstable/base/RefCounted.h similarity index 100% rename from gtsam/discrete/RefCounted.h rename to gtsam/unstable/base/RefCounted.h diff --git a/gtsam/discrete/PotentialTable.cpp b/gtsam/unstable/discrete/PotentialTable.cpp similarity index 100% rename from gtsam/discrete/PotentialTable.cpp rename to gtsam/unstable/discrete/PotentialTable.cpp diff --git a/gtsam/discrete/PotentialTable.h b/gtsam/unstable/discrete/PotentialTable.h similarity index 100% rename from gtsam/discrete/PotentialTable.h rename to gtsam/unstable/discrete/PotentialTable.h diff --git a/gtsam/discrete/TypedDiscreteFactor.cpp b/gtsam/unstable/discrete/TypedDiscreteFactor.cpp similarity index 97% rename from gtsam/discrete/TypedDiscreteFactor.cpp rename to gtsam/unstable/discrete/TypedDiscreteFactor.cpp index 86f902e89..51f3ff791 100644 --- a/gtsam/discrete/TypedDiscreteFactor.cpp +++ b/gtsam/unstable/discrete/TypedDiscreteFactor.cpp @@ -5,10 +5,10 @@ * @date Mar 5, 2011 */ -#include -#include +#include +#include #include -#include +#include using namespace std; diff --git a/gtsam/discrete/TypedDiscreteFactor.h b/gtsam/unstable/discrete/TypedDiscreteFactor.h similarity index 96% rename from gtsam/discrete/TypedDiscreteFactor.h rename to gtsam/unstable/discrete/TypedDiscreteFactor.h index 3d9fd6ee6..e6a8b2f32 100644 --- a/gtsam/discrete/TypedDiscreteFactor.h +++ b/gtsam/unstable/discrete/TypedDiscreteFactor.h @@ -7,10 +7,10 @@ #pragma once -#include -#include #include -#include +#include +#include +#include namespace gtsam { diff --git a/gtsam/discrete/TypedDiscreteFactorGraph.cpp b/gtsam/unstable/discrete/TypedDiscreteFactorGraph.cpp similarity index 97% rename from gtsam/discrete/TypedDiscreteFactorGraph.cpp rename to gtsam/unstable/discrete/TypedDiscreteFactorGraph.cpp index 2f8c2d22b..65ffe2cc8 100644 --- a/gtsam/discrete/TypedDiscreteFactorGraph.cpp +++ b/gtsam/unstable/discrete/TypedDiscreteFactorGraph.cpp @@ -5,16 +5,15 @@ * @date Mar 1, 2011 */ +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include - -#include using namespace std; diff --git a/gtsam/discrete/TypedDiscreteFactorGraph.h b/gtsam/unstable/discrete/TypedDiscreteFactorGraph.h similarity index 95% rename from gtsam/discrete/TypedDiscreteFactorGraph.h rename to gtsam/unstable/discrete/TypedDiscreteFactorGraph.h index 010113bda..d466358f8 100644 --- a/gtsam/discrete/TypedDiscreteFactorGraph.h +++ b/gtsam/unstable/discrete/TypedDiscreteFactorGraph.h @@ -8,10 +8,10 @@ #pragma once +#include +#include #include #include -#include -#include namespace gtsam { diff --git a/gtsam/discrete/parseUAI.cpp b/gtsam/unstable/discrete/parseUAI.cpp similarity index 100% rename from gtsam/discrete/parseUAI.cpp rename to gtsam/unstable/discrete/parseUAI.cpp diff --git a/gtsam/discrete/parseUAI.h b/gtsam/unstable/discrete/parseUAI.h similarity index 100% rename from gtsam/discrete/parseUAI.h rename to gtsam/unstable/discrete/parseUAI.h diff --git a/gtsam/discrete/tests/testPotentialTable.cpp b/gtsam/unstable/discrete/tests/testPotentialTable.cpp similarity index 100% rename from gtsam/discrete/tests/testPotentialTable.cpp rename to gtsam/unstable/discrete/tests/testPotentialTable.cpp diff --git a/gtsam/discrete/tests/testTypedDiscreteFactor.cpp b/gtsam/unstable/discrete/tests/testTypedDiscreteFactor.cpp similarity index 96% rename from gtsam/discrete/tests/testTypedDiscreteFactor.cpp rename to gtsam/unstable/discrete/tests/testTypedDiscreteFactor.cpp index af69eab41..6f90dcb22 100644 --- a/gtsam/discrete/tests/testTypedDiscreteFactor.cpp +++ b/gtsam/unstable/discrete/tests/testTypedDiscreteFactor.cpp @@ -5,13 +5,12 @@ * @date Mar 5, 2011 */ +#include +#include +#include #include using namespace boost::assign; -#include -#include -#include - using namespace std; using namespace gtsam; diff --git a/gtsam/discrete/tests/testTypedDiscreteFactorGraph.cpp b/gtsam/unstable/discrete/tests/testTypedDiscreteFactorGraph.cpp similarity index 96% rename from gtsam/discrete/tests/testTypedDiscreteFactorGraph.cpp rename to gtsam/unstable/discrete/tests/testTypedDiscreteFactorGraph.cpp index 90c4617ba..c0244ec88 100644 --- a/gtsam/discrete/tests/testTypedDiscreteFactorGraph.cpp +++ b/gtsam/unstable/discrete/tests/testTypedDiscreteFactorGraph.cpp @@ -6,16 +6,9 @@ * @date Feb 14, 2011 */ -//#include -//#include - -#include +#include #include -//#include -//#include - -#include -//#include +#include using namespace std; using namespace gtsam; diff --git a/gtsam/discrete/tests/testTypedDiscreteVariable.cpp b/gtsam/unstable/discrete/tests/testTypedDiscreteVariable.cpp similarity index 100% rename from gtsam/discrete/tests/testTypedDiscreteVariable.cpp rename to gtsam/unstable/discrete/tests/testTypedDiscreteVariable.cpp diff --git a/gtsam_unstable/CMakeLists.txt b/gtsam_unstable/CMakeLists.txt index 9e1daf24b..f7563f8ff 100644 --- a/gtsam_unstable/CMakeLists.txt +++ b/gtsam_unstable/CMakeLists.txt @@ -2,6 +2,7 @@ # and also build tests set (gtsam_unstable_subdirs base + discrete dynamics slam ) diff --git a/gtsam/discrete/AllDiff.cpp b/gtsam_unstable/discrete/AllDiff.cpp similarity index 93% rename from gtsam/discrete/AllDiff.cpp rename to gtsam_unstable/discrete/AllDiff.cpp index 064e0d1c8..46efd4499 100644 --- a/gtsam/discrete/AllDiff.cpp +++ b/gtsam_unstable/discrete/AllDiff.cpp @@ -5,8 +5,8 @@ * @author Frank Dellaert */ -#include -#include +#include +#include #include #include @@ -14,7 +14,7 @@ namespace gtsam { /* ************************************************************************* */ AllDiff::AllDiff(const DiscreteKeys& dkeys) : - DiscreteFactor(dkeys.indices()) { + Constraint(dkeys.indices()) { BOOST_FOREACH(const DiscreteKey& dkey, dkeys) cardinalities_.insert(dkey); } @@ -84,7 +84,7 @@ namespace gtsam { } /* ************************************************************************* */ - DiscreteFactor::shared_ptr AllDiff::partiallyApply(const Values& values) const { + Constraint::shared_ptr AllDiff::partiallyApply(const Values& values) const { DiscreteKeys newKeys; // loop over keys and add them only if they do not appear in values BOOST_FOREACH(Index k, keys_) @@ -95,7 +95,7 @@ namespace gtsam { } /* ************************************************************************* */ - DiscreteFactor::shared_ptr AllDiff::partiallyApply( + Constraint::shared_ptr AllDiff::partiallyApply( const std::vector& domains) const { DiscreteFactor::Values known; BOOST_FOREACH(Index k, keys_) { diff --git a/gtsam/discrete/AllDiff.h b/gtsam_unstable/discrete/AllDiff.h similarity index 86% rename from gtsam/discrete/AllDiff.h rename to gtsam_unstable/discrete/AllDiff.h index 846dc335b..4f4e10511 100644 --- a/gtsam/discrete/AllDiff.h +++ b/gtsam_unstable/discrete/AllDiff.h @@ -7,8 +7,8 @@ #pragma once +#include #include -#include namespace gtsam { @@ -19,7 +19,7 @@ namespace gtsam { * for each variable we have a Index and an Index. In this factor, we * keep the Indices locally, and the Indices are stored in IndexFactor. */ - class AllDiff: public DiscreteFactor { + class AllDiff: public Constraint { std::map cardinalities_; @@ -55,10 +55,10 @@ namespace gtsam { bool ensureArcConsistency(size_t j, std::vector& domains) const; /// Partially apply known values - virtual DiscreteFactor::shared_ptr partiallyApply(const Values&) const; + virtual Constraint::shared_ptr partiallyApply(const Values&) const; /// Partially apply known values, domain version - virtual DiscreteFactor::shared_ptr partiallyApply(const std::vector&) const; + virtual Constraint::shared_ptr partiallyApply(const std::vector&) const; }; } // namespace gtsam diff --git a/gtsam/discrete/BinaryAllDiff.h b/gtsam_unstable/discrete/BinaryAllDiff.h similarity index 88% rename from gtsam/discrete/BinaryAllDiff.h rename to gtsam_unstable/discrete/BinaryAllDiff.h index 31fe070c2..04eeba953 100644 --- a/gtsam/discrete/BinaryAllDiff.h +++ b/gtsam_unstable/discrete/BinaryAllDiff.h @@ -7,6 +7,8 @@ #pragma once +#include +#include #include namespace gtsam { @@ -18,7 +20,7 @@ namespace gtsam { * for each variable we have a Index and an Index. In this factor, we * keep the Indices locally, and the Indices are stored in IndexFactor. */ - class BinaryAllDiff: public DiscreteFactor { + class BinaryAllDiff: public Constraint { size_t cardinality0_, cardinality1_; /// cardinality @@ -26,7 +28,7 @@ namespace gtsam { /// Constructor BinaryAllDiff(const DiscreteKey& key1, const DiscreteKey& key2) : - DiscreteFactor(key1.first, key2.first), + Constraint(key1.first, key2.first), cardinality0_(key1.second), cardinality1_(key2.second) { } @@ -73,12 +75,12 @@ namespace gtsam { } /// Partially apply known values - virtual DiscreteFactor::shared_ptr partiallyApply(const Values&) const { + virtual Constraint::shared_ptr partiallyApply(const Values&) const { throw std::runtime_error("BinaryAllDiff::partiallyApply not implemented"); } /// Partially apply known values, domain version - virtual DiscreteFactor::shared_ptr partiallyApply( + virtual Constraint::shared_ptr partiallyApply( const std::vector&) const { throw std::runtime_error("BinaryAllDiff::partiallyApply not implemented"); } diff --git a/gtsam_unstable/discrete/CMakeLists.txt b/gtsam_unstable/discrete/CMakeLists.txt new file mode 100644 index 000000000..b049562a5 --- /dev/null +++ b/gtsam_unstable/discrete/CMakeLists.txt @@ -0,0 +1,31 @@ +# Install headers +file(GLOB discrete_headers "*.h") +install(FILES ${discrete_headers} DESTINATION include/gtsam_unstable/discrete) + +# Components to link tests in this subfolder against +set(discrete_local_libs + discrete_unstable + discrete + inference + base + ccolamd +) + +set (discrete_full_libs + gtsam-static + gtsam_unstable-static) + +# Exclude tests that don't work +set (discrete_excluded_tests "${CMAKE_CURRENT_SOURCE_DIR}/tests/testScheduler.cpp") + +# Add all tests +gtsam_add_subdir_tests(discrete_unstable "${discrete_local_libs}" "${discrete_full_libs}" "${discrete_excluded_tests}") + +# add examples +foreach(example schedulingExample schedulingQuals12) + add_executable(${example} "examples/${example}.cpp") + add_dependencies(${example} gtsam-static gtsam_unstable-static) + target_link_libraries(${example} gtsam-static gtsam_unstable-static) + add_custom_target(${example}.run ${EXECUTABLE_OUTPUT_PATH}${example} ${ARGN}) +endforeach(example) + diff --git a/gtsam/discrete/CSP.cpp b/gtsam_unstable/discrete/CSP.cpp similarity index 90% rename from gtsam/discrete/CSP.cpp rename to gtsam_unstable/discrete/CSP.cpp index c0d57f320..4da2f440a 100644 --- a/gtsam/discrete/CSP.cpp +++ b/gtsam_unstable/discrete/CSP.cpp @@ -5,8 +5,8 @@ * @author Frank Dellaert */ -#include -#include +#include +#include #include #include #include @@ -49,7 +49,7 @@ namespace gtsam { // if not already a singleton if (!domains[v].isSingleton()) { // get the constraint and call its ensureArcConsistency method - DiscreteFactor::shared_ptr factor = (*this)[f]; + Constraint::shared_ptr factor = (*this)[f]; changed[v] = factor->ensureArcConsistency(v,domains) || changed[v]; } } // f @@ -84,8 +84,8 @@ namespace gtsam { // TODO: create a new ordering as we go, to ensure a connected graph // KeyOrdering ordering; // vector dkeys; - BOOST_FOREACH(const DiscreteFactor::shared_ptr& factor, factors_) { - DiscreteFactor::shared_ptr reduced = factor->partiallyApply(domains); + BOOST_FOREACH(const Constraint::shared_ptr& factor, factors_) { + Constraint::shared_ptr reduced = factor->partiallyApply(domains); if (print) reduced->print(); } #endif diff --git a/gtsam/discrete/CSP.h b/gtsam_unstable/discrete/CSP.h similarity index 67% rename from gtsam/discrete/CSP.h rename to gtsam_unstable/discrete/CSP.h index d423426fd..e2e2a2251 100644 --- a/gtsam/discrete/CSP.h +++ b/gtsam_unstable/discrete/CSP.h @@ -7,8 +7,8 @@ #pragma once -#include -#include +#include +#include #include namespace gtsam { @@ -18,13 +18,40 @@ namespace gtsam { * A specialization of a DiscreteFactorGraph. * It knows about CSP-specific constraints and algorithms */ - class CSP: public DiscreteFactorGraph { + class CSP: public FactorGraph { + public: + + /** A map from keys to values */ + typedef std::vector Indices; + typedef Assignment Values; + typedef boost::shared_ptr sharedValues; public: /// Constructor CSP() { } + template + void add(const DiscreteKey& j, SOURCE table) { + DiscreteKeys keys; + keys.push_back(j); + push_back(boost::make_shared(keys, table)); + } + + template + void add(const DiscreteKey& j1, const DiscreteKey& j2, SOURCE table) { + DiscreteKeys keys; + keys.push_back(j1); + keys.push_back(j2); + push_back(boost::make_shared(keys, table)); + } + + /** add shared discreteFactor immediately from arguments */ + template + void add(const DiscreteKeys& keys, SOURCE table) { + push_back(boost::make_shared(keys, table)); + } + /// Add a unary constraint, allowing only a single value void addSingleValue(const DiscreteKey& dkey, size_t value) { boost::shared_ptr factor(new SingleValue(dkey, value)); diff --git a/gtsam_unstable/discrete/Constraint.h b/gtsam_unstable/discrete/Constraint.h new file mode 100644 index 000000000..3b9cd8b8a --- /dev/null +++ b/gtsam_unstable/discrete/Constraint.h @@ -0,0 +1,91 @@ +/* ---------------------------------------------------------------------------- + + * 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 Constraint.h + * @date May 15, 2012 + * @author Frank Dellaert + */ + +#pragma once + +#include + +namespace gtsam { + + class Domain; + + /** + * Base class for discrete probabilistic factors + * The most general one is the derived DecisionTreeFactor + */ + class Constraint : public DiscreteFactor { + + public: + + typedef boost::shared_ptr shared_ptr; + + protected: + + /// Construct n-way factor + Constraint(const std::vector& js) : + DiscreteFactor(js) { + } + + /// Construct unary factor + Constraint(Index j) : + DiscreteFactor(j) { + } + + /// Construct binary factor + Constraint(Index j1, Index j2) : + DiscreteFactor(j1, j2) { + } + + /// construct from container + template + Constraint(KeyIterator beginKey, KeyIterator endKey) : + DiscreteFactor(beginKey, endKey) { + } + + public: + + /// @name Standard Constructors + /// @{ + + /// Default constructor for I/O + Constraint(); + + /// Virtual destructor + virtual ~Constraint() {} + + /// @} + /// @name Standard Interface + /// @{ + + /* + * Ensure Arc-consistency + * @param j domain to be checked + * @param domains all other domains + */ + virtual bool ensureArcConsistency(size_t j, std::vector& domains) const = 0; + + /// Partially apply known values + virtual shared_ptr partiallyApply(const Values&) const = 0; + + + /// Partially apply known values, domain version + virtual shared_ptr partiallyApply(const std::vector&) const = 0; + /// @} + }; +// DiscreteFactor + +}// namespace gtsam diff --git a/gtsam/discrete/Domain.cpp b/gtsam_unstable/discrete/Domain.cpp similarity index 95% rename from gtsam/discrete/Domain.cpp rename to gtsam_unstable/discrete/Domain.cpp index 130bd71ff..fd2631cec 100644 --- a/gtsam/discrete/Domain.cpp +++ b/gtsam_unstable/discrete/Domain.cpp @@ -5,7 +5,7 @@ * @author Frank Dellaert */ -#include +#include #include #include #include @@ -74,7 +74,7 @@ namespace gtsam { } /* ************************************************************************* */ - DiscreteFactor::shared_ptr Domain::partiallyApply( + Constraint::shared_ptr Domain::partiallyApply( const Values& values) const { Values::const_iterator it = values.find(keys_[0]); if (it != values.end() && !contains(it->second)) throw runtime_error( @@ -83,7 +83,7 @@ namespace gtsam { } /* ************************************************************************* */ - DiscreteFactor::shared_ptr Domain::partiallyApply( + Constraint::shared_ptr Domain::partiallyApply( const vector& domains) const { const Domain& Dk = domains[keys_[0]]; if (Dk.isSingleton() && !contains(*Dk.begin())) throw runtime_error( diff --git a/gtsam/discrete/Domain.h b/gtsam_unstable/discrete/Domain.h similarity index 86% rename from gtsam/discrete/Domain.h rename to gtsam_unstable/discrete/Domain.h index 934f0c306..50c534f8a 100644 --- a/gtsam/discrete/Domain.h +++ b/gtsam_unstable/discrete/Domain.h @@ -7,15 +7,15 @@ #pragma once +#include #include -#include namespace gtsam { /** * Domain restriction constraint */ - class Domain: public DiscreteFactor { + class Domain: public Constraint { size_t cardinality_; /// Cardinality std::set values_; /// allowed values @@ -26,7 +26,7 @@ namespace gtsam { // Constructor on Discrete Key initializes an "all-allowed" domain Domain(const DiscreteKey& dkey) : - DiscreteFactor(dkey.first), cardinality_(dkey.second) { + Constraint(dkey.first), cardinality_(dkey.second) { for (size_t v = 0; v < cardinality_; v++) values_.insert(v); } @@ -34,13 +34,13 @@ namespace gtsam { // Constructor on Discrete Key with single allowed value // Consider SingleValue constraint Domain(const DiscreteKey& dkey, size_t v) : - DiscreteFactor(dkey.first), cardinality_(dkey.second) { + Constraint(dkey.first), cardinality_(dkey.second) { values_.insert(v); } /// Constructor Domain(const Domain& other) : - DiscreteFactor(other.keys_[0]), values_(other.values_) { + Constraint(other.keys_[0]), values_(other.values_) { } /// insert a value, non const :-( @@ -96,11 +96,11 @@ namespace gtsam { bool checkAllDiff(const std::vector keys, std::vector& domains); /// Partially apply known values - virtual DiscreteFactor::shared_ptr partiallyApply( + virtual Constraint::shared_ptr partiallyApply( const Values& values) const; /// Partially apply known values, domain version - virtual DiscreteFactor::shared_ptr partiallyApply( + virtual Constraint::shared_ptr partiallyApply( const std::vector& domains) const; }; diff --git a/gtsam/discrete/Scheduler.cpp b/gtsam_unstable/discrete/Scheduler.cpp similarity index 92% rename from gtsam/discrete/Scheduler.cpp rename to gtsam_unstable/discrete/Scheduler.cpp index dd578930d..678ba1580 100644 --- a/gtsam/discrete/Scheduler.cpp +++ b/gtsam_unstable/discrete/Scheduler.cpp @@ -5,7 +5,7 @@ * @author Frank Dellaert */ -#include +#include #include #include #include @@ -29,6 +29,10 @@ namespace gtsam { // open file ifstream is(filename.c_str()); + if (!is) { + cerr << "Scheduler: could not open file " << filename << endl; + throw runtime_error("Scheduler: could not open file " + filename); + } string line; // buffer @@ -101,6 +105,7 @@ namespace gtsam { /** Add student-specific constraints to the graph */ void Scheduler::addStudentSpecificConstraints(size_t i, boost::optional slot) { +#ifdef BROKEN bool debug = ISDEBUG("Scheduler::buildGraph"); assert(i +#include namespace gtsam { diff --git a/gtsam/discrete/SingleValue.cpp b/gtsam_unstable/discrete/SingleValue.cpp similarity index 91% rename from gtsam/discrete/SingleValue.cpp rename to gtsam_unstable/discrete/SingleValue.cpp index 8d5fd0d8d..855d62353 100644 --- a/gtsam/discrete/SingleValue.cpp +++ b/gtsam_unstable/discrete/SingleValue.cpp @@ -5,8 +5,8 @@ * @author Frank Dellaert */ -#include -#include +#include +#include #include #include #include @@ -58,7 +58,7 @@ namespace gtsam { } /* ************************************************************************* */ - DiscreteFactor::shared_ptr SingleValue::partiallyApply(const Values& values) const { + Constraint::shared_ptr SingleValue::partiallyApply(const Values& values) const { Values::const_iterator it = values.find(keys_[0]); if (it != values.end() && it->second != value_) throw runtime_error( "SingleValue::partiallyApply: unsatisfiable"); @@ -66,7 +66,7 @@ namespace gtsam { } /* ************************************************************************* */ - DiscreteFactor::shared_ptr SingleValue::partiallyApply( + Constraint::shared_ptr SingleValue::partiallyApply( const vector& domains) const { const Domain& Dk = domains[keys_[0]]; if (Dk.isSingleton() && !Dk.contains(value_)) throw runtime_error( diff --git a/gtsam/discrete/SingleValue.h b/gtsam_unstable/discrete/SingleValue.h similarity index 80% rename from gtsam/discrete/SingleValue.h rename to gtsam_unstable/discrete/SingleValue.h index fc3d166fd..3f7f3011d 100644 --- a/gtsam/discrete/SingleValue.h +++ b/gtsam_unstable/discrete/SingleValue.h @@ -7,15 +7,15 @@ #pragma once +#include #include -#include namespace gtsam { /** * SingleValue constraint */ - class SingleValue: public DiscreteFactor { + class SingleValue: public Constraint { /// Number of values size_t cardinality_; @@ -33,12 +33,12 @@ namespace gtsam { /// Constructor SingleValue(Index key, size_t n, size_t value) : - DiscreteFactor(key), cardinality_(n), value_(value) { + Constraint(key), cardinality_(n), value_(value) { } /// Constructor SingleValue(const DiscreteKey& dkey, size_t value) : - DiscreteFactor(dkey.first), cardinality_(dkey.second), value_(value) { + Constraint(dkey.first), cardinality_(dkey.second), value_(value) { } // print @@ -61,11 +61,11 @@ namespace gtsam { bool ensureArcConsistency(size_t j, std::vector& domains) const; /// Partially apply known values - virtual DiscreteFactor::shared_ptr partiallyApply( + virtual Constraint::shared_ptr partiallyApply( const Values& values) const; /// Partially apply known values, domain version - virtual DiscreteFactor::shared_ptr partiallyApply( + virtual Constraint::shared_ptr partiallyApply( const std::vector& domains) const; }; diff --git a/gtsam/discrete/examples/Doodle.csv b/gtsam_unstable/discrete/examples/Doodle.csv similarity index 100% rename from gtsam/discrete/examples/Doodle.csv rename to gtsam_unstable/discrete/examples/Doodle.csv diff --git a/gtsam/discrete/examples/Doodle.xls b/gtsam_unstable/discrete/examples/Doodle.xls similarity index 100% rename from gtsam/discrete/examples/Doodle.xls rename to gtsam_unstable/discrete/examples/Doodle.xls diff --git a/gtsam/discrete/examples/Doodle2012.csv b/gtsam_unstable/discrete/examples/Doodle2012.csv similarity index 100% rename from gtsam/discrete/examples/Doodle2012.csv rename to gtsam_unstable/discrete/examples/Doodle2012.csv diff --git a/gtsam/discrete/examples/Doodle2012.xls b/gtsam_unstable/discrete/examples/Doodle2012.xls similarity index 100% rename from gtsam/discrete/examples/Doodle2012.xls rename to gtsam_unstable/discrete/examples/Doodle2012.xls diff --git a/gtsam/discrete/examples/intrusive.xlsx b/gtsam_unstable/discrete/examples/intrusive.xlsx similarity index 100% rename from gtsam/discrete/examples/intrusive.xlsx rename to gtsam_unstable/discrete/examples/intrusive.xlsx diff --git a/gtsam/discrete/examples/schedulingExample.cpp b/gtsam_unstable/discrete/examples/schedulingExample.cpp similarity index 98% rename from gtsam/discrete/examples/schedulingExample.cpp rename to gtsam_unstable/discrete/examples/schedulingExample.cpp index ff3f8a26f..485f0ea1c 100644 --- a/gtsam/discrete/examples/schedulingExample.cpp +++ b/gtsam_unstable/discrete/examples/schedulingExample.cpp @@ -8,7 +8,7 @@ //#define ENABLE_TIMING #define ADD_NO_CACHING #define ADD_NO_PRUNING -#include +#include #include #include @@ -53,7 +53,7 @@ void addStudent(Scheduler& s, size_t i) { } /* ************************************************************************* */ Scheduler largeExample(size_t nrStudents = 7) { - string path("/Users/dellaert/borg/gtsam/gtsam/discrete/examples/"); + string path("../../../gtsam_unstable/discrete/examples/"); Scheduler s(nrStudents, path + "Doodle.csv"); s.addArea("Harvey Lipkin", "Mechanics"); diff --git a/gtsam/discrete/examples/schedulingQuals12.cpp b/gtsam_unstable/discrete/examples/schedulingQuals12.cpp similarity index 98% rename from gtsam/discrete/examples/schedulingQuals12.cpp rename to gtsam_unstable/discrete/examples/schedulingQuals12.cpp index 7571fbc58..d0fa041c9 100644 --- a/gtsam/discrete/examples/schedulingQuals12.cpp +++ b/gtsam_unstable/discrete/examples/schedulingQuals12.cpp @@ -8,7 +8,7 @@ #define ENABLE_TIMING #define ADD_NO_CACHING #define ADD_NO_PRUNING -#include +#include #include #include @@ -65,7 +65,7 @@ void addStudent(Scheduler& s, size_t i) { /* ************************************************************************* */ Scheduler largeExample(size_t nrStudents = NRSTUDENTS) { - string path("/Users/dellaert/borg/gtsam/gtsam/discrete/examples/"); + string path("../../../gtsam_unstable/discrete/examples/"); Scheduler s(nrStudents, path + "Doodle2012.csv"); s.addArea("Harvey Lipkin", "Mechanics"); diff --git a/gtsam/discrete/examples/small.csv b/gtsam_unstable/discrete/examples/small.csv similarity index 100% rename from gtsam/discrete/examples/small.csv rename to gtsam_unstable/discrete/examples/small.csv diff --git a/gtsam/discrete/tests/testCSP.cpp b/gtsam_unstable/discrete/tests/testCSP.cpp similarity index 98% rename from gtsam/discrete/tests/testCSP.cpp rename to gtsam_unstable/discrete/tests/testCSP.cpp index cce32f09f..46bf61240 100644 --- a/gtsam/discrete/tests/testCSP.cpp +++ b/gtsam_unstable/discrete/tests/testCSP.cpp @@ -5,8 +5,8 @@ * @author Frank Dellaert */ -#include -#include +#include +#include #include #include #include diff --git a/gtsam/discrete/tests/testScheduler.cpp b/gtsam_unstable/discrete/tests/testScheduler.cpp similarity index 97% rename from gtsam/discrete/tests/testScheduler.cpp rename to gtsam_unstable/discrete/tests/testScheduler.cpp index 28e3e16ed..bf9273ad6 100644 --- a/gtsam/discrete/tests/testScheduler.cpp +++ b/gtsam_unstable/discrete/tests/testScheduler.cpp @@ -5,7 +5,7 @@ */ //#define ENABLE_TIMING -#include +#include #include #include @@ -149,7 +149,7 @@ TEST( schedulingExample, test) /* ************************************************************************* */ TEST( schedulingExample, smallFromFile) { - string path("../../../gtsam/discrete/examples/"); + string path("../../../gtsam_unstable/discrete/examples/"); Scheduler s(2, path + "small.csv"); // add areas diff --git a/gtsam/discrete/tests/testSudoku.cpp b/gtsam_unstable/discrete/tests/testSudoku.cpp similarity index 99% rename from gtsam/discrete/tests/testSudoku.cpp rename to gtsam_unstable/discrete/tests/testSudoku.cpp index 7e4139818..1bbac4777 100644 --- a/gtsam/discrete/tests/testSudoku.cpp +++ b/gtsam_unstable/discrete/tests/testSudoku.cpp @@ -5,7 +5,7 @@ * @author Frank Dellaert */ -#include +#include #include #include #include