Parcourir la source

First commit : switch paradevs project to two different repositories

Eric Ramat il y a 10 ans
commit
9d56670331
47 fichiers modifiés avec 16680 ajouts et 0 suppressions
  1. 2 0
      .gitignore
  2. 31 0
      AUTHORS
  3. 109 0
      CMakeCPack.cmake
  4. 123 0
      CMakeLists.txt
  5. 676 0
      COPYING
  6. 32 0
      README
  7. BIN
      doc/comparison.ods
  8. 8 0
      src/CMakeLists.txt
  9. 18 0
      src/tests/CMakeLists.txt
  10. 22 0
      src/tests/boost_graph/CMakeLists.txt
  11. 466 0
      src/tests/boost_graph/graph_builder.hpp
  12. 78 0
      src/tests/boost_graph/graph_defs.hpp
  13. 758 0
      src/tests/boost_graph/graph_manager.hpp
  14. 171 0
      src/tests/boost_graph/graph_partitioning.hpp
  15. 207 0
      src/tests/boost_graph/models.hpp
  16. 30 0
      src/tests/boost_graph/partitioning/CMakeLists.txt
  17. 71 0
      src/tests/boost_graph/partitioning/defs.hpp
  18. 939 0
      src/tests/boost_graph/partitioning/gggp.cpp
  19. 68 0
      src/tests/boost_graph/partitioning/gggp.hpp
  20. 434 0
      src/tests/boost_graph/partitioning/graph_build.cpp
  21. 39 0
      src/tests/boost_graph/partitioning/graph_build.hpp
  22. 132 0
      src/tests/boost_graph/partitioning/main.cpp
  23. 1588 0
      src/tests/boost_graph/partitioning/utils.cpp
  24. 114 0
      src/tests/boost_graph/partitioning/utils.hpp
  25. 378 0
      src/tests/boost_graph/tests.cpp
  26. 6446 0
      src/tests/catch.hpp
  27. 12 0
      src/tests/common/CMakeLists.txt
  28. 17 0
      src/tests/common/scheduler/CMakeLists.txt
  29. 167 0
      src/tests/common/scheduler/tests.cpp
  30. 17 0
      src/tests/dtss/CMakeLists.txt
  31. 119 0
      src/tests/dtss/graph_manager.hpp
  32. 195 0
      src/tests/dtss/models.hpp
  33. 120 0
      src/tests/dtss/tests.cpp
  34. 19 0
      src/tests/mixed/CMakeLists.txt
  35. 428 0
      src/tests/mixed/graph_manager.hpp
  36. 622 0
      src/tests/mixed/models.hpp
  37. 124 0
      src/tests/mixed/tests.cpp
  38. 16 0
      src/tests/multithreading/CMakeLists.txt
  39. 406 0
      src/tests/multithreading/graph_manager.hpp
  40. 230 0
      src/tests/multithreading/lifegame/graph_manager.hpp
  41. 95 0
      src/tests/multithreading/lifegame/models.hpp
  42. 88 0
      src/tests/multithreading/lifegame/tests.cpp
  43. 139 0
      src/tests/multithreading/tests.cpp
  44. 16 0
      src/tests/pdevs/CMakeLists.txt
  45. 248 0
      src/tests/pdevs/graph_manager.hpp
  46. 357 0
      src/tests/pdevs/models.hpp
  47. 305 0
      src/tests/pdevs/tests.cpp

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+*~
+build/

+ 31 - 0
AUTHORS

@@ -0,0 +1,31 @@
+                 PARADEVS development team
+                 =========================
+
+
+Copyright
+=========
+
+- ULCO
+  - Copyright © 2013-2014
+  - Université du Littoral Côte d'Opale
+  - http://www.univ-littoral.fr
+
+Authors
+=======
+
+Integrator / Release manager
+----------------------------
+
+- Eric Ramat <eric.ramat@gmail.com>
+
+
+Main programmer and founder
+---------------------------
+
+- Eric Ramat <eric.ramat@gmail.com>
+
+
+Contributors
+------------
+
+- Christopher Herbez <christopher.herbez@gmail.com>

+ 109 - 0
CMakeCPack.cmake

@@ -0,0 +1,109 @@
+INCLUDE(InstallRequiredSystemLibraries)
+
+IF (WIN32)
+  SET(CPACK_GENERATOR "NSIS")
+  SET(CPACK_SOURCE_GENERATOR "ZIP")
+ENDIF (WIN32)
+
+IF (UNIX)
+  SET(CPACK_GENERATOR "TGZ;DEB;RPM")
+  SET(CPACK_SOURCE_GENERATOR "ZIP;TGZ;TBZ2")
+ENDIF (UNIX)
+
+IF (APPLE)
+  SET(CPACK_GENERATOR "OSXX11")
+ENDIF (APPLE)
+
+SET(CPACK_STRIP_FILES "1")
+SET(CPACK_PACKAGE_NAME "VLE")
+SET(CPACK_PACKAGE_VENDOR "VLE Development Team")
+SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "VLE - Virtual Laboratory Environment")
+SET(CPACK_PACKAGE_CONTACT "Gauthier Quesnel <quesnel@users.sourceforge.net>")
+SET(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README")
+SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
+SET(CPACK_PACKAGE_FILE_NAME "${VLE_NAME_COMPLETE}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
+SET(CPACK_PACKAGE_VERSION_MAJOR "${VLE_MAJOR}")
+SET(CPACK_PACKAGE_VERSION_MINOR "${VLE_MINOR}")
+
+IF ("${VLE_EXTRA}" STREQUAL "")
+  SET(CPACK_PACKAGE_VERSION_PATCH "${VLE_PATCH}")
+ELSE ("${VLE_EXTRA}" STREQUAL "")
+  SET(CPACK_PACKAGE_VERSION_PATCH "${VLE_PATCH}-${VLE_EXTRA}")
+ENDIF ("${VLE_EXTRA}" STREQUAL "")
+
+SET(CPACK_PACKAGE_INSTALL_DIRECTORY ${VLE_NAME_COMPLETE})
+SET(CPACK_PACKAGE_EXECUTABLES "vle" "VLE" "oov" "OOV" "eov" "EOV" "gvle" "GVLE")
+
+# CPack source configuration
+SET(CPACK_SOURCE_PACKAGE_FILE_NAME ${VLE_NAME_COMPLETE})
+SET(CPACK_SOURCE_IGNORE_FILES "\\\\.swp$;/\\\\.gitignore;/build/;/\\\\.git/")
+
+# CPack DEB configuration
+SET(CPACK_DEBIAN_PACKAGE_NAME ${VLE_NAME}-${VLE_MAJOR}.${VLE_MINOR})
+SET(CPACK_DEBIAN_PACKAGE_VERSION ${VLE_COMPLETE})
+SET(CPACK_DEBIAN_PACKAGE_DEPENDS "")
+SET(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS "")
+SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Gauthier Quesnel <quesnel@users.sourceforge.net>")
+SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "VLE, a framework for multi-modeling, simulation and analysis of complex dynamical systems.")
+SET(CPACK_DEBIAN_PACKAGE_SECTION "libs")
+SET(CPACK_DEBIAN_PACKAGE_PRIORITY "extra")
+
+# CPack RPM configuration
+SET(CPACK_RPM_PACKAGE_SUMMARY "VLE, a framework for multi-modeling, simulation and analysis of complex dynamical systems.")
+SET(CPACK_RPM_PACKAGE_NAME ${VLE_NAME}-${VLE_MAJOR}.${VLE_MINOR})
+SET(CPACK_RPM_PACKAGE_VERSION ${VLE_MAJOR}.${VLE_MINOR}.${VLE_PATCH})
+SET(CPACK_RPM_PACKAGE_RELEASE "1")
+SET(CPACK_RPM_PACKAGE_VENDOR "Gauthier Quesnel <quesnel@users.sourceforge.net>")
+SET(CPACK_RPM_PACKAGE_LICENSE "GNU General Public License (GPL)")
+SET(CPACK_RPM_PACKAGE_DESCRIPTION "VLE, a framework for multi-modeling, simulation and analysis of complex dynamical systems.")
+
+# CPack NSIS configuration
+IF (CPACK_GENERATOR MATCHES "NSIS")
+  SET(CMAKE_MODULE_PATH "share")
+  SET(VLE_BOOST_INCLUDE_DIR CACHE PATH "Boost include directory")
+  SET(VLE_BOOST_LIBRARY_DIR CACHE PATH "Boost library directory")
+  SET(VLE_MINGW_PATH CACHE PATH "Mingw Boost directory")
+  SET(VLE_GTK_PATH CACHE PATH "Gtk directory")
+  SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/share)
+
+  INSTALL(DIRECTORY "${VLE_BOOST_INCLUDE_DIR}/" DESTINATION include)
+  INSTALL(DIRECTORY "${VLE_BOOST_LIBRARY_DIR}/" DESTINATION bin
+    FILES_MATCHING PATTERN "libboost*.dll")
+  INSTALL(DIRECTORY "${VLE_BOOST_LIBRARY_DIR}/" DESTINATION lib
+    FILES_MATCHING PATTERN "libboost*.a")
+
+  INSTALL(FILES "${VLE_MINGW_PATH}/bin\\\\mingwm10.dll" DESTINATION bin)
+
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/include/" DESTINATION include)
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/redist/" DESTINATION bin)
+
+  INSTALL(FILES "${VLE_GTK_PATH}/bin\\\\pkg-config.exe" DESTINATION bin)
+
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/lib/" DESTINATION lib
+    PATTERN "*.def" EXCLUDE
+    PATTERN "*.lib" EXCLUDE)
+
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/etc\\\\gtk-2.0" DESTINATION etc)
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/etc\\\\pango" DESTINATION etc)
+
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/share\\\\doc" DESTINATION share)
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/share\\\\locale" DESTINATION share)
+  INSTALL(DIRECTORY "${VLE_GTK_PATH}/share\\\\themes" DESTINATION share)
+
+  SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/share/pixmaps\\\\vle.ico")
+  SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/share/pixmaps\\\\vle.ico")
+  SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/share/pixmaps\\\\logo.bmp")
+  SET(CPACK_NSIS_MENU_LINKS "${VLE_SHARE_DIRS}/doc/vle.chm" "VLE API" "http://www.sourceforge.net/projects/vle" "VLE Web Site")
+  SET(CPACK_CREATE_DESKTOP_LINKS gvle)
+  SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\vle.exe")
+  SET(CPACK_NSIS_DISPLAY_NAME "VLE - Virtual Laboratory Environment")
+  SET(CPACK_NSIS_HELP_LINK "http://www.sourceforge.net/projects/vle")
+  SET(CPACK_NSIS_URL_INFO_ABOUT "http://www.sourceforge.net/projects/vle")
+  SET(CPACK_NSIS_CONTACT "Gauthier Quesnel <quesnel@users.sourceforge.net>")
+  SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} ${VLE_VERSION_SHORT}.0")
+  SET(CPACK_NSIS_MODIFY_PATH ON)
+ENDIF (CPACK_GENERATOR MATCHES "NSIS")
+
+INCLUDE(CPack)
+
+# vim:tw=0:ts=8:tw=0:sw=2:sts=2

+ 123 - 0
CMakeLists.txt

@@ -0,0 +1,123 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(PARADEVS_TEST CXX C)
+ENABLE_TESTING()
+
+SET(MODEL_MAJOR 0)
+SET(MODEL_MINOR 1)
+SET(MODEL_PATCH 0)
+SET(MODEL_EXTRA "-dev")
+
+IF ("${MODEL_EXTRA}" STREQUAL "")
+  SET(MODEL_NAME "${PROJECT_NAME}-${MODEL_MAJOR}.${MODEL_MINOR}.${MODEL_PATCH}")
+ELSE ("${MODEL_EXTRA}" STREQUAL "")
+  SET(MODEL_NAME "${PROJECT_NAME}-${MODEL_MAJOR}.${MODEL_MINOR}.${MODEL_PATCH}${MODEL_EXTRA}")
+ENDIF ("${MODEL_EXTRA}" STREQUAL "")
+
+#
+ # CPack configuration
+#
+
+INCLUDE(CMakeCPack.cmake)
+
+#
+ # Debug mode
+#
+
+IF (CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++11 -pthread")
+  IF (UNIX)
+    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic")
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
+  ENDIF (UNIX)
+ENDIF (CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
+
+if (CMAKE_BUILD_TYPE STREQUAL "")
+  SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build" FORCE)
+endif ()
+
+#
+ # Modules
+#
+
+INCLUDE(CheckIncludeFileCXX)
+INCLUDE(CheckIncludeFile)
+INCLUDE(CheckLibraryExists)
+INCLUDE(CMakeDetermineCCompiler)
+
+#
+ # Check libraries with pkgconfig
+#
+
+FIND_PACKAGE(PkgConfig REQUIRED)
+
+# FIXME use old-style link directories for now
+IF (COMMAND CMAKE_POLICY)
+  CMAKE_POLICY(SET CMP0003 OLD)
+ENDIF (COMMAND CMAKE_POLICY)
+
+PKG_CHECK_MODULES(PARADEVS REQUIRED paradevs-1.0)
+PKG_CHECK_MODULES(LIBXML REQUIRED libxml-2.0)
+#
+ # Test the libboost header and libboost-text library.
+#
+
+OPTION(WITH_TEST "use the libboost test unit library [default: on]" ON)
+SET(Boost_USE_MULTITHREADED ON)
+SET(Boost_USE_STATIC_LIBS OFF)
+SET(Boost_NO_SYSTEM_PATHS OFF)
+SET(Boost_USE_STATIC_RUNTIME ON)
+IF (WIN32)
+  SET(Boost_THREADAPI "win32")
+ENDIF (WIN32)
+SET(Boost_DETAILED_FAILURE_MSG FALSE)
+SET(Boost_DEBUG FALSE)
+
+FIND_PACKAGE(Boost COMPONENTS graph timer system)
+IF (NOT Boost_GRAPH_FOUND)
+  MESSAGE(FATAL_ERROR "The boost graph library is required")
+ENDIF (NOT Boost_GRAPH_FOUND)
+IF (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "35")
+  SET(Boost_SYSTEM_LIBRARY "")
+ENDIF (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "35")
+IF (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "41")
+  SET(PARADEVS_HAVE_BOOST_SPIRIT2 0 CACHE INTERNAL "" FORCE)
+ELSE (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "41")
+  SET(PARADEVS_HAVE_BOOST_SPIRIT2 1 CACHE INTERNAL "" FORCE)
+ENDIF (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "41")
+
+#
+ # Generate the config.h
+#
+
+CHECK_INCLUDE_FILE_CXX(cxxabi.h PARADEVS_HAVE_GCC_ABI_DEMANGLE)
+CHECK_INCLUDE_FILE_CXX(execinfo.h PARADEVS_HAVE_EXECINFO)
+CHECK_INCLUDE_FILE_CXX(signal.h PARADEVS_HAVE_SIGNAL)
+INCLUDE_DIRECTORIES(${PARADEVS_BINARY_DIR})
+
+#
+ # Browse the src subdirectory
+#
+
+ADD_SUBDIRECTORY(src)
+
+#
+ # Status
+#
+
+MESSAGE(STATUS "- - - -")
+MESSAGE(STATUS "${PARADEVS_NAME_COMPLETE} configured successfully")
+MESSAGE(STATUS "Using ${CMAKE_INSTALL_PREFIX} for installation")
+MESSAGE(STATUS "Build type ${CMAKE_BUILD_TYPE}")
+IF (PARADEVS_HAVE_GCC_ABI_DEMANGLE)
+  MESSAGE(STATUS "Build with GCC ABI Demangle...: yes")
+ENDIF (PARADEVS_HAVE_GCC_ABI_DEMANGLE)
+IF (PARADEVS_HAVE_EXECINFO)
+  MESSAGE(STATUS "Build with execinfo.h.........: yes")
+ENDIF (PARADEVS_HAVE_EXECINFO)
+IF (Boost_FOUND)
+  MESSAGE(STATUS "Build with boost..............: yes")
+ENDIF (Boost_FOUND)
+MESSAGE(STATUS "- - - -")
+
+# vim:tw=0:ts=8:tw=0:sw=2:sts=2

+ 676 - 0
COPYING

@@ -0,0 +1,676 @@
+
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+ 
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+  
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+

+ 32 - 0
README

@@ -0,0 +1,32 @@
+Paradevs : DEVS multimodeling and simulation framework
+======================================================
+
+See AUTHORS and COPYRIGHT for the list of contributors.
+
+PARADEVS is a framework for multimodeling and simulation of complex dynamical
+systems. It addresses the reliability issue by using recent
+developments in the theory of modeling and simulation proposed by B. Zeigler
+with the Discrete Event System Specification formalism (DEVS).
+
+
+Requirements
+------------
+
+For the simulator and API only:
+    boost	1.34  http://www.boost.org
+
+To build VLE you need:
+    cmake	2.6.0 http://www.cmake.org
+    make	1.8
+    gcc, g++	4.6 minimum
+
+
+Getting the code
+----------------
+
+The source tree is currently hosted on SourceforgeGitHub. To view the repository
+online :
+    https://github.com//vle-labs/paradevs
+
+The URL to clone it:
+    git@github.com:vle-labs/paradevs.git

BIN
doc/comparison.ods


+ 8 - 0
src/CMakeLists.txt

@@ -0,0 +1,8 @@
+IF ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
+  message("TRACE on")
+  add_definitions(-DWITH_TRACE)
+ELSE ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
+  message("TRACE off")
+ENDIF ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
+
+ADD_SUBDIRECTORY(tests)

+ 18 - 0
src/tests/CMakeLists.txt

@@ -0,0 +1,18 @@
+INCLUDE_DIRECTORIES(
+  ${PARADEVS_BINARY_DIR}/src
+  ${PARADEVS_SOURCE_DIR}/src
+  ${Boost_INCLUDE_DIRS}
+  ${GLIBMM_INCLUDE_DIRS}
+  ${LIBXML_INCLUDE_DIRS})
+
+LINK_DIRECTORIES(
+  ${GLIBMM_LIBRARY_DIRS}
+  ${LIBXML_LIBRARY_DIR})
+
+ADD_SUBDIRECTORY(boost_graph)
+ADD_SUBDIRECTORY(common)
+ADD_SUBDIRECTORY(corsen)
+ADD_SUBDIRECTORY(dtss)
+ADD_SUBDIRECTORY(mixed)
+ADD_SUBDIRECTORY(multithreading)
+ADD_SUBDIRECTORY(pdevs)

+ 22 - 0
src/tests/boost_graph/CMakeLists.txt

@@ -0,0 +1,22 @@
+INCLUDE_DIRECTORIES(
+  ${CMAKE_SOURCE_DIR}/src
+  ${PARADEVS_INCLUDE_DIRS}
+  ${Boost_INCLUDE_DIRS}
+  ${GLIBMM_INCLUDE_DIRS}
+  ${LIBXML_INCLUDE_DIRS})
+
+LINK_DIRECTORIES(
+  ${GLIBMM_LIBRARY_DIRS}
+  ${LIBXML_LIBRARY_DIR})
+
+# graph tests
+ADD_EXECUTABLE(graph-tests graph_builder.hpp graph_defs.hpp graph_manager.hpp
+  graph_partitioning.hpp tests.cpp models.hpp)
+
+TARGET_LINK_LIBRARIES(graph-tests partitioning
+  ${Boost_LIBRARIES}
+  ${GLIBMM_LIBRARIES}
+  ${LIBXML_LIBRARIES}
+  ${GTHREAD_LIBRARIES})
+
+ADD_SUBDIRECTORY(partitioning)

+ 466 - 0
src/tests/boost_graph/graph_builder.hpp

@@ -0,0 +1,466 @@
+/**
+ * @file tests/boost_graph/graph_builder.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __TESTS_BOOST_GRAPH_GRAPH_BUILDER_HPP
+#define __TESTS_BOOST_GRAPH_GRAPH_BUILDER_HPP 1
+
+#include <tests/boost_graph/graph_defs.hpp>
+
+namespace paradevs { namespace tests { namespace boost_graph {
+
+class FlatGraphBuilder
+{
+public:
+    FlatGraphBuilder()
+    { }
+
+    void build(OrientedGraphs& graphs, InputEdgeList& /* input_edges */,
+               OutputEdgeList& /* output_edges */,
+               Connections& /* parent_connections */)
+    {
+        OrientedGraph graph;
+
+        OrientedGraph::vertex_descriptor v0 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v1 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v2 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v3 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v4 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v5 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v6 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v7 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v8 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v9 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v10 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v11 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v12 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v13 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v14 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v15 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v16 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v17 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v18 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v19 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v20 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v21 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v22 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v23 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v24 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v25 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v26 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v27 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v28 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v29 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v30 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v31 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v32 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v33 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v34 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v35 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v36 = boost::add_vertex(graph);
+        OrientedGraph::vertex_descriptor v37 = boost::add_vertex(graph);
+
+        boost::add_edge(v1, v0, 1., graph);
+        boost::add_edge(v2, v0, 1., graph);
+        boost::add_edge(v3, v0, 1., graph);
+        boost::add_edge(v1, v2, 1., graph);
+        boost::add_edge(v4, v1, 1., graph);
+        boost::add_edge(v5, v1, 1., graph);
+        boost::add_edge(v6, v1, 1., graph);
+        boost::add_edge(v6, v2, 1., graph);
+        boost::add_edge(v2, v3, 1., graph);
+        boost::add_edge(v9, v3, 1., graph);
+        boost::add_edge(v10, v3 , 1., graph);
+        boost::add_edge(v4, v5, 1., graph);
+        boost::add_edge(v5, v6, 1., graph);
+        boost::add_edge(v7, v4, 1., graph);
+        boost::add_edge(v8, v4, 1., graph);
+        boost::add_edge(v7, v8, 1., graph);
+        boost::add_edge(v9, v10 , 1., graph);
+        boost::add_edge(v8, v11, 1., graph);
+        boost::add_edge(v11, v4, 1., graph);
+        boost::add_edge(v12, v13, 1., graph);
+        boost::add_edge(v12, v7, 1., graph);
+        boost::add_edge(v13, v7, 1., graph);
+        boost::add_edge(v14, v15, 1., graph);
+        boost::add_edge(v14, v12, 1., graph);
+        boost::add_edge(v15, v16, 1., graph);
+        boost::add_edge(v15, v12, 1., graph);
+        boost::add_edge(v16, v17, 1., graph);
+        boost::add_edge(v16, v12, 1., graph);
+        boost::add_edge(v17, v12, 1., graph);
+        boost::add_edge(v18, v19, 1., graph);
+        boost::add_edge(v18, v8, 1., graph);
+        boost::add_edge(v19, v20, 1., graph);
+        boost::add_edge(v19, v8, 1., graph);
+        boost::add_edge(v20, v8, 1., graph);
+        boost::add_edge(v21, v22, 1., graph);
+        boost::add_edge(v21, v19, 1., graph);
+        boost::add_edge(v22, v23, 1., graph);
+        boost::add_edge(v22, v19, 1., graph);
+        boost::add_edge(v23, v19, 1., graph);
+        boost::add_edge(v24, v25, 1., graph);
+        boost::add_edge(v24, v6, 1., graph);
+        boost::add_edge(v25, v6, 1., graph);
+        boost::add_edge(v26, v11, 1., graph);
+        boost::add_edge(v26, v27, 1., graph);
+        boost::add_edge(v26, v24, 1., graph);
+        boost::add_edge(v27, v24, 1., graph);
+        boost::add_edge(v28, v25, 1., graph);
+        boost::add_edge(v29, v27, 1., graph);
+        boost::add_edge(v29, v28, 1., graph);
+        boost::add_edge(v30, v27, 1., graph);
+        boost::add_edge(v30, v28, 1., graph);
+        boost::add_edge(v31, v32, 1., graph);
+        boost::add_edge(v31, v10, 1., graph);
+        boost::add_edge(v32, v33, 1., graph);
+        boost::add_edge(v32, v10, 1., graph);
+        boost::add_edge(v33, v10, 1., graph);
+        boost::add_edge(v34, v31, 1., graph);
+        boost::add_edge(v34, v35, 1., graph);
+        boost::add_edge(v35, v31, 1., graph);
+        boost::add_edge(v35, v32, 1., graph);
+        boost::add_edge(v36, v32, 1., graph);
+        boost::add_edge(v36, v37, 1., graph);
+        boost::add_edge(v36, v33, 1., graph);
+        boost::add_edge(v37, v33, 1., graph);
+
+        /*graph[v6] = VertexProperties(6, 1., NORMAL_PIXEL);
+        graph[v8] = VertexProperties(8, 1., NORMAL_PIXEL);
+        graph[v10] = VertexProperties(10, 1., NORMAL_PIXEL);
+        graph[v0] = VertexProperties(0, 1., NORMAL_PIXEL);
+        graph[v1] = VertexProperties(1, 1., NORMAL_PIXEL);
+        graph[v2] = VertexProperties(2, 1., NORMAL_PIXEL);
+        graph[v3] = VertexProperties(3, 1., NORMAL_PIXEL);
+        graph[v4] = VertexProperties(4, 1., NORMAL_PIXEL);
+        graph[v5] = VertexProperties(5, 1., NORMAL_PIXEL);
+        graph[v7] = VertexProperties(7, 1., TOP_PIXEL);
+        graph[v9] = VertexProperties(9, 1., TOP_PIXEL);*/
+
+        graph[v6] = VertexProperties(6, 2.5, NORMAL_PIXEL);
+        graph[v8] = VertexProperties(8, 2., NORMAL_PIXEL);
+        graph[v10] = VertexProperties(10, 2.5, NORMAL_PIXEL);
+        graph[v0] = VertexProperties(0, 4, NORMAL_PIXEL);
+        graph[v1] = VertexProperties(1, 3, NORMAL_PIXEL);
+        graph[v2] = VertexProperties(2, 3, NORMAL_PIXEL);
+        graph[v3] = VertexProperties(3, 3, NORMAL_PIXEL);
+        graph[v4] = VertexProperties(4, 2.5, NORMAL_PIXEL);
+        graph[v5] = VertexProperties(5, 2.5, NORMAL_PIXEL);
+        graph[v7] = VertexProperties(7, 2., NORMAL_PIXEL);
+        graph[v9] = VertexProperties(9, 2.5, TOP_PIXEL);
+        graph[v11] = VertexProperties(11, 2, NORMAL_PIXEL);
+        graph[v12] = VertexProperties(12, 1.5, NORMAL_PIXEL);
+        graph[v13] = VertexProperties(13, 1.5, NORMAL_PIXEL);
+        graph[v14] = VertexProperties(14, 1, TOP_PIXEL);
+        graph[v15] = VertexProperties(15, 1, NORMAL_PIXEL);
+        graph[v16] = VertexProperties(16, 1, NORMAL_PIXEL);
+        graph[v17] = VertexProperties(17, 1, NORMAL_PIXEL);
+        graph[v18] = VertexProperties(18, 1.5, TOP_PIXEL);
+        graph[v19] = VertexProperties(19, 1.5, NORMAL_PIXEL);
+        graph[v20] = VertexProperties(20, 1.5, NORMAL_PIXEL);
+        graph[v21] = VertexProperties(21, 1, TOP_PIXEL);
+        graph[v22] = VertexProperties(22, 1, NORMAL_PIXEL);
+        graph[v23] = VertexProperties(23, 1, NORMAL_PIXEL);
+        graph[v24] = VertexProperties(24, 2, NORMAL_PIXEL);
+        graph[v25] = VertexProperties(25, 2, NORMAL_PIXEL);
+        graph[v26] = VertexProperties(26, 1.5, TOP_PIXEL);
+        graph[v27] = VertexProperties(27, 1.5, NORMAL_PIXEL);
+        graph[v28] = VertexProperties(28, 1.5, NORMAL_PIXEL);
+        graph[v29] = VertexProperties(29, 1, TOP_PIXEL);
+        graph[v30] = VertexProperties(30, 1, TOP_PIXEL);
+        graph[v31] = VertexProperties(31, 2, NORMAL_PIXEL);
+        graph[v32] = VertexProperties(32, 2, NORMAL_PIXEL);
+        graph[v33] = VertexProperties(33, 2, NORMAL_PIXEL);
+        graph[v34] = VertexProperties(34, 1.5, TOP_PIXEL);
+        graph[v35] = VertexProperties(35, 1.5, NORMAL_PIXEL);
+        graph[v36] = VertexProperties(36, 1.5, TOP_PIXEL);
+        graph[v37] = VertexProperties(37, 1.5, NORMAL_PIXEL);
+
+
+        graphs.push_back(graph);
+    }
+};
+
+class HierarchicalGraphBuilder
+{
+public:
+    HierarchicalGraphBuilder()
+    { }
+
+    void build(OrientedGraphs& graphs, InputEdgeList& input_edges,
+               OutputEdgeList& output_edges, Connections& parent_connections)
+    {
+        // S1
+        {
+            OrientedGraph graph;
+
+            OrientedGraph::vertex_descriptor v1 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v4 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v5 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v7 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v8 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v11 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v12 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v13 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v14 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v15 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v16 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v17 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v18 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v19 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v20 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v21 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v22 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v23 = boost::add_vertex(graph);
+
+            boost::add_edge(v4, v1, 1., graph);
+            boost::add_edge(v5, v1, 1., graph);
+            boost::add_edge(v4, v5, 1., graph);
+            boost::add_edge(v7, v4, 1., graph);
+            boost::add_edge(v8, v4, 1., graph);
+            boost::add_edge(v7, v8, 1., graph);
+            boost::add_edge(v8, v11, 1., graph);
+            boost::add_edge(v11, v4, 1., graph);
+            boost::add_edge(v12, v13, 1., graph);
+            boost::add_edge(v12, v7, 1., graph);
+            boost::add_edge(v13, v7, 1., graph);
+            boost::add_edge(v14, v15, 1., graph);
+            boost::add_edge(v14, v12, 1., graph);
+            boost::add_edge(v15, v16, 1., graph);
+            boost::add_edge(v15, v12, 1., graph);
+            boost::add_edge(v16, v17, 1., graph);
+            boost::add_edge(v16, v12, 1., graph);
+            boost::add_edge(v17, v12, 1., graph);
+            boost::add_edge(v18, v19, 1., graph);
+            boost::add_edge(v18, v8, 1., graph);
+            boost::add_edge(v19, v20, 1., graph);
+            boost::add_edge(v19, v8, 1., graph);
+            boost::add_edge(v20, v8, 1., graph);
+            boost::add_edge(v21, v22, 1., graph);
+            boost::add_edge(v21, v19, 1., graph);
+            boost::add_edge(v22, v23, 1., graph);
+            boost::add_edge(v22, v19, 1., graph);
+            boost::add_edge(v23, v19, 1., graph);
+
+            graph[v8] = VertexProperties(8, 2., NORMAL_PIXEL);
+            graph[v1] = VertexProperties(1, 3, NORMAL_PIXEL);
+            graph[v4] = VertexProperties(4, 2.5, NORMAL_PIXEL);
+            graph[v5] = VertexProperties(5, 2.5, NORMAL_PIXEL);
+            graph[v7] = VertexProperties(7, 2., NORMAL_PIXEL);
+            graph[v11] = VertexProperties(11, 2, NORMAL_PIXEL);
+            graph[v12] = VertexProperties(12, 1.5, NORMAL_PIXEL);
+            graph[v13] = VertexProperties(13, 1.5, NORMAL_PIXEL);
+            graph[v14] = VertexProperties(14, 1, TOP_PIXEL);
+            graph[v15] = VertexProperties(15, 1, NORMAL_PIXEL);
+            graph[v16] = VertexProperties(16, 1, NORMAL_PIXEL);
+            graph[v17] = VertexProperties(17, 1, NORMAL_PIXEL);
+            graph[v18] = VertexProperties(18, 1.5, TOP_PIXEL);
+            graph[v19] = VertexProperties(19, 1.5, NORMAL_PIXEL);
+            graph[v20] = VertexProperties(20, 1.5, NORMAL_PIXEL);
+            graph[v21] = VertexProperties(21, 1, TOP_PIXEL);
+            graph[v22] = VertexProperties(22, 1, NORMAL_PIXEL);
+            graph[v23] = VertexProperties(23, 1, NORMAL_PIXEL);
+
+
+            /*OrientedGraph::vertex_descriptor v1 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v2 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v4 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v5 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v6 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v7 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v8 = boost::add_vertex(graph);
+
+            boost::add_edge(v1, v2, 1., graph);
+            boost::add_edge(v4, v1, 1., graph);
+            boost::add_edge(v5, v1, 1., graph);
+            boost::add_edge(v6, v1, 1., graph);
+            boost::add_edge(v6, v2, 1., graph);
+            boost::add_edge(v4, v5, 1., graph);
+            boost::add_edge(v5, v6, 1., graph);
+            boost::add_edge(v7, v4, 1., graph);
+            boost::add_edge(v8, v4, 1., graph);
+            boost::add_edge(v7, v8, 1., graph);
+
+            graph[v6] = VertexProperties(6, 1., NORMAL_PIXEL);
+            graph[v8] = VertexProperties(8, 1., NORMAL_PIXEL);
+            graph[v1] = VertexProperties(1, 1., NORMAL_PIXEL);
+            graph[v2] = VertexProperties(2, 1., NORMAL_PIXEL);
+            graph[v4] = VertexProperties(4, 1., NORMAL_PIXEL);
+            graph[v5] = VertexProperties(5, 1., NORMAL_PIXEL);
+            graph[v7] = VertexProperties(7, 1., TOP_PIXEL);*/
+
+            graphs.push_back(graph);
+        }
+        // S2
+        {
+            OrientedGraph graph;
+
+            OrientedGraph::vertex_descriptor v0 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v2 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v3 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v6 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v9 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v10 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v24 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v25 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v26 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v27 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v28 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v29 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v30 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v31 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v32 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v33 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v34 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v35 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v36 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v37 = boost::add_vertex(graph);
+
+            boost::add_edge(v2, v0, 1., graph);
+            boost::add_edge(v3, v0, 1., graph);
+            boost::add_edge(v6, v2, 1., graph);
+            boost::add_edge(v2, v3, 1., graph);
+            boost::add_edge(v9, v3, 1., graph);
+            boost::add_edge(v10, v3 , 1., graph);
+            boost::add_edge(v9, v10 , 1., graph);
+            boost::add_edge(v24, v25, 1., graph);
+            boost::add_edge(v24, v6, 1., graph);
+            boost::add_edge(v25, v6, 1., graph);
+            boost::add_edge(v26, v27, 1., graph);
+            boost::add_edge(v26, v24, 1., graph);
+            boost::add_edge(v27, v24, 1., graph);
+            boost::add_edge(v28, v25, 1., graph);
+            boost::add_edge(v29, v27, 1., graph);
+            boost::add_edge(v29, v28, 1., graph);
+            boost::add_edge(v30, v27, 1., graph);
+            boost::add_edge(v31, v32, 1., graph);
+            boost::add_edge(v31, v10, 1., graph);
+            boost::add_edge(v32, v33, 1., graph);
+            boost::add_edge(v32, v10, 1., graph);
+            boost::add_edge(v33, v10, 1., graph);
+            boost::add_edge(v34, v31, 1., graph);
+            boost::add_edge(v34, v35, 1., graph);
+            boost::add_edge(v35, v31, 1., graph);
+            boost::add_edge(v35, v32, 1., graph);
+            boost::add_edge(v36, v32, 1., graph);
+            boost::add_edge(v36, v37, 1., graph);
+            boost::add_edge(v36, v33, 1., graph);
+            boost::add_edge(v37, v33, 1., graph);
+
+            graph[v6] = VertexProperties(6, 2.5, NORMAL_PIXEL);
+            graph[v10] = VertexProperties(10, 2.5, NORMAL_PIXEL);
+            graph[v0] = VertexProperties(0, 4, NORMAL_PIXEL);
+            graph[v2] = VertexProperties(2, 3, NORMAL_PIXEL);
+            graph[v3] = VertexProperties(3, 3, NORMAL_PIXEL);
+            graph[v9] = VertexProperties(9, 2.5, TOP_PIXEL);
+            graph[v24] = VertexProperties(24, 2, NORMAL_PIXEL);
+            graph[v25] = VertexProperties(25, 2, NORMAL_PIXEL);
+            graph[v26] = VertexProperties(26, 1.5, TOP_PIXEL);
+            graph[v27] = VertexProperties(27, 1.5, NORMAL_PIXEL);
+            graph[v28] = VertexProperties(28, 1.5, NORMAL_PIXEL);
+            graph[v29] = VertexProperties(29, 1, TOP_PIXEL);
+            graph[v30] = VertexProperties(30, 1, TOP_PIXEL);
+            graph[v31] = VertexProperties(31, 2, NORMAL_PIXEL);
+            graph[v32] = VertexProperties(32, 2, NORMAL_PIXEL);
+            graph[v33] = VertexProperties(33, 2, NORMAL_PIXEL);
+            graph[v34] = VertexProperties(34, 1.5, TOP_PIXEL);
+            graph[v35] = VertexProperties(35, 1.5, NORMAL_PIXEL);
+            graph[v36] = VertexProperties(36, 1.5, TOP_PIXEL);
+            graph[v37] = VertexProperties(37, 1.5, NORMAL_PIXEL);
+
+            /*OrientedGraph::vertex_descriptor v0 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v3 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v9 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v10 = boost::add_vertex(graph);
+
+            boost::add_edge(v3, v0, 1., graph);
+            boost::add_edge(v10, v3, 1., graph);
+            boost::add_edge(v9, v10, 1., graph);
+            boost::add_edge(v9, v3, 1., graph);
+
+            graph[v10] = VertexProperties(10, 1., NORMAL_PIXEL);
+            graph[v0] = VertexProperties(0, 1., NORMAL_PIXEL);
+            graph[v3] = VertexProperties(3, 1., NORMAL_PIXEL);
+            graph[v9] = VertexProperties(9, 1., TOP_PIXEL);*/
+
+            graphs.push_back(graph);
+        }
+        {
+
+            /*// input S1
+            input_edges.push_back(InputEdges());
+            // input S2
+            input_edges.push_back(InputEdges());
+            input_edges[1].push_back(Edge(1, 0));
+            input_edges[1].push_back(Edge(2, 0));
+            input_edges[1].push_back(Edge(2, 3));
+
+            // output S1
+            output_edges.push_back(OutputEdges());
+            output_edges[0].push_back(Edge(1, 0));
+            output_edges[0].push_back(Edge(2, 0));
+            output_edges[0].push_back(Edge(2, 3));
+            // output S2
+            output_edges.push_back(OutputEdges());
+
+            // parent
+            parent_connections.push_back(Connection(Port(1,1),Port(2,0)));
+            parent_connections.push_back(Connection(Port(1,2),Port(2,0)));
+            parent_connections.push_back(Connection(Port(1,2),Port(2,3)));*/
+
+
+            // input S1
+            input_edges.push_back(InputEdges());
+            input_edges[0].push_back(Edge(6, 1));
+            input_edges[0].push_back(Edge(26, 11));
+            // input S2
+            input_edges.push_back(InputEdges());
+            input_edges[1].push_back(Edge(1, 0));
+            input_edges[1].push_back(Edge(1, 2));
+            input_edges[1].push_back(Edge(5, 6));
+
+            // output S1
+            output_edges.push_back(OutputEdges());
+            output_edges[0].push_back(Edge(1, 0));
+            output_edges[0].push_back(Edge(1, 2));
+            output_edges[0].push_back(Edge(5, 6));
+            // output S2
+            output_edges.push_back(OutputEdges());
+            output_edges[1].push_back(Edge(6, 1));
+            output_edges[1].push_back(Edge(26, 11));
+
+            // parent
+            parent_connections.push_back(Connection(Port(1,1),Port(2,0)));
+            parent_connections.push_back(Connection(Port(1,1),Port(2,2)));
+            parent_connections.push_back(Connection(Port(1,5),Port(2,6)));
+            parent_connections.push_back(Connection(Port(2,6),Port(1,1)));
+            parent_connections.push_back(Connection(Port(2,26),Port(1,11)));
+        }
+    }
+};
+
+} } } // namespace paradevs tests boost_graph
+
+#endif

+ 78 - 0
src/tests/boost_graph/graph_defs.hpp

@@ -0,0 +1,78 @@
+/**
+ * @file tests/boost_graph/graph_defs.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __TESTS_BOOST_GRAPH_GRAPH_DEFS_HPP
+#define __TESTS_BOOST_GRAPH_GRAPH_DEFS_HPP 1
+
+#include <boost/graph/adjacency_list.hpp>
+
+namespace paradevs { namespace tests { namespace boost_graph {
+
+enum DynamicsType {
+    TOP_PIXEL = 0, NORMAL_PIXEL
+};
+
+struct VertexProperties
+{
+    int          _index;
+    double       _weight;
+    DynamicsType _type;
+
+    VertexProperties() : _index(0), _weight(0), _type(NORMAL_PIXEL)
+    { }
+    VertexProperties(int index, double weight, DynamicsType type) :
+        _index(index), _weight(weight), _type(type)
+    { }
+};
+
+struct EdgeProperties
+{
+    double       _weight;
+
+    EdgeProperties() : _weight(0)
+    { }
+    EdgeProperties(double weight) : _weight(weight)
+    { }
+};
+
+typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::directedS,
+                                VertexProperties, EdgeProperties> OrientedGraph;
+typedef std::vector < OrientedGraph > OrientedGraphs;
+
+typedef std::pair < int, int > Edge;
+typedef std::vector < Edge > Edges;
+typedef Edges OutputEdges;
+typedef Edges InputEdges;
+typedef std::vector < OutputEdges > OutputEdgeList;
+typedef std::vector < InputEdges > InputEdgeList;
+
+typedef std::pair < int, int > Port;
+typedef std::pair < Port, Port > Connection;
+typedef std::vector < Connection > Connections;
+
+} } } // namespace paradevs tests boost_graph
+
+#endif

+ 758 - 0
src/tests/boost_graph/graph_manager.hpp

@@ -0,0 +1,758 @@
+/**
+ * @file tests/boost_graph/graph_manager.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __TESTS_BOOST_GRAPH_GRAPH_MANAGER_HPP
+#define __TESTS_BOOST_GRAPH_GRAPH_MANAGER_HPP 1
+
+#include <paradevs/common/scheduler/HeapScheduler.hpp>
+#include <paradevs/common/scheduler/VectorScheduler.hpp>
+
+#include <paradevs/kernel/pdevs/Coordinator.hpp>
+#include <paradevs/kernel/pdevs/GraphManager.hpp>
+#include <paradevs/kernel/pdevs/Simulator.hpp>
+
+#include <paradevs/kernel/pdevs/multithreading/Coordinator.hpp>
+
+#include <tests/boost_graph/models.hpp>
+#include <tests/boost_graph/graph_partitioning.hpp>
+
+namespace paradevs { namespace tests { namespace boost_graph {
+
+struct SchedulerHandle;
+
+typedef typename paradevs::common::scheduler::HeapScheduler <
+    common::DoubleTime, SchedulerHandle >::type SchedulerType;
+
+struct SchedulerHandle
+{
+    SchedulerHandle()
+    { }
+
+    SchedulerHandle(const SchedulerType::handle_type& handle)
+        : _handle(handle)
+    { }
+
+    const SchedulerHandle& handle() const
+    { return *this; }
+
+    void handle(const SchedulerHandle& handle)
+    { _handle = handle._handle; }
+
+    SchedulerType::handle_type _handle;
+};
+
+struct GraphParameters
+{
+    OrientedGraph _graph;
+    InputEdges    _input_edges;
+    OutputEdges   _output_edges;
+
+    GraphParameters(const OrientedGraph& graph,
+                    const InputEdges& input_edges,
+                    const OutputEdges& output_edges) :
+        _graph(graph), _input_edges(input_edges), _output_edges(output_edges)
+    { }
+};
+
+template < class SchedulerHandle, class Parameters >
+class FlatGraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               SchedulerHandle,
+                                               Parameters >
+{
+public:
+    FlatGraphManager(common::Coordinator < common::DoubleTime,
+                                           SchedulerHandle >* coordinator,
+        const Parameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime, SchedulerHandle,
+                                        Parameters >(
+            coordinator, parameters)
+    { }
+
+    virtual ~FlatGraphManager()
+    {
+        for (typename TopSimulators::const_iterator it =
+                 _top_simulators.begin(); it != _top_simulators.end();
+             ++it) {
+            delete it->second;
+        }
+        for (typename NormalSimulators::const_iterator it =
+                 _normal_simulators.begin(); it != _normal_simulators.end();
+             ++it) {
+            delete it->second;
+        }
+    }
+
+    void build_flat_graph(const OrientedGraph& g, const InputEdges& inputs)
+    {
+        OrientedGraph::vertex_iterator vertexIt, vertexEnd;
+
+        boost::tie(vertexIt, vertexEnd) = boost::vertices(g);
+        for (; vertexIt != vertexEnd; ++vertexIt) {
+            std::ostringstream ss;
+
+            ss << "a" << g[*vertexIt]._index;
+            switch (g[*vertexIt]._type) {
+            case TOP_PIXEL:
+                _top_simulators[g[*vertexIt]._index] =
+                    new pdevs::Simulator <
+                        common::DoubleTime, TopPixel < SchedulerHandle >,
+                        SchedulerHandle,
+                        TopPixelParameters >(ss.str(), TopPixelParameters());
+                _top_simulators[g[*vertexIt]._index]->add_out_port("out");
+                FlatGraphManager < SchedulerHandle, Parameters >::add_child(
+                    _top_simulators[g[*vertexIt]._index]);
+                break;
+            case NORMAL_PIXEL:
+                unsigned int n = 0;
+                OrientedGraph::vertex_iterator vertexIt2, vertexEnd2;
+
+                boost::tie(vertexIt2, vertexEnd2) = boost::vertices(g);
+                for (; vertexIt2 != vertexEnd2; ++vertexIt2) {
+                    OrientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+                    boost::tie(neighbourIt, neighbourEnd) =
+                        boost::adjacent_vertices(*vertexIt2, g);
+                    for (; neighbourIt != neighbourEnd; ++neighbourIt) {
+                        if (g[*neighbourIt]._index == g[*vertexIt]._index) {
+                            ++n;
+                        }
+                    }
+                }
+
+                for (InputEdges::const_iterator it = inputs.begin();
+                     it != inputs.end(); ++it) {
+                    if (g[*vertexIt]._index == it->second) {
+                        ++n;
+                    }
+                }
+                _normal_simulators[g[*vertexIt]._index] =
+                    new pdevs::Simulator <
+                        common::DoubleTime, NormalPixel < SchedulerHandle >,
+                        SchedulerHandle, NormalPixelParameters >(
+                            ss.str(), NormalPixelParameters(n));
+                _normal_simulators[g[*vertexIt]._index]->add_in_port("in");
+                _normal_simulators[g[*vertexIt]._index]->add_out_port("out");
+                FlatGraphManager < SchedulerHandle, Parameters >::add_child(
+                    _normal_simulators[g[*vertexIt]._index]);
+                break;
+            };
+        }
+
+        boost::tie(vertexIt, vertexEnd) = boost::vertices(g);
+        for (; vertexIt != vertexEnd; ++vertexIt)
+        {
+            OrientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+            boost::tie(neighbourIt, neighbourEnd) =
+                boost::adjacent_vertices(*vertexIt, g);
+            for (; neighbourIt != neighbourEnd; ++neighbourIt) {
+                paradevs::common::Model < common::DoubleTime,
+                                          SchedulerHandle >* a = 0;
+                paradevs::common::Model < common::DoubleTime,
+                                          SchedulerHandle >* b = 0;
+
+                if (g[*vertexIt]._type == TOP_PIXEL) {
+                    a = _top_simulators[g[*vertexIt]._index];
+                } else {
+                    a = _normal_simulators[g[*vertexIt]._index];
+                }
+                if (g[*neighbourIt]._type == TOP_PIXEL) {
+                    b = _top_simulators[g[*neighbourIt]._index];
+                } else {
+                    b = _normal_simulators[g[*neighbourIt]._index];
+                }
+                FlatGraphManager < SchedulerHandle,
+                                   Parameters >::add_link(a, "out",
+                                                          b, "in");
+            }
+        }
+    }
+
+protected:
+    typedef std::map < int, pdevs::Simulator <
+                                common::DoubleTime,
+                                TopPixel < SchedulerHandle >,
+                                SchedulerHandle,
+                                TopPixelParameters >* > TopSimulators;
+    typedef std::map < int, pdevs::Simulator <
+                                common::DoubleTime,
+                                NormalPixel < SchedulerHandle >,
+                                SchedulerHandle,
+                                NormalPixelParameters >* > NormalSimulators;
+
+    TopSimulators    _top_simulators;
+    NormalSimulators _normal_simulators;
+};
+
+template < class SchedulerHandle >
+class BuiltFlatGraphManager :
+        public FlatGraphManager < SchedulerHandle, GraphParameters >
+{
+public:
+    BuiltFlatGraphManager(
+        common::Coordinator < common::DoubleTime,
+                              SchedulerHandle >* coordinator,
+        const GraphParameters& parameters) :
+        FlatGraphManager < SchedulerHandle, GraphParameters >(
+            coordinator, parameters)
+    {
+        BuiltFlatGraphManager < SchedulerHandle >::build_flat_graph(
+            parameters._graph, parameters._input_edges);
+        // input
+
+        // std::cout << "Input edges:" << std::endl;
+
+        for (Edges::const_iterator it = parameters._input_edges.begin();
+             it != parameters._input_edges.end(); ++it) {
+            std::ostringstream ss_in;
+
+            ss_in << "in_" << it->first;
+            if (not coordinator->exist_in_port(ss_in.str())) {
+                coordinator->add_in_port(ss_in.str());
+            }
+            BuiltFlatGraphManager < SchedulerHandle>::add_link(
+                coordinator, ss_in.str(),
+                BuiltFlatGraphManager <
+                    SchedulerHandle >::_normal_simulators[it->second], "in");
+
+            // std::cout << "link = " << coordinator->get_name()
+            //           << "::" << ss_in.str() << " -> "
+            //           << BuiltFlatGraphManager <
+            //               SchedulerHandle >::_normal_simulators[it->second]
+            //     ->get_name() << "::" << "in" << std::endl;
+
+        }
+        // output
+
+        // std::cout << "Output edges:" << std::endl;
+
+        for (Edges::const_iterator it = parameters._output_edges.begin();
+             it != parameters._output_edges.end(); ++it) {
+            std::ostringstream ss_out;
+
+            ss_out << "out_" << it->first;
+            if (not coordinator->exist_out_port(ss_out.str())) {
+                coordinator->add_out_port(ss_out.str());
+            }
+
+            if (BuiltFlatGraphManager <
+                    SchedulerHandle >::_normal_simulators.find(it->first) !=
+                BuiltFlatGraphManager <
+                    SchedulerHandle >::_normal_simulators.end()) {
+                if (not BuiltFlatGraphManager < SchedulerHandle>::exist_link(
+                        BuiltFlatGraphManager <
+                            SchedulerHandle >::_normal_simulators[it->first],
+                        "out", coordinator, ss_out.str())) {
+                    BuiltFlatGraphManager < SchedulerHandle>::add_link(
+                        BuiltFlatGraphManager <
+                            SchedulerHandle >::_normal_simulators[it->first],
+                        "out", coordinator, ss_out.str());
+
+                    // std::cout << "link = " << BuiltFlatGraphManager <
+                    //     SchedulerHandle >::_normal_simulators[it->first]
+                    //     ->get_name() << "::" << "out -> "
+                    //           << coordinator->get_name()
+                    //           << "::" << ss_out.str()
+                    //           << std::endl;
+                }
+            } else {
+                if (not BuiltFlatGraphManager < SchedulerHandle>::exist_link(
+                        BuiltFlatGraphManager <
+                            SchedulerHandle >::_top_simulators[it->first],
+                        "out", coordinator, ss_out.str())) {
+                    BuiltFlatGraphManager < SchedulerHandle>::add_link(
+                        BuiltFlatGraphManager <
+                            SchedulerHandle >::_top_simulators[it->first],
+                        "out", coordinator, ss_out.str());
+
+                    // std::cout << "link = " << BuiltFlatGraphManager <
+                    //     SchedulerHandle >::_top_simulators[it->first]
+                    //     ->get_name() << "::" << "out -> "
+                    //           << coordinator->get_name()
+                    //           << "::" << ss_out.str()
+                    //           << std::endl;
+
+                }
+            }
+        }
+    }
+
+    virtual ~BuiltFlatGraphManager()
+    { }
+};
+
+template < class SchedulerHandle >
+class ParallelBuiltFlatGraphManager :
+        public FlatGraphManager < SchedulerHandle, GraphParameters >
+{
+public:
+    ParallelBuiltFlatGraphManager(
+        common::Coordinator < common::DoubleTime,
+                              SchedulerHandle >* coordinator,
+        const GraphParameters& parameters) :
+        FlatGraphManager < SchedulerHandle, GraphParameters >(
+            coordinator, parameters)
+    {
+        ParallelBuiltFlatGraphManager < SchedulerHandle >::build_flat_graph(
+            parameters._graph, parameters._input_edges);
+        // input
+        for (Edges::const_iterator it = parameters._input_edges.begin();
+             it != parameters._input_edges.end(); ++it) {
+            std::ostringstream ss_in;
+
+            ss_in << "in_" << it->first;
+            if (not coordinator->exist_in_port(ss_in.str())) {
+                coordinator->add_in_port(ss_in.str());
+            }
+            ParallelBuiltFlatGraphManager < SchedulerHandle>::add_link(
+                coordinator, ss_in.str(),
+                ParallelBuiltFlatGraphManager <
+                    SchedulerHandle >::_normal_simulators[it->second], "in");
+        }
+        // output
+        for (Edges::const_iterator it = parameters._output_edges.begin();
+             it != parameters._output_edges.end(); ++it) {
+            std::ostringstream ss_out;
+
+            ss_out << "out_" << it->first;
+            if (not coordinator->exist_out_port(ss_out.str())) {
+                coordinator->add_out_port(ss_out.str());
+            }
+            if (not ParallelBuiltFlatGraphManager < SchedulerHandle >::exist_link(
+                ParallelBuiltFlatGraphManager <
+                    SchedulerHandle >::_normal_simulators[it->first], "out",
+                coordinator, ss_out.str())) {
+                ParallelBuiltFlatGraphManager < SchedulerHandle>::add_link(
+                    ParallelBuiltFlatGraphManager <
+                        SchedulerHandle >::_normal_simulators[it->first], "out",
+                    coordinator, ss_out.str());
+            }
+        }
+    }
+
+    void init()
+    { }
+
+    void start(common::DoubleTime::type /* t */)
+    { }
+
+    void transition(
+        const common::Models < common::DoubleTime,
+                               SchedulerHandle >& /* receivers */,
+        common::DoubleTime::type /* t */)
+    { }
+
+    virtual ~ParallelBuiltFlatGraphManager()
+    { }
+};
+
+template < class SchedulerHandle, class GraphBuilder >
+class InBuildFlatGraphManager :
+        public FlatGraphManager < SchedulerHandle,
+                                  paradevs::common::NoParameters >
+{
+public:
+    InBuildFlatGraphManager(
+        common::Coordinator < common::DoubleTime,
+                              SchedulerHandle >* coordinator,
+        const paradevs::common::NoParameters& parameters) :
+        FlatGraphManager < SchedulerHandle, paradevs::common::NoParameters >(
+            coordinator, parameters)
+    {
+        GraphBuilder   builder;
+        OrientedGraphs graphs;
+        InputEdgeList  input_edges;
+        OutputEdgeList output_edges;
+        Connections    parent_connections;
+
+        builder.build(graphs, input_edges, output_edges, parent_connections);
+        InBuildFlatGraphManager < SchedulerHandle,
+                                  GraphBuilder >::build_flat_graph(
+                                      graphs.front(), InputEdges());
+    }
+
+    virtual ~InBuildFlatGraphManager()
+    { }
+};
+
+struct PartitioningParameters
+{
+    int         cluster_number;
+    std::string partitioning_method_name;
+    int         contraction_coef;
+    bool        contraction_coef_flag;
+
+    PartitioningParameters(int cn,
+                           const std::string& pmn,
+                           int cc, bool ccf) :
+        cluster_number(cn), partitioning_method_name(pmn),
+        contraction_coef(cc), contraction_coef_flag(ccf)
+    { }
+};
+
+template < class SchedulerHandle, class GraphBuilder >
+class HeapHierarchicalGraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               SchedulerHandle,
+                                               PartitioningParameters >
+{
+public:
+    HeapHierarchicalGraphManager(
+        common::Coordinator < common::DoubleTime,
+                              SchedulerHandle >* coordinator,
+        const PartitioningParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime, SchedulerHandle,
+                                        PartitioningParameters >(
+                                            coordinator, parameters)
+    {
+        GraphBuilder graph_builder(parameters.cluster_number,
+                                   parameters.partitioning_method_name,
+                                   parameters.contraction_coef,
+                                   parameters.contraction_coef_flag);
+        OrientedGraphs graphs;
+        InputEdgeList  input_edges;
+        OutputEdgeList output_edges;
+        Connections    parent_connections;
+
+        graph_builder.build(graphs, input_edges, output_edges,
+                            parent_connections);
+
+        // build coordinators (graphs)
+        for (unsigned int i = 0; i < graphs.size(); ++i) {
+            Coordinator* coordinator = 0;
+            std::ostringstream ss;
+
+            ss << "S" << i;
+            coordinator =
+                new Coordinator(ss.str(), paradevs::common::NoParameters(),
+                                GraphParameters(graphs[i], input_edges[i],
+                                                output_edges[i]));
+            _coordinators.push_back(coordinator);
+            HeapHierarchicalGraphManager < SchedulerHandle,
+                                           GraphBuilder >::add_child(
+                                               coordinator);
+
+        }
+
+        // std::cout << "Root:" << std::endl;
+
+        // builds internal connections (edges)
+        for (Connections::const_iterator it = parent_connections.begin();
+             it != parent_connections.end(); ++it) {
+            const Connection& connection = *it;
+            std::ostringstream ss_out;
+            std::ostringstream ss_in;
+
+            ss_out << "out_" << connection.first.second;
+            ss_in << "in_" << connection.first.second;
+
+            if (not HeapHierarchicalGraphManager <
+                    SchedulerHandle, GraphBuilder >::exist_link(
+                        _coordinators[connection.first.first - 1],
+                        ss_out.str(),
+                        _coordinators[connection.second.first - 1],
+                        ss_in.str())) {
+
+                // std::cout << "link = "
+                //           << _coordinators[connection.first.first - 1]
+                //     ->get_name()
+                //           << "::" << ss_out.str() << " -> "
+                //           << _coordinators[connection.second.first - 1]
+                //     ->get_name()
+                //           << "::" << ss_in.str() << std::endl;
+
+                HeapHierarchicalGraphManager <
+                    SchedulerHandle, GraphBuilder >::add_link(
+                        _coordinators[connection.first.first - 1],
+                        ss_out.str(),
+                        _coordinators[connection.second.first - 1],
+                        ss_in.str());
+            }
+        }
+    }
+
+    virtual ~HeapHierarchicalGraphManager()
+    {
+        for (typename Coordinators::const_iterator it = _coordinators.begin();
+             it != _coordinators.end(); ++it) {
+            delete *it;
+        }
+    }
+
+private:
+    typedef paradevs::pdevs::Coordinator <
+        common::DoubleTime,
+        SchedulerType,
+        SchedulerHandle,
+        BuiltFlatGraphManager < SchedulerHandle >,
+        common::NoParameters,
+        GraphParameters > Coordinator;
+    typedef std::vector < Coordinator* > Coordinators;
+
+    Coordinators _coordinators;
+};
+
+template < class SchedulerHandle, class GraphBuilder >
+class VectorHierarchicalGraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               SchedulerHandle,
+                                               PartitioningParameters >
+{
+public:
+    VectorHierarchicalGraphManager(
+        common::Coordinator < common::DoubleTime,
+                              SchedulerHandle >* coordinator,
+        const PartitioningParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime, SchedulerHandle,
+                                        PartitioningParameters >(
+                                            coordinator, parameters)
+    {
+        GraphBuilder   graph_builder(parameters.cluster_number,
+                                     parameters.partitioning_method_name,
+                                     parameters.contraction_coef,
+                                     parameters.contraction_coef_flag);
+        OrientedGraphs graphs;
+        InputEdgeList  input_edges;
+        OutputEdgeList output_edges;
+        Connections    parent_connections;
+
+        graph_builder.build(graphs, input_edges, output_edges,
+                            parent_connections);
+
+        // build coordinators (graphs)
+        for (unsigned int i = 0; i < graphs.size(); ++i) {
+            Coordinator* coordinator = 0;
+            std::ostringstream ss;
+
+            ss << "S" << i;
+            coordinator =
+                new Coordinator(ss.str(), paradevs::common::NoParameters(),
+                                GraphParameters(graphs[i], input_edges[i],
+                                                output_edges[i]));
+            _coordinators.push_back(coordinator);
+            VectorHierarchicalGraphManager < SchedulerHandle,
+                                             GraphBuilder >::add_child(
+                                                 coordinator);
+
+        }
+
+        // builds internal connections (edges)
+        for (Connections::const_iterator it = parent_connections.begin();
+             it != parent_connections.end(); ++it) {
+            const Connection& connection = *it;
+            std::ostringstream ss_out;
+            std::ostringstream ss_in;
+
+            ss_out << "out_" << connection.first.second;
+            ss_in << "in_" << connection.first.second;
+
+            if (not VectorHierarchicalGraphManager <
+                    SchedulerHandle, GraphBuilder >::exist_link(
+                        _coordinators[connection.first.first - 1],
+                        ss_out.str(),
+                        _coordinators[connection.second.first - 1],
+                        ss_in.str())) {
+                VectorHierarchicalGraphManager <
+                    SchedulerHandle, GraphBuilder >::add_link(
+                        _coordinators[connection.first.first - 1],
+                        ss_out.str(),
+                        _coordinators[connection.second.first - 1],
+                        ss_in.str());
+            }
+        }
+    }
+
+    virtual ~VectorHierarchicalGraphManager()
+    {
+        for (typename Coordinators::const_iterator it = _coordinators.begin();
+             it != _coordinators.end(); ++it) {
+            delete *it;
+        }
+    }
+
+private:
+    typedef paradevs::pdevs::Coordinator <
+    common::DoubleTime,
+    paradevs::common::scheduler::VectorScheduler <
+        paradevs::common::DoubleTime >,
+    paradevs::common::scheduler::NoSchedulerHandle,
+    BuiltFlatGraphManager < paradevs::common::scheduler::NoSchedulerHandle >,
+    common::NoParameters,
+    GraphParameters > Coordinator;
+    typedef std::vector < Coordinator* > Coordinators;
+
+    Coordinators _coordinators;
+};
+
+template < class SchedulerHandle, class GraphBuilder >
+class ParallelHeapHierarchicalGraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               SchedulerHandle,
+                                               PartitioningParameters >
+{
+public:
+    ParallelHeapHierarchicalGraphManager(
+        common::Coordinator < common::DoubleTime,
+                              SchedulerHandle >* coordinator,
+        const PartitioningParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime, SchedulerHandle,
+                                        PartitioningParameters >(
+                                            coordinator, parameters)
+    {
+        GraphBuilder   graph_builder(parameters.cluster_number,
+                                     parameters.partitioning_method_name,
+                                     parameters.contraction_coef,
+                                     parameters.contraction_coef_flag);
+        OrientedGraphs graphs;
+        InputEdgeList  input_edges;
+        OutputEdgeList output_edges;
+        Connections    parent_connections;
+
+        graph_builder.build(graphs, input_edges, output_edges,
+                            parent_connections);
+
+        // build coordinators (graphs)
+        for (unsigned int i = 0; i < graphs.size(); ++i) {
+            ParallelCoordinator* coordinator = 0;
+            std::ostringstream ss;
+
+            ss << "S" << i;
+            coordinator =
+                new ParallelCoordinator(ss.str(),
+                                        paradevs::common::NoParameters(),
+                                        GraphParameters(graphs[i],
+                                                        input_edges[i],
+                                                        output_edges[i]));
+            _coordinators.push_back(coordinator);
+            ParallelHeapHierarchicalGraphManager < SchedulerHandle,
+                                                   GraphBuilder >::add_child(
+                                                       coordinator);
+
+        }
+
+        // builds internal connections (edges)
+        for (Connections::const_iterator it = parent_connections.begin();
+             it != parent_connections.end(); ++it) {
+            const Connection& connection = *it;
+            std::ostringstream ss_out;
+            std::ostringstream ss_in;
+
+            ss_out << "out_" << connection.first.second;
+            ss_in << "in_" << connection.first.second;
+
+            if (not ParallelHeapHierarchicalGraphManager <
+                    SchedulerHandle, GraphBuilder >::exist_link(
+                        _coordinators[connection.first.first - 1],
+                        ss_out.str(),
+                        _coordinators[connection.second.first - 1],
+                        ss_in.str())) {
+                ParallelHeapHierarchicalGraphManager <
+                    SchedulerHandle, GraphBuilder >::add_link(
+                        _coordinators[connection.first.first - 1],
+                        ss_out.str(),
+                        _coordinators[connection.second.first - 1],
+                        ss_in.str());
+            }
+        }
+    }
+
+    virtual ~ParallelHeapHierarchicalGraphManager()
+    {
+        for (typename Coordinators::const_iterator it = _coordinators.begin();
+             it != _coordinators.end(); ++it) {
+            delete *it;
+        }
+    }
+
+    void init()
+    {
+        for (typename Coordinators::const_iterator it = _coordinators.begin();
+             it != _coordinators.end(); ++it) {
+            (*it)->set_sender(
+                dynamic_cast < paradevs::pdevs::multithreading::Coordinator <
+                    common::DoubleTime,
+                    SchedulerType,
+                    SchedulerHandle,
+                    ParallelHeapHierarchicalGraphManager <
+                        SchedulerHandle,
+                        PartitioningGraphBuilder >,
+                    paradevs::common::NoParameters,
+                    PartitioningParameters >*
+                >(ParallelHeapHierarchicalGraphManager < SchedulerHandle,
+                                                         GraphBuilder >::
+                  get_coordinator())->get_sender());
+        }
+    }
+
+    void start(common::DoubleTime::type t)
+    {
+        for (typename Coordinators::const_iterator it = _coordinators.begin();
+             it != _coordinators.end(); ++it) {
+            (*it)->get_sender().send(
+                paradevs::pdevs::multithreading::start_message <
+                    paradevs::common::DoubleTime >(t));
+        }
+    }
+
+    void transition(const common::Models < common::DoubleTime,
+                    SchedulerHandle >& receivers,
+                    paradevs::common::DoubleTime::type t)
+    {
+        typename Coordinators::const_iterator it = _coordinators.begin();
+        bool found = false;
+
+        while (not found) {
+            if (std::find(receivers.begin(), receivers.end(),
+                          *it) != receivers.end()) {
+                (*it)->get_sender().send(
+                    paradevs::pdevs::multithreading::transition_message <
+                        paradevs::common::DoubleTime >(t));
+                found = true;
+            } else {
+                ++it;
+            }
+        }
+    }
+
+private:
+    typedef paradevs::pdevs::multithreading::Coordinator <
+    common::DoubleTime,
+    SchedulerType,
+    SchedulerHandle,
+    ParallelBuiltFlatGraphManager
+    < SchedulerHandle >,
+    common::NoParameters,
+    GraphParameters > ParallelCoordinator;
+
+    typedef std::vector < ParallelCoordinator* > Coordinators;
+
+    Coordinators _coordinators;
+};
+
+} } } // namespace paradevs tests boost_graph
+
+#endif

+ 171 - 0
src/tests/boost_graph/graph_partitioning.hpp

@@ -0,0 +1,171 @@
+/**
+ * @file tests/boost_graph/graph_partitioning.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __TESTS_BOOST_GRAPH_GRAPH_PARTITIONING_HPP
+#define __TESTS_BOOST_GRAPH_GRAPH_PARTITIONING_HPP 1
+
+#include <tests/boost_graph/graph_defs.hpp>
+#include <tests/boost_graph/partitioning/graph_build.hpp>
+#include <tests/boost_graph/partitioning/gggp.hpp>
+
+#include <boost/graph/copy.hpp>
+
+namespace paradevs { namespace tests { namespace boost_graph {
+
+class PartitioningGraphBuilder
+{
+public:
+    PartitioningGraphBuilder(int cn, std::string pmn, int cc, bool ccf) :
+        cluster_number(cn), partitioning_method_name(pmn),
+        contraction_coef(cc), contraction_coef_flag(ccf)
+    { }
+
+    void build(OrientedGraphs& graphs,
+               InputEdgeList& input_edges,
+               OutputEdgeList& output_edges,
+               Connections& parent_connections)
+    {
+        UnorientedGraph* g = new UnorientedGraph();
+        OrientedGraph go;
+        UnorientedGraph graph_origin;
+
+        // internal examples
+        // {
+        //     build_graph(*g, go);
+        //     boost::copy_graph(*g, graph_origin);
+        // }
+
+        // corsen examples
+        {
+            build_corsen_graph(go);
+            make_unoriented_graph(go, *g);
+            boost::copy_graph(*g, graph_origin);
+        }
+
+        Edges edge_partie;
+        Connections connections;
+
+        output_edges = OutputEdgeList(cluster_number);
+
+        if (contraction_coef_flag) {
+            graphs = Multiniveau(num_vertices(*g) / contraction_coef,
+                                 g, &graph_origin, &go,
+                                 cluster_number, "HEM",
+                                 partitioning_method_name,
+                                 "cut_norm", "norm", edge_partie ,
+                                 output_edges, input_edges,
+                                 parent_connections);
+        } else {
+            graphs = Multiniveau(contraction_coef, g, &graph_origin, &go,
+                                 cluster_number, "HEM",
+                                 partitioning_method_name,
+                                 "cut_norm", "norm", edge_partie ,
+                                 output_edges, input_edges,
+                                 parent_connections);
+        }
+
+        // std::cout << "*********************************" << std::endl;
+        // std::cout << "Graphs:" << std::endl;
+        // for (unsigned int i = 0; i < graphs.size(); ++i) {
+        //     std::cout << "graph[" << i << "]:" << std::endl;
+        //     const OrientedGraph& og = graphs[i];
+        //     OrientedGraph::vertex_iterator it_og, end_og;
+
+        //     tie(it_og, end_og) = vertices(og);
+        //     for (; it_og != end_og; ++it_og) {
+        //         OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
+
+        //         std::cout << og[*it_og]._index << " -> { ";
+        //         tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_og,
+        //                                                              og);
+        //         for (; neighbour_it != neighbour_end; ++neighbour_it) {
+        //             std::cout << og[*neighbour_it]._index << " ";
+        //         }
+        //         std::cout << "}" << std::endl;
+        //     }
+        // }
+        // {
+        //     unsigned int i = 0;
+
+        //     std::cout << "Input edges:" << std::endl;
+        //     for (InputEdgeList::const_iterator it = input_edges.begin();
+        //          it != input_edges.end(); ++it, ++i) {
+        //         std::cout << "S" << i << " = {";
+        //         for (InputEdges::const_iterator it2 = it->begin();
+        //              it2 != it->end(); ++it2) {
+        //             std::cout << " ( " << it2->first << " -> " << it2->second
+        //                       << " )";
+        //         }
+        //         std::cout << " }" << std::endl;;
+        //     }
+        // }
+        // {
+        //     unsigned int i = 0;
+
+        //     std::cout << "Output edges:" << std::endl;
+        //     for (OutputEdgeList::const_iterator it = output_edges.begin();
+        //          it != output_edges.end(); ++it, ++i) {
+        //         std::cout << "S" << i << " = {";
+        //         for (OutputEdges::const_iterator it2 = it->begin();
+        //              it2 != it->end(); ++it2) {
+        //             std::cout << " ( " << it2->first << " -> " << it2->second
+        //                       << " )";
+        //         }
+        //         std::cout << " }" << std::endl;;
+        //     }
+        // }
+
+        // std::cout << "*********************************" << std::endl;
+
+    }
+
+private:
+    int cluster_number;
+    std::string partitioning_method_name;
+    int contraction_coef;
+    bool contraction_coef_flag;
+};
+
+class CorsenFlatGraphBuilder
+{
+public:
+    CorsenFlatGraphBuilder()
+    { }
+
+    void build(OrientedGraphs& graphs, InputEdgeList& /* input_edges */,
+               OutputEdgeList& /* output_edges */,
+               Connections& /* parent_connections */)
+    {
+        OrientedGraph graph;
+
+        build_corsen_graph(graph);
+        graphs.push_back(graph);
+    }
+};
+
+} } } // namespace paradevs tests boost_graph
+
+#endif

+ 207 - 0
src/tests/boost_graph/models.hpp

@@ -0,0 +1,207 @@
+/**
+ * @file tests/boost_graph/models.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_BOOST_GRAPH_MODELS_HPP
+#define TESTS_BOOST_GRAPH_MODELS_HPP 1
+
+#include <paradevs/common/time/DoubleTime.hpp>
+#include <paradevs/kernel/pdevs/Dynamics.hpp>
+
+namespace paradevs { namespace tests { namespace boost_graph {
+
+struct TopPixelParameters
+{ };
+
+template < class SchedulerHandle>
+class TopPixel :
+    public paradevs::pdevs::Dynamics < common::DoubleTime, SchedulerHandle,
+                                       TopPixelParameters >
+{
+public:
+    TopPixel(const std::string& name,
+             const TopPixelParameters& parameters) :
+        paradevs::pdevs::Dynamics < common::DoubleTime, SchedulerHandle,
+                                    TopPixelParameters >(name, parameters)
+    { }
+
+    virtual ~TopPixel()
+    { }
+
+    virtual void dint(typename common::DoubleTime::type /* t */)
+    {
+
+        // std::cout << TopPixel < SchedulerHandle >::get_name() << " at "
+        //           << t << ": dint" << std::endl;
+
+    }
+
+    virtual typename common::DoubleTime::type start(
+        typename common::DoubleTime::type /* t */)
+    { return 0; }
+
+    virtual typename common::DoubleTime::type ta(
+        typename common::DoubleTime::type /* t */) const
+    { return 1; }
+
+    virtual common::Bag < common::DoubleTime, SchedulerHandle > lambda(
+        typename common::DoubleTime::type /* t */) const
+    {
+
+        // std::cout << TopPixel < SchedulerHandle >::get_name() << " at "
+        //           << t << ": lambda" << std::endl;
+
+        common::Bag < common::DoubleTime, SchedulerHandle > bag;
+
+        bag.push_back(common::ExternalEvent < common::DoubleTime,
+                                              SchedulerHandle >("out", 0.));
+        return bag;
+    }
+};
+
+struct NormalPixelParameters
+{
+    NormalPixelParameters(unsigned int n) : _neighbour_number(n)
+    { }
+
+    unsigned int _neighbour_number;
+};
+
+template < class SchedulerHandle>
+class NormalPixel :
+    public paradevs::pdevs::Dynamics < common::DoubleTime, SchedulerHandle,
+                                       NormalPixelParameters >
+{
+public:
+    NormalPixel(const std::string& name,
+             const NormalPixelParameters& parameters) :
+        paradevs::pdevs::Dynamics < common::DoubleTime, SchedulerHandle,
+                                    NormalPixelParameters >(name, parameters),
+        _neighbour_number(parameters._neighbour_number)
+    { }
+
+    virtual ~NormalPixel()
+    { }
+
+    virtual void dint(typename common::DoubleTime::type t)
+    {
+
+        // std::cout << NormalPixel < SchedulerHandle >::get_name() << " at "
+        //           << t << ": dint" << std::endl;
+
+        if (_phase == SEND) {
+            _phase = WAIT;
+            _received = 0;
+            _last_time = t;
+        }
+    }
+
+    virtual void dext(typename common::DoubleTime::type t,
+                      typename common::DoubleTime::type /* e */,
+                      const common::Bag < common::DoubleTime,
+                                          SchedulerHandle >& bag)
+    {
+
+        // std::cout << NormalPixel < SchedulerHandle >::get_name() << " at "
+        //           << t << ": dext -> "
+        //           << bag.to_string() << std::endl;
+
+        for (typename common::Bag < common::DoubleTime,
+                                    SchedulerHandle >::const_iterator it =
+                 bag.begin(); it != bag.end(); ++it) {
+            if (it->on_port("in")) {
+                if (_last_time == t) {
+                    std::cout << "oups !" << std::endl;
+                }
+                ++_received;
+                if (_received == _neighbour_number) {
+                    _phase = SEND;
+                }
+            }
+        }
+
+        // std::cout << NormalPixel < SchedulerHandle >::get_name() << " at "
+        //           << t << ": dext -> "
+        //           << _received << "/" << _neighbour_number
+        //           << std::endl;
+
+    }
+
+    virtual typename common::DoubleTime::type start(
+        typename common::DoubleTime::type /* t */)
+    {
+
+        // std::cout << NormalPixel < SchedulerHandle >::get_name()
+        //           << " = " <<_neighbour_number << std::endl;
+
+        _phase = WAIT;
+        _received = 0;
+        _last_time = common::DoubleTime::negative_infinity;
+        return common::DoubleTime::infinity;
+    }
+
+    virtual typename common::DoubleTime::type ta(
+        typename common::DoubleTime::type /* t */) const
+    {
+
+        // std::cout << NormalPixel < SchedulerHandle >::get_name() << " at "
+        //           << t << ": ta" << std::endl;
+
+        if (_phase == WAIT) {
+            return common::DoubleTime::infinity;
+        } else {
+            return 0;
+        }
+    }
+
+    virtual common::Bag < common::DoubleTime, SchedulerHandle > lambda(
+        typename common::DoubleTime::type /* t */) const
+    {
+
+        // std::cout << NormalPixel < SchedulerHandle >::get_name() << " at "
+        //           << t << ": lambda" << std::endl;
+
+        common::Bag < common::DoubleTime, SchedulerHandle > bag;
+
+        if (_phase == SEND) {
+            bag.push_back(common::ExternalEvent < common::DoubleTime,
+                                                  SchedulerHandle >("out", 0.));
+        }
+        return bag;
+    }
+
+private:
+    enum Phase { WAIT, SEND };
+
+    unsigned int _neighbour_number;
+
+    Phase                             _phase;
+    unsigned int                      _received;
+    typename common::DoubleTime::type _last_time;
+};
+
+} } } // namespace paradevs tests boost_graph
+
+#endif

+ 30 - 0
src/tests/boost_graph/partitioning/CMakeLists.txt

@@ -0,0 +1,30 @@
+INCLUDE_DIRECTORIES(
+  ${CMAKE_SOURCE_DIR}/src
+  ${PARADEVS_INCLUDE_DIRS}
+  ${Boost_INCLUDE_DIRS}
+  ${GLIBMM_INCLUDE_DIRS}
+  ${LIBXML_INCLUDE_DIRS})
+
+LINK_DIRECTORIES(
+  ${GLIBMM_LIBRARY_DIRS}
+  ${LIBXML_LIBRARY_DIR})
+
+SET(PARTITIONING_HPP utils.hpp gggp.hpp graph_build.hpp)
+
+SET(PARTITIONING_CPP utils.cpp gggp.cpp graph_build.cpp)
+
+ADD_LIBRARY(partitioning SHARED ${PARTITIONING_HPP};${PARTITIONING_CPP})
+
+TARGET_LINK_LIBRARIES(partitioning corsen
+  ${Boost_LIBRARIES}
+  ${GLIBMM_LIBRARIES}
+  ${LIBXML_LIBRARIES}
+  ${GTHREAD_LIBRARIES})
+
+ADD_EXECUTABLE(partitioning-tests main.cpp)
+
+TARGET_LINK_LIBRARIES(partitioning-tests partitioning
+  ${Boost_LIBRARIES}
+  ${GLIBMM_LIBRARIES}
+  ${LIBXML_LIBRARIES}
+  ${GTHREAD_LIBRARIES})

+ 71 - 0
src/tests/boost_graph/partitioning/defs.hpp

@@ -0,0 +1,71 @@
+/**
+ * @file tests/boost_graph/partitioning/defs.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_BOOST_GRAPH_PARTITIONING_DEFS_H
+#define TESTS_BOOST_GRAPH_PARTITIONING_DEFS_H 1
+
+#include <list>
+#include <vector>
+
+#include <boost/graph/adjacency_list.hpp>
+
+#include <tests/boost_graph/graph_defs.hpp>
+
+namespace paradevs { namespace tests { namespace boost_graph {
+
+typedef unsigned int uint;
+
+typedef std::vector < int > Entiers;
+
+typedef std::vector < Entiers* > EntiersEntiers;
+typedef std::vector < EntiersEntiers > EntiersEntiersEntiers;
+typedef std::list < int > List;
+typedef std::list < EntiersEntiers* > ListEntiersEntiers;
+
+typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS,
+                                VertexProperties,
+                                EdgeProperties> UnorientedGraph;
+
+typedef std::vector < UnorientedGraph* > Base_Graph;
+
+typedef boost::graph_traits < UnorientedGraph >::vertex_descriptor vertex_t;
+typedef boost::graph_traits < UnorientedGraph >::edge_descriptor edge_t;
+
+typedef OrientedGraph::vertex_descriptor vertex_to;
+typedef OrientedGraph::edge_descriptor edge_to;
+
+template < class G >
+struct VertexAndEdgeListGraphConcept
+{
+    void constraints() {
+        boost::function_requires < boost::VertexListGraphConcept < G > >();
+        boost::function_requires < boost::EdgeListGraphConcept < G > >();
+    }
+};
+
+} } } // namespace paradevs tests boost_graph
+
+#endif

+ 939 - 0
src/tests/boost_graph/partitioning/gggp.cpp

@@ -0,0 +1,939 @@
+/**
+ * @file tests/boost_graph/partitioning/gggp.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <tests/boost_graph/partitioning/gggp.hpp>
+
+#include <algorithm>
+#include <iostream>
+
+namespace paradevs { namespace tests { namespace boost_graph {
+
+extern UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+extern UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+extern OrientedGraph::vertex_iterator vertexIto, vertexEndo;
+extern OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
+
+void ggp(UnorientedGraph *g, Entiers *sommetsSource,
+               Entiers *sommetsDestination, EntiersEntiers &Partition)
+{
+    //std::cout<<""<<std::endl;
+    int val;
+    Entiers sommets_adj;
+    if(sommetsSource->size()==1){
+        val=0;
+        //std::cout<<"Entré dans le debug ! "<<std::endl;
+        Entiers tailles;
+        for(uint i=0;i<Partition.size();i++){
+            tailles.push_back(Partition.at(i)->size());
+        }
+        uint tmp=*max_element(tailles.begin(),tailles.end());
+        for(uint i=0; i<Partition.size();i++){
+            if(Partition.at(i)->size()==tmp)
+            {
+                ggp(g,Partition[i],sommetsDestination,Partition);
+                return;
+            }
+        }
+    }
+    else
+        val=rand_fini(0,sommetsSource->size()-1);//Tirage aléatoire de l'indice du premier sommet entre 0 et taille du tableau -1
+        //std::cout<<"val : "<<sommetsSource->at(val)<<std::endl;
+    double poids_max=0;
+    for(uint i=0;i<sommetsSource->size();i++){
+        poids_max+=(*g)[sommetsSource->at(i)]._weight;
+    }
+    poids_max/=2.;
+
+    double poids=(*g)[sommetsSource->at(val)]._weight;
+    sommetsDestination->push_back(sommetsSource->at(val));
+    sommetsSource->erase(sommetsSource->begin() + val);
+    int cpt = 0;
+
+   // std::cout<<"taille sommetsSource avant le while : "<<sommetsSource->size()<<std::endl;
+    while(poids<poids_max && sommetsSource->size()>1)
+    {
+        //std::cout<<"taille sommetsSource dans le while "<<sommetsSource->size()<<std::endl;
+        if(cpt<sommetsDestination->size() )
+            adjacence_ggp(sommetsDestination->at(cpt),sommets_adj,g);
+        else{
+            val=rand_fini(0,sommetsSource->size()-1);
+            sommetsDestination->push_back(sommetsSource->at(val));
+            sommetsSource->erase(sommetsSource->begin() + val);
+            adjacence_ggp(sommetsDestination->at(cpt),sommets_adj,g);
+        }
+        /*std::cout<<"adj :"<<std::endl;
+        for(uint a = 0; a<sommets_adj.size(); a++){
+            std::cout<<sommets_adj.at(a)<<std::endl;
+        }*/
+        if(sommets_adj.size()==0)
+        {
+            //std::cout<<"Je suis sorti car pas de voisin !!!! "<<std::endl;
+            for (uint i=0; i<sommetsSource->size();i++)
+            {
+                for (uint j=0; j<sommetsDestination->size();j++)
+                {
+                    remove_edge(sommetsSource->at(i),sommetsDestination->at(j),*g);
+                }
+            }
+            sort(sommetsDestination->begin(), sommetsDestination->end());
+            return;
+        }
+        else{
+            for(uint i =0; i<sommets_adj.size(); i++){
+                if(In_tab(*sommetsDestination,sommets_adj.at(i))!=1 && sommetsSource->size()!=1){
+                    sommetsDestination->push_back(sommets_adj.at(i));
+                    poids+=(*g)[sommets_adj.at(i)]._weight;
+                    suprim_val(*sommetsSource, sommets_adj[i]);
+                }
+                if(poids>poids_max || sommetsSource->size()==1)
+                    break;
+            }
+
+            /*std::cout<<"Sommets_source :"<<std::endl;
+            for(uint i =0; i<sommetsSource->size();i++){
+                std::cout<<sommetsSource->at(i)<<",";
+            }
+            std::cout<<std::endl;
+            std::cout<<"Sommets_destination :"<<std::endl;
+            for(uint i =0; i<sommetsDestination->size();i++){
+                std::cout<<sommetsDestination->at(i)<<",";
+            }
+            std::cout<<std::endl;*/
+
+            if(poids>poids_max  || sommetsSource->size()==1){
+                for (uint i=0; i<sommetsSource->size();i++)
+                {
+                    for (uint j=0; j<sommetsDestination->size();j++)
+                    {
+                        remove_edge(sommetsSource->at(i),sommetsDestination->at(j),*g);
+                    }
+                }
+                sort(sommetsDestination->begin(), sommetsDestination->end());
+                return;
+            }
+
+            sommets_adj.clear();
+            cpt++;
+        }
+
+    }
+
+    for (uint i=0; i<sommetsSource->size();i++)
+    {
+        for (uint j=0; j<sommetsDestination->size();j++)
+        {
+            remove_edge(sommetsSource->at(i),sommetsDestination->at(j),*g);
+        }
+    }
+    sort(sommetsDestination->begin(), sommetsDestination->end());
+}
+
+void Iter_2l(EntiersEntiers &part, int nbr_parties, UnorientedGraph *g,
+             const std::string &nom)
+{
+    if (nom =="gggp"){
+
+        for(int i = 0; i<floor(log(nbr_parties)/log(2)); i++)
+        {
+            for(int j = 0; j< pow(2,i);j++)
+            {
+                Entiers *Q = new Entiers();
+                gggp(g,part[j],Q,part);
+                part.push_back(Q);
+            }
+        }
+    }
+
+    else if (nom =="ggp"){
+ for(int i = 0; i<floor(log(nbr_parties)/log(2)); i++)
+        {
+            //std::cout<<"Et un tours de plus !!!! "<<std::endl;
+            for(int j = 0; j< pow(2,i);j++)
+            {
+                Entiers *Q = new Entiers();
+                ggp(g,part[j],Q,part);
+                part.push_back(Q);
+            }
+
+        }
+    }
+
+    else {
+        //std::cout<<"je jsuis dans gggp_pond"<<std::endl;
+
+        for(int i = 0; i<floor(log(nbr_parties)/log(2)); i++)
+        {
+            //std::cout<<"Et un tours de plus !!!! "<<std::endl;
+            for(int j = 0; j< pow(2,i);j++)
+            {
+                Entiers *Q = new Entiers();
+                gggp_pond(g,part.at(j),Q,part);
+                //std::clog<<"sortie du gggp_pond"<<std::endl;
+                part.push_back(Q);
+            }
+            //std::cout<<"\n"<<std::endl;
+
+        }
+    }
+}
+
+void bissectionRec(UnorientedGraph *g, EntiersEntiers &Partition,
+                   int nbr_parties, const std::string &nom)
+{
+    if((nbr_parties&(nbr_parties-1))==0)
+    {
+        //std::cout<<"C'est de la forme 2l : "<<nbr_parties<<std::endl;
+        Iter_2l(Partition,nbr_parties,g,nom);
+    }
+    else
+    {
+        int puissance_2=0;
+
+        Entiers tailles;
+
+        while(pow(2,puissance_2)<nbr_parties)
+            puissance_2++;
+
+        Iter_2l(Partition,pow(2,puissance_2-1),g,nom);
+
+        for(unsigned int i = 0; i< Partition.size() -1 ; i++)
+        {
+            for(EntiersEntiers::iterator it1 = Partition.begin() + i ; it1!=Partition.end(); it1++)
+            {
+                if((*it1)->size() > Partition.at(i)->size())
+                    Partition.at(i)->swap(**it1);
+            }
+        }
+
+        for(int j = 0; j<nbr_parties-pow(2,puissance_2-1);j++)
+        {
+            Entiers *Q = new Entiers();
+            if(nom=="gggp")
+                gggp(g,Partition.at(j),Q,Partition);
+            else if (nom == "ggp")
+                ggp(g,Partition.at(j),Q,Partition);
+            else
+                gggp_pond(g,Partition.at(j),Q,Partition);
+            Partition.push_back(Q);
+        }
+    }
+}
+
+
+
+void gggp(UnorientedGraph *g, Entiers *sommetsSource,
+          Entiers *sommetsDestination, EntiersEntiers &Partition)
+{
+    int val;
+    Entiers sommets_adj;
+
+    if (sommetsSource->size() - 1 == 0) {
+        Entiers tailles;
+
+        val = 0;
+        for (uint i = 0;i < Partition.size(); i++) {
+            tailles.push_back(Partition.at(i)->size());
+        }
+
+        uint tmp = *max_element(tailles.begin(), tailles.end());
+
+        for (uint i = 0; i < Partition.size(); i++) {
+            if (Partition.at(i)->size() == tmp) {
+                gggp(g, Partition.at(i), sommetsDestination, Partition);
+            }
+            break;
+        }
+    } else {
+
+        // Tirage aléatoire de l'indice du premier sommet entre 0 et
+        // taille du tableau -1
+        val = rand_fini(0, sommetsSource->size() - 1);
+    }
+
+    float poids_max=sommetsSource->size()/2.;
+    float poids=1;
+    Entiers sommets_cut;
+
+    //clog<<"Etape 1 : "<<std::endl;
+    sommetsDestination->push_back(sommetsSource->at(val));
+    sommetsSource->erase(sommetsSource->begin() + val);
+
+    if (sommetsSource->size() < 2) {
+        return;
+    }
+
+    while (poids < poids_max) {
+//		for(uint i =0; i< sommetsDestination.size();i++){
+//			std::cout<<sommetsDestination.at(i)<<std::endl;
+//		}
+        Liste_Voisin(*sommetsDestination, sommets_adj, *g);
+        if (sommets_adj.size() == 0) {
+            for (uint i=0; i<sommetsSource->size();i++)
+            {
+                for (uint j=0; j<sommetsDestination->size();j++)
+                {
+                    remove_edge(sommetsSource->at(i),sommetsDestination->at(j),*g);
+                }
+            }
+            sort(sommetsDestination->begin(), sommetsDestination->end());
+            return;
+        } else {
+            /*clog<<"Liste voisin est : "<<std::endl;
+              for(int i=0;i<sommets_adj.size();i++)
+              {
+              std::cout<<sommets_adj[i]<<std::endl;
+              }*/
+            std::sort(sommets_adj.begin(), sommets_adj.end());
+            for (uint i = 0; i < sommets_adj.size(); i++) {
+                sommets_cut.push_back(Cout_coupe(*sommetsDestination,
+                                                 sommets_adj[i], *g));
+            }
+
+            int tmp = recherche_val(sommets_cut,
+                                    *min_element(sommets_cut.begin(),
+                                                 sommets_cut.end()));
+            sommetsDestination->push_back(sommets_adj[tmp]);
+            suprim_val(*sommetsSource, sommets_adj[tmp]);
+            suprim_val(sommets_adj, sommets_adj[tmp]);
+
+            sommets_cut.clear();
+            poids++;
+        }
+    }
+
+    for (uint i = 0; i < sommetsSource->size(); i++) {
+        for (uint j = 0; j < sommetsDestination->size(); j++) {
+            remove_edge(sommetsSource->at(i), sommetsDestination->at(j), *g);
+        }
+    }
+    sort(sommetsDestination->begin(), sommetsDestination->end());
+}
+
+void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource,
+               Entiers *sommetsDestination, EntiersEntiers &Partition)
+{
+    int val;
+    Entiers sommets_adj;
+    if(sommetsSource->size()==1){
+        val=0;
+        Entiers tailles;
+        for(uint i=0;i<Partition.size();i++){
+            tailles.push_back(Partition.at(i)->size());
+        }
+        uint tmp=*max_element(tailles.begin(),tailles.end());
+        for(uint i=0; i<Partition.size();i++){
+            if(Partition.at(i)->size()==tmp)
+            {
+                gggp_pond(g,Partition[i],sommetsDestination,Partition);
+                return;
+            }
+        }
+    }
+    else
+        val=rand_fini(0,sommetsSource->size()-1);
+    double poids_max=0;
+    for(uint i=0;i<sommetsSource->size();i++){
+        poids_max+=(*g)[sommetsSource->at(i)]._weight;
+    }
+    poids_max/=2.;
+    double poids=(*g)[sommetsSource->at(val)]._weight;
+    std::vector<float> sommets_cut;
+    float cut = Degree(*g,sommetsSource->at(val));
+    sommetsDestination->push_back(sommetsSource->at(val));
+    sommetsSource->erase(sommetsSource->begin() + val);
+
+    while(poids<poids_max && sommetsSource->size()>1)
+    {
+        Liste_Voisin(*sommetsDestination,sommets_adj,*g);
+        if(sommets_adj.size()==0)
+        {
+            for (uint i=0; i<sommetsSource->size();i++)
+            {
+                for (uint j=0; j<sommetsDestination->size();j++)
+                {
+                    remove_edge(sommetsSource->at(i),sommetsDestination->at(j),*g);
+                }
+            }
+            sort(sommetsDestination->begin(), sommetsDestination->end());
+            return;
+        }
+        else{
+            sort(sommets_adj.begin(), sommets_adj.end());
+
+            for(uint i=0;i<sommets_adj.size();i++)
+            {
+                sommets_cut.push_back(modif_Cout_coupe(*sommetsDestination,sommets_adj.at(i),cut,g));
+            }
+
+            cut = *min_element(sommets_cut.begin(),sommets_cut.end());
+            sommetsDestination->push_back(sommets_adj[recherche_val2(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]);
+            poids+=(*g)[sommets_adj[recherche_val2(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]]._weight;
+            suprim_val(*sommetsSource, sommets_adj[recherche_val2(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]);
+            suprim_val(sommets_adj, sommets_adj[recherche_val2(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]);
+
+            sommets_cut.clear();
+
+        }
+    }
+
+    for (uint i=0; i<sommetsSource->size();i++)
+    {
+        for (uint j=0; j<sommetsDestination->size();j++)
+        {
+            remove_edge(sommetsSource->at(i),sommetsDestination->at(j),*g);
+        }
+    }
+    sort(sommetsDestination->begin(), sommetsDestination->end());
+
+}
+
+// void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource,
+//                Entiers *sommetsDestination, EntiersEntiers &Partition)
+// {
+//     int val;
+//     Entiers sommets_adj;
+//     if(sommetsSource->size()==1){
+//         val=0;
+//         //std::cout<<"Entré dans le debug ! "<<std::endl;
+//         Entiers tailles;
+//         for(uint i=0;i<Partition.size();i++){
+//             tailles.push_back(Partition.at(i)->size());
+//         }
+//         uint tmp=*max_element(tailles.begin(),tailles.end());
+//         for(uint i=0; i<Partition.size();i++){
+//             if(Partition.at(i)->size()==tmp)
+//             {
+//                 gggp_pond(g,Partition[i],sommetsDestination,Partition);
+//             	return;
+//             }
+//         }
+//     }
+//     else
+//         val=rand_fini(0,sommetsSource->size()-1);//Tirage aléatoire de l'indice du premier sommet entre 0 et taille du tableau -1
+//     	//std::cout<<"val : "<<sommetsSource->at(val)<<std::endl;
+//     double poids_max=0;
+//     for(uint i=0;i<sommetsSource->size();i++){
+//         poids_max+=(*g)[sommetsSource->at(i)]._weight;
+//     }
+//     poids_max/=2.;
+//     double poids=(*g)[sommetsSource->at(val)]._weight;
+//     std::vector<float> sommets_cut;
+//     float  cut = Degree(*g,sommetsSource->at(val));
+
+//     sommetsDestination->push_back(sommetsSource->at(val));
+//     sommetsSource->erase(sommetsSource->begin() + val);
+
+//    // std::cout<<"taille sommetsSource avant le while : "<<sommetsSource->size()<<std::endl;
+//     while(poids<poids_max && sommetsSource->size()>1)
+//     {
+//     	//std::cout<<"taille sommetsSource dans le while "<<sommetsSource->size()<<std::endl;
+//         Liste_Voisin(*sommetsDestination,sommets_adj,*g);
+//         if(sommets_adj.size()==0)
+//         {
+//             //std::cout<<"Je suis sorti car pas de voisin !!!! "<<std::endl;
+//             for (uint i=0; i<sommetsSource->size();i++)
+//             {
+//                 for (uint j=0; j<sommetsDestination->size();j++)
+//                 {
+//                     remove_edge(sommetsSource->at(i),sommetsDestination->at(j),*g);
+//                 }
+//             }
+//             sort(sommetsDestination->begin(), sommetsDestination->end());
+//             return;
+//         }
+//         else{
+//             sort(sommets_adj.begin(), sommets_adj.end());
+
+//             /*std::cout<<"adj :"<<std::endl;
+//             for(uint a = 0; a<sommets_adj.size(); a++){
+//             	std::cout<<sommets_adj.at(a)<<std::endl;
+//             }
+//             std::cout<<std::endl;*/
+
+//             for(uint i=0;i<sommets_adj.size();i++)
+//             {
+//                 sommets_cut.push_back(modif_Cout_coupe(*sommetsDestination, sommets_adj.at(i), cut, g));
+//                 // sommets_cut.push_back(Cout_coupe_pond(*sommetsDestination,sommets_adj[i],*g));
+//             }
+//             /*std::cout<<"cut :"<<std::endl;
+//             for(uint a = 0; a<sommets_cut.size(); a++){
+//             	std::cout<<sommets_cut.at(a)<<std::endl;
+//             }
+//             std::cout<<std::endl;*/
+//             sommetsDestination->push_back(sommets_adj[recherche_val2(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]);
+//             //std::cout<<"Sommet deplacé : "<<sommets_adj[recherche_val2(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]<<std::endl;
+//             poids+=(*g)[sommets_adj[recherche_val2(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]]._weight;
+//             suprim_val(*sommetsSource, sommets_adj[recherche_val2(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]);
+//             suprim_val(sommets_adj, sommets_adj[recherche_val2(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]);
+
+//             sommets_cut.clear();
+
+//         }
+
+//         /*for(uint i =0; i<sommetsSource->size();i++){
+//         	std::cout<<sommetsSource->at(i)<<",";
+//         }
+//         std::cout<<std::endl;
+//         for(uint i =0; i<sommetsDestination->size();i++){
+//         	std::cout<<sommetsDestination->at(i)<<",";
+//         }
+//         std::cout<<std::endl;*/
+
+//     }
+
+//     for (uint i=0; i<sommetsSource->size();i++)
+//     {
+//         for (uint j=0; j<sommetsDestination->size();j++)
+//         {
+//             remove_edge(sommetsSource->at(i),sommetsDestination->at(j),*g);
+//         }
+//     }
+//     sort(sommetsDestination->begin(), sommetsDestination->end());
+
+//     //std::cout<<"fin du gggp_pond"<<std::endl;
+// }
+
+// void Iter_2l(EntiersEntiers &part, int nbr_parties, UnorientedGraph *g,
+//              const std::string &nom)
+// {
+//     if (nom!="gggp_pond"){
+//         //std::cout<<"je jsuis dans gggp"<<std::endl;
+
+//         for(int i = 0; i<floor(log(nbr_parties)/log(2)); i++)
+//         {
+//             //std::cout<<"Et un tours de plus !!!! "<<std::endl;
+//             for(int j = 0; j< pow(2,i);j++)
+//             {
+//                 Entiers *Q = new Entiers();
+//                 gggp(g,part[j],Q,part);
+//                 part.push_back(Q);
+//             }
+
+//         }
+//     } else {
+//         //std::cout<<"je jsuis dans gggp_pond"<<std::endl;
+
+//         for(int i = 0; i<floor(log(nbr_parties)/log(2)); i++)
+//         {
+//             //std::cout<<"Et un tours de plus !!!! "<<std::endl;
+//             for(int j = 0; j< pow(2,i);j++)
+//             {
+//                 Entiers *Q = new Entiers();
+//                 gggp_pond(g,part.at(j),Q,part);
+//                 //std::clog<<"sortie du gggp_pond"<<std::endl;
+//                 part.push_back(Q);
+//             }
+//             //std::cout<<"\n"<<std::endl;
+
+//         }
+//     }
+// }
+
+// void bissectionRec(UnorientedGraph *g, EntiersEntiers &Partition,
+//                    int nbr_parties, const std::string &nom)
+// {
+//     if((nbr_parties&(nbr_parties-1))==0)
+//     {
+//         //std::cout<<"C'est de la forme 2l : "<<nbr_parties<<std::endl;
+//         Iter_2l(Partition,nbr_parties,g,nom);
+//     }
+//     else
+//     {
+//         int puissance_2=0;
+
+//         Entiers tailles;
+
+//         while(pow(2,puissance_2)<nbr_parties)
+//             puissance_2++;
+
+//         Iter_2l(Partition,pow(2,puissance_2-1),g,nom);
+
+//         for(unsigned int i = 0; i< Partition.size() -1 ; i++)
+//         {
+//             for(EntiersEntiers::iterator it1 = Partition.begin() + i ; it1!=Partition.end(); it1++)
+//             {
+//                 if((*it1)->size() > Partition.at(i)->size())
+//                     Partition.at(i)->swap(**it1);
+//             }
+//         }
+
+//         for(int j = 0; j<nbr_parties-pow(2,puissance_2-1);j++)
+//         {
+//             Entiers *Q = new Entiers();
+//             if(nom!="gggp_pond")
+//                 gggp(g,Partition.at(j),Q,Partition);
+//             else
+//                 gggp_pond(g,Partition.at(j),Q,Partition);
+//             Partition.push_back(Q);
+//         }
+//     }
+//     // std::cout<<"Partition avant affinage "<<std::endl;
+//     // for(uint i = 0 ; i<Partition.size(); i++){
+//     // 	for(uint j = 0 ; j<Partition.at(i)->size(); j++){
+//     // 		std::cout<<Partition.at(i)->at(j)<<" ";
+//     // 	}
+//     // 	std::cout<<"\n"<<std::endl;
+//     // }
+// }
+
+/**
+ * Fonction réalisant un partitionnement pseudo aléatoire suivant un voisinage.
+ * @param *g : adresse d'un graphe de type boost graphe undirected
+ * @param Partition : vecteur contenant des vecteurs d'entiers [tableau contenant les parties de la partition]
+ * @param nbr_partie : entier correspondant au nombre de parties voulues pour la partition
+ * @return
+ */
+
+void Pseudo_random_partitioning(UnorientedGraph *g, EntiersEntiers &Partition,
+                                uint nbr_parties)
+{
+    /*
+     * Principe : distribution des sommets de la première partie en plusieurs autres parties
+     * Le partitionnement étant pseudo aléatoire il n'y a pas de contrainte stricte sur le nombre
+     * de sommets par partie
+     */
+
+
+    uint size = Partition.at(0)->size();
+    uint cpt_sommets=1;
+    int val;
+    uint cpt;
+
+    if(nbr_parties==size){
+        for(uint i = 0; i < nbr_parties;i++){
+            if(Partition.at(0)->size()!=1)
+            {
+                val=rand_fini(0,Partition.at(0)->size()-1);//tirage aléatoire d'un sommets
+            }
+            else
+                val=0;
+
+            int vertex = Partition.at(0)->at(val);
+            Entiers *part = new Entiers();
+            part->push_back(vertex);// ajout du sommet tiré
+            suprim_val(*Partition.at(0),vertex);//suppression du sommet dans la premiere partie
+
+        }
+    }
+    /*
+     * Boucle sur le nombre de partie à réaliser
+     */
+    for(uint i = 0; i < nbr_parties-1;i++){
+        if(Partition.at(0)->size()!=1)
+        {
+            val=rand_fini(0,Partition.at(0)->size()-1);//tirage aléatoire d'un sommets
+        }
+        else
+            val=0;
+        int vertex = Partition.at(0)->at(val);
+        /*
+         * Initialisation d'un pointeur sur un vecteur d'entier, dans notre cas
+         * la n+1 ième partie de la partition
+         */
+        Entiers *part = new Entiers();
+        part->push_back(vertex);// ajout du sommet tiré
+        suprim_val(*Partition.at(0),vertex);//suppression du sommet dans la premiere partie
+        cpt=1;
+
+        /*
+         * Pour chaque element de la nouvelle partie faire
+         */
+        for(uint j = 0; j<part->size();j++){
+            /*
+             * Détermination des voisins de chacun des sommets de cette nouvelle
+             * partie et ajoue de ce voisin si celui-ci est présent dans la première partie (Partition[0])
+             */
+            tie(neighbourIt, neighbourEnd) = adjacent_vertices(part->at(j),*g);
+            for (; neighbourIt != neighbourEnd; ++neighbourIt){
+                if(In_tab(*Partition.at(0),*neighbourIt)==1){
+                    // std::cout<<"le voisin déplacé est : "<<*neighbourIt<<std::endl;
+                    part->push_back(*neighbourIt);
+                    cpt_sommets++;
+                    suprim_val(*Partition.at(0),*neighbourIt);
+                    cpt++;
+                }
+                /*
+                 * Si le nombre moyen de sommets est atteind dans la partie on sort de la boucle des voisins
+                 * Même chose si l'on a rencontré le nombre total de sommets
+                 */
+                if(cpt==(size/nbr_parties)+1)
+                    break;
+                if(cpt_sommets==size)
+                    break;
+            }
+
+            /*
+             * Même chose
+             */
+            if(cpt==(size/nbr_parties)+1)
+                break;
+            if(cpt_sommets==size)
+                break;
+        }
+        Partition.push_back(part);// ajoue de la nouvelle partie à la partition
+        if(cpt_sommets==size)
+            break;
+    }
+}
+
+EntiersEntiers Random_partitioning(UnorientedGraph *g,
+                                uint nbr_parties)
+{
+	EntiersEntiers Partition;
+	Entiers random_order; //gestion d'un tableau contenant tout les sommets et ranger de façon aléatoire
+
+	for (uint i=0 ; i<num_vertices(*g) ; i++)
+		random_order.push_back(i);
+	for (uint j=0 ; j<num_vertices(*g)-1 ; j++) {
+		int rand_pos = rand()%(num_vertices(*g)-j)+j;
+		int tmp      = random_order.at(j);
+		random_order.at(j) = random_order.at(rand_pos);
+		random_order.at(rand_pos) = tmp;
+	}
+
+	uint size = num_vertices(*g)/nbr_parties;
+	for(uint j = 0 ; j < nbr_parties-1 ; j++){
+		Entiers *part = new Entiers();
+		for(uint i = j*size; i<(j+1)*size; i++){
+			part->push_back(random_order.at(i));
+		}
+		Partition.push_back(part);
+	}
+
+	Entiers *part = new Entiers();
+	for(uint i = (nbr_parties-1)*size; i < random_order.size(); i++){
+		part->push_back(random_order.at(i));
+	}
+	Partition.push_back(part);
+
+	for(uint i = 0 ; i < Partition.size() ; i++){
+		sort(Partition.at(i)->begin(),Partition.at(i)->end());
+	}
+
+	return Partition;
+}
+
+OrientedGraphs Multiniveau(uint niveau_contraction,
+                           UnorientedGraph *g,
+                           UnorientedGraph *graph_origin,
+                           OrientedGraph *go,
+                           int nbr_parties,
+                           std::string contraction,
+                           std::string type_methode,
+                           std::string choix_affinage,
+                           std::string type_cut,
+                           Edges& /* edge_partie */,
+                           OutputEdgeList& outputedgelist,
+                           InputEdgeList& inputedgelist,
+                           Connections& connections)
+{
+    EntiersEntiers Partition;
+    Entiers *part = new Entiers();
+    Base_Graph baseg;
+    baseg.push_back(g);
+    ListEntiersEntiers liste_corr;
+    uint cpt =0;
+
+    int val_cpt = num_vertices(*g);
+    bool stop = false;
+
+    if (niveau_contraction == val_cpt) {
+        stop = true;
+    }
+
+    while(stop != true)
+    {
+    	if(contraction == "HEM")
+    		stop = contraction_HEM(baseg.at(cpt),baseg,liste_corr,niveau_contraction,val_cpt);
+    	else
+    		stop = contraction_Random_Maching(baseg.at(cpt),baseg,liste_corr,niveau_contraction,val_cpt);
+        cpt++;
+        // std::cout<<"passage"<<std::endl;
+    }
+
+    // std::cout<<"Graphe contracté : "<<std::endl;
+    // for (uint i = 0; i< baseg.size(); i++) {
+    //     tie(vertexIt, vertexEnd) = vertices(*baseg[i]);
+    //     for (; vertexIt != vertexEnd; ++vertexIt) {
+    //         std::cout << (*baseg[i])[*vertexIt]._index
+    //                   << " est connecté avec ";
+    //         tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
+    //         		*baseg[i]);
+    //         for (; neighbourIt != neighbourEnd; ++neighbourIt)
+    //             std::cout << (*baseg[i])[*neighbourIt]._index << " ";
+    //         std::cout << " et son poids est de "
+    //                   << (*baseg[i])[*vertexIt]._weight<<std::endl;
+    //     }
+    //     std::cout << std::endl;
+    // }
+    UnorientedGraph *gtmp = new UnorientedGraph();
+    *gtmp = *baseg.at(baseg.size() - 1);
+    // std::cout<<"Partitionnement "<<std::endl;
+    if(type_methode == "gggp_pond" || type_methode == "gggp" || type_methode == "ggp"){
+		for(uint i = 0;i < num_vertices(*baseg.at(baseg.size() - 1)); i++)
+		{
+			part->push_back(i);
+		}
+		Partition.push_back(part);
+		bissectionRec(baseg.at(baseg.size()-1),Partition,nbr_parties,type_methode);
+		double cut_norm = Cut_cluster(Partition,*gtmp,"norm");
+		// std::cout<<"Cout de coupe normalisé initial : "<<cut_norm<<std::
+                    // endl;
+		int cpt_part = 0;
+		while (cpt_part!=3){
+			EntiersEntiers new_Partition;
+			Entiers *new_part = new Entiers();
+			for(uint i = 0;i < num_vertices(*baseg.at(baseg.size() - 1)); i++)
+			{
+				new_part->push_back(i);
+			}
+			new_Partition.push_back(new_part);
+			bissectionRec(baseg.at(baseg.size()-1),new_Partition,nbr_parties,type_methode);
+			double new_cut_norm = Cut_cluster(new_Partition,*gtmp,"norm");
+			// std::cout<<"Nouveau cout de coupe normalisé : "<<new_cut_norm<<std::endl;
+
+			if(new_cut_norm<cut_norm){
+				// std::cout<<"Changement !!!"<<std::endl;
+				for(EntiersEntiers::iterator it = Partition.begin(); it != Partition.end(); it++)
+				{
+					delete *it;
+					*it = NULL;
+				}
+				Partition = new_Partition;
+				cut_norm = new_cut_norm;
+			}
+			else{
+				for(EntiersEntiers::iterator it = new_Partition.begin(); it != new_Partition.end(); it++)
+				{
+					delete *it;
+					*it = NULL;
+				}
+			}
+			cpt_part++;
+		}
+		// std::cout<<std::endl;
+		// std::cout<<"Cout de coupe normalisé conservé : "<<cut_norm<<std::endl;
+		delete gtmp;
+    }
+    else
+    	Partition = Random_partitioning(baseg.at(baseg.size()-1),nbr_parties);
+    // std::cout<<std::endl;
+
+    ListEntiersEntiers::iterator lit(liste_corr.end());
+    bool proj;
+    uint taille_list = liste_corr.size();
+    if(liste_corr.size()==0){
+    	taille_list = 1;
+    	proj = true;
+    }
+    else{
+    	lit--;
+    	proj = false;
+    }
+
+    for(uint y =0; y<taille_list;y++){
+    	if(proj != true){
+    		// std::cout<<"Projection "<<std::endl;
+    		projection(Partition,lit);
+    		// std::cout<<std::endl;
+    		double cut = Cut_cluster(Partition,*baseg.at(baseg.size()-2-y),type_cut);
+    		// std::cout<<"Cout de coupe avant affinage : "<<cut<<std::endl;
+    		// std::cout<<std::endl;
+    		// std::cout<<"Affinage "<<std::endl;
+    		if(choix_affinage=="charge")
+    			Affinage_equilibrage_charge(baseg.at(baseg.size()-2-y),Partition);
+    		else
+    			Affinage_recherche_locale(baseg.at(baseg.size()-2-y),Partition,cut,type_cut);
+
+    		lit--;
+    	}
+    	else{
+    		// std::cout<<"Pas de projection "<<std::endl;
+    		// std::cout<<std::endl;
+
+    		if(nbr_parties != num_vertices(*g)){
+    			// std::cout<<"Affinage "<<std::endl;
+        		double cut = Cut_cluster(Partition,*graph_origin,type_cut);
+        		// std::cout<<"Cout de coupe avant affinage : "<<cut<<std::
+                            // endl;
+    			if(choix_affinage=="charge")
+    				Affinage_equilibrage_charge(graph_origin,Partition);
+    			else{
+    				Affinage_recherche_locale(graph_origin,Partition,cut,type_cut);
+    				// std::cout<<"Cout de coupe après affinage : "<<cut<<std::endl;
+    			}
+    		}
+    		// else
+    			// std::cout<<"Pas d'affinage "<<std::endl;
+    	}
+
+    }
+
+    OrientedGraphs Graphes = Graph_Partition(Partition, go, graph_origin, outputedgelist,
+                                             inputedgelist, connections);
+
+    // std::cout<<std::endl;
+    // std::cout<<"Résultat de la partition "<<std::endl;
+    // for(uint k=0; k<Partition.size(); k++)
+    // {
+    // 	for(uint j=0; j<Partition.at(k)->size(); j++)
+    // 	{
+    // 		std::cout<<Partition.at(k)->at(j)<<" ";
+    // 	}
+    // 	std::cout<<"\n"<<std::endl;
+    // }
+
+	double cut = Cut_cluster(Partition,*graph_origin,"cut");
+	// std::cout<<"Cout de coupe engendré par le partitionnement: "<<cut<<std::endl;
+
+
+    for(EntiersEntiers::iterator it = Partition.begin(); it != Partition.end(); it++)
+    {
+        delete *it;
+        *it = NULL;
+    }
+
+    for(ListEntiersEntiers::iterator it = liste_corr.begin(); it != liste_corr.end(); it++)
+    {
+        for(EntiersEntiers::iterator it1 = (*it)->begin(); it1 != (*it)->end(); it1++)
+        {
+            delete *it1;
+            *it1 = NULL;
+        }
+        delete *it;
+        *it = NULL;
+    }
+
+    for(Base_Graph::iterator it = baseg.begin(); it != baseg.end(); it++)
+    {
+        delete *it;
+        *it = NULL;
+    }
+    return Graphes;
+}
+
+} } } // namespace paradevs tests boost_graph

+ 68 - 0
src/tests/boost_graph/partitioning/gggp.hpp

@@ -0,0 +1,68 @@
+/**
+ * @file tests/boost_graph/partitioning/gggp.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_BOOST_GRAPH_PARTITIONING_GGGP_H
+#define TESTS_BOOST_GRAPH_PARTITIONING_GGGP_H 1
+
+#include <tests/boost_graph/partitioning/utils.hpp>
+
+namespace paradevs { namespace tests { namespace boost_graph {
+
+void ggp(UnorientedGraph *g, Entiers *sommetsSource,
+         Entiers *sommetsDestination, EntiersEntiers &Partition);
+
+void gggp(UnorientedGraph *g, Entiers *sommetsSource,
+          Entiers *sommetsDestination, EntiersEntiers &Partition);
+
+void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource,
+               Entiers *sommetsDestination, EntiersEntiers &Partition);
+
+void Iter_2l(EntiersEntiers &part, int nbr_parties, UnorientedGraph *g,
+             const std::string &nom);
+
+void bissectionRec(UnorientedGraph *g, EntiersEntiers &Partition,
+                   int nbr_parties, const std::string &nom);
+
+void Pseudo_random_partitioning(UnorientedGraph *g, EntiersEntiers &Partition,
+                                uint nbr_parties);
+
+EntiersEntiers Random_partitioning(UnorientedGraph *g,
+                                uint nbr_parties);
+
+OrientedGraphs Multiniveau(uint niveau_contraction, UnorientedGraph *g, UnorientedGraph *graph_origin,
+                           OrientedGraph *go, int nbr_parties,
+                           std::string contraction,
+                           std::string type_methode,
+                           std::string choix_affinage,
+                           std::string type_cut,
+                           Edges &edge_partie,
+                           OutputEdgeList &outputedgeslist,
+                           InputEdgeList &inputedgelist,
+                           Connections &connections);
+
+} } } // namespace paradevs tests boost_graph
+
+#endif

+ 434 - 0
src/tests/boost_graph/partitioning/graph_build.cpp

@@ -0,0 +1,434 @@
+/**
+ * @file tests/boost_graph/partitioning/graph_build.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <tests/boost_graph/partitioning/graph_build.hpp>
+
+#include <tests/corsen/lib/Corsen.hpp>
+
+namespace paradevs { namespace tests { namespace boost_graph {
+
+void build_graph(UnorientedGraph& ug, OrientedGraph& og)
+{
+
+    /*
+     * construction graphe Oriente
+     */
+    vertex_to v0 = boost::add_vertex(og);
+    vertex_to v1 = boost::add_vertex(og);
+    vertex_to v2 = boost::add_vertex(og);
+    vertex_to v3 = boost::add_vertex(og);
+    vertex_to v4 = boost::add_vertex(og);
+    vertex_to v5 = boost::add_vertex(og);
+    vertex_to v6 = boost::add_vertex(og);
+    vertex_to v7 = boost::add_vertex(og);
+    vertex_to v8 = boost::add_vertex(og);
+    vertex_to v9 = boost::add_vertex(og);
+    vertex_to v10 = boost::add_vertex(og);
+    vertex_to v11 = boost::add_vertex(og);
+    vertex_to v12 = boost::add_vertex(og);
+    vertex_to v13 = boost::add_vertex(og);
+    vertex_to v14 = boost::add_vertex(og);
+    vertex_to v15 = boost::add_vertex(og);
+    vertex_to v16 = boost::add_vertex(og);
+    vertex_to v17 = boost::add_vertex(og);
+    vertex_to v18 = boost::add_vertex(og);
+    vertex_to v19 = boost::add_vertex(og);
+    vertex_to v20 = boost::add_vertex(og);
+    vertex_to v21 = boost::add_vertex(og);
+    vertex_to v22 = boost::add_vertex(og);
+    vertex_to v23 = boost::add_vertex(og);
+    vertex_to v24 = boost::add_vertex(og);
+    vertex_to v25 = boost::add_vertex(og);
+    vertex_to v26 = boost::add_vertex(og);
+    vertex_to v27 = boost::add_vertex(og);
+    vertex_to v28 = boost::add_vertex(og);
+    vertex_to v29 = boost::add_vertex(og);
+    vertex_to v30 = boost::add_vertex(og);
+    vertex_to v31 = boost::add_vertex(og);
+    vertex_to v32 = boost::add_vertex(og);
+    vertex_to v33 = boost::add_vertex(og);
+    vertex_to v34 = boost::add_vertex(og);
+    vertex_to v35 = boost::add_vertex(og);
+    vertex_to v36 = boost::add_vertex(og);
+    vertex_to v37 = boost::add_vertex(og);
+
+
+
+    add_edge(v1, v0, EdgeProperties(1.), og);
+    add_edge(v2, v0, EdgeProperties(1.), og);
+    add_edge(v3, v0, EdgeProperties(1.), og);
+    add_edge(v1, v2, EdgeProperties(1.), og);
+    add_edge(v4, v1, EdgeProperties(1.), og);
+    add_edge(v5, v1, EdgeProperties(1.), og);
+    add_edge(v6, v1, EdgeProperties(1.), og);
+    add_edge(v6, v2, EdgeProperties(1.), og);
+    add_edge(v2, v3, EdgeProperties(1.), og);
+    add_edge(v9, v3, EdgeProperties(1.), og);
+    add_edge(v10, v3, EdgeProperties(1.), og);
+    add_edge(v4, v5, EdgeProperties(1.), og);
+    add_edge(v5, v6, EdgeProperties(1.), og);
+    add_edge(v7, v4, EdgeProperties(1.), og);
+    add_edge(v8, v4, EdgeProperties(1.), og);
+    add_edge(v7, v8, EdgeProperties(1.), og);
+    add_edge(v9, v10, EdgeProperties(1.), og);
+    add_edge(v8, v11, EdgeProperties(1.), og);
+    add_edge(v11, v4, EdgeProperties(1.), og);
+    add_edge(v12, v13, EdgeProperties(1.), og);
+    add_edge(v12, v7, EdgeProperties(1.), og);
+    add_edge(v13, v7, EdgeProperties(1.), og);
+    add_edge(v14, v15, EdgeProperties(1.), og);
+    add_edge(v14, v12, EdgeProperties(1.), og);
+    add_edge(v15, v16, EdgeProperties(1.), og);
+    add_edge(v15, v12, EdgeProperties(1.), og);
+    add_edge(v16, v17, EdgeProperties(1.), og);
+    add_edge(v16, v12, EdgeProperties(1.), og);
+    add_edge(v17, v12, EdgeProperties(1.), og);
+    add_edge(v18, v19, EdgeProperties(1.), og);
+    add_edge(v18, v8, EdgeProperties(1.), og);
+    add_edge(v19, v20, EdgeProperties(1.), og);
+    add_edge(v19, v8, EdgeProperties(1.), og);
+    add_edge(v20, v8, EdgeProperties(1.), og);
+    add_edge(v21, v22, EdgeProperties(1.), og);
+    add_edge(v21, v19, EdgeProperties(1.), og);
+    add_edge(v22, v23, EdgeProperties(1.), og);
+    add_edge(v22, v19, EdgeProperties(1.), og);
+    add_edge(v23, v19, EdgeProperties(1.), og);
+    add_edge(v24, v25, EdgeProperties(1.), og);
+    add_edge(v24, v6, EdgeProperties(1.), og);
+    add_edge(v25, v6, EdgeProperties(1.), og);
+    add_edge(v26, v11, EdgeProperties(1.), og);
+    add_edge(v26, v27, EdgeProperties(1.), og);
+    add_edge(v26, v24, EdgeProperties(1.), og);
+    add_edge(v27, v24, EdgeProperties(1.), og);
+    add_edge(v28, v25, EdgeProperties(1.), og);
+    add_edge(v29, v27, EdgeProperties(1.), og);
+    add_edge(v29, v28, EdgeProperties(1.), og);
+    add_edge(v30, v27, EdgeProperties(1.), og);
+    add_edge(v30, v28, EdgeProperties(1.), og);
+    add_edge(v31, v32, EdgeProperties(1.), og);
+    add_edge(v31, v10, EdgeProperties(1.), og);
+    add_edge(v32, v33, EdgeProperties(1.), og);
+    add_edge(v32, v10, EdgeProperties(1.), og);
+    add_edge(v33, v10, EdgeProperties(1.), og);
+    add_edge(v34, v31, EdgeProperties(1.), og);
+    add_edge(v34, v35, EdgeProperties(1.), og);
+    add_edge(v35, v31, EdgeProperties(1.), og);
+    add_edge(v35, v32, EdgeProperties(1.), og);
+    add_edge(v36, v32, EdgeProperties(1.), og);
+    add_edge(v36, v37, EdgeProperties(1.), og);
+    add_edge(v36, v33, EdgeProperties(1.), og);
+    add_edge(v37, v33, EdgeProperties(1.), og);
+
+
+    /*og[v6] = VertexProperties(6, 1.5, NORMAL_PIXEL);
+    og[v8] = VertexProperties(8, 1., NORMAL_PIXEL);
+    og[v10] = VertexProperties(10, 1.5, NORMAL_PIXEL);
+    og[v0] = VertexProperties(0, 3, NORMAL_PIXEL);
+    og[v1] = VertexProperties(1, 2, NORMAL_PIXEL);
+    og[v2] = VertexProperties(2, 2, NORMAL_PIXEL);
+    og[v3] = VertexProperties(3, 2, NORMAL_PIXEL);
+    og[v4] = VertexProperties(4, 1.5, NORMAL_PIXEL);
+    og[v5] = VertexProperties(5, 1.5, NORMAL_PIXEL);
+    og[v7] = VertexProperties(7, 1., TOP_PIXEL);
+    og[v9] = VertexProperties(9, 1.5, TOP_PIXEL);*/
+
+    og[v6] = VertexProperties(6, 2.5, NORMAL_PIXEL);
+    og[v8] = VertexProperties(8, 2., NORMAL_PIXEL);
+    og[v10] = VertexProperties(10, 2.5, NORMAL_PIXEL);
+    og[v0] = VertexProperties(0, 4, NORMAL_PIXEL);
+    og[v1] = VertexProperties(1, 3, NORMAL_PIXEL);
+    og[v2] = VertexProperties(2, 3, NORMAL_PIXEL);
+    og[v3] = VertexProperties(3, 3, NORMAL_PIXEL);
+    og[v4] = VertexProperties(4, 2.5, NORMAL_PIXEL);
+    og[v5] = VertexProperties(5, 2.5, NORMAL_PIXEL);
+    og[v7] = VertexProperties(7, 2., NORMAL_PIXEL);
+    og[v9] = VertexProperties(9, 2.5, TOP_PIXEL);
+    og[v11] = VertexProperties(11, 2, NORMAL_PIXEL);
+    og[v12] = VertexProperties(12, 1.5, NORMAL_PIXEL);
+    og[v13] = VertexProperties(13, 1.5, NORMAL_PIXEL);
+    og[v14] = VertexProperties(14, 1, TOP_PIXEL);
+    og[v15] = VertexProperties(15, 1, NORMAL_PIXEL);
+    og[v16] = VertexProperties(16, 1, NORMAL_PIXEL);
+    og[v17] = VertexProperties(17, 1, NORMAL_PIXEL);
+    og[v18] = VertexProperties(18, 1.5, TOP_PIXEL);
+    og[v19] = VertexProperties(19, 1.5, NORMAL_PIXEL);
+    og[v20] = VertexProperties(20, 1.5, NORMAL_PIXEL);
+    og[v21] = VertexProperties(21, 1, TOP_PIXEL);
+    og[v22] = VertexProperties(22, 1, NORMAL_PIXEL);
+    og[v23] = VertexProperties(23, 1, NORMAL_PIXEL);
+    og[v24] = VertexProperties(24, 2, NORMAL_PIXEL);
+    og[v25] = VertexProperties(25, 2, NORMAL_PIXEL);
+    og[v26] = VertexProperties(26, 1.5, TOP_PIXEL);
+    og[v27] = VertexProperties(27, 1.5, NORMAL_PIXEL);
+    og[v28] = VertexProperties(28, 1.5, NORMAL_PIXEL);
+    og[v29] = VertexProperties(29, 1, TOP_PIXEL);
+    og[v30] = VertexProperties(30, 1, TOP_PIXEL);
+    og[v31] = VertexProperties(31, 2, NORMAL_PIXEL);
+    og[v32] = VertexProperties(32, 2, NORMAL_PIXEL);
+    og[v33] = VertexProperties(33, 2, NORMAL_PIXEL);
+    og[v34] = VertexProperties(34, 1.5, TOP_PIXEL);
+    og[v35] = VertexProperties(35, 1.5, NORMAL_PIXEL);
+    og[v36] = VertexProperties(36, 1.5, TOP_PIXEL);
+    og[v37] = VertexProperties(37, 1.5, NORMAL_PIXEL);
+
+
+    /*
+     * construction graphe Non Oriente
+     */
+
+    vertex_t v01 = boost::add_vertex(ug);
+    vertex_t v1r1 = boost::add_vertex(ug);
+    vertex_t v2r1 = boost::add_vertex(ug);
+    vertex_t v3r1 = boost::add_vertex(ug);
+    vertex_t v41 = boost::add_vertex(ug);
+    vertex_t v51 = boost::add_vertex(ug);
+    vertex_t v61 = boost::add_vertex(ug);
+    vertex_t v71 = boost::add_vertex(ug);
+    vertex_t v81 = boost::add_vertex(ug);
+    vertex_t v91 = boost::add_vertex(ug);
+    vertex_t v101 = boost::add_vertex(ug);
+    vertex_t v111 = boost::add_vertex(ug);
+    vertex_t v121 = boost::add_vertex(ug);
+    vertex_t v131 = boost::add_vertex(ug);
+    vertex_t v141 = boost::add_vertex(ug);
+    vertex_t v151 = boost::add_vertex(ug);
+    vertex_t v161 = boost::add_vertex(ug);
+    vertex_t v171 = boost::add_vertex(ug);
+    vertex_t v181 = boost::add_vertex(ug);
+    vertex_t v191 = boost::add_vertex(ug);
+    vertex_t v201 = boost::add_vertex(ug);
+    vertex_t v211 = boost::add_vertex(ug);
+    vertex_t v221 = boost::add_vertex(ug);
+    vertex_t v231 = boost::add_vertex(ug);
+    vertex_t v241 = boost::add_vertex(ug);
+    vertex_t v251 = boost::add_vertex(ug);
+    vertex_t v261 = boost::add_vertex(ug);
+    vertex_t v271 = boost::add_vertex(ug);
+    vertex_t v281 = boost::add_vertex(ug);
+    vertex_t v291 = boost::add_vertex(ug);
+    vertex_t v301 = boost::add_vertex(ug);
+    vertex_t v311 = boost::add_vertex(ug);
+    vertex_t v321 = boost::add_vertex(ug);
+    vertex_t v331 = boost::add_vertex(ug);
+    vertex_t v341 = boost::add_vertex(ug);
+    vertex_t v351 = boost::add_vertex(ug);
+    vertex_t v361 = boost::add_vertex(ug);
+    vertex_t v371 = boost::add_vertex(ug);
+
+    boost::add_edge(v01, v1r1, EdgeProperties(1.), ug);
+    boost::add_edge(v01, v2r1, EdgeProperties(1.), ug);
+    boost::add_edge(v01, v3r1, EdgeProperties(1.), ug);
+    boost::add_edge(v1r1, v2r1, EdgeProperties(1.), ug);
+    boost::add_edge(v1r1, v41, EdgeProperties(1.), ug);
+    boost::add_edge(v1r1, v51, EdgeProperties(1.), ug);
+    boost::add_edge(v1r1, v61, EdgeProperties(1.), ug);
+    boost::add_edge(v2r1, v61, EdgeProperties(1.), ug);
+    boost::add_edge(v2r1, v3r1, EdgeProperties(1.), ug);
+    boost::add_edge(v3r1, v91, EdgeProperties(1.), ug);
+    boost::add_edge(v3r1, v101, EdgeProperties(1.), ug);
+    boost::add_edge(v41, v51, EdgeProperties(1.), ug);
+    boost::add_edge(v51, v61, EdgeProperties(1.), ug);
+    boost::add_edge(v41, v71, EdgeProperties(1.), ug);
+    boost::add_edge(v41, v81, EdgeProperties(1.), ug);
+    boost::add_edge(v71, v81, EdgeProperties(1.), ug);
+    boost::add_edge(v91, v101, EdgeProperties(1.), ug);
+    boost::add_edge(v41, v111, EdgeProperties(1.), ug);
+    boost::add_edge(v71, v121, EdgeProperties(1.), ug);
+    boost::add_edge(v71, v131, EdgeProperties(1.), ug);
+    boost::add_edge(v121, v131, EdgeProperties(1.), ug);
+    boost::add_edge(v121, v141, EdgeProperties(1.), ug);
+    boost::add_edge(v121, v151, EdgeProperties(1.), ug);
+    boost::add_edge(v121, v161, EdgeProperties(1.), ug);
+    boost::add_edge(v121, v171, EdgeProperties(1.), ug);
+    boost::add_edge(v141, v151, EdgeProperties(1.), ug);
+    boost::add_edge(v151, v161, EdgeProperties(1.), ug);
+    boost::add_edge(v161, v171, EdgeProperties(1.), ug);
+    boost::add_edge(v81, v111, EdgeProperties(1.), ug);
+    boost::add_edge(v81, v181, EdgeProperties(1.), ug);
+    boost::add_edge(v81, v191, EdgeProperties(1.), ug);
+    boost::add_edge(v81, v201, EdgeProperties(1.), ug);
+    boost::add_edge(v181, v191, EdgeProperties(1.), ug);
+    boost::add_edge(v191, v201, EdgeProperties(1.), ug);
+    boost::add_edge(v191, v211, EdgeProperties(1.), ug);
+    boost::add_edge(v191, v221, EdgeProperties(1.), ug);
+    boost::add_edge(v191, v231, EdgeProperties(1.), ug);
+    boost::add_edge(v211, v221, EdgeProperties(1.), ug);
+    boost::add_edge(v221, v231, EdgeProperties(1.), ug);
+    boost::add_edge(v111, v261, EdgeProperties(1.), ug);
+    boost::add_edge(v61, v241, EdgeProperties(1.), ug);
+    boost::add_edge(v61, v251, EdgeProperties(1.), ug);
+    boost::add_edge(v241, v251, EdgeProperties(1.), ug);
+    boost::add_edge(v241, v261, EdgeProperties(1.), ug);
+    boost::add_edge(v241, v271, EdgeProperties(1.), ug);
+    boost::add_edge(v261, v271, EdgeProperties(1.), ug);
+    boost::add_edge(v251, v281, EdgeProperties(1.), ug);
+    boost::add_edge(v271, v291, EdgeProperties(1.), ug);
+    boost::add_edge(v271, v301, EdgeProperties(1.), ug);
+    boost::add_edge(v281, v291, EdgeProperties(1.), ug);
+    boost::add_edge(v281, v301, EdgeProperties(1.), ug);
+    boost::add_edge(v101, v311, EdgeProperties(1.), ug);
+    boost::add_edge(v101, v321, EdgeProperties(1.), ug);
+    boost::add_edge(v101, v331, EdgeProperties(1.), ug);
+    boost::add_edge(v311, v321, EdgeProperties(1.), ug);
+    boost::add_edge(v321, v331, EdgeProperties(1.), ug);
+    boost::add_edge(v311, v341, EdgeProperties(1.), ug);
+    boost::add_edge(v311, v351, EdgeProperties(1.), ug);
+    boost::add_edge(v321, v351, EdgeProperties(1.), ug);
+    boost::add_edge(v321, v361, EdgeProperties(1.), ug);
+    boost::add_edge(v331, v361, EdgeProperties(1.), ug);
+    boost::add_edge(v331, v371, EdgeProperties(1.), ug);
+    boost::add_edge(v341, v351, EdgeProperties(1.), ug);
+    boost::add_edge(v361, v371, EdgeProperties(1.), ug);
+
+    /*ug[v61] = VertexProperties(60, 1.5, NORMAL_PIXEL);
+    ug[v81] = VertexProperties(80, 1, NORMAL_PIXEL);
+    ug[v101] = VertexProperties(100, 1.5, NORMAL_PIXEL);
+    ug[v01] = VertexProperties(0, 3, NORMAL_PIXEL);
+    ug[v1r1] = VertexProperties(10, 2, NORMAL_PIXEL);
+    ug[v2r1] = VertexProperties(20, 2, NORMAL_PIXEL);
+    ug[v3r1] = VertexProperties(30, 2, NORMAL_PIXEL);
+    ug[v41] = VertexProperties(40, 1.5, NORMAL_PIXEL);
+    ug[v51] = VertexProperties(50, 1.5, NORMAL_PIXEL);
+    ug[v71] = VertexProperties(70, 1, TOP_PIXEL);
+    ug[v91] = VertexProperties(90, 1.5, TOP_PIXEL);*/
+
+    ug[v6] = VertexProperties(6, 2.5, NORMAL_PIXEL);
+    ug[v8] = VertexProperties(8, 2., NORMAL_PIXEL);
+    ug[v10] = VertexProperties(10, 2.5, NORMAL_PIXEL);
+    ug[v0] = VertexProperties(0, 4, NORMAL_PIXEL);
+    ug[v1] = VertexProperties(1, 3, NORMAL_PIXEL);
+    ug[v2] = VertexProperties(2, 3, NORMAL_PIXEL);
+    ug[v3] = VertexProperties(3, 3, NORMAL_PIXEL);
+    ug[v4] = VertexProperties(4, 2.5, NORMAL_PIXEL);
+    ug[v5] = VertexProperties(5, 2.5, NORMAL_PIXEL);
+    ug[v7] = VertexProperties(7, 2., NORMAL_PIXEL);
+    ug[v9] = VertexProperties(9, 2.5, TOP_PIXEL);
+    ug[v11] = VertexProperties(11, 2, NORMAL_PIXEL);
+    ug[v12] = VertexProperties(12, 1.5, NORMAL_PIXEL);
+    ug[v13] = VertexProperties(13, 1.5, NORMAL_PIXEL);
+    ug[v14] = VertexProperties(14, 1, TOP_PIXEL);
+    ug[v15] = VertexProperties(15, 1, NORMAL_PIXEL);
+    ug[v16] = VertexProperties(16, 1, NORMAL_PIXEL);
+    ug[v17] = VertexProperties(17, 1, NORMAL_PIXEL);
+    ug[v18] = VertexProperties(18, 1.5, TOP_PIXEL);
+    ug[v19] = VertexProperties(19, 1.5, NORMAL_PIXEL);
+    ug[v20] = VertexProperties(20, 1.5, NORMAL_PIXEL);
+    ug[v21] = VertexProperties(21, 1, TOP_PIXEL);
+    ug[v22] = VertexProperties(22, 1, NORMAL_PIXEL);
+    ug[v23] = VertexProperties(23, 1, NORMAL_PIXEL);
+    ug[v24] = VertexProperties(24, 2, NORMAL_PIXEL);
+    ug[v25] = VertexProperties(25, 2, NORMAL_PIXEL);
+    ug[v26] = VertexProperties(26, 1.5, TOP_PIXEL);
+    ug[v27] = VertexProperties(27, 1.5, NORMAL_PIXEL);
+    ug[v28] = VertexProperties(28, 1.5, NORMAL_PIXEL);
+    ug[v29] = VertexProperties(29, 1, TOP_PIXEL);
+    ug[v30] = VertexProperties(30, 1, TOP_PIXEL);
+    ug[v31] = VertexProperties(31, 2, NORMAL_PIXEL);
+    ug[v32] = VertexProperties(32, 2, NORMAL_PIXEL);
+    ug[v33] = VertexProperties(33, 2, NORMAL_PIXEL);
+    ug[v34] = VertexProperties(34, 1.5, TOP_PIXEL);
+    ug[v35] = VertexProperties(35, 1.5, NORMAL_PIXEL);
+    ug[v36] = VertexProperties(36, 1.5, TOP_PIXEL);
+    ug[v37] = VertexProperties(37, 1.5, NORMAL_PIXEL);
+
+}
+
+void modify_file_paths(std::string& absolutePath,
+                       std::vector < std::string* >& files)
+{
+    for (std::vector < std::string* >::iterator it = files.begin();
+         it != files.end(); it++) {
+        (*it)->insert(0, absolutePath);
+    }
+}
+
+void build_corsen_graph(OrientedGraph& graph)
+{
+    std::string absolutePath(
+        "/home/eric/vle/vle-labs/paradevs/src/tests/corsen/data_s/");
+    std::string modeFile(".mode");
+    std::string parametersFile("par.txt");
+    std::string elevationFile("alt");
+    std::string outletFile("arbre");
+    std::string layersFile("couche");
+    std::string contextFile("contexte_yar_scenario.xml");
+    std::string slopeFile("pav");
+    std::vector < std::string* > files;
+    Corsen c;
+
+    files.push_back(&parametersFile);
+    files.push_back(&modeFile);
+    files.push_back(&elevationFile);
+    files.push_back(&outletFile);
+    files.push_back(&slopeFile);
+    files.push_back(&contextFile);
+    files.push_back(&layersFile);
+    modify_file_paths(absolutePath, files);
+
+    c.read(files, absolutePath);
+    c.buildGraph();
+
+    const DirectedGraph& g = c.getGraph().graph();
+    std::vector < vertex_t > og_vertex_list;
+    std::vector < vertex_t > dg_vertex_list;
+    std::vector < int > dg_in_vertex_list;
+    DirectedGraph::vertex_iterator it_dg, end_dg;
+
+    tie(it_dg, end_dg) = vertices(g);
+    for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
+        og_vertex_list.push_back(add_vertex(graph));
+        dg_vertex_list.push_back(*it_dg);
+        dg_in_vertex_list.push_back(0);
+    }
+
+    tie(it_dg, end_dg) = vertices(g);
+    for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
+        DirectedGraph::adjacency_iterator neighbour_it, neighbour_end;
+
+        tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_dg, g);
+        for (; neighbour_it != neighbour_end; ++neighbour_it) {
+            uint index = 0;
+
+            while (dg_vertex_list[index] != *neighbour_it) {
+                ++index;
+            }
+            ++dg_in_vertex_list[index];
+            boost::add_edge(og_vertex_list[i], og_vertex_list[index],
+                            EdgeProperties(1.), graph);
+        }
+    }
+
+    tie(it_dg, end_dg) = vertices(g);
+    for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
+        if (dg_in_vertex_list[i] == 0) {
+            graph[og_vertex_list[i]] = VertexProperties(i, 1., TOP_PIXEL);
+        } else {
+            graph[og_vertex_list[i]] = VertexProperties(i, 1., NORMAL_PIXEL);
+        }
+    }
+}
+
+} } } // namespace paradevs tests boost_graph

+ 39 - 0
src/tests/boost_graph/partitioning/graph_build.hpp

@@ -0,0 +1,39 @@
+/**
+ * @file tests/boost_graph/partitioning/graph_build.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_BOOST_GRAPH_PARTITIONING_GRAPH_BUILD_H
+#define TESTS_BOOST_GRAPH_PARTITIONING_GRAPH_BUILD_H
+
+#include <tests/boost_graph/partitioning/defs.hpp>
+
+namespace paradevs { namespace tests { namespace boost_graph {
+
+void build_graph(UnorientedGraph& g, OrientedGraph& graph);
+void build_corsen_graph(OrientedGraph& graph);
+
+} } } // namespace paradevs tests boost_graph
+
+#endif

+ 132 - 0
src/tests/boost_graph/partitioning/main.cpp

@@ -0,0 +1,132 @@
+/**
+ * @file tests/boost_graph/partitioning/main.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <tests/boost_graph/partitioning/gggp.hpp>
+#include <tests/boost_graph/partitioning/graph_build.hpp>
+
+#include <boost/timer.hpp>
+
+#include <iostream>
+
+using namespace paradevs::tests::boost_graph;
+
+UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+OrientedGraph::vertex_iterator vertexIto, vertexEndo;
+OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
+
+int main()
+{
+    boost::timer t;
+
+    srand((unsigned)time(NULL));
+
+    UnorientedGraph* g = new UnorientedGraph();
+    OrientedGraph* go = new OrientedGraph();
+    UnorientedGraph* graph_origin = new UnorientedGraph();
+    OrientedGraph* gop = new OrientedGraph();
+
+    build_graph(*g, *go);
+    build_graph(*graph_origin, *gop);
+
+    delete gop;
+
+    int nbr_parties = 4;
+
+    /*EntiersEntiers Partition = Random_partitioning(g,nbr_parties);
+
+    for(uint i = 0; i < Partition.size(); i++){
+    	for(uint j = 0; j < Partition.at(i)->size(); j++){
+    		std::cout<<Partition.at(i)->at(j)<<std::endl;
+    	}
+    	std::cout<<std::endl;
+    }
+
+    std::cout<<Partition.size()<<std::endl;*/
+
+    Edges edge_partie;
+    OutputEdgeList outputedgeslist(nbr_parties);
+    InputEdgeList inputedgelist;
+    Connections connections;
+
+    std::cout<<num_vertices(*g)/4<<std::endl;
+
+    OrientedGraphs graphs = Multiniveau(num_vertices(*g)/2, g, graph_origin, go, nbr_parties,"rand", "gggp_pond",
+                                        "cut_norm", "norm", edge_partie ,
+                                        outputedgeslist, inputedgelist,
+                                        connections);
+
+    std::cout << std::endl;
+    std::cout << "Sous Graphes :" << std::endl;
+    for (uint i = 0; i< graphs.size(); i++) {
+        tie(vertexIto, vertexEndo) = vertices(graphs[i]);
+        for (; vertexIto != vertexEndo; ++vertexIto) {
+            std::cout << graphs[i][*vertexIto]._index
+                      << " est connecté avec ";
+            tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
+                                                                 graphs[i]);
+            for (; neighbourIto != neighbourEndo; ++neighbourIto)
+                std::cout << graphs[i][*neighbourIto]._index << " ";
+            std::cout << " et son poids est de "
+                      << graphs[i][*vertexIto]._weight<<std::endl;
+        }
+        std::cout << std::endl;
+    }
+
+    std::clog << "OutputEdgeList :" << std::endl;
+    for (uint i = 0; i < outputedgeslist.size(); i++) {
+        for (uint j = 0; j < outputedgeslist.at(i).size(); j++){
+            std::cout << outputedgeslist.at(i).at(j).first << " "
+                      << outputedgeslist.at(i).at(j).second << std::endl;
+        }
+    }
+    std::cout << std::endl;
+
+    std::clog << "InputEdgeList :" << std::endl;
+    for (uint i = 0; i < inputedgelist.size(); i++) {
+        for (uint j = 0; j < inputedgelist.at(i).size(); j++){
+            std::cout << inputedgelist.at(i).at(j).first << " "
+                      << inputedgelist.at(i).at(j).second << std::endl;
+        }
+    }
+    std::cout << std::endl;
+
+    std::clog << "Connections :" << std::endl;
+    for (uint i = 0; i < connections.size(); i++) {
+        std::cout << "(" << connections.at(i).first.first << ","
+                  << connections.at(i).first.second << ") -> ("
+                  << connections.at(i).second.first << ","
+                  << connections.at(i).second.second << ")"
+                  << std::endl;
+    }
+
+	delete graph_origin;
+	delete go;
+
+    std::cout << "Duration : " << t.elapsed() << " seconds" << std::endl;
+
+}

+ 1588 - 0
src/tests/boost_graph/partitioning/utils.cpp

@@ -0,0 +1,1588 @@
+/**
+ * @file tests/boost_graph/partitioning/utils.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <tests/boost_graph/partitioning/utils.hpp>
+
+#include <algorithm>
+#include <iostream>
+
+namespace paradevs { namespace tests { namespace boost_graph {
+
+UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+OrientedGraph::vertex_iterator vertexIto, vertexEndo;
+OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
+
+struct myclass
+{
+    bool operator() (Entiers *i, Entiers *j)
+    { return i->at(0) < j->at(0); }
+} myobject;
+
+struct myclass2
+{
+    bool operator() (Entiers *i, Entiers *j, UnorientedGraph *g)
+    { return Calcul_poids(i,g) < Calcul_poids(j,g); }
+} mon_tri;
+
+/**
+ * Fonction de verification de la connexité d'un graphe
+ * @param *g : adresse d'un graphe de type boost graphe undirected
+ * @param Partition : vecteur contenant des vecteurs d'entiers [tableau contenant les parties de la partition]
+ * @param part : vecteur d'entier (une partie de la partition)
+ * @return un booleen
+ */
+bool Est_connexe(UnorientedGraph *g, EntiersEntiers Partition, Entiers &part)
+{
+    /*
+     * Copie du graphe contenu par l'adresse *g
+     */
+    UnorientedGraph copie_g;
+    copie_g = *g;
+
+    /*
+     * Modification du graphe copié afin de générer des sous graphes liés aux différentes parties
+     */
+    for (uint i=0; i<Partition.size()-1;i++)
+    {
+        for (uint j=1+i; j<Partition.size();j++)
+        {
+            for (uint k=0; k<Partition.at(i)->size();k++)
+            {
+                for (uint y=0; y<Partition.at(j)->size();y++)
+                {
+                    remove_edge(Partition.at(i)->at(k),Partition.at(j)->at(y),copie_g); //suppression de certains arcs
+                }
+            }
+        }
+    }
+
+    /*
+     * Objectif : déterminer s'il existe un chemin reliant tous les noeuds d'une même partie
+     * Méthode : partir d'un sommet de départ tiré aléatoirement dans la partie "part" et parcourir l'ensemble de ces voisins.
+     * Si le voisin recontré n'est pas contenu dans le vecteur "sommets" il est ajouté. Le processus est répété pour chaque
+     * nouveau sommet ajouté au vecteur.
+     * Résultat : si le nombre de sommets contenu dans le vecteur "part" est égale au nombre de sommets du vecteur "sommets"
+     * alors le graphe est connexe
+     */
+
+    int val;
+    Entiers sommets;
+
+    if(part.size()==1)
+        val = 0;
+    else
+        val=rand_fini(0,part.size()-1); //tirage aléatoire d'un sommets
+
+    int vertex = part.at(val);
+    sommets.push_back(vertex); //ajout du sommets à la lsite des sommets parcouru
+
+    /*
+     * Recherche de voisins n'appartenant pas à la liste des sommets parcourus
+     */
+    for(uint i = 0;i<sommets.size();i++){
+        tie(neighbourIt, neighbourEnd) = adjacent_vertices(sommets.at(i),copie_g);
+        for (; neighbourIt != neighbourEnd; ++neighbourIt){
+            if(In_tab(sommets,*neighbourIt)!=1)
+                sommets.push_back(*neighbourIt);
+        }
+    }
+
+    /*
+     * Retour de la réponse vrai ou faux
+     */
+    if(part.size()!=sommets.size())
+        return false;
+    else
+        return true;
+
+}
+
+/**
+ * Fonction de projection
+ * @param Partition : vecteur contenant des vecteurs d'entiers [tableau contenant les parties de la partition]
+ * @param lit : itérateur sur une liste contenant une vecteur de vecteur d'entier
+ * @return
+ */
+
+/*
+ * Objectif : obtenir la correspondance entre les sommets d'un graphe Gn et celui de Gn-1
+ * Méthode : modification des sommets contenus dans "Partition" à l'aide de la liste de correspondance *lit
+ */
+
+void projection(EntiersEntiers &Partition,ListEntiersEntiers::iterator lit)
+{
+
+    /*
+     * Création d'un nouveau vecteur contenant les adresses d'autres vecteur d'entiers.
+     * Celui-ci est conçu pour recevoir les sommets contenus dans la liste de correspondance,
+     * correspondant à la projection des sommets du graphe Gn à celui de Gn-1
+     */
+    EntiersEntiers new_partition;
+    for(uint i = 0; i< Partition.size() ; i++)
+    {
+        Entiers *new_part = new Entiers();
+        for(uint j = 0 ; j<Partition.at(i)->size() ; j++)
+        {
+            for(uint k = 0; k<((*lit)->at(Partition.at(i)->at(j)))->size();k++){
+                new_part->push_back((*lit)->at(Partition.at(i)->at(j))->at(k));
+            }
+
+        }
+        new_partition.push_back(new_part);
+    }
+
+
+    /*
+     * Désalocation mémoire des pointeurs que contient "Partition"
+     */
+    for(EntiersEntiers::iterator it = Partition.begin(); it != Partition.end(); it++)
+    {
+        delete *it;
+        *it = NULL;
+    }
+
+    Partition = new_partition; // copie de new_partition dans Partition
+    for(uint i =0; i<Partition.size(); i++) {
+        // permet de trier chaque  sous vecteur de "Partition"
+        std::sort(Partition[i]->begin(),Partition[i]->end());
+    }
+
+    new_partition.clear();
+}
+
+/**
+ * Fonction qui calcul le poids d'une partie
+ * @param * part : adresse d'un vecteur d'entier, ici une partie de la partition
+ * @param *g : adresse d'un graphe de type boost graphe undirected
+ * @return un type double contenant le poids associé à la partie
+ */
+double Calcul_poids(Entiers *partie, UnorientedGraph *g)
+{
+    double poids=0; // initialisation du poids à 0
+
+    /*
+     * Pour chaque sommet de la partie concerné on ajoute son poids au poids total
+     */
+    for(uint j = 0; j<partie->size();j++){
+        poids+=(*g)[partie->at(j)]._weight;
+    }
+
+    return poids;
+}
+
+/**
+ * Fonction d'affinage suivant un critère de poids
+ * @param *g : adresse d'un graphe de type boost graphe undirected
+ * @param Partition : vecteur contenant des vecteurs d'entiers [tableau contenant les parties de la partition]
+ * @return modification de la partition
+ */
+void Affinage_equilibrage_charge(UnorientedGraph *g, EntiersEntiers &Partition)
+{
+    /*
+     * Calcule de la somme des poids du graphe et le poids moyen à atteindre
+     */
+    double poids_moyen = 0.;
+
+    for(uint i = 0; i < num_vertices(*g); i++) {
+        poids_moyen += (*g)[i]._weight;
+    }
+
+    // détermination du poids moyen à atteindre pour chaque partie
+    poids_moyen /= Partition.size();
+
+    std::vector < double > poids_parties;
+
+    /*
+     * Calcul du poids de chaque partie de la partition
+     */
+    for (uint i = 0; i < Partition.size(); i++) {
+        double tmp = Calcul_poids(Partition.at(i),g);
+
+        poids_parties.push_back(tmp);
+    }
+
+    std::clog << "Poids initial des parties : " << std::endl;
+
+    // for (uint i = 0; i < poids_parties.size(); i++){
+    //     std::cout << poids_parties.at(i) << " ";
+    // }
+    // std::cout << "\n" << std::endl;
+
+    /*
+     * Le critère d'amélioration consiste à faire tendre vers 0 la somme
+     * des écarts entre le poids des parties et le poids moyen
+     * le "critere" est la somme pour chaque partie de la différence
+     * en valeurs absolues du poids
+     * d'une partie moins le poids moyen divisé par le nombre de parties
+     */
+
+    double critere = 0.;
+
+    for (uint i = 0; i < poids_parties.size(); i++){
+        critere += abs(poids_parties.at(i) - poids_moyen);
+    }
+    critere /= Partition.size();
+
+    // on conserve le poids maximum
+    double p_max = *max_element(poids_parties.begin(), poids_parties.end());
+
+    // std::cout << "Valeurs du criètre de départ : " << critere << std::endl;
+
+    // création d'un second critère légérement plsu faible que le premier
+    double best_critere = critere - 1e-7;
+    uint nbr_passage = 1; // initialisation du nombre de passages à 1
+
+    /*
+     * Tant que le critère n'est pas amélioré etque le nombre de
+     * passage est inférieur au nombre de parties on réalise
+     * des modifications sur la partition
+     */
+    while (best_critere < critere or nbr_passage < Partition.size()) {
+        critere = best_critere; //critere devient best_critere
+
+        // recherche la partie associé au poids maximum
+        int cpt = recherche_val_double(poids_parties,p_max);
+        bool decision = false; //initialisatio d'un booleen a false
+        int nbr_pass_interne = 0;
+
+        /*
+         * tirage aléatoire des sommets de la partie de poids maximum
+         */
+        Entiers random_orders(Partition.at(cpt)->size());
+        for (uint i=0 ; i<Partition.at(cpt)->size() ; i++)
+            random_orders.at(i)=Partition.at(cpt)->at(i);
+
+        for (uint j=0 ; j<Partition.at(cpt)->size()-1 ; j++) {
+            int rand_pos = (rand() % Partition.at(cpt)->size()-j)+j;
+            int tmp = random_orders[j];
+            random_orders[j] = random_orders[rand_pos];
+            random_orders[rand_pos] = tmp;
+        }
+
+        /*
+         * Si le nombre de sommets d'une partie excéde les 400, on tire au hasar 400 sommets sans remise
+         * et on effectue les modifications (ceci permet d'eviter une explosion des temps de calcul)
+         */
+        int size;
+
+        if(Partition.at(cpt)->size()>400)
+            size = 400;
+        else
+            size = Partition.at(cpt)->size();
+
+        /*
+         * Seconde boucle Tant que sur les sommets d'une partie.
+         * Tant que le critere booleen est vrai et que le nombre de passe interne est inférieur au seuil size faire
+         */
+        while(decision!=true && nbr_pass_interne < size){
+            int vertex = random_orders.at(nbr_pass_interne); //tirage d'un sommets dans la parite de poids maximum
+            Entiers community = Neigh_community(g,Partition,vertex,cpt); // recherche des communautés voisines à ce sommet (s'il est au bord)
+            if(community.size()!=0) // s'il existe au moins une communauté voisine
+            {
+                std::vector<double> new_poids_parties; // initialisation d'un nouveau vecteur contenant des doubles
+                std::vector<double> tmp_critere; // initialisation d'un nouveau vecteur contenant des doubles
+
+                /*
+                 * Pour chacune des parties (communauté) voisine au sommet vertexs faire
+                 */
+                for(uint k = 0; k < community.size();k++)
+                {
+                    new_poids_parties = poids_parties; //copie du tableau de poids des parties dans new_poids_parties
+
+                    /*
+                     * Modification des poids des parties :
+                     * on ajoute le poids du sommets à la partie voisine
+                     * et on soustrait son poids à sa partie d'origine
+                     */
+                    new_poids_parties.at(community.at(k))+=(*g)[vertex]._weight;
+                    new_poids_parties.at(cpt)-=(*g)[vertex]._weight;
+
+                    /*
+                     * Calcul ldu nouveau critère associé à cette modification
+                     */
+                    double new_critere = 0.;
+
+                    for(uint i = 0; i<poids_parties.size();i++){
+                        new_critere += abs(new_poids_parties.at(i)-poids_moyen);
+                    }
+                    new_critere/=Partition.size();
+                    tmp_critere.push_back(new_critere); // enregistrement du résutlat dans le tableau tmp_critere
+                }
+                double val_min = *min_element(tmp_critere.begin(),tmp_critere.end()); // enregistrement de la valeur minimale du tableau tmp_critere
+                int val = recherche_val_double(tmp_critere,val_min); // recherche de la communauté correspondant à cette valeur
+
+                /*
+                 * Si la valeur associé est plus petite et que la partie selectionné n'est pas vérouillée faire
+                 */
+                if(val_min<critere && poids_parties.at(val)!=-1)
+                {
+                    /*
+                     * On change le sommet vertex de partie, il est déplacé vers la partie
+                     * qui permet la meilleure amélioration du critère
+                     */
+                    Partition.at(community.at(val))->push_back(vertex);
+                    suprim_val(*Partition.at(cpt),vertex);
+                    std::sort(Partition.at(community.at(val))->begin(), Partition.at(community.at(val))->end());
+
+                    /*
+                     * Vérification de la sauvegarde de la connexsité,
+                     * si se n'est pas le cas retour à l'état précédent
+                     */
+                    if(Est_connexe(g,Partition,*Partition.at(cpt))!=1)
+                    {
+                        suprim_val(*Partition.at(community.at(val)),vertex);
+                        Partition.at(cpt)->push_back(vertex);
+                        std::sort(Partition.at(cpt)->begin(), Partition.at(cpt)->end());
+                        // std::cout<<" C'EST MORT RETOUR EN ARRIERE ! "<<std::endl
+                            ;
+                    }
+                    else
+                    {
+                        poids_parties = new_poids_parties;
+                        decision = true;
+                        // std::cout<<" Modification reussi ! "<<std::endl;
+                    }
+                }
+            }
+            nbr_pass_interne++;
+        }
+        /*
+         * Si aucune modification n'a été réalisé pour cett partie de poids maximum
+         */
+        if(decision==false)
+        {
+            nbr_passage++; // augmentation du nombre de passage
+            poids_parties.at(cpt)=-1; // vérrouillage de la partie
+            std::clog<<"nouveau passag ! "<<std::endl;
+        }
+        else
+        {
+            best_critere = 0.;
+
+            for(uint i = 0; i<poids_parties.size();i++){
+                best_critere += abs(poids_parties.at(i)-poids_moyen);
+            }
+            best_critere/=Partition.size();
+            nbr_passage = 0;
+        }
+
+        // std::clog<<"Poids des parties modifié : "<<std::endl;
+        // for(uint i = 0; i<poids_parties.size(); i++){
+        //     std::cout<<poids_parties.at(i)<<" ";
+        // }
+        // std::cout<<"\n"<<std::endl;
+        p_max = *max_element(poids_parties.begin(),poids_parties.end());
+        // std::cout<<"Valeurs du criètre : "<<critere<<std::endl;
+        // std::cout<<"Valeurs du best_criètre : "<<best_critere<<std::endl;
+        // std::cout<<"Nombre de passage : "<<nbr_passage<<std::endl;
+        // std::cout<<"\n"<<std::endl;
+
+    }
+}
+
+Entiers Neigh_community(UnorientedGraph *g, EntiersEntiers &Partition, int vertex, int comm_in)
+{
+    Entiers community;
+    int comm;
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex,*g);
+    for (; neighbourIt != neighbourEnd; ++neighbourIt){
+        comm = In_community_dichotomie(Partition,*neighbourIt);
+        if(In_tab(community,comm)!=1 && comm!=comm_in)
+            community.push_back(comm);
+    }
+    return community;
+}
+
+void Affinage_recherche_locale(UnorientedGraph *g, EntiersEntiers &Partition, double &cut, std::string name)
+{
+
+    Entiers random_orders(num_vertices(*g)); //gestion d'un tableau contenant tout les sommets et ranger de façon aléatoire
+
+    for (uint i=0 ; i<num_vertices(*g) ; i++)
+        random_orders.at(i)=i;
+
+    for (uint j=0 ; j<num_vertices(*g)-1 ; j++) {
+        int rand_pos = (rand() % num_vertices(*g)-j)+j;
+        int tmp = random_orders[j];
+        random_orders[j] = random_orders[rand_pos];
+        random_orders[rand_pos] = tmp;
+    }
+    uint size = random_orders.size();
+
+    if(num_vertices(*g)>500)
+        size=500;
+
+    std::vector<std::vector<double> > tabe_cut;
+
+    //std::cout<<"Passage : "<<Partition.size()<<std::endl;
+    for(uint k = 0; k < Partition.size();k++){
+        std::vector<double> tmp;
+        double vol = 0.;
+        double cut = Modif_Cut_one_cluster(*Partition.at(k), *g, vol);
+        tmp.push_back(cut);
+        tmp.push_back(vol);
+        tabe_cut.push_back(tmp);
+    }
+
+    for(uint i = 0; i < size; i++){
+        if(random_orders.at(i)!=-1){
+            int vertex = random_orders.at(i);
+            //std::cout<<vertex<<std::endl;
+            int comm = In_community_dichotomie(Partition, vertex);
+            Entiers community = Neigh_community(g,Partition,vertex,comm);
+            std::vector<double> tmp_cut;
+
+            if(community.size()!=0 && Partition.at(comm)->size()!=1){
+                tmp_cut = modif_cut_tmp(g,Partition,tabe_cut,vertex,comm,community,cut,name);
+                /*for(uint z = 0; z<tmp_cut.size(); z++){
+                    std::cout<<tmp_cut.at(z)<<std::endl;
+                }
+                std::cout<<"\n"<<std::endl;*/
+                double cut_min = *min_element(tmp_cut.begin(),tmp_cut.end());
+                //std::cout<<"cout de coupe minimum de la liste : "<<cut_min<<std::endl;
+                if(cut_min<cut){
+                    // std::clog<<"Changement ! "<<std::endl;
+                    int tmp = recherche_val_double(tmp_cut,cut_min);
+                    cut=cut_min;
+                    Partition.at(community.at(tmp))->push_back(vertex);
+                    suprim_val(*Partition.at(comm),vertex);
+                    std::sort(Partition.at(community.at(tmp))->begin(), Partition.at(community.at(tmp))->end());
+                    tabe_cut.clear();
+                    for(uint k = 0; k < Partition.size();k++){
+                        std::vector<double> tmp;
+                        double vol = 0.;
+                        double cut = Modif_Cut_one_cluster(*Partition.at(k), *g, vol);
+                        tmp.push_back(cut);
+                        tmp.push_back(vol);
+                        tabe_cut.push_back(tmp);
+                    }
+
+                }
+            }
+
+            //Modif_fonction_Gain_Cut(Partition,g,community,vertex,cut,name);
+
+
+            /*if(Est_connexe(g,Partition,*Partition.at(comm))!=1)
+              {
+              suprim_val(*Partition.at(community.at(tmp)),vertex);
+              Partition.at(comm)->push_back(vertex);
+              std::sort(*Partition.at(comm));
+              std::cout<<" C'EST MORT RETOUR EN ARRIERE ! "<<std::endl;
+              }*/
+
+        }
+    }
+}
+
+double Modif_Cut_one_cluster(Entiers &cluster, UnorientedGraph &g, double &vol)
+{
+	edge_t e1;
+	bool found;
+	double cpt=0.;
+	for(uint i=0;i<cluster.size();i++){
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i), g);
+		for (; neighbourIt != neighbourEnd; ++neighbourIt){
+			tie(e1,found)=edge(vertex(cluster[i],g),vertex(*neighbourIt,g),g);
+			if(In_tab(cluster,*neighbourIt)!=1){
+				cpt+=g[e1]._weight;
+			}
+		}
+	}
+	vol = Cluster_Degree(g,cluster);
+	return cpt/2.;
+
+}
+
+std::vector<double> modif_cut_tmp(UnorientedGraph *g, EntiersEntiers &Partition, std::vector<std::vector<double> > tabe_cut, int vertexs, int comm_in, Entiers community, double cut,std::string name){
+	edge_t e1;
+	bool found;
+	//std::cout<<"le sommet tiré est : "<<vertexs<<std::endl;
+
+	if(name!="norm")
+	{
+		std::vector<double> modif_cut(community.size());
+		double cpt_comm_in;
+		double cpt_comm_out;
+		for(uint i =0; i<community.size(); i++){
+			double tmp_cut = cut;
+			cpt_comm_in=0;
+			cpt_comm_out=0;
+
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertexs,*g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				tie(e1,found)=edge(vertex(vertexs,*g),vertex(*neighbourIt,*g),*g);
+				if(In_tab(*Partition.at(comm_in),*neighbourIt)==1)
+					cpt_comm_in+=(*g)[e1]._weight;
+				else if(In_tab(*Partition.at(community.at(i)),*neighbourIt)==1)
+					cpt_comm_out+=(*g)[e1]._weight;
+			}
+
+			tmp_cut+=cpt_comm_in;
+			tmp_cut-=cpt_comm_out;
+
+			modif_cut.at(i)=tmp_cut;
+		}
+		return modif_cut;
+	}
+	else{
+		std::vector<double> modif_cut(community.size());
+		double cpt_comm_in;
+		double cpt_comm_out;
+		double tmp_cut;
+
+		for(uint i =0; i<community.size(); i++){
+			std::vector<std::vector<double> > tab_cut = tabe_cut;
+
+			tmp_cut =0.;
+			cpt_comm_in=0.;
+			cpt_comm_out=0.;
+
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertexs,*g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				tie(e1,found)=edge(vertex(vertexs,*g),vertex(*neighbourIt,*g),*g);
+				if(In_tab(*Partition.at(comm_in),*neighbourIt)==1)
+					cpt_comm_in+=(*g)[e1]._weight;
+				else if(In_tab(*Partition.at(community.at(i)),*neighbourIt)==1)
+					cpt_comm_out+=(*g)[e1]._weight;
+			}
+
+			cpt_comm_in/=2.;
+			cpt_comm_out/=2.;
+
+			tab_cut.at(comm_in).at(0)+=cpt_comm_in;
+			tab_cut.at(comm_in).at(0)-=cpt_comm_out;
+			tab_cut.at(comm_in).at(1)-= Degree(*g ,vertexs);
+
+			tab_cut.at(community.at(i)).at(0)+=cpt_comm_in;
+			tab_cut.at(community.at(i)).at(0)-=cpt_comm_out;
+			tab_cut.at(community.at(i)).at(1)+= Degree(*g ,vertexs);
+
+			for(uint j = 0; j < tab_cut.size();j++){
+				tmp_cut+=((tab_cut.at(j).at(0))/(tab_cut.at(j).at(1)));
+			}
+
+			modif_cut.at(i)=tmp_cut;
+		}
+		return modif_cut;
+	}
+}
+void Modif_fonction_Gain_Cut(EntiersEntiers &Partition,UnorientedGraph *g, Entiers &community, int val, double &cut,std::string name)
+{
+	/*std::cout<<"Nombre de communauté voisine : "<<community.size()<<std::endl;
+	std::cout<<"\n"<<std::endl;*/
+	for(uint i = 0; i<community.size();i++){
+		EntiersEntiers new_partition;
+		for(uint k = 0; k < Partition.size();k++){
+			Entiers * tmp = new Entiers();
+			for(uint j = 0;j<Partition.at(k)->size();j++){
+				tmp->push_back(Partition.at(k)->at(j));
+			}
+			new_partition.push_back(tmp);
+		}
+
+		/*std::cout<<"Avant Modification partition"<<std::endl;
+		std::cout<<"************"<<std::endl;
+		for(uint t = 0; t< new_partition.size() ; t++)
+				{
+					for(uint j = 0 ; j<new_partition.at(t)->size() ; j++)
+					{
+						std::cout<<new_partition.at(t)->at(j)<<std::endl;
+					}
+					std::cout<<"\n"<<std::endl;
+				}
+		std::cout<<"************"<<std::endl;*/
+
+
+		new_partition.at(community.at(i))->push_back(val);
+		suprim_val(*new_partition.at(In_community_dichotomie(Partition,val)),val);
+		std::sort(new_partition.at(community.at(i))->begin(),
+                    new_partition.at(community.at(i))->end());
+
+		/*std::cout<<"Modification partition"<<std::endl;
+		std::cout<<"************"<<std::endl;
+		for(uint t= 0; t< new_partition.size() ; t++)
+		{
+			for(uint j = 0 ; j<new_partition.at(t)->size() ; j++)
+			{
+				std::cout<<new_partition.at(t)->at(j)<<std::endl;
+			}
+			std::cout<<"\n"<<std::endl;
+		}
+		std::cout<<"************"<<std::endl;*/
+
+		double coupe = Cut_cluster(new_partition,*g,name);
+
+		//std::cout<<"cout de coupe : "<<coupe<<std::endl;
+		if(coupe<cut)
+		{
+			for(EntiersEntiers::iterator it = Partition.begin(); it != Partition.end(); it++)
+			{
+				delete *it;
+				*it = NULL;
+			}
+			Partition = new_partition;
+			cut = coupe;
+		}
+		else
+		{
+			for(EntiersEntiers::iterator it = new_partition.begin(); it != new_partition.end(); it++)
+			{
+				delete *it;
+				*it = NULL;
+			}
+		}
+	}
+}
+
+bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
+	UnorientedGraph *gtmp = new UnorientedGraph();
+	*gtmp=*g;
+	Entiers Random_list_vertices; // Initialisation du tableau de sommets rangés aléatoirements
+	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
+	edge_t e1,e2; // Iterateurs sur les arcs
+	bool found;
+	uint nbr_vertex = num_vertices(*gtmp);
+	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
+	/*
+	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
+	 * aléatoirement afin de simuler un tirage aléatoire
+	 */
+	for (uint i=0 ; i<nbr_vertex ; i++)
+		Random_list_vertices.push_back(i);
+	for (uint j=0 ; j<nbr_vertex-1 ; j++) {
+		int rand_pos = rand()%(nbr_vertex-j)+j;
+		int tmp      = Random_list_vertices[j];
+		Random_list_vertices[j] = Random_list_vertices[rand_pos];
+		Random_list_vertices[rand_pos] = tmp;
+	}
+
+	/*
+	 * Pour chaque sommet non verrouiller faire ....
+	 */
+	for(uint i=0; i<nbr_vertex; i++){
+		int vertexs = Random_list_vertices[i];
+		//std::cout<<"Le sommet tiré est : "<<vertexs<<std::endl;
+		if(vertexs!=-1){
+			Entiers liste_voisin = Liste_adjacence(*gtmp,vertexs,Random_list_vertices); // Recherche des sommets adjacents au sommets  tiré
+			if(liste_voisin.size()!=0){
+				/*
+				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
+				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
+				 * le même poids, on selectionne le sommet d'identifiant le plus petit
+				 */
+				double poids_a = 0.;
+				int best_vertexs = -1;
+				for(uint j=0;j<liste_voisin.size();j++){
+					tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
+					if((*gtmp)[e1]._weight>poids_a){
+						best_vertexs = liste_voisin[j];
+						poids_a = (*gtmp)[e1]._weight;
+					}
+				}
+
+
+				Entiers * couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
+				int vertex_delete = std::max(vertexs, best_vertexs); // Sommet d'indentifiant le plus grand (qui sera détruit)
+				//std::cout<<"sommet détruit : "<<vertex_delete<<std::endl;
+				int vertex_save = std::min(vertexs,best_vertexs); // Sommet d'identifiant le plus petit (qui sera conservé)
+				//std::cout<<"sommet sauvé : "<<vertex_save<<std::endl;
+
+				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
+				/*
+				 * On ajoute au tableau "couple" le couple de sommet à fusionner
+				 */
+				couple->push_back(vertex_save);
+				couple->push_back(vertex_delete);
+				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
+
+				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
+
+				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
+				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
+
+				/*
+				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
+				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
+				 * du processus]
+				 */
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_save.push_back(*neighbourIt);
+				}
+
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_delete.push_back(*neighbourIt);
+				}
+
+				/*
+				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
+				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
+				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
+				 */
+				for(uint j=0;j<neigh_vertex_delete.size();j++){
+					if(In_tab(neigh_vertex_save,neigh_vertex_delete[j])==1){
+						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+					else
+					{
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+				}
+
+				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
+				/*
+				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
+				 */
+				Random_list_vertices[i]=-1;
+				Random_list_vertices[recherche_val(Random_list_vertices,best_vertexs)]=-1;
+				val_cpt--;
+				// std::cout<<val_cpt<<std::endl;
+			}
+			else{
+				/*
+				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
+				 * alors on l'ajoute à la liste de correspondance des sommets et on
+				 * le verrouille
+				 */
+				Entiers *couple = new Entiers();
+				couple->push_back(Random_list_vertices.at(i));
+				tableau_de_correspondance->push_back(couple);
+				Random_list_vertices[i]=-1;
+			}
+
+
+
+			/*std::cout<<"Graphe contracté : "<<std::endl;
+			tie(vertexIt, vertexEnd) = vertices(*gtmp);
+			for (; vertexIt != vertexEnd; ++vertexIt) {
+				std::cout << (*gtmp)[*vertexIt]._index
+						<< " est connecté avec ";
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
+						*gtmp);
+				for (; neighbourIt != neighbourEnd; ++neighbourIt)
+					std::cout << (*gtmp)[*neighbourIt]._index << " ";
+				std::cout << " et son poids est de "
+						<< (*gtmp)[*vertexIt]._weight<<std::endl;
+			}
+			std::cout << std::endl;*/
+		}
+		if(val_cpt == val_reduc){
+			for(uint j=i+1; j <nbr_vertex; j++){
+				if(Random_list_vertices[j] !=-1){
+				Entiers *couple = new Entiers();
+				couple->push_back(Random_list_vertices.at(j));
+				tableau_de_correspondance->push_back(couple);}
+			}
+			break;
+		}
+	}
+
+	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
+	// std::cout<<"\n"<<std::endl;
+	/*
+	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
+	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
+	 * des sommets
+	 */
+	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
+		//std::cout<<"Noeuds a supprimer : "<<sommets_a_detruire.at(j)<<std::endl;
+		remove_vertex(sommets_a_detruire[j],*gtmp);
+	}
+
+	// std::clog<<"Affichage avant tri "<<std::endl;
+	// for(uint k = 0;k<tableau_de_correspondance->size();k++){
+	// 	for(uint v = 0; v<tableau_de_correspondance->at(k)->size();v++){
+	// 		std::cout<<tableau_de_correspondance->at(k)->at(v)<<" ";
+	// 	}
+	// 	std::cout<<"\n"<<std::endl;
+	// }
+	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
+
+	// std::clog<<"Tableau de correspondance "<<std::endl;
+	// for(uint k = 0;k<tableau_de_correspondance->size();k++){
+	// 	for(uint v = 0; v<tableau_de_correspondance->at(k)->size();v++){
+	// 		std::cout<<tableau_de_correspondance->at(k)->at(v)<<" ";
+	// 	}
+	// 	std::cout<<"\n"<<std::endl;
+	// }
+
+	liste_corr.push_back(tableau_de_correspondance);
+	// std::cout<<"\n"<<std::endl;
+	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
+
+	if(val_cpt == val_reduc)
+		return true;
+	else
+		return false;
+
+}
+
+bool contraction_Random_Maching(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
+	UnorientedGraph *gtmp = new UnorientedGraph();
+	*gtmp=*g;
+	Entiers Random_list_vertices; // Initialisation du tableau de sommets rangés aléatoirements
+	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
+	edge_t e1,e2; // Iterateurs sur les arcs
+	bool found;
+	uint nbr_vertex = num_vertices(*gtmp);
+	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
+	/*
+	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
+	 * aléatoirement afin de simuler un tirage aléatoire
+	 */
+	for (uint i=0 ; i<nbr_vertex ; i++)
+		Random_list_vertices.push_back(i);
+	for (uint j=0 ; j<nbr_vertex-1 ; j++) {
+		int rand_pos = rand()%(nbr_vertex-j)+j;
+		int tmp      = Random_list_vertices[j];
+		Random_list_vertices[j] = Random_list_vertices[rand_pos];
+		Random_list_vertices[rand_pos] = tmp;
+	}
+
+	/*
+	 * Pour chaque sommet non verrouiller faire ....
+	 */
+	for(uint i=0; i<nbr_vertex; i++){
+		int vertexs = Random_list_vertices[i];
+		if(vertexs!=-1){
+			Entiers liste_voisin = Liste_adjacence(*gtmp,vertexs,Random_list_vertices); // Recherche des sommets adjacents au sommets  tiré
+			if(liste_voisin.size()!=0){
+				/*
+				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
+				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
+				 * le même poids, on selectionne le sommet d'identifiant le plus petit
+				 */
+				int tmp;
+				if(liste_voisin.size()==1)
+					tmp = 0;
+				else
+					tmp = rand_fini(0,liste_voisin.size()-1);
+
+				int best_vertexs = liste_voisin.at(tmp);
+
+				Entiers * couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
+				int vertex_delete = std::max(vertexs, best_vertexs); // Sommet d'indentifiant le plus grand (qui sera détruit)
+				//std::cout<<"sommet détruit : "<<vertex_delete<<std::endl;
+				int vertex_save = std::min(vertexs,best_vertexs); // Sommet d'identifiant le plus petit (qui sera conservé)
+				//std::cout<<"sommet sauvé : "<<vertex_save<<std::endl;
+
+				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
+				/*
+				 * On ajoute au tableau "couple" le couple de sommet à fusionner
+				 */
+				couple->push_back(vertex_save);
+				couple->push_back(vertex_delete);
+				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
+
+				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
+
+				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les somemts adjacents au "sommet sauvegardé"
+				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
+
+				/*
+				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
+				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
+				 * du processus]
+				 */
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_save.push_back(*neighbourIt);
+				}
+
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_delete.push_back(*neighbourIt);
+				}
+
+				/*
+				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
+				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
+				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
+				 */
+				for(uint j=0;j<neigh_vertex_delete.size();j++){
+					if(In_tab(neigh_vertex_save,neigh_vertex_delete[j])==1){
+						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+					else
+					{
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+				}
+
+				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
+				/*
+				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
+				 */
+				Random_list_vertices[i]=-1;
+				Random_list_vertices[recherche_val(Random_list_vertices,best_vertexs)]=-1;
+				val_cpt--;
+				// std::cout<<val_cpt<<std::endl;
+			}
+			else{
+				/*
+				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
+				 * alors on l'ajoute à la liste de correspondance des sommets et on
+				 * le verrouille
+				 */
+				Entiers *couple = new Entiers();
+				couple->push_back(Random_list_vertices.at(i));
+				tableau_de_correspondance->push_back(couple);
+				Random_list_vertices[i]=-1;
+			}
+		}
+		if(val_cpt == val_reduc){
+			for(uint j=i+1; j <nbr_vertex; j++){
+				if(Random_list_vertices[j] !=-1){
+				Entiers *couple = new Entiers();
+				couple->push_back(Random_list_vertices.at(j));
+				tableau_de_correspondance->push_back(couple);}
+			}
+			break;
+		}
+	}
+
+	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
+	//std::cout<<"\n"<<std::endl;
+	/*
+	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
+	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
+	 * des sommets
+	 */
+	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
+		//std::cout<<"Noeuds a supprimer : "<<sommets_a_detruire.at(j)<<std::endl;
+		remove_vertex(sommets_a_detruire[j],*gtmp);
+	}
+
+	/**std::clog<<"Affichage avant tri "<<std::endl;
+	for(uint k = 0;k<tableau_de_correspondance->size();k++){
+		for(uint v = 0; v<tableau_de_correspondance->at(k)->size();v++){
+			std::cout<<tableau_de_correspondance->at(k)->at(v)<<" ";
+		}
+		std::cout<<"\n"<<std::endl;
+	}*/
+	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
+
+	// std::clog<<"Tableau de correspondance "<<std::endl;
+	// for(uint k = 0;k<tableau_de_correspondance->size();k++){
+	// 	for(uint v = 0; v<tableau_de_correspondance->at(k)->size();v++){
+	// 		std::cout<<tableau_de_correspondance->at(k)->at(v)<<" ";
+	// 	}
+	// 	std::cout<<"\n"<<std::endl;
+	// }
+
+	liste_corr.push_back(tableau_de_correspondance);
+	// std::cout<<"\n"<<std::endl;
+	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
+
+
+	if(val_cpt == val_reduc)
+		return true;
+	else
+		return false;
+
+}
+
+Entiers Liste_adjacence(UnorientedGraph &g, int vertexs,const Entiers &random_vertices){ // a revoir !!!!
+	Entiers liste_voisin;
+	tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertexs, g);
+	for (; neighbourIt != neighbourEnd; ++neighbourIt){
+		if(In_tab(random_vertices,*neighbourIt)==1)
+			liste_voisin.push_back(*neighbourIt);
+	}
+	return liste_voisin;
+}
+
+int rand_fini(int a, int b){
+	return rand()%(b-a)+a;
+}
+
+/**
+ * Fonction de recherche d'une valeur dans un tableau.
+ * @param tab
+ * @param val
+ * @return
+ */
+int recherche_val2(const std::vector<float> &tab,float val){
+	int cpt=0;
+	while(tab[cpt]!=val)
+		cpt++;
+	return cpt;
+}
+
+int recherche_val_double(const std::vector<double> &tab,double val){
+	int cpt=0;
+	while(tab[cpt]!=val)
+		cpt++;
+	return cpt;
+}
+
+int recherche_val(const Entiers &tab,int val){
+	int cpt=0;
+	while(tab[cpt]!=val)
+		cpt++;
+	return cpt;
+}
+/**
+ * @param tab
+ * @param i
+ * @return
+ */
+int dichotomie(const Entiers &tab, int i){
+
+	/* déclaration des variables locales à la fonction */
+	int id;  //indice de début
+	int ifin;  //indice de fin
+	int im;  //indice de "milieu"
+
+	/* initialisation de ces variables avant la boucle de recherche */
+	id = 0;  //intervalle de recherche compris entre 0...
+	ifin = tab.size();  //...et nbVal
+
+	/* boucle de recherche */
+	while ((ifin - id) > 1){
+		im = (id + ifin)/2;  //on détermine l'indice de milieu
+		if(tab[im] > i) ifin = im;  //si la valeur qui est à la case "im" est supérieure à la valeur recherchée, l'indice de fin "ifin" << devient >> l'indice de milieu, ainsi l'intervalle de recherche est restreint lors du prochain tour de boucle
+		else id = im;  //sinon l'indice de début << devient >> l'indice de milieu et l'intervalle est de la même façon restreint
+	}
+
+	/* test conditionnant la valeur que la fonction va renvoyer */
+	if (tab[id] == i) return id;  //si on a trouvé la bonne valeur, on retourne l'indice
+	else return -1;  //sinon on retourne -1
+
+}
+
+/**
+ * Fonction permettant de supprimer une case d'un tableau.
+ * @param tab une référence sur un tableau d'entiers
+ * @param i un indice dans tab
+ */
+void suprim_val(Entiers &tab,int i) {
+	tab.erase(tab.begin() + dichotomie(tab,i));
+}
+
+/**
+ * Détermine si une valeur se trouve dans un tableau.
+ * @param tab une référence sur un tableau d'entiers
+ * @param val une valeur
+ * @return true si la valeur a été trouvée, false sinon
+ */
+bool In_tab(const Entiers &tab, int val)
+{
+	for (uint i=0; i < tab.size(); i++)
+		if(tab[i]==val)
+			return true;
+	return false;
+}
+
+bool In_tab_dichotomie(const Entiers &tab, int val)
+{
+	if(dichotomie(tab,val)!=-1)
+		return true;
+	else
+		return false;
+}
+
+
+void Liste_Voisin(const Entiers &P,Entiers &tab,const UnorientedGraph &g)
+{
+	tie(neighbourIt, neighbourEnd) = adjacent_vertices(P.at(P.size()-1), g);
+	for (; neighbourIt != neighbourEnd; ++neighbourIt)
+	{
+		if((In_tab(tab,*neighbourIt) == false ) && (In_tab(P,*neighbourIt) == false ))
+			tab.push_back(*neighbourIt);
+	}
+}
+
+int Cout_coupe(Entiers P,int val, UnorientedGraph &g)
+{
+	int cpt=0;
+	P.push_back(val);
+	for(uint i=0;i<P.size();i++){
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(P[i], g);
+		for (; neighbourIt != neighbourEnd; ++neighbourIt){
+			if(In_tab(P,*neighbourIt)!=1){
+				cpt++;
+			}
+		}
+	}
+	return cpt;
+}
+
+double Cut_one_cluster(const Entiers &cluster, UnorientedGraph &g, std::string name)
+{
+	if(name=="norm"){
+		edge_t e1;
+		bool found;
+		double cpt=0.;
+		for(uint i=0;i<cluster.size();i++){
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster[i], g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				tie(e1,found)=edge(vertex(cluster[i],g),vertex(*neighbourIt,g),g);
+				if(In_tab(cluster,*neighbourIt)!=1){
+					cpt+=g[e1]._weight;
+				}
+			}
+		}
+		double vol = Cluster_Degree(g,cluster);
+		return (cpt/2.)/vol;
+	}
+	else{
+		edge_t e1;
+		bool found;
+		double cpt=0.;
+		for(uint i=0;i<cluster.size();i++){
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i), g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				tie(e1,found)=edge(vertex(cluster.at(i),g),vertex(*neighbourIt,g),g);
+				if(In_tab(cluster,*neighbourIt)!=1){
+					cpt+=g[e1]._weight;
+				}
+			}
+		}
+		return cpt/2.;
+	}
+}
+
+double Cut_cluster(const EntiersEntiers &tab_cluster,UnorientedGraph &g,std::string name)
+{
+	double cpt=0.;
+	for(uint i=0;i<tab_cluster.size();i++){
+		cpt+=Cut_one_cluster(*tab_cluster[i],g,name);
+	}
+	return cpt;
+}
+
+double Cout_coupe_pond(Entiers P, int val, UnorientedGraph &g)
+{
+    edge_t e1;
+    bool found;
+    double cpt=0;
+
+    P.push_back(val);
+    for(uint i=0;i<P.size();i++){
+        tie(neighbourIt, neighbourEnd) = adjacent_vertices(P[i], g);
+        for (; neighbourIt != neighbourEnd; ++neighbourIt){
+            tie(e1,found)=edge(vertex(P[i],g),vertex(*neighbourIt,g),g);
+            if(In_tab(P,*neighbourIt)!=1){
+                cpt+=g[e1]._weight;
+            }
+        }
+    }
+    return cpt;
+}
+
+
+int In_community_dichotomie(const EntiersEntiers &part, int val)
+{
+    for (uint i = 0; i < part.size() ; i++) {
+        if (In_tab_dichotomie(*part[i], val)) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+double Degree(UnorientedGraph& g, int node)
+{
+    edge_t e1;
+    bool found;
+    double val = 0.;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(node, g);
+    for (; neighbourIt != neighbourEnd; ++neighbourIt) {
+        tie(e1, found) = edge(vertex(node, g), vertex(*neighbourIt, g), g);
+        val += g[e1]._weight;
+    }
+    return val;
+}
+
+double Cluster_Degree(UnorientedGraph &g , const Entiers &cluster)
+{
+    double val = 0.;
+
+    for(uint i = 0; i < cluster.size(); i++){
+        val += Degree(g, cluster.at(i));
+    }
+    return val;
+}
+
+void List_edge_partie(Entiers *Partie, OrientedGraph *go, Edges &edge_partie,
+                      OutputEdges &outputedgespartie){
+    edge_to e1;
+    //bool found;
+
+    for(uint i = 0; i < Partie->size(); i++) {
+        tie(neighbourIto, neighbourEndo) = adjacent_vertices(Partie->at(i),
+                                                             *go);
+        for (; neighbourIto != neighbourEndo; ++neighbourIto) {
+            if(In_tab_dichotomie(*Partie,*neighbourIto)) {
+                Edge new_edge;
+
+                new_edge.first = Partie->at(i);
+                new_edge.second = *neighbourIto;
+                edge_partie.push_back(new_edge);
+            } else {
+                Edge new_edge;
+
+                new_edge.first = Partie->at(i);
+                new_edge.second = *neighbourIto;
+                outputedgespartie.push_back(new_edge);
+            }
+        }
+    }
+}
+
+void Global_Neigh_community(UnorientedGraph *g,
+                            const EntiersEntiers &Partition,
+                            Entiers *community, int vertex, int comm_in)
+{
+    int comm;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex, *g);
+    for (; neighbourIt != neighbourEnd; ++neighbourIt){
+        comm = In_community_dichotomie(Partition, *neighbourIt);
+        if (In_tab(*community,comm) != 1 and comm != comm_in)
+            community->push_back(comm);
+    }
+}
+
+OrientedGraphs Graph_Partition(const EntiersEntiers& Partition,
+                               OrientedGraph *go,
+                               UnorientedGraph *g,
+                               OutputEdgeList &outputedgelist,
+                               InputEdgeList &inputedgelist,
+                               Connections &connections)
+{
+    OrientedGraphs graph_partie;
+    EntiersEntiers neigh_community;
+
+    for (uint i = 0; i < Partition.size();i++){
+        Edges edge_partie;
+        List_edge_partie(Partition.at(i),go,edge_partie,outputedgelist.at(i));
+        OrientedGraph graph;
+        std::vector<vertex_to> tab_vertex_to;
+        Entiers *community = new Entiers();
+
+        for (uint j = 0; j < Partition.at(i)->size(); j++) {
+            Global_Neigh_community(g, Partition, community,
+                                   Partition.at(i)->at(j),i);
+            vertex_to v = add_vertex(graph);
+
+            tab_vertex_to.push_back(v);
+            graph[v] = VertexProperties((*go)[Partition.at(i)->at(j)]._index,
+                                        (*go)[Partition.at(i)->at(j)]._weight,
+                                        (*go)[Partition.at(i)->at(j)]._type);
+        }
+        neigh_community.push_back(community);
+
+        for(uint k = 0; k < edge_partie.size(); k++) {
+            add_edge(tab_vertex_to.at(recherche_val(*Partition.at(i),
+                                                    edge_partie.at(k).first)),
+                     tab_vertex_to.at(recherche_val(*Partition.at(i),
+                                                    edge_partie.at(k).second)),
+                     graph);
+        }
+        graph_partie.push_back(graph);
+    }
+
+    for (uint i = 0; i < neigh_community.size(); i++) {
+        InputEdges inputedges;
+
+        for (uint j = 0; j < neigh_community.at(i)->size(); j++) {
+            for (uint k = 0;
+                 k < outputedgelist.at(neigh_community.at(i)->at(j)).size();
+                 k++) {
+                if (In_tab_dichotomie(
+                        *Partition.at(i),
+                        outputedgelist.at(
+                            neigh_community.at(i)->at(j)).at(k).second))
+                    inputedges.push_back(
+                        outputedgelist.at(
+                            neigh_community.at(i)->at(j)).at(k));
+            }
+        }
+        inputedgelist.push_back(inputedges);
+    }
+
+    for (uint i = 0; i < outputedgelist.size(); i++){
+        Connection connec;
+
+        for(uint j = 0; j < outputedgelist.at(i).size(); j++){
+            Port port1;
+
+            port1.first = i + 1;
+            port1.second = outputedgelist.at(i).at(j).first;
+
+            Port port2;
+
+            port2.first = In_community_dichotomie(
+                Partition,outputedgelist.at(i).at(j).second) + 1;
+            port2.second = outputedgelist.at(i).at(j).second;
+
+            connec.first = port1;
+            connec.second = port2;
+
+            connections.push_back(connec);
+        }
+    }
+
+    for (EntiersEntiers::iterator it = neigh_community.begin();
+        it != neigh_community.end(); it++) {
+        delete *it;
+        *it = NULL;
+    }
+
+    return graph_partie;
+}
+
+/*double In_modularity(UnorientedGraph &g , const Entiers &cluster){
+	property_map<UnorientedGraph,edge_weight_t>::type poids_arc=get(edge_weight_t(),g);
+	edge_t e1;
+	bool found;
+	int val=0;
+
+	for(uint i=0;i<cluster.size();i++){
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster[i],g);
+		for (; neighbourIt != neighbourEnd; ++neighbourIt){
+			tie(e1,found)=edge(vertex(cluster[i],g),vertex(*neighbourIt,g),g);
+			if(In_tab(cluster,*neighbourIt)==1)
+				val+=get(poids_arc,e1);
+		}
+	}
+	return val/2.;
+}*/
+
+/**
+ *
+ * @param g
+ * @param cluster
+ * @return
+ */
+
+
+
+/**
+ *
+ * @param g
+ * @param part
+ * @return
+ */
+
+/*double Modularity(UnorientedGraph &g,const EntiersEntiers &part) {
+  double q  = 0.;
+  int tmp=num_edges(g);
+  for(uint i=0;i<part.size();i++){
+	  q+=In_modularity(g,*part[i])/tmp-(Cluster_Degree(g,*part[i])/(2*tmp))*(Cluster_Degree(g,*part[i])/(2*tmp));
+  	}
+
+  return q;
+}*/
+
+/**
+ *
+ * @param part
+ * @param val
+ * @return
+ */
+
+
+
+/**
+ * Fonction de calcul du gain de modularité de déplacement d'un sommet d'une communoté à une autre !!!!!
+ *  ajoute le sommet à part[val] et on calcul la nouvelle modularité
+ *  on prend la différence entre la modularité et la nouvouvelle !
+ * @param cur_mod
+ * @param val
+ * @param neight
+ * @param node_comm
+ * @param part
+ * @param g
+ */
+/*double Modularity_gain(double cur_mod , int val , int neight , int node_comm , EntiersEntiers part , UnorientedGraph &g) {
+	double q;
+	part[neight]->push_back(val);
+	std::sort(*part[neight]);
+	q=Modularity(g,part);
+
+	return q-cur_mod;
+}*/
+
+/**
+ * Fonction de calcul du gain de modularité de déplacement d'un sommet d'une communoté à une autre !!!!!
+ *  ajoute le sommet à part[val] et on calcul la nouvelle modularité
+ *  on prend la différence entre la modularité et la nouvouvelle !
+ * @param cur_mod
+ * @param tmp_community
+ * @param neight
+ * @param node_comm
+ * @param part
+ * @param g
+ */
+/*double Modularity_gain_phase_2(double cur_mod, Entiers tmp_community, int neight, int node_comm, EntiersEntiers part, UnorientedGraph &g) {
+	double q;
+	for (uint i=0;i<tmp_community.size();i++)
+		part[neight]->push_back(tmp_community[i]);
+	std::sort(*part[neight]);
+	q = Modularity(g,part);
+	return q - cur_mod;
+}*/
+
+/**
+ * Donne la liste des communautés voisines à celle contenant le sommet val.
+ * @param part
+ * @param val
+ * @param g
+ * @return
+ */
+/*Entiers Neight_community(const EntiersEntiers &part, int val , UnorientedGraph &g){
+	Entiers Neight;
+	tie(neighbourIt, neighbourEnd) = adjacent_vertices(val, g);
+	for (; neighbourIt != neighbourEnd; ++neighbourIt){
+		int tmp=In_community(part,*neighbourIt);
+		if(In_tab(Neight,tmp)!=1 && In_tab(*part[In_community(part,val)],*neighbourIt)!=1)
+			Neight.push_back(tmp);
+	}
+	std::sort(Neight);
+	return Neight;
+}*/
+
+/**
+ *
+ * @param part
+ * @param community
+ * @param g
+ * @return
+ */
+/*Entiers Part_Neight_community(const EntiersEntiers &part,int community, UnorientedGraph &g){
+	Entiers Neight;
+	for(uint i =0;i<part[community]->size();i++){
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(part[community]->at(i), g);
+		for (; neighbourIt != neighbourEnd; ++neighbourIt){
+			int tmp=In_community(part,*neighbourIt);
+			if(In_tab(Neight,tmp)!=1 && tmp!=community)
+				Neight.push_back(tmp);
+		}
+	}
+	std::sort(Neight);
+	return Neight;
+}*/
+
+void make_unoriented_graph(const OrientedGraph& og, UnorientedGraph& ug)
+{
+    std::vector < vertex_t > ug_vertex_list;
+    std::vector < vertex_t > og_vertex_list;
+
+    for (uint i = 0; i < num_vertices(og); ++i) {
+        ug_vertex_list.push_back(add_vertex(ug));
+    }
+
+    OrientedGraph::vertex_iterator it_og, end_og;
+    UnorientedGraph::vertex_iterator it_ug, end_ug;
+
+    tie(it_og, end_og) = vertices(og);
+    tie(it_ug, end_ug) = vertices(ug);
+    for (; it_og != end_og; ++it_og, ++it_ug) {
+        ug[*it_ug] = og[*it_og];
+        og_vertex_list.push_back(*it_og);
+    }
+
+    OrientedGraph::edge_iterator ite_og, ende_og;
+
+    tie(ite_og, ende_og) = edges(og);
+    for (; ite_og != ende_og; ++ite_og) {
+        boost::add_edge(source(*ite_og, og), target(*ite_og, og),
+                        og[*ite_og], ug);
+    }
+
+    // std::cout << "Oriented graph: " << std::endl;
+    // tie(it_og, end_og) = vertices(og);
+    // for (; it_og != end_og; ++it_og) {
+    //     OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
+
+    //     std::cout << og[*it_og]._index << " is connected with ";
+    //     tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_og, og);
+    //     for (; neighbour_it != neighbour_end; ++neighbour_it)
+    //         std::cout << og[*neighbour_it]._index << " ";
+    //     std::cout << " and weight = " << og[*it_og]._weight << std::endl;
+    // }
+    // std::cout << std::endl;
+
+    // std::cout << "Unoriented graph: " << std::endl;
+    // tie(it_ug, end_ug) = vertices(ug);
+    // for (; it_ug != end_ug; ++it_ug) {
+    //     UnorientedGraph::adjacency_iterator neighbour_it, neighbour_end;
+
+    //     std::cout << ug[*it_ug]._index << " is connected with ";
+    //     tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_ug, ug);
+    //     for (; neighbour_it != neighbour_end; ++neighbour_it)
+    //         std::cout << ug[*neighbour_it]._index << " ";
+    //     std::cout << " and weight = " << ug[*it_ug]._weight << std::endl;
+    // }
+    // std::cout << std::endl;
+}
+
+void adjacence_ggp(int vertex, Entiers &sommets_adj, UnorientedGraph *g)
+{
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex, *g);
+    for (; neighbourIt != neighbourEnd; ++neighbourIt)
+    {
+        sommets_adj.push_back(*neighbourIt);
+    }
+
+}
+
+float modif_Cout_coupe(const Entiers &P, int val, float cut, UnorientedGraph *g)
+{
+    //std::cout<<"Cout de coupe initiale : "<<cut<<std::endl;
+    //std::cout<<"degré du sommet tiré : "<<Degree(*g,val)<<std::endl;
+    double cpt=0;
+    float new_cut;
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(val, *g);
+    for (; neighbourIt != neighbourEnd; neighbourIt++){
+        if(In_tab(P,*neighbourIt)==1){
+            cpt++;
+        }
+    }
+    new_cut = cut + (Degree(*g,val) - (2 * cpt));
+    return new_cut;
+}
+
+
+} } } // namespace paradevs tests boost_graph

+ 114 - 0
src/tests/boost_graph/partitioning/utils.hpp

@@ -0,0 +1,114 @@
+/**
+ * @file tests/boost_graph/partitioning/utils.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_BOOST_GRAPH_PARTITIONING_UTILS_H
+#define TESTS_BOOST_GRAPH_PARTITIONING_UTILS_H 1
+
+#include <tests/boost_graph/partitioning/defs.hpp>
+
+namespace paradevs { namespace tests { namespace boost_graph {
+
+void Global_Neigh_community(UnorientedGraph *g,
+                            const EntiersEntiers &Partition,
+                            Entiers *community, int vertex, int comm_in);
+
+OrientedGraphs Graph_Partition(const EntiersEntiers &Partition,
+                               OrientedGraph *go,
+                               UnorientedGraph *g,
+                               OutputEdgeList &outputedgelist,
+                               InputEdgeList &inputedgelist,
+                               Connections &connections);
+
+void List_edge_partie(Entiers *Partie, OrientedGraph *go, Edges &edge_partie,
+                      OutputEdges &outputedgespartie);
+
+void construire_graph(UnorientedGraph *g, OrientedGraph *graph);
+
+double Modif_Cut_one_cluster(Entiers &cluster, UnorientedGraph &g, double &vol);
+
+std::vector<double> modif_cut_tmp(UnorientedGraph *g, EntiersEntiers &Partition,
+                             std::vector<std::vector<double> > tabe_cut,
+                                  int vertexs,
+                             int comm_in, Entiers community, double cut,
+                             std::string name);
+
+double Calcul_poids(Entiers *partie, UnorientedGraph *g);
+
+bool Est_connexe(UnorientedGraph *g, EntiersEntiers Partition, Entiers &part);
+
+void Affinage_equilibrage_charge(UnorientedGraph *g, EntiersEntiers &Partition);
+
+Entiers Neigh_community(UnorientedGraph *g, EntiersEntiers &Partition,
+                        int vertex, int comm_in);
+
+void Modif_fonction_Gain_Cut(EntiersEntiers &Partition,UnorientedGraph *g,
+                             Entiers &community, int val, double &cut,
+                             std::string name);
+
+void Affinage_recherche_locale(UnorientedGraph *g, EntiersEntiers &Partition,
+                               double &cut, std::string name);
+
+void projection(EntiersEntiers &Partition,ListEntiersEntiers::iterator lit);
+
+bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg,
+                     ListEntiersEntiers &liste_corr, int val_reduc,
+                     int &val_cpt);
+bool contraction_Random_Maching(UnorientedGraph *g, Base_Graph &baseg,
+                                ListEntiersEntiers &liste_corr, int val_reduc,
+                                int &val_cpt);
+
+Entiers Liste_adjacence(UnorientedGraph &g, int vertexs,
+                        const Entiers &random_vertices);
+
+int rand_fini(int a, int b);
+int recherche_val2(const std::vector<float> &tab,float val);
+int recherche_val_double(const std::vector<double> &tab,double val);
+int recherche_val(const std::vector<int> &tab,int val);
+int dichotomie(const Entiers &tab,int i);
+void suprim_val(Entiers &tab,int i);
+bool In_tab(const Entiers &tab, int val);
+bool In_tab_dichotomie(const Entiers &tab, int val);
+double Cut_cluster(const EntiersEntiers &tab_cluster,UnorientedGraph &g,
+                   std::string name);
+void Modif_fonction_Gain_Cut(EntiersEntiers &Partition,UnorientedGraph *g,
+                             int community_out,int community_in,int val,
+                             double &cut);
+void Liste_Voisin(const Entiers &P,Entiers &tab,const UnorientedGraph &g);
+int Cout_coupe(Entiers P,int val, UnorientedGraph &g);
+double Cout_coupe_pond(Entiers P,int val, UnorientedGraph &g);
+int In_community_dichotomie(const EntiersEntiers &part, int val);
+double Degree(UnorientedGraph &g , int node);
+double Cluster_Degree(UnorientedGraph &g , const Entiers &cluster);
+
+void make_unoriented_graph(const OrientedGraph& og, UnorientedGraph& uog);
+
+void adjacence_ggp(int vertex, Entiers &sommets_adj, UnorientedGraph *g);
+
+float modif_Cout_coupe(const Entiers &P, int val, float cut, UnorientedGraph *g);
+
+} } } // namespace paradevs tests boost_graph
+
+#endif

+ 378 - 0
src/tests/boost_graph/tests.cpp

@@ -0,0 +1,378 @@
+/**
+ * @file tests/boost_graph/tests.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <boost/timer.hpp>
+
+#include <paradevs/common/RootCoordinator.hpp>
+
+#include <tests/boost_graph/models.hpp>
+#include <tests/boost_graph/graph_builder.hpp>
+#include <tests/boost_graph/graph_manager.hpp>
+#include <tests/boost_graph/graph_partitioning.hpp>
+
+using namespace paradevs::common;
+using namespace paradevs::common::scheduler;
+using namespace paradevs::pdevs;
+using namespace paradevs::tests::boost_graph;
+
+template < class GraphBuilder >
+void flat_heap_test(double duration)
+{
+    RootCoordinator <
+        DoubleTime,
+        paradevs::pdevs::Coordinator <
+            DoubleTime,
+            SchedulerType,
+            SchedulerHandle,
+            InBuildFlatGraphManager <
+                SchedulerHandle,
+                GraphBuilder >,
+            paradevs::common::NoParameters,
+            paradevs::common::NoParameters >
+    > rc(0, duration, "root", NoParameters(), NoParameters());
+
+    rc.run();
+}
+
+template < class GraphBuilder >
+void flat_vector_test(double duration)
+{
+    RootCoordinator <
+        DoubleTime,
+        paradevs::pdevs::Coordinator <
+            DoubleTime,
+            paradevs::common::scheduler::VectorScheduler <
+                paradevs::common::DoubleTime >,
+            paradevs::common::scheduler::NoSchedulerHandle,
+            InBuildFlatGraphManager <
+                paradevs::common::scheduler::NoSchedulerHandle,
+                GraphBuilder >,
+            paradevs::common::NoParameters,
+            paradevs::common::NoParameters >
+    > rc(0, duration, "root", NoParameters(), NoParameters());
+
+    rc.run();
+}
+
+void hierarchical_test()
+{
+    // RootCoordinator <
+    //     DoubleTime,
+    //     paradevs::pdevs::Coordinator <
+    //         DoubleTime,
+    //         SchedulerType,
+    //         SchedulerHandle,
+    //         HierarchicalGraphManager <
+    //             SchedulerHandle,
+    //             HierarchicalGraphBuilder >,
+    //         paradevs::common::NoParameters,
+    //         paradevs::common::NoParameters >
+    //     > rc(0, 100, "root", NoParameters(), NoParameters());
+
+    // rc.run();
+}
+
+void parallel_partitionning_heap_test(double duration,
+                                      int cluster_number,
+                                      std::string partitioning_method_name,
+                                      int contraction_coef,
+                                      bool contraction_coef_flag)
+{
+    RootCoordinator <
+        DoubleTime,
+        paradevs::pdevs::multithreading::Coordinator <
+            DoubleTime,
+            SchedulerType,
+            SchedulerHandle,
+            ParallelHeapHierarchicalGraphManager <
+                SchedulerHandle,
+                PartitioningGraphBuilder >,
+            paradevs::common::NoParameters,
+            PartitioningParameters >
+        > rc(0, duration, "root", NoParameters(),
+             PartitioningParameters(cluster_number, partitioning_method_name,
+                                    contraction_coef, contraction_coef_flag));
+
+    rc.run();
+}
+
+void partitionning_heap_test(double duration,
+                             int cluster_number,
+                             std::string partitioning_method_name,
+                             int contraction_coef,
+                             bool contraction_coef_flag)
+{
+    RootCoordinator <
+        DoubleTime,
+        paradevs::pdevs::Coordinator <
+            DoubleTime,
+            SchedulerType,
+            SchedulerHandle,
+            HeapHierarchicalGraphManager <
+                SchedulerHandle,
+                PartitioningGraphBuilder >,
+            paradevs::common::NoParameters,
+            PartitioningParameters >
+        > rc(0, duration, "root", NoParameters(),
+             PartitioningParameters(cluster_number, partitioning_method_name,
+                                    contraction_coef, contraction_coef_flag));
+
+    rc.run();
+}
+
+void partitionning_vector_test(double duration,
+                               int cluster_number,
+                               std::string partitioning_method_name,
+                               int contraction_coef,
+                               bool contraction_coef_flag)
+{
+    RootCoordinator <
+        DoubleTime,
+        paradevs::pdevs::Coordinator <
+            DoubleTime,
+            paradevs::common::scheduler::VectorScheduler <
+                paradevs::common::DoubleTime >,
+            paradevs::common::scheduler::NoSchedulerHandle,
+            VectorHierarchicalGraphManager <
+                paradevs::common::scheduler::NoSchedulerHandle,
+                PartitioningGraphBuilder >,
+            paradevs::common::NoParameters,
+            PartitioningParameters >
+        > rc(0, duration, "root", NoParameters(),
+             PartitioningParameters(cluster_number, partitioning_method_name,
+                                    contraction_coef, contraction_coef_flag));
+
+    rc.run();
+}
+
+void test(double duration, std::string partitioning_method_name,
+          unsigned int min, unsigned int max, unsigned int step,
+          bool vector, bool heap,
+          int contraction_coef,
+          bool contraction_coef_flag)
+{
+    boost::timer t;
+
+    std::cout << "==== " << partitioning_method_name << " with ";
+    if (contraction_coef_flag) {
+        std::cout << "/";
+    }
+    std::cout << contraction_coef << " ===" << std::endl;
+    std::cout << "n";
+    if (heap) {
+        std::cout << "\t heap";
+    }
+    if (vector) {
+        std::cout << "\t vector";
+    }
+    std::cout << std::endl;
+
+    if (contraction_coef_flag) {
+        for (unsigned int n = min; n <= max; n += step) {
+            std::cout << n << "\t";
+            if (heap) {
+                double t1 = t.elapsed();
+
+                for (unsigned int i = 0; i < 20; ++i) {
+                    partitionning_heap_test(duration, n,
+                                            partitioning_method_name,
+                                            contraction_coef,
+                                            contraction_coef_flag);
+                }
+
+                double t2 = t.elapsed();
+
+                std::cout << (t2 - t1) / 20 << "\t";
+            }
+            if (vector) {
+                double t1 = t.elapsed();
+
+                for (unsigned int i = 0; i < 20; ++i) {
+                    partitionning_vector_test(duration, n,
+                                              partitioning_method_name,
+                                              contraction_coef,
+                                              contraction_coef_flag);
+                }
+
+                double t2 = t.elapsed();
+
+                std::cout << (t2 - t1) / 20 << std::endl;
+            } else {
+                std::cout << std::endl;
+            }
+
+        }
+    } else {
+        std::cout << contraction_coef << "\t";
+        if (heap) {
+            double t1 = t.elapsed();
+
+            for (unsigned int i = 0; i < 20; ++i) {
+                partitionning_heap_test(duration, contraction_coef,
+                                        partitioning_method_name,
+                                        contraction_coef,
+                                        contraction_coef_flag);
+            }
+
+            double t2 = t.elapsed();
+
+            std::cout << (t2 - t1) / 20 << "\t";
+        }
+        if (vector) {
+            double t1 = t.elapsed();
+
+            for (unsigned int i = 0; i < 20; ++i) {
+                partitionning_vector_test(duration, contraction_coef,
+                                          partitioning_method_name,
+                                          contraction_coef,
+                                          contraction_coef_flag);
+                }
+
+            double t2 = t.elapsed();
+
+            std::cout << (t2 - t1) / 20 << std::endl;
+        } else {
+            std::cout << std::endl;
+        }
+    }
+}
+
+void test_flat_38()
+{
+    boost::timer t;
+
+    std::cout << "== 38 nodes ==" << std::endl;
+    std::cout << "flat graph with heap = ";
+    for (unsigned int i = 0; i < 20; ++i) {
+        flat_heap_test< FlatGraphBuilder >(10000);
+    }
+
+    double t2 = t.elapsed();
+
+    std::cout << t2 / 20 << std::endl;
+
+    std::cout << "flat graph with vector = ";
+    for (unsigned int i = 0; i < 20; ++i) {
+        flat_vector_test< FlatGraphBuilder >(10000);
+    }
+
+    double t3 = t.elapsed();
+
+    std::cout << (t3 - t2) / 20 << std::endl;
+}
+
+const double duration_38 = -1;
+
+void test_partiotining_38()
+{
+    for (int i = 1; i <= 2; ++i) {
+        test(duration_38, "ggp", 2, 16, 2, true, true, i, true);
+        test(duration_38, "gggp_pond", 2, 16, 2, true, true, i, true);
+        test(duration_38, "random", 2, 16, 2, true, true, i, true);
+    }
+
+    for (int i = 2; i <= 8; i += 2) {
+        test(duration_38, "gggp_pond", 0, 0, 0, true, true, i, false);
+    }
+}
+
+const double corsen_duration = 20;
+
+void test_flat_corsen()
+{
+    boost::timer t;
+
+    std::cout << "== CORSEN == " << std::endl;
+    std::cout << "flat graph with heap = ";
+    for (unsigned int i = 0; i < 20; ++i) {
+        flat_heap_test< CorsenFlatGraphBuilder >(corsen_duration);
+    }
+
+    double t2 = t.elapsed();
+
+    std::cout << t2 / 20 << std::endl;
+
+    // std::cout << "flat graph with vector = ";
+    // for (unsigned int i = 0; i < 20; ++i) {
+    //     flat_vector_test< CorsenFlatGraphBuilder >(corsen_duration);
+    // }
+
+    // double t3 = t.elapsed();
+
+    // std::cout << (t3 - t2) / 20 << std::endl;
+}
+
+void test_partitioning_corsen()
+{
+    test(corsen_duration, "gggp_pond", 2, 32, 2, false, true, 10, true);
+    test(corsen_duration, "gggp_pond", 2, 32, 2, false, true, 20, true);
+    test(corsen_duration, "gggp_pond", 2, 32, 2, false, true, 40, true);
+    test(corsen_duration, "gggp_pond", 2, 32, 2, false, true, 80, true);
+    test(corsen_duration, "gggp_pond", 2, 22, 2, false, true, 200, true);
+
+    test(corsen_duration, "gggp_pond", 2, 32, 2, false, true, 30, false);
+    test(corsen_duration, "gggp_pond", 2, 32, 2, false, true, 40, false);
+    test(corsen_duration, "gggp_pond", 2, 32, 2, false, true, 50, false);
+    test(corsen_duration, "gggp_pond", 2, 32, 2, false, true, 60, false);
+    test(corsen_duration, "gggp_pond", 2, 32, 2, false, true, 70, false);
+    test(corsen_duration, "gggp_pond", 2, 32, 2, false, true, 80, false);
+    test(corsen_duration, "gggp_pond", 2, 32, 2, false, true, 90, false);
+    test(corsen_duration, "gggp_pond", 2, 32, 2, false, true, 100, false);
+
+    test(corsen_duration, "ggp", 2, 32, 2, false, true, 10, true);
+    test(corsen_duration, "ggp", 2, 32, 2, false, true, 20, true);
+    test(corsen_duration, "ggp", 2, 32, 2, false, true, 40, true);
+    test(corsen_duration, "ggp", 2, 32, 2, false, true, 80, true);
+    test(corsen_duration, "ggp", 2, 22, 2, false, true, 200, true);
+
+    test(corsen_duration, "ggp", 2, 32, 2, false, true, 30, false);
+    test(corsen_duration, "ggp", 2, 32, 2, false, true, 40, false);
+    test(corsen_duration, "ggp", 2, 32, 2, false, true, 50, false);
+    test(corsen_duration, "ggp", 2, 32, 2, false, true, 60, false);
+    test(corsen_duration, "ggp", 2, 32, 2, false, true, 70, false);
+    test(corsen_duration, "ggp", 2, 32, 2, false, true, 80, false);
+    test(corsen_duration, "ggp", 2, 32, 2, false, true, 90, false);
+    test(corsen_duration, "ggp", 2, 32, 2, false, true, 100, false);
+
+    test(corsen_duration, "random", 2, 32, 2, false, true, 10, true);
+    test(corsen_duration, "random", 2, 32, 2, false, true, 20, true);
+    test(corsen_duration, "random", 2, 32, 2, false, true, 40, true);
+    test(corsen_duration, "random", 2, 32, 2, false, true, 80, true);
+    test(corsen_duration, "random", 2, 22, 2, false, true, 200, true);
+}
+
+int main()
+{
+    srand(7262);
+
+    // test_flat_38();
+    // test_partiotining_38();
+
+    test_flat_corsen();
+    test_partitioning_corsen();
+
+    return 0;
+}

+ 6446 - 0
src/tests/catch.hpp

@@ -0,0 +1,6446 @@
+/*
+ *  Generated: 2013-02-19 08:44:57.311773
+ *  ----------------------------------------------------------
+ *  This file has been merged from multiple headers. Please don't edit it directly
+ *  Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
+ *
+ *  Distributed under the Boost Software License, Version 1.0. (See accompanying
+ *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
+#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
+
+#define TWOBLUECUBES_CATCH_HPP_INCLUDED
+
+#ifdef __clang__
+#pragma clang diagnostic ignored "-Wglobal-constructors"
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpadded"
+#endif
+
+// #included from: internal/catch_notimplemented_exception.h
+#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED
+
+// #included from: catch_common.h
+#define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
+
+#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
+#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
+#define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
+
+#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
+#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
+
+#ifdef __GNUC__
+#define CATCH_ATTRIBUTE_NORETURN __attribute__ ((noreturn))
+#else
+#define CATCH_ATTRIBUTE_NORETURN
+#endif
+
+#include <sstream>
+#include <stdexcept>
+#include <algorithm>
+
+namespace Catch {
+
+	class NonCopyable {
+		NonCopyable( const NonCopyable& );
+		void operator = ( const NonCopyable& );
+	protected:
+		NonCopyable() {}
+		virtual ~NonCopyable();
+	};
+
+    class SafeBool {
+    public:
+        typedef void (SafeBool::*type)() const;
+
+        static type makeSafe( bool value ) {
+            return value ? &SafeBool::trueValue : 0;
+        }
+    private:
+        void trueValue() const {}
+    };
+
+    template<typename ContainerT>
+    inline void deleteAll( ContainerT& container ) {
+        typename ContainerT::const_iterator it = container.begin();
+        typename ContainerT::const_iterator itEnd = container.end();
+        for(; it != itEnd; ++it )
+        {
+            delete *it;
+        }
+    }
+    template<typename AssociativeContainerT>
+    inline void deleteAllValues( AssociativeContainerT& container ) {
+        typename AssociativeContainerT::const_iterator it = container.begin();
+        typename AssociativeContainerT::const_iterator itEnd = container.end();
+        for(; it != itEnd; ++it )
+        {
+            delete it->second;
+        }
+    }
+
+    template<typename ContainerT, typename Function>
+    inline void forEach( ContainerT& container, Function function ) {
+        std::for_each( container.begin(), container.end(), function );
+    }
+
+    template<typename ContainerT, typename Function>
+    inline void forEach( const ContainerT& container, Function function ) {
+        std::for_each( container.begin(), container.end(), function );
+    }
+
+    inline bool startsWith( const std::string& s, const std::string& prefix ) {
+        return s.size() >= prefix.size() && s.substr( 0, prefix.size() ) == prefix;
+    }
+    inline bool endsWith( const std::string& s, const std::string& suffix ) {
+        return s.size() >= suffix.size() && s.substr( s.size()-suffix.size(), suffix.size() ) == suffix;
+    }
+    inline bool contains( const std::string& s, const std::string& infix ) {
+        return s.find( infix ) != std::string::npos;
+    }
+
+    struct pluralise {
+        pluralise( std::size_t count, const std::string& label )
+        :   m_count( count ),
+            m_label( label )
+        {}
+
+        friend std::ostream& operator << ( std::ostream& os, const pluralise& pluraliser ) {
+            os << pluraliser.m_count << " " << pluraliser.m_label;
+            if( pluraliser.m_count != 1 )
+                os << "s";
+            return os;
+        }
+
+        std::size_t m_count;
+        std::string m_label;
+    };
+
+    struct SourceLineInfo {
+
+        SourceLineInfo() : line( 0 ){}
+        SourceLineInfo( const std::string& _file, std::size_t _line )
+        :   file( _file ),
+            line( _line )
+        {}
+        SourceLineInfo( const SourceLineInfo& other )
+        :   file( other.file ),
+            line( other.line )
+        {}
+        bool empty() const {
+            return file.empty();
+        }
+
+        std::string file;
+        std::size_t line;
+    };
+
+    inline std::ostream& operator << ( std::ostream& os, const SourceLineInfo& info ) {
+#ifndef __GNUG__
+        os << info.file << "(" << info.line << "): ";
+#else
+        os << info.file << ":" << info.line << ": ";
+#endif
+        return os;
+    }
+
+    CATCH_ATTRIBUTE_NORETURN
+    inline void throwLogicError( const std::string& message, const SourceLineInfo& locationInfo ) {
+        std::ostringstream oss;
+        oss << "Internal Catch error: '" << message << "' at: " << locationInfo;
+        throw std::logic_error( oss.str() );
+    }
+}
+
+#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
+#define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO );
+
+#include <ostream>
+
+namespace Catch {
+
+    class NotImplementedException : public std::exception
+    {
+    public:
+        NotImplementedException( const SourceLineInfo& lineInfo );
+
+        virtual ~NotImplementedException() throw() {}
+
+        virtual const char* what() const throw();
+
+    private:
+        std::string m_what;
+        SourceLineInfo m_lineInfo;
+    };
+
+} // end namespace Catch
+
+///////////////////////////////////////////////////////////////////////////////
+#define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException( CATCH_INTERNAL_LINEINFO )
+
+// #included from: internal/catch_context.h
+#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
+
+// #included from: catch_interfaces_generators.h
+#define TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED
+
+#include <string>
+
+namespace Catch {
+
+    struct IGeneratorInfo {
+        virtual ~IGeneratorInfo();
+        virtual bool moveNext() = 0;
+        virtual std::size_t getCurrentIndex() const = 0;
+    };
+
+    struct IGeneratorsForTest {
+        virtual ~IGeneratorsForTest();
+
+        virtual IGeneratorInfo& getGeneratorInfo( const std::string& fileInfo, std::size_t size ) = 0;
+        virtual bool moveNext() = 0;
+    };
+
+    IGeneratorsForTest* createGeneratorsForTest();
+
+} // end namespace Catch
+
+#include <memory>
+#include <vector>
+#include <stdlib.h>
+
+namespace Catch {
+
+    class TestCaseInfo;
+    class Stream;
+    struct IResultCapture;
+    struct IRunner;
+    struct IGeneratorsForTest;
+    struct IConfig;
+
+    struct IContext
+    {
+        virtual ~IContext();
+
+        virtual IResultCapture& getResultCapture() = 0;
+        virtual IRunner& getRunner() = 0;
+        virtual size_t getGeneratorIndex( const std::string& fileInfo, size_t totalSize ) = 0;
+        virtual bool advanceGeneratorsForCurrentTest() = 0;
+        virtual const IConfig* getConfig() const = 0;
+    };
+
+    struct IMutableContext : IContext
+    {
+        virtual ~IMutableContext();
+        virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
+        virtual void setRunner( IRunner* runner ) = 0;
+        virtual void setConfig( const IConfig* config ) = 0;
+    };
+
+    IContext& getCurrentContext();
+    IMutableContext& getCurrentMutableContext();
+    void cleanUpContext();
+    Stream createStream( const std::string& streamName );
+
+}
+
+// #included from: internal/catch_test_registry.hpp
+#define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
+
+// #included from: catch_interfaces_testcase.h
+#define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
+
+// #included from: catch_ptr.hpp
+#define TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED
+
+namespace Catch {
+
+    // An intrusive reference counting smart pointer.
+    // T must implement addRef() and release() methods
+    // typically implementing the IShared interface
+    template<typename T>
+    class Ptr {
+    public:
+        Ptr() : m_p( NULL ){}
+        Ptr( T* p ) : m_p( p ){
+            if( m_p )
+                m_p->addRef();
+        }
+        Ptr( const Ptr& other ) : m_p( other.m_p ){
+            if( m_p )
+                m_p->addRef();
+        }
+        ~Ptr(){
+            if( m_p )
+                m_p->release();
+        }
+        Ptr& operator = ( T* p ){
+            Ptr temp( p );
+            swap( temp );
+            return *this;
+        }
+        Ptr& operator = ( const Ptr& other ){
+            Ptr temp( other );
+            swap( temp );
+            return *this;
+        }
+        void swap( Ptr& other ){
+            std::swap( m_p, other.m_p );
+        }
+
+        T* get(){
+            return m_p;
+        }
+        const T* get() const{
+            return m_p;
+        }
+
+        T& operator*() const {
+            return *m_p;
+        }
+
+        T* operator->() const {
+            return m_p;
+        }
+
+        bool operator !() const {
+            return m_p == NULL;
+        }
+
+    private:
+        T* m_p;
+    };
+
+    struct IShared : NonCopyable {
+        virtual ~IShared();
+        virtual void addRef() = 0;
+        virtual void release() = 0;
+    };
+
+    template<typename T>
+    struct SharedImpl : T {
+
+        SharedImpl() : m_rc( 0 ){}
+
+        virtual void addRef(){
+            ++m_rc;
+        }
+        virtual void release(){
+            if( --m_rc == 0 )
+                delete this;
+        }
+
+        int m_rc;
+    };
+
+} // end namespace Catch
+
+#include <vector>
+
+namespace Catch {
+
+    class TestCaseFilters;
+
+    struct ITestCase : IShared {
+        virtual void invoke () const = 0;
+    protected:
+        virtual ~ITestCase();
+    };
+
+    class TestCaseInfo;
+
+    struct ITestCaseRegistry {
+        virtual ~ITestCaseRegistry();
+        virtual const std::vector<TestCaseInfo>& getAllTests() const = 0;
+        virtual std::vector<TestCaseInfo> getMatchingTestCases( const std::string& rawTestSpec ) const = 0;
+    };
+}
+
+namespace Catch {
+
+template<typename C>
+class MethodTestCase : public SharedImpl<ITestCase> {
+
+public:
+    MethodTestCase( void (C::*method)() ) : m_method( method ) {}
+
+    virtual void invoke() const {
+        C obj;
+        (obj.*m_method)();
+    }
+
+private:
+    virtual ~MethodTestCase() {}
+
+    void (C::*m_method)();
+};
+
+typedef void(*TestFunction)();
+
+struct AutoReg {
+
+    AutoReg(    TestFunction function,
+                const char* name,
+                const char* description,
+                const SourceLineInfo& lineInfo );
+
+    template<typename C>
+    AutoReg(    void (C::*method)(),
+                const char* className,
+                const char* name,
+                const char* description,
+                const SourceLineInfo& lineInfo ) {
+        registerTestCase( new MethodTestCase<C>( method ), className, name, description, lineInfo );
+    }
+
+    void registerTestCase(  ITestCase* testCase,
+                            const char* className,
+                            const char* name,
+                            const char* description,
+                            const SourceLineInfo& lineInfo );
+
+    ~AutoReg();
+
+private:
+    AutoReg( const AutoReg& );
+    void operator= ( const AutoReg& );
+};
+
+} // end namespace Catch
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
+    static void INTERNAL_CATCH_UNIQUE_NAME( TestCaseFunction_catch_internal_ )(); \
+    namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME(  TestCaseFunction_catch_internal_ ), Name, Desc, CATCH_INTERNAL_LINEINFO ); }\
+    static void INTERNAL_CATCH_UNIQUE_NAME(  TestCaseFunction_catch_internal_ )()
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_TESTCASE_NORETURN( Name, Desc ) \
+    static void INTERNAL_CATCH_UNIQUE_NAME( TestCaseFunction_catch_internal_ )() CATCH_ATTRIBUTE_NORETURN; \
+    namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME(  TestCaseFunction_catch_internal_ ), Name, Desc, CATCH_INTERNAL_LINEINFO ); }\
+    static void INTERNAL_CATCH_UNIQUE_NAME(  TestCaseFunction_catch_internal_ )()
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
+    namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Name, Desc, CATCH_INTERNAL_LINEINFO ); }
+
+///////////////////////////////////////////////////////////////////////////////
+#define TEST_CASE_METHOD( ClassName, TestName, Desc )\
+    namespace{ \
+        struct INTERNAL_CATCH_UNIQUE_NAME( TestCaseMethod_catch_internal_ ) : ClassName{ \
+            void test(); \
+        }; \
+        Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( TestCaseMethod_catch_internal_ )::test, #ClassName, TestName, Desc, CATCH_INTERNAL_LINEINFO ); \
+    } \
+    void INTERNAL_CATCH_UNIQUE_NAME( TestCaseMethod_catch_internal_ )::test()
+
+// #included from: internal/catch_capture.hpp
+#define TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED
+
+// #included from: catch_expression_decomposer.hpp
+#define TWOBLUECUBES_CATCH_EXPRESSION_DECOMPOSER_HPP_INCLUDED
+
+// #included from: catch_expression_lhs.hpp
+#define TWOBLUECUBES_CATCH_EXPRESSION_LHS_HPP_INCLUDED
+
+// #included from: catch_expressionresult_builder.h
+#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_H_INCLUDED
+
+// #included from: catch_tostring.hpp
+#define TWOBLUECUBES_CATCH_TOSTRING_HPP_INCLUDED
+
+#include <sstream>
+
+#ifdef __OBJC__
+// #included from: catch_objc_arc.hpp
+#define TWOBLUECUBES_CATCH_OBJC_ARC_HPP_INCLUDED
+
+#import <Foundation/Foundation.h>
+
+#ifdef __has_feature
+#define CATCH_ARC_ENABLED __has_feature(objc_arc)
+#else
+#define CATCH_ARC_ENABLED 0
+#endif
+
+void arcSafeRelease( NSObject* obj );
+id performOptionalSelector( id obj, SEL sel );
+
+#if !CATCH_ARC_ENABLED
+inline void arcSafeRelease( NSObject* obj ) {
+    [obj release];
+}
+inline id performOptionalSelector( id obj, SEL sel ) {
+    if( [obj respondsToSelector: sel] )
+        return [obj performSelector: sel];
+    return nil;
+}
+#define CATCH_UNSAFE_UNRETAINED
+#define CATCH_ARC_STRONG
+#else
+inline void arcSafeRelease( NSObject* ){}
+inline id performOptionalSelector( id obj, SEL sel ) {
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
+#endif
+    if( [obj respondsToSelector: sel] )
+        return [obj performSelector: sel];
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+    return nil;
+}
+#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained
+#define CATCH_ARC_STRONG __strong
+#endif
+
+#endif
+
+namespace Catch {
+namespace Detail {
+
+    struct NonStreamable {
+        template<typename T> NonStreamable( const T& ){}
+    };
+
+    // If the type does not have its own << overload for ostream then
+    // this one will be used instead
+    inline std::ostream& operator << ( std::ostream& ss, NonStreamable ){
+        return ss << "{?}";
+    }
+
+    template<typename T>
+    inline std::string makeString( const T& value ) {
+        std::ostringstream oss;
+        oss << value;
+        return oss.str();
+    }
+
+    template<typename T>
+    inline std::string makeString( T* p ) {
+        if( !p )
+            return INTERNAL_CATCH_STRINGIFY( NULL );
+        std::ostringstream oss;
+        oss << p;
+        return oss.str();
+    }
+
+    template<typename T>
+    inline std::string makeString( const T* p ) {
+        if( !p )
+            return INTERNAL_CATCH_STRINGIFY( NULL );
+        std::ostringstream oss;
+        oss << p;
+        return oss.str();
+    }
+
+} // end namespace Detail
+
+/// \brief converts any type to a string
+///
+/// The default template forwards on to ostringstream - except when an
+/// ostringstream overload does not exist - in which case it attempts to detect
+/// that and writes {?}.
+/// Overload (not specialise) this template for custom typs that you don't want
+/// to provide an ostream overload for.
+template<typename T>
+std::string toString( const T& value ) {
+    return Detail::makeString( value );
+}
+
+// Built in overloads
+
+inline std::string toString( const std::string& value ) {
+    return "\"" + value + "\"";
+}
+
+inline std::string toString( const std::wstring& value ) {
+    std::ostringstream oss;
+    oss << "\"";
+    for(size_t i = 0; i < value.size(); ++i )
+        oss << static_cast<char>( value[i] <= 0xff ? value[i] : '?');
+    oss << "\"";
+    return oss.str();
+}
+
+inline std::string toString( const char* const value ) {
+    return value ? Catch::toString( std::string( value ) ) : std::string( "{null string}" );
+}
+
+inline std::string toString( char* const value ) {
+    return Catch::toString( static_cast<const char*>( value ) );
+}
+
+inline std::string toString( int value ) {
+    std::ostringstream oss;
+    oss << value;
+    return oss.str();
+}
+
+inline std::string toString( unsigned long value ) {
+    std::ostringstream oss;
+    if( value > 8192 )
+        oss << "0x" << std::hex << value;
+    else
+        oss << value;
+    return oss.str();
+}
+
+inline std::string toString( unsigned int value ) {
+    return toString( static_cast<unsigned long>( value ) );
+}
+
+inline std::string toString( const double value ) {
+    std::ostringstream oss;
+    oss << value;
+    return oss.str();
+}
+
+inline std::string toString( bool value ) {
+    return value ? "true" : "false";
+}
+
+inline std::string toString( char value ) {
+    return value < ' '
+        ? toString( (unsigned int)value )
+        : Detail::makeString( value );
+}
+
+inline std::string toString( signed char value ) {
+    return toString( static_cast<char>( value ) );
+}
+
+#ifdef CATCH_CONFIG_CPP11_NULLPTR
+inline std::string toString( std::nullptr_t ) {
+    return "nullptr";
+}
+#endif
+
+#ifdef __OBJC__
+    inline std::string toString( NSString const * const& nsstring ) {
+        return std::string( "@\"" ) + [nsstring UTF8String] + "\"";
+    }
+    inline std::string toString( NSString * CATCH_ARC_STRONG const& nsstring ) {
+        return std::string( "@\"" ) + [nsstring UTF8String] + "\"";
+    }
+    inline std::string toString( NSObject* const& nsObject ) {
+        return toString( [nsObject description] );
+    }
+#endif
+
+} // end namespace Catch
+
+// #included from: catch_assertionresult.h
+#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED
+
+#include <string>
+// #included from: catch_result_type.h
+#define TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED
+
+namespace Catch {
+
+    // ResultWas::OfType enum
+    struct ResultWas { enum OfType {
+        Unknown = -1,
+        Ok = 0,
+        Info = 1,
+        Warning = 2,
+
+        FailureBit = 0x10,
+
+        ExpressionFailed = FailureBit | 1,
+        ExplicitFailure = FailureBit | 2,
+
+        Exception = 0x100 | FailureBit,
+
+        ThrewException = Exception | 1,
+        DidntThrowException = Exception | 2
+
+    }; };
+
+    inline bool isOk( ResultWas::OfType resultType ) {
+        return ( resultType & ResultWas::FailureBit ) == 0;
+    }
+
+    // ResultAction::Value enum
+    struct ResultAction { enum Value {
+        None,
+        Failed = 1, // Failure - but no debug break if Debug bit not set
+        Debug = 2,  // If this bit is set, invoke the debugger
+        Abort = 4   // Test run should abort
+    }; };
+
+    // ResultDisposition::Flags enum
+    struct ResultDisposition { enum Flags {
+            Normal = 0x00,
+
+            ContinueOnFailure = 0x01,   // Failures fail test, but execution continues
+            NegateResult = 0x02,        // Prefix expressiom with !
+            SuppressFail = 0x04         // Failures are reported but do not fail the test
+    }; };
+
+    inline ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) {
+        return static_cast<ResultDisposition::Flags>( static_cast<int>( lhs ) | static_cast<int>( rhs ) );
+    }
+
+    inline bool shouldContinueOnFailure( int flags ) { return flags & ResultDisposition::ContinueOnFailure; }
+    inline bool shouldNegate( int flags ) { return flags & ResultDisposition::NegateResult; }
+    inline bool shouldSuppressFailure( int flags ) { return flags & ResultDisposition::SuppressFail; }
+
+} // end namespace Catch
+
+
+namespace Catch {
+
+    struct AssertionInfo
+    {
+        AssertionInfo() {}
+        AssertionInfo(  const std::string& _macroName,
+                        const SourceLineInfo& _lineInfo,
+                        const std::string& _capturedExpression,
+                        ResultDisposition::Flags _resultDisposition );
+
+        std::string macroName;
+        SourceLineInfo lineInfo;
+        std::string capturedExpression;
+        ResultDisposition::Flags resultDisposition;
+    };
+
+    struct AssertionResultData
+    {
+        AssertionResultData() : resultType( ResultWas::Unknown ) {}
+
+        std::string reconstructedExpression;
+        std::string message;
+        ResultWas::OfType resultType;
+    };
+
+    class AssertionResult {
+    public:
+        AssertionResult();
+        AssertionResult( const AssertionInfo& info, const AssertionResultData& data );
+        ~AssertionResult();
+
+        bool isOk() const;
+        bool succeeded() const;
+        ResultWas::OfType getResultType() const;
+        bool hasExpression() const;
+        bool hasMessage() const;
+        std::string getExpression() const;
+        bool hasExpandedExpression() const;
+        std::string getExpandedExpression() const;
+        std::string getMessage() const;
+        SourceLineInfo getSourceInfo() const;
+        std::string getTestMacroName() const;
+
+    protected:
+        AssertionInfo m_info;
+        AssertionResultData m_resultData;
+    };
+
+} // end namespace Catch
+
+// #included from: catch_evaluate.hpp
+#define TWOBLUECUBES_CATCH_EVALUATE_HPP_INCLUDED
+
+namespace Catch {
+namespace Internal {
+
+    enum Operator {
+        IsEqualTo,
+        IsNotEqualTo,
+        IsLessThan,
+        IsGreaterThan,
+        IsLessThanOrEqualTo,
+        IsGreaterThanOrEqualTo
+    };
+
+    template<Operator Op> struct OperatorTraits             { static const char* getName(){ return "*error*"; } };
+    template<> struct OperatorTraits<IsEqualTo>             { static const char* getName(){ return "=="; } };
+    template<> struct OperatorTraits<IsNotEqualTo>          { static const char* getName(){ return "!="; } };
+    template<> struct OperatorTraits<IsLessThan>            { static const char* getName(){ return "<"; } };
+    template<> struct OperatorTraits<IsGreaterThan>         { static const char* getName(){ return ">"; } };
+    template<> struct OperatorTraits<IsLessThanOrEqualTo>   { static const char* getName(){ return "<="; } };
+    template<> struct OperatorTraits<IsGreaterThanOrEqualTo>{ static const char* getName(){ return ">="; } };
+
+    // So the compare overloads can be operator agnostic we convey the operator as a template
+    // enum, which is used to specialise an Evaluator for doing the comparison.
+    template<typename T1, typename T2, Operator Op>
+    class Evaluator{};
+
+    template<typename T1, typename T2>
+    struct Evaluator<T1, T2, IsEqualTo> {
+        static bool evaluate( const T1& lhs, const T2& rhs) {
+            return const_cast<T1&>( lhs ) ==  const_cast<T2&>( rhs );
+        }
+    };
+    template<typename T1, typename T2>
+    struct Evaluator<T1, T2, IsNotEqualTo> {
+        static bool evaluate( const T1& lhs, const T2& rhs ) {
+            return const_cast<T1&>( lhs ) != const_cast<T2&>( rhs );
+        }
+    };
+    template<typename T1, typename T2>
+    struct Evaluator<T1, T2, IsLessThan> {
+        static bool evaluate( const T1& lhs, const T2& rhs ) {
+            return const_cast<T1&>( lhs ) < const_cast<T2&>( rhs );
+        }
+    };
+    template<typename T1, typename T2>
+    struct Evaluator<T1, T2, IsGreaterThan> {
+        static bool evaluate( const T1& lhs, const T2& rhs ) {
+            return const_cast<T1&>( lhs ) > const_cast<T2&>( rhs );
+        }
+    };
+    template<typename T1, typename T2>
+    struct Evaluator<T1, T2, IsGreaterThanOrEqualTo> {
+        static bool evaluate( const T1& lhs, const T2& rhs ) {
+            return const_cast<T1&>( lhs ) >= const_cast<T2&>( rhs );
+        }
+    };
+    template<typename T1, typename T2>
+    struct Evaluator<T1, T2, IsLessThanOrEqualTo> {
+        static bool evaluate( const T1& lhs, const T2& rhs ) {
+            return const_cast<T1&>( lhs ) <= const_cast<T2&>( rhs );
+        }
+    };
+
+    template<Operator Op, typename T1, typename T2>
+    bool applyEvaluator( const T1& lhs, const T2& rhs ) {
+        return Evaluator<T1, T2, Op>::evaluate( lhs, rhs );
+    }
+
+    // This level of indirection allows us to specialise for integer types
+    // to avoid signed/ unsigned warnings
+
+    // "base" overload
+    template<Operator Op, typename T1, typename T2>
+    bool compare( const T1& lhs, const T2& rhs ) {
+        return Evaluator<T1, T2, Op>::evaluate( lhs, rhs );
+    }
+
+    // unsigned X to int
+    template<Operator Op> bool compare( unsigned int lhs, int rhs ) {
+        return applyEvaluator<Op>( lhs, static_cast<unsigned int>( rhs ) );
+    }
+    template<Operator Op> bool compare( unsigned long lhs, int rhs ) {
+        return applyEvaluator<Op>( lhs, static_cast<unsigned int>( rhs ) );
+    }
+    template<Operator Op> bool compare( unsigned char lhs, int rhs ) {
+        return applyEvaluator<Op>( lhs, static_cast<unsigned int>( rhs ) );
+    }
+
+    // unsigned X to long
+    template<Operator Op> bool compare( unsigned int lhs, long rhs ) {
+        return applyEvaluator<Op>( lhs, static_cast<unsigned long>( rhs ) );
+    }
+    template<Operator Op> bool compare( unsigned long lhs, long rhs ) {
+        return applyEvaluator<Op>( lhs, static_cast<unsigned long>( rhs ) );
+    }
+    template<Operator Op> bool compare( unsigned char lhs, long rhs ) {
+        return applyEvaluator<Op>( lhs, static_cast<unsigned long>( rhs ) );
+    }
+
+    // int to unsigned X
+    template<Operator Op> bool compare( int lhs, unsigned int rhs ) {
+        return applyEvaluator<Op>( static_cast<unsigned int>( lhs ), rhs );
+    }
+    template<Operator Op> bool compare( int lhs, unsigned long rhs ) {
+        return applyEvaluator<Op>( static_cast<unsigned int>( lhs ), rhs );
+    }
+    template<Operator Op> bool compare( int lhs, unsigned char rhs ) {
+        return applyEvaluator<Op>( static_cast<unsigned int>( lhs ), rhs );
+    }
+
+    // long to unsigned X
+    template<Operator Op> bool compare( long lhs, unsigned int rhs ) {
+        return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
+    }
+    template<Operator Op> bool compare( long lhs, unsigned long rhs ) {
+        return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
+    }
+    template<Operator Op> bool compare( long lhs, unsigned char rhs ) {
+        return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
+    }
+
+    // pointer to long (when comparing against NULL)
+    template<Operator Op, typename T> bool compare( long lhs, T* rhs ) {
+        return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
+    }
+    template<Operator Op, typename T> bool compare( T* lhs, long rhs ) {
+        return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
+    }
+
+    // pointer to int (when comparing against NULL)
+    template<Operator Op, typename T> bool compare( int lhs, T* rhs ) {
+        return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
+    }
+    template<Operator Op, typename T> bool compare( T* lhs, int rhs ) {
+        return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
+    }
+
+} // end of namespace Internal
+} // end of namespace Catch
+
+namespace Catch {
+
+// Wraps the (stringised versions of) the lhs, operator and rhs of an expression - as well as
+// the result of evaluating it. This is used to build an AssertionResult object
+class ExpressionResultBuilder {
+public:
+
+    ExpressionResultBuilder( ResultWas::OfType resultType = ResultWas::Unknown );
+    ExpressionResultBuilder( const ExpressionResultBuilder& other );
+    ExpressionResultBuilder& operator=(const ExpressionResultBuilder& other );
+
+    ExpressionResultBuilder& setResultType( ResultWas::OfType result );
+    ExpressionResultBuilder& setResultType( bool result );
+    ExpressionResultBuilder& setLhs( const std::string& lhs );
+    ExpressionResultBuilder& setRhs( const std::string& rhs );
+    ExpressionResultBuilder& setOp( const std::string& op );
+
+    ExpressionResultBuilder& endExpression( ResultDisposition::Flags resultDisposition );
+
+    template<typename T>
+    ExpressionResultBuilder& operator << ( const T& value ) {
+        m_stream << value;
+        return *this;
+    }
+
+    std::string reconstructExpression( const AssertionInfo& info ) const;
+
+    AssertionResult buildResult( const AssertionInfo& info ) const;
+
+private:
+    AssertionResultData m_data;
+    struct ExprComponents {
+        ExprComponents() : shouldNegate( false ) {}
+        bool shouldNegate;
+        std::string lhs, rhs, op;
+    } m_exprComponents;
+    std::ostringstream m_stream;
+};
+
+} // end namespace Catch
+
+namespace Catch {
+
+struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
+
+// Wraps the LHS of an expression and captures the operator and RHS (if any) - wrapping them all
+// in an ExpressionResultBuilder object
+template<typename T>
+class ExpressionLhs {
+	void operator = ( const ExpressionLhs& );
+
+public:
+    ExpressionLhs( T lhs ) : m_lhs( lhs ) {}
+
+    template<typename RhsT>
+    ExpressionResultBuilder& operator == ( const RhsT& rhs ) {
+        return captureExpression<Internal::IsEqualTo>( rhs );
+    }
+
+    template<typename RhsT>
+    ExpressionResultBuilder& operator != ( const RhsT& rhs ) {
+        return captureExpression<Internal::IsNotEqualTo>( rhs );
+    }
+
+    template<typename RhsT>
+    ExpressionResultBuilder& operator < ( const RhsT& rhs ) {
+        return captureExpression<Internal::IsLessThan>( rhs );
+    }
+
+    template<typename RhsT>
+    ExpressionResultBuilder& operator > ( const RhsT& rhs ) {
+        return captureExpression<Internal::IsGreaterThan>( rhs );
+    }
+
+    template<typename RhsT>
+    ExpressionResultBuilder& operator <= ( const RhsT& rhs ) {
+        return captureExpression<Internal::IsLessThanOrEqualTo>( rhs );
+    }
+
+    template<typename RhsT>
+    ExpressionResultBuilder& operator >= ( const RhsT& rhs ) {
+        return captureExpression<Internal::IsGreaterThanOrEqualTo>( rhs );
+    }
+
+    ExpressionResultBuilder& operator == ( bool rhs ) {
+        return captureExpression<Internal::IsEqualTo>( rhs );
+    }
+
+    ExpressionResultBuilder& operator != ( bool rhs ) {
+        return captureExpression<Internal::IsNotEqualTo>( rhs );
+    }
+
+    ExpressionResultBuilder& endExpression( ResultDisposition::Flags resultDisposition ) {
+        bool value = m_lhs ? true : false;
+        return m_result
+            .setLhs( Catch::toString( value ) )
+            .setResultType( value )
+            .endExpression( resultDisposition );
+    }
+
+    // Only simple binary expressions are allowed on the LHS.
+    // If more complex compositions are required then place the sub expression in parentheses
+    template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator + ( const RhsT& );
+    template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator - ( const RhsT& );
+    template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator / ( const RhsT& );
+    template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator * ( const RhsT& );
+
+private:
+    template<Internal::Operator Op, typename RhsT>
+    ExpressionResultBuilder& captureExpression( const RhsT& rhs ) {
+        return m_result
+            .setResultType( Internal::compare<Op>( m_lhs, rhs ) )
+            .setLhs( Catch::toString( m_lhs ) )
+            .setRhs( Catch::toString( rhs ) )
+            .setOp( Internal::OperatorTraits<Op>::getName() );
+    }
+
+private:
+    ExpressionResultBuilder m_result;
+    T m_lhs;
+};
+
+} // end namespace Catch
+
+namespace Catch {
+
+// Captures the LHS of the expression and wraps it in an Expression Lhs object
+class ExpressionDecomposer {
+public:
+
+    template<typename T>
+    ExpressionLhs<const T&> operator->* ( const T & operand ) {
+        return ExpressionLhs<const T&>( operand );
+    }
+
+    ExpressionLhs<bool> operator->* ( bool value ) {
+        return ExpressionLhs<bool>( value );
+    }
+};
+
+} // end namespace Catch
+
+// #included from: catch_interfaces_capture.h
+#define TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED
+
+#include <string>
+// #included from: catch_totals.hpp
+#define TWOBLUECUBES_CATCH_TOTALS_HPP_INCLUDED
+
+#include <cstddef>
+
+namespace Catch {
+
+    struct Counts {
+        Counts() : passed( 0 ), failed( 0 ) {}
+
+        Counts operator - ( const Counts& other ) const {
+            Counts diff;
+            diff.passed = passed - other.passed;
+            diff.failed = failed - other.failed;
+            return diff;
+        }
+        Counts& operator += ( const Counts& other ) {
+            passed += other.passed;
+            failed += other.failed;
+            return *this;
+        }
+
+        std::size_t total() const {
+            return passed + failed;
+        }
+
+        std::size_t passed;
+        std::size_t failed;
+    };
+
+    struct Totals {
+
+        Totals operator - ( const Totals& other ) const {
+            Totals diff;
+            diff.assertions = assertions - other.assertions;
+            diff.testCases = testCases - other.testCases;
+            return diff;
+        }
+
+        Totals delta( const Totals& prevTotals ) const {
+            Totals diff = *this - prevTotals;
+            if( diff.assertions.failed > 0 )
+                ++diff.testCases.failed;
+            else
+                ++diff.testCases.passed;
+            return diff;
+        }
+
+        Totals& operator += ( const Totals& other ) {
+            assertions += other.assertions;
+            testCases += other.testCases;
+            return *this;
+        }
+
+        Counts assertions;
+        Counts testCases;
+    };
+}
+
+
+namespace Catch {
+
+    class TestCaseInfo;
+    class ScopedInfo;
+    class ExpressionResultBuilder;
+    class AssertionResult;
+    struct AssertionInfo;
+
+    struct IResultCapture {
+
+        virtual ~IResultCapture();
+
+        virtual void testEnded( const AssertionResult& result ) = 0;
+        virtual bool sectionStarted(    const std::string& name,
+                                        const std::string& description,
+                                        const SourceLineInfo& lineInfo,
+                                        Counts& assertions ) = 0;
+        virtual void sectionEnded( const std::string& name, const Counts& assertions ) = 0;
+        virtual void pushScopedInfo( ScopedInfo* scopedInfo ) = 0;
+        virtual void popScopedInfo( ScopedInfo* scopedInfo ) = 0;
+        virtual bool shouldDebugBreak() const = 0;
+
+        virtual ResultAction::Value acceptExpression( const ExpressionResultBuilder& assertionResult, const AssertionInfo& assertionInfo ) = 0;
+
+        virtual std::string getCurrentTestName() const = 0;
+        virtual const AssertionResult* getLastResult() const = 0;
+    };
+}
+
+// #included from: catch_debugger.hpp
+#define TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED
+
+#include <iostream>
+
+#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
+#define CATCH_PLATFORM_MAC
+#elif  defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
+#define CATCH_PLATFORM_IPHONE
+#elif defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER)
+#define CATCH_PLATFORM_WINDOWS
+#endif
+
+#ifdef CATCH_PLATFORM_MAC
+
+    #include <assert.h>
+    #include <stdbool.h>
+    #include <sys/types.h>
+    #include <unistd.h>
+    #include <sys/sysctl.h>
+
+    namespace Catch{
+
+        // The following function is taken directly from the following technical note:
+        // http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html
+
+        // Returns true if the current process is being debugged (either
+        // running under the debugger or has a debugger attached post facto).
+        inline bool isDebuggerActive(){
+
+            int                 junk;
+            int                 mib[4];
+            struct kinfo_proc   info;
+            size_t              size;
+
+            // Initialize the flags so that, if sysctl fails for some bizarre
+            // reason, we get a predictable result.
+
+            info.kp_proc.p_flag = 0;
+
+            // Initialize mib, which tells sysctl the info we want, in this case
+            // we're looking for information about a specific process ID.
+
+            mib[0] = CTL_KERN;
+            mib[1] = KERN_PROC;
+            mib[2] = KERN_PROC_PID;
+            mib[3] = getpid();
+
+            // Call sysctl.
+
+            size = sizeof(info);
+            junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);
+            assert(junk == 0);
+
+            // We're being debugged if the P_TRACED flag is set.
+
+            return ( (info.kp_proc.p_flag & P_TRACED) != 0 );
+        }
+    }
+
+    // The following code snippet taken from:
+    // http://cocoawithlove.com/2008/03/break-into-debugger.html
+    #ifdef DEBUG
+        #if defined(__ppc64__) || defined(__ppc__)
+            #define BreakIntoDebugger() \
+            if( Catch::isDebuggerActive() ) { \
+            __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
+            : : : "memory","r0","r3","r4" ); \
+            }
+        #else
+            #define BreakIntoDebugger() if( Catch::isDebuggerActive() ) {__asm__("int $3\n" : : );}
+        #endif
+    #else
+        inline void BreakIntoDebugger(){}
+    #endif
+
+#elif defined(_MSC_VER)
+    extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
+    #define BreakIntoDebugger() if (IsDebuggerPresent() ) { __debugbreak(); }
+    inline bool isDebuggerActive() {
+        return IsDebuggerPresent() != 0;
+    }
+#elif defined(__MINGW32__)
+    extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
+    extern "C" __declspec(dllimport) void __stdcall DebugBreak();
+    #define BreakIntoDebugger() if (IsDebuggerPresent() ) { DebugBreak(); }
+    inline bool isDebuggerActive() {
+        return IsDebuggerPresent() != 0;
+    }
+#else
+	   inline void BreakIntoDebugger(){}
+	   inline bool isDebuggerActive() { return false; }
+#endif
+
+#ifdef CATCH_PLATFORM_WINDOWS
+extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( const char* );
+inline void writeToDebugConsole( const std::string& text ) {
+    ::OutputDebugStringA( text.c_str() );
+}
+#else
+inline void writeToDebugConsole( const std::string& text ) {
+    // !TBD: Need a version for Mac/ XCode and other IDEs
+    std::cout << text;
+}
+#endif // CATCH_PLATFORM_WINDOWS
+
+// #included from: catch_interfaces_registry_hub.h
+#define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
+
+// #included from: catch_interfaces_reporter.h
+#define TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
+
+// #included from: catch_config.hpp
+#define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED
+
+// #included from: catch_test_spec.h
+#define TWOBLUECUBES_CATCH_TEST_SPEC_H_INCLUDED
+
+// #included from: catch_test_case_info.h
+#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED
+
+#include <string>
+#include <set>
+
+namespace Catch {
+
+    struct ITestCase;
+
+    class TestCaseInfo {
+    public:
+        TestCaseInfo();
+
+        TestCaseInfo(   ITestCase* testCase,
+                        const std::string& className,
+                        const std::string& name,
+                        const std::string& description,
+                        const SourceLineInfo& lineInfo );
+
+        TestCaseInfo( const TestCaseInfo& other, const std::string& name );
+        TestCaseInfo( const TestCaseInfo& other );
+
+        void invoke() const;
+
+        const std::string& getClassName() const;
+        const std::string& getName() const;
+        const std::string& getDescription() const;
+        const SourceLineInfo& getLineInfo() const;
+        bool isHidden() const;
+        bool hasTag( const std::string& tag ) const;
+        bool matchesTags( const std::string& tagPattern ) const;
+        const std::set<std::string>& getTags() const;
+
+        void swap( TestCaseInfo& other );
+        bool operator == ( const TestCaseInfo& other ) const;
+        bool operator < ( const TestCaseInfo& other ) const;
+        TestCaseInfo& operator = ( const TestCaseInfo& other );
+
+    private:
+        Ptr<ITestCase> m_test;
+        std::string m_className;
+        std::string m_name;
+        std::string m_description;
+        std::set<std::string> m_tags;
+        SourceLineInfo m_lineInfo;
+        bool m_isHidden;
+    };
+}
+
+// #included from: catch_tags.hpp
+#define TWOBLUECUBES_CATCH_TAGS_HPP_INCLUDED
+
+#include <string>
+#include <set>
+#include <map>
+#include <vector>
+
+#ifdef __clang__
+#pragma clang diagnostic ignored "-Wpadded"
+#endif
+
+namespace Catch {
+    class TagParser {
+    public:
+        virtual ~TagParser();
+
+        void parse( const std::string& str ) {
+            std::size_t pos = 0;
+            while( pos < str.size() ) {
+                char c = str[pos];
+                if( c == '[' ) {
+                    std::size_t end = str.find_first_of( ']', pos );
+                    if( end != std::string::npos ) {
+                        acceptTag( str.substr( pos+1, end-pos-1 ) );
+                        pos = end+1;
+                    }
+                    else {
+                        acceptChar( c );
+                        pos++;
+                    }
+                }
+                else {
+                    acceptChar( c );
+                    pos++;
+                }
+            }
+            endParse();
+        }
+
+    protected:
+        virtual void acceptTag( const std::string& tag ) = 0;
+        virtual void acceptChar( char c ) = 0;
+        virtual void endParse() {}
+
+    private:
+    };
+
+    class TagExtracter : public TagParser {
+    public:
+
+        TagExtracter( std::set<std::string>& tags )
+        :   m_tags( tags )
+        {}
+        virtual ~TagExtracter();
+
+        void parse( std::string& description ) {
+            TagParser::parse( description );
+            description = m_remainder;
+        }
+
+    private:
+        virtual void acceptTag( const std::string& tag ) {
+            m_tags.insert( tag );
+        }
+        virtual void acceptChar( char c ) {
+            m_remainder += c;
+        }
+
+        TagExtracter& operator=(const TagExtracter&);
+
+        std::set<std::string>& m_tags;
+        std::string m_remainder;
+    };
+
+    class Tag {
+    public:
+        Tag()
+        :   m_isNegated( false )
+        {}
+
+        Tag( const std::string& name, bool isNegated )
+        :   m_name( name ),
+            m_isNegated( isNegated )
+        {}
+
+        std::string getName() const {
+            return m_name;
+        }
+        bool isNegated() const {
+            return m_isNegated;
+        }
+
+        bool operator ! () const {
+            return m_name.empty();
+        }
+
+    private:
+        std::string m_name;
+        bool m_isNegated;
+    };
+
+    class TagSet {
+        typedef std::map<std::string, Tag> TagMap;
+    public:
+        void add( const Tag& tag ) {
+            m_tags.insert( std::make_pair( tag.getName(), tag ) );
+        }
+
+        bool empty() const {
+            return m_tags.empty();
+        }
+
+        bool matches( const std::set<std::string>& tags ) const {
+            TagMap::const_iterator it = m_tags.begin();
+            TagMap::const_iterator itEnd = m_tags.end();
+            for(; it != itEnd; ++it ) {
+                bool found = tags.find( it->first ) != tags.end();
+                if( found == it->second.isNegated() )
+                    return false;
+            }
+            return true;
+        }
+
+    private:
+        TagMap m_tags;
+    };
+
+    class TagExpression {
+    public:
+        bool matches( const std::set<std::string>& tags ) const {
+            std::vector<TagSet>::const_iterator it = m_tagSets.begin();
+            std::vector<TagSet>::const_iterator itEnd = m_tagSets.end();
+            for(; it != itEnd; ++it )
+                if( it->matches( tags ) )
+                    return true;
+            return false;
+        }
+
+    private:
+        friend class TagExpressionParser;
+
+        std::vector<TagSet> m_tagSets;
+    };
+
+    class TagExpressionParser : public TagParser {
+    public:
+        TagExpressionParser( TagExpression& exp )
+        :   m_isNegated( false ),
+            m_exp( exp )
+        {}
+
+        ~TagExpressionParser();
+
+    private:
+        virtual void acceptTag( const std::string& tag ) {
+            m_currentTagSet.add( Tag( tag, m_isNegated ) );
+            m_isNegated = false;
+        }
+        virtual void acceptChar( char c ) {
+            switch( c ) {
+                case '~':
+                    m_isNegated = true;
+                    break;
+                case ',':
+                    m_exp.m_tagSets.push_back( m_currentTagSet );
+                    break;
+            }
+        }
+        virtual void endParse() {
+            if( !m_currentTagSet.empty() )
+                m_exp.m_tagSets.push_back( m_currentTagSet );
+        }
+
+        TagExpressionParser& operator=(const TagExpressionParser&);
+
+        bool m_isNegated;
+        TagSet m_currentTagSet;
+        TagExpression& m_exp;
+    };
+
+} // end namespace Catch
+
+#include <string>
+#include <vector>
+
+namespace Catch {
+
+    struct IfFilterMatches{ enum DoWhat {
+        AutoDetectBehaviour,
+        IncludeTests,
+        ExcludeTests
+    }; };
+
+    class TestCaseFilter {
+        enum WildcardPosition {
+            NoWildcard = 0,
+            WildcardAtStart = 1,
+            WildcardAtEnd = 2,
+            WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd
+        };
+
+    public:
+        TestCaseFilter( const std::string& testSpec, IfFilterMatches::DoWhat matchBehaviour = IfFilterMatches::AutoDetectBehaviour )
+        :   m_stringToMatch( testSpec ),
+            m_filterType( matchBehaviour ),
+            m_wildcardPosition( NoWildcard )
+        {
+            if( m_filterType == IfFilterMatches::AutoDetectBehaviour ) {
+                if( startsWith( m_stringToMatch, "exclude:" ) ) {
+                    m_stringToMatch = m_stringToMatch.substr( 8 );
+                    m_filterType = IfFilterMatches::ExcludeTests;
+                }
+                else if( startsWith( m_stringToMatch, "~" ) ) {
+                    m_stringToMatch = m_stringToMatch.substr( 1 );
+                    m_filterType = IfFilterMatches::ExcludeTests;
+                }
+                else {
+                    m_filterType = IfFilterMatches::IncludeTests;
+                }
+            }
+
+            if( m_stringToMatch[0] == '*' ) {
+                m_stringToMatch = m_stringToMatch.substr( 1 );
+                m_wildcardPosition = (WildcardPosition)( m_wildcardPosition | WildcardAtStart );
+            }
+            if( m_stringToMatch[m_stringToMatch.size()-1] == '*' ) {
+                m_stringToMatch = m_stringToMatch.substr( 0, m_stringToMatch.size()-1 );
+                m_wildcardPosition = (WildcardPosition)( m_wildcardPosition | WildcardAtEnd );
+            }
+        }
+
+        IfFilterMatches::DoWhat getFilterType() const {
+            return m_filterType;
+        }
+
+        bool shouldInclude( const TestCaseInfo& testCase ) const {
+            return isMatch( testCase ) == (m_filterType == IfFilterMatches::IncludeTests);
+        }
+    private:
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunreachable-code"
+#endif
+
+        bool isMatch( const TestCaseInfo& testCase ) const {
+            const std::string& name = testCase.getName();
+
+            switch( m_wildcardPosition ) {
+                case NoWildcard:
+                    return m_stringToMatch == name;
+                case WildcardAtStart:
+                    return endsWith( name, m_stringToMatch );
+                case WildcardAtEnd:
+                    return startsWith( name, m_stringToMatch );
+                case WildcardAtBothEnds:
+                    return contains( name, m_stringToMatch );
+            }
+            throw std::logic_error( "Unhandled wildcard type" );
+        }
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+        std::string m_stringToMatch;
+        IfFilterMatches::DoWhat m_filterType;
+        WildcardPosition m_wildcardPosition;
+    };
+
+    class TestCaseFilters {
+    public:
+        TestCaseFilters( const std::string& name ) : m_name( name ) {}
+
+        std::string getName() const {
+            return m_name;
+        }
+
+        void addFilter( const TestCaseFilter& filter ) {
+            if( filter.getFilterType() == IfFilterMatches::ExcludeTests )
+                m_exclusionFilters.push_back( filter );
+            else
+                m_inclusionFilters.push_back( filter );
+        }
+
+        void addTags( const std::string& tagPattern ) {
+            TagExpression exp;
+            TagExpressionParser( exp ).parse( tagPattern );
+
+            m_tagExpressions.push_back( exp );
+        }
+
+        bool shouldInclude( const TestCaseInfo& testCase ) const {
+            if( !m_tagExpressions.empty() ) {
+                std::vector<TagExpression>::const_iterator it = m_tagExpressions.begin();
+                std::vector<TagExpression>::const_iterator itEnd = m_tagExpressions.end();
+                for(; it != itEnd; ++it )
+                    if( it->matches( testCase.getTags() ) )
+                        break;
+                if( it == itEnd )
+                    return false;
+            }
+
+            if( !m_inclusionFilters.empty() ) {
+                std::vector<TestCaseFilter>::const_iterator it = m_inclusionFilters.begin();
+                std::vector<TestCaseFilter>::const_iterator itEnd = m_inclusionFilters.end();
+                for(; it != itEnd; ++it )
+                    if( it->shouldInclude( testCase ) )
+                        break;
+                if( it == itEnd )
+                    return false;
+            }
+            else if( m_exclusionFilters.empty() && m_tagExpressions.empty() ) {
+                return !testCase.isHidden();
+            }
+
+            std::vector<TestCaseFilter>::const_iterator it = m_exclusionFilters.begin();
+            std::vector<TestCaseFilter>::const_iterator itEnd = m_exclusionFilters.end();
+            for(; it != itEnd; ++it )
+                if( !it->shouldInclude( testCase ) )
+                    return false;
+            return true;
+        }
+    private:
+        std::vector<TagExpression> m_tagExpressions;
+        std::vector<TestCaseFilter> m_inclusionFilters;
+        std::vector<TestCaseFilter> m_exclusionFilters;
+        std::string m_name;
+    };
+
+}
+
+// #included from: catch_interfaces_config.h
+#define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED
+
+namespace Catch {
+
+    struct IConfig {
+
+        virtual ~IConfig();
+
+        virtual bool allowThrows() const = 0;
+    };
+}
+
+// #included from: catch_stream.hpp
+#define TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED
+
+// #included from: catch_streambuf.h
+#define TWOBLUECUBES_CATCH_STREAMBUF_H_INCLUDED
+
+#include <streambuf>
+
+namespace Catch {
+
+    class StreamBufBase : public std::streambuf {
+    public:
+        virtual ~StreamBufBase();
+    };
+}
+
+#include <stdexcept>
+#include <cstdio>
+
+namespace Catch {
+
+    template<typename WriterF, size_t bufferSize=256>
+    class StreamBufImpl : public StreamBufBase {
+        char data[bufferSize];
+        WriterF m_writer;
+
+    public:
+        StreamBufImpl() {
+            setp( data, data + sizeof(data) );
+        }
+
+        ~StreamBufImpl() {
+            sync();
+        }
+
+    private:
+        int	overflow( int c ) {
+            sync();
+
+            if( c != EOF ) {
+                if( pbase() == epptr() )
+                    m_writer( std::string( 1, static_cast<char>( c ) ) );
+                else
+                    sputc( static_cast<char>( c ) );
+            }
+            return 0;
+        }
+
+        int	sync() {
+            if( pbase() != pptr() ) {
+                m_writer( std::string( pbase(), static_cast<std::string::size_type>( pptr() - pbase() ) ) );
+                setp( pbase(), epptr() );
+            }
+            return 0;
+        }
+    };
+
+    ///////////////////////////////////////////////////////////////////////////
+
+    struct OutputDebugWriter {
+
+        void operator()( const std::string &str ) {
+            writeToDebugConsole( str );
+        }
+    };
+
+    class Stream {
+    public:
+        Stream()
+        : streamBuf( NULL ), isOwned( false )
+        {}
+
+        Stream( std::streambuf* _streamBuf, bool _isOwned )
+        : streamBuf( _streamBuf ), isOwned( _isOwned )
+        {}
+
+        void release() {
+            if( isOwned ) {
+                delete streamBuf;
+                streamBuf = NULL;
+                isOwned = false;
+            }
+        }
+
+        std::streambuf* streamBuf;
+
+    private:
+        bool isOwned;
+    };
+}
+
+#include <memory>
+#include <vector>
+#include <string>
+#include <iostream>
+
+namespace Catch {
+
+    struct Include { enum WhichResults {
+        FailedOnly,
+        SuccessfulResults
+    }; };
+
+    struct List{ enum What {
+        None = 0,
+
+        Reports = 1,
+        Tests = 2,
+        All = 3,
+
+        TestNames = 6,
+
+        WhatMask = 0xf,
+
+        AsText = 0x10,
+        AsXml = 0x20,
+
+        AsMask = 0xf0
+    }; };
+
+    struct ConfigData {
+
+        struct WarnAbout { enum What {
+            Nothing = 0x00,
+            NoAssertions = 0x01
+        }; };
+
+        ConfigData()
+        :   listSpec( List::None ),
+            shouldDebugBreak( false ),
+            includeWhichResults( Include::FailedOnly ),
+            cutoff( -1 ),
+            allowThrows( true ),
+            warnings( WarnAbout::Nothing )
+        {}
+
+        std::string reporter;
+        std::string outputFilename;
+        List::What listSpec;
+        std::vector<TestCaseFilters> filters;
+        bool shouldDebugBreak;
+        std::string stream;
+        Include::WhichResults includeWhichResults;
+        std::string name;
+        int cutoff;
+        bool allowThrows;
+        WarnAbout::What warnings;
+    };
+
+    class Config : public IConfig {
+    private:
+        Config( const Config& other );
+        Config& operator = ( const Config& other );
+        virtual void dummy();
+    public:
+
+        Config()
+        :   m_os( std::cout.rdbuf() )
+        {}
+
+        Config( const ConfigData& data )
+        :   m_data( data ),
+            m_os( std::cout.rdbuf() )
+        {}
+
+        virtual ~Config() {
+            m_os.rdbuf( std::cout.rdbuf() );
+            m_stream.release();
+        }
+
+        void setFilename( const std::string& filename ) {
+            m_data.outputFilename = filename;
+        }
+
+        List::What getListSpec( void ) const {
+            return m_data.listSpec;
+        }
+
+        const std::string& getFilename() const {
+            return m_data.outputFilename ;
+        }
+
+        List::What listWhat() const {
+            return static_cast<List::What>( m_data.listSpec & List::WhatMask );
+        }
+
+        List::What listAs() const {
+            return static_cast<List::What>( m_data.listSpec & List::AsMask );
+        }
+
+        std::string getName() const {
+            return m_data.name;
+        }
+
+        bool shouldDebugBreak() const {
+            return m_data.shouldDebugBreak;
+        }
+
+        virtual std::ostream& stream() const {
+            return m_os;
+        }
+
+        void setStreamBuf( std::streambuf* buf ) {
+            m_os.rdbuf( buf ? buf : std::cout.rdbuf() );
+        }
+
+        void useStream( const std::string& streamName ) {
+            Stream stream = createStream( streamName );
+            setStreamBuf( stream.streamBuf );
+            m_stream.release();
+            m_stream = stream;
+        }
+
+        void addTestSpec( const std::string& testSpec ) {
+            TestCaseFilters filters( testSpec );
+            filters.addFilter( TestCaseFilter( testSpec ) );
+            m_data.filters.push_back( filters );
+        }
+
+        virtual bool includeSuccessfulResults() const {
+            return m_data.includeWhichResults == Include::SuccessfulResults;
+        }
+
+        int getCutoff() const {
+            return m_data.cutoff;
+        }
+
+        virtual bool allowThrows() const {
+            return m_data.allowThrows;
+        }
+
+        const ConfigData& data() const {
+            return m_data;
+        }
+        ConfigData& data() {
+            return m_data;
+        }
+
+    private:
+        ConfigData m_data;
+
+        // !TBD Move these out of here
+        Stream m_stream;
+        mutable std::ostream m_os;
+    };
+
+} // end namespace Catch
+
+#include <string>
+#include <ostream>
+#include <map>
+
+namespace Catch
+{
+    struct ReporterConfig
+    {
+        ReporterConfig( const std::string& _name,
+                        std::ostream& _stream,
+                        bool _includeSuccessfulResults,
+                        const ConfigData& _fullConfig )
+        :   name( _name ),
+            stream( _stream ),
+            includeSuccessfulResults( _includeSuccessfulResults ),
+            fullConfig( _fullConfig )
+        {}
+
+        ReporterConfig( const ReporterConfig& other )
+        :   name( other.name ),
+            stream( other.stream ),
+            includeSuccessfulResults( other.includeSuccessfulResults ),
+            fullConfig( other.fullConfig )
+        {}
+
+        std::string name;
+        std::ostream& stream;
+        bool includeSuccessfulResults;
+        ConfigData fullConfig;
+
+    private:
+        void operator=(const ReporterConfig&);
+    };
+
+    class TestCaseInfo;
+    class AssertionResult;
+
+    struct IReporter : IShared {
+        virtual ~IReporter();
+
+        virtual bool shouldRedirectStdout() const = 0;
+
+        virtual void StartTesting() = 0;
+        virtual void EndTesting( const Totals& totals ) = 0;
+
+        virtual void StartGroup( const std::string& groupName ) = 0;
+        virtual void EndGroup( const std::string& groupName, const Totals& totals ) = 0;
+
+        virtual void StartTestCase( const TestCaseInfo& testInfo ) = 0;
+        // TestCaseResult
+        virtual void EndTestCase( const TestCaseInfo& testInfo, const Totals& totals, const std::string& stdOut, const std::string& stdErr ) = 0;
+
+        // SectionInfo
+        virtual void StartSection( const std::string& sectionName, const std::string& description ) = 0;
+        // Section Result
+        virtual void EndSection( const std::string& sectionName, const Counts& assertions ) = 0;
+
+        // - merge into SectionResult ?
+        virtual void NoAssertionsInSection( const std::string& sectionName ) = 0;
+        virtual void NoAssertionsInTestCase( const std::string& testName ) = 0;
+
+        // - merge into SectionResult, TestCaseResult, GroupResult & TestRunResult
+        virtual void Aborted() = 0;
+
+        // AssertionReslt
+        virtual void Result( const AssertionResult& result ) = 0;
+    };
+
+    struct IReporterFactory {
+        virtual ~IReporterFactory();
+        virtual IReporter* create( const ReporterConfig& config ) const = 0;
+        virtual std::string getDescription() const = 0;
+    };
+
+    struct IReporterRegistry {
+        typedef std::map<std::string, IReporterFactory*> FactoryMap;
+
+        virtual ~IReporterRegistry();
+        virtual IReporter* create( const std::string& name, const ReporterConfig& config ) const = 0;
+        virtual const FactoryMap& getFactories() const = 0;
+    };
+
+    inline std::string trim( const std::string& str ) {
+        std::string::size_type start = str.find_first_not_of( "\n\r\t " );
+        std::string::size_type end = str.find_last_not_of( "\n\r\t " );
+
+        return start != std::string::npos ? str.substr( start, 1+end-start ) : "";
+    }
+}
+
+#include <vector>
+
+namespace Catch {
+
+    class TestCaseInfo;
+    struct ITestCaseRegistry;
+    struct IExceptionTranslatorRegistry;
+    struct IExceptionTranslator;
+
+    struct IRegistryHub {
+        virtual ~IRegistryHub();
+
+        virtual const IReporterRegistry& getReporterRegistry() const = 0;
+        virtual const ITestCaseRegistry& getTestCaseRegistry() const = 0;
+        virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0;
+    };
+
+    struct IMutableRegistryHub {
+        virtual ~IMutableRegistryHub();
+        virtual void registerReporter( const std::string& name, IReporterFactory* factory ) = 0;
+        virtual void registerTest( const TestCaseInfo& testInfo ) = 0;
+        virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
+    };
+
+    IRegistryHub& getRegistryHub();
+    IMutableRegistryHub& getMutableRegistryHub();
+    void cleanUp();
+    std::string translateActiveException();
+
+}
+
+#include <ostream>
+
+namespace Catch {
+
+    inline IResultCapture& getResultCapture() {
+        return getCurrentContext().getResultCapture();
+    }
+
+    template<typename MatcherT>
+    ExpressionResultBuilder expressionResultBuilderFromMatcher( const MatcherT& matcher,
+                                                                const std::string& matcherCallAsString ) {
+        std::string matcherAsString = matcher.toString();
+        if( matcherAsString == "{?}" )
+            matcherAsString = matcherCallAsString;
+        return ExpressionResultBuilder()
+            .setRhs( matcherAsString )
+            .setOp( "matches" );
+    }
+
+    template<typename MatcherT, typename ArgT>
+    ExpressionResultBuilder expressionResultBuilderFromMatcher( const MatcherT& matcher,
+                                                                const ArgT& arg,
+                                                                const std::string& matcherCallAsString ) {
+        return expressionResultBuilderFromMatcher( matcher, matcherCallAsString )
+            .setLhs( Catch::toString( arg ) )
+            .setResultType( matcher.match( arg ) );
+    }
+
+    template<typename MatcherT, typename ArgT>
+    ExpressionResultBuilder expressionResultBuilderFromMatcher( const MatcherT& matcher,
+                                                                ArgT* arg,
+                                                                const std::string& matcherCallAsString ) {
+        return expressionResultBuilderFromMatcher( matcher, matcherCallAsString )
+            .setLhs( Catch::toString( arg ) )
+            .setResultType( matcher.match( arg ) );
+    }
+
+struct TestFailureException{};
+
+class ScopedInfo {
+public:
+    ScopedInfo() : m_resultBuilder( ResultWas::Info ) {
+        getResultCapture().pushScopedInfo( this );
+    }
+    ~ScopedInfo() {
+        getResultCapture().popScopedInfo( this );
+    }
+    template<typename T>
+    ScopedInfo& operator << ( const T& value ) {
+        m_resultBuilder << value;
+        return *this;
+    }
+    AssertionResult buildResult( const AssertionInfo& assertionInfo ) const {
+        return m_resultBuilder.buildResult( assertionInfo );
+    }
+
+private:
+    ExpressionResultBuilder m_resultBuilder;
+};
+
+// This is just here to avoid compiler warnings with macro constants and boolean literals
+inline bool isTrue( bool value ){ return value; }
+
+} // end namespace Catch
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_ASSERTIONINFO_NAME INTERNAL_CATCH_UNIQUE_NAME( __assertionInfo )
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_ACCEPT_EXPR( evaluatedExpr, resultDisposition, originalExpr ) \
+    if( Catch::ResultAction::Value internal_catch_action = Catch::getResultCapture().acceptExpression( evaluatedExpr, INTERNAL_CATCH_ASSERTIONINFO_NAME )  ) { \
+        if( internal_catch_action & Catch::ResultAction::Debug ) BreakIntoDebugger(); \
+        if( internal_catch_action & Catch::ResultAction::Abort ) throw Catch::TestFailureException(); \
+        if( !Catch::shouldContinueOnFailure( resultDisposition ) ) throw Catch::TestFailureException(); \
+        if( Catch::isTrue( false ) ){ bool this_is_here_to_invoke_warnings = ( originalExpr ); Catch::isTrue( this_is_here_to_invoke_warnings ); } \
+    }
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_ACCEPT_INFO( expr, macroName, resultDisposition ) \
+    Catch::AssertionInfo INTERNAL_CATCH_ASSERTIONINFO_NAME( macroName, CATCH_INTERNAL_LINEINFO, expr, resultDisposition );
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ) \
+    do { \
+        INTERNAL_CATCH_ACCEPT_INFO( #expr, macroName, resultDisposition ); \
+        try { \
+            INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionDecomposer()->*expr ).endExpression( resultDisposition ), resultDisposition, expr ); \
+        } catch( Catch::TestFailureException& ) { \
+            throw; \
+        } catch( ... ) { \
+            INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), \
+                resultDisposition | Catch::ResultDisposition::ContinueOnFailure, expr ); \
+            throw; \
+        } \
+    } while( Catch::isTrue( false ) )
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
+    INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
+    if( Catch::getResultCapture().getLastResult()->succeeded() )
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \
+    INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
+    if( !Catch::getResultCapture().getLastResult()->succeeded() )
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \
+    do { \
+        INTERNAL_CATCH_ACCEPT_INFO( #expr, macroName, resultDisposition ); \
+        try { \
+            expr; \
+            INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::Ok ), resultDisposition, false ); \
+        } \
+        catch( ... ) { \
+            INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), resultDisposition, false ); \
+        } \
+} while( Catch::isTrue( false ) )
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_THROWS_IMPL( expr, exceptionType, resultDisposition ) \
+    try { \
+        if( Catch::getCurrentContext().getConfig()->allowThrows() ) { \
+            expr; \
+            INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::DidntThrowException ), resultDisposition, false ); \
+        } \
+    } \
+    catch( Catch::TestFailureException& ) { \
+        throw; \
+    } \
+    catch( exceptionType ) { \
+        INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::Ok ), resultDisposition, false ); \
+    }
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_THROWS( expr, exceptionType, resultDisposition, macroName ) \
+    do { \
+        INTERNAL_CATCH_ACCEPT_INFO( #expr, macroName, resultDisposition ); \
+        INTERNAL_CATCH_THROWS_IMPL( expr, exceptionType, resultDisposition ) \
+    } while( Catch::isTrue( false ) )
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, resultDisposition, macroName ) \
+    do { \
+        INTERNAL_CATCH_ACCEPT_INFO( #expr, macroName, resultDisposition ); \
+        INTERNAL_CATCH_THROWS_IMPL( expr, exceptionType, resultDisposition ) \
+        catch( ... ) { \
+            INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException() ), \
+                resultDisposition | Catch::ResultDisposition::ContinueOnFailure, false ); \
+        } \
+    } while( Catch::isTrue( false ) )
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_MSG( reason, resultType, resultDisposition, macroName ) \
+    do { \
+        INTERNAL_CATCH_ACCEPT_INFO( "", macroName, resultDisposition ); \
+        INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( resultType ) << reason, resultDisposition, true ) \
+    } while( Catch::isTrue( false ) )
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_SCOPED_INFO( log, macroName ) \
+    INTERNAL_CATCH_ACCEPT_INFO( "", macroName, Catch::ResultDisposition::Normal ); \
+    Catch::ScopedInfo INTERNAL_CATCH_UNIQUE_NAME( info ); \
+    INTERNAL_CATCH_UNIQUE_NAME( info ) << log
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CHECK_THAT( arg, matcher, resultDisposition, macroName ) \
+    do { \
+        INTERNAL_CATCH_ACCEPT_INFO( #arg " " #matcher, macroName, resultDisposition ); \
+        try { \
+            INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::expressionResultBuilderFromMatcher( ::Catch::Matchers::matcher, arg, #matcher ) ), resultDisposition, false ); \
+        } catch( Catch::TestFailureException& ) { \
+            throw; \
+        } catch( ... ) { \
+            INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException() ), \
+                resultDisposition | Catch::ResultDisposition::ContinueOnFailure, false ); \
+            throw; \
+        } \
+    } while( Catch::isTrue( false ) )
+
+// #included from: internal/catch_section.hpp
+#define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED
+
+#include <string>
+
+namespace Catch {
+
+    class Section {
+    public:
+        Section(    const std::string& name,
+                    const std::string& description,
+                    const SourceLineInfo& lineInfo )
+        :   m_name( name ),
+            m_sectionIncluded( getCurrentContext().getResultCapture().sectionStarted( name, description, lineInfo, m_assertions ) )
+        {}
+
+        ~Section() {
+            if( m_sectionIncluded )
+                getCurrentContext().getResultCapture().sectionEnded( m_name, m_assertions );
+        }
+
+        // This indicates whether the section should be executed or not
+        operator bool() {
+            return m_sectionIncluded;
+        }
+
+    private:
+
+        std::string m_name;
+        Counts m_assertions;
+        bool m_sectionIncluded;
+    };
+
+} // end namespace Catch
+
+#define INTERNAL_CATCH_SECTION( name, desc ) \
+    if( Catch::Section INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::Section( name, desc, CATCH_INTERNAL_LINEINFO ) )
+
+// #included from: internal/catch_generators.hpp
+#define TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED
+
+#include <iterator>
+#include <vector>
+#include <string>
+#include <stdlib.h>
+
+namespace Catch {
+
+template<typename T>
+struct IGenerator {
+    virtual ~IGenerator() {}
+    virtual T getValue( std::size_t index ) const = 0;
+    virtual std::size_t size () const = 0;
+};
+
+template<typename T>
+class BetweenGenerator : public IGenerator<T> {
+public:
+    BetweenGenerator( T from, T to ) : m_from( from ), m_to( to ){}
+
+    virtual T getValue( std::size_t index ) const {
+        return m_from+static_cast<T>( index );
+    }
+
+    virtual std::size_t size() const {
+        return static_cast<std::size_t>( 1+m_to-m_from );
+    }
+
+private:
+
+    T m_from;
+    T m_to;
+};
+
+template<typename T>
+class ValuesGenerator : public IGenerator<T> {
+public:
+    ValuesGenerator(){}
+
+    void add( T value ) {
+        m_values.push_back( value );
+    }
+
+    virtual T getValue( std::size_t index ) const {
+        return m_values[index];
+    }
+
+    virtual std::size_t size() const {
+        return m_values.size();
+    }
+
+private:
+    std::vector<T> m_values;
+};
+
+template<typename T>
+class CompositeGenerator {
+public:
+    CompositeGenerator() : m_totalSize( 0 ) {}
+
+	// *** Move semantics, similar to auto_ptr ***
+    CompositeGenerator( CompositeGenerator& other )
+    :   m_fileInfo( other.m_fileInfo ),
+        m_totalSize( 0 )
+    {
+		move( other );
+    }
+
+    CompositeGenerator& setFileInfo( const char* fileInfo ) {
+        m_fileInfo = fileInfo;
+        return *this;
+    }
+
+    ~CompositeGenerator() {
+        deleteAll( m_composed );
+    }
+
+    operator T () const {
+        size_t overallIndex = getCurrentContext().getGeneratorIndex( m_fileInfo, m_totalSize );
+
+        typename std::vector<const IGenerator<T>*>::const_iterator it = m_composed.begin();
+        typename std::vector<const IGenerator<T>*>::const_iterator itEnd = m_composed.end();
+        for( size_t index = 0; it != itEnd; ++it )
+        {
+            const IGenerator<T>* generator = *it;
+            if( overallIndex >= index && overallIndex < index + generator->size() )
+            {
+                return generator->getValue( overallIndex-index );
+            }
+            index += generator->size();
+        }
+        CATCH_INTERNAL_ERROR( "Indexed past end of generated range" );
+		return T(); // Suppress spurious "not all control paths return a value" warning in Visual Studio - if you know how to fix this please do so
+    }
+
+    void add( const IGenerator<T>* generator ) {
+        m_totalSize += generator->size();
+        m_composed.push_back( generator );
+    }
+
+    CompositeGenerator& then( CompositeGenerator& other ) {
+        move( other );
+        return *this;
+    }
+
+    CompositeGenerator& then( T value ) {
+        ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
+        valuesGen->add( value );
+        add( valuesGen );
+        return *this;
+    }
+
+private:
+
+    void move( CompositeGenerator& other ) {
+        std::copy( other.m_composed.begin(), other.m_composed.end(), std::back_inserter( m_composed ) );
+        m_totalSize += other.m_totalSize;
+        other.m_composed.clear();
+    }
+
+    std::vector<const IGenerator<T>*> m_composed;
+    std::string m_fileInfo;
+    size_t m_totalSize;
+};
+
+namespace Generators
+{
+    template<typename T>
+    CompositeGenerator<T> between( T from, T to ) {
+        CompositeGenerator<T> generators;
+        generators.add( new BetweenGenerator<T>( from, to ) );
+        return generators;
+    }
+
+    template<typename T>
+    CompositeGenerator<T> values( T val1, T val2 ) {
+        CompositeGenerator<T> generators;
+        ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
+        valuesGen->add( val1 );
+        valuesGen->add( val2 );
+        generators.add( valuesGen );
+        return generators;
+    }
+
+    template<typename T>
+    CompositeGenerator<T> values( T val1, T val2, T val3 ){
+        CompositeGenerator<T> generators;
+        ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
+        valuesGen->add( val1 );
+        valuesGen->add( val2 );
+        valuesGen->add( val3 );
+        generators.add( valuesGen );
+        return generators;
+    }
+
+    template<typename T>
+    CompositeGenerator<T> values( T val1, T val2, T val3, T val4 ) {
+        CompositeGenerator<T> generators;
+        ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
+        valuesGen->add( val1 );
+        valuesGen->add( val2 );
+        valuesGen->add( val3 );
+        valuesGen->add( val4 );
+        generators.add( valuesGen );
+        return generators;
+    }
+
+} // end namespace Generators
+
+using namespace Generators;
+
+} // end namespace Catch
+
+#define INTERNAL_CATCH_LINESTR2( line ) #line
+#define INTERNAL_CATCH_LINESTR( line ) INTERNAL_CATCH_LINESTR2( line )
+
+#define INTERNAL_CATCH_GENERATE( expr ) expr.setFileInfo( __FILE__ "(" INTERNAL_CATCH_LINESTR( __LINE__ ) ")" )
+
+// #included from: internal/catch_interfaces_exception.h
+#define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED
+
+#include <string>
+
+namespace Catch {
+
+    typedef std::string(*exceptionTranslateFunction)();
+
+    struct IExceptionTranslator {
+        virtual ~IExceptionTranslator();
+        virtual std::string translate() const = 0;
+    };
+
+    struct IExceptionTranslatorRegistry {
+        virtual ~IExceptionTranslatorRegistry();
+
+        virtual std::string translateActiveException() const = 0;
+    };
+
+    class ExceptionTranslatorRegistrar {
+        template<typename T>
+        class ExceptionTranslator : public IExceptionTranslator {
+        public:
+
+            ExceptionTranslator( std::string(*translateFunction)( T& ) )
+            : m_translateFunction( translateFunction )
+            {}
+
+            virtual std::string translate() const {
+                try {
+                    throw;
+                }
+                catch( T& ex ) {
+                    return m_translateFunction( ex );
+                }
+            }
+
+        protected:
+            std::string(*m_translateFunction)( T& );
+        };
+
+    public:
+        template<typename T>
+        ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) {
+            getMutableRegistryHub().registerTranslator
+                ( new ExceptionTranslator<T>( translateFunction ) );
+        }
+    };
+}
+
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) \
+    static std::string INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator )( signature ); \
+    namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ) ); }\
+    static std::string INTERNAL_CATCH_UNIQUE_NAME(  catch_internal_ExceptionTranslator )( signature )
+
+// #included from: internal/catch_approx.hpp
+#define TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED
+
+#include <cmath>
+#include <limits>
+
+namespace Catch {
+namespace Detail {
+
+    class Approx {
+    public:
+        explicit Approx ( double value )
+        :   m_epsilon( std::numeric_limits<float>::epsilon()*100 ),
+            m_scale( 1.0 ),
+            m_value( value )
+        {}
+
+        Approx( const Approx& other )
+        :   m_epsilon( other.m_epsilon ),
+            m_scale( other.m_scale ),
+            m_value( other.m_value )
+        {}
+
+        static Approx custom() {
+            return Approx( 0 );
+        }
+
+        Approx operator()( double value ) {
+            Approx approx( value );
+            approx.epsilon( m_epsilon );
+            approx.scale( m_scale );
+            return approx;
+        }
+
+        friend bool operator == ( double lhs, const Approx& rhs ) {
+            // Thanks to Richard Harris for his help refining this formula
+            return fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( fabs(lhs), fabs(rhs.m_value) ) );
+        }
+
+        friend bool operator == ( const Approx& lhs, double rhs ) {
+            return operator==( rhs, lhs );
+        }
+
+        friend bool operator != ( double lhs, const Approx& rhs ) {
+            return !operator==( lhs, rhs );
+        }
+
+        friend bool operator != ( const Approx& lhs, double rhs ) {
+            return !operator==( rhs, lhs );
+        }
+
+        Approx& epsilon( double newEpsilon ) {
+            m_epsilon = newEpsilon;
+            return *this;
+        }
+
+        Approx& scale( double newScale ) {
+            m_scale = newScale;
+            return *this;
+        }
+
+        std::string toString() const {
+            std::ostringstream oss;
+            oss << "Approx( " << m_value << " )";
+            return oss.str();
+        }
+
+    private:
+        double m_epsilon;
+        double m_scale;
+        double m_value;
+    };
+}
+
+template<>
+inline std::string toString<Detail::Approx>( const Detail::Approx& value ) {
+    return value.toString();
+}
+
+} // end namespace Catch
+
+// #included from: internal/catch_matchers.hpp
+#define TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED
+
+namespace Catch {
+namespace Matchers {
+    namespace Impl {
+
+    template<typename ExpressionT>
+    struct Matcher : SharedImpl<IShared>
+    {
+        typedef ExpressionT ExpressionType;
+
+        virtual ~Matcher() {}
+        virtual Ptr<Matcher> clone() const = 0;
+        virtual bool match( const ExpressionT& expr ) const = 0;
+        virtual std::string toString() const = 0;
+    };
+
+    template<typename DerivedT, typename ExpressionT>
+    struct MatcherImpl : Matcher<ExpressionT> {
+
+        virtual Ptr<Matcher<ExpressionT> > clone() const {
+            return Ptr<Matcher<ExpressionT> >( new DerivedT( static_cast<const DerivedT&>( *this ) ) );
+        }
+    };
+
+    namespace Generic {
+
+        template<typename ExpressionT>
+        class AllOf : public MatcherImpl<AllOf<ExpressionT>, ExpressionT> {
+        public:
+
+            AllOf() {}
+            AllOf( const AllOf& other ) : m_matchers( other.m_matchers ) {}
+
+            AllOf& add( const Matcher<ExpressionT>& matcher ) {
+                m_matchers.push_back( matcher.clone() );
+                return *this;
+            }
+            virtual bool match( const ExpressionT& expr ) const
+            {
+                for( std::size_t i = 0; i < m_matchers.size(); ++i )
+                    if( !m_matchers[i]->match( expr ) )
+                        return false;
+                return true;
+            }
+            virtual std::string toString() const {
+                std::ostringstream oss;
+                oss << "( ";
+                for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
+                    if( i != 0 )
+                        oss << " and ";
+                    oss << m_matchers[i]->toString();
+                }
+                oss << " )";
+                return oss.str();
+            }
+
+        private:
+            std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
+        };
+
+        template<typename ExpressionT>
+        class AnyOf : public MatcherImpl<AnyOf<ExpressionT>, ExpressionT> {
+        public:
+
+            AnyOf() {}
+            AnyOf( const AnyOf& other ) : m_matchers( other.m_matchers ) {}
+
+            AnyOf& add( const Matcher<ExpressionT>& matcher ) {
+                m_matchers.push_back( matcher.clone() );
+                return *this;
+            }
+            virtual bool match( const ExpressionT& expr ) const
+            {
+                for( std::size_t i = 0; i < m_matchers.size(); ++i )
+                    if( m_matchers[i]->match( expr ) )
+                        return true;
+                return false;
+            }
+            virtual std::string toString() const {
+                std::ostringstream oss;
+                oss << "( ";
+                for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
+                    if( i != 0 )
+                        oss << " or ";
+                    oss << m_matchers[i]->toString();
+                }
+                oss << " )";
+                return oss.str();
+            }
+
+        private:
+            std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
+        };
+
+    }
+
+    namespace StdString {
+
+        struct Equals : MatcherImpl<Equals, std::string> {
+            Equals( const std::string& str ) : m_str( str ){}
+            Equals( const Equals& other ) : m_str( other.m_str ){}
+
+            virtual ~Equals();
+
+            virtual bool match( const std::string& expr ) const {
+                return m_str == expr;
+            }
+            virtual std::string toString() const {
+                return "equals: \"" + m_str + "\"";
+            }
+
+            std::string m_str;
+        };
+
+        struct Contains : MatcherImpl<Contains, std::string> {
+            Contains( const std::string& substr ) : m_substr( substr ){}
+            Contains( const Contains& other ) : m_substr( other.m_substr ){}
+
+            virtual ~Contains();
+
+            virtual bool match( const std::string& expr ) const {
+                return expr.find( m_substr ) != std::string::npos;
+            }
+            virtual std::string toString() const {
+                return "contains: \"" + m_substr + "\"";
+            }
+
+            std::string m_substr;
+        };
+
+        struct StartsWith : MatcherImpl<StartsWith, std::string> {
+            StartsWith( const std::string& substr ) : m_substr( substr ){}
+            StartsWith( const StartsWith& other ) : m_substr( other.m_substr ){}
+
+            virtual ~StartsWith();
+
+            virtual bool match( const std::string& expr ) const {
+                return expr.find( m_substr ) == 0;
+            }
+            virtual std::string toString() const {
+                return "starts with: \"" + m_substr + "\"";
+            }
+
+            std::string m_substr;
+        };
+
+        struct EndsWith : MatcherImpl<EndsWith, std::string> {
+            EndsWith( const std::string& substr ) : m_substr( substr ){}
+            EndsWith( const EndsWith& other ) : m_substr( other.m_substr ){}
+
+            virtual ~EndsWith();
+
+            virtual bool match( const std::string& expr ) const {
+                return expr.find( m_substr ) == expr.size() - m_substr.size();
+            }
+            virtual std::string toString() const {
+                return "ends with: \"" + m_substr + "\"";
+            }
+
+            std::string m_substr;
+        };
+    } // namespace StdString
+    } // namespace Impl
+
+    // The following functions create the actual matcher objects.
+    // This allows the types to be inferred
+    template<typename ExpressionT>
+    inline Impl::Generic::AllOf<ExpressionT> AllOf( const Impl::Matcher<ExpressionT>& m1,
+                                                    const Impl::Matcher<ExpressionT>& m2 ) {
+        return Impl::Generic::AllOf<ExpressionT>().add( m1 ).add( m2 );
+    }
+    template<typename ExpressionT>
+    inline Impl::Generic::AllOf<ExpressionT> AllOf( const Impl::Matcher<ExpressionT>& m1,
+                                                    const Impl::Matcher<ExpressionT>& m2,
+                                                    const Impl::Matcher<ExpressionT>& m3 ) {
+        return Impl::Generic::AllOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
+    }
+    template<typename ExpressionT>
+    inline Impl::Generic::AnyOf<ExpressionT> AnyOf( const Impl::Matcher<ExpressionT>& m1,
+                                                    const Impl::Matcher<ExpressionT>& m2 ) {
+        return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 );
+    }
+    template<typename ExpressionT>
+    inline Impl::Generic::AnyOf<ExpressionT> AnyOf( const Impl::Matcher<ExpressionT>& m1,
+                                                    const Impl::Matcher<ExpressionT>& m2,
+                                                    const Impl::Matcher<ExpressionT>& m3 ) {
+        return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
+    }
+
+    inline Impl::StdString::Equals      Equals( const std::string& str ){ return Impl::StdString::Equals( str ); }
+    inline Impl::StdString::Contains    Contains( const std::string& substr ){ return Impl::StdString::Contains( substr ); }
+    inline Impl::StdString::StartsWith  StartsWith( const std::string& substr ){ return Impl::StdString::StartsWith( substr ); }
+    inline Impl::StdString::EndsWith    EndsWith( const std::string& substr ){ return Impl::StdString::EndsWith( substr ); }
+
+} // namespace Matchers
+
+using namespace Matchers;
+
+} // namespace Catch
+
+// These files are included here so the single_include script doesn't put them
+// in the conditionally compiled sections
+// #included from: internal/catch_interfaces_runner.h
+#define TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED
+
+#include <string>
+
+namespace Catch {
+    class TestCaseInfo;
+
+    struct IRunner {
+        virtual ~IRunner();
+    };
+}
+
+
+#ifdef __OBJC__
+// #included from: internal/catch_objc.hpp
+#define TWOBLUECUBES_CATCH_OBJC_HPP_INCLUDED
+
+#import <objc/runtime.h>
+
+#include <string>
+
+// NB. Any general catch headers included here must be included
+// in catch.hpp first to make sure they are included by the single
+// header for non obj-usage
+
+///////////////////////////////////////////////////////////////////////////////
+// This protocol is really only here for (self) documenting purposes, since
+// all its methods are optional.
+@protocol OcFixture
+
+@optional
+
+-(void) setUp;
+-(void) tearDown;
+
+@end
+
+namespace Catch {
+
+    class OcMethod : public SharedImpl<ITestCase> {
+
+    public:
+        OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {}
+
+        virtual void invoke() const {
+            id obj = [[m_cls alloc] init];
+
+            performOptionalSelector( obj, @selector(setUp)  );
+            performOptionalSelector( obj, m_sel );
+            performOptionalSelector( obj, @selector(tearDown)  );
+
+            arcSafeRelease( obj );
+        }
+    private:
+        virtual ~OcMethod() {}
+
+        Class m_cls;
+        SEL m_sel;
+    };
+
+    namespace Detail{
+
+        inline bool startsWith( const std::string& str, const std::string& sub ) {
+            return str.length() > sub.length() && str.substr( 0, sub.length() ) == sub;
+        }
+
+        inline std::string getAnnotation(   Class cls,
+                                            const std::string& annotationName,
+                                            const std::string& testCaseName ) {
+            NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()];
+            SEL sel = NSSelectorFromString( selStr );
+            arcSafeRelease( selStr );
+            id value = performOptionalSelector( cls, sel );
+            if( value )
+                return [(NSString*)value UTF8String];
+            return "";
+        }
+    }
+
+    inline size_t registerTestMethods() {
+        size_t noTestMethods = 0;
+        int noClasses = objc_getClassList( NULL, 0 );
+
+        Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses);
+        objc_getClassList( classes, noClasses );
+
+        for( int c = 0; c < noClasses; c++ ) {
+            Class cls = classes[c];
+            {
+                u_int count;
+                Method* methods = class_copyMethodList( cls, &count );
+                for( u_int m = 0; m < count ; m++ ) {
+                    SEL selector = method_getName(methods[m]);
+                    std::string methodName = sel_getName(selector);
+                    if( Detail::startsWith( methodName, "Catch_TestCase_" ) ) {
+                        std::string testCaseName = methodName.substr( 15 );
+                        std::string name = Detail::getAnnotation( cls, "Name", testCaseName );
+                        std::string desc = Detail::getAnnotation( cls, "Description", testCaseName );
+                        const char* className = class_getName( cls );
+
+                        getMutableRegistryHub().registerTest( TestCaseInfo( new OcMethod( cls, selector ), className, name.c_str(), desc.c_str(), SourceLineInfo() ) );
+                        noTestMethods++;
+                    }
+                }
+                free(methods);
+            }
+        }
+        return noTestMethods;
+    }
+
+    namespace Matchers {
+        namespace Impl {
+        namespace NSStringMatchers {
+
+            template<typename MatcherT>
+            struct StringHolder : MatcherImpl<MatcherT, NSString*>{
+                StringHolder( NSString* substr ) : m_substr( [substr copy] ){}
+                StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){}
+                StringHolder() {
+                    arcSafeRelease( m_substr );
+                }
+
+                NSString* m_substr;
+            };
+
+            struct Equals : StringHolder<Equals> {
+                Equals( NSString* substr ) : StringHolder( substr ){}
+
+                virtual bool match( ExpressionType const& str ) const {
+                    return [str isEqualToString:m_substr];
+                }
+
+                virtual std::string toString() const {
+                    return "equals string: \"" + Catch::toString( m_substr ) + "\"";
+                }
+            };
+
+            struct Contains : StringHolder<Contains> {
+                Contains( NSString* substr ) : StringHolder( substr ){}
+
+                virtual bool match( ExpressionType const& str ) const {
+                    return [str rangeOfString:m_substr].location != NSNotFound;
+                }
+
+                virtual std::string toString() const {
+                    return "contains string: \"" + Catch::toString( m_substr ) + "\"";
+                }
+            };
+
+            struct StartsWith : StringHolder<StartsWith> {
+                StartsWith( NSString* substr ) : StringHolder( substr ){}
+
+                virtual bool match( ExpressionType const& str ) const {
+                    return [str rangeOfString:m_substr].location == 0;
+                }
+
+                virtual std::string toString() const {
+                    return "starts with: \"" + Catch::toString( m_substr ) + "\"";
+                }
+            };
+            struct EndsWith : StringHolder<EndsWith> {
+                EndsWith( NSString* substr ) : StringHolder( substr ){}
+
+                virtual bool match( ExpressionType const& str ) const {
+                    return [str rangeOfString:m_substr].location == [str length] - [m_substr length];
+                }
+
+                virtual std::string toString() const {
+                    return "ends with: \"" + Catch::toString( m_substr ) + "\"";
+                }
+            };
+
+        } // namespace NSStringMatchers
+        } // namespace Impl
+
+        inline Impl::NSStringMatchers::Equals
+            Equals( NSString* substr ){ return Impl::NSStringMatchers::Equals( substr ); }
+
+        inline Impl::NSStringMatchers::Contains
+            Contains( NSString* substr ){ return Impl::NSStringMatchers::Contains( substr ); }
+
+        inline Impl::NSStringMatchers::StartsWith
+            StartsWith( NSString* substr ){ return Impl::NSStringMatchers::StartsWith( substr ); }
+
+        inline Impl::NSStringMatchers::EndsWith
+            EndsWith( NSString* substr ){ return Impl::NSStringMatchers::EndsWith( substr ); }
+
+    } // namespace Matchers
+
+    using namespace Matchers;
+
+} // namespace Catch
+
+///////////////////////////////////////////////////////////////////////////////
+#define OC_TEST_CASE( name, desc )\
++(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Name_test ) \
+{\
+return @ name; \
+}\
++(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Description_test ) \
+{ \
+return @ desc; \
+} \
+-(void) INTERNAL_CATCH_UNIQUE_NAME( Catch_TestCase_test )
+
+#endif
+
+#if defined( CATCH_CONFIG_MAIN ) || defined( CATCH_CONFIG_RUNNER )
+// #included from: internal/catch_impl.hpp
+#define TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED
+
+// Collect all the implementation files together here
+// These are the equivalent of what would usually be cpp files
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wweak-vtables"
+#endif
+
+// #included from: catch_runner.hpp
+#define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED
+
+// #included from: internal/catch_commandline.hpp
+#define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED
+
+namespace Catch {
+
+    class Command {
+    public:
+        Command(){}
+
+        explicit Command( const std::string& name ) : m_name( name ) {
+        }
+
+        Command& operator += ( const std::string& arg ) {
+            m_args.push_back( arg );
+            return *this;
+        }
+        Command& operator += ( const Command& other ) {
+            std::copy( other.m_args.begin(), other.m_args.end(), std::back_inserter( m_args ) );
+            if( m_name.empty() )
+                m_name = other.m_name;
+            return *this;
+        }
+        Command operator + ( const Command& other ) {
+            Command newCommand( *this );
+            newCommand += other;
+            return newCommand;
+        }
+
+        operator SafeBool::type() const {
+            return SafeBool::makeSafe( !m_name.empty() || !m_args.empty() );
+        }
+
+        std::string name() const { return m_name; }
+        std::string operator[]( std::size_t i ) const { return m_args[i]; }
+        std::size_t argsCount() const { return m_args.size(); }
+
+        CATCH_ATTRIBUTE_NORETURN
+        void raiseError( const std::string& message ) const {
+            std::ostringstream oss;
+            if( m_name.empty() )
+                oss << "Error while parsing " << m_name << ". " << message << ".";
+            else
+                oss << "Error while parsing arguments. " << message << ".";
+
+            if( m_args.size() > 0 )
+                oss << " Arguments were:";
+            for( std::size_t i = 0; i < m_args.size(); ++i )
+                oss << " " << m_args[i];
+            throw std::domain_error( oss.str() );
+        }
+
+    private:
+
+        std::string m_name;
+        std::vector<std::string> m_args;
+    };
+
+    class CommandParser {
+    public:
+        CommandParser( int argc, char const * const * argv ) : m_argc( static_cast<std::size_t>( argc ) ), m_argv( argv ) {}
+
+        std::string exeName() const {
+            return m_argv[0];
+        }
+        Command find( const std::string& arg1,  const std::string& arg2, const std::string& arg3 ) const {
+            return find( arg1 ) + find( arg2 ) + find( arg3 );
+        }
+
+        Command find( const std::string& shortArg, const std::string& longArg ) const {
+            return find( shortArg ) + find( longArg );
+        }
+        Command find( const std::string& arg ) const {
+            if( arg.empty() )
+                return getArgs( "", 1 );
+            else
+                for( std::size_t i = 1; i < m_argc; ++i  )
+                    if( m_argv[i] == arg )
+                        return getArgs( m_argv[i], i+1 );
+            return Command();
+        }
+        Command getDefaultArgs() const {
+            return getArgs( "", 1 );
+        }
+
+    private:
+        Command getArgs( const std::string& cmdName, std::size_t from ) const {
+            Command command( cmdName );
+            for( std::size_t i = from; i < m_argc && m_argv[i][0] != '-'; ++i  )
+                command += m_argv[i];
+            return command;
+        }
+
+        std::size_t m_argc;
+        char const * const * m_argv;
+    };
+
+    class OptionParser : public SharedImpl<IShared> {
+    public:
+        OptionParser( int minArgs = 0, int maxArgs = 0 )
+        : m_minArgs( minArgs ), m_maxArgs( maxArgs )
+        {}
+
+        virtual ~OptionParser() {}
+
+        Command find( const CommandParser& parser ) const {
+            Command cmd;
+            for( std::vector<std::string>::const_iterator it = m_optionNames.begin();
+                it != m_optionNames.end();
+                ++it )
+                cmd += parser.find( *it );
+            return cmd;
+        }
+
+        void validateArgs( const Command& args ) const {
+            if(  tooFewArgs( args ) || tooManyArgs( args ) ) {
+                std::ostringstream oss;
+                if( m_maxArgs == -1 )
+                    oss <<"Expected at least " << pluralise( static_cast<std::size_t>( m_minArgs ), "argument" );
+                else if( m_minArgs == m_maxArgs )
+                    oss <<"Expected " << pluralise( static_cast<std::size_t>( m_minArgs ), "argument" );
+                else
+                    oss <<"Expected between " << m_minArgs << " and " << m_maxArgs << " argument";
+                args.raiseError( oss.str() );
+            }
+        }
+
+        void parseIntoConfig( const CommandParser& parser, ConfigData& config ) {
+            if( Command cmd = find( parser ) ) {
+                validateArgs( cmd );
+                parseIntoConfig( cmd, config );
+            }
+        }
+
+        virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) = 0;
+        virtual std::string argsSynopsis() const = 0;
+        virtual std::string optionSummary() const = 0;
+        virtual std::string optionDescription() const { return ""; }
+
+        std::string optionNames() const {
+            std::string names;
+            for(    std::vector<std::string>::const_iterator it = m_optionNames.begin();
+                    it != m_optionNames.end();
+                    ++it ) {
+                if( !it->empty() ) {
+                    if( !names.empty() )
+                        names += ", ";
+                    names += *it;
+                }
+                else {
+                    names = "[" + names;
+                }
+            }
+            if( names[0] == '[' )
+                names += "]";
+            return names;
+        }
+
+    protected:
+
+        bool tooFewArgs( const Command& args ) const {
+            return args.argsCount() < static_cast<std::size_t>( m_minArgs );
+        }
+        bool tooManyArgs( const Command& args ) const {
+            return m_maxArgs >= 0 && args.argsCount() > static_cast<std::size_t>( m_maxArgs );
+        }
+        std::vector<std::string> m_optionNames;
+        int m_minArgs;
+        int m_maxArgs;
+    };
+
+    namespace Options {
+
+        class HelpOptionParser : public OptionParser {
+        public:
+            HelpOptionParser() {
+                m_optionNames.push_back( "-?" );
+                m_optionNames.push_back( "-h" );
+                m_optionNames.push_back( "--help" );
+            }
+            virtual std::string argsSynopsis() const {
+                return "[<option for help on> ...]";
+            }
+            virtual std::string optionSummary() const {
+                return "Shows this usage summary, or help on a specific option, or options, if supplied";
+            }
+            virtual std::string optionDescription() const {
+                return "";
+            }
+
+            virtual void parseIntoConfig( const Command&, ConfigData& ) {
+                // Does not affect config
+            }
+        };
+
+        class TestCaseOptionParser : public OptionParser {
+        public:
+            TestCaseOptionParser() : OptionParser( 1, -1 ) {
+                m_optionNames.push_back( "-t" );
+                m_optionNames.push_back( "--test" );
+                m_optionNames.push_back( "" ); // default option
+            }
+            virtual std::string argsSynopsis() const {
+                return "<testspec> [<testspec>...]";
+            }
+            virtual std::string optionSummary() const {
+                return "Specifies which test case or cases to run";
+            }
+
+            // Lines are split at the nearest prior space char to the 80 char column.
+            // Tab chars are removed from the output but their positions are used to align
+            // subsequently wrapped lines
+            virtual std::string optionDescription() const {
+                return
+                    "This option allows one ore more test specs to be supplied. Each spec either fully "
+                    "specifies a test case or is a pattern containing wildcards to match a set of test "
+                    "cases. If this option is not provided then all test cases, except those prefixed "
+                    "by './' are run\n"
+                    "\n"
+                    "Specs must be enclosed in \"quotes\" if they contain spaces. If they do not "
+                    "contain spaces the quotes are optional.\n"
+                    "\n"
+                    "Wildcards consist of the * character at the beginning, end, or both and can substitute for "
+                    "any number of any characters (including none)\n"
+                    "\n"
+                    "If spec is prefixed with exclude: or the ~ character then the pattern matches an exclusion. "
+                    "This means that tests matching the pattern are excluded from the set - even if a prior "
+                    "inclusion spec included them. Subsequent inclusion specs will take precedence, however. "
+                    "Inclusions and exclusions are evaluated in left-to-right order.\n"
+                    "\n"
+                    "Examples:\n"
+                    "\n"
+                    "    -t thisTestOnly        \tMatches the test case called, 'thisTestOnly'\n"
+                    "    -t \"this test only\"    \tMatches the test case called, 'this test only'\n"
+                    "    -t these/*             \tMatches all cases starting with 'these/'\n"
+                    "    -t exclude:notThis     \tMatches all tests except, 'notThis'\n"
+                    "    -t ~notThis            \tMatches all tests except, 'notThis'\n"
+                    "    -t ~*private*          \tMatches all tests except those that contain 'private'\n"
+                    "    -t a/* ~a/b/* a/b/c    \tMatches all tests that start with 'a/', except those "
+                                                 "that start with 'a/b/', except 'a/b/c', which is included";
+            }
+
+            virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
+                std::string groupName;
+                for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
+                    if( i != 0 )
+                        groupName += " ";
+                    groupName += cmd[i];
+                }
+                TestCaseFilters filters( groupName );
+                for( std::size_t i = 0; i < cmd.argsCount(); ++i )
+                    filters.addFilter( TestCaseFilter( cmd[i] ) );
+                config.filters.push_back( filters );
+            }
+        };
+
+        class TagOptionParser : public OptionParser {
+        public:
+            TagOptionParser() : OptionParser( 1, -1 ) {
+                m_optionNames.push_back( "-g" );
+                m_optionNames.push_back( "--tag" );
+            }
+            virtual std::string argsSynopsis() const {
+                return "<tagspec> [,<tagspec>...]";
+            }
+            virtual std::string optionSummary() const {
+                return "Matches test cases against tags or tag patterns";
+            }
+
+            // Lines are split at the nearest prior space char to the 80 char column.
+            // Tab chars are removed from the output but their positions are used to align
+            // subsequently wrapped lines
+            virtual std::string optionDescription() const {
+                return
+                "This option allows one or more tags or tag patterns to be specified.\n"
+                "Each tag is enclosed in square brackets. A series of tags form an AND expression "
+                "wheras a comma seperated sequence forms an OR expression. e.g.:\n\n"
+                "    -g [one][two],[three]\n\n"
+                "This matches all tests tagged [one] and [two], as well as all tests tagged [three].\n\n"
+                "Tags can be negated with the ~ character. This removes matching tests from the set. e.g.:\n\n"
+                "    -g [one]~[two]\n\n"
+                "matches all tests tagged [one], except those also tagged [two]";
+            }
+
+            virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
+                std::string groupName;
+                for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
+                    if( i != 0 )
+                        groupName += " ";
+                    groupName += cmd[i];
+                }
+                TestCaseFilters filters( groupName );
+                for( std::size_t i = 0; i < cmd.argsCount(); ++i )
+                    filters.addTags( cmd[i] );
+                config.filters.push_back( filters );
+            }
+        };
+
+        class ListOptionParser : public OptionParser {
+        public:
+            ListOptionParser() : OptionParser( 0, 2 ) {
+                m_optionNames.push_back( "-l" );
+                m_optionNames.push_back( "--list" );
+            }
+            virtual std::string argsSynopsis() const {
+                return "[all | tests | reporters [xml]]";
+            }
+            virtual std::string optionSummary() const {
+                return "Lists available tests or reporters";
+            }
+
+            virtual std::string optionDescription() const {
+                return
+                    "With no arguments this option will list all registered tests - one per line.\n"
+                    "Supplying the xml argument formats the list as an xml document (which may be useful for "
+                    "consumption by other tools).\n"
+                    "Supplying the tests or reporters lists tests or reporters respectively - with descriptions.\n"
+                    "\n"
+                    "Examples:\n"
+                    "\n"
+                    "    -l\n"
+                    "    -l tests\n"
+                    "    -l reporters xml\n"
+                    "    -l xml";
+            }
+
+            virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
+                config.listSpec = List::TestNames;
+                if( cmd.argsCount() >= 1 ) {
+                    if( cmd[0] == "all" )
+                        config.listSpec = List::All;
+                    else if( cmd[0] == "tests" )
+                        config.listSpec = List::Tests;
+                    else if( cmd[0] == "reporters" )
+                        config.listSpec = List::Reports;
+                    else
+                        cmd.raiseError( "Expected [tests] or [reporters]" );
+                }
+                if( cmd.argsCount() >= 2 ) {
+                    if( cmd[1] == "xml" )
+                        config.listSpec = static_cast<List::What>( config.listSpec | List::AsXml );
+                    else if( cmd[1] == "text" )
+                        config.listSpec = static_cast<List::What>( config.listSpec | List::AsText );
+                    else
+                        cmd.raiseError( "Expected [xml] or [text]" );
+                }
+            }
+        };
+
+        class ReporterOptionParser : public OptionParser {
+        public:
+            ReporterOptionParser() : OptionParser( 1, 1 ) {
+                m_optionNames.push_back( "-r" );
+                m_optionNames.push_back( "--reporter" );
+            }
+            virtual std::string argsSynopsis() const {
+                return "<reporter name>";
+            }
+            virtual std::string optionSummary() const {
+                return "Specifies type of reporter";
+            }
+
+            virtual std::string optionDescription() const {
+                return
+                    "A reporter is an object that formats and structures the output of running "
+                    "tests, and potentially summarises the results. By default a basic reporter "
+                    "is used that writes IDE friendly results. CATCH comes bundled with some "
+                    "alternative reporters, but more can be added in client code.\n"
+                    "\n"
+                    "The bundled reporters are:\n"
+                    "    -r basic\n"
+                    "    -r xml\n"
+                    "    -r junit\n"
+                    "\n"
+                    "The JUnit reporter is an xml format that follows the structure of the JUnit "
+                    "XML Report ANT task, as consumed by a number of third-party tools, "
+                    "including Continuous Integration servers such as Jenkins.\n"
+                    "If not otherwise needed, the standard XML reporter is preferred as this is "
+                    "a streaming reporter, whereas the Junit reporter needs to hold all its "
+                    "results until the end so it can write the overall results into attributes "
+                    "of the root node.";
+            }
+
+            virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
+                config.reporter = cmd[0];
+            }
+        };
+
+        class OutputOptionParser : public OptionParser {
+        public:
+            OutputOptionParser() : OptionParser( 1, 1 ) {
+                m_optionNames.push_back( "-o" );
+                m_optionNames.push_back( "--out" );
+            }
+            virtual std::string argsSynopsis() const {
+                return "<file name>|<%stream name>";
+            }
+            virtual std::string optionSummary() const {
+                return "Sends output to a file or stream";
+            }
+            virtual std::string optionDescription() const {
+                return
+                    "Use this option to send all output to a file or a stream. By default output is "
+                    "sent to stdout (note that uses of stdout and stderr from within test cases are "
+                    "redirected and included in the report - so even stderr will effectively end up "
+                    "on stdout). If the name begins with % it is interpreted as a stream. "
+                    "Otherwise it is treated as a filename.\n"
+                    "\n"
+                    "Examples are:\n"
+                    "\n"
+                    "    -o filename.txt\n"
+                    "    -o \"long filename.txt\"\n"
+                    "    -o %stdout\n"
+                    "    -o %stderr\n"
+                    "    -o %debug    \t(The IDE's debug output window - currently only Windows' "
+                                        "OutputDebugString is supported).";
+            }
+            virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
+                if( cmd[0][0] == '%' )
+                    config.stream = cmd[0].substr( 1 );
+                else
+                    config.outputFilename = cmd[0];
+            }
+        };
+
+        class SuccessOptionParser : public OptionParser {
+        public:
+            SuccessOptionParser() {
+                m_optionNames.push_back( "-s" );
+                m_optionNames.push_back( "--success" );
+            }
+            virtual std::string argsSynopsis() const {
+                return "";
+            }
+            virtual std::string optionSummary() const {
+                return "Shows results for successful tests";
+            }
+            virtual std::string optionDescription() const {
+                return
+                    "Usually you only want to see reporting for failed tests. Sometimes it's useful "
+                    "to see all the output (especially when you don't trust that that test you just "
+                    "added worked first time!). To see successful, as well as failing, test results "
+                    "just pass this option.";
+            }
+            virtual void parseIntoConfig( const Command&, ConfigData& config ) {
+                config.includeWhichResults = Include::SuccessfulResults;
+            }
+        };
+
+        class DebugBreakOptionParser : public OptionParser {
+        public:
+            DebugBreakOptionParser() {
+                m_optionNames.push_back( "-b" );
+                m_optionNames.push_back( "--break" );
+            }
+            virtual std::string argsSynopsis() const {
+                return "";
+            }
+            virtual std::string optionSummary() const {
+                return "Breaks into the debugger on failure";
+            }
+            virtual std::string optionDescription() const {
+                return
+                    "In some IDEs (currently XCode and Visual Studio) it is possible for CATCH to "
+                    "break into the debugger on a test failure. This can be very helpful during "
+                    "debug sessions - especially when there is more than one path through a "
+                    "particular test. In addition to the command line option, ensure you have "
+                    "built your code with the DEBUG preprocessor symbol";
+            }
+
+            virtual void parseIntoConfig( const Command&, ConfigData& config ) {
+                config.shouldDebugBreak = true;
+            }
+        };
+
+        class NameOptionParser : public OptionParser {
+        public:
+            NameOptionParser() : OptionParser( 1, 1 ) {
+                m_optionNames.push_back( "-n" );
+                m_optionNames.push_back( "--name" );
+            }
+            virtual std::string argsSynopsis() const {
+                return "<name>";
+            }
+            virtual std::string optionSummary() const {
+                return "Names a test run";
+            }
+            virtual std::string optionDescription() const {
+                return
+                    "If a name is supplied it will be used by the reporter to provide an overall "
+                    "name for the test run. This can be useful if you are sending to a file, for "
+                    "example, and need to distinguish different test runs - either from different "
+                    "Catch executables or runs of the same executable with different options.\n"
+                    "\n"
+                    "Examples:\n"
+                    "\n"
+                    "    -n testRun\n"
+                    "    -n \"tests of the widget component\"";
+            }
+
+            virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
+                config.name = cmd[0];
+            }
+        };
+
+        class AbortOptionParser : public OptionParser {
+        public:
+            AbortOptionParser() : OptionParser( 0, 1 ) {
+                m_optionNames.push_back( "-a" );
+                m_optionNames.push_back( "--abort" );
+            }
+            virtual std::string argsSynopsis() const {
+                return "[#]";
+            }
+            virtual std::string optionSummary() const {
+                return "Aborts after a certain number of failures";
+            }
+            virtual std::string optionDescription() const {
+                return
+                    "If a REQUIRE assertion fails the test case aborts, but subsequent test cases "
+                    "are still run. If a CHECK assertion fails even the current test case is not "
+                    "aborted.\n"
+                    "\n"
+                    "Sometimes this results in a flood of failure messages and you'd rather just "
+                    "see the first few. Specifying -a or --abort on its own will abort the whole "
+                    "test run on the first failed assertion of any kind. Following it with a "
+                    "number causes it to abort after that number of assertion failures.";
+            }
+
+            virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
+                int threshold = 1;
+                if( cmd.argsCount() == 1 ) {
+                    std::stringstream ss;
+                    ss << cmd[0];
+                    ss >> threshold;
+                    if( ss.fail() || threshold <= 0 )
+                        cmd.raiseError( "threshold must be a number greater than zero" );
+                }
+                config.cutoff = threshold;
+            }
+        };
+
+        class NoThrowOptionParser : public OptionParser {
+        public:
+            NoThrowOptionParser() {
+                m_optionNames.push_back( "-nt" );
+                m_optionNames.push_back( "--nothrow" );
+            }
+            virtual std::string argsSynopsis() const {
+                return "";
+            }
+            virtual std::string optionSummary() const {
+                return "Elides assertions expected to throw";
+            }
+            virtual std::string optionDescription() const {
+                return
+                    "Skips all assertions that test that an exception is thrown, "
+                    "e.g. REQUIRE_THROWS.\n"
+                    "\n"
+                    "These can be a nuisance in certain debugging environments that may break when "
+                    "exceptions are thrown (while this is usually optional for handled exceptions, "
+                    "it can be useful to have enabled if you are trying to track down something "
+                    "unexpected).\n"
+                    "\n"
+                    "When running with this option the throw checking assertions are skipped so "
+                    "as not to contribute additional noise.";
+            }
+
+            virtual void parseIntoConfig( const Command&, ConfigData& config ) {
+                config.allowThrows = false;
+            }
+        };
+
+        class WarningsOptionParser : public OptionParser {
+        public:
+            WarningsOptionParser() : OptionParser( 1, -1 ) {
+                m_optionNames.push_back( "-w" );
+                m_optionNames.push_back( "--warnings" );
+            }
+            virtual std::string argsSynopsis() const {
+                return "<warning>";
+            }
+            virtual std::string optionSummary() const {
+                return "Enable warnings";
+            }
+            virtual std::string optionDescription() const {
+                return
+                    "Enables the named warnings. If the warnings are violated the test case is "
+                    "failed.\n"
+                    "\n"
+                    "At present only one warning has been provided: NoAssertions. If this warning "
+                    "is enabled then any test case that completes without an assertions (CHECK, "
+                    "REQUIRE etc) being encountered violates the warning.\n"
+                    "\n"
+                    "e.g.:\n"
+                    "\n"
+                    "    -w NoAssertions";
+            }
+
+            virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
+                for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
+                    if( cmd[i] == "NoAssertions" )
+                        config.warnings = (ConfigData::WarnAbout::What)( config.warnings | ConfigData::WarnAbout::NoAssertions );
+                    else
+                        cmd.raiseError( "Unrecognised warning: " + cmd[i] );
+                }
+            }
+        };
+    }
+
+    class AllOptions
+    {
+    public:
+        typedef std::vector<Ptr<OptionParser> > Parsers;
+        typedef Parsers::const_iterator const_iterator;
+        typedef Parsers::const_iterator iterator;
+
+        AllOptions() {
+            add<Options::TestCaseOptionParser>();   // Keep this one first
+
+            add<Options::TagOptionParser>();
+            add<Options::ListOptionParser>();
+            add<Options::ReporterOptionParser>();
+            add<Options::OutputOptionParser>();
+            add<Options::SuccessOptionParser>();
+            add<Options::DebugBreakOptionParser>();
+            add<Options::NameOptionParser>();
+            add<Options::AbortOptionParser>();
+            add<Options::NoThrowOptionParser>();
+            add<Options::WarningsOptionParser>();
+
+            add<Options::HelpOptionParser>();       // Keep this one last
+        }
+
+        void parseIntoConfig( const CommandParser& parser, ConfigData& config ) {
+            for( const_iterator it = m_parsers.begin(); it != m_parsers.end(); ++it )
+                (*it)->parseIntoConfig( parser, config );
+        }
+
+        const_iterator begin() const {
+            return m_parsers.begin();
+        }
+        const_iterator end() const {
+            return m_parsers.end();
+        }
+    private:
+
+        template<typename T>
+        void add() {
+            m_parsers.push_back( new T() );
+        }
+        Parsers m_parsers;
+
+    };
+
+} // end namespace Catch
+
+// #included from: internal/catch_list.hpp
+#define TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED
+
+#include <limits>
+
+namespace Catch {
+    inline bool matchesFilters( const std::vector<TestCaseFilters>& filters, const TestCaseInfo& testCase ) {
+        std::vector<TestCaseFilters>::const_iterator it = filters.begin();
+        std::vector<TestCaseFilters>::const_iterator itEnd = filters.end();
+        for(; it != itEnd; ++it )
+            if( !it->shouldInclude( testCase ) )
+                return false;
+        return true;
+    }
+    inline void List( const ConfigData& config ) {
+
+        if( config.listSpec & List::Reports ) {
+            std::cout << "Available reports:\n";
+            IReporterRegistry::FactoryMap::const_iterator it = getRegistryHub().getReporterRegistry().getFactories().begin();
+            IReporterRegistry::FactoryMap::const_iterator itEnd = getRegistryHub().getReporterRegistry().getFactories().end();
+            for(; it != itEnd; ++it ) {
+                // !TBD: consider listAs()
+                std::cout << "\t" << it->first << "\n\t\t'" << it->second->getDescription() << "'\n";
+            }
+            std::cout << std::endl;
+        }
+
+        if( config.listSpec & List::Tests ) {
+            if( config.filters.empty() )
+                std::cout << "All available test cases:\n";
+            else
+                std::cout << "Matching test cases:\n";
+            std::vector<TestCaseInfo>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin();
+            std::vector<TestCaseInfo>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end();
+            std::size_t matchedTests = 0;
+            for(; it != itEnd; ++it ) {
+                if( matchesFilters( config.filters, *it ) ) {
+                    matchedTests++;
+                    // !TBD: consider listAs()
+                    std::cout << "\t" << it->getName() << "\n";
+                    if( ( config.listSpec & List::TestNames ) != List::TestNames )
+                        std::cout << "\t\t '" << it->getDescription() << "'\n";
+                }
+            }
+            if( config.filters.empty() )
+                std::cout << pluralise( matchedTests, "test case" ) << std::endl;
+            else
+                std::cout << pluralise( matchedTests, "matching test case" ) << std::endl;
+        }
+
+        if( ( config.listSpec & List::All ) == 0 ) {
+            std::ostringstream oss;
+            oss << "Unknown list type";
+            throw std::domain_error( oss.str() );
+        }
+    }
+
+} // end namespace Catch
+
+// #included from: internal/catch_runner_impl.hpp
+#define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
+
+// #included from: catch_running_test.hpp
+#define TWOBLUECUBES_CATCH_RUNNING_TEST_HPP_INCLUDED
+
+// #included from: catch_section_info.hpp
+#define TWOBLUECUBES_CATCH_SECTION_INFO_HPP_INCLUDED
+
+#include <map>
+#include <string>
+
+namespace Catch {
+
+    class SectionInfo {
+    public:
+
+        enum Status {
+            Root,
+            Unknown,
+            Branch,
+            TestedBranch,
+            TestedLeaf
+        };
+
+        SectionInfo( SectionInfo* parent )
+        :   m_status( Unknown ),
+            m_parent( parent )
+        {}
+
+        SectionInfo()
+        :   m_status( Root ),
+            m_parent( NULL )
+        {}
+
+        ~SectionInfo() {
+            deleteAllValues( m_subSections );
+        }
+
+        bool shouldRun() const {
+            return m_status < TestedBranch;
+        }
+
+        bool ran() {
+            if( m_status < Branch ) {
+                m_status = TestedLeaf;
+                return true;
+            }
+            return false;
+        }
+
+        bool isBranch() const {
+            return m_status == Branch;
+        }
+
+        void ranToCompletion() {
+            if( m_status == Branch && !hasUntestedSections() )
+                m_status = TestedBranch;
+        }
+
+        SectionInfo* findSubSection( const std::string& name ) {
+            std::map<std::string, SectionInfo*>::const_iterator it = m_subSections.find( name );
+            return it != m_subSections.end()
+                        ? it->second
+                        : NULL;
+        }
+
+        SectionInfo* addSubSection( const std::string& name ) {
+            SectionInfo* subSection = new SectionInfo( this );
+            m_subSections.insert( std::make_pair( name, subSection ) );
+            m_status = Branch;
+            return subSection;
+        }
+
+        SectionInfo* getParent() {
+            return m_parent;
+        }
+
+        bool hasUntestedSections() const {
+            if( m_status == Unknown )
+                return true;
+
+            std::map<std::string, SectionInfo*>::const_iterator it = m_subSections.begin();
+            std::map<std::string, SectionInfo*>::const_iterator itEnd = m_subSections.end();
+            for(; it != itEnd; ++it ) {
+                if( it->second->hasUntestedSections() )
+                    return true;
+            }
+            return false;
+        }
+
+    private:
+        Status m_status;
+        std::map<std::string, SectionInfo*> m_subSections;
+        SectionInfo* m_parent;
+    };
+}
+
+namespace Catch {
+
+    class RunningTest {
+
+        enum RunStatus {
+            NothingRun,
+            EncounteredASection,
+            RanAtLeastOneSection,
+            RanToCompletionWithSections,
+            RanToCompletionWithNoSections
+        };
+
+    public:
+        explicit RunningTest( const TestCaseInfo* info = NULL )
+        :   m_info( info ),
+            m_runStatus( RanAtLeastOneSection ),
+            m_currentSection( &m_rootSection ),
+            m_changed( false )
+        {}
+
+        bool wasSectionSeen() const {
+            return  m_runStatus == RanAtLeastOneSection ||
+                    m_runStatus == RanToCompletionWithSections;
+        }
+
+        bool isBranchSection() const {
+            return  m_currentSection &&
+                    m_currentSection->isBranch();
+        }
+
+        bool hasSections() const {
+            return  m_runStatus == RanAtLeastOneSection ||
+                    m_runStatus == RanToCompletionWithSections ||
+                    m_runStatus == EncounteredASection;
+        }
+
+        void reset() {
+            m_runStatus = NothingRun;
+            m_changed = false;
+            m_lastSectionToRun = NULL;
+        }
+
+        void ranToCompletion() {
+            if( m_runStatus == RanAtLeastOneSection ||
+                m_runStatus == EncounteredASection ) {
+                m_runStatus = RanToCompletionWithSections;
+                if( m_lastSectionToRun ) {
+                    m_lastSectionToRun->ranToCompletion();
+                    m_changed = true;
+                }
+            }
+            else {
+                m_runStatus = RanToCompletionWithNoSections;
+            }
+        }
+
+        bool addSection( const std::string& name ) {
+            if( m_runStatus == NothingRun )
+                m_runStatus = EncounteredASection;
+
+            SectionInfo* thisSection = m_currentSection->findSubSection( name );
+            if( !thisSection ) {
+                thisSection = m_currentSection->addSubSection( name );
+                m_changed = true;
+            }
+
+            if( !wasSectionSeen() && thisSection->shouldRun() ) {
+                m_currentSection = thisSection;
+                m_lastSectionToRun = NULL;
+                return true;
+            }
+            return false;
+        }
+
+        void endSection( const std::string& ) {
+            if( m_currentSection->ran() ) {
+                m_runStatus = RanAtLeastOneSection;
+                m_changed = true;
+            }
+            else if( m_runStatus == EncounteredASection ) {
+                m_runStatus = RanAtLeastOneSection;
+                m_lastSectionToRun = m_currentSection;
+            }
+            m_currentSection = m_currentSection->getParent();
+        }
+
+        const TestCaseInfo& getTestCaseInfo() const {
+            return *m_info;
+        }
+
+        bool hasUntestedSections() const {
+            return  m_runStatus == RanAtLeastOneSection ||
+                    ( m_rootSection.hasUntestedSections() && m_changed );
+        }
+
+    private:
+        const TestCaseInfo* m_info;
+        RunStatus m_runStatus;
+        SectionInfo m_rootSection;
+        SectionInfo* m_currentSection;
+        SectionInfo* m_lastSectionToRun;
+        bool m_changed;
+    };
+}
+
+#include <set>
+#include <string>
+
+namespace Catch {
+
+    class StreamRedirect {
+
+    public:
+        StreamRedirect( std::ostream& stream, std::string& targetString )
+        :   m_stream( stream ),
+            m_prevBuf( stream.rdbuf() ),
+            m_targetString( targetString )
+        {
+            stream.rdbuf( m_oss.rdbuf() );
+        }
+
+        ~StreamRedirect() {
+            m_targetString += m_oss.str();
+            m_stream.rdbuf( m_prevBuf );
+        }
+
+    private:
+        std::ostream& m_stream;
+        std::streambuf* m_prevBuf;
+        std::ostringstream m_oss;
+        std::string& m_targetString;
+    };
+
+    ///////////////////////////////////////////////////////////////////////////
+
+    class Runner : public IResultCapture, public IRunner {
+
+        Runner( const Runner& );
+        void operator =( const Runner& );
+
+    public:
+
+        explicit Runner( const Config& config, const Ptr<IReporter>& reporter )
+        :   m_context( getCurrentMutableContext() ),
+            m_runningTest( NULL ),
+            m_config( config ),
+            m_reporter( reporter ),
+            m_prevRunner( &m_context.getRunner() ),
+            m_prevResultCapture( &m_context.getResultCapture() ),
+            m_prevConfig( m_context.getConfig() )
+        {
+            m_context.setRunner( this );
+            m_context.setConfig( &m_config );
+            m_context.setResultCapture( this );
+            m_reporter->StartTesting();
+        }
+
+        virtual ~Runner() {
+            m_reporter->EndTesting( m_totals );
+            m_context.setRunner( m_prevRunner );
+            m_context.setConfig( NULL );
+            m_context.setResultCapture( m_prevResultCapture );
+            m_context.setConfig( m_prevConfig );
+        }
+
+        Totals runMatching( const std::string& testSpec ) {
+
+            std::vector<TestCaseInfo> matchingTests = getRegistryHub().getTestCaseRegistry().getMatchingTestCases( testSpec );
+
+            Totals totals;
+
+            m_reporter->StartGroup( testSpec );
+
+            std::vector<TestCaseInfo>::const_iterator it = matchingTests.begin();
+            std::vector<TestCaseInfo>::const_iterator itEnd = matchingTests.end();
+            for(; it != itEnd; ++it )
+                totals += runTest( *it );
+            // !TBD use std::accumulate?
+
+            m_reporter->EndGroup( testSpec, totals );
+            return totals;
+        }
+
+        Totals runTest( const TestCaseInfo& testInfo ) {
+            Totals prevTotals = m_totals;
+
+            std::string redirectedCout;
+            std::string redirectedCerr;
+
+            m_reporter->StartTestCase( testInfo );
+
+            m_runningTest = new RunningTest( &testInfo );
+
+            do {
+                do {
+                    runCurrentTest( redirectedCout, redirectedCerr );
+                }
+                while( m_runningTest->hasUntestedSections() && !aborting() );
+            }
+            while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
+
+            delete m_runningTest;
+            m_runningTest = NULL;
+
+            Totals deltaTotals = m_totals.delta( prevTotals );
+            m_totals.testCases += deltaTotals.testCases;
+            m_reporter->EndTestCase( testInfo, deltaTotals, redirectedCout, redirectedCerr );
+            return deltaTotals;
+        }
+
+        const Config& config() const {
+            return m_config;
+        }
+
+    private: // IResultCapture
+
+        virtual ResultAction::Value acceptExpression( const ExpressionResultBuilder& assertionResult, const AssertionInfo& assertionInfo ) {
+            m_lastAssertionInfo = assertionInfo;
+            return actOnCurrentResult( assertionResult.buildResult( assertionInfo ) );
+        }
+
+        virtual void testEnded( const AssertionResult& result ) {
+            if( result.getResultType() == ResultWas::Ok ) {
+                m_totals.assertions.passed++;
+            }
+            else if( !result.isOk() ) {
+                m_totals.assertions.failed++;
+
+                {
+                    std::vector<ScopedInfo*>::const_iterator it = m_scopedInfos.begin();
+                    std::vector<ScopedInfo*>::const_iterator itEnd = m_scopedInfos.end();
+                    for(; it != itEnd; ++it )
+                        m_reporter->Result( (*it)->buildResult( m_lastAssertionInfo ) );
+                }
+                {
+                    std::vector<AssertionResult>::const_iterator it = m_assertionResults.begin();
+                    std::vector<AssertionResult>::const_iterator itEnd = m_assertionResults.end();
+                    for(; it != itEnd; ++it )
+                        m_reporter->Result( *it );
+                }
+                m_assertionResults.clear();
+            }
+
+            if( result.getResultType() == ResultWas::Info )
+                m_assertionResults.push_back( result );
+            else
+                m_reporter->Result( result );
+        }
+
+        virtual bool sectionStarted (
+            const std::string& name,
+            const std::string& description,
+            const SourceLineInfo& lineInfo,
+            Counts& assertions
+        )
+        {
+            std::ostringstream oss;
+            oss << name << "@" << lineInfo;
+
+            if( !m_runningTest->addSection( oss.str() ) )
+                return false;
+
+            m_lastAssertionInfo.lineInfo = lineInfo;
+
+            m_reporter->StartSection( name, description );
+            assertions = m_totals.assertions;
+
+            return true;
+        }
+
+        virtual void sectionEnded( const std::string& name, const Counts& prevAssertions ) {
+            Counts assertions = m_totals.assertions - prevAssertions;
+            if( assertions.total() == 0  &&
+               ( m_config.data().warnings & ConfigData::WarnAbout::NoAssertions ) &&
+               !m_runningTest->isBranchSection() ) {
+                m_reporter->NoAssertionsInSection( name );
+                m_totals.assertions.failed++;
+                assertions.failed++;
+            }
+            m_runningTest->endSection( name );
+            m_reporter->EndSection( name, assertions );
+        }
+
+        virtual void pushScopedInfo( ScopedInfo* scopedInfo ) {
+            m_scopedInfos.push_back( scopedInfo );
+        }
+
+        virtual void popScopedInfo( ScopedInfo* scopedInfo ) {
+            if( m_scopedInfos.back() == scopedInfo )
+                m_scopedInfos.pop_back();
+        }
+
+        virtual bool shouldDebugBreak() const {
+            return m_config.shouldDebugBreak();
+        }
+
+        virtual std::string getCurrentTestName() const {
+            return m_runningTest
+                ? m_runningTest->getTestCaseInfo().getName()
+                : "";
+        }
+
+        virtual const AssertionResult* getLastResult() const {
+            return &m_lastResult;
+        }
+
+    public:
+        // !TBD We need to do this another way!
+        bool aborting() const {
+            return m_totals.assertions.failed == static_cast<std::size_t>( m_config.getCutoff() );
+        }
+
+    private:
+
+        ResultAction::Value actOnCurrentResult( const AssertionResult& result ) {
+            m_lastResult = result;
+            testEnded( m_lastResult );
+
+            ResultAction::Value action = ResultAction::None;
+
+            if( !m_lastResult.isOk() ) {
+                action = ResultAction::Failed;
+                if( shouldDebugBreak() )
+                    action = (ResultAction::Value)( action | ResultAction::Debug );
+                if( aborting() )
+                    action = (ResultAction::Value)( action | ResultAction::Abort );
+            }
+            return action;
+        }
+
+        void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) {
+            try {
+                m_lastAssertionInfo = AssertionInfo( "TEST_CASE", m_runningTest->getTestCaseInfo().getLineInfo(), "", ResultDisposition::Normal );
+                m_runningTest->reset();
+                Counts prevAssertions = m_totals.assertions;
+                if( m_reporter->shouldRedirectStdout() ) {
+                    StreamRedirect coutRedir( std::cout, redirectedCout );
+                    StreamRedirect cerrRedir( std::cerr, redirectedCerr );
+                    m_runningTest->getTestCaseInfo().invoke();
+                }
+                else {
+                    m_runningTest->getTestCaseInfo().invoke();
+                }
+                Counts assertions = m_totals.assertions - prevAssertions;
+                if( assertions.total() == 0  &&
+                   ( m_config.data().warnings & ConfigData::WarnAbout::NoAssertions ) &&
+                   !m_runningTest->hasSections() ) {
+                        m_totals.assertions.failed++;
+                        m_reporter->NoAssertionsInTestCase( m_runningTest->getTestCaseInfo().getName() );
+                }
+                m_runningTest->ranToCompletion();
+            }
+            catch( TestFailureException& ) {
+                // This just means the test was aborted due to failure
+            }
+            catch(...) {
+                ExpressionResultBuilder exResult( ResultWas::ThrewException );
+                exResult << translateActiveException();
+                actOnCurrentResult( exResult.buildResult( m_lastAssertionInfo )  );
+            }
+            m_assertionResults.clear();
+        }
+
+    private:
+        IMutableContext& m_context;
+        RunningTest* m_runningTest;
+        AssertionResult m_lastResult;
+
+        const Config& m_config;
+        Totals m_totals;
+        Ptr<IReporter> m_reporter;
+        std::vector<ScopedInfo*> m_scopedInfos;
+        std::vector<AssertionResult> m_assertionResults;
+        IRunner* m_prevRunner;
+        IResultCapture* m_prevResultCapture;
+        const IConfig* m_prevConfig;
+        AssertionInfo m_lastAssertionInfo;
+    };
+
+} // end namespace Catch
+
+#include <fstream>
+#include <stdlib.h>
+#include <limits>
+
+namespace Catch {
+
+    class Runner2 { // This will become Runner when Runner becomes Context
+
+    public:
+        Runner2( Config& configWrapper )
+        :   m_configWrapper( configWrapper ),
+            m_config( configWrapper.data() )
+        {
+            openStream();
+            makeReporter();
+        }
+
+        Totals runTests() {
+
+            std::vector<TestCaseFilters> filterGroups = m_config.filters;
+            if( filterGroups.empty() ) {
+                TestCaseFilters filterGroup( "" );
+                filterGroups.push_back( filterGroup );
+            }
+
+            Runner context( m_configWrapper, m_reporter ); // This Runner will be renamed Context
+            Totals totals;
+
+            std::vector<TestCaseFilters>::const_iterator it = filterGroups.begin();
+            std::vector<TestCaseFilters>::const_iterator itEnd = filterGroups.end();
+            for(; it != itEnd && !context.aborting(); ++it ) {
+                m_reporter->StartGroup( it->getName() );
+                totals += runTestsForGroup( context, *it );
+                if( context.aborting() )
+                    m_reporter->Aborted();
+                m_reporter->EndGroup( it->getName(), totals );
+            }
+            return totals;
+        }
+
+        Totals runTestsForGroup( Runner& context, const TestCaseFilters& filterGroup ) {
+            Totals totals;
+            std::vector<TestCaseInfo>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin();
+            std::vector<TestCaseInfo>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end();
+            int testsRunForGroup = 0;
+            for(; it != itEnd; ++it ) {
+                if( filterGroup.shouldInclude( *it ) ) {
+                    testsRunForGroup++;
+                    if( m_testsAlreadyRun.find( *it ) == m_testsAlreadyRun.end() ) {
+
+                        if( context.aborting() )
+                            break;
+
+                        totals += context.runTest( *it );
+                        m_testsAlreadyRun.insert( *it );
+                    }
+                }
+            }
+            if( testsRunForGroup == 0 )
+                std::cerr << "\n[No test cases matched with: " << filterGroup.getName() << "]" << std::endl;
+            return totals;
+
+        }
+
+    private:
+        void openStream() {
+            if( !m_config.stream.empty() )
+                m_configWrapper.useStream( m_config.stream );
+
+            // Open output file, if specified
+            if( !m_config.outputFilename.empty() ) {
+                m_ofs.open( m_config.outputFilename.c_str() );
+                if( m_ofs.fail() ) {
+                    std::ostringstream oss;
+                    oss << "Unable to open file: '" << m_config.outputFilename << "'";
+                    throw std::domain_error( oss.str() );
+                }
+                m_configWrapper.setStreamBuf( m_ofs.rdbuf() );
+            }
+        }
+        void makeReporter() {
+            std::string reporterName = m_config.reporter.empty()
+            ? "basic"
+            : m_config.reporter;
+
+            ReporterConfig reporterConfig( m_config.name, m_configWrapper.stream(), m_config.includeWhichResults == Include::SuccessfulResults, m_config );
+
+            m_reporter = getRegistryHub().getReporterRegistry().create( reporterName, reporterConfig );
+            if( !m_reporter ) {
+                std::ostringstream oss;
+                oss << "No reporter registered with name: '" << reporterName << "'";
+                throw std::domain_error( oss.str() );
+            }
+        }
+
+    private:
+        Config& m_configWrapper;
+        const ConfigData& m_config;
+        std::ofstream m_ofs;
+        Ptr<IReporter> m_reporter;
+        std::set<TestCaseInfo> m_testsAlreadyRun;
+    };
+
+    inline int Main( Config& configWrapper ) {
+        int result = 0;
+        try
+        {
+            Runner2 runner( configWrapper );
+
+            const ConfigData& config = configWrapper.data();
+
+            // Handle list request
+            if( config.listSpec != List::None ) {
+                List( config );
+                Catch::cleanUp();
+                return 0;
+            }
+
+            result = static_cast<int>( runner.runTests().assertions.failed );
+
+        }
+        catch( std::exception& ex ) {
+            std::cerr << ex.what() << std::endl;
+            result = (std::numeric_limits<int>::max)();
+        }
+
+        Catch::cleanUp();
+        return result;
+    }
+
+    inline void showUsage( std::ostream& os ) {
+        AllOptions options;
+
+        for( AllOptions::const_iterator it = options.begin(); it != options.end(); ++it ) {
+            OptionParser& opt = **it;
+            os << "  " << opt.optionNames() << " " << opt.argsSynopsis() << "\n";
+        }
+        os << "\nFor more detail usage please see: https://github.com/philsquared/Catch/wiki/Command-line\n" << std::endl;
+    }
+
+    inline void addIndent( std::ostream& os, std::size_t indent ) {
+        while( indent-- > 0 )
+            os << ' ';
+    }
+
+    inline void recursivelyWrapLine( std::ostream& os, std::string paragraph, std::size_t columns, std::size_t indent ) {
+        std::size_t width = columns-indent;
+        std::size_t tab = 0;
+        std::size_t wrapPoint = width;
+        for( std::size_t pos = 0; pos < paragraph.size(); ++pos ) {
+            if( pos == width ) {
+                addIndent( os, indent );
+                os << paragraph.substr( 0, wrapPoint ) << "\n";
+                return recursivelyWrapLine( os, paragraph.substr( wrapPoint+1 ), columns, indent+tab );
+            }
+            if( paragraph[pos] == '\t' ) {
+                    tab = pos;
+                    paragraph = paragraph.substr( 0, tab ) + paragraph.substr( tab+1 );
+                    pos--;
+            }
+            else if( paragraph[pos] == ' ' ) {
+                wrapPoint = pos;
+            }
+        }
+        addIndent( os, indent );
+        os << paragraph << "\n";
+    }
+
+    inline std::string addLineBreaks( const std::string& str, std::size_t columns, std::size_t indent = 0 ) {
+        std::ostringstream oss;
+        std::string::size_type pos = 0;
+        std::string::size_type newline = str.find_first_of( '\n' );
+        while( newline != std::string::npos ) {
+            std::string paragraph = str.substr( pos, newline-pos );
+            recursivelyWrapLine( oss, paragraph, columns, indent );
+            pos = newline+1;
+            newline = str.find_first_of( '\n', pos );
+        }
+        if( pos != str.size() )
+            recursivelyWrapLine( oss, str.substr( pos, str.size()-pos ), columns, indent );
+
+        return oss.str();
+    }
+
+    inline void showHelp( const CommandParser& parser ) {
+        std::string exeName = parser.exeName();
+        std::string::size_type pos = exeName.find_last_of( "/\\" );
+        if( pos != std::string::npos ) {
+            exeName = exeName.substr( pos+1 );
+        }
+
+        AllOptions options;
+        Options::HelpOptionParser helpOpt;
+        bool displayedSpecificOption = false;
+        for( AllOptions::const_iterator it = options.begin(); it != options.end(); ++it ) {
+            OptionParser& opt = **it;
+            if( opt.find( parser ) && opt.optionNames() != helpOpt.optionNames() ) {
+                displayedSpecificOption = true;
+                std::cout   << "\n" << opt.optionNames() << " " << opt.argsSynopsis() << "\n\n"
+                            << opt.optionSummary() << "\n\n"
+
+                << addLineBreaks( opt.optionDescription(), 80, 2 ) << "\n" << std::endl;
+            }
+        }
+
+        if( !displayedSpecificOption ) {
+            std::cout << exeName << " is a CATCH host application. Options are as follows:\n\n";
+            showUsage( std::cout );
+        }
+    }
+
+    inline int Main( int argc, char* const argv[], Config& config ) {
+
+        try {
+            CommandParser parser( argc, argv );
+
+            if( Command cmd = Options::HelpOptionParser().find( parser ) ) {
+                if( cmd.argsCount() != 0 )
+                    cmd.raiseError( "Does not accept arguments" );
+
+                showHelp( parser );
+                Catch::cleanUp();
+                return 0;
+            }
+
+            AllOptions options;
+
+            options.parseIntoConfig( parser, config.data() );
+        }
+        catch( std::exception& ex ) {
+            std::cerr << ex.what() << "\n\nUsage: ...\n\n";
+            showUsage( std::cerr );
+            Catch::cleanUp();
+            return (std::numeric_limits<int>::max)();
+        }
+
+        return Main( config );
+    }
+
+    inline int Main( int argc, char* const argv[] ) {
+        Config config;
+// !TBD: This doesn't always work, for some reason
+//        if( isDebuggerActive() )
+//            config.useStream( "debug" );
+        return Main( argc, argv, config );
+    }
+
+} // end namespace Catch
+
+// #included from: catch_registry_hub.hpp
+#define TWOBLUECUBES_CATCH_REGISTRY_HUB_HPP_INCLUDED
+
+// #included from: catch_test_case_registry_impl.hpp
+#define TWOBLUECUBES_CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED
+
+#include <vector>
+#include <set>
+#include <sstream>
+#include <iostream>
+
+namespace Catch {
+
+    class TestRegistry : public ITestCaseRegistry {
+    public:
+        TestRegistry() : m_unnamedCount( 0 ) {}
+        virtual ~TestRegistry();
+
+        virtual void registerTest( const TestCaseInfo& testInfo ) {
+            if( testInfo.getName() == "" ) {
+                std::ostringstream oss;
+                oss << testInfo.getName() << "unnamed/" << ++m_unnamedCount;
+                return registerTest( TestCaseInfo( testInfo, oss.str() ) );
+            }
+
+            if( m_functions.find( testInfo ) == m_functions.end() ) {
+                m_functions.insert( testInfo );
+                m_functionsInOrder.push_back( testInfo );
+                if( !testInfo.isHidden() )
+                    m_nonHiddenFunctions.push_back( testInfo );
+            }
+            else {
+                const TestCaseInfo& prev = *m_functions.find( testInfo );
+                std::cerr   << "error: TEST_CASE( \"" << testInfo.getName() << "\" ) already defined.\n"
+                            << "\tFirst seen at " << SourceLineInfo( prev.getLineInfo() ) << "\n"
+                            << "\tRedefined at " << SourceLineInfo( testInfo.getLineInfo() ) << std::endl;
+                exit(1);
+            }
+        }
+
+        virtual const std::vector<TestCaseInfo>& getAllTests() const {
+            return m_functionsInOrder;
+        }
+
+        virtual const std::vector<TestCaseInfo>& getAllNonHiddenTests() const {
+            return m_nonHiddenFunctions;
+        }
+
+        // !TBD deprecated
+        virtual std::vector<TestCaseInfo> getMatchingTestCases( const std::string& rawTestSpec ) const {
+            std::vector<TestCaseInfo> matchingTests;
+            getMatchingTestCases( rawTestSpec, matchingTests );
+            return matchingTests;
+        }
+
+        // !TBD deprecated
+        virtual void getMatchingTestCases( const std::string& rawTestSpec, std::vector<TestCaseInfo>& matchingTestsOut ) const {
+            TestCaseFilter filter( rawTestSpec );
+
+            std::vector<TestCaseInfo>::const_iterator it = m_functionsInOrder.begin();
+            std::vector<TestCaseInfo>::const_iterator itEnd = m_functionsInOrder.end();
+            for(; it != itEnd; ++it ) {
+                if( filter.shouldInclude( *it ) ) {
+                    matchingTestsOut.push_back( *it );
+                }
+            }
+        }
+        virtual void getMatchingTestCases( const TestCaseFilters& filters, std::vector<TestCaseInfo>& matchingTestsOut ) const {
+            std::vector<TestCaseInfo>::const_iterator it = m_functionsInOrder.begin();
+            std::vector<TestCaseInfo>::const_iterator itEnd = m_functionsInOrder.end();
+            // !TBD: replace with algorithm
+            for(; it != itEnd; ++it )
+                if( filters.shouldInclude( *it ) )
+                    matchingTestsOut.push_back( *it );
+        }
+
+    private:
+
+        std::set<TestCaseInfo> m_functions;
+        std::vector<TestCaseInfo> m_functionsInOrder;
+        std::vector<TestCaseInfo> m_nonHiddenFunctions;
+        size_t m_unnamedCount;
+    };
+
+    ///////////////////////////////////////////////////////////////////////////
+
+    class FreeFunctionTestCase : public SharedImpl<ITestCase> {
+    public:
+
+        FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {}
+
+        virtual void invoke() const {
+            m_fun();
+        }
+
+    private:
+        virtual ~FreeFunctionTestCase();
+
+        TestFunction m_fun;
+    };
+
+    inline std::string extractClassName( const std::string& classOrQualifiedMethodName ) {
+        std::string className = classOrQualifiedMethodName;
+        if( className[0] == '&' )
+        {
+            std::size_t lastColons = className.rfind( "::" );
+            std::size_t penultimateColons = className.rfind( "::", lastColons-1 );
+            if( penultimateColons == std::string::npos )
+                penultimateColons = 1;
+            className = className.substr( penultimateColons, lastColons-penultimateColons );
+        }
+        return className;
+    }
+
+    ///////////////////////////////////////////////////////////////////////////
+
+    AutoReg::AutoReg(   TestFunction function,
+                        const char* name,
+                        const char* description,
+                        const SourceLineInfo& lineInfo ) {
+        registerTestCase( new FreeFunctionTestCase( function ), "global", name, description, lineInfo );
+    }
+
+    AutoReg::~AutoReg() {}
+
+    void AutoReg::registerTestCase( ITestCase* testCase,
+                                    const char* classOrQualifiedMethodName,
+                                    const char* name,
+                                    const char* description,
+                                    const SourceLineInfo& lineInfo ) {
+
+        getMutableRegistryHub().registerTest( TestCaseInfo( testCase, extractClassName( classOrQualifiedMethodName ), name, description, lineInfo ) );
+    }
+
+} // end namespace Catch
+
+// #included from: catch_reporter_registry.hpp
+#define TWOBLUECUBES_CATCH_REPORTER_REGISTRY_HPP_INCLUDED
+
+#include <map>
+
+namespace Catch {
+
+    class ReporterRegistry : public IReporterRegistry {
+
+    public:
+
+        virtual ~ReporterRegistry() {
+            deleteAllValues( m_factories );
+        }
+
+        virtual IReporter* create( const std::string& name, const ReporterConfig& config ) const {
+            FactoryMap::const_iterator it =  m_factories.find( name );
+            if( it == m_factories.end() )
+                return NULL;
+            return it->second->create( config );
+        }
+
+        void registerReporter( const std::string& name, IReporterFactory* factory ) {
+            m_factories.insert( std::make_pair( name, factory ) );
+        }
+
+        const FactoryMap& getFactories() const {
+            return m_factories;
+        }
+
+    private:
+        FactoryMap m_factories;
+    };
+}
+
+// #included from: catch_exception_translator_registry.hpp
+#define TWOBLUECUBES_CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED
+
+#ifdef __OBJC__
+#import "Foundation/Foundation.h"
+#endif
+
+namespace Catch {
+
+    class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry {
+    public:
+        ~ExceptionTranslatorRegistry() {
+            deleteAll( m_translators );
+        }
+
+        virtual void registerTranslator( const IExceptionTranslator* translator ) {
+            m_translators.push_back( translator );
+        }
+
+        virtual std::string translateActiveException() const {
+            try {
+#ifdef __OBJC__
+                // In Objective-C try objective-c exceptions first
+                @try {
+                    throw;
+                }
+                @catch (NSException *exception) {
+                    return toString( [exception description] );
+                }
+#else
+                throw;
+#endif
+            }
+            catch( std::exception& ex ) {
+                return ex.what();
+            }
+            catch( std::string& msg ) {
+                return msg;
+            }
+            catch( const char* msg ) {
+                return msg;
+            }
+            catch(...) {
+                return tryTranslators( m_translators.begin() );
+            }
+        }
+
+        std::string tryTranslators( std::vector<const IExceptionTranslator*>::const_iterator it ) const {
+            if( it == m_translators.end() )
+                return "Unknown exception";
+
+            try {
+                return (*it)->translate();
+            }
+            catch(...) {
+                return tryTranslators( it+1 );
+            }
+        }
+
+    private:
+        std::vector<const IExceptionTranslator*> m_translators;
+    };
+}
+
+namespace Catch {
+
+    namespace {
+
+        class RegistryHub : public IRegistryHub, public IMutableRegistryHub {
+
+            RegistryHub( const RegistryHub& );
+            void operator=( const RegistryHub& );
+
+        public: // IRegistryHub
+            RegistryHub() {
+            }
+            virtual const IReporterRegistry& getReporterRegistry() const {
+                return m_reporterRegistry;
+            }
+            virtual const ITestCaseRegistry& getTestCaseRegistry() const {
+                return m_testCaseRegistry;
+            }
+            virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() {
+                return m_exceptionTranslatorRegistry;
+            }
+
+        public: // IMutableRegistryHub
+            virtual void registerReporter( const std::string& name, IReporterFactory* factory ) {
+                m_reporterRegistry.registerReporter( name, factory );
+            }
+            virtual void registerTest( const TestCaseInfo& testInfo ) {
+                m_testCaseRegistry.registerTest( testInfo );
+            }
+            virtual void registerTranslator( const IExceptionTranslator* translator ) {
+                m_exceptionTranslatorRegistry.registerTranslator( translator );
+            }
+
+        private:
+            TestRegistry m_testCaseRegistry;
+            ReporterRegistry m_reporterRegistry;
+            ExceptionTranslatorRegistry m_exceptionTranslatorRegistry;
+        };
+
+        // Single, global, instance
+        inline RegistryHub*& getTheRegistryHub() {
+            static RegistryHub* theRegistryHub = NULL;
+            if( !theRegistryHub )
+                theRegistryHub = new RegistryHub();
+            return theRegistryHub;
+        }
+    }
+
+    IRegistryHub& getRegistryHub() {
+        return *getTheRegistryHub();
+    }
+    IMutableRegistryHub& getMutableRegistryHub() {
+        return *getTheRegistryHub();
+    }
+    void cleanUp() {
+        delete getTheRegistryHub();
+        getTheRegistryHub() = NULL;
+        cleanUpContext();
+    }
+    std::string translateActiveException() {
+        return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException();
+    }
+
+} // end namespace Catch
+
+// #included from: catch_notimplemented_exception.hpp
+#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_HPP_INCLUDED
+
+#include <ostream>
+
+namespace Catch {
+
+    NotImplementedException::NotImplementedException( const SourceLineInfo& lineInfo )
+    :   m_lineInfo( lineInfo ) {
+        std::ostringstream oss;
+        oss << lineInfo << "function ";
+        oss << "not implemented";
+        m_what = oss.str();
+    }
+
+    const char* NotImplementedException::what() const throw() {
+        return m_what.c_str();
+    }
+
+} // end namespace Catch
+
+// #included from: catch_context_impl.hpp
+#define TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED
+
+namespace Catch {
+
+    class Context : public IMutableContext {
+
+        Context() : m_config( NULL ) {}
+        Context( const Context& );
+        void operator=( const Context& );
+
+    public: // IContext
+        virtual IResultCapture& getResultCapture() {
+            return *m_resultCapture;
+        }
+        virtual IRunner& getRunner() {
+            return *m_runner;
+        }
+        virtual size_t getGeneratorIndex( const std::string& fileInfo, size_t totalSize ) {
+            return getGeneratorsForCurrentTest()
+            .getGeneratorInfo( fileInfo, totalSize )
+            .getCurrentIndex();
+        }
+        virtual bool advanceGeneratorsForCurrentTest() {
+            IGeneratorsForTest* generators = findGeneratorsForCurrentTest();
+            return generators && generators->moveNext();
+        }
+
+        virtual const IConfig* getConfig() const {
+            return m_config;
+        }
+
+    public: // IMutableContext
+        virtual void setResultCapture( IResultCapture* resultCapture ) {
+            m_resultCapture = resultCapture;
+        }
+        virtual void setRunner( IRunner* runner ) {
+            m_runner = runner;
+        }
+        virtual void setConfig( const IConfig* config ) {
+            m_config = config;
+        }
+
+        friend IMutableContext& getCurrentMutableContext();
+
+    private:
+        IGeneratorsForTest* findGeneratorsForCurrentTest() {
+            std::string testName = getResultCapture().getCurrentTestName();
+
+            std::map<std::string, IGeneratorsForTest*>::const_iterator it =
+            m_generatorsByTestName.find( testName );
+            return it != m_generatorsByTestName.end()
+            ? it->second
+            : NULL;
+        }
+
+        IGeneratorsForTest& getGeneratorsForCurrentTest() {
+            IGeneratorsForTest* generators = findGeneratorsForCurrentTest();
+            if( !generators ) {
+                std::string testName = getResultCapture().getCurrentTestName();
+                generators = createGeneratorsForTest();
+                m_generatorsByTestName.insert( std::make_pair( testName, generators ) );
+            }
+            return *generators;
+        }
+
+    private:
+        IRunner* m_runner;
+        IResultCapture* m_resultCapture;
+        const IConfig* m_config;
+        std::map<std::string, IGeneratorsForTest*> m_generatorsByTestName;
+    };
+
+    namespace {
+        Context* currentContext = NULL;
+    }
+    IMutableContext& getCurrentMutableContext() {
+        if( !currentContext )
+            currentContext = new Context();
+        return *currentContext;
+    }
+    IContext& getCurrentContext() {
+        return getCurrentMutableContext();
+    }
+
+    Stream createStream( const std::string& streamName ) {
+        if( streamName == "stdout" ) return Stream( std::cout.rdbuf(), false );
+        if( streamName == "stderr" ) return Stream( std::cerr.rdbuf(), false );
+        if( streamName == "debug" ) return Stream( new StreamBufImpl<OutputDebugWriter>, true );
+
+        throw std::domain_error( "Unknown stream: " + streamName );
+    }
+
+    void cleanUpContext() {
+        delete currentContext;
+        currentContext = NULL;
+    }
+}
+
+// #included from: catch_console_colour_impl.hpp
+#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_IMPL_HPP_INCLUDED
+
+// #included from: catch_console_colour.hpp
+#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED
+
+namespace Catch {
+
+    struct ConsoleColourImpl;
+
+    class TextColour : NonCopyable {
+    public:
+
+        enum Colours {
+            None,
+
+            FileName,
+            ResultError,
+            ResultSuccess,
+
+            Error,
+            Success,
+
+            OriginalExpression,
+            ReconstructedExpression
+        };
+
+        TextColour( Colours colour = None );
+        void set( Colours colour );
+        ~TextColour();
+
+    private:
+        ConsoleColourImpl* m_impl;
+    };
+
+} // end namespace Catch
+
+#if defined( CATCH_CONFIG_USE_ANSI_COLOUR_CODES )
+
+#include <unistd.h>
+
+namespace Catch {
+
+    // use POSIX/ ANSI console terminal codes
+    // Implementation contributed by Adam Strzelecki (http://github.com/nanoant)
+    // https://github.com/philsquared/Catch/pull/131
+
+    TextColour::TextColour( Colours colour ) {
+        if( colour )
+            set( colour );
+    }
+
+    TextColour::~TextColour() {
+        set( TextColour::None );
+    }
+
+    namespace { const char colourEscape = '\033'; }
+
+    void TextColour::set( Colours colour ) {
+        if( isatty( fileno(stdout) ) ) {
+            switch( colour ) {
+                case TextColour::FileName:
+                    std::cout << colourEscape << "[0m";    // white/ normal
+                    break;
+                case TextColour::ResultError:
+                    std::cout << colourEscape << "[1;31m"; // bold red
+                    break;
+                case TextColour::ResultSuccess:
+                    std::cout << colourEscape << "[1;32m"; // bold green
+                    break;
+                case TextColour::Error:
+                    std::cout << colourEscape << "[0;31m"; // red
+                    break;
+                case TextColour::Success:
+                    std::cout << colourEscape << "[0;32m"; // green
+                    break;
+                case TextColour::OriginalExpression:
+                    std::cout << colourEscape << "[0;36m"; // cyan
+                    break;
+                case TextColour::ReconstructedExpression:
+                    std::cout << colourEscape << "[0;33m"; // yellow
+                    break;
+                case TextColour::None:
+                    std::cout << colourEscape << "[0m"; // reset
+            }
+        }
+    }
+
+} // namespace Catch
+
+#elif defined ( CATCH_PLATFORM_WINDOWS )
+
+#include <windows.h>
+
+namespace Catch {
+
+    namespace {
+
+        WORD mapConsoleColour( TextColour::Colours colour ) {
+            switch( colour ) {
+                case TextColour::FileName:
+                    return FOREGROUND_INTENSITY;                    // greyed out
+                case TextColour::ResultError:
+                    return FOREGROUND_RED | FOREGROUND_INTENSITY;   // bright red
+                case TextColour::ResultSuccess:
+                    return FOREGROUND_GREEN | FOREGROUND_INTENSITY; // bright green
+                case TextColour::Error:
+                    return FOREGROUND_RED;                          // dark red
+                case TextColour::Success:
+                    return FOREGROUND_GREEN;                        // dark green
+                case TextColour::OriginalExpression:
+                    return FOREGROUND_BLUE | FOREGROUND_GREEN;      // turquoise
+                case TextColour::ReconstructedExpression:
+                    return FOREGROUND_RED | FOREGROUND_GREEN;       // greeny-yellow
+                default: return 0;
+            }
+        }
+    }
+
+    struct ConsoleColourImpl {
+
+        ConsoleColourImpl()
+        :   hStdout( GetStdHandle(STD_OUTPUT_HANDLE) ),
+            wOldColorAttrs( 0 )
+        {
+            GetConsoleScreenBufferInfo( hStdout, &csbiInfo );
+            wOldColorAttrs = csbiInfo.wAttributes;
+        }
+
+        ~ConsoleColourImpl() {
+            SetConsoleTextAttribute( hStdout, wOldColorAttrs );
+        }
+
+        void set( TextColour::Colours colour ) {
+            WORD consoleColour = mapConsoleColour( colour );
+            if( consoleColour > 0 )
+                SetConsoleTextAttribute( hStdout, consoleColour );
+        }
+
+        HANDLE hStdout;
+        CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
+        WORD wOldColorAttrs;
+    };
+
+    TextColour::TextColour( Colours colour )
+    : m_impl( new ConsoleColourImpl() )
+    {
+        if( colour )
+            m_impl->set( colour );
+    }
+
+    TextColour::~TextColour() {
+        delete m_impl;
+    }
+
+    void TextColour::set( Colours colour ) {
+        m_impl->set( colour );
+    }
+
+} // end namespace Catch
+
+#else
+
+namespace Catch {
+
+    TextColour::TextColour( Colours ){}
+    TextColour::~TextColour(){}
+    void TextColour::set( Colours ){}
+
+} // end namespace Catch
+
+#endif
+
+// #included from: catch_generators_impl.hpp
+#define TWOBLUECUBES_CATCH_GENERATORS_IMPL_HPP_INCLUDED
+
+#include <vector>
+#include <string>
+#include <map>
+
+namespace Catch {
+
+    struct GeneratorInfo : IGeneratorInfo {
+
+        GeneratorInfo( std::size_t size )
+        :   m_size( size ),
+            m_currentIndex( 0 )
+        {}
+
+        bool moveNext() {
+            if( ++m_currentIndex == m_size ) {
+                m_currentIndex = 0;
+                return false;
+            }
+            return true;
+        }
+
+        std::size_t getCurrentIndex() const {
+            return m_currentIndex;
+        }
+
+        std::size_t m_size;
+        std::size_t m_currentIndex;
+    };
+
+    ///////////////////////////////////////////////////////////////////////////
+
+    class GeneratorsForTest : public IGeneratorsForTest {
+
+    public:
+        ~GeneratorsForTest() {
+            deleteAll( m_generatorsInOrder );
+        }
+
+        IGeneratorInfo& getGeneratorInfo( const std::string& fileInfo, std::size_t size ) {
+            std::map<std::string, IGeneratorInfo*>::const_iterator it = m_generatorsByName.find( fileInfo );
+            if( it == m_generatorsByName.end() ) {
+                IGeneratorInfo* info = new GeneratorInfo( size );
+                m_generatorsByName.insert( std::make_pair( fileInfo, info ) );
+                m_generatorsInOrder.push_back( info );
+                return *info;
+            }
+            return *it->second;
+        }
+
+        bool moveNext() {
+            std::vector<IGeneratorInfo*>::const_iterator it = m_generatorsInOrder.begin();
+            std::vector<IGeneratorInfo*>::const_iterator itEnd = m_generatorsInOrder.end();
+            for(; it != itEnd; ++it ) {
+                if( (*it)->moveNext() )
+                    return true;
+            }
+            return false;
+        }
+
+    private:
+        std::map<std::string, IGeneratorInfo*> m_generatorsByName;
+        std::vector<IGeneratorInfo*> m_generatorsInOrder;
+    };
+
+    IGeneratorsForTest* createGeneratorsForTest()
+    {
+        return new GeneratorsForTest();
+    }
+
+} // end namespace Catch
+
+// #included from: catch_assertionresult.hpp
+#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED
+
+namespace Catch {
+
+    AssertionInfo::AssertionInfo(   const std::string& _macroName,
+                                    const SourceLineInfo& _lineInfo,
+                                    const std::string& _capturedExpression,
+                                    ResultDisposition::Flags _resultDisposition )
+    :   macroName( _macroName ),
+        lineInfo( _lineInfo ),
+        capturedExpression( _capturedExpression ),
+        resultDisposition( _resultDisposition )
+    {
+        if( shouldNegate( resultDisposition ) )
+            capturedExpression = "!" + _capturedExpression;
+    }
+
+    AssertionResult::AssertionResult() {}
+
+    AssertionResult::AssertionResult( const AssertionInfo& info, const AssertionResultData& data )
+    :   m_info( info ),
+        m_resultData( data )
+    {}
+
+    AssertionResult::~AssertionResult() {}
+
+    // Result was a success
+    bool AssertionResult::succeeded() const {
+        return Catch::isOk( m_resultData.resultType );
+    }
+
+    // Result was a success, or failure is suppressed
+    bool AssertionResult::isOk() const {
+        return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition );
+    }
+
+    ResultWas::OfType AssertionResult::getResultType() const {
+        return m_resultData.resultType;
+    }
+
+    bool AssertionResult::hasExpression() const {
+        return !m_info.capturedExpression.empty();
+    }
+
+    bool AssertionResult::hasMessage() const {
+        return !m_resultData.message.empty();
+    }
+
+    std::string AssertionResult::getExpression() const {
+        return m_info.capturedExpression;
+    }
+
+    bool AssertionResult::hasExpandedExpression() const {
+        return hasExpression() && getExpandedExpression() != getExpression();
+    }
+
+    std::string AssertionResult::getExpandedExpression() const {
+        return m_resultData.reconstructedExpression;
+    }
+
+    std::string AssertionResult::getMessage() const {
+        return m_resultData.message;
+    }
+    SourceLineInfo AssertionResult::getSourceInfo() const {
+        return m_info.lineInfo;
+    }
+
+    std::string AssertionResult::getTestMacroName() const {
+        return m_info.macroName;
+    }
+
+} // end namespace Catch
+
+// #included from: catch_expressionresult_builder.hpp
+#define TWOBLUECUBES_CATCH_EXPRESSIONRESULT_BUILDER_HPP_INCLUDED
+
+#include <assert.h>
+
+namespace Catch {
+
+    ExpressionResultBuilder::ExpressionResultBuilder( ResultWas::OfType resultType ) {
+        m_data.resultType = resultType;
+    }
+    ExpressionResultBuilder::ExpressionResultBuilder( const ExpressionResultBuilder& other )
+    :   m_data( other.m_data ),
+        m_exprComponents( other.m_exprComponents )
+    {
+        m_stream << other.m_stream.str();
+    }
+    ExpressionResultBuilder& ExpressionResultBuilder::operator=(const ExpressionResultBuilder& other ) {
+        m_data = other.m_data;
+        m_exprComponents = other.m_exprComponents;
+        m_stream.str("");
+        m_stream << other.m_stream.str();
+        return *this;
+    }
+    ExpressionResultBuilder& ExpressionResultBuilder::setResultType( ResultWas::OfType result ) {
+        m_data.resultType = result;
+        return *this;
+    }
+    ExpressionResultBuilder& ExpressionResultBuilder::setResultType( bool result ) {
+        m_data.resultType = result ? ResultWas::Ok : ResultWas::ExpressionFailed;
+        return *this;
+    }
+    ExpressionResultBuilder& ExpressionResultBuilder::endExpression( ResultDisposition::Flags resultDisposition ) {
+        m_exprComponents.shouldNegate = shouldNegate( resultDisposition );
+        return *this;
+    }
+    ExpressionResultBuilder& ExpressionResultBuilder::setLhs( const std::string& lhs ) {
+        m_exprComponents.lhs = lhs;
+        return *this;
+    }
+    ExpressionResultBuilder& ExpressionResultBuilder::setRhs( const std::string& rhs ) {
+        m_exprComponents.rhs = rhs;
+        return *this;
+    }
+    ExpressionResultBuilder& ExpressionResultBuilder::setOp( const std::string& op ) {
+        m_exprComponents.op = op;
+        return *this;
+    }
+    AssertionResult ExpressionResultBuilder::buildResult( const AssertionInfo& info ) const
+    {
+        assert( m_data.resultType != ResultWas::Unknown );
+
+        AssertionResultData data = m_data;
+
+        // Flip bool results if shouldNegate is set
+        if( m_exprComponents.shouldNegate && data.resultType == ResultWas::Ok )
+            data.resultType = ResultWas::ExpressionFailed;
+        else if( m_exprComponents.shouldNegate && data.resultType == ResultWas::ExpressionFailed )
+            data.resultType = ResultWas::Ok;
+
+        data.message = m_stream.str();
+        data.reconstructedExpression = reconstructExpression( info );
+        if( m_exprComponents.shouldNegate ) {
+            if( m_exprComponents.op == "" )
+                data.reconstructedExpression = "!" + data.reconstructedExpression;
+            else
+                data.reconstructedExpression = "!(" + data.reconstructedExpression + ")";
+        }
+        return AssertionResult( info, data );
+    }
+    std::string ExpressionResultBuilder::reconstructExpression( const AssertionInfo& info ) const {
+        if( m_exprComponents.op == "" )
+            return m_exprComponents.lhs.empty() ? info.capturedExpression : m_exprComponents.op + m_exprComponents.lhs;
+        else if( m_exprComponents.op == "matches" )
+            return m_exprComponents.lhs + " " + m_exprComponents.rhs;
+        else if( m_exprComponents.op != "!" ) {
+            if( m_exprComponents.lhs.size() + m_exprComponents.rhs.size() < 30 )
+                return m_exprComponents.lhs + " " + m_exprComponents.op + " " + m_exprComponents.rhs;
+            else if( m_exprComponents.lhs.size() < 70 && m_exprComponents.rhs.size() < 70 )
+                return "\n\t" + m_exprComponents.lhs + "\n\t" + m_exprComponents.op + "\n\t" + m_exprComponents.rhs;
+            else
+                return "\n" + m_exprComponents.lhs + "\n" + m_exprComponents.op + "\n" + m_exprComponents.rhs + "\n\n";
+        }
+        else
+            return "{can't expand - use " + info.macroName + "_FALSE( " + info.capturedExpression.substr(1) + " ) instead of " + info.macroName + "( " + info.capturedExpression + " ) for better diagnostics}";
+    }
+
+} // end namespace Catch
+
+// #included from: catch_test_case_info.hpp
+#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_HPP_INCLUDED
+
+namespace Catch {
+
+    TestCaseInfo::TestCaseInfo( ITestCase* testCase,
+                                const std::string& className,
+                                const std::string& name,
+                                const std::string& description,
+                                const SourceLineInfo& lineInfo )
+    :   m_test( testCase ),
+        m_className( className ),
+        m_name( name ),
+        m_description( description ),
+        m_lineInfo( lineInfo ),
+        m_isHidden( startsWith( name, "./" ) )
+    {
+        TagExtracter( m_tags ).parse( m_description );
+        if( hasTag( "hide" ) )
+            m_isHidden = true;
+    }
+
+    TestCaseInfo::TestCaseInfo()
+    :   m_test( NULL ),
+        m_className(),
+        m_name(),
+        m_description(),
+        m_isHidden( false )
+    {}
+
+    TestCaseInfo::TestCaseInfo( const TestCaseInfo& other, const std::string& name )
+    :   m_test( other.m_test ),
+        m_className( other.m_className ),
+        m_name( name ),
+        m_description( other.m_description ),
+        m_tags( other.m_tags ),
+        m_lineInfo( other.m_lineInfo ),
+        m_isHidden( other.m_isHidden )
+    {}
+
+    TestCaseInfo::TestCaseInfo( const TestCaseInfo& other )
+    :   m_test( other.m_test ),
+        m_className( other.m_className ),
+        m_name( other.m_name ),
+        m_description( other.m_description ),
+        m_tags( other.m_tags ),
+        m_lineInfo( other.m_lineInfo ),
+        m_isHidden( other.m_isHidden )
+    {}
+
+    void TestCaseInfo::invoke() const {
+        m_test->invoke();
+    }
+
+    const std::string& TestCaseInfo::getClassName() const {
+        return m_className;
+    }
+    const std::string& TestCaseInfo::getName() const {
+        return m_name;
+    }
+    const std::string& TestCaseInfo::getDescription() const {
+        return m_description;
+    }
+    const SourceLineInfo& TestCaseInfo::getLineInfo() const {
+        return m_lineInfo;
+    }
+
+    bool TestCaseInfo::isHidden() const {
+        return m_isHidden;
+    }
+
+    bool TestCaseInfo::hasTag( const std::string& tag ) const {
+        return m_tags.find( tag ) != m_tags.end();
+    }
+    bool TestCaseInfo::matchesTags( const std::string& tagPattern ) const {
+        TagExpression exp;
+        TagExpressionParser( exp ).parse( tagPattern );
+        return exp.matches( m_tags );
+    }
+    const std::set<std::string>& TestCaseInfo::getTags() const {
+        return m_tags;
+    }
+
+    void TestCaseInfo::swap( TestCaseInfo& other ) {
+        m_test.swap( other.m_test );
+        m_className.swap( other.m_className );
+        m_name.swap( other.m_name );
+        m_description.swap( other.m_description );
+        std::swap( m_lineInfo, other.m_lineInfo );
+    }
+
+    bool TestCaseInfo::operator == ( const TestCaseInfo& other ) const {
+        return  m_test.get() == other.m_test.get() &&
+                m_name == other.m_name &&
+                m_className == other.m_className;
+    }
+
+    bool TestCaseInfo::operator < ( const TestCaseInfo& other ) const {
+        return m_name < other.m_name;
+    }
+    TestCaseInfo& TestCaseInfo::operator = ( const TestCaseInfo& other ) {
+        TestCaseInfo temp( other );
+        swap( temp );
+        return *this;
+    }
+
+} // end namespace Catch
+
+// #included from: ../reporters/catch_reporter_basic.hpp
+#define TWOBLUECUBES_CATCH_REPORTER_BASIC_HPP_INCLUDED
+
+// #included from: ../internal/catch_reporter_registrars.hpp
+#define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
+
+namespace Catch {
+
+    template<typename T>
+    class ReporterRegistrar {
+
+        class ReporterFactory : public IReporterFactory {
+
+            virtual IReporter* create( const ReporterConfig& config ) const {
+                return new T( config );
+            }
+
+            virtual std::string getDescription() const {
+                return T::getDescription();
+            }
+        };
+
+    public:
+
+        ReporterRegistrar( const std::string& name ) {
+            getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
+        }
+    };
+}
+
+#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
+    Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name );
+
+namespace Catch {
+
+    class BasicReporter : public SharedImpl<IReporter> {
+
+        struct SpanInfo {
+
+            SpanInfo()
+            :   emitted( false )
+            {}
+
+            SpanInfo( const std::string& spanName )
+            :   name( spanName ),
+                emitted( false )
+            {}
+
+            SpanInfo( const SpanInfo& other )
+            :   name( other.name ),
+                emitted( other.emitted )
+            {}
+
+            std::string name;
+            bool emitted;
+        };
+
+    public:
+        BasicReporter( const ReporterConfig& config )
+        :   m_config( config ),
+            m_firstSectionInTestCase( true ),
+            m_aborted( false )
+        {}
+
+        virtual ~BasicReporter();
+
+        static std::string getDescription() {
+            return "Reports test results as lines of text";
+        }
+
+    private:
+
+        void ReportCounts( const std::string& label, const Counts& counts, const std::string& allPrefix = "All " ) {
+            if( counts.passed )
+                m_config.stream << counts.failed << " of " << counts.total() << " " << label << "s failed";
+            else
+                m_config.stream << ( counts.failed > 1 ? allPrefix : "" ) << pluralise( counts.failed, label ) << " failed";
+        }
+
+        void ReportCounts( const Totals& totals, const std::string& allPrefix = "All " ) {
+            if( totals.assertions.total() == 0 ) {
+                m_config.stream << "No tests ran";
+            }
+            else if( totals.assertions.failed ) {
+                TextColour colour( TextColour::ResultError );
+                ReportCounts( "test case", totals.testCases, allPrefix );
+                if( totals.testCases.failed > 0 ) {
+                    m_config.stream << " (";
+                    ReportCounts( "assertion", totals.assertions, allPrefix );
+                    m_config.stream << ")";
+                }
+            }
+            else {
+                TextColour colour( TextColour::ResultSuccess );
+                m_config.stream   << allPrefix << "tests passed ("
+                                    << pluralise( totals.assertions.passed, "assertion" ) << " in "
+                                    << pluralise( totals.testCases.passed, "test case" ) << ")";
+            }
+        }
+
+    private: // IReporter
+
+        virtual bool shouldRedirectStdout() const {
+            return false;
+        }
+
+        virtual void StartTesting() {
+            m_testingSpan = SpanInfo();
+        }
+
+        virtual void Aborted() {
+            m_aborted = true;
+        }
+
+        virtual void EndTesting( const Totals& totals ) {
+            // Output the overall test results even if "Started Testing" was not emitted
+            if( m_aborted ) {
+                m_config.stream << "\n[Testing aborted. ";
+                ReportCounts( totals, "The first " );
+            }
+            else {
+                m_config.stream << "\n[Testing completed. ";
+                ReportCounts( totals );
+            }
+            m_config.stream << "]\n" << std::endl;
+        }
+
+        virtual void StartGroup( const std::string& groupName ) {
+            m_groupSpan = groupName;
+        }
+
+        virtual void EndGroup( const std::string& groupName, const Totals& totals ) {
+            if( m_groupSpan.emitted && !groupName.empty() ) {
+                m_config.stream << "[End of group: '" << groupName << "'. ";
+                ReportCounts( totals );
+                m_config.stream << "]\n" << std::endl;
+                m_groupSpan = SpanInfo();
+            }
+        }
+
+        virtual void StartTestCase( const TestCaseInfo& testInfo ) {
+            m_testSpan = testInfo.getName();
+        }
+
+        virtual void StartSection( const std::string& sectionName, const std::string& ) {
+            m_sectionSpans.push_back( SpanInfo( sectionName ) );
+        }
+
+        virtual void NoAssertionsInSection( const std::string& sectionName ) {
+            startSpansLazily();
+            TextColour colour( TextColour::ResultError );
+            m_config.stream << "\nNo assertions in section, '" << sectionName << "'\n" << std::endl;
+        }
+        virtual void NoAssertionsInTestCase( const std::string& testName ) {
+            startSpansLazily();
+            TextColour colour( TextColour::ResultError );
+            m_config.stream << "\nNo assertions in test case, '" << testName << "'\n" << std::endl;
+        }
+
+        virtual void EndSection( const std::string& sectionName, const Counts& assertions ) {
+
+            SpanInfo& sectionSpan = m_sectionSpans.back();
+            if( sectionSpan.emitted && !sectionSpan.name.empty() ) {
+                m_config.stream << "[End of section: '" << sectionName << "' ";
+
+                if( assertions.failed ) {
+                    TextColour colour( TextColour::ResultError );
+                    ReportCounts( "assertion", assertions);
+                }
+                else {
+                    TextColour colour( TextColour::ResultSuccess );
+                    m_config.stream   << ( assertions.passed > 1 ? "All " : "" )
+                                        << pluralise( assertions.passed, "assertion" ) << " passed" ;
+                }
+                m_config.stream << "]\n" << std::endl;
+            }
+            m_sectionSpans.pop_back();
+        }
+
+        virtual void Result( const AssertionResult& assertionResult ) {
+            if( !m_config.includeSuccessfulResults && assertionResult.getResultType() == ResultWas::Ok )
+                return;
+
+            startSpansLazily();
+
+            if( !assertionResult.getSourceInfo().empty() ) {
+                TextColour colour( TextColour::FileName );
+                m_config.stream << assertionResult.getSourceInfo();
+            }
+
+            if( assertionResult.hasExpression() ) {
+                TextColour colour( TextColour::OriginalExpression );
+                m_config.stream << assertionResult.getExpression();
+                if( assertionResult.succeeded() ) {
+                    TextColour successColour( TextColour::Success );
+                    m_config.stream << " succeeded";
+                }
+                else {
+                    TextColour errorColour( TextColour::Error );
+                    m_config.stream << " failed";
+                    if( assertionResult.isOk() ) {
+                        TextColour okAnywayColour( TextColour::Success );
+                        m_config.stream << " - but was ok";
+                    }
+                }
+            }
+            switch( assertionResult.getResultType() ) {
+                case ResultWas::ThrewException:
+                    {
+                        TextColour colour( TextColour::Error );
+                        if( assertionResult.hasExpression() )
+                            m_config.stream << " with unexpected";
+                        else
+                            m_config.stream << "Unexpected";
+                        m_config.stream << " exception with message: '" << assertionResult.getMessage() << "'";
+                    }
+                    break;
+                case ResultWas::DidntThrowException:
+                    {
+                        TextColour colour( TextColour::Error );
+                        if( assertionResult.hasExpression() )
+                            m_config.stream << " because no exception was thrown where one was expected";
+                        else
+                            m_config.stream << "No exception thrown where one was expected";
+                    }
+                    break;
+                case ResultWas::Info:
+                    {
+                        TextColour colour( TextColour::ReconstructedExpression );
+                        streamVariableLengthText( "info", assertionResult.getMessage() );
+                    }
+                    break;
+                case ResultWas::Warning:
+                    {
+                        TextColour colour( TextColour::ReconstructedExpression );
+                        streamVariableLengthText( "warning", assertionResult.getMessage() );
+                    }
+                    break;
+                case ResultWas::ExplicitFailure:
+                    {
+                        TextColour colour( TextColour::Error );
+                        m_config.stream << "failed with message: '" << assertionResult.getMessage() << "'";
+                    }
+                    break;
+                case ResultWas::Unknown: // These cases are here to prevent compiler warnings
+                case ResultWas::Ok:
+                case ResultWas::FailureBit:
+                case ResultWas::ExpressionFailed:
+                case ResultWas::Exception:
+                    if( !assertionResult.hasExpression() ) {
+                        if( assertionResult.succeeded() ) {
+                            TextColour colour( TextColour::Success );
+                            m_config.stream << " succeeded";
+                        }
+                        else {
+                            TextColour colour( TextColour::Error );
+                            m_config.stream << " failed";
+                            if( assertionResult.isOk() ) {
+                                TextColour okAnywayColour( TextColour::Success );
+                                m_config.stream << " - but was ok";
+                            }
+                        }
+                    }
+                    break;
+            }
+
+            if( assertionResult.hasExpandedExpression() ) {
+                m_config.stream << " for: ";
+                if( assertionResult.getExpandedExpression().size() > 40 ) {
+                    m_config.stream << "\n";
+                    if( assertionResult.getExpandedExpression().size() < 70 )
+                        m_config.stream << "\t";
+                }
+                TextColour colour( TextColour::ReconstructedExpression );
+                m_config.stream << assertionResult.getExpandedExpression();
+            }
+            m_config.stream << std::endl;
+        }
+
+        virtual void EndTestCase(   const TestCaseInfo& testInfo,
+                                    const Totals& totals,
+                                    const std::string& stdOut,
+                                    const std::string& stdErr ) {
+            if( !stdOut.empty() ) {
+                startSpansLazily();
+                streamVariableLengthText( "stdout", stdOut );
+            }
+
+            if( !stdErr.empty() ) {
+                startSpansLazily();
+                streamVariableLengthText( "stderr", stdErr );
+            }
+
+            if( m_testSpan.emitted ) {
+                m_config.stream << "[Finished: '" << testInfo.getName() << "' ";
+                ReportCounts( totals );
+                m_config.stream << "]" << std::endl;
+            }
+        }
+
+    private: // helpers
+
+        void startSpansLazily() {
+            if( !m_testingSpan.emitted ) {
+                if( m_config.name.empty() )
+                    m_config.stream << "[Started testing]" << std::endl;
+                else
+                    m_config.stream << "[Started testing: " << m_config.name << "]" << std::endl;
+                m_testingSpan.emitted = true;
+            }
+
+            if( !m_groupSpan.emitted && !m_groupSpan.name.empty() ) {
+                m_config.stream << "[Started group: '" << m_groupSpan.name << "']" << std::endl;
+                m_groupSpan.emitted = true;
+            }
+
+            if( !m_testSpan.emitted ) {
+                m_config.stream << std::endl << "[Running: " << m_testSpan.name << "]" << std::endl;
+                m_testSpan.emitted = true;
+            }
+
+            if( !m_sectionSpans.empty() ) {
+                SpanInfo& sectionSpan = m_sectionSpans.back();
+                if( !sectionSpan.emitted && !sectionSpan.name.empty() ) {
+                    if( m_firstSectionInTestCase ) {
+                        m_config.stream << "\n";
+                        m_firstSectionInTestCase = false;
+                    }
+                    std::vector<SpanInfo>::iterator it = m_sectionSpans.begin();
+                    std::vector<SpanInfo>::iterator itEnd = m_sectionSpans.end();
+                    for(; it != itEnd; ++it ) {
+                        SpanInfo& prevSpan = *it;
+                        if( !prevSpan.emitted && !prevSpan.name.empty() ) {
+                            m_config.stream << "[Started section: '" << prevSpan.name << "']" << std::endl;
+                            prevSpan.emitted = true;
+                        }
+                    }
+                }
+            }
+        }
+
+        void streamVariableLengthText( const std::string& prefix, const std::string& text ) {
+            std::string trimmed = trim( text );
+            if( trimmed.find_first_of( "\r\n" ) == std::string::npos ) {
+                m_config.stream << "[" << prefix << ": " << trimmed << "]";
+            }
+            else {
+                m_config.stream << "\n[" << prefix << "] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" << trimmed
+                << "\n[end of " << prefix << "] <<<<<<<<<<<<<<<<<<<<<<<<\n";
+            }
+        }
+
+    private:
+        ReporterConfig m_config;
+        bool m_firstSectionInTestCase;
+
+        SpanInfo m_testingSpan;
+        SpanInfo m_groupSpan;
+        SpanInfo m_testSpan;
+        std::vector<SpanInfo> m_sectionSpans;
+        bool m_aborted;
+    };
+
+} // end namespace Catch
+
+// #included from: ../reporters/catch_reporter_xml.hpp
+#define TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED
+
+// #included from: ../internal/catch_xmlwriter.hpp
+#define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED
+
+#include <sstream>
+#include <iostream>
+#include <string>
+#include <vector>
+
+namespace Catch {
+
+    class XmlWriter {
+    public:
+
+        class ScopedElement {
+        public:
+            ScopedElement( XmlWriter* writer )
+            :   m_writer( writer )
+            {}
+
+            ScopedElement( const ScopedElement& other )
+            :   m_writer( other.m_writer ){
+                other.m_writer = NULL;
+            }
+
+            ~ScopedElement() {
+                if( m_writer )
+                    m_writer->endElement();
+            }
+
+            ScopedElement& writeText( const std::string& text ) {
+                m_writer->writeText( text );
+                return *this;
+            }
+
+            template<typename T>
+            ScopedElement& writeAttribute( const std::string& name, const T& attribute ) {
+                m_writer->writeAttribute( name, attribute );
+                return *this;
+            }
+
+        private:
+            mutable XmlWriter* m_writer;
+        };
+
+        XmlWriter()
+        :   m_tagIsOpen( false ),
+            m_needsNewline( false ),
+            m_os( &std::cout )
+        {}
+
+        XmlWriter( std::ostream& os )
+        :   m_tagIsOpen( false ),
+            m_needsNewline( false ),
+            m_os( &os )
+        {}
+
+        ~XmlWriter() {
+            while( !m_tags.empty() )
+                endElement();
+        }
+
+        XmlWriter& operator = ( const XmlWriter& other ) {
+            XmlWriter temp( other );
+            swap( temp );
+            return *this;
+        }
+
+        void swap( XmlWriter& other ) {
+            std::swap( m_tagIsOpen, other.m_tagIsOpen );
+            std::swap( m_needsNewline, other.m_needsNewline );
+            std::swap( m_tags, other.m_tags );
+            std::swap( m_indent, other.m_indent );
+            std::swap( m_os, other.m_os );
+        }
+
+        XmlWriter& startElement( const std::string& name ) {
+            ensureTagClosed();
+            newlineIfNecessary();
+            stream() << m_indent << "<" << name;
+            m_tags.push_back( name );
+            m_indent += "  ";
+            m_tagIsOpen = true;
+            return *this;
+        }
+
+        ScopedElement scopedElement( const std::string& name ) {
+            ScopedElement scoped( this );
+            startElement( name );
+            return scoped;
+        }
+
+        XmlWriter& endElement() {
+            newlineIfNecessary();
+            m_indent = m_indent.substr( 0, m_indent.size()-2 );
+            if( m_tagIsOpen ) {
+                stream() << "/>\n";
+                m_tagIsOpen = false;
+            }
+            else {
+                stream() << m_indent << "</" << m_tags.back() << ">\n";
+            }
+            m_tags.pop_back();
+            return *this;
+        }
+
+        XmlWriter& writeAttribute( const std::string& name, const std::string& attribute ) {
+            if( !name.empty() && !attribute.empty() ) {
+                stream() << " " << name << "=\"";
+                writeEncodedText( attribute );
+                stream() << "\"";
+            }
+            return *this;
+        }
+
+        XmlWriter& writeAttribute( const std::string& name, bool attribute ) {
+            stream() << " " << name << "=\"" << ( attribute ? "true" : "false" ) << "\"";
+            return *this;
+        }
+
+        template<typename T>
+        XmlWriter& writeAttribute( const std::string& name, const T& attribute ) {
+            if( !name.empty() )
+                stream() << " " << name << "=\"" << attribute << "\"";
+            return *this;
+        }
+
+        XmlWriter& writeText( const std::string& text ) {
+            if( !text.empty() ){
+                bool tagWasOpen = m_tagIsOpen;
+                ensureTagClosed();
+                if( tagWasOpen )
+                    stream() << m_indent;
+                writeEncodedText( text );
+                m_needsNewline = true;
+            }
+            return *this;
+        }
+
+        XmlWriter& writeComment( const std::string& text ) {
+            ensureTagClosed();
+            stream() << m_indent << "<!--" << text << "-->";
+            m_needsNewline = true;
+            return *this;
+        }
+
+        XmlWriter& writeBlankLine() {
+            ensureTagClosed();
+            stream() << "\n";
+            return *this;
+        }
+
+    private:
+
+        std::ostream& stream() {
+            return *m_os;
+        }
+
+        void ensureTagClosed() {
+            if( m_tagIsOpen ) {
+                stream() << ">\n";
+                m_tagIsOpen = false;
+            }
+        }
+
+        void newlineIfNecessary() {
+            if( m_needsNewline ) {
+                stream() << "\n";
+                m_needsNewline = false;
+            }
+        }
+
+        void writeEncodedText( const std::string& text ) {
+            static const char* charsToEncode = "<&\"";
+            std::string mtext = text;
+            std::string::size_type pos = mtext.find_first_of( charsToEncode );
+            while( pos != std::string::npos ) {
+                stream() << mtext.substr( 0, pos );
+
+                switch( mtext[pos] ) {
+                    case '<':
+                        stream() << "&lt;";
+                        break;
+                    case '&':
+                        stream() << "&amp;";
+                        break;
+                    case '\"':
+                        stream() << "&quot;";
+                        break;
+                }
+                mtext = mtext.substr( pos+1 );
+                pos = mtext.find_first_of( charsToEncode );
+            }
+            stream() << mtext;
+        }
+
+        bool m_tagIsOpen;
+        bool m_needsNewline;
+        std::vector<std::string> m_tags;
+        std::string m_indent;
+        std::ostream* m_os;
+    };
+
+}
+namespace Catch {
+    class XmlReporter : public SharedImpl<IReporter> {
+    public:
+        XmlReporter( const ReporterConfig& config ) : m_config( config ) {}
+
+        static std::string getDescription() {
+            return "Reports test results as an XML document";
+        }
+        virtual ~XmlReporter();
+
+    private: // IReporter
+
+        virtual bool shouldRedirectStdout() const {
+            return true;
+        }
+
+        virtual void StartTesting() {
+            m_xml = XmlWriter( m_config.stream );
+            m_xml.startElement( "Catch" );
+            if( !m_config.name.empty() )
+                m_xml.writeAttribute( "name", m_config.name );
+        }
+
+        virtual void EndTesting( const Totals& totals ) {
+            m_xml.scopedElement( "OverallResults" )
+                .writeAttribute( "successes", totals.assertions.passed )
+                .writeAttribute( "failures", totals.assertions.failed );
+            m_xml.endElement();
+        }
+
+        virtual void StartGroup( const std::string& groupName ) {
+            m_xml.startElement( "Group" )
+                .writeAttribute( "name", groupName );
+        }
+
+        virtual void EndGroup( const std::string&, const Totals& totals ) {
+            m_xml.scopedElement( "OverallResults" )
+                .writeAttribute( "successes", totals.assertions.passed )
+                .writeAttribute( "failures", totals.assertions.failed );
+            m_xml.endElement();
+        }
+
+        virtual void StartSection( const std::string& sectionName, const std::string& description ) {
+            m_xml.startElement( "Section" )
+                .writeAttribute( "name", sectionName )
+                .writeAttribute( "description", description );
+        }
+        virtual void NoAssertionsInSection( const std::string& ) {}
+        virtual void NoAssertionsInTestCase( const std::string& ) {}
+
+        virtual void EndSection( const std::string& /*sectionName*/, const Counts& assertions ) {
+            m_xml.scopedElement( "OverallResults" )
+                .writeAttribute( "successes", assertions.passed )
+                .writeAttribute( "failures", assertions.failed );
+            m_xml.endElement();
+        }
+
+        virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) {
+            m_xml.startElement( "TestCase" ).writeAttribute( "name", testInfo.getName() );
+            m_currentTestSuccess = true;
+        }
+
+        virtual void Result( const Catch::AssertionResult& assertionResult ) {
+            if( !m_config.includeSuccessfulResults && assertionResult.getResultType() == ResultWas::Ok )
+                return;
+
+            if( assertionResult.hasExpression() ) {
+                m_xml.startElement( "Expression" )
+                    .writeAttribute( "success", assertionResult.succeeded() )
+                    .writeAttribute( "filename", assertionResult.getSourceInfo().file )
+                    .writeAttribute( "line", assertionResult.getSourceInfo().line );
+
+                m_xml.scopedElement( "Original" )
+                    .writeText( assertionResult.getExpression() );
+                m_xml.scopedElement( "Expanded" )
+                    .writeText( assertionResult.getExpandedExpression() );
+                m_currentTestSuccess &= assertionResult.succeeded();
+            }
+
+            switch( assertionResult.getResultType() ) {
+                case ResultWas::ThrewException:
+                    m_xml.scopedElement( "Exception" )
+                        .writeAttribute( "filename", assertionResult.getSourceInfo().file )
+                        .writeAttribute( "line", assertionResult.getSourceInfo().line )
+                        .writeText( assertionResult.getMessage() );
+                    m_currentTestSuccess = false;
+                    break;
+                case ResultWas::Info:
+                    m_xml.scopedElement( "Info" )
+                        .writeText( assertionResult.getMessage() );
+                    break;
+                case ResultWas::Warning:
+                    m_xml.scopedElement( "Warning" )
+                        .writeText( assertionResult.getMessage() );
+                    break;
+                case ResultWas::ExplicitFailure:
+                    m_xml.scopedElement( "Failure" )
+                        .writeText( assertionResult.getMessage() );
+                    m_currentTestSuccess = false;
+                    break;
+                case ResultWas::Unknown:
+                case ResultWas::Ok:
+                case ResultWas::FailureBit:
+                case ResultWas::ExpressionFailed:
+                case ResultWas::Exception:
+                case ResultWas::DidntThrowException:
+                    break;
+            }
+            if( assertionResult.hasExpression() )
+                m_xml.endElement();
+        }
+
+        virtual void Aborted() {
+            // !TBD
+        }
+
+        virtual void EndTestCase( const Catch::TestCaseInfo&, const Totals&, const std::string&, const std::string& ) {
+            m_xml.scopedElement( "OverallResult" ).writeAttribute( "success", m_currentTestSuccess );
+            m_xml.endElement();
+        }
+
+    private:
+        ReporterConfig m_config;
+        bool m_currentTestSuccess;
+        XmlWriter m_xml;
+    };
+
+} // end namespace Catch
+
+// #included from: ../reporters/catch_reporter_junit.hpp
+#define TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED
+
+namespace Catch {
+
+    class JunitReporter : public SharedImpl<IReporter> {
+
+        struct TestStats {
+            std::string m_element;
+            std::string m_resultType;
+            std::string m_message;
+            std::string m_content;
+        };
+
+        struct TestCaseStats {
+
+            TestCaseStats( const std::string& className, const std::string& name )
+            :   m_className( className ),
+                m_name( name )
+            {}
+
+            double      m_timeInSeconds;
+            std::string m_status;
+            std::string m_className;
+            std::string m_name;
+            std::vector<TestStats> m_testStats;
+        };
+
+        struct Stats {
+
+            Stats( const std::string& name = std::string() )
+            :   m_testsCount( 0 ),
+                m_failuresCount( 0 ),
+                m_disabledCount( 0 ),
+                m_errorsCount( 0 ),
+                m_timeInSeconds( 0 ),
+                m_name( name )
+            {}
+
+            std::size_t m_testsCount;
+            std::size_t m_failuresCount;
+            std::size_t m_disabledCount;
+            std::size_t m_errorsCount;
+            double      m_timeInSeconds;
+            std::string m_name;
+
+            std::vector<TestCaseStats> m_testCaseStats;
+        };
+
+    public:
+        JunitReporter( const ReporterConfig& config )
+        :   m_config( config ),
+            m_testSuiteStats( "AllTests" ),
+            m_currentStats( &m_testSuiteStats )
+        {}
+        virtual ~JunitReporter();
+
+        static std::string getDescription() {
+            return "Reports test results in an XML format that looks like Ant's junitreport target";
+        }
+
+    private: // IReporter
+
+        virtual bool shouldRedirectStdout() const {
+            return true;
+        }
+
+        virtual void StartTesting(){}
+
+        virtual void StartGroup( const std::string& groupName ) {
+            m_statsForSuites.push_back( Stats( groupName ) );
+            m_currentStats = &m_statsForSuites.back();
+        }
+
+        virtual void EndGroup( const std::string&, const Totals& totals ) {
+            m_currentStats->m_testsCount = totals.assertions.total();
+            m_currentStats = &m_testSuiteStats;
+        }
+
+        virtual void StartSection( const std::string&, const std::string& ){}
+
+        virtual void NoAssertionsInSection( const std::string& ) {}
+        virtual void NoAssertionsInTestCase( const std::string& ) {}
+
+        virtual void EndSection( const std::string&, const Counts& ) {}
+
+        virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) {
+            m_currentStats->m_testCaseStats.push_back( TestCaseStats( testInfo.getClassName(), testInfo.getName() ) );
+        }
+
+        virtual void Result( const Catch::AssertionResult& assertionResult ) {
+            if( assertionResult.getResultType() != ResultWas::Ok || m_config.includeSuccessfulResults ) {
+                TestCaseStats& testCaseStats = m_currentStats->m_testCaseStats.back();
+                TestStats stats;
+                std::ostringstream oss;
+                if( !assertionResult.getMessage().empty() )
+                    oss << assertionResult.getMessage() << " at ";
+                oss << assertionResult.getSourceInfo();
+                stats.m_content = oss.str();
+                stats.m_message = assertionResult.getExpandedExpression();
+                stats.m_resultType = assertionResult.getTestMacroName();
+
+                switch( assertionResult.getResultType() ) {
+                    case ResultWas::ThrewException:
+                        stats.m_element = "error";
+                        m_currentStats->m_errorsCount++;
+                        break;
+                    case ResultWas::Info:
+                        stats.m_element = "info"; // !TBD ?
+                        break;
+                    case ResultWas::Warning:
+                        stats.m_element = "warning"; // !TBD ?
+                        break;
+                    case ResultWas::ExplicitFailure:
+                        stats.m_element = "failure";
+                        m_currentStats->m_failuresCount++;
+                        break;
+                    case ResultWas::ExpressionFailed:
+                        stats.m_element = "failure";
+                        m_currentStats->m_failuresCount++;
+                        break;
+                    case ResultWas::Ok:
+                        stats.m_element = "success";
+                        break;
+                    case ResultWas::Unknown:
+                    case ResultWas::FailureBit:
+                    case ResultWas::Exception:
+                    case ResultWas::DidntThrowException:
+                        break;
+                }
+                testCaseStats.m_testStats.push_back( stats );
+            }
+        }
+
+        virtual void EndTestCase( const Catch::TestCaseInfo&, const Totals&, const std::string& stdOut, const std::string& stdErr ) {
+            if( !stdOut.empty() )
+                m_stdOut << stdOut << "\n";
+            if( !stdErr.empty() )
+                m_stdErr << stdErr << "\n";
+        }
+
+        virtual void Aborted() {
+            // !TBD
+        }
+
+        virtual void EndTesting( const Totals& ) {
+            std::ostream& str = m_config.stream;
+            {
+                XmlWriter xml( str );
+
+                if( m_statsForSuites.size() > 0 )
+                    xml.startElement( "testsuites" );
+
+                std::vector<Stats>::const_iterator it = m_statsForSuites.begin();
+                std::vector<Stats>::const_iterator itEnd = m_statsForSuites.end();
+
+                for(; it != itEnd; ++it ) {
+                    XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" );
+                    xml.writeAttribute( "name", it->m_name );
+                    xml.writeAttribute( "errors", it->m_errorsCount );
+                    xml.writeAttribute( "failures", it->m_failuresCount );
+                    xml.writeAttribute( "tests", it->m_testsCount );
+                    xml.writeAttribute( "hostname", "tbd" );
+                    xml.writeAttribute( "time", "tbd" );
+                    xml.writeAttribute( "timestamp", "tbd" );
+
+                    OutputTestCases( xml, *it );
+                }
+
+                xml.scopedElement( "system-out" ).writeText( trim( m_stdOut.str() ) );
+                xml.scopedElement( "system-err" ).writeText( trim( m_stdErr.str() ) );
+            }
+        }
+
+        void OutputTestCases( XmlWriter& xml, const Stats& stats ) {
+            std::vector<TestCaseStats>::const_iterator it = stats.m_testCaseStats.begin();
+            std::vector<TestCaseStats>::const_iterator itEnd = stats.m_testCaseStats.end();
+            for(; it != itEnd; ++it ) {
+                xml.writeBlankLine();
+                xml.writeComment( "Test case" );
+
+                XmlWriter::ScopedElement e = xml.scopedElement( "testcase" );
+                xml.writeAttribute( "classname", it->m_className );
+                xml.writeAttribute( "name", it->m_name );
+                xml.writeAttribute( "time", "tbd" );
+
+                OutputTestResult( xml, *it );
+            }
+        }
+
+        void OutputTestResult( XmlWriter& xml, const TestCaseStats& stats ) {
+            std::vector<TestStats>::const_iterator it = stats.m_testStats.begin();
+            std::vector<TestStats>::const_iterator itEnd = stats.m_testStats.end();
+            for(; it != itEnd; ++it ) {
+                if( it->m_element != "success" ) {
+                    XmlWriter::ScopedElement e = xml.scopedElement( it->m_element );
+
+                    xml.writeAttribute( "message", it->m_message );
+                    xml.writeAttribute( "type", it->m_resultType );
+                    if( !it->m_content.empty() )
+                        xml.writeText( it->m_content );
+                }
+            }
+        }
+
+    private:
+        ReporterConfig m_config;
+        bool m_currentTestSuccess;
+
+        Stats m_testSuiteStats;
+        Stats* m_currentStats;
+        std::vector<Stats> m_statsForSuites;
+        std::ostringstream m_stdOut;
+        std::ostringstream m_stdErr;
+    };
+
+} // end namespace Catch
+
+namespace Catch {
+    NonCopyable::~NonCopyable() {}
+    IShared::~IShared() {}
+    StreamBufBase::~StreamBufBase() {}
+    IContext::~IContext() {}
+    IResultCapture::~IResultCapture() {}
+    ITestCase::~ITestCase() {}
+    ITestCaseRegistry::~ITestCaseRegistry() {}
+    IRegistryHub::~IRegistryHub() {}
+    IMutableRegistryHub::~IMutableRegistryHub() {}
+    IExceptionTranslator::~IExceptionTranslator() {}
+    IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {}
+    IReporter::~IReporter() {}
+    IReporterFactory::~IReporterFactory() {}
+    IReporterRegistry::~IReporterRegistry() {}
+    BasicReporter::~BasicReporter() {}
+    IRunner::~IRunner() {}
+    IMutableContext::~IMutableContext() {}
+    IConfig::~IConfig() {}
+    XmlReporter::~XmlReporter() {}
+    JunitReporter::~JunitReporter() {}
+    TestRegistry::~TestRegistry() {}
+    FreeFunctionTestCase::~FreeFunctionTestCase() {}
+    IGeneratorInfo::~IGeneratorInfo() {}
+    IGeneratorsForTest::~IGeneratorsForTest() {}
+    TagParser::~TagParser() {}
+    TagExtracter::~TagExtracter() {}
+    TagExpressionParser::~TagExpressionParser() {}
+
+    Matchers::Impl::StdString::Equals::~Equals() {}
+    Matchers::Impl::StdString::Contains::~Contains() {}
+    Matchers::Impl::StdString::StartsWith::~StartsWith() {}
+    Matchers::Impl::StdString::EndsWith::~EndsWith() {}
+
+    void Config::dummy() {}
+
+    INTERNAL_CATCH_REGISTER_REPORTER( "basic", BasicReporter )
+    INTERNAL_CATCH_REGISTER_REPORTER( "xml", XmlReporter )
+    INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter )
+
+}
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+#endif
+
+#ifdef CATCH_CONFIG_MAIN
+// #included from: internal/catch_default_main.hpp
+#define TWOBLUECUBES_CATCH_DEFAULT_MAIN_HPP_INCLUDED
+
+#ifndef __OBJC__
+
+// Standard C/C++ main entry point
+int main (int argc, char * const argv[]) {
+    return Catch::Main( argc, argv );
+}
+
+#else // __OBJC__
+
+// Objective-C entry point
+int main (int argc, char * const argv[]) {
+#if !CATCH_ARC_ENABLED
+    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+#endif
+
+    Catch::registerTestMethods();
+    int result = Catch::Main( argc, (char* const*)argv );
+
+#if !CATCH_ARC_ENABLED
+    [pool drain];
+#endif
+
+    return result;
+}
+
+#endif // __OBJC__
+
+#endif
+
+//////
+
+// If this config identifier is defined then all CATCH macros are prefixed with CATCH_
+#ifdef CATCH_CONFIG_PREFIX_ALL
+
+#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE" )
+#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::NegateResult, "CATCH_REQUIRE_FALSE" )
+
+#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS" )
+#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS_AS" )
+#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_NOTHROW" )
+
+#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK" )
+#define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::NegateResult, "CATCH_CHECK_FALSE" )
+#define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_IF" )
+#define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_ELSE" )
+#define CATCH_CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CATCH_CHECK_NOFAIL" )
+
+#define CATCH_CHECK_THROWS( expr )  INTERNAL_CATCH_THROWS( expr, ..., Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS" )
+#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS_AS" )
+#define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_NOTHROW" )
+
+#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" )
+#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THAT" )
+
+#define CATCH_INFO( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Info, Catch::ResultDisposition::ContinueOnFailure, "CATCH_INFO" )
+#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "CATCH_WARN" )
+#define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL" )
+#define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED" )
+#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg, "CATCH_SCOPED_INFO" )
+#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_MSG( #msg " := " << msg, Catch::ResultWas::Info, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CAPTURE" )
+#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_SCOPED_INFO( #msg " := " << msg, "CATCH_SCOPED_CAPTURE" )
+
+#define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
+
+#define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
+#define CATCH_TEST_CASE_NORETURN( name, description ) INTERNAL_CATCH_TESTCASE_NORETURN( name, description )
+#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "Anonymous test case" )
+#define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
+
+#define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
+
+#define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
+
+// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required
+#else
+
+#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" )
+#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::NegateResult, "REQUIRE_FALSE" )
+
+#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., Catch::ResultDisposition::Normal, "REQUIRE_THROWS" )
+#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "REQUIRE_THROWS_AS" )
+#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "REQUIRE_NOTHROW" )
+
+#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" )
+#define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::NegateResult, "CHECK_FALSE" )
+#define CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_IF" )
+#define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" )
+#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CHECK_NOFAIL" )
+
+#define CHECK_THROWS( expr )  INTERNAL_CATCH_THROWS( expr, ..., Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS" )
+#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" )
+#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOTHROW" )
+
+#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" )
+#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "REQUIRE_THAT" )
+
+#define INFO( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Info, Catch::ResultDisposition::ContinueOnFailure, "INFO" )
+#define WARN( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "WARN" )
+#define FAIL( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL" )
+#define SUCCEED( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED" )
+#define SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg, "SCOPED_INFO" )
+#define CAPTURE( msg ) INTERNAL_CATCH_MSG( #msg " := " << msg, Catch::ResultWas::Info, Catch::ResultDisposition::ContinueOnFailure, "CAPTURE" )
+#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_SCOPED_INFO( #msg " := " << msg, "SCOPED_CAPTURE" )
+
+#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
+
+#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
+#define TEST_CASE_NORETURN( name, description ) INTERNAL_CATCH_TESTCASE_NORETURN( name, description )
+#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "Anonymous test case" )
+#define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
+
+#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
+
+#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
+
+#endif
+
+#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )
+
+using Catch::Detail::Approx;
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
+

+ 12 - 0
src/tests/common/CMakeLists.txt

@@ -0,0 +1,12 @@
+INCLUDE_DIRECTORIES(
+  ${PARADEVS_BINARY_DIR}/src
+  ${PARADEVS_SOURCE_DIR}/src
+  ${Boost_INCLUDE_DIRS}
+  ${GLIBMM_INCLUDE_DIRS}
+  ${LIBXML_INCLUDE_DIRS})
+
+LINK_DIRECTORIES(
+  ${GLIBMM_LIBRARY_DIRS}
+  ${LIBXML_LIBRARY_DIR})
+
+ADD_SUBDIRECTORY(scheduler)

+ 17 - 0
src/tests/common/scheduler/CMakeLists.txt

@@ -0,0 +1,17 @@
+INCLUDE_DIRECTORIES(
+  ${CMAKE_SOURCE_DIR}/src
+  ${PARADEVS_INCLUDE_DIRS}
+  ${Boost_INCLUDE_DIRS}
+  ${GLIBMM_INCLUDE_DIRS}
+  ${LIBXML_INCLUDE_DIRS})
+
+LINK_DIRECTORIES(
+  ${GLIBMM_LIBRARY_DIRS}
+  ${LIBXML_LIBRARY_DIR})
+
+ADD_EXECUTABLE(common-scheduler-tests ${COMMON_HPP} tests.cpp)
+
+TARGET_LINK_LIBRARIES(common-scheduler-tests
+  ${GLIBMM_LIBRARIES}
+  ${LIBXML_LIBRARIES}
+  ${GTHREAD_LIBRARIES})

+ 167 - 0
src/tests/common/scheduler/tests.cpp

@@ -0,0 +1,167 @@
+/**
+ * @file tests/common/scheduler/tests.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <paradevs/common/scheduler/HeapScheduler.hpp>
+#include <paradevs/common/time/DoubleTime.hpp>
+
+#include <paradevs/kernel/pdevs/Dynamics.hpp>
+#include <paradevs/kernel/pdevs/Simulator.hpp>
+
+#include <chrono>
+
+#define CATCH_CONFIG_MAIN
+#include <tests/catch.hpp>
+
+using namespace paradevs::common;
+using namespace paradevs::common::scheduler;
+
+using namespace paradevs::pdevs;
+
+using namespace std::chrono;
+
+struct SchedulerHandle;
+
+typedef typename HeapScheduler < DoubleTime,
+                                 SchedulerHandle >::type SchedulerType;
+
+struct SchedulerHandle
+{
+    SchedulerHandle()
+    { }
+
+    SchedulerHandle(const SchedulerType::handle_type& handle)
+        : _handle(handle)
+    { }
+
+    const SchedulerHandle& handle() const
+    { return *this; }
+
+    void handle(const SchedulerHandle& handle)
+    { _handle = handle._handle; }
+
+    SchedulerType::handle_type _handle;
+};
+
+typedef Dynamics < DoubleTime, SchedulerHandle > MyDynamics;
+typedef paradevs::pdevs::Simulator < DoubleTime, MyDynamics,
+                                     SchedulerHandle > MySimulator;
+typedef std::vector < MySimulator* > MySimulators;
+
+const int simulator_number = 5000;
+const double simulation_duration = 1000;
+const int sample_number = 20;
+
+double unit_test(unsigned int n)
+{
+    MySimulators simulators;
+    HeapScheduler < DoubleTime, SchedulerHandle > scheduler;
+
+    for (unsigned int i = 0; i < simulator_number; ++i) {
+        std::ostringstream ss;
+
+        ss << "a" << (i + 1);
+        simulators.push_back(new MySimulator(ss.str(), NoParameters()));
+    }
+
+    std::vector < std::vector < unsigned int > > lists;
+
+    for (unsigned int t = 1; t < simulation_duration; ++t) {
+        std::vector < unsigned int > list;
+        std::vector < unsigned int > list2;
+
+        for (unsigned int i = 0; i < n; ++i) {
+            list2.push_back(i);
+        }
+        for (unsigned int i = 0; i < n; ++i) {
+            unsigned int j = rand() % list2.size();
+            unsigned int index = list2[j];
+            std::vector < unsigned int >::iterator it =
+                std::find(list2.begin(), list2.end(), index);
+
+            list.push_back(index);
+            list2.erase(it);
+        }
+        lists.push_back(list);
+    }
+
+    steady_clock::time_point t1 = steady_clock::now();
+
+    for (unsigned int i = 0; i < n; ++i) {
+        scheduler.init(0., simulators[i]);
+    }
+
+    for (unsigned int t = 1; t < simulation_duration; ++t) {
+        for (unsigned int i = 0; i < n; ++i) {
+            scheduler.put((double)t, simulators[lists[t - 1][i]]);
+        }
+    }
+
+    steady_clock::time_point t2 = steady_clock::now();
+
+    duration < double > time_span = duration_cast <
+        duration < double > >(t2 - t1);
+
+    for (MySimulators::const_iterator it = simulators.begin();
+         it != simulators.end(); ++it) {
+        delete *it;
+    }
+
+    return time_span.count();
+}
+
+void test(unsigned int n, unsigned int r)
+{
+    std::vector < double > t;
+
+    for (unsigned int i = 0; i < sample_number; ++i) {
+        t.push_back(unit_test(n));
+    }
+
+    double a = 0;
+
+    for (unsigned int i = 0; i < sample_number; ++i) {
+        a += t[i];
+    }
+    a /= sample_number;
+
+    double sd = 0;
+
+    for (unsigned int i = 0; i < sample_number; ++i) {
+        sd += (t[i] - a)*(t[i] - a);
+    }
+    sd /= sample_number;
+    sd = sqrt(sd);
+
+    std::cout << n << "\t" << a << "\t" << (a * r) << "\t"
+              << sd << "\t" << (sd * r) << std::endl;
+}
+
+TEST_CASE("common/scheduler/heap", "run")
+{
+    for (unsigned int i = 1; i <= 200; i+= 5) {
+        test(simulator_number / i, i);
+    }
+}

+ 17 - 0
src/tests/dtss/CMakeLists.txt

@@ -0,0 +1,17 @@
+INCLUDE_DIRECTORIES(
+  ${CMAKE_SOURCE_DIR}/src
+  ${PARADEVS_INCLUDE_DIRS}
+  ${Boost_INCLUDE_DIRS}
+  ${GLIBMM_INCLUDE_DIRS}
+  ${LIBXML_INCLUDE_DIRS})
+
+LINK_DIRECTORIES(
+  ${GLIBMM_LIBRARY_DIRS}
+  ${LIBXML_LIBRARY_DIR})
+
+ADD_EXECUTABLE(dtss-tests graph_manager.hpp models.hpp tests.cpp)
+
+TARGET_LINK_LIBRARIES(dtss-tests
+  ${GLIBMM_LIBRARIES}
+  ${LIBXML_LIBRARIES}
+  ${GTHREAD_LIBRARIES})

+ 119 - 0
src/tests/dtss/graph_manager.hpp

@@ -0,0 +1,119 @@
+/**
+ * @file tests/dtss/graph_manager.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_DTSS_GRAPH_MANAGER_HPP
+#define TESTS_DTSS_GRAPH_MANAGER_HPP 1
+
+#include <paradevs/kernel/dtss/Coordinator.hpp>
+#include <paradevs/kernel/dtss/GraphManager.hpp>
+#include <paradevs/kernel/dtss/Simulator.hpp>
+
+#include <tests/dtss/models.hpp>
+
+namespace paradevs { namespace tests { namespace dtss {
+
+template < class SchedulerHandle >
+struct Policy
+{
+    const common::Bag < common::DoubleTime, SchedulerHandle >& bag() const
+    { return _bag; }
+
+    virtual void operator()(
+        common::DoubleTime::type /* t */,
+        const common::ExternalEvent < common::DoubleTime,
+                                      SchedulerHandle >& event,
+        common::DoubleTime::type /* tl */,
+        common::DoubleTime::type /* tn */)
+    {
+        _bag.clear();
+        _bag.push_back(event);
+    }
+
+private:
+    common::Bag < common::DoubleTime, SchedulerHandle > _bag;
+};
+
+template < class SchedulerHandle >
+class OnlyOneGraphManager :
+        public paradevs::dtss::GraphManager < common::DoubleTime,
+                                              SchedulerHandle,
+                                              paradevs::common::NoParameters >
+{
+public:
+    OnlyOneGraphManager(common::Coordinator < common::DoubleTime,
+                                              SchedulerHandle >* coordinator,
+                        const paradevs::common::NoParameters& parameters) :
+        paradevs::dtss::GraphManager < common::DoubleTime, SchedulerHandle,
+                                       paradevs::common::NoParameters >(
+                                           coordinator, parameters),
+        a("a", 1, common::NoParameters())
+    {
+        OnlyOneGraphManager < SchedulerHandle >::add_child(&a);
+    }
+
+    virtual ~OnlyOneGraphManager()
+    { }
+
+private:
+    paradevs::dtss::Simulator < common::DoubleTime, A < SchedulerHandle >,
+                                SchedulerHandle > a;
+};
+
+template < class SchedulerHandle >
+class TwoGraphManager :
+        public paradevs::dtss::GraphManager < common::DoubleTime,
+                                              SchedulerHandle,
+                                              paradevs::common::NoParameters >
+{
+public:
+    TwoGraphManager(common::Coordinator < common::DoubleTime,
+                                          SchedulerHandle >* coordinator,
+                    const paradevs::common::NoParameters& parameters) :
+        paradevs::dtss::GraphManager < common::DoubleTime, SchedulerHandle,
+                                       paradevs::common::NoParameters >(
+                                           coordinator, parameters),
+        a("a", 1, common::NoParameters()), b("b", 1, common::NoParameters())
+    {
+        TwoGraphManager < SchedulerHandle >::add_child(&a);
+        TwoGraphManager < SchedulerHandle >::add_child(&b);
+        a.add_out_port("out");
+        b.add_in_port("in");
+        TwoGraphManager < SchedulerHandle >::add_link(&a, "out", &b, "in");
+    }
+
+    virtual ~TwoGraphManager()
+    { }
+
+private:
+    paradevs::dtss::Simulator < common::DoubleTime, A < SchedulerHandle >,
+                                SchedulerHandle > a;
+    paradevs::dtss::Simulator < common::DoubleTime, B < SchedulerHandle >,
+                                SchedulerHandle > b;
+};
+
+} } } // namespace paradevs tests dtss
+
+#endif

+ 195 - 0
src/tests/dtss/models.hpp

@@ -0,0 +1,195 @@
+/**
+ * @file tests/dtss/models.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_DTSS_MODELS_HPP
+#define TESTS_DTSS_MODELS_HPP 1
+
+#include <paradevs/kernel/dtss/Dynamics.hpp>
+
+#include <paradevs/common/time/DoubleTime.hpp>
+
+namespace paradevs { namespace tests { namespace dtss {
+
+template < class SchedulerHandle>
+class A :
+        public paradevs::dtss::Dynamics < common::DoubleTime, SchedulerHandle,
+                                          paradevs::common::NoParameters >
+{
+public:
+    A(const std::string& name,
+      const paradevs::common::NoParameters& parameters) :
+        paradevs::dtss::Dynamics < common::DoubleTime, SchedulerHandle,
+                                   paradevs::common::NoParameters >(name,
+                                                                    parameters)
+    { }
+    virtual ~A()
+    { }
+
+    void transition(const common::Bag < common::DoubleTime,
+                    SchedulerHandle >& /* x */,
+                    common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::DELTA_INT);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+    }
+
+    common::DoubleTime::type start(common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::START);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        return 0;
+    }
+
+    common::Bag < common::DoubleTime, SchedulerHandle > lambda(
+        common::DoubleTime::type t) const
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+        common::Bag < common::DoubleTime, SchedulerHandle > msgs;
+
+        msgs.push_back(common::ExternalEvent < common::DoubleTime,
+                                               SchedulerHandle >("out", 0.));
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::LAMBDA)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        return msgs;
+    }
+};
+
+template < class SchedulerHandle>
+class B :
+        public paradevs::dtss::Dynamics < common::DoubleTime, SchedulerHandle,
+                                          paradevs::common::NoParameters >
+{
+public:
+    B(const std::string& name,
+      const paradevs::common::NoParameters& parameters) :
+        paradevs::dtss::Dynamics < common::DoubleTime, SchedulerHandle,
+                                   paradevs::common::NoParameters >(name,
+                                                                    parameters)
+    { }
+    virtual ~B()
+    { }
+
+    void transition(const common::Bag < common::DoubleTime,
+                    SchedulerHandle >& x,
+                    common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)x;
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::DELTA_INT)
+            << "x = " << x.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+    }
+
+    common::DoubleTime::type start(common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::START);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        return 0;
+    }
+
+    common::Bag < common::DoubleTime, SchedulerHandle > lambda(
+        common::DoubleTime::type t) const
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+        common::Bag < common::DoubleTime, SchedulerHandle > msgs;
+
+        msgs.push_back(common::ExternalEvent < common::DoubleTime,
+                                               SchedulerHandle >("out", 0.));
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::LAMBDA)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        return msgs;
+    }
+};
+
+} } } // namespace paradevs tests dtss
+
+#endif

+ 120 - 0
src/tests/dtss/tests.cpp

@@ -0,0 +1,120 @@
+/**
+ * @file tests/dtss/tests.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <paradevs/common/scheduler/SchedulerHandle.hpp>
+
+#include <tests/dtss/graph_manager.hpp>
+#include <tests/dtss/models.hpp>
+
+#include <paradevs/common/RootCoordinator.hpp>
+
+#define CATCH_CONFIG_MAIN
+#include <tests/catch.hpp>
+
+using namespace paradevs::tests::dtss;
+using namespace paradevs::common;
+
+TEST_CASE("dtss/only_one", "run")
+{
+
+    paradevs::common::RootCoordinator <
+        DoubleTime, paradevs::dtss::Coordinator <
+            DoubleTime,
+            Policy < paradevs::common::scheduler::NoSchedulerHandle >,
+            OnlyOneGraphManager <
+                paradevs::common::scheduler::NoSchedulerHandle >,
+            paradevs::common::scheduler::NoSchedulerHandle,
+            paradevs::dtss::Parameters < DoubleTime > >
+        > rc(0, 10, "root",
+             paradevs::dtss::Parameters < DoubleTime >(1),
+             paradevs::common::NoParameters());
+
+    paradevs::common::Trace < DoubleTime >::trace().clear();
+    rc.run();
+
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("a").
+            filter_type(paradevs::common::START).size() == 1);
+    for (double t = 0; t <= 10; ++t) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 1);
+    }
+}
+
+TEST_CASE("dtss/two", "run")
+{
+    paradevs::common::RootCoordinator <
+        DoubleTime, paradevs::dtss::Coordinator <
+            DoubleTime,
+            Policy < paradevs::common::scheduler::NoSchedulerHandle >,
+            TwoGraphManager <
+                paradevs::common::scheduler::NoSchedulerHandle >,
+            paradevs::common::scheduler::NoSchedulerHandle,
+            paradevs::dtss::Parameters < DoubleTime > >
+        > rc(0, 10, "root",
+             paradevs::dtss::Parameters < DoubleTime >(1),
+             paradevs::common::NoParameters());
+
+    paradevs::common::Trace < DoubleTime >::trace().clear();
+    rc.run();
+
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("a").
+            filter_type(paradevs::common::START).size() == 1);
+    for (unsigned int t = 0; t <= 10; ++t) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 1);
+    }
+
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("b").
+            filter_type(paradevs::common::START).size() == 1);
+    for (unsigned int t = 0; t <= 10; ++t) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 1);
+    }
+}

+ 19 - 0
src/tests/mixed/CMakeLists.txt

@@ -0,0 +1,19 @@
+INCLUDE_DIRECTORIES(
+  ${CMAKE_SOURCE_DIR}/src
+  ${PARADEVS_INCLUDE_DIRS}
+  ${Boost_INCLUDE_DIRS}
+  ${GLIBMM_INCLUDE_DIRS}
+  ${LIBXML_INCLUDE_DIRS})
+
+LINK_DIRECTORIES(
+  ${GLIBMM_LIBRARY_DIRS}
+  ${LIBXML_LIBRARY_DIR})
+
+SET(MIXED_TESTS_HPP graph_manager.hpp models.hpp)
+
+ADD_EXECUTABLE(mixed-tests ${MIXED_TESTS_HPP} tests.cpp)
+
+TARGET_LINK_LIBRARIES(mixed-tests
+  ${GLIBMM_LIBRARIES}
+  ${LIBXML_LIBRARIES}
+  ${GTHREAD_LIBRARIES})

+ 428 - 0
src/tests/mixed/graph_manager.hpp

@@ -0,0 +1,428 @@
+/**
+ * @file tests/mixed/graph_manager.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_MIXED_GRAPH_MANAGER_HPP
+#define TESTS_MIXED_GRAPH_MANAGER_HPP 1
+
+#include <paradevs/common/scheduler/VectorScheduler.hpp>
+#include <paradevs/common/scheduler/HeapScheduler.hpp>
+
+#include <paradevs/kernel/dtss/Coordinator.hpp>
+#include <paradevs/kernel/dtss/GraphManager.hpp>
+#include <paradevs/kernel/dtss/Simulator.hpp>
+
+#include <paradevs/kernel/pdevs/Coordinator.hpp>
+#include <paradevs/kernel/pdevs/GraphManager.hpp>
+#include <paradevs/kernel/pdevs/Simulator.hpp>
+
+#include <tests/mixed/models.hpp>
+
+namespace paradevs { namespace tests { namespace mixed {
+
+struct SchedulerHandle;
+
+typedef typename paradevs::common::scheduler::HeapScheduler <
+    common::DoubleTime, SchedulerHandle >::type SchedulerType;
+
+struct SchedulerHandle
+{
+    SchedulerHandle()
+    { }
+
+    SchedulerHandle(const SchedulerType::handle_type& handle)
+        : _handle(handle)
+    { }
+
+    const SchedulerHandle& handle() const
+    { return *this; }
+
+    void handle(const SchedulerHandle& handle)
+    { _handle = handle._handle; }
+
+    SchedulerType::handle_type _handle;
+};
+
+template < class SchedulerHandle >
+struct LastBagPolicy
+{
+    const common::Bag < common::DoubleTime, SchedulerHandle >& bag() const
+    { return _bag; }
+
+    virtual void operator()(
+        typename common::DoubleTime::type /* t */,
+        const common::ExternalEvent < common::DoubleTime,
+                                      SchedulerHandle >& event,
+        typename common::DoubleTime::type /* tl */,
+        typename common::DoubleTime::type /* tn */)
+    {
+        _bag.clear();
+        _bag.push_back(event);
+    }
+
+private:
+    common::Bag < common::DoubleTime, SchedulerHandle > _bag;
+};
+
+template < class SchedulerHandle >
+struct IgnorePolicy
+{
+    const common::Bag < common::DoubleTime, SchedulerHandle >& bag() const
+    { return _bag; }
+
+    virtual void operator()(
+        typename common::DoubleTime::type /* t */,
+        const common::ExternalEvent < common::DoubleTime,
+                                      SchedulerHandle >& /* event */,
+        typename common::DoubleTime::type /* tl */,
+        typename common::DoubleTime::type /* tn */)
+    { }
+
+private:
+    common::Bag < common::DoubleTime, SchedulerHandle > _bag;
+};
+
+template < class SchedulerHandle >
+class S1GraphManager :
+        public pdevs::GraphManager < common::DoubleTime, SchedulerHandle,
+                                     paradevs::common::NoParameters >
+{
+public:
+    S1GraphManager(common::Coordinator < common::DoubleTime,
+                                         SchedulerHandle >* coordinator,
+                   const paradevs::common::NoParameters& parameters) :
+        pdevs::GraphManager < common::DoubleTime, SchedulerHandle,
+                              paradevs::common::NoParameters >(
+                                  coordinator, parameters),
+        a("a1", paradevs::common::NoParameters()),
+        b("b1", paradevs::common::NoParameters())
+    {
+        S1GraphManager < SchedulerHandle >::add_child(&a);
+        S1GraphManager < SchedulerHandle >::add_child(&b);
+
+        a.add_out_port("out");
+        b.add_in_port("in");
+        b.add_out_port("out");
+        coordinator->add_out_port("out");
+
+        S1GraphManager < SchedulerHandle >::add_link(&a, "out",
+                                                     &b, "in");
+        S1GraphManager < SchedulerHandle >::add_link(&b, "out",
+                                                     coordinator, "out");
+    }
+
+    virtual ~S1GraphManager()
+    { }
+
+private:
+    pdevs::Simulator < common::DoubleTime,
+                       A1 < SchedulerHandle >,
+                       SchedulerHandle,
+                       paradevs::common::NoParameters > a;
+    pdevs::Simulator < common::DoubleTime,
+                       B1 < SchedulerHandle >,
+                       SchedulerHandle,
+                       paradevs::common::NoParameters > b;
+};
+
+template < class SchedulerHandle >
+class S2GraphManager :
+        public dtss::GraphManager < common::DoubleTime, SchedulerHandle >
+{
+public:
+    S2GraphManager(common::Coordinator < common::DoubleTime,
+                                         SchedulerHandle >* coordinator,
+                   const paradevs::common::NoParameters& parameters) :
+        dtss::GraphManager < common::DoubleTime,
+                             SchedulerHandle >(coordinator, parameters),
+        a("a2", 20, paradevs::common::NoParameters()),
+        b("b2", 20, paradevs::common::NoParameters())
+    {
+        S2GraphManager < SchedulerHandle >::add_child(&a);
+        S2GraphManager < SchedulerHandle >::add_child(&b);
+
+        a.add_in_port("in");
+        a.add_out_port("out");
+        b.add_in_port("in");
+        coordinator->add_in_port("in");
+
+        S2GraphManager < SchedulerHandle >::add_link(&a, "out", &b, "in");
+        S2GraphManager < SchedulerHandle >::add_link(coordinator, "in",
+                                                     &a, "in");
+    }
+
+    virtual ~S2GraphManager()
+    { }
+
+private:
+    dtss::Simulator < common::DoubleTime,
+                      A2 < SchedulerHandle >,
+                      SchedulerHandle
+                    > a;
+    dtss::Simulator < common::DoubleTime,
+                      B2 < SchedulerHandle >,
+                      SchedulerHandle
+                    > b;
+};
+
+class RootGraphManager :
+        public pdevs::GraphManager < common::DoubleTime, SchedulerHandle,
+                                     paradevs::common::NoParameters >
+{
+public:
+    RootGraphManager(common::Coordinator < common::DoubleTime,
+                                           SchedulerHandle >* coordinator,
+                     const paradevs::common::NoParameters& parameters) :
+        pdevs::GraphManager < common::DoubleTime, SchedulerHandle,
+                              paradevs::common::NoParameters >(
+                                  coordinator, parameters),
+        S1("S1", paradevs::common::NoParameters(),
+           paradevs::common::NoParameters()),
+        S2("S2", paradevs::dtss::Parameters < common::DoubleTime >(20),
+           paradevs::common::NoParameters())
+    {
+        add_child(&S1);
+        add_child(&S2);
+        add_link(&S1, "out", &S2, "in");
+    }
+
+    virtual ~RootGraphManager()
+    { }
+
+private:
+    paradevs::pdevs::Coordinator <
+        common::DoubleTime,
+        SchedulerType,
+        SchedulerHandle,
+        S1GraphManager < SchedulerHandle >
+    > S1;
+    paradevs::dtss::Coordinator <
+        common::DoubleTime,
+        LastBagPolicy < SchedulerHandle >,
+        S2GraphManager < SchedulerHandle >,
+        SchedulerHandle,
+        paradevs::dtss::Parameters < common::DoubleTime >
+    > S2;
+};
+
+template < int size, class SchedulerHandle >
+class LinearGraphManager :
+        public pdevs::GraphManager < common::DoubleTime, SchedulerHandle,
+                                     paradevs::common::NoParameters >
+{
+public:
+    LinearGraphManager(common::Coordinator < common::DoubleTime,
+                                             SchedulerHandle >* coordinator,
+                       const paradevs::common::NoParameters& parameters) :
+        pdevs::GraphManager < common::DoubleTime, SchedulerHandle,
+                              paradevs::common::NoParameters >(
+                                  coordinator, parameters)
+    {
+        for (unsigned int i = 1; i <= size; ++i) {
+            std::ostringstream ss;
+
+            ss << "a" << i;
+            _models.push_back(
+                new pdevs::Simulator < common::DoubleTime,
+                                       Beep < SchedulerHandle >,
+                                       SchedulerHandle,
+                                       paradevs::common::NoParameters >(
+                                           ss.str(),
+                                           paradevs::common::NoParameters()));
+        }
+        for (unsigned int i = 0; i < size; ++i) {
+            LinearGraphManager < size, SchedulerHandle >::add_child(_models[i]);
+
+            _models[i]->add_in_port("in");
+            _models[i]->add_out_port("out");
+        }
+        for (unsigned int i = 0; i < size - 1; ++i) {
+            LinearGraphManager < size,
+                                 SchedulerHandle >::add_link(_models[i],
+                                                             "out",
+                                                             _models[i + 1],
+                                                             "in");
+        }
+    }
+
+    virtual ~LinearGraphManager()
+    {
+        for (unsigned int i = 0; i < size; ++i) {
+            delete _models[i];
+        }
+    }
+
+private:
+    std::vector <
+    pdevs::Simulator < common::DoubleTime,
+                       Beep < SchedulerHandle >,
+                       SchedulerHandle,
+                       paradevs::common::NoParameters >* > _models;
+};
+
+template < class SchedulerHandle >
+class Linear2GraphManager :
+        public pdevs::GraphManager < common::DoubleTime, SchedulerHandle,
+                                     paradevs::common::NoParameters >
+{
+public:
+    Linear2GraphManager(common::Coordinator < common::DoubleTime,
+                                              SchedulerHandle >* coordinator,
+                        const paradevs::common::NoParameters& parameters) :
+        pdevs::GraphManager < common::DoubleTime, SchedulerHandle,
+                              paradevs::common::NoParameters >(
+                                  coordinator, parameters)
+    {
+        for (unsigned int i = 1; i <= 100; ++i) {
+            std::ostringstream ss;
+
+            ss << "a" << i;
+            _models.push_back(
+                new pdevs::Simulator < common::DoubleTime,
+                                       Beep < SchedulerHandle >,
+                                       SchedulerHandle,
+                                       paradevs::common::NoParameters >(
+                                           ss.str(),
+                                           paradevs::common::NoParameters()));
+        }
+        for (unsigned int i = 0; i < 100; ++i) {
+            Linear2GraphManager < SchedulerHandle >::add_child(_models[i]);
+
+            _models[i]->add_in_port("in");
+            _models[i]->add_out_port("out");
+        }
+        for (unsigned int i = 0; i < 99; ++i) {
+            Linear2GraphManager < SchedulerHandle >::add_link(_models[i], "out",
+                                                              _models[i + 1],
+                                                              "in");
+        }
+
+        coordinator->add_in_port("in");
+        coordinator->add_out_port("out");
+
+        Linear2GraphManager < SchedulerHandle >::add_link(coordinator, "in",
+                                                          _models[0], "in");
+        Linear2GraphManager < SchedulerHandle >::add_link(_models[49], "out",
+                                                          coordinator, "out");
+    }
+
+    virtual ~Linear2GraphManager()
+    {
+        for (unsigned int i = 0; i < 100; ++i) {
+            delete _models[i];
+        }
+    }
+
+private:
+    std::vector <
+        pdevs::Simulator < common::DoubleTime, Beep < SchedulerHandle >,
+                           SchedulerHandle,
+                           paradevs::common::NoParameters >* > _models;
+};
+
+class Root2GraphManager :
+        public pdevs::GraphManager < common::DoubleTime, SchedulerHandle,
+                                     paradevs::common::NoParameters >
+{
+public:
+    Root2GraphManager(common::Coordinator < common::DoubleTime,
+                                            SchedulerHandle >* coordinator,
+                      const paradevs::common::NoParameters& parameters) :
+        pdevs::GraphManager < common::DoubleTime, SchedulerHandle,
+                              paradevs::common::NoParameters >(
+                                  coordinator, parameters),
+        S1("S1", paradevs::common::NoParameters(),
+           paradevs::common::NoParameters()),
+        S2("S2", paradevs::common::NoParameters(),
+           paradevs::common::NoParameters())
+    {
+        add_child(&S1);
+        add_child(&S2);
+        add_link(&S1, "out", &S2, "in");
+    }
+
+    virtual ~Root2GraphManager()
+    { }
+
+private:
+    paradevs::pdevs::Coordinator <
+        common::DoubleTime,
+        SchedulerType,
+        SchedulerHandle,
+        Linear2GraphManager < SchedulerHandle > > S1;
+    paradevs::pdevs::Coordinator <
+        common::DoubleTime,
+        SchedulerType,
+        SchedulerHandle,
+        Linear2GraphManager < SchedulerHandle > > S2;
+};
+
+class Root3GraphManager :
+        public pdevs::GraphManager <
+            common::DoubleTime,
+            paradevs::common::scheduler::NoSchedulerHandle,
+            paradevs::common::NoParameters >
+{
+public:
+    Root3GraphManager(
+        common::Coordinator <
+            common::DoubleTime,
+            paradevs::common::scheduler::NoSchedulerHandle >* coordinator,
+        const paradevs::common::NoParameters& parameters) :
+        pdevs::GraphManager < common::DoubleTime,
+                              paradevs::common::scheduler::NoSchedulerHandle,
+                              paradevs::common::NoParameters >(
+                                  coordinator, parameters),
+        S1("S1", paradevs::common::NoParameters(),
+           paradevs::common::NoParameters()),
+        S2("S2", paradevs::common::NoParameters(),
+           paradevs::common::NoParameters())
+    {
+        add_child(&S1);
+        add_child(&S2);
+        add_link(&S1, "out", &S2, "in");
+    }
+
+    virtual ~Root3GraphManager()
+    { }
+
+private:
+    pdevs::Coordinator <
+        common::DoubleTime,
+        paradevs::common::scheduler::VectorScheduler < common::DoubleTime >,
+        paradevs::common::scheduler::NoSchedulerHandle,
+        Linear2GraphManager < paradevs::common::scheduler::NoSchedulerHandle >
+    > S1;
+    pdevs::Coordinator <
+        common::DoubleTime,
+        paradevs::common::scheduler::VectorScheduler < common::DoubleTime >,
+        paradevs::common::scheduler::NoSchedulerHandle,
+        Linear2GraphManager < paradevs::common::scheduler::NoSchedulerHandle >
+    > S2;
+};
+
+} } } // namespace paradevs tests mixed
+
+#endif

+ 622 - 0
src/tests/mixed/models.hpp

@@ -0,0 +1,622 @@
+/**
+ * @file tests/mixed/models.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_MIXED_MODELS_HPP
+#define TESTS_MIXED_MODELS_HPP 1
+
+#include <paradevs/common/time/DoubleTime.hpp>
+#include <paradevs/common/utils/Trace.hpp>
+
+#include <paradevs/kernel/dtss/Dynamics.hpp>
+
+#include <paradevs/kernel/pdevs/Dynamics.hpp>
+
+namespace paradevs { namespace tests { namespace mixed {
+
+template < class SchedulerHandle>
+class A1 :
+        public paradevs::pdevs::Dynamics < common::DoubleTime, SchedulerHandle,
+                                           paradevs::common::NoParameters >
+{
+public:
+    A1(const std::string& name,
+       const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::Dynamics < common::DoubleTime, SchedulerHandle,
+                                    paradevs::common::NoParameters >(
+                                        name, parameters)
+    { }
+    virtual ~A1()
+    { }
+
+    void dint(typename common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace() <<
+            common::TraceElement < common::DoubleTime >(
+                A1 < SchedulerHandle >::get_name(), t, common::DELTA_INT);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        if (_phase == SEND) {
+            _phase = WAIT;
+        }
+    }
+
+    void dext(typename common::DoubleTime::type t,
+              typename common::DoubleTime::type /* e */,
+              const common::Bag < common::DoubleTime, SchedulerHandle >& msgs)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+        (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A1 < SchedulerHandle >::get_name(), t, common::DELTA_EXT)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        _phase = SEND;
+    }
+
+    void dconf(typename common::DoubleTime::type t,
+               typename common::DoubleTime::type /* e */,
+               const common::Bag < common::DoubleTime, SchedulerHandle >& msgs)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+        (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A1 < SchedulerHandle >::get_name(), t, common::DELTA_CONF)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+    }
+
+    typename common::DoubleTime::type start(typename common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A1 < SchedulerHandle >::get_name(), t, common::START);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+        _phase = WAIT;
+        return 0;
+    }
+
+    typename common::DoubleTime::type ta(
+        typename common::DoubleTime::type t) const
+    {
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A1 < SchedulerHandle >::get_name(), t, common::TA);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+        if (_phase == WAIT) {
+            return 1;
+        } else {
+            return 0;
+        }
+    }
+
+    common::Bag < common::DoubleTime, SchedulerHandle > lambda(
+        typename common::DoubleTime::type t) const
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+        common::Bag < common::DoubleTime, SchedulerHandle > msgs;
+
+        msgs.push_back(common::ExternalEvent < common::DoubleTime,
+                                               SchedulerHandle >("out", 0.));
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A1 < SchedulerHandle >::get_name(), t, common::LAMBDA)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        return msgs;
+    }
+
+private:
+    enum Phase { WAIT, SEND };
+
+    Phase _phase;
+};
+
+template < class SchedulerHandle>
+class B1 :
+        public paradevs::pdevs::Dynamics < common::DoubleTime, SchedulerHandle,
+                                           paradevs::common::NoParameters >
+{
+public:
+    B1(const std::string& name,
+       const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::Dynamics < common::DoubleTime, SchedulerHandle,
+                                    paradevs::common::NoParameters >(
+                                        name, parameters)
+    { }
+    virtual ~B1()
+    { }
+
+    void dint(typename common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B1 < SchedulerHandle >::get_name(), t, common::DELTA_INT);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        if (_phase == SEND) {
+            _phase = WAIT;
+        }
+    }
+
+    void dext(typename common::DoubleTime::type t,
+              typename common::DoubleTime::type /* e */,
+              const common::Bag < common::DoubleTime, SchedulerHandle >& msgs)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+        (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B1 < SchedulerHandle >::get_name(), t, common::DELTA_EXT)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        _phase = SEND;
+    }
+
+    void dconf(typename common::DoubleTime::type t,
+               typename common::DoubleTime::type /* e */,
+               const common::Bag < common::DoubleTime, SchedulerHandle >& msgs)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+        (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B1 < SchedulerHandle >::get_name(), t, common::DELTA_CONF)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+    }
+
+    typename common::DoubleTime::type start(typename common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B1 < SchedulerHandle >::get_name(), t, common::START);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        _phase = WAIT;
+        return std::numeric_limits < double >::max();
+    }
+
+    typename common::DoubleTime::type ta(
+        typename common::DoubleTime::type t) const
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B1 < SchedulerHandle >::get_name(), t, common::TA);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        if (_phase == WAIT) {
+            return std::numeric_limits < double >::max();
+        } else {
+            return 0;
+        }
+    }
+
+    common::Bag < common::DoubleTime, SchedulerHandle > lambda(
+        typename common::DoubleTime::type t) const
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+        common::Bag < common::DoubleTime, SchedulerHandle > msgs;
+
+        msgs.push_back(common::ExternalEvent < common::DoubleTime,
+                                               SchedulerHandle >("out", t));
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B1 < SchedulerHandle >::get_name(), t, common::LAMBDA)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        return msgs;
+    }
+
+private:
+    enum Phase { WAIT, SEND };
+
+    Phase _phase;
+};
+
+template < class SchedulerHandle >
+class A2 :
+        public paradevs::dtss::Dynamics < common::DoubleTime, SchedulerHandle >
+{
+public:
+    A2(const std::string& name,
+       const paradevs::common::NoParameters& parameters) :
+        paradevs::dtss::Dynamics < common::DoubleTime, SchedulerHandle,
+                                   paradevs::common::NoParameters >(
+                                       name, parameters)
+    { }
+    virtual ~A2()
+    { }
+
+    void transition(
+        const common::Bag < common::DoubleTime, SchedulerHandle >& x,
+        typename common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)x;
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A2 < SchedulerHandle >::get_name(), t, common::DELTA_INT)
+            << "x = " << x.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+    }
+
+    typename common::DoubleTime::type start(typename common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A2 < SchedulerHandle >::get_name(), t, common::START);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        return 0;
+    }
+
+    common::Bag < common::DoubleTime, SchedulerHandle > lambda(
+        typename common::DoubleTime::type t) const
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+        common::Bag < common::DoubleTime, SchedulerHandle > msgs;
+
+        msgs.push_back(
+            common::ExternalEvent < common::DoubleTime,
+                                    SchedulerHandle >( "out", 0.));
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A2 < SchedulerHandle >::get_name(), t, common::LAMBDA)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        return msgs;
+    }
+};
+
+template < class SchedulerHandle >
+class B2 :
+        public paradevs::dtss::Dynamics < common::DoubleTime, SchedulerHandle >
+{
+public:
+    B2(const std::string& name,
+       const paradevs::common::NoParameters& parameters) :
+        paradevs::dtss::Dynamics < common::DoubleTime, SchedulerHandle,
+                                   paradevs::common::NoParameters >(
+                                       name, parameters)
+    { }
+    virtual ~B2()
+    { }
+
+    void transition(
+        const common::Bag < common::DoubleTime, SchedulerHandle >& x,
+        typename common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)x;
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B2 < SchedulerHandle >::get_name(), t, common::DELTA_INT)
+            << "x = " << x.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+    }
+
+    typename common::DoubleTime::type start(typename common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B2 < SchedulerHandle >::get_name(), t, common::START);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        return 0;
+    }
+
+    common::Bag < common::DoubleTime, SchedulerHandle > lambda(
+        typename common::DoubleTime::type t) const
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+        common::Bag < common::DoubleTime, SchedulerHandle > msgs;
+
+        msgs.push_back(
+            common::ExternalEvent < common::DoubleTime,
+                                    SchedulerHandle >("out", 0.));
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B2 < SchedulerHandle >::get_name(), t, common::LAMBDA)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        return msgs;
+    }
+};
+
+template < class SchedulerHandle>
+class Beep :
+        public paradevs::pdevs::Dynamics < common::DoubleTime, SchedulerHandle,
+                                           paradevs::common::NoParameters >
+{
+public:
+    Beep(const std::string& name,
+         const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::Dynamics < common::DoubleTime, SchedulerHandle,
+                                    paradevs::common::NoParameters >(name,
+                                                                     parameters)
+    { }
+    virtual ~Beep()
+    { }
+
+    void dint(typename common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace() <<
+            common::TraceElement < common::DoubleTime >(
+                Beep < SchedulerHandle >::get_name(), t, common::DELTA_INT);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        if (_phase == SEND) {
+            _phase = WAIT;
+        }
+    }
+
+    void dext(typename common::DoubleTime::type t,
+              typename common::DoubleTime::type /* e */,
+              const common::Bag < common::DoubleTime, SchedulerHandle >& msgs)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+        (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                Beep < SchedulerHandle >::get_name(), t, common::DELTA_EXT)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        _phase = SEND;
+    }
+
+    void dconf(typename common::DoubleTime::type t,
+               typename common::DoubleTime::type /* e */,
+               const common::Bag < common::DoubleTime, SchedulerHandle >& msgs)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+        (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                Beep < SchedulerHandle >::get_name(), t, common::DELTA_CONF)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+    }
+
+    typename common::DoubleTime::type start(typename common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                Beep < SchedulerHandle >::get_name(), t, common::START);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        _phase = WAIT;
+        return 0;
+    }
+
+    typename common::DoubleTime::type ta(
+        typename common::DoubleTime::type t) const
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                Beep < SchedulerHandle >::get_name(), t, common::TA);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        if (_phase == WAIT) {
+            return (rand() % 100) / 10.;
+        } else {
+            return 0;
+        }
+    }
+
+    common::Bag < common::DoubleTime, SchedulerHandle > lambda(
+        typename common::DoubleTime::type t) const
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+        common::Bag < common::DoubleTime, SchedulerHandle > msgs;
+
+        msgs.push_back(common::ExternalEvent < common::DoubleTime,
+                                               SchedulerHandle >("out", 0.));
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                Beep < SchedulerHandle >::get_name(), t, common::LAMBDA)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        return msgs;
+    }
+
+private:
+    enum Phase { WAIT, SEND };
+
+    Phase _phase;
+};
+
+} } } // namespace paradevs tests mixed
+
+#endif

+ 124 - 0
src/tests/mixed/tests.cpp

@@ -0,0 +1,124 @@
+/**
+ * @file tests/mixed/tests.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <paradevs/common/RootCoordinator.hpp>
+
+#include <tests/mixed/graph_manager.hpp>
+#include <tests/mixed/models.hpp>
+
+#define CATCH_CONFIG_MAIN
+#include <tests/catch.hpp>
+
+using namespace paradevs::tests::mixed;
+using namespace paradevs::common;
+
+TEST_CASE("mixed/hierachical", "run")
+{
+    paradevs::common::RootCoordinator <
+        DoubleTime,
+        paradevs::pdevs::Coordinator <
+            DoubleTime,
+            paradevs::common::scheduler::HeapScheduler <
+                DoubleTime, SchedulerHandle >,
+            SchedulerHandle,
+            RootGraphManager >
+        > rc(0, 100, "root");
+
+    paradevs::common::Trace < DoubleTime >::trace().clear();
+    rc.run();
+
+    REQUIRE(paradevs::common::Trace < DoubleTime >::trace().elements().
+            filter_model_name("a1").
+            filter_type(paradevs::common::START).size() == 1);
+    REQUIRE(paradevs::common::Trace < DoubleTime >::trace().elements().
+            filter_model_name("b1").
+            filter_type(paradevs::common::START).size() == 1);
+    REQUIRE(paradevs::common::Trace < DoubleTime >::trace().elements().
+            filter_model_name("a2").
+            filter_type(paradevs::common::START).size() == 1);
+    REQUIRE(paradevs::common::Trace < DoubleTime >::trace().elements().
+            filter_model_name("b2").
+            filter_type(paradevs::common::START).size() == 1);
+
+    REQUIRE(paradevs::common::Trace < DoubleTime >::trace().elements().
+            filter_model_name("a1").
+            filter_type(paradevs::common::DELTA_EXT).size() == 0);
+    for (double t = 0; t <= 100; ++t) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a1").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a1").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a1").filter_time(t).
+                filter_type(paradevs::common::TA).size() == 1);
+    }
+
+    for (double t = 0; t <= 100; ++t) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b1").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b1").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b1").filter_time(t).
+                filter_type(paradevs::common::TA).size() == 2);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b1").filter_time(t).
+                filter_type(paradevs::common::DELTA_EXT).size() == 1);
+    }
+
+    for (unsigned int t = 0; t <= 100; t += 20) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a2").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a2").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 1);
+    }
+
+    for (unsigned int t = 0; t <= 100; t += 20) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b2").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b2").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 1);
+    }
+}

+ 16 - 0
src/tests/multithreading/CMakeLists.txt

@@ -0,0 +1,16 @@
+INCLUDE_DIRECTORIES(
+  ${CMAKE_SOURCE_DIR}/src
+  ${PARADEVS_INCLUDE_DIRS}
+  ${Boost_INCLUDE_DIRS}
+  ${GLIBMM_INCLUDE_DIRS}
+  ${LIBXML_INCLUDE_DIRS})
+
+LINK_DIRECTORIES(
+  ${GLIBMM_LIBRARY_DIRS}
+  ${LIBXML_LIBRARY_DIR})
+
+ADD_EXECUTABLE(pdevs-multithreading-tests graph_manager.hpp tests.cpp)
+
+TARGET_LINK_LIBRARIES(pdevs-multithreading-tests
+  ${Boost_SYSTEM_LIBRARY}
+  ${Boost_TIMER_LIBRARY})

+ 406 - 0
src/tests/multithreading/graph_manager.hpp

@@ -0,0 +1,406 @@
+/**
+ * @file tests/multithreading/graph_manager.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_PDEVS_MULTITHREADING_GRAPH_MANAGER_HPP
+#define TESTS_PDEVS_MULTITHREADING_GRAPH_MANAGER_HPP 1
+
+#include <tests/pdevs/models.hpp>
+#include <tests/pdevs/graph_manager.hpp>
+
+#include <paradevs/kernel/pdevs/multithreading/Coordinator.hpp>
+#include <paradevs/kernel/pdevs/GraphManager.hpp>
+#include <paradevs/kernel/pdevs/Simulator.hpp>
+
+namespace paradevs { namespace tests { namespace multithreading {
+
+template < class SchedulerHandle >
+class S1GraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               SchedulerHandle >
+{
+public:
+    S1GraphManager(common::Coordinator < common::DoubleTime,
+                                         SchedulerHandle >* coordinator,
+                   const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime,
+                                        SchedulerHandle >(coordinator,
+                                                          parameters),
+        a("a1", common::NoParameters()), b("b1", common::NoParameters())
+    {
+        S1GraphManager < SchedulerHandle >::add_child(&a);
+        S1GraphManager < SchedulerHandle >::add_child(&b);
+
+        a.add_out_port("out");
+        b.add_in_port("in");
+        b.add_out_port("out");
+        coordinator->add_out_port("out");
+
+        S1GraphManager < SchedulerHandle >::add_link(&a, "out", &b, "in");
+        S1GraphManager < SchedulerHandle >::add_link(&b, "out",
+                                                     coordinator, "out");
+    }
+
+    void init()
+    { }
+
+    void start(common::DoubleTime::type /* t */)
+    { }
+
+    void transition(
+        const common::Models < common::DoubleTime,
+                               pdevs::SchedulerHandle >& /* receivers */,
+        common::DoubleTime::type /* t */)
+    { }
+
+    virtual ~S1GraphManager()
+    { }
+
+private:
+    paradevs::pdevs::Simulator < common::DoubleTime,
+                                 pdevs::A < SchedulerHandle >,
+                                 SchedulerHandle > a;
+    paradevs::pdevs::Simulator < common::DoubleTime,
+                                 pdevs::B < SchedulerHandle >,
+                                 SchedulerHandle > b;
+};
+
+template < class SchedulerHandle >
+class S2GraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               SchedulerHandle >
+{
+public:
+    S2GraphManager(common::Coordinator < common::DoubleTime,
+                                         SchedulerHandle >* coordinator,
+                   const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime,
+                                        SchedulerHandle >(coordinator,
+                                                          parameters),
+        a("a2", common::NoParameters()), b("b2", common::NoParameters())
+    {
+        S2GraphManager < SchedulerHandle >::add_child(&a);
+        S2GraphManager < SchedulerHandle >::add_child(&b);
+
+        a.add_in_port("in");
+        a.add_out_port("out");
+        b.add_in_port("in");
+        coordinator->add_in_port("in");
+
+        S2GraphManager < SchedulerHandle >::add_link(&a, "out", &b, "in");
+        S2GraphManager < SchedulerHandle >::add_link(coordinator, "in",
+                                                     &a, "in");
+    }
+
+    void init()
+    { }
+
+    void start(common::DoubleTime::type /* t */)
+    { }
+
+    void transition(
+        const common::Models < common::DoubleTime,
+                               pdevs::SchedulerHandle >& /* receivers */,
+        common::DoubleTime::type /* t */)
+    { }
+
+    virtual ~S2GraphManager()
+    { }
+
+private:
+    paradevs::pdevs::Simulator < common::DoubleTime,
+                                 pdevs::A < SchedulerHandle >,
+                                 SchedulerHandle > a;
+    paradevs::pdevs::Simulator < common::DoubleTime,
+                                 pdevs::B < SchedulerHandle >,
+                                 SchedulerHandle > b;
+};
+
+class RootGraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               pdevs::SchedulerHandle >
+{
+public:
+    RootGraphManager(
+        common::Coordinator < common::DoubleTime,
+                              pdevs::SchedulerHandle >* coordinator,
+        const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime,
+                                        pdevs::SchedulerHandle >(
+                                            coordinator, parameters),
+        S1("S1", paradevs::common::NoParameters(),
+           paradevs::common::NoParameters()),
+        S2("S2", paradevs::common::NoParameters(),
+           paradevs::common::NoParameters())
+    {
+        add_child(&S1);
+        add_child(&S2);
+
+        add_link(&S1, "out", &S2, "in");
+    }
+
+    void init()
+    {
+        S1.set_sender(
+            dynamic_cast < paradevs::pdevs::multithreading::Coordinator <
+                common::DoubleTime,
+                paradevs::common::scheduler::HeapScheduler <
+                    common::DoubleTime, pdevs::SchedulerHandle >,
+                pdevs::SchedulerHandle,
+                paradevs::tests::multithreading::RootGraphManager >*
+            >(get_coordinator())->get_sender());
+        S2.set_sender(
+            dynamic_cast < paradevs::pdevs::multithreading::Coordinator <
+                common::DoubleTime,
+                paradevs::common::scheduler::HeapScheduler <
+                    common::DoubleTime, pdevs::SchedulerHandle >,
+                pdevs::SchedulerHandle,
+                paradevs::tests::multithreading::RootGraphManager >*
+            >(get_coordinator())->get_sender());
+    }
+
+    void start(common::DoubleTime::type t)
+    {
+        S1.get_sender().send(
+            paradevs::pdevs::multithreading::start_message <
+                common::DoubleTime >(t));
+        S2.get_sender().send(
+            paradevs::pdevs::multithreading::start_message <
+                common::DoubleTime >(t));
+    }
+
+    void transition(const common::Models < common::DoubleTime,
+                                           pdevs::SchedulerHandle >& receivers,
+                    common::DoubleTime::type t)
+    {
+        if (std::find(receivers.begin(), receivers.end(),
+                      &S1) != receivers.end()) {
+            S1.get_sender().send(
+                paradevs::pdevs::multithreading::transition_message <
+                    common::DoubleTime >(t));
+        }
+        if (std::find(receivers.begin(), receivers.end(),
+                      &S2) != receivers.end()) {
+            S2.get_sender().send(
+                paradevs::pdevs::multithreading::transition_message <
+                    common::DoubleTime >(t));
+        }
+    }
+
+    virtual ~RootGraphManager()
+    { }
+
+private:
+    paradevs::pdevs::multithreading::Coordinator <
+        common::DoubleTime,
+        pdevs::SchedulerType,
+        pdevs::SchedulerHandle,
+        S1GraphManager < pdevs::SchedulerHandle > > S1;
+    paradevs::pdevs::multithreading::Coordinator <
+        common::DoubleTime,
+        pdevs::SchedulerType,
+        pdevs::SchedulerHandle,
+        S2GraphManager < pdevs::SchedulerHandle > > S2;
+};
+
+template < class SchedulerHandle >
+class S3GraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               SchedulerHandle >
+{
+public:
+    S3GraphManager(common::Coordinator < common::DoubleTime,
+                                         SchedulerHandle >* coordinator,
+                   const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime,
+                                        SchedulerHandle >(coordinator,
+                                                          parameters)
+    {
+        coordinator->add_out_port("out");
+        for (unsigned int i = 0; i < 10; ++i) {
+            std::ostringstream ss;
+            simulator_type* s = new simulator_type(ss.str(),
+                                                   common::NoParameters());
+
+            ss << "a" << (i + 1);
+            _simulators.push_back(s);
+            S3GraphManager < SchedulerHandle >::add_child(s);
+            s->add_out_port("out");
+        }
+    }
+
+    void init()
+    { }
+
+    void start(common::DoubleTime::type /* t */)
+    { }
+
+    void transition(
+        const common::Models < common::DoubleTime,
+                               pdevs::SchedulerHandle >& /* receivers */,
+        common::DoubleTime::type /* t */)
+    { }
+
+    virtual ~S3GraphManager()
+    {
+        for (typename std::vector < simulator_type* >::const_iterator it =
+                 _simulators.begin(); it != _simulators.end(); ++it) {
+            delete *it;
+        }
+    }
+
+private:
+    typedef paradevs::pdevs::Simulator < common::DoubleTime,
+                                         pdevs::A < SchedulerHandle >,
+                                         SchedulerHandle > simulator_type;
+
+    std::vector < simulator_type* > _simulators;
+};
+
+class Root2GraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               pdevs::SchedulerHandle >
+{
+public:
+    Root2GraphManager(
+        common::Coordinator < common::DoubleTime,
+                              pdevs::SchedulerHandle >* coordinator,
+        const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime,
+                                        pdevs::SchedulerHandle >(
+                                            coordinator, parameters),
+        S1("S1", paradevs::common::NoParameters(),
+           paradevs::common::NoParameters()),
+        S2("S2", paradevs::common::NoParameters(),
+           paradevs::common::NoParameters())
+    {
+        add_child(&S1);
+        add_child(&S2);
+    }
+
+    void init()
+    {
+        S1.set_sender(
+            dynamic_cast < paradevs::pdevs::multithreading::Coordinator <
+                common::DoubleTime,
+                paradevs::common::scheduler::HeapScheduler <
+                    common::DoubleTime, pdevs::SchedulerHandle >,
+                pdevs::SchedulerHandle,
+                paradevs::tests::multithreading::Root2GraphManager >*
+            >(get_coordinator())->get_sender());
+        S2.set_sender(
+            dynamic_cast < paradevs::pdevs::multithreading::Coordinator <
+                common::DoubleTime,
+                paradevs::common::scheduler::HeapScheduler <
+                    common::DoubleTime, pdevs::SchedulerHandle >,
+                pdevs::SchedulerHandle,
+                paradevs::tests::multithreading::Root2GraphManager >*
+            >(get_coordinator())->get_sender());
+    }
+
+    void start(common::DoubleTime::type t)
+    {
+        S1.get_sender().send(
+            paradevs::pdevs::multithreading::start_message <
+                common::DoubleTime >(t));
+        S2.get_sender().send(
+            paradevs::pdevs::multithreading::start_message <
+                common::DoubleTime >(t));
+    }
+
+    void transition(const common::Models < common::DoubleTime,
+                                           pdevs::SchedulerHandle >& receivers,
+                    common::DoubleTime::type t)
+    {
+        if (std::find(receivers.begin(), receivers.end(),
+                      &S1) != receivers.end()) {
+            S1.get_sender().send(
+                paradevs::pdevs::multithreading::transition_message <
+                    common::DoubleTime >(t));
+        }
+        if (std::find(receivers.begin(), receivers.end(),
+                      &S2) != receivers.end()) {
+            S2.get_sender().send(
+                paradevs::pdevs::multithreading::transition_message <
+                    common::DoubleTime >(t));
+        }
+    }
+
+    virtual ~Root2GraphManager()
+    { }
+
+private:
+    paradevs::pdevs::multithreading::Coordinator <
+        common::DoubleTime,
+        pdevs::SchedulerType,
+        pdevs::SchedulerHandle,
+        S3GraphManager < pdevs::SchedulerHandle > > S1;
+    paradevs::pdevs::multithreading::Coordinator <
+        common::DoubleTime,
+        pdevs::SchedulerType,
+        pdevs::SchedulerHandle,
+        S3GraphManager < pdevs::SchedulerHandle > > S2;
+};
+
+class Root3GraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               pdevs::SchedulerHandle >
+{
+public:
+    Root3GraphManager(
+        common::Coordinator < common::DoubleTime,
+                              pdevs::SchedulerHandle >* coordinator,
+        const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime,
+                                        pdevs::SchedulerHandle >(
+                                            coordinator, parameters),
+        S1("S1", paradevs::common::NoParameters(),
+           paradevs::common::NoParameters()),
+        S2("S2", paradevs::common::NoParameters(),
+           paradevs::common::NoParameters())
+    {
+        add_child(&S1);
+        add_child(&S2);
+    }
+
+    virtual ~Root3GraphManager()
+    { }
+
+private:
+    paradevs::pdevs::Coordinator <
+        common::DoubleTime,
+        pdevs::SchedulerType,
+        pdevs::SchedulerHandle,
+        S3GraphManager < pdevs::SchedulerHandle > > S1;
+    paradevs::pdevs::Coordinator <
+        common::DoubleTime,
+        pdevs::SchedulerType,
+        pdevs::SchedulerHandle,
+        S3GraphManager < pdevs::SchedulerHandle > > S2;
+};
+
+} } } // namespace paradevs tests multithreading
+
+#endif

+ 230 - 0
src/tests/multithreading/lifegame/graph_manager.hpp

@@ -0,0 +1,230 @@
+/**
+ * @file tests/multithreading/lifegame/graph_manager.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_MULTITHREADING_LIFEGAME_GRAPH_MANAGER_HPP
+#define TESTS_MULTITHREADING_LIFEGAME_GRAPH_MANAGER_HPP 1
+
+#include <tests/multithreading/lifegame/models.hpp>
+
+#include <paradevs/kernel/pdevs/multithreading/Coordinator.hpp>
+#include <paradevs/kernel/pdevs/GraphManager.hpp>
+#include <paradevs/kernel/pdevs/Simulator.hpp>
+
+namespace paradevs { namespace tests {
+        namespace multithreading { namespace lifegame {
+
+template < class SchedulerHandle >
+class S1GraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               SchedulerHandle >
+{
+public:
+    S1GraphManager(common::Coordinator < common::DoubleTime,
+                                         SchedulerHandle >* coordinator,
+                   const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime,
+                                        SchedulerHandle >(coordinator,
+                                                          parameters),
+        a("a1", common::NoParameters()), b("b1", common::NoParameters())
+    {
+        S1GraphManager < SchedulerHandle >::add_child(&a);
+        S1GraphManager < SchedulerHandle >::add_child(&b);
+
+        a.add_out_port("out");
+        b.add_in_port("in");
+        b.add_out_port("out");
+        coordinator->add_out_port("out");
+
+        S1GraphManager < SchedulerHandle >::add_link(&a, "out", &b, "in");
+        S1GraphManager < SchedulerHandle >::add_link(&b, "out",
+                                                     coordinator, "out");
+    }
+
+    void init()
+    { }
+
+    void start(common::DoubleTime::type /* t */)
+    { }
+
+    void transition(
+        const common::Models < common::DoubleTime,
+                               pdevs::SchedulerHandle >& /* receivers */,
+        common::DoubleTime::type /* t */)
+    { }
+
+    virtual ~S1GraphManager()
+    { }
+
+private:
+    paradevs::pdevs::Simulator < common::DoubleTime,
+                                 pdevs::A < SchedulerHandle >,
+                                 SchedulerHandle > a;
+    paradevs::pdevs::Simulator < common::DoubleTime,
+                                 pdevs::B < SchedulerHandle >,
+                                 SchedulerHandle > b;
+};
+
+template < class SchedulerHandle >
+class S2GraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               SchedulerHandle >
+{
+public:
+    S2GraphManager(common::Coordinator < common::DoubleTime,
+                                         SchedulerHandle >* coordinator,
+                   const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime,
+                                        SchedulerHandle >(coordinator,
+                                                          parameters),
+        a("a2", common::NoParameters()), b("b2", common::NoParameters())
+    {
+        S2GraphManager < SchedulerHandle >::add_child(&a);
+        S2GraphManager < SchedulerHandle >::add_child(&b);
+
+        a.add_in_port("in");
+        a.add_out_port("out");
+        b.add_in_port("in");
+        coordinator->add_in_port("in");
+
+        S2GraphManager < SchedulerHandle >::add_link(&a, "out", &b, "in");
+        S2GraphManager < SchedulerHandle >::add_link(coordinator, "in",
+                                                     &a, "in");
+    }
+
+    void init()
+    { }
+
+    void start(common::DoubleTime::type /* t */)
+    { }
+
+    void transition(
+        const common::Models < common::DoubleTime,
+                               pdevs::SchedulerHandle >& /* receivers */,
+        common::DoubleTime::type /* t */)
+    { }
+
+    virtual ~S2GraphManager()
+    { }
+
+private:
+    paradevs::pdevs::Simulator < common::DoubleTime,
+                                 pdevs::A < SchedulerHandle >,
+                                 SchedulerHandle > a;
+    paradevs::pdevs::Simulator < common::DoubleTime,
+                                 pdevs::B < SchedulerHandle >,
+                                 SchedulerHandle > b;
+};
+
+class RootGraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               pdevs::SchedulerHandle >
+{
+public:
+    RootGraphManager(
+        common::Coordinator < common::DoubleTime,
+                              pdevs::SchedulerHandle >* coordinator,
+        const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime,
+                                        pdevs::SchedulerHandle >(
+                                            coordinator, parameters),
+        S1("S1", paradevs::common::NoParameters(),
+           paradevs::common::NoParameters()),
+        S2("S2", paradevs::common::NoParameters(),
+           paradevs::common::NoParameters())
+    {
+        add_child(&S1);
+        add_child(&S2);
+
+        add_link(&S1, "out", &S2, "in");
+    }
+
+    void init()
+    {
+        S1.set_sender(
+            dynamic_cast < paradevs::pdevs::multithreading::Coordinator <
+                common::DoubleTime,
+                paradevs::common::scheduler::HeapScheduler <
+                    common::DoubleTime, pdevs::SchedulerHandle >,
+                pdevs::SchedulerHandle,
+                paradevs::tests::multithreading::RootGraphManager >*
+            >(get_coordinator())->get_sender());
+        S2.set_sender(
+            dynamic_cast < paradevs::pdevs::multithreading::Coordinator <
+                common::DoubleTime,
+                paradevs::common::scheduler::HeapScheduler <
+                    common::DoubleTime, pdevs::SchedulerHandle >,
+                pdevs::SchedulerHandle,
+                paradevs::tests::multithreading::RootGraphManager >*
+            >(get_coordinator())->get_sender());
+    }
+
+    void start(common::DoubleTime::type t)
+    {
+        S1.get_sender().send(
+            paradevs::pdevs::multithreading::start_message <
+                common::DoubleTime >(t));
+        S2.get_sender().send(
+            paradevs::pdevs::multithreading::start_message <
+                common::DoubleTime >(t));
+    }
+
+    void transition(const common::Models < common::DoubleTime,
+                                           pdevs::SchedulerHandle >& receivers,
+                    common::DoubleTime::type t)
+    {
+        if (std::find(receivers.begin(), receivers.end(),
+                      &S1) != receivers.end()) {
+            S1.get_sender().send(
+                paradevs::pdevs::multithreading::transition_message <
+                    common::DoubleTime >(t));
+        }
+        if (std::find(receivers.begin(), receivers.end(),
+                      &S2) != receivers.end()) {
+            S2.get_sender().send(
+                paradevs::pdevs::multithreading::transition_message <
+                    common::DoubleTime >(t));
+        }
+    }
+
+    virtual ~RootGraphManager()
+    { }
+
+private:
+    paradevs::pdevs::multithreading::Coordinator <
+        common::DoubleTime,
+        pdevs::SchedulerType,
+        pdevs::SchedulerHandle,
+        S1GraphManager < pdevs::SchedulerHandle > > S1;
+    paradevs::pdevs::multithreading::Coordinator <
+        common::DoubleTime,
+        pdevs::SchedulerType,
+        pdevs::SchedulerHandle,
+        S2GraphManager < pdevs::SchedulerHandle > > S2;
+};
+
+} } } } // namespace paradevs tests multithreading lifegame
+
+#endif

+ 95 - 0
src/tests/multithreading/lifegame/models.hpp

@@ -0,0 +1,95 @@
+/**
+ * @file tests/multithreading/lifegame/models.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_MULTITHREADING_LIFEGAME_MODELS_HPP
+#define TESTS_MULTITHREADING_LIFEGAME_MODELS_HPP 1
+
+#include <paradevs/common/time/DoubleTime.hpp>
+
+#include <paradevs/kernel/pdevs/Dynamics.hpp>
+
+namespace paradevs { namespace tests {
+        namespace multithreading { namespace lifegame {
+
+
+template < class SchedulerHandle>
+class Cell :
+        public paradevs::pdevs::Dynamics < common::DoubleTime, SchedulerHandle >
+{
+public:
+    Cell(const std::string& name, const common::NoParameters& parameters) :
+        paradevs::pdevs::Dynamics < common::DoubleTime,
+                                    SchedulerHandle >(name, parameters)
+    { }
+    virtual ~Cell()
+    { }
+
+    void dint(typename common::DoubleTime::type t)
+    {
+    }
+
+    void dext(typename common::DoubleTime::type t,
+              typename common::DoubleTime::type /* e */,
+              const common::Bag < common::DoubleTime, SchedulerHandle >& msgs)
+    {
+    }
+
+    void dconf(typename common::DoubleTime::type t,
+               typename common::DoubleTime::type /* e */,
+               const common::Bag < common::DoubleTime, SchedulerHandle >& msgs)
+    {
+    }
+
+    typename common::DoubleTime::type start(typename common::DoubleTime::type t)
+    {
+        return 0;
+    }
+
+    typename common::DoubleTime::type ta(
+        typename common::DoubleTime::type t) const
+    {
+    }
+
+    common::Bag < common::DoubleTime, SchedulerHandle > lambda(
+        typename common::DoubleTime::type t) const
+    {
+        common::Bag < common::DoubleTime, SchedulerHandle > msgs;
+
+        return msgs;
+    }
+
+    void observation(std::ostream& /* file */) const
+    { }
+
+private:
+    enum Phase { INIT, IDLE, NEWSTATE };
+
+    Phase _phase;
+};
+
+} } } } // namespace paradevs tests multithreading lifegame
+
+#endif

+ 88 - 0
src/tests/multithreading/lifegame/tests.cpp

@@ -0,0 +1,88 @@
+/**
+ * @file tests/multithreading/lifegame/tests.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <tests/multithreading/lifegame/graph_manager.hpp>
+
+#include <paradevs/common/RootCoordinator.hpp>
+
+#include <chrono>
+
+#define CATCH_CONFIG_MAIN
+#include <tests/catch.hpp>
+
+using namespace paradevs::tests::pdevs;
+using namespace paradevs::tests::multithreading;
+using namespace paradevs::common;
+using namespace std::chrono;
+
+TEST_CASE("pdevs/multithreading/lifegame", "run")
+{
+    steady_clock::time_point t1 = steady_clock::now();
+
+    paradevs::common::RootCoordinator <
+        DoubleTime, paradevs::pdevs::multithreading::Coordinator <
+            DoubleTime,
+            paradevs::common::scheduler::HeapScheduler <
+                DoubleTime, SchedulerHandle >,
+            SchedulerHandle,
+            paradevs::tests::multithreading::RootGraphManager >
+        > rc(0, 100, "root", paradevs::common::NoParameters(),
+             paradevs::common::NoParameters());
+
+    rc.run();
+
+    steady_clock::time_point t2 = steady_clock::now();
+
+    duration < double > time_span = duration_cast <
+        duration < double > >(t2 - t1);
+
+    std::cout << "multithreading/dependant -> " << time_span.count()
+              << std::endl;
+}
+
+TEST_CASE("pdevs/mono/lifegame", "run")
+{
+    steady_clock::time_point t1 = steady_clock::now();
+
+    paradevs::common::RootCoordinator <
+        DoubleTime, paradevs::pdevs::Coordinator <
+            DoubleTime,
+            paradevs::common::scheduler::HeapScheduler <
+                DoubleTime, SchedulerHandle >,
+            SchedulerHandle,
+            paradevs::tests::pdevs::RootGraphManager >
+        > rc(0, 100, "root", paradevs::common::NoParameters(),
+             paradevs::common::NoParameters());
+
+    rc.run();
+
+    steady_clock::time_point t2 = steady_clock::now();
+
+    duration < double > time_span = duration_cast <
+        duration < double > >(t2 - t1);
+
+    std::cout << "classic/dependant -> " << time_span.count() << std::endl;
+}

+ 139 - 0
src/tests/multithreading/tests.cpp

@@ -0,0 +1,139 @@
+/**
+ * @file tests/multithreading/tests.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <tests/multithreading/graph_manager.hpp>
+#include <tests/pdevs/graph_manager.hpp>
+
+#include <paradevs/common/RootCoordinator.hpp>
+
+#include <chrono>
+
+#define CATCH_CONFIG_MAIN
+#include <tests/catch.hpp>
+
+using namespace paradevs::tests::pdevs;
+using namespace paradevs::tests::multithreading;
+using namespace paradevs::common;
+using namespace std::chrono;
+
+TEST_CASE("pdevs/multithreading/hierachical", "run")
+{
+    steady_clock::time_point t1 = steady_clock::now();
+
+    paradevs::common::RootCoordinator <
+        DoubleTime, paradevs::pdevs::multithreading::Coordinator <
+            DoubleTime,
+            paradevs::common::scheduler::HeapScheduler <
+                DoubleTime, SchedulerHandle >,
+            SchedulerHandle,
+            paradevs::tests::multithreading::RootGraphManager >
+        > rc(0, 100, "root", paradevs::common::NoParameters(),
+             paradevs::common::NoParameters());
+
+    rc.run();
+
+    steady_clock::time_point t2 = steady_clock::now();
+
+    duration < double > time_span = duration_cast <
+        duration < double > >(t2 - t1);
+
+    std::cout << "multithreading/dependant -> " << time_span.count()
+              << std::endl;
+}
+
+TEST_CASE("pdevs/classic/hierachical", "run")
+{
+    steady_clock::time_point t1 = steady_clock::now();
+
+    paradevs::common::RootCoordinator <
+        DoubleTime, paradevs::pdevs::Coordinator <
+            DoubleTime,
+            paradevs::common::scheduler::HeapScheduler <
+                DoubleTime, SchedulerHandle >,
+            SchedulerHandle,
+            paradevs::tests::pdevs::RootGraphManager >
+        > rc(0, 100, "root", paradevs::common::NoParameters(),
+             paradevs::common::NoParameters());
+
+    rc.run();
+
+    steady_clock::time_point t2 = steady_clock::now();
+
+    duration < double > time_span = duration_cast <
+        duration < double > >(t2 - t1);
+
+    std::cout << "classic/dependant -> " << time_span.count() << std::endl;
+}
+
+TEST_CASE("pdevs/multithreading/independant", "run")
+{
+    steady_clock::time_point t1 = steady_clock::now();
+
+    paradevs::common::RootCoordinator <
+        DoubleTime, paradevs::pdevs::multithreading::Coordinator <
+            DoubleTime,
+            paradevs::common::scheduler::HeapScheduler <
+                DoubleTime, SchedulerHandle >,
+            SchedulerHandle,
+            paradevs::tests::multithreading::Root2GraphManager >
+        > rc(0, 100, "root", paradevs::common::NoParameters(),
+             paradevs::common::NoParameters());
+
+    rc.run();
+
+    steady_clock::time_point t2 = steady_clock::now();
+
+    duration < double > time_span = duration_cast <
+        duration < double > >(t2 - t1);
+
+    std::cout << "multithreading/independant -> " << time_span.count()
+              << std::endl;
+}
+
+TEST_CASE("pdevs/classic/independant", "run")
+{
+    steady_clock::time_point t1 = steady_clock::now();
+
+    paradevs::common::RootCoordinator <
+        DoubleTime, paradevs::pdevs::Coordinator <
+            DoubleTime,
+            paradevs::common::scheduler::HeapScheduler <
+                DoubleTime, SchedulerHandle >,
+            SchedulerHandle,
+            paradevs::tests::multithreading::Root3GraphManager >
+        > rc(0, 100, "root", paradevs::common::NoParameters(),
+             paradevs::common::NoParameters());
+
+    rc.run();
+
+    steady_clock::time_point t2 = steady_clock::now();
+
+    duration < double > time_span = duration_cast <
+        duration < double > >(t2 - t1);
+
+    std::cout << "classic/independant -> " << time_span.count() << std::endl;
+}
+

+ 16 - 0
src/tests/pdevs/CMakeLists.txt

@@ -0,0 +1,16 @@
+INCLUDE_DIRECTORIES(
+  ${CMAKE_SOURCE_DIR}/src
+  ${PARADEVS_INCLUDE_DIRS}
+  ${Boost_INCLUDE_DIRS}
+  ${GLIBMM_INCLUDE_DIRS}
+  ${LIBXML_INCLUDE_DIRS})
+
+LINK_DIRECTORIES(
+  ${GLIBMM_LIBRARY_DIRS}
+  ${LIBXML_LIBRARY_DIR})
+
+ADD_EXECUTABLE(pdevs-tests graph_manager.hpp models.hpp tests.cpp)
+
+TARGET_LINK_LIBRARIES(pdevs-tests
+  ${Boost_SYSTEM_LIBRARY}
+  ${Boost_TIMER_LIBRARY})

+ 248 - 0
src/tests/pdevs/graph_manager.hpp

@@ -0,0 +1,248 @@
+/**
+ * @file tests/pdevs/graph_manager.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_PDEVS_GRAPH_MANAGER_HPP
+#define TESTS_PDEVS_GRAPH_MANAGER_HPP 1
+
+#include <tests/pdevs/models.hpp>
+
+#include <paradevs/common/scheduler/HeapScheduler.hpp>
+
+#include <paradevs/kernel/pdevs/Coordinator.hpp>
+#include <paradevs/kernel/pdevs/GraphManager.hpp>
+#include <paradevs/kernel/pdevs/Simulator.hpp>
+
+namespace paradevs { namespace tests { namespace pdevs {
+
+struct SchedulerHandle;
+
+typedef typename paradevs::common::scheduler::HeapScheduler <
+    common::DoubleTime, SchedulerHandle >::type SchedulerType;
+
+struct SchedulerHandle
+{
+    SchedulerHandle()
+    { }
+
+    SchedulerHandle(const SchedulerType::handle_type& handle)
+        : _handle(handle)
+    { }
+
+    const SchedulerHandle& handle() const
+    { return *this; }
+
+    void handle(const SchedulerHandle& handle)
+    { _handle = handle._handle; }
+
+    SchedulerType::handle_type _handle;
+};
+
+template < class SchedulerHandle >
+class S1GraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               SchedulerHandle >
+{
+public:
+    S1GraphManager(common::Coordinator < common::DoubleTime,
+                                         SchedulerHandle >* coordinator,
+                   const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime,
+                                        SchedulerHandle >(coordinator,
+                                                          parameters),
+        a("a1", common::NoParameters()), b("b1", common::NoParameters())
+    {
+        S1GraphManager < SchedulerHandle >::add_child(&a);
+        S1GraphManager < SchedulerHandle >::add_child(&b);
+
+        a.add_out_port("out");
+        b.add_in_port("in");
+        b.add_out_port("out");
+        coordinator->add_out_port("out");
+
+        S1GraphManager < SchedulerHandle >::add_link(&a, "out", &b, "in");
+        S1GraphManager < SchedulerHandle >::add_link(&b, "out",
+                                                     coordinator, "out");
+    }
+
+    virtual ~S1GraphManager()
+    { }
+
+private:
+    paradevs::pdevs::Simulator < common::DoubleTime, A < SchedulerHandle >,
+                                 SchedulerHandle > a;
+    paradevs::pdevs::Simulator < common::DoubleTime, B < SchedulerHandle >,
+                                 SchedulerHandle > b;
+};
+
+template < class SchedulerHandle >
+class S2GraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               SchedulerHandle >
+{
+public:
+    S2GraphManager(common::Coordinator < common::DoubleTime,
+                                         SchedulerHandle >* coordinator,
+                   const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime,
+                                        SchedulerHandle >(coordinator,
+                                                          parameters),
+        a("a2", common::NoParameters()), b("b2", common::NoParameters())
+    {
+        S2GraphManager < SchedulerHandle >::add_child(&a);
+        S2GraphManager < SchedulerHandle >::add_child(&b);
+
+        a.add_in_port("in");
+        a.add_out_port("out");
+        b.add_in_port("in");
+        coordinator->add_in_port("in");
+
+        S2GraphManager < SchedulerHandle >::add_link(&a, "out", &b, "in");
+        S2GraphManager < SchedulerHandle >::add_link(coordinator, "in",
+                                                     &a, "in");
+    }
+
+    virtual ~S2GraphManager()
+    { }
+
+private:
+    paradevs::pdevs::Simulator < common::DoubleTime, A < SchedulerHandle >,
+                                 SchedulerHandle > a;
+    paradevs::pdevs::Simulator < common::DoubleTime, B < SchedulerHandle >,
+                                 SchedulerHandle > b;
+};
+
+class RootGraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               SchedulerHandle >
+{
+public:
+    RootGraphManager(
+        common::Coordinator < common::DoubleTime,
+                              SchedulerHandle >* coordinator,
+        const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime, SchedulerHandle >(
+                                            coordinator, parameters),
+        S1("S1", paradevs::common::NoParameters(),
+           paradevs::common::NoParameters()),
+        S2("S2", paradevs::common::NoParameters(),
+           paradevs::common::NoParameters())
+    {
+        add_child(&S1);
+        add_child(&S2);
+
+        add_link(&S1, "out", &S2, "in");
+    }
+
+    virtual ~RootGraphManager()
+    { }
+
+private:
+    paradevs::pdevs::Coordinator <
+        common::DoubleTime,
+        SchedulerType,
+        SchedulerHandle,
+        S1GraphManager < SchedulerHandle > > S1;
+    paradevs::pdevs::Coordinator <
+        common::DoubleTime,
+        SchedulerType,
+        SchedulerHandle,
+        S2GraphManager < SchedulerHandle > > S2;
+};
+
+template < class SchedulerHandle >
+class OnlyOneGraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               SchedulerHandle >
+{
+public:
+    OnlyOneGraphManager(common::Coordinator < common::DoubleTime,
+                                              SchedulerHandle >* coordinator,
+                        const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime,
+                                        SchedulerHandle >(coordinator,
+                                                          parameters),
+        a("a", common::NoParameters())
+    {
+        OnlyOneGraphManager < SchedulerHandle >::add_child(&a);
+    }
+
+    virtual ~OnlyOneGraphManager()
+    { }
+
+private:
+    paradevs::pdevs::Simulator < common::DoubleTime, A < SchedulerHandle >,
+                                 SchedulerHandle > a;
+};
+
+template < class SchedulerHandle >
+class FlatGraphManager :
+        public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                               SchedulerHandle >
+{
+public:
+    FlatGraphManager(common::Coordinator < common::DoubleTime,
+                                           SchedulerHandle >* coordinator,
+                     const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime,
+                                        SchedulerHandle >(coordinator,
+                                                          parameters),
+        a1("a1", common::NoParameters()), b1("b1", common::NoParameters()),
+        a2("a2", common::NoParameters()), b2("b2", common::NoParameters())
+    {
+        FlatGraphManager < SchedulerHandle >::add_child(&a1);
+        FlatGraphManager < SchedulerHandle >::add_child(&b1);
+        FlatGraphManager < SchedulerHandle >::add_child(&a2);
+        FlatGraphManager < SchedulerHandle >::add_child(&b2);
+
+        a1.add_out_port("out");
+        b1.add_in_port("in");
+        b1.add_out_port("out");
+        a2.add_in_port("in");
+        a2.add_out_port("out");
+        b2.add_in_port("in");
+
+        FlatGraphManager < SchedulerHandle >::add_link(&a1, "out", &b1, "in");
+        FlatGraphManager < SchedulerHandle >::add_link(&b1, "out", &a2, "in");
+        FlatGraphManager < SchedulerHandle >::add_link(&a2, "out", &b2, "in");
+    }
+
+    virtual ~FlatGraphManager()
+    { }
+
+private:
+    paradevs::pdevs::Simulator < common::DoubleTime, A < SchedulerHandle >,
+                                 SchedulerHandle > a1;
+    paradevs::pdevs::Simulator < common::DoubleTime, B < SchedulerHandle >,
+                                 SchedulerHandle > b1;
+    paradevs::pdevs::Simulator < common::DoubleTime, A < SchedulerHandle >,
+                                 SchedulerHandle > a2;
+    paradevs::pdevs::Simulator < common::DoubleTime, B < SchedulerHandle >,
+                                 SchedulerHandle > b2;
+};
+
+} } } // namespace paradevs tests pdevs
+
+#endif

+ 357 - 0
src/tests/pdevs/models.hpp

@@ -0,0 +1,357 @@
+/**
+ * @file tests/pdevs/models.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_PDEVS_MODELS_HPP
+#define TESTS_PDEVS_MODELS_HPP 1
+
+#include <paradevs/common/time/DoubleTime.hpp>
+#include <paradevs/common/utils/Trace.hpp>
+
+#include <paradevs/kernel/pdevs/Dynamics.hpp>
+
+#include <chrono>
+
+#define DELAY 100
+
+namespace paradevs { namespace tests { namespace pdevs {
+
+void delay()
+{
+    for (unsigned int i = 0; i < DELAY; ++i) {
+        std::vector < int > v;
+
+        for (unsigned int j = 1000; j > 0; --j) {
+            v.push_back(j);
+        }
+        std::sort(v.begin(), v.end());
+    }
+}
+
+template < class SchedulerHandle>
+class A :
+        public paradevs::pdevs::Dynamics < common::DoubleTime, SchedulerHandle >
+{
+public:
+    A(const std::string& name, const common::NoParameters& parameters) :
+        paradevs::pdevs::Dynamics < common::DoubleTime,
+                                    SchedulerHandle >(name, parameters)
+    { }
+    virtual ~A()
+    { }
+
+    void dint(typename common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::DELTA_INT);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        delay();
+
+        if (_phase == SEND) {
+            _phase = WAIT;
+        }
+    }
+
+    void dext(typename common::DoubleTime::type t,
+              typename common::DoubleTime::type /* e */,
+              const common::Bag < common::DoubleTime, SchedulerHandle >& msgs)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+        (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::DELTA_EXT)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        _phase = SEND;
+    }
+
+    void dconf(typename common::DoubleTime::type t,
+               typename common::DoubleTime::type /* e */,
+               const common::Bag < common::DoubleTime, SchedulerHandle >& msgs)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+        (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::DELTA_CONF)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+    }
+
+    typename common::DoubleTime::type start(typename common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::START);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        _phase = WAIT;
+        return 0;
+    }
+
+    typename common::DoubleTime::type ta(
+        typename common::DoubleTime::type t) const
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::TA);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        if (_phase == WAIT) {
+            return 1;
+        } else {
+            return 0;
+        }
+    }
+
+    common::Bag < common::DoubleTime, SchedulerHandle > lambda(
+        typename common::DoubleTime::type t) const
+    {
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+        common::Bag < common::DoubleTime, SchedulerHandle > msgs;
+
+        msgs.push_back(
+            common::ExternalEvent < common::DoubleTime, SchedulerHandle >(
+                "out", 0.));
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::LAMBDA)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        return msgs;
+    }
+
+    void observation(std::ostream& /* file */) const
+    { }
+
+private:
+    enum Phase { WAIT, SEND };
+
+    Phase _phase;
+};
+
+template < class SchedulerHandle >
+class B :
+        public paradevs::pdevs::Dynamics < common::DoubleTime, SchedulerHandle >
+{
+public:
+    B(const std::string& name, const common::NoParameters& parameters) :
+        paradevs::pdevs::Dynamics < common::DoubleTime,
+                                    SchedulerHandle >(name, parameters)
+    { }
+    virtual ~B()
+    { }
+
+    void dint(typename common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::DELTA_INT);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        delay();
+
+        if (_phase == SEND) {
+            _phase = WAIT;
+        }
+    }
+
+    void dext(typename common::DoubleTime::type t,
+              typename common::DoubleTime::type /* e */,
+              const common::Bag < common::DoubleTime, SchedulerHandle >& msgs)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+        (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::DELTA_EXT)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        _phase = SEND;
+    }
+
+    void dconf(typename common::DoubleTime::type t,
+               typename common::DoubleTime::type /* e */,
+               const common::Bag < common::DoubleTime, SchedulerHandle >& msgs)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+        (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::DELTA_CONF)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+    }
+
+    typename common::DoubleTime::type start(typename common::DoubleTime::type t)
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::START);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+        _phase = WAIT;
+        return std::numeric_limits < double >::max();
+    }
+
+    typename common::DoubleTime::type ta(
+        typename common::DoubleTime::type t) const
+    {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::TA);
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        if (_phase == WAIT) {
+            return std::numeric_limits < double >::max();
+        } else {
+            return 0;
+        }
+    }
+
+    common::Bag < common::DoubleTime, SchedulerHandle > lambda(
+        typename common::DoubleTime::type t) const
+    {
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+        common::Bag < common::DoubleTime, SchedulerHandle > msgs;
+
+        msgs.push_back(common::ExternalEvent < common::DoubleTime,
+                                               SchedulerHandle >("out", 0.));
+
+#ifdef WITH_TRACE
+        common::Trace < common::DoubleTime >::trace()
+            << common::TraceElement < common::DoubleTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::LAMBDA)
+            << "messages = " << msgs.to_string();
+        common::Trace < common::DoubleTime >::trace().flush();
+#endif
+
+        return msgs;
+    }
+
+    void observation(std::ostream& /* file */) const
+    { }
+
+private:
+    enum Phase { WAIT, SEND };
+
+    Phase _phase;
+};
+
+} } } // namespace paradevs tests pdevs
+
+#endif

+ 305 - 0
src/tests/pdevs/tests.cpp

@@ -0,0 +1,305 @@
+/**
+ * @file tests/pdevs/tests.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <tests/pdevs/graph_manager.hpp>
+#include <tests/pdevs/models.hpp>
+
+#include <paradevs/common/RootCoordinator.hpp>
+
+#define CATCH_CONFIG_MAIN
+#include <tests/catch.hpp>
+
+using namespace paradevs::tests::pdevs;
+using namespace paradevs::common;
+
+TEST_CASE("pdevs/only_one", "run")
+{
+    paradevs::common::RootCoordinator <
+        DoubleTime, paradevs::pdevs::Coordinator <
+            DoubleTime,
+            paradevs::common::scheduler::HeapScheduler <
+                DoubleTime, SchedulerHandle >,
+            SchedulerHandle,
+            OnlyOneGraphManager < SchedulerHandle > >
+        > rc(0, 10, "root", paradevs::common::NoParameters(),
+             paradevs::common::NoParameters());
+
+    paradevs::common::Trace < DoubleTime >::trace().clear();
+    rc.run();
+
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("a").
+            filter_type(paradevs::common::START).size() == 1);
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("a").
+            filter_type(paradevs::common::DELTA_EXT).size() == 0);
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("a").
+            filter_type(paradevs::common::DELTA_CONF).size() == 0);
+    for (unsigned int t = 0; t <= 10; ++t) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a").filter_time(t).
+                filter_type(paradevs::common::TA).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 1);
+    }
+}
+
+TEST_CASE("pdevs/flat", "run")
+{
+    paradevs::common::RootCoordinator <
+        DoubleTime, paradevs::pdevs::Coordinator <
+            DoubleTime,
+            paradevs::common::scheduler::HeapScheduler <
+                DoubleTime, SchedulerHandle >,
+            SchedulerHandle,
+            FlatGraphManager < SchedulerHandle> >
+        > rc(0, 10, "root", paradevs::common::NoParameters(),
+             paradevs::common::NoParameters());
+
+    paradevs::common::Trace < DoubleTime >::trace().clear();
+    rc.run();
+
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("a1").
+            filter_type(paradevs::common::START).size() == 1);
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("b1").
+            filter_type(paradevs::common::START).size() == 1);
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("a2").
+            filter_type(paradevs::common::START).size() == 1);
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("b2").
+            filter_type(paradevs::common::START).size() == 1);
+
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("a1").
+            filter_type(paradevs::common::DELTA_EXT).size() == 0);
+    for (unsigned int t = 0; t <= 10; ++t) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a1").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a1").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a1").filter_time(t).
+                filter_type(paradevs::common::TA).size() == 1);
+    }
+
+    for (unsigned int t = 0; t <= 10; ++t) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b1").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b1").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b1").filter_time(t).
+                filter_type(paradevs::common::TA).size() == 2);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b1").filter_time(t).
+                filter_type(paradevs::common::DELTA_EXT).size() == 1);
+    }
+
+    for (unsigned int t = 0; t <= 10; ++t) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a2").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 2);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a2").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 2);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a2").filter_time(t).
+                filter_type(paradevs::common::TA).size() == 3);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a2").filter_time(t).
+                filter_type(paradevs::common::DELTA_EXT).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a2").filter_time(t).
+                filter_type(paradevs::common::DELTA_CONF).size() == 0);
+    }
+
+    for (unsigned int t = 0; t <= 10; ++t) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b2").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 2);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b2").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 2);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b2").filter_time(t).
+                filter_type(paradevs::common::TA).size() == 4);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b2").filter_time(t).
+                filter_type(paradevs::common::DELTA_EXT).size() == 2);
+    }
+}
+
+TEST_CASE("pdevs/hierachical", "run")
+{
+    paradevs::common::RootCoordinator <
+        DoubleTime, paradevs::pdevs::Coordinator <
+            DoubleTime,
+            paradevs::common::scheduler::HeapScheduler <
+                DoubleTime, SchedulerHandle >,
+            SchedulerHandle,
+            RootGraphManager >
+        > rc(0, 10, "root", paradevs::common::NoParameters(),
+             paradevs::common::NoParameters());
+
+    paradevs::common::Trace < DoubleTime >::trace().clear();
+    rc.run();
+
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("a1").
+            filter_type(paradevs::common::START).size() == 1);
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("b1").
+            filter_type(paradevs::common::START).size() == 1);
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("a2").
+            filter_type(paradevs::common::START).size() == 1);
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("b2").
+            filter_type(paradevs::common::START).size() == 1);
+
+    REQUIRE(paradevs::common::Trace <
+                DoubleTime >::trace().elements().
+            filter_model_name("a1").
+            filter_type(paradevs::common::DELTA_EXT).size() == 0);
+    for (unsigned int t = 0; t <= 10; ++t) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a1").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a1").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a1").filter_time(t).
+                filter_type(paradevs::common::TA).size() == 1);
+    }
+
+    for (unsigned int t = 0; t <= 10; ++t) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b1").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b1").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b1").filter_time(t).
+                filter_type(paradevs::common::TA).size() == 2);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b1").filter_time(t).
+                filter_type(paradevs::common::DELTA_EXT).size() == 1);
+    }
+
+    for (unsigned int t = 0; t <= 10; ++t) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a2").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 2);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a2").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 2);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a2").filter_time(t).
+                filter_type(paradevs::common::TA).size() == 3);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a2").filter_time(t).
+                filter_type(paradevs::common::DELTA_EXT).size() == 1);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("a2").filter_time(t).
+                filter_type(paradevs::common::DELTA_CONF).size() == 0);
+    }
+
+    for (unsigned int t = 0; t <= 10; ++t) {
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b2").filter_time(t).
+                filter_type(paradevs::common::LAMBDA).size() == 2);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b2").filter_time(t).
+                filter_type(paradevs::common::DELTA_INT).size() == 2);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b2").filter_time(t).
+                filter_type(paradevs::common::TA).size() == 4);
+        REQUIRE(paradevs::common::Trace <
+                    DoubleTime >::trace().elements().
+                filter_model_name("b2").filter_time(t).
+                filter_type(paradevs::common::DELTA_EXT).size() == 2);
+    }
+}