diff --git a/CMakeLists.txt b/CMakeLists.txt index 7da6c745d..edf817f5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,9 @@ include(imported) ############################################################# option(STORM_DEVELOPER "Sets whether the development mode is used." OFF) option(STORM_ALLWARNINGS "Compile with even more warnings" OFF) -option(STORM_PORTABLE_RELEASE "Sets whether a release build needs to be portable to another machine. This is only effective for release builds in non-development mode." OFF) +option(STORM_USE_LTO "Sets whether link-time optimizations are enabled." ON) +MARK_AS_ADVANCED(STORM_USE_LTO) +option(STORM_PORTABLE_RELEASE "Sets whether a release build needs to be portable to another machine." OFF) MARK_AS_ADVANCED(STORM_PORTABLE_RELEASE) option(STORM_USE_POPCNT "Sets whether the popcnt instruction is going to be used." ON) MARK_AS_ADVANCED(STORM_USE_POPCNT) @@ -31,12 +33,13 @@ option(USE_BOOST_STATIC_LIBRARIES "Sets whether the Boost libraries should be li option(STORM_USE_INTELTBB "Sets whether the Intel TBB libraries should be used." OFF) option(STORM_USE_GUROBI "Sets whether Gurobi should be used." OFF) option(USE_CARL "Sets whether carl should be included." ON) +option(STORM_FORCE_SHIPPED_CARL "Sets whether the shipped version of carl is to be used no matter whether carl is found or not." OFF) +MARK_AS_ADVANCED(STORM_FORCE_SHIPPED_CARL) option(USE_SMTRAT "Sets whether SMT-RAT should be included." OFF) option(USE_HYPRO "Sets whether HyPro should be included." OFF) option(XML_SUPPORT "Sets whether xml based format parsing should be included." ON) option(FORCE_COLOR "Force color output" OFF) mark_as_advanced(FORCE_COLOR) -option(STORM_PYTHON "Build the API for Python" OFF) option(STORM_COMPILE_WITH_CCACHE "Compile using CCache [if found]" ON) mark_as_advanced(STORM_COMPILE_WITH_CCACHE) option(STORM_LOG_DISABLE_DEBUG "Disable log and trace message support" OFF) @@ -78,6 +81,8 @@ message("CMAKE_INSTALL_DIR: ${CMAKE_INSTALL_DIR}") if (STORM_DEVELOPER) set(CMAKE_BUILD_TYPE "DEBUG") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTORM_DEV") +else() + set(STORM_LOG_DISABLE_DEBUG ON) endif() message(STATUS "Storm - Building ${CMAKE_BUILD_TYPE} version.") @@ -132,11 +137,6 @@ endif() message(STATUS "Assuming extension for shared libraries: ${DYNAMIC_EXT}") message(STATUS "Assuming extension for static libraries: ${STATIC_EXT}") -# Python bindings need shared library -if(STORM_PYTHON) - set(BUILD_SHARED_LIBS ON CACHE BOOL "Build the Storm library dynamically" FORCE) -endif() - if(BUILD_SHARED_LIBS) set(LIB_EXT ${DYNAMIC_EXT}) message(STATUS "Build dynamic libraries.") @@ -219,7 +219,7 @@ if (STORM_COMPILER_CLANG OR STORM_COMPILER_APPLECLANG) endif() set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -stdlib=${CLANG_STDLIB} -ftemplate-depth=1024") - set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto -ffast-math -fno-finite-math-only") + set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math -fno-finite-math-only") set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-export_dynamic") set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-export_dynamic") elseif (STORM_COMPILER_GCC) @@ -229,6 +229,10 @@ elseif (STORM_COMPILER_GCC) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic") endif () +if (STORM_USE_LTO) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto") +endif() + # In release mode, we turn on even more optimizations if we do not have to provide a portable binary. if (NOT STORM_PORTABLE_RELEASE) set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native") @@ -264,6 +268,25 @@ else() set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer") endif() +############################################################# +## +## RPATH settings +## +############################################################# + +# don't skip the full RPATH for the build tree +SET(CMAKE_SKIP_BUILD_RPATH FALSE) + +# when building, don't use the install RPATH already (but only when installing) +SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) + +# the RPATH to be used when installing +SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + +# don't add the automatically determined parts of the RPATH +# which point to directories outside the build tree to the install RPATH +SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + ############################################################# ## ## Generator specific settings @@ -360,12 +383,15 @@ set(STORM_GENERATED_SOURCES "${PROJECT_BINARY_DIR}/src/storm/utility/storm-versi include_directories("${PROJECT_BINARY_DIR}/include") include(CTest) +# Compiles all tests +add_custom_target(tests) +# Compiles and runs all tests add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) set(CMAKE_CTEST_COMMAND_VERBOSE ${CMAKE_CTEST_COMMAND} -V) add_custom_target(check-verbose COMMAND ${CMAKE_CTEST_COMMAND_VERBOSE}) +add_dependencies(check tests) +add_dependencies(check-verbose tests) - -# Python bindings for storm set(STORM_TARGETS "") add_subdirectory(src) diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..fd321e147 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,44 @@ +node { + def cmakeTool + stage('Preparation') { + // Get some code from a GitHub repository + checkout scm + + cmakeTool = tool name: 'InSearchPath', type: 'hudson.plugins.cmake.CmakeTool' + + sh "rm -rf build" + sh "mkdir -p build" + } + stage('Configure') { + dir("build") { + sh "${cmakeTool} .." + } + + } + + stage('Build') { + dir("build") { + sh "make storm" + } + + } + + stage('Build Tests') { + dir("build") { + sh "make -j 4 tests" + } + + } + + stage('Test') { + dir("build") { + sh "make check-verbose" + } + } + + stage('Archive') { + archiveArtifacts artifacts: 'build/bin/*', onlyIfSuccessful: true + archiveArtifacts artifacts: 'build/lib/*', onlyIfSuccessful: true + archiveArtifacts artifacts: 'build/include/*', onlyIfSuccessful: true + } +} diff --git a/LICENSE b/LICENSE index 6d45519c8..94a9ed024 100644 --- a/LICENSE +++ b/LICENSE @@ -1,285 +1,626 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble + Preamble - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to + 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 -this service 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. +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 make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. + 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 give the recipients all the rights that -you have. 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. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. +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. - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to + 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. - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or + 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 -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will +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 a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs + 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 @@ -287,15 +628,15 @@ 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 -convey the exclusion of warranty; and each file should have at least +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. Copyright (C) - This program is free software; you can redistribute it and/or modify + 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 2 of the License, or + 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, @@ -304,37 +645,30 @@ the "copyright" line and a pointer to where the full notice is found. 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, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + Copyright (C) + 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, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This 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 Library General -Public License instead of this License. +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 +. + + 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 +. diff --git a/README b/README deleted file mode 100644 index bef720bdf..000000000 --- a/README +++ /dev/null @@ -1,24 +0,0 @@ -# Create build directory for storm -mkdir build - -# Go to build directory -cd build - -# Configure the project -cmake .. -# If you want an interactive configuration, try "ccmake ..". Then you can press "c" to initially configure the project, change your values and then press "g" to generate the Makefile - -# After generating the Makefile you can build the resources we need for the project -make resources - -# Now we build the main project for DFTs -make storm-dft-main - -# Last you can run an example -./src/storm-dft -dft ../examples/dft/and.dft -mttf - -# To get a list of all available arguments run -./src/storm-dft --help - -# Example for DFT to Petri net translation -./src/storm-dft -dft ../examples/dft/and.dft --gspn diff --git a/README.md b/README.md index 54db5bddb..ffcc3bc5c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Storm ============================== -For more instructions, check out the documentation found in [Getting Started](doc/getting-started.md) +For more instructions, check out the documentation found in [Getting Started](https://moves-rwth.github.io/storm/getting-started.html) Benchmarks @@ -48,5 +48,6 @@ Storm has been developed at RWTH Aachen University. * Thomas Henn * Tom Janson * Gereon Kremer +* Sascha Vincent Kurowski * Manuel Sascha Weiand * Lukas Westhofen diff --git a/StormCPackConfig.cmake b/StormCPackConfig.cmake index 5ce6c0f53..6f58f9fd0 100644 --- a/StormCPackConfig.cmake +++ b/StormCPackConfig.cmake @@ -4,9 +4,9 @@ include(InstallRequiredSystemLibraries) # http://www.cmake.org/Wiki/CMake:CPackConfiguration ### general settings -set(CPACK_PACKAGE_NAME "StoRM") -set(CPACK_PACKAGE_VENDOR "i2 RWTH Aachen University") -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Stochastic Reward Model Checker - An extensible model checker written in C++.") +set(CPACK_PACKAGE_NAME "Storm") +set(CPACK_PACKAGE_VENDOR "RWTH Aachen University") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Storm - A probabilistic model checker written in C++.") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") diff --git a/doc/build.md b/doc/build.md index 703f6ca0f..725794034 100644 --- a/doc/build.md +++ b/doc/build.md @@ -23,9 +23,11 @@ Prerequisites: ## Instructions ### General - -> mkdir build +```bash +mkdir build +cd build +``` It is recommended to make an out-of-source build, meaning that the folder in which CMake generates its Cache, Makefiles and output files should not be the Project Root nor its Source Directory. A typical build layout is to create a folder "build" in the project root alongside the CMakeLists.txt file, change into this folder and execute "cmake .." as this will leave all source files untouched diff --git a/resources/3rdparty/CMakeLists.txt b/resources/3rdparty/CMakeLists.txt index e6bd1c6f5..32cf3872e 100644 --- a/resources/3rdparty/CMakeLists.txt +++ b/resources/3rdparty/CMakeLists.txt @@ -69,10 +69,13 @@ endif () if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL "")) set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib") endif () -link_directories(${Boost_LIBRARY_DIRS}) -include_directories(${Boost_INCLUDE_DIRS}) -list(APPEND STORM_LINK_LIBRARIES ${Boost_LIBRARIES}) +set(CNTVAR 1) +foreach(BOOSTLIB ${Boost_LIBRARIES}) + add_imported_library(target-boost-${CNTVAR} SHARED ${BOOSTLIB} ${Boost_INCLUDE_DIRS}) + list(APPEND STORM_DEP_TARGETS target-boost-${CNTVAR}_SHARED) + MATH(EXPR CNTVAR "${CNTVAR}+1") +endforeach() message(STATUS "Storm - Using boost ${Boost_VERSION} (library version ${Boost_LIB_VERSION}).") # set the information for the config header set(STORM_BOOST_INCLUDE_DIR "${Boost_INCLUDE_DIRS}") @@ -131,8 +134,8 @@ set(STORM_HAVE_Z3 ${Z3_FOUND}) if(Z3_FOUND) message (STATUS "Storm - Linking with Z3.") - include_directories(${Z3_INCLUDE_DIRS}) - list(APPEND STORM_LINK_LIBRARIES ${Z3_LIBRARIES}) + add_imported_library(z3 SHARED ${Z3_LIBRARIES} ${Z3_INCLUDE_DIRS}) + list(APPEND STORM_DEP_TARGETS z3_SHARED) endif(Z3_FOUND) ############################################################# @@ -175,8 +178,6 @@ include(${STORM_3RDPARTY_SOURCE_DIR}/include_cudd.cmake) ############################################################# include(${STORM_3RDPARTY_SOURCE_DIR}/include_cpptemplate.cmake) - - ############################################################# ## ## carl @@ -185,23 +186,25 @@ include(${STORM_3RDPARTY_SOURCE_DIR}/include_cpptemplate.cmake) set(STORM_HAVE_CARL OFF) if(USE_CARL) - find_package(carl QUIET) - if(carl_FOUND) + if (NOT STORM_FORCE_SHIPPED_CARL) + find_package(carl QUIET) + endif() + if(carl_FOUND AND NOT STORM_FORCE_SHIPPED_CARL) + set(STORM_SHIPPED_CARL OFF) set(STORM_HAVE_CARL ON) message(STATUS "Storm - Use system version of carl.") message(STATUS "Storm - Linking with carl ${carl_VERSION} (CARL_USE_CLN_NUMBERS: ${CARL_USE_CLN_NUMBERS}).") set(STORM_HAVE_CLN ${CARL_USE_CLN_NUMBERS}) else() + set(STORM_SHIPPED_CARL ON) # The first external project will be built at *configure stage* message("START CARL CONFIG PROCESS") file(MAKE_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download) - execute_process( - COMMAND ${CMAKE_COMMAND} ${STORM_3RDPARTY_SOURCE_DIR}/carl "-DSTORM_3RDPARTY_BINARY_DIR=${STORM_3RDPARTY_BINARY_DIR}" - WORKING_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download - OUTPUT_VARIABLE carlconfig_out - RESULT_VARIABLE carlconfig_result - ) - + execute_process( + COMMAND ${CMAKE_COMMAND} ${STORM_3RDPARTY_SOURCE_DIR}/carl "-DSTORM_3RDPARTY_BINARY_DIR=${STORM_3RDPARTY_BINARY_DIR}" + WORKING_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download + OUTPUT_VARIABLE carlconfig_out + RESULT_VARIABLE carlconfig_result) if(NOT carlconfig_result) message("${carlconfig_out}") @@ -218,30 +221,34 @@ if(USE_CARL) message("END CARL CONFIG PROCESS") message(STATUS "Storm - Using shipped version of carl.") - set(CARL_BUILD_COMMAND make lib_carl) ExternalProject_Add( carl SOURCE_DIR ${STORM_3RDPARTY_BINARY_DIR}/carl CONFIGURE_COMMAND "" BUILD_IN_SOURCE 1 BUILD_COMMAND make lib_carl - INSTALL_COMMAND "" + INSTALL_COMMAND make install LOG_BUILD ON + LOG_INSTALL ON BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT} ) include(${STORM_3RDPARTY_BINARY_DIR}/carl/carlConfig.cmake) message("CARL_USE_CLN_NUMBERS: ${CARL_USE_CLN_NUMBERS}") set(STORM_HAVE_CLN ${CARL_USE_CLN_NUMBERS}) add_dependencies(resources carl) - set(carl_INCLUDE_DIR "${STORM_3RDPARTY_BINARY_DIR}/carl/build/include") + set(carl_INCLUDE_DIR "${STORM_3RDPARTY_BINARY_DIR}/carl/include/") + set(carl_LIBRARIES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT}) set(STORM_HAVE_CARL ON) + + # install the carl dynamic library if we build it + get_filename_component(STORM_CARL_DYLIB_FULL_PATH ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT} REALPATH) + install(FILES ${STORM_CARL_DYLIB_FULL_PATH} DESTINATION lib) endif() if(STORM_USE_CLN_NUMBERS AND NOT STORM_HAVE_CLN) message(FATAL_ERROR "Cannot use CLN numbers if carl is build without") endif() list(APPEND STORM_DEP_IMP_TARGETS lib_carl) - endif() @@ -276,9 +283,8 @@ if(USE_HYPRO) find_package(hypro QUIET REQUIRED) if(hypro_FOUND) set(STORM_HAVE_HYPRO ON) - message(STATUS "Storm - Linking with hypro ${hypro_VERSION_STRING}.") + message(STATUS "Storm - Linking with hypro.") include_directories("${hypro_INCLUDE_DIR}") - link_directories( /Users/tim/hypro/build ) list(APPEND STORM_LINK_LIBRARIES ${hypro_LIBRARIES}) else() message(FATAL_ERROR "StoRM - HyPro was requested but not found") @@ -317,10 +323,11 @@ if (ENABLE_MSAT) list(APPEND STORM_LINK_LIBRARIES "mathsat") if(GMP_FOUND) include_directories("${GMP_INCLUDE_DIR}") - list(APPEND STORM_LINK_LIBRARIES "gmp") + list(APPEND STORM_LINK_LIBRARIES ${GMP_LIBRARY}) elseif(MPIR_FOUND) include_directories("${GMP_INCLUDE_DIR}") - list(APPEND STORM_LINK_LIBRARIES "mpir" "mpirxx") + list(APPEND STORM_LINK_LIBRARIES ${GMP_MPIR_LIBRARY}) + list(APPEND STORM_LINK_LIBRARIES ${GMP_MPIRXX_LIBRARY}) else(GMP_FOUND) message(FATAL_ERROR "GMP is required for MathSAT, but was not found!") endif(GMP_FOUND) @@ -345,7 +352,7 @@ ExternalProject_Add( DOWNLOAD_COMMAND "" PREFIX "sylvan" SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/sylvan - CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DSYLVAN_BUILD_TEST=Off -DSYLVAN_BUILD_EXAMPLES=Off -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON + CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DSYLVAN_BUILD_TEST=Off -DSYLVAN_BUILD_EXAMPLES=Off -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DUSE_CARL=ON -Dcarl_INCLUDE_DIR=${carl_INCLUDE_DIR} -DSYLVAN_PORTABLE=${STORM_PORTABLE_RELEASE} -Dcarl_LIBRARIES=${carl_LIBRARIES} BINARY_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan BUILD_IN_SOURCE 0 INSTALL_COMMAND "" @@ -362,16 +369,19 @@ message(STATUS "Storm - Using shipped version of sylvan.") message(STATUS "Storm - Linking with sylvan.") add_imported_library(sylvan STATIC ${Sylvan_LIBRARY} ${Sylvan_INCLUDE_DIR}) add_dependencies(sylvan_STATIC sylvan) +if(STORM_SHIPPED_CARL) + add_dependencies(sylvan carl) +endif() list(APPEND STORM_DEP_TARGETS sylvan_STATIC) -if(${OPERATING_SYSTEM} MATCHES "Linux") - find_package(Hwloc QUIET REQUIRED) - if(HWLOC_FOUND) - message(STATUS "Storm - Linking with hwloc ${HWLOC_VERSION}.") - add_imported_library(hwloc STATIC ${HWLOC_LIBRARIES} "") - list(APPEND STORM_DEP_TARGETS hwloc_STATIC) - else() - message(FATAL_ERROR "HWLOC is required but was not found.") +find_package(Hwloc QUIET REQUIRED) +if(HWLOC_FOUND) + message(STATUS "Storm - Linking with hwloc ${HWLOC_VERSION}.") + add_imported_library(hwloc STATIC ${HWLOC_LIBRARIES} "") + list(APPEND STORM_DEP_TARGETS hwloc_STATIC) +else() + if(${OPERATING_SYSTEM} MATCHES "Linux") + message(FATAL_ERROR "HWLOC is required on Linux but was not found.") endif() endif() diff --git a/resources/3rdparty/cpptemplate/cpptempl.h b/resources/3rdparty/cpptemplate/cpptempl.h index bd7c77510..b6a19d293 100755 --- a/resources/3rdparty/cpptemplate/cpptempl.h +++ b/resources/3rdparty/cpptemplate/cpptempl.h @@ -114,8 +114,8 @@ namespace cpptempl { public: TemplateException(std::string reason) : m_reason(reason){} - ~TemplateException() throw() {} - const char* what() throw() { + ~TemplateException() {} + const char* what() const noexcept { return m_reason.c_str(); } private: diff --git a/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.cc b/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.cc index e1c9807d8..753a40b8a 100644 --- a/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.cc +++ b/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.cc @@ -566,7 +566,7 @@ BDD::operator+( const BDD& other) const { DdManager *mgr = checkSameManager(other); - DdNode *result = Cudd_bddOr(mgr,node,other.node); + DdNode *result = (mgr,node,other.node); checkReturnValue(result); return BDD(p, result); @@ -2648,7 +2648,16 @@ ADD::MinAbstract(const ADD& cube) const checkReturnValue(result); return ADD(p, result); } // ADD::MinAbstract - + +ADD +ADD::MinAbstractExcept0(const ADD& cube) const +{ + DdManager *mgr = checkSameManager(cube); + DdNode *result = Cudd_addMinExcept0Abstract(mgr, node, cube.node); + checkReturnValue(result); + return ADD(p, result); +} // ADD::MinAbstractExcept0 + ADD ADD::MaxAbstract(const ADD& cube) const { @@ -2658,6 +2667,24 @@ ADD::MaxAbstract(const ADD& cube) const return ADD(p, result); } // ADD::MaxAbstract +BDD +ADD::MinAbstractRepresentative(const ADD& cube) const +{ + DdManager *mgr = checkSameManager(cube); + DdNode *result = Cudd_addMinAbstractRepresentative(mgr, node, cube.node); + checkReturnValue(result); + return BDD(p, result); +} // ADD::MinRepresentative + +BDD +ADD::MaxAbstractRepresentative(const ADD& cube) const +{ + DdManager *mgr = checkSameManager(cube); + DdNode *result = Cudd_addMaxAbstractRepresentative(mgr, node, cube.node); + checkReturnValue(result); + return BDD(p, result); +} // ADD::MaxRepresentative + ADD ADD::Plus( const ADD& g) const @@ -3136,6 +3163,66 @@ ADD::GreaterThanOrEqual(const ADD& g) const } // ADD::GreaterThanOrEqual +BDD +ADD::EqualsBdd(const ADD& g) const +{ + DdManager *mgr = checkSameManager(g); + DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddEquals, node, g.node); + checkReturnValue(result); + return BDD(p, result); + +} // ADD::EqualsBdd + +BDD +ADD::NotEqualsBdd(const ADD& g) const +{ + DdManager *mgr = checkSameManager(g); + DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddNotEquals, node, g.node); + checkReturnValue(result); + return BDD(p, result); + +} // ADD::NotEqualsBdd + +BDD +ADD::LessThanBdd(const ADD& g) const +{ + DdManager *mgr = checkSameManager(g); + DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddLessThan, node, g.node); + checkReturnValue(result); + return BDD(p, result); + +} // ADD::LessThanBdd + +BDD +ADD::LessThanOrEqualBdd(const ADD& g) const +{ + DdManager *mgr = checkSameManager(g); + DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddLessThanEquals, node, g.node); + checkReturnValue(result); + return BDD(p, result); + +} // ADD::LessThanOrEqualBdd + +BDD +ADD::GreaterThanBdd(const ADD& g) const +{ + DdManager *mgr = checkSameManager(g); + DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddGreaterThan, node, g.node); + checkReturnValue(result); + return BDD(p, result); + +} // ADD::GreaterThanBdd + +BDD +ADD::GreaterThanOrEqualBdd(const ADD& g) const +{ + DdManager *mgr = checkSameManager(g); + DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddGreaterThanEquals, node, g.node); + checkReturnValue(result); + return BDD(p, result); + +} // ADD::GreaterThanOrEqualBdd + BDD BDD::AndAbstract( const BDD& g, @@ -3485,6 +3572,14 @@ BDD::ExistAbstract( } // BDD::ExistAbstract +BDD +BDD::ExistAbstractRepresentative(const BDD& cube) const { + DdManager *mgr = checkSameManager(cube); + DdNode *result; + result = Cudd_bddExistAbstractRepresentative(mgr, node, cube.node); + checkReturnValue(result); + return BDD(p, result); +} // BDD::ExistAbstractRepresentative BDD BDD::XorExistAbstract( diff --git a/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.hh b/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.hh index f180320bd..84018dc07 100644 --- a/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.hh +++ b/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.hh @@ -213,6 +213,7 @@ public: BDD BiasedOverApprox(const BDD& bias, int numVars, int threshold = 0, double quality1 = 1.0, double quality0 = 1.0) const; BDD ExistAbstract(const BDD& cube, unsigned int limit = 0) const; + BDD ExistAbstractRepresentative(const BDD& cube) const; BDD XorExistAbstract(const BDD& g, const BDD& cube) const; BDD UnivAbstract(const BDD& cube) const; BDD BooleanDiff(int x) const; @@ -333,7 +334,10 @@ public: ADD UnivAbstract(const ADD& cube) const; ADD OrAbstract(const ADD& cube) const; ADD MinAbstract(const ADD& cube) const; + ADD MinAbstractExcept0(const ADD& cube) const; ADD MaxAbstract(const ADD& cube) const; + BDD MinAbstractRepresentative(const ADD& cube) const; + BDD MaxAbstractRepresentative(const ADD& cube) const; ADD Plus(const ADD& g) const; ADD Times(const ADD& g) const; ADD Threshold(const ADD& g) const; @@ -373,6 +377,12 @@ public: ADD LessThanOrEqual(const ADD& g) const; ADD GreaterThan(const ADD& g) const; ADD GreaterThanOrEqual(const ADD& g) const; + BDD EqualsBdd(const ADD& g) const; + BDD NotEqualsBdd(const ADD& g) const; + BDD LessThanBdd(const ADD& g) const; + BDD LessThanOrEqualBdd(const ADD& g) const; + BDD GreaterThanBdd(const ADD& g) const; + BDD GreaterThanOrEqualBdd(const ADD& g) const; BDD BddThreshold(CUDD_VALUE_TYPE value) const; BDD BddStrictThreshold(CUDD_VALUE_TYPE value) const; BDD BddInterval(CUDD_VALUE_TYPE lower, CUDD_VALUE_TYPE upper) const; diff --git a/resources/3rdparty/cudd-3.0.0/cudd/cudd.h b/resources/3rdparty/cudd-3.0.0/cudd/cudd.h index e2447c878..20acf5854 100644 --- a/resources/3rdparty/cudd-3.0.0/cudd/cudd.h +++ b/resources/3rdparty/cudd-3.0.0/cudd/cudd.h @@ -515,6 +515,7 @@ extern int Cudd_zddVarsFromBddVars(DdManager *dd, int multiplicity); extern unsigned int Cudd_ReadMaxIndex(void); extern DdNode * Cudd_addConst(DdManager *dd, CUDD_VALUE_TYPE c); extern int Cudd_IsConstant(DdNode *node); +extern int Cudd_IsConstant_const(DdNode const *node); extern int Cudd_IsNonConstant(DdNode *f); extern DdNode * Cudd_T(DdNode *node); extern DdNode * Cudd_E(DdNode *node); @@ -666,8 +667,12 @@ extern DdNode * Cudd_addExistAbstract(DdManager *manager, DdNode *f, DdNode *cub extern DdNode * Cudd_addUnivAbstract(DdManager *manager, DdNode *f, DdNode *cube); extern DdNode * Cudd_addOrAbstract(DdManager *manager, DdNode *f, DdNode *cube); extern DdNode * Cudd_addMinAbstract(DdManager * manager, DdNode * f, DdNode * cube); +extern DdNode * Cudd_addMinExcept0Abstract(DdManager * manager, DdNode * f, DdNode * cube); extern DdNode * Cudd_addMaxAbstract(DdManager * manager, DdNode * f, DdNode * cube); +extern DdNode * Cudd_addMinAbstractRepresentative(DdManager * manager, DdNode * f, DdNode * cube); +extern DdNode * Cudd_addMaxAbstractRepresentative(DdManager * manager, DdNode * f, DdNode * cube); extern DdNode * Cudd_addApply(DdManager *dd, DD_AOP op, DdNode *f, DdNode *g); +extern DdNode * Cudd_addToBddApply(DdManager *dd, DD_AOP op, DdNode *f, DdNode *g); extern DdNode * Cudd_addPlus(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addTimes(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addThreshold(DdManager *dd, DdNode **f, DdNode **g); @@ -675,6 +680,7 @@ extern DdNode * Cudd_addSetNZ(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addDivide(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addMinus(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addMinimum(DdManager *dd, DdNode **f, DdNode **g); +extern DdNode * Cudd_addMinimumExcept0(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addMaximum(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addOneZeroMaximum(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addDiff(DdManager *dd, DdNode **f, DdNode **g); @@ -690,6 +696,12 @@ extern DdNode * Cudd_addGreaterThan (DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addGreaterThanEquals (DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addLessThan (DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addLessThanEquals (DdManager *dd, DdNode **f, DdNode **g); +extern DdNode * Cudd_addToBddEquals (DdManager *dd, DdNode **f, DdNode **g); +extern DdNode * Cudd_addToBddNotEquals (DdManager *dd, DdNode **f, DdNode **g); +extern DdNode * Cudd_addToBddGreaterThan (DdManager *dd, DdNode **f, DdNode **g); +extern DdNode * Cudd_addToBddGreaterThanEquals (DdManager *dd, DdNode **f, DdNode **g); +extern DdNode * Cudd_addToBddLessThan (DdManager *dd, DdNode **f, DdNode **g); +extern DdNode * Cudd_addToBddLessThanEquals (DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addPow (DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addMod (DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addLogXY (DdManager *dd, DdNode **f, DdNode **g); @@ -740,6 +752,7 @@ extern DdNode * Cudd_RemapOverApprox(DdManager *dd, DdNode *f, int numVars, int extern DdNode * Cudd_BiasedUnderApprox(DdManager *dd, DdNode *f, DdNode *b, int numVars, int threshold, double quality1, double quality0); extern DdNode * Cudd_BiasedOverApprox(DdManager *dd, DdNode *f, DdNode *b, int numVars, int threshold, double quality1, double quality0); extern DdNode * Cudd_bddExistAbstract(DdManager *manager, DdNode *f, DdNode *cube); +extern DdNode * Cudd_bddExistAbstractRepresentative(DdManager *manager, DdNode *f, DdNode *cube); extern DdNode * Cudd_bddExistAbstractLimit(DdManager * manager, DdNode * f, DdNode * cube, unsigned int limit); extern DdNode * Cudd_bddXorExistAbstract(DdManager *manager, DdNode *f, DdNode *g, DdNode *cube); extern DdNode * Cudd_bddUnivAbstract(DdManager *manager, DdNode *f, DdNode *cube); diff --git a/resources/3rdparty/cudd-3.0.0/cudd/cuddAPI.c b/resources/3rdparty/cudd-3.0.0/cudd/cuddAPI.c index 78214567e..45cbc714a 100644 --- a/resources/3rdparty/cudd-3.0.0/cudd/cuddAPI.c +++ b/resources/3rdparty/cudd-3.0.0/cudd/cuddAPI.c @@ -553,6 +553,20 @@ int Cudd_IsConstant(DdNode *node) } /* end of Cudd_IsConstant */ +/** + @brief Returns 1 if the node is a constant node. + + @details A constant node is not an internal node. The pointer + passed to Cudd_IsConstant may be either regular or complemented. + + @sideeffect none + + */ +int Cudd_IsConstant_const(DdNode const*node) +{ + return Cudd_Regular(node)->index == CUDD_CONST_INDEX; + +} /* end of Cudd_IsConstant_const */ /** @brief Returns 1 if a %DD node is not constant. @@ -576,7 +590,6 @@ Cudd_IsNonConstant( } /* end of Cudd_IsNonConstant */ - /** @brief Returns the then child of an internal node. diff --git a/resources/3rdparty/cudd-3.0.0/cudd/cuddAddAbs.c b/resources/3rdparty/cudd-3.0.0/cudd/cuddAddAbs.c index db284f7b4..1f8414017 100644 --- a/resources/3rdparty/cudd-3.0.0/cudd/cuddAddAbs.c +++ b/resources/3rdparty/cudd-3.0.0/cudd/cuddAddAbs.c @@ -243,6 +243,44 @@ Cudd_addMinAbstract( } /* end of Cudd_addMinAbstract */ +/**Function******************************************************************** + + Synopsis [Abstracts all the variables in cube from the + ADD f by taking the minimum.] + + Description [Abstracts all the variables in cube from the ADD f + by taking the minimum over all possible values taken by the + variables. Returns the abstracted ADD if successful; NULL + otherwise.] + + SideEffects [None] + + SeeAlso [Cudd_addUnivAbstract Cudd_addExistAbstract] + + Note: Added by Christian Dehnert 24/08/2016 + + ******************************************************************************/ +DdNode * +Cudd_addMinExcept0Abstract( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *res; + + if (addCheckPositiveCube(manager, cube) == 0) { + (void) fprintf(manager->err,"Error: Can only abstract cubes"); + return(NULL); + } + + do { + manager->reordered = 0; + res = cuddAddMinExcept0AbstractRecur(manager, f, cube); + } while (manager->reordered == 1); + return(res); + +} /* end of Cudd_addMinExcept0Abstract */ + /**Function******************************************************************** Synopsis [Abstracts all the variables in cube from the @@ -281,6 +319,78 @@ Cudd_addMaxAbstract( } /* end of Cudd_addMaxAbstract */ +/**Function******************************************************************** + + Synopsis [Just like Cudd_addMinAbstract, but instead of abstracting the + variables in the given cube, picks a unique representative that realizes th + minimal function value.] + + Description [Returns the resulting ADD if successful; NULL otherwise.] + + SideEffects [None] + + SeeAlso [Cudd_addMaxAbstractRepresentative] + + Note: Added by Christian Dehnert 8/5/14 + + ******************************************************************************/ +DdNode * +Cudd_addMinAbstractRepresentative( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *res; + + if (addCheckPositiveCube(manager, cube) == 0) { + (void) fprintf(manager->err,"Error: Can only abstract cubes"); + return(NULL); + } + + do { + manager->reordered = 0; + res = cuddAddMinAbstractRepresentativeRecur(manager, f, cube); + } while (manager->reordered == 1); + return(res); + +} /* end of Cudd_addMinRepresentative */ + +/**Function******************************************************************** + + Synopsis [Just like Cudd_addMaxAbstract, but instead of abstracting the + variables in the given cube, picks a unique representative that realizes th + maximal function value.] + + Description [Returns the resulting ADD if successful; NULL otherwise.] + + SideEffects [None] + + SeeAlso [Cudd_addMinAbstractRepresentative] + + Note: Added by Christian Dehnert 8/5/14 + + ******************************************************************************/ +DdNode * +Cudd_addMaxAbstractRepresentative( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *res; + + if (addCheckPositiveCube(manager, cube) == 0) { + (void) fprintf(manager->err,"Error: Can only abstract cubes"); + return(NULL); + } + + do { + manager->reordered = 0; + res = cuddAddMaxAbstractRepresentativeRecur(manager, f, cube); + } while (manager->reordered == 1); + return(res); + +} /* end of Cudd_addMaxRepresentative */ + /*---------------------------------------------------------------------------*/ /* Definition of internal functions */ /*---------------------------------------------------------------------------*/ @@ -678,6 +788,98 @@ cuddAddMinAbstractRecur( } /* end of cuddAddMinAbstractRecur */ +/**Function******************************************************************** + + Synopsis [Performs the recursive step of Cudd_addMinAbstract.] + + Description [Performs the recursive step of Cudd_addMinAbstract. + Returns the ADD obtained by abstracting the variables of cube from f, + if successful; NULL otherwise.] + + SideEffects [None] + + SeeAlso [] + + added 24/08/2016 by Christian Dehnert + + ******************************************************************************/ +DdNode * +cuddAddMinExcept0AbstractRecur( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *T, *E, *res, *res1, *res2, *zero; + + zero = DD_ZERO(manager); + + /* Cube is guaranteed to be a cube at this point. */ + if (f == zero || cuddIsConstant(cube)) { + return(f); + } + + /* Abstract a variable that does not appear in f. */ + if (cuddI(manager,f->index) > cuddI(manager,cube->index)) { + res = cuddAddMinAbstractRecur(manager, f, cuddT(cube)); + return(res); + } + + if ((res = cuddCacheLookup2(manager, Cudd_addMinAbstract, f, cube)) != NULL) { + return(res); + } + + + T = cuddT(f); + E = cuddE(f); + + /* If the two indices are the same, so are their levels. */ + if (f->index == cube->index) { + res1 = cuddAddMinAbstractRecur(manager, T, cuddT(cube)); + if (res1 == NULL) return(NULL); + cuddRef(res1); + res2 = cuddAddMinAbstractRecur(manager, E, cuddT(cube)); + if (res2 == NULL) { + Cudd_RecursiveDeref(manager,res1); + return(NULL); + } + cuddRef(res2); + res = cuddAddApplyRecur(manager, Cudd_addMinimumExcept0, res1, res2); + if (res == NULL) { + Cudd_RecursiveDeref(manager,res1); + Cudd_RecursiveDeref(manager,res2); + return(NULL); + } + cuddRef(res); + Cudd_RecursiveDeref(manager,res1); + Cudd_RecursiveDeref(manager,res2); + cuddCacheInsert2(manager, Cudd_addMinAbstract, f, cube, res); + cuddDeref(res); + return(res); + } + else { /* if (cuddI(manager,f->index) < cuddI(manager,cube->index)) */ + res1 = cuddAddMinAbstractRecur(manager, T, cube); + if (res1 == NULL) return(NULL); + cuddRef(res1); + res2 = cuddAddMinAbstractRecur(manager, E, cube); + if (res2 == NULL) { + Cudd_RecursiveDeref(manager,res1); + return(NULL); + } + cuddRef(res2); + res = (res1 == res2) ? res1 : + cuddUniqueInter(manager, (int) f->index, res1, res2); + if (res == NULL) { + Cudd_RecursiveDeref(manager,res1); + Cudd_RecursiveDeref(manager,res2); + return(NULL); + } + cuddDeref(res1); + cuddDeref(res2); + cuddCacheInsert2(manager, Cudd_addMinAbstract, f, cube, res); + return(res); + } + +} /* end of cuddAddMinAbstractRecur */ /**Function******************************************************************** @@ -774,6 +976,385 @@ cuddAddMaxAbstractRecur( /* Definition of static functions */ /*---------------------------------------------------------------------------*/ +/**Function******************************************************************** + + Synopsis [Performs the recursive step of Cudd_addMinAbstractRepresentative.] + + Description [Performs the recursive step of Cudd_addMinAbstractRepresentative. + Returns the ADD obtained by picking a representative over the variables in + the given cube for all other valuations. Returns the resulting ADD if successful; + NULL otherwise.] + + SideEffects [None] + + SeeAlso [] + + ******************************************************************************/ +DdNode * +cuddAddMinAbstractRepresentativeRecur( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *T, *E, *res, *res1, *res2, *zero, *one, *logicalZero, *res1Inf, *res2Inf, *left, *right, *tmp, *tmp2; + + zero = DD_ZERO(manager); + one = DD_ONE(manager); + logicalZero = Cudd_Not(one); + + /* Cube is guaranteed to be a cube at this point. */ + if (cuddIsConstant(cube)) { + return one; + } + if (cuddIsConstant(f)) { + res = cuddAddMinAbstractRepresentativeRecur(manager, f, cuddT(cube)); + if (res == NULL) { + return(NULL); + } + cuddRef(res); + + // We build in the negation ourselves. + res1 = cuddUniqueInter(manager, (int) cube->index, one, Cudd_Not(res)); + if (res1 == NULL) { + Cudd_IterDerefBdd(manager,res); + return(NULL); + } + res1 = Cudd_Not(res1); + cuddDeref(res); + return(res1); + } + + /* Abstract a variable that does not appear in f. */ + if (cuddI(manager,f->index) > cuddI(manager,cube->index)) { + res = cuddAddMinAbstractRepresentativeRecur(manager, f, cuddT(cube)); + if (res == NULL) { + return(NULL); + } + + // Fill in the missing variables to make representative unique. + cuddRef(res); + // We build in the negation ourselves. + res1 = cuddUniqueInter(manager, (int) cube->index, one, Cudd_Not(res)); + if (res1 == NULL) { + Cudd_IterDerefBdd(manager,res); + return(NULL); + } + res1 = Cudd_Not(res1); + cuddDeref(res); + return(res1); + } + + if ((res = cuddCacheLookup2(manager, Cudd_addMinAbstractRepresentative, f, cube)) != NULL) { + return(res); + } + + + E = cuddE(f); + T = cuddT(f); + + /* If the two indices are the same, so are their levels. */ + if (f->index == cube->index) { + res1 = cuddAddMinAbstractRepresentativeRecur(manager, E, cuddT(cube)); + if (res1 == NULL) { + return(NULL); + } + cuddRef(res1); + + res2 = cuddAddMinAbstractRepresentativeRecur(manager, T, cuddT(cube)); + if (res2 == NULL) { + Cudd_IterDerefBdd(manager, res1); + return(NULL); + } + cuddRef(res2); + + left = cuddAddMinAbstractRecur(manager, E, cuddT(cube)); + if (left == NULL) { + Cudd_IterDerefBdd(manager, res1); + Cudd_IterDerefBdd(manager, res2); + return(NULL); + } + cuddRef(left); + right = cuddAddMinAbstractRecur(manager, T, cuddT(cube)); + if (right == NULL) { + Cudd_IterDerefBdd(manager, res1); + Cudd_IterDerefBdd(manager, res2); + Cudd_RecursiveDeref(manager, left); + return(NULL); + } + cuddRef(right); + + tmp = cuddAddToBddApplyRecur(manager, Cudd_addToBddLessThanEquals, left, right); + if (tmp == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + Cudd_RecursiveDeref(manager,left); + Cudd_RecursiveDeref(manager,right); + return(NULL); + } + cuddRef(tmp); + + Cudd_RecursiveDeref(manager, left); + Cudd_RecursiveDeref(manager, right); + + res1Inf = cuddBddIteRecur(manager, tmp, res1, logicalZero); + if (res1Inf == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,tmp); + return(NULL); + } + cuddRef(res1Inf); + Cudd_IterDerefBdd(manager,res1); + + res2Inf = cuddBddIteRecur(manager, tmp, logicalZero, res2); + Cudd_IterDerefBdd(manager,tmp); + if (res2Inf == NULL) { + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,res1Inf); + return(NULL); + } + cuddRef(res2Inf); + Cudd_IterDerefBdd(manager,res2); + + int compl = (res1Inf == res2Inf) ? 1 : Cudd_IsComplement(res2Inf); + res = (res1Inf == res2Inf) ? cuddUniqueInter(manager, (int) f->index, one, Cudd_Not(res1Inf)) : cuddUniqueInter(manager, (int) f->index, Cudd_Regular(res2Inf), compl ? Cudd_Not(res1Inf) : res1Inf); + if (res == NULL) { + Cudd_IterDerefBdd(manager,res1Inf); + Cudd_IterDerefBdd(manager,res2Inf); + return(NULL); + } + if (compl) { + res = Cudd_Not(res); + } + cuddRef(res); + cuddDeref(res1Inf); + cuddDeref(res2Inf); + cuddCacheInsert2(manager, Cudd_addMinAbstractRepresentative, f, cube, res); + cuddDeref(res); + return(res); + } + else { /* if (cuddI(manager,f->index) < cuddI(manager,cube->index)) */ + res1 = cuddAddMinAbstractRepresentativeRecur(manager, E, cube); + if (res1 == NULL) return(NULL); + cuddRef(res1); + res2 = cuddAddMinAbstractRepresentativeRecur(manager, T, cube); + if (res2 == NULL) { + Cudd_IterDerefBdd(manager,res1); + return(NULL); + } + cuddRef(res2); + + int compl = (res1 == res2) ? 0 : Cudd_IsComplement(res2); + res = (res1 == res2) ? res1 : cuddUniqueInter(manager, (int) f->index, Cudd_Regular(res2), compl ? Cudd_Not(res1) : res1); + if (res == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + return(NULL); + } + if (compl) { + res = Cudd_Not(res); + } + cuddDeref(res1); + cuddDeref(res2); + cuddCacheInsert2(manager, Cudd_addMinAbstractRepresentative, f, cube, res); + return(res); + } + +} /* end of cuddAddMinAbstractRepresentativeRecur */ + +/**Function******************************************************************** + + Synopsis [Performs the recursive step of Cudd_addMaxAbstractRepresentative.] + + Description [Performs the recursive step of Cudd_addMaxAbstractRepresentative. + Returns the ADD obtained by picking a representative over the variables in + the given cube for all other valuations. Returns the resulting ADD if successful; + NULL otherwise.] + + SideEffects [None] + + SeeAlso [] + + ******************************************************************************/ +DdNode * +cuddAddMaxAbstractRepresentativeRecur( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *T, *E, *res, *res1, *res2, *zero, *one, *logicalZero, *res1Inf, *res2Inf, *left, *right, *tmp, *tmp2; + + zero = DD_ZERO(manager); + one = DD_ONE(manager); + logicalZero = Cudd_Not(one); + + /* Cube is guaranteed to be a cube at this point. */ + if (cuddIsConstant(cube)) { + return one; + } + if (cuddIsConstant(f)) { + res = cuddAddMaxAbstractRepresentativeRecur(manager, f, cuddT(cube)); + if (res == NULL) { + return(NULL); + } + cuddRef(res); + + // We build in the negation ourselves. + res1 = cuddUniqueInter(manager, (int) cube->index, one, Cudd_Not(res)); + if (res1 == NULL) { + Cudd_IterDerefBdd(manager,res); + return(NULL); + } + res1 = Cudd_Not(res1); + cuddDeref(res); + return(res1); + + } + + /* Abstract a variable that does not appear in f. */ + if (cuddI(manager,f->index) > cuddI(manager,cube->index)) { + res = cuddAddMaxAbstractRepresentativeRecur(manager, f, cuddT(cube)); + + if (res == NULL) { + return(NULL); + } + + // Fill in the missing variables to make representative unique. + cuddRef(res); + res1 = cuddUniqueInter(manager, (int) cube->index, one, Cudd_Not(res)); + if (res1 == NULL) { + Cudd_IterDerefBdd(manager, res); + return(NULL); + } + res1 = Cudd_Not(res1); + Cudd_IterDerefBdd(manager,res); + return(res1); + } + + if ((res = cuddCacheLookup2(manager, Cudd_addMaxAbstractRepresentative, f, cube)) != NULL) { + return(res); + } + + + E = cuddE(f); + T = cuddT(f); + + /* If the two indices are the same, so are their levels. */ + if (f->index == cube->index) { + res1 = cuddAddMaxAbstractRepresentativeRecur(manager, E, cuddT(cube)); + if (res1 == NULL) { + return(NULL); + } + cuddRef(res1); + + res2 = cuddAddMaxAbstractRepresentativeRecur(manager, T, cuddT(cube)); + if (res2 == NULL) { + Cudd_IterDerefBdd(manager, res1); + return(NULL); + } + cuddRef(res2); + + left = cuddAddMaxAbstractRecur(manager, E, cuddT(cube)); + if (left == NULL) { + Cudd_IterDerefBdd(manager, res1); + Cudd_IterDerefBdd(manager, res2); + return(NULL); + } + cuddRef(left); + right = cuddAddMaxAbstractRecur(manager, T, cuddT(cube)); + if (right == NULL) { + Cudd_IterDerefBdd(manager, res1); + Cudd_IterDerefBdd(manager, res2); + Cudd_RecursiveDeref(manager, left); + return(NULL); + } + cuddRef(right); + + tmp = cuddAddToBddApplyRecur(manager, Cudd_addToBddGreaterThanEquals, left, right); + if (tmp == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + Cudd_RecursiveDeref(manager,left); + Cudd_RecursiveDeref(manager,right); + return(NULL); + } + cuddRef(tmp); + + Cudd_RecursiveDeref(manager, left); + Cudd_RecursiveDeref(manager, right); + + cuddRef(zero); + res1Inf = cuddBddIteRecur(manager, tmp, res1, logicalZero); + if (res1Inf == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,tmp); + cuddDeref(zero); + return(NULL); + } + cuddRef(res1Inf); + Cudd_IterDerefBdd(manager,res1); + + cuddRef(zero); + res2Inf = cuddBddIteRecur(manager, tmp, logicalZero, res2); + if (res2Inf == NULL) { + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,res1Inf); + Cudd_IterDerefBdd(manager,tmp); + return(NULL); + } + cuddRef(res2Inf); + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,tmp); + + int compl = (res1Inf == res2Inf) ? 1 : Cudd_IsComplement(res2Inf); + res = (res1Inf == res2Inf) ? cuddUniqueInter(manager, (int) f->index, one, Cudd_Not(res1Inf)) : cuddUniqueInter(manager, (int) f->index, Cudd_Regular(res2Inf), compl ? Cudd_Not(res1Inf) : res1Inf); + if (res == NULL) { + Cudd_IterDerefBdd(manager,res1Inf); + Cudd_IterDerefBdd(manager,res2Inf); + return(NULL); + } + if (compl) { + res = Cudd_Not(res); + } + cuddRef(res); + Cudd_IterDerefBdd(manager,res1Inf); + Cudd_IterDerefBdd(manager,res2Inf); + cuddCacheInsert2(manager, Cudd_addMaxAbstractRepresentative, f, cube, res); + cuddDeref(res); + return(res); + } + else { /* if (cuddI(manager,f->index) < cuddI(manager,cube->index)) */ + res1 = cuddAddMaxAbstractRepresentativeRecur(manager, E, cube); + if (res1 == NULL) return(NULL); + cuddRef(res1); + res2 = cuddAddMaxAbstractRepresentativeRecur(manager, T, cube); + if (res2 == NULL) { + Cudd_IterDerefBdd(manager,res1); + return(NULL); + } + cuddRef(res2); + + int compl = (res1 == res2) ? 0 : Cudd_IsComplement(res2); + res = (res1 == res2) ? res1 : cuddUniqueInter(manager, (int) f->index, Cudd_Regular(res2), compl ? Cudd_Not(res1) : res1); + if (res == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + return(NULL); + } + if (compl) { + res = Cudd_Not(res); + } + cuddDeref(res1); + cuddDeref(res2); + cuddCacheInsert2(manager, Cudd_addMaxAbstractRepresentative, f, cube, res); + return(res); + } +} /* end of cuddAddMaxAbstractRepresentativeRecur */ + +/*---------------------------------------------------------------------------*/ +/* Definition of static functions */ +/*---------------------------------------------------------------------------*/ /** @brief Checks whether cube is an %ADD representing the product diff --git a/resources/3rdparty/cudd-3.0.0/cudd/cuddAddApply.c b/resources/3rdparty/cudd-3.0.0/cudd/cuddAddApply.c index d7a3c71cc..01fc45fe6 100644 --- a/resources/3rdparty/cudd-3.0.0/cudd/cuddAddApply.c +++ b/resources/3rdparty/cudd-3.0.0/cudd/cuddAddApply.c @@ -117,6 +117,41 @@ Cudd_addApply( } /* end of Cudd_addApply */ +/** + @brief Applies op to the corresponding discriminants of f and g and produces a BDD as a result. + + @return a pointer to the result if succssful; NULL otherwise. + + @sideeffect None + + @see Cudd_addMonadicApply Cudd_addPlus Cudd_addTimes + Cudd_addThreshold Cudd_addSetNZ Cudd_addDivide Cudd_addMinus Cudd_addMinimum + Cudd_addMaximum Cudd_addOneZeroMaximum Cudd_addDiff Cudd_addAgreement + Cudd_addOr Cudd_addNand Cudd_addNor Cudd_addXor Cudd_addXnor + + added 23/08/2016 by Christian Dehnert + + */ +DdNode * +Cudd_addToBddApply( + DdManager * dd /**< manager */, + DD_AOP op /**< operator */, + DdNode * f /**< first operand */, + DdNode * g /**< second operand */) +{ + DdNode *res; + + do { + dd->reordered = 0; + res = cuddAddToBddApplyRecur(dd,op,f,g); + } while (dd->reordered == 1); + if (dd->errorCode == CUDD_TIMEOUT_EXPIRED && dd->timeoutHandler) { + dd->timeoutHandler(dd, dd->tohArg); + } + + return(res); + +} /* end of Cudd_addToBddApply */ /** @brief Integer and floating point addition. @@ -371,6 +406,53 @@ Cudd_addMinimum( } /* end of Cudd_addMinimum */ +/** + @brief Integer and floating point min. + + @details Integer and floating point min for Cudd_addApply. + + @return NULL if not a terminal case; min(f,g) otherwise. + + @sideeffect None + + @see Cudd_addApply + + added 24/08/2016 + + */ +DdNode * +Cudd_addMinimumExcept0( + DdManager * dd, + DdNode ** f, + DdNode ** g) +{ + DdNode *F, *G; + + F = *f; G = *g; + if (F == DD_ZERO(dd)) return(G); + if (G == DD_ZERO(dd)) return(F); + if (F == DD_PLUS_INFINITY(dd)) return(G); + if (G == DD_PLUS_INFINITY(dd)) return(F); + if (F == G) return(F); +#if 0 + /* These special cases probably do not pay off. */ + if (F == DD_MINUS_INFINITY(dd)) return(F); + if (G == DD_MINUS_INFINITY(dd)) return(G); +#endif + if (cuddIsConstant(F) && cuddIsConstant(G)) { + if (cuddV(F) <= cuddV(G)) { + return(F); + } else { + return(G); + } + } + if (F > G) { /* swap f and g */ + *f = G; + *g = F; + } + return(NULL); + +} /* end of Cudd_addMinimumExcept0 */ /** @brief Integer and floating point max. @@ -817,6 +899,38 @@ Cudd_addEquals( } /* end of Cudd_addEquals */ +/**Function******************************************************************** + + Synopsis [1 if f==g; 0 otherwise.] + + Description [Returns NULL if not a terminal case; f op g otherwise, + where f op g is 1 if f==g; 0 otherwise.] + + SideEffects [None] + + SeeAlso [Cudd_addApply] + + Added 23/08/2016 by Christian Dehnert + + ******************************************************************************/ +DdNode * +Cudd_addToBddEquals( + DdManager * dd, + DdNode ** f, + DdNode ** g) +{ + DdNode *F, *G; + + F = *f; G = *g; + if (F == G) return(DD_ONE(dd)); + if (cuddIsConstant(F) && cuddIsConstant(G)) return(Cudd_Not(DD_ONE(dd))); + if (F > G) { /* swap f and g */ + *f = G; + *g = F; + } + return(NULL); + +} /* end of Cudd_addToBddEquals */ /**Function******************************************************************** @@ -849,6 +963,39 @@ Cudd_addNotEquals( } /* end of Cudd_addNotEquals */ +/**Function******************************************************************** + + Synopsis [1 if f!=g; 0 otherwise.] + + Description [Returns NULL if not a terminal case; f op g otherwise, + where f op g is 1 if f!=g; 0 otherwise.] + + SideEffects [None] + + SeeAlso [Cudd_addApply] + + Added 23/08/2016 by Christian Dehnert + + ******************************************************************************/ +DdNode * +Cudd_addToBddNotEquals( + DdManager * dd, + DdNode ** f, + DdNode ** g) +{ + DdNode *F, *G; + + F = *f; G = *g; + if (F == G) return(Cudd_Not(DD_ONE(dd))); + if (cuddIsConstant(F) && cuddIsConstant(G)) return(DD_ONE(dd)); + if (F > G) { /* swap f and g */ + *f = G; + *g = F; + } + return(NULL); + +} /* end of Cudd_addToBddNotEquals */ + /**Function******************************************************************** Synopsis [1 if f>g; 0 otherwise.] @@ -878,6 +1025,37 @@ Cudd_addGreaterThan( } /* end of Cudd_addGreaterThan */ +/**Function******************************************************************** + + Synopsis [1 if f>g; 0 otherwise.] + + Description [Returns NULL if not a terminal case; f op g otherwise, + where f op g is 1 if f>g; 0 otherwise.] + + SideEffects [None] + + SeeAlso [Cudd_addApply] + + Added 23/08/2016 by Christian Dehnert + + ******************************************************************************/ +DdNode * +Cudd_addToBddGreaterThan( + DdManager * dd, + DdNode ** f, + DdNode ** g) +{ + DdNode *F, *G; + + F = *f; G = *g; + if (F == G) return(Cudd_Not(DD_ONE(dd))); + if (cuddIsConstant(F) && cuddIsConstant(G)) { + if (cuddV(F)>cuddV(G)) return (DD_ONE(dd)); else return (Cudd_Not(DD_ONE(dd))); + } + return(NULL); + +} /* end of Cudd_addToBddGreaterThan */ + /**Function******************************************************************** @@ -908,6 +1086,36 @@ Cudd_addGreaterThanEquals( } /* end of Cudd_addGreaterThanEquals */ +/**Function******************************************************************** + + Synopsis [1 if f>=g; 0 otherwise.] + + Description [Returns NULL if not a terminal case; f op g otherwise, + where f op g is 1 if f>=g; 0 otherwise.] + + SideEffects [None] + + SeeAlso [Cudd_addApply] + + Added 23/08/2016 by Christian Dehnert + + ******************************************************************************/ +DdNode * +Cudd_addToBddGreaterThanEquals( + DdManager * dd, + DdNode ** f, + DdNode ** g) +{ + DdNode *F, *G; + + F = *f; G = *g; + if (F == G) return(DD_ONE(dd)); + if (cuddIsConstant(F) && cuddIsConstant(G)) { + if (cuddV(F)>=cuddV(G)) return (DD_ONE(dd)); else return (Cudd_Not(DD_ONE(dd))); + } + return(NULL); + +} /* end of Cudd_addToBddGreaterThanEquals */ /**Function******************************************************************** @@ -938,6 +1146,36 @@ Cudd_addLessThan( } /* end of Cudd_addLessThan */ +/**Function******************************************************************** + + Synopsis [1 if findex); + gord = cuddI(dd,g->index); + if (ford <= gord) { + index = f->index; + fv = cuddT(f); + fvn = cuddE(f); + } else { + index = g->index; + fv = fvn = f; + } + if (gord <= ford) { + gv = cuddT(g); + gvn = cuddE(g); + } else { + gv = gvn = g; + } + + T = cuddAddToBddApplyRecur(dd,op,fv,gv); + if (T == NULL) return(NULL); + cuddRef(T); + + E = cuddAddToBddApplyRecur(dd,op,fvn,gvn); + if (E == NULL) { + Cudd_IterDerefBdd(dd,T); + return(NULL); + } + cuddRef(E); + + int complT = Cudd_IsComplement(T); + + if (T == E) { + res = T; + } else { + res = cuddUniqueInter(dd,(int)index,Cudd_Regular(T),complT ? Cudd_Not(E) : E); + if (complT) { + res = Cudd_Not(res); + } + } + if (res == NULL) { + Cudd_IterDerefBdd(dd, T); + Cudd_IterDerefBdd(dd, E); + return(NULL); + } + cuddRef(res); + cuddDeref(T); + cuddDeref(E); + + /* Store result. */ + cuddCacheInsert2(dd,cacheOp,f,g,res); + + cuddDeref(res); + return(res); + +} /* end of cuddAddToBddApplyRecur */ /** @brief Performs the recursive step of Cudd_addMonadicApply. diff --git a/resources/3rdparty/cudd-3.0.0/cudd/cuddBddAbs.c b/resources/3rdparty/cudd-3.0.0/cudd/cuddBddAbs.c index 62170e3b2..8c3026b9d 100644 --- a/resources/3rdparty/cudd-3.0.0/cudd/cuddBddAbs.c +++ b/resources/3rdparty/cudd-3.0.0/cudd/cuddBddAbs.c @@ -124,6 +124,42 @@ Cudd_bddExistAbstract( } /* end of Cudd_bddExistAbstract */ +/**Function******************************************************************** + + Synopsis [Just like Cudd_bddExistAbstract, but instead of abstracting the + variables in the given cube, picks a unique representative that realizes the + existential truth value.] + + Description [Returns the resulting BDD if successful; NULL otherwise.] + + SideEffects [None] + + SeeAlso [] + + Note: Added by Christian Dehnert 9/21/15 + + ******************************************************************************/ +DdNode * +Cudd_bddExistAbstractRepresentative( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *res; + + if (bddCheckPositiveCube(manager, cube) == 0) { + (void) fprintf(manager->err,"Error: Can only abstract positive cubes\n"); + manager->errorCode = CUDD_INVALID_ARG; + return(NULL); + } + + do { + manager->reordered = 0; + res = cuddBddExistAbstractRepresentativeRecur(manager, f, cube); + } while (manager->reordered == 1); + return(res); + +} /* end of Cudd_bddExistAbstractRepresentative */ /** @brief Existentially abstracts all the variables in cube from f. @@ -465,6 +501,209 @@ cuddBddExistAbstractRecur( } /* end of cuddBddExistAbstractRecur */ +/**Function******************************************************************** + + Synopsis [Performs the recursive steps of Cudd_bddExistAbstractRepresentative.] + + Description [Performs the recursive steps of Cudd_bddExistAbstractRepresentative. + Returns the BDD obtained by picking a representative over the variables in + the given cube for all other valuations. Returns the resulting BDD if successful; + NULL otherwise.] + + SideEffects [None] + + SeeAlso [] + + ******************************************************************************/ +DdNode * +cuddBddExistAbstractRepresentativeRecur( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *F, *T, *E, *res, *res1, *res2, *one, *zero, *left, *right, *tmp, *res1Inf, *res2Inf; + + statLine(manager); + one = DD_ONE(manager); + zero = Cudd_Not(one); + F = Cudd_Regular(f); + + // Store whether f is negated. + int fIsNegated = f != F; + + /* Cube is guaranteed to be a cube at this point. */ + if (F == one) { + if (fIsNegated) { + return f; + } + + if (cube == one) { + return one; + } else { + res = cuddBddExistAbstractRepresentativeRecur(manager, f, cuddT(cube)); + if (res == NULL) { + return(NULL); + } + cuddRef(res); + +// res1 = cuddUniqueInter(manager, (int) cube->index, zero, res); + + // We now build in the necessary negation ourselves. + res1 = cuddUniqueInter(manager, (int) cube->index, one, Cudd_Not(res)); + if (res1 == NULL) { + Cudd_IterDerefBdd(manager,res); + return(NULL); + } + res1 = Cudd_Not(res1); + cuddDeref(res); + return(res1); + } + } else if (cube == one) { + return f; + } + /* From now on, cube and f are non-constant. */ + + + /* Abstract a variable that does not appear in f. */ + if (manager->perm[F->index] > manager->perm[cube->index]) { + res = cuddBddExistAbstractRepresentativeRecur(manager, f, cuddT(cube)); + if (res == NULL) { + return(NULL); + } + cuddRef(res); + +// res1 = cuddUniqueInter(manager, (int) cube->index, zero, res); + + // We now build in the necessary negation ourselves. + res1 = cuddUniqueInter(manager, (int) cube->index, one, Cudd_Not(res)); + if (res1 == NULL) { + Cudd_IterDerefBdd(manager,res); + return(NULL); + } + res1 = Cudd_Not(res1); + cuddDeref(res); + + return(res1); + } + + /* Check the cache. */ + if (F->ref != 1 && (res = cuddCacheLookup2(manager, Cudd_bddExistAbstractRepresentative, f, cube)) != NULL) { + return(res); + } + + /* Compute the cofactors of f. */ + T = cuddT(F); E = cuddE(F); + if (f != F) { + T = Cudd_Not(T); E = Cudd_Not(E); + } + + /* If the two indices are the same, so are their levels. */ + if (F->index == cube->index) { + res1 = cuddBddExistAbstractRepresentativeRecur(manager, E, cuddT(cube)); + if (res1 == NULL) { + return(NULL); + } + if (res1 == one) { + if (F->ref != 1) { + cuddCacheInsert2(manager, Cudd_bddExistAbstractRepresentative, f, cube, Cudd_Not(cube)); + } + return(Cudd_Not(cube)); + } + cuddRef(res1); + + res2 = cuddBddExistAbstractRepresentativeRecur(manager, T, cuddT(cube)); + if (res2 == NULL) { + Cudd_IterDerefBdd(manager,res1); + return(NULL); + } + cuddRef(res2); + + left = cuddBddExistAbstractRecur(manager, E, cuddT(cube)); + if (left == NULL) { + Cudd_IterDerefBdd(manager, res1); + Cudd_IterDerefBdd(manager, res2); + return(NULL); + } + cuddRef(left); + + res1Inf = cuddBddIteRecur(manager, left, res1, zero); + if (res1Inf == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,left); + return(NULL); + } + cuddRef(res1Inf); + + Cudd_IterDerefBdd(manager,res1); + + res2Inf = cuddBddIteRecur(manager, left, zero, res2); + if (res2Inf == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,left); + Cudd_IterDerefBdd(manager,res1Inf); + return(NULL); + } + cuddRef(res2Inf); + + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,left); + + assert(res1Inf != res2Inf); + int compl = Cudd_IsComplement(res2Inf); + res = cuddUniqueInter(manager, (int) F->index, Cudd_Regular(res2Inf), compl ? Cudd_Not(res1Inf) : res1Inf); + if (res == NULL) { + Cudd_IterDerefBdd(manager,res1Inf); + Cudd_IterDerefBdd(manager,res2Inf); + return(NULL); + } + if (compl) { + res = Cudd_Not(res); + } + cuddRef(res); + + cuddDeref(res1Inf); + cuddDeref(res2Inf); + + cuddCacheInsert2(manager, Cudd_bddExistAbstractRepresentative, f, cube, res); + cuddDeref(res); + return(res); + } else { /* if (cuddI(manager,F->index) < cuddI(manager,cube->index)) */ + res1 = cuddBddExistAbstractRepresentativeRecur(manager, E, cube); + if (res1 == NULL){ + return(NULL); + } + cuddRef(res1); + + res2 = cuddBddExistAbstractRepresentativeRecur(manager, T, cube); + if (res2 == NULL) { + Cudd_IterDerefBdd(manager, res1); + return(NULL); + } + cuddRef(res2); + + /* ITE takes care of possible complementation of res1 and of the + ** case in which res1 == res2. */ + int compl = Cudd_IsComplement(res2); + res = cuddUniqueInter(manager, (int)F->index, Cudd_Regular(res2), compl ? Cudd_Not(res1) : res1); + if (res == NULL) { + Cudd_IterDerefBdd(manager, res1); + Cudd_IterDerefBdd(manager, res2); + return(NULL); + } + if (compl) { + res = Cudd_Not(res); + } + cuddDeref(res1); + cuddDeref(res2); + if (F->ref != 1) { + cuddCacheInsert2(manager, Cudd_bddExistAbstractRepresentative, f, cube, res); + } + return(res); + } + +} /* end of cuddBddExistAbstractRepresentativeRecur */ /** @brief Takes the exclusive OR of two BDDs and simultaneously abstracts the diff --git a/resources/3rdparty/cudd-3.0.0/cudd/cuddInt.h b/resources/3rdparty/cudd-3.0.0/cudd/cuddInt.h index ccb2a8f16..f5af25cd2 100644 --- a/resources/3rdparty/cudd-3.0.0/cudd/cuddInt.h +++ b/resources/3rdparty/cudd-3.0.0/cudd/cuddInt.h @@ -1062,8 +1062,12 @@ extern DdNode * cuddAddExistAbstractRecur(DdManager *manager, DdNode *f, DdNode extern DdNode * cuddAddUnivAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube); extern DdNode * cuddAddOrAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube); extern DdNode * cuddAddMinAbstractRecur (DdManager *manager, DdNode *f, DdNode *cube); +extern DdNode * cuddAddMinExcept0AbstractRecur (DdManager *manager, DdNode *f, DdNode *cube); extern DdNode * cuddAddMaxAbstractRecur (DdManager *manager, DdNode *f, DdNode *cube); +extern DdNode * cuddAddMinAbstractRepresentativeRecur(DdManager * manager, DdNode * f, DdNode * cube); +extern DdNode * cuddAddMaxAbstractRepresentativeRecur(DdManager * manager, DdNode * f, DdNode * cube); extern DdNode * cuddAddApplyRecur(DdManager *dd, DdNode * (*)(DdManager *, DdNode **, DdNode **), DdNode *f, DdNode *g); +extern DdNode * cuddAddToBddApplyRecur(DdManager *dd, DdNode * (*)(DdManager *, DdNode **, DdNode **), DdNode *f, DdNode *g); extern DdNode * cuddAddMonadicApplyRecur(DdManager * dd, DdNode * (*op)(DdManager *, DdNode *), DdNode * f); extern DdNode * cuddAddScalarInverseRecur(DdManager *dd, DdNode *f, DdNode *epsilon); extern DdNode * cuddAddIteRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *h); @@ -1076,6 +1080,7 @@ extern DdNode * cuddBiasedUnderApprox(DdManager *dd, DdNode *f, DdNode *b, int n extern DdNode * cuddBddAndAbstractRecur(DdManager *manager, DdNode *f, DdNode *g, DdNode *cube); extern int cuddAnnealing(DdManager *table, int lower, int upper); extern DdNode * cuddBddExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube); +extern DdNode * cuddBddExistAbstractRepresentativeRecur(DdManager *manager, DdNode *f, DdNode *cube); extern DdNode * cuddBddXorExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *g, DdNode *cube); extern DdNode * cuddBddBooleanDiffRecur(DdManager *manager, DdNode *f, DdNode *var); extern DdNode * cuddBddIteRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *h); diff --git a/resources/3rdparty/cudd-3.0.0/cudd/cuddSat.c b/resources/3rdparty/cudd-3.0.0/cudd/cuddSat.c index 91daa142b..c07b948c3 100644 --- a/resources/3rdparty/cudd-3.0.0/cudd/cuddSat.c +++ b/resources/3rdparty/cudd-3.0.0/cudd/cuddSat.c @@ -843,11 +843,12 @@ Cudd_EqualSupNormRel( /* Check terminal cases. */ if (f == g) return(1); if (Cudd_IsConstant(f) && Cudd_IsConstant(g)) { - if (ddAbs((cuddV(f) - cuddV(g))/cuddV(f)) < tolerance) { + CUDD_VALUE_TYPE absDiff = ddAbs((cuddV(f) - cuddV(g))); + if (absDiff/cuddV(f) < tolerance || absDiff < Cudd_ReadEpsilon(dd)) { return(1); } else { if (pr>0) { - (void) fprintf(dd->out,"Offending nodes:\n"); + (void) fprintf(dd->out,"Offending nodes (wrt. precision %0.30f) with diff %0.30f:\n", Cudd_ReadEpsilon(dd), absDiff); (void) fprintf(dd->out, "f: address = %p\t value = %40.30f\n", (void *) f, cuddV(f)); diff --git a/resources/3rdparty/eigen-3.3-beta1/COPYING.BSD b/resources/3rdparty/eigen-3.3-beta1/COPYING.BSD index 11971ffe2..8964ddfdd 100644 --- a/resources/3rdparty/eigen-3.3-beta1/COPYING.BSD +++ b/resources/3rdparty/eigen-3.3-beta1/COPYING.BSD @@ -23,4 +23,4 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ \ No newline at end of file +*/ diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/Core b/resources/3rdparty/eigen-3.3-beta1/Eigen/Core index 63602f4c3..d04611854 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/Core +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/Core @@ -242,7 +242,7 @@ #endif /** \brief Namespace containing all symbols from the %Eigen library. */ -namespace Eigen { +namespace StormEigen { inline static const char *SimdInstructionSetsInUse(void) { #if defined(EIGEN_VECTORIZE_AVX) @@ -268,7 +268,7 @@ inline static const char *SimdInstructionSetsInUse(void) { #endif } -} // end namespace Eigen +} // end namespace StormEigen #if defined EIGEN2_SUPPORT_STAGE40_FULL_EIGEN3_STRICTNESS || defined EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API || defined EIGEN2_SUPPORT_STAGE20_RESOLVE_API_CONFLICTS || defined EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API || defined EIGEN2_SUPPORT // This will generate an error message: diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/QtAlignedMalloc b/resources/3rdparty/eigen-3.3-beta1/Eigen/QtAlignedMalloc index 4044d5ac5..6b462d627 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/QtAlignedMalloc +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/QtAlignedMalloc @@ -16,19 +16,19 @@ void *qMalloc(size_t size) { - return Eigen::internal::aligned_malloc(size); + return StormEigen::internal::aligned_malloc(size); } void qFree(void *ptr) { - Eigen::internal::aligned_free(ptr); + StormEigen::internal::aligned_free(ptr); } void *qRealloc(void *ptr, size_t size) { - void* newPtr = Eigen::internal::aligned_malloc(size); + void* newPtr = StormEigen::internal::aligned_malloc(size); memcpy(newPtr, ptr, size); - Eigen::internal::aligned_free(ptr); + StormEigen::internal::aligned_free(ptr); return newPtr; } diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/SuperLUSupport b/resources/3rdparty/eigen-3.3-beta1/Eigen/SuperLUSupport index 113f58ee5..de32632d5 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/SuperLUSupport +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/SuperLUSupport @@ -33,7 +33,7 @@ typedef int int_t; #define SUPERLU_EMPTY (-1) -namespace Eigen { struct SluMatrix; } +namespace StormEigen { struct SluMatrix; } /** \ingroup Support_modules * \defgroup SuperLUSupport_Module SuperLUSupport module diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Cholesky/LDLT.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Cholesky/LDLT.h index 6fcae01f7..72186d46f 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Cholesky/LDLT.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Cholesky/LDLT.h @@ -13,7 +13,7 @@ #ifndef EIGEN_LDLT_H #define EIGEN_LDLT_H -namespace Eigen { +namespace StormEigen { namespace internal { template struct LDLT_Traits; @@ -59,7 +59,7 @@ template class LDLT }; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 typedef typename MatrixType::StorageIndex StorageIndex; typedef Matrix TmpMatrixType; @@ -596,6 +596,6 @@ MatrixBase::ldlt() const } #endif // __CUDACC__ -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_LDLT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Cholesky/LLT.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Cholesky/LLT.h index 1f0091f3c..a4af79d9a 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Cholesky/LLT.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Cholesky/LLT.h @@ -10,7 +10,7 @@ #ifndef EIGEN_LLT_H #define EIGEN_LLT_H -namespace Eigen { +namespace StormEigen { namespace internal{ template struct LLT_Traits; @@ -59,7 +59,7 @@ template class LLT }; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 typedef typename MatrixType::StorageIndex StorageIndex; enum { @@ -325,7 +325,7 @@ template struct llt_inplace template static Index rankUpdate(MatrixType& mat, const VectorType& vec, const RealScalar& sigma) { - return Eigen::internal::llt_rank_update_lower(mat, vec, sigma); + return StormEigen::internal::llt_rank_update_lower(mat, vec, sigma); } }; @@ -487,6 +487,6 @@ SelfAdjointView::llt() const } #endif // __CUDACC__ -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_LLT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Cholesky/LLT_MKL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Cholesky/LLT_MKL.h index 0d42cb5bc..d9a024209 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Cholesky/LLT_MKL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Cholesky/LLT_MKL.h @@ -36,7 +36,7 @@ #include "Eigen/src/Core/util/MKL_support.h" #include -namespace Eigen { +namespace StormEigen { namespace internal { @@ -73,7 +73,7 @@ template<> struct llt_inplace \ } \ template \ static Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \ - { return Eigen::internal::llt_rank_update_lower(mat, vec, sigma); } \ + { return StormEigen::internal::llt_rank_update_lower(mat, vec, sigma); } \ }; \ template<> struct llt_inplace \ { \ @@ -97,6 +97,6 @@ EIGEN_MKL_LLT(scomplex, MKL_Complex8, c) } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_LLT_MKL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/CholmodSupport/CholmodSupport.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/CholmodSupport/CholmodSupport.h index 06421d5ed..8a8211f04 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/CholmodSupport/CholmodSupport.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/CholmodSupport/CholmodSupport.h @@ -10,7 +10,7 @@ #ifndef EIGEN_CHOLMODSUPPORT_H #define EIGEN_CHOLMODSUPPORT_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -558,6 +558,6 @@ class CholmodDecomposition : public CholmodBase<_MatrixType, _UpLo, CholmodDecom } }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_CHOLMODSUPPORT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Array.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Array.h index e38eda72c..b2f719c60 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Array.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Array.h @@ -10,7 +10,7 @@ #ifndef EIGEN_ARRAY_H #define EIGEN_ARRAY_H -namespace Eigen { +namespace StormEigen { /** \class Array * \ingroup Core_Module @@ -303,9 +303,9 @@ EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex, cd) #undef EIGEN_MAKE_ARRAY_TYPEDEFS_LARGE #define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \ -using Eigen::Matrix##SizeSuffix##TypeSuffix; \ -using Eigen::Vector##SizeSuffix##TypeSuffix; \ -using Eigen::RowVector##SizeSuffix##TypeSuffix; +using StormEigen::Matrix##SizeSuffix##TypeSuffix; \ +using StormEigen::Vector##SizeSuffix##TypeSuffix; \ +using StormEigen::RowVector##SizeSuffix##TypeSuffix; #define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(TypeSuffix) \ EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \ @@ -320,6 +320,6 @@ EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(d) \ EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cf) \ EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cd) -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_ARRAY_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ArrayBase.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ArrayBase.h index b4c24a27a..19067e4f0 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ArrayBase.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ArrayBase.h @@ -10,7 +10,7 @@ #ifndef EIGEN_ARRAYBASE_H #define EIGEN_ARRAYBASE_H -namespace Eigen { +namespace StormEigen { template class MatrixWrapper; @@ -88,7 +88,7 @@ template class ArrayBase typedef CwiseNullaryOp,PlainObject> ConstantReturnType; #endif // not EIGEN_PARSED_BY_DOXYGEN -#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::ArrayBase +#define EIGEN_CURRENT_STORAGE_BASE_CLASS StormEigen::ArrayBase # include "../plugins/CommonCwiseUnaryOps.h" # include "../plugins/MatrixCwiseUnaryOps.h" # include "../plugins/ArrayCwiseUnaryOps.h" @@ -142,7 +142,7 @@ template class ArrayBase EIGEN_DEVICE_FUNC const ArrayBase& array() const { return *this; } - /** \returns an \link Eigen::MatrixBase Matrix \endlink expression of this array + /** \returns an \link StormEigen::MatrixBase Matrix \endlink expression of this array * \sa MatrixBase::array() */ EIGEN_DEVICE_FUNC MatrixWrapper matrix() { return MatrixWrapper(derived()); } @@ -221,6 +221,6 @@ ArrayBase::operator/=(const ArrayBase& other) return derived(); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_ARRAYBASE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ArrayWrapper.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ArrayWrapper.h index 4e484f290..028cf0ad0 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ArrayWrapper.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ArrayWrapper.h @@ -10,7 +10,7 @@ #ifndef EIGEN_ARRAYWRAPPER_H #define EIGEN_ARRAYWRAPPER_H -namespace Eigen { +namespace StormEigen { /** \class ArrayWrapper * \ingroup Core_Module @@ -294,6 +294,6 @@ class MatrixWrapper : public MatrixBase > NestedExpressionType m_expression; }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_ARRAYWRAPPER_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Assign.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Assign.h index 53806ba33..2a68be185 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Assign.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Assign.h @@ -12,7 +12,7 @@ #ifndef EIGEN_ASSIGN_H #define EIGEN_ASSIGN_H -namespace Eigen { +namespace StormEigen { template template @@ -85,6 +85,6 @@ EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const ReturnByValue< return derived(); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_ASSIGN_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/AssignEvaluator.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/AssignEvaluator.h index 9dfffbcc4..5bcd3b388 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/AssignEvaluator.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/AssignEvaluator.h @@ -12,7 +12,7 @@ #ifndef EIGEN_ASSIGN_EVALUATOR_H #define EIGEN_ASSIGN_EVALUATOR_H -namespace Eigen { +namespace StormEigen { // This implementation is based on Assign.h @@ -805,6 +805,6 @@ struct Assignment } // namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_ASSIGN_EVALUATOR_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Assign_MKL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Assign_MKL.h index 897187a30..3bd7328fe 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Assign_MKL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Assign_MKL.h @@ -34,7 +34,7 @@ #ifndef EIGEN_ASSIGN_VML_H #define EIGEN_ASSIGN_VML_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -169,6 +169,6 @@ EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmzPowx, dcomplex, MKL_Complex16, LA) } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_ASSIGN_VML_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/BandMatrix.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/BandMatrix.h index 87c124fdf..feef67cec 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/BandMatrix.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/BandMatrix.h @@ -10,7 +10,7 @@ #ifndef EIGEN_BANDMATRIX_H #define EIGEN_BANDMATRIX_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -179,7 +179,7 @@ struct traits > { typedef _Scalar Scalar; typedef Dense StorageKind; - typedef Eigen::Index StorageIndex; + typedef StormEigen::Index StorageIndex; enum { CoeffReadCost = NumTraits::ReadCost, RowsAtCompileTime = _Rows, @@ -348,6 +348,6 @@ template<> struct AssignmentKind { typedef EigenBase2Eigen } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_BANDMATRIX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Block.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Block.h index 3748e259b..07a383ba1 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Block.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Block.h @@ -11,7 +11,7 @@ #ifndef EIGEN_BLOCK_H #define EIGEN_BLOCK_H -namespace Eigen { +namespace StormEigen { /** \class Block * \ingroup Core_Module @@ -431,6 +431,6 @@ class BlockImpl_dense } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_BLOCK_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/BooleanRedux.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/BooleanRedux.h index 8409d8749..553a99180 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/BooleanRedux.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/BooleanRedux.h @@ -10,7 +10,7 @@ #ifndef EIGEN_ALLANDANY_H #define EIGEN_ALLANDANY_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -126,7 +126,7 @@ inline bool DenseBase::any() const * \sa all(), any() */ template -inline Eigen::Index DenseBase::count() const +inline StormEigen::Index DenseBase::count() const { return derived().template cast().template cast().sum(); } @@ -159,6 +159,6 @@ inline bool DenseBase::allFinite() const #endif } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_ALLANDANY_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CommaInitializer.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CommaInitializer.h index 89bcd750c..d1504795c 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CommaInitializer.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CommaInitializer.h @@ -11,7 +11,7 @@ #ifndef EIGEN_COMMAINITIALIZER_H #define EIGEN_COMMAINITIALIZER_H -namespace Eigen { +namespace StormEigen { /** \class CommaInitializer * \ingroup Core_Module @@ -106,7 +106,7 @@ struct CommaInitializer EIGEN_DEVICE_FUNC inline ~CommaInitializer() #if defined VERIFY_RAISES_ASSERT && (!defined EIGEN_NO_ASSERTION_CHECKING) && defined EIGEN_EXCEPTIONS - EIGEN_EXCEPTION_SPEC(Eigen::eigen_assert_exception) + EIGEN_EXCEPTION_SPEC(StormEigen::eigen_assert_exception) #endif { eigen_assert((m_row+m_currentBlockRows) == m_xpr.rows() @@ -158,6 +158,6 @@ DenseBase::operator<<(const DenseBase& other) return CommaInitializer(*static_cast(this), other); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_COMMAINITIALIZER_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CoreEvaluators.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CoreEvaluators.h index f97dc33de..c98ce80e6 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CoreEvaluators.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CoreEvaluators.h @@ -13,7 +13,7 @@ #ifndef EIGEN_COREEVALUATORS_H #define EIGEN_COREEVALUATORS_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -1371,6 +1371,6 @@ protected: } // namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_COREEVALUATORS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CoreIterators.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CoreIterators.h index 4eb42b93a..8f0893db5 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CoreIterators.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CoreIterators.h @@ -10,7 +10,7 @@ #ifndef EIGEN_COREITERATORS_H #define EIGEN_COREITERATORS_H -namespace Eigen { +namespace StormEigen { /* This file contains the respective InnerIterator definition of the expressions defined in Eigen/Core */ @@ -122,6 +122,6 @@ public: } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_COREITERATORS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseBinaryOp.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseBinaryOp.h index e42c3031b..14abec97d 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseBinaryOp.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseBinaryOp.h @@ -11,7 +11,7 @@ #ifndef EIGEN_CWISE_BINARY_OP_H #define EIGEN_CWISE_BINARY_OP_H -namespace Eigen { +namespace StormEigen { /** \class CwiseBinaryOp * \ingroup Core_Module @@ -178,7 +178,7 @@ MatrixBase::operator+=(const MatrixBase& other) return derived(); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_CWISE_BINARY_OP_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseNullaryOp.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseNullaryOp.h index 2bc6933d9..0fd3503fd 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseNullaryOp.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseNullaryOp.h @@ -10,7 +10,7 @@ #ifndef EIGEN_CWISE_NULLARY_OP_H #define EIGEN_CWISE_NULLARY_OP_H -namespace Eigen { +namespace StormEigen { /** \class CwiseNullaryOp * \ingroup Core_Module @@ -866,6 +866,6 @@ template EIGEN_STRONG_INLINE const typename MatrixBase::BasisReturnType MatrixBase::UnitW() { return Derived::Unit(3); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_CWISE_NULLARY_OP_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseUnaryOp.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseUnaryOp.h index da1d1992d..a383fcbaf 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseUnaryOp.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseUnaryOp.h @@ -11,7 +11,7 @@ #ifndef EIGEN_CWISE_UNARY_OP_H #define EIGEN_CWISE_UNARY_OP_H -namespace Eigen { +namespace StormEigen { /** \class CwiseUnaryOp * \ingroup Core_Module @@ -98,6 +98,6 @@ public: typedef typename internal::generic_xpr_base >::type Base; }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_CWISE_UNARY_OP_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseUnaryView.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseUnaryView.h index 72244751e..89223019d 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseUnaryView.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/CwiseUnaryView.h @@ -10,7 +10,7 @@ #ifndef EIGEN_CWISE_UNARY_VIEW_H #define EIGEN_CWISE_UNARY_VIEW_H -namespace Eigen { +namespace StormEigen { /** \class CwiseUnaryView * \ingroup Core_Module @@ -123,6 +123,6 @@ class CwiseUnaryViewImpl } }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_CWISE_UNARY_VIEW_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DenseBase.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DenseBase.h index fd4ef025d..7b027ecde 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DenseBase.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DenseBase.h @@ -11,7 +11,7 @@ #ifndef EIGEN_DENSEBASE_H #define EIGEN_DENSEBASE_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -52,15 +52,15 @@ template class DenseBase /** Inner iterator type to iterate over the coefficients of a row or column. * \sa class InnerIterator */ - typedef Eigen::InnerIterator InnerIterator; + typedef StormEigen::InnerIterator InnerIterator; typedef typename internal::traits::StorageKind StorageKind; /** * \brief The type used to store indices * \details This typedef is relevant for types that store multiple indices such as - * PermutationMatrix or Transpositions, otherwise it defaults to Eigen::Index - * \sa \ref TopicPreprocessorDirectives, Eigen::Index, SparseMatrixBase. + * PermutationMatrix or Transpositions, otherwise it defaults to StormEigen::Index + * \sa \ref TopicPreprocessorDirectives, StormEigen::Index, SparseMatrixBase. */ typedef typename internal::traits::StorageIndex StorageIndex; @@ -560,7 +560,7 @@ template class DenseBase } EIGEN_DEVICE_FUNC void reverseInPlace(); -#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::DenseBase +#define EIGEN_CURRENT_STORAGE_BASE_CLASS StormEigen::DenseBase # include "../plugins/BlockMethods.h" # ifdef EIGEN_DENSEBASE_PLUGIN # include EIGEN_DENSEBASE_PLUGIN @@ -596,6 +596,6 @@ template class DenseBase template EIGEN_DEVICE_FUNC explicit DenseBase(const DenseBase&); }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_DENSEBASE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DenseCoeffsBase.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DenseCoeffsBase.h index 820a90e6f..95906d33f 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DenseCoeffsBase.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DenseCoeffsBase.h @@ -10,7 +10,7 @@ #ifndef EIGEN_DENSECOEFFSBASE_H #define EIGEN_DENSECOEFFSBASE_H -namespace Eigen { +namespace StormEigen { namespace internal { template struct add_const_on_value_type_if_arithmetic @@ -652,6 +652,6 @@ struct outer_stride_at_compile_time } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_DENSECOEFFSBASE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DenseStorage.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DenseStorage.h index 340484610..a1b15b1f9 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DenseStorage.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DenseStorage.h @@ -18,7 +18,7 @@ #define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN #endif -namespace Eigen { +namespace StormEigen { namespace internal { @@ -558,6 +558,6 @@ template class DenseStorage::diagonal() const return typename ConstDiagonalIndexReturnType::Type(derived()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_DIAGONAL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DiagonalMatrix.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DiagonalMatrix.h index 5a9e3abd4..4c2584904 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DiagonalMatrix.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DiagonalMatrix.h @@ -11,7 +11,7 @@ #ifndef EIGEN_DIAGONALMATRIX_H #define EIGEN_DIAGONALMATRIX_H -namespace Eigen { +namespace StormEigen { #ifndef EIGEN_PARSED_BY_DOXYGEN template @@ -335,6 +335,6 @@ struct Assignment } // namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_DIAGONALMATRIX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DiagonalProduct.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DiagonalProduct.h index d372b938f..d31914617 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DiagonalProduct.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/DiagonalProduct.h @@ -11,7 +11,7 @@ #ifndef EIGEN_DIAGONALPRODUCT_H #define EIGEN_DIAGONALPRODUCT_H -namespace Eigen { +namespace StormEigen { /** \returns the diagonal matrix product of \c *this by the diagonal matrix \a diagonal. */ @@ -23,6 +23,6 @@ MatrixBase::operator*(const DiagonalBase &a_diagonal) return Product(derived(),a_diagonal.derived()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_DIAGONALPRODUCT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Dot.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Dot.h index 003450f1a..1a6b68f4f 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Dot.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Dot.h @@ -10,7 +10,7 @@ #ifndef EIGEN_DOT_H #define EIGEN_DOT_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -179,7 +179,7 @@ struct lpNorm_selector } // end namespace internal /** \returns the \b coefficient-wise \f$ \ell^p \f$ norm of \c *this, that is, returns the p-th root of the sum of the p-th powers of the absolute values - * of the coefficients of \c *this. If \a p is the special value \a Eigen::Infinity, this function returns the \f$ \ell^\infty \f$ + * of the coefficients of \c *this. If \a p is the special value \a StormEigen::Infinity, this function returns the \f$ \ell^\infty \f$ * norm, that is the maximum of the absolute values of the coefficients of \c *this. * * \note For matrices, this function does not compute the operator-norm. That is, if \c *this is a matrix, then its coefficients are interpreted as a 1D vector. Nonetheless, you can easily compute the 1-norm and \f$\infty\f$-norm matrix operator norms using \link TutorialReductionsVisitorsBroadcastingReductionsNorm partial reductions \endlink. @@ -238,6 +238,6 @@ bool MatrixBase::isUnitary(const RealScalar& prec) const return true; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_DOT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/EigenBase.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/EigenBase.h index 79dabda37..63593d614 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/EigenBase.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/EigenBase.h @@ -11,7 +11,7 @@ #ifndef EIGEN_EIGENBASE_H #define EIGEN_EIGENBASE_H -namespace Eigen { +namespace StormEigen { /** \class EigenBase * @@ -31,10 +31,10 @@ template struct EigenBase /** \brief The interface type of indices * \details To change this, \c \#define the preprocessor symbol \c EIGEN_DEFAULT_DENSE_INDEX_TYPE. - * \deprecated Since Eigen 3.3, its usage is deprecated. Use Eigen::Index instead. + * \deprecated Since Eigen 3.3, its usage is deprecated. Use StormEigen::Index instead. * \sa StorageIndex, \ref TopicPreprocessorDirectives. */ - typedef Eigen::Index Index; + typedef StormEigen::Index Index; // FIXME is it needed? typedef typename internal::traits::StorageKind StorageKind; @@ -150,6 +150,6 @@ Derived& DenseBase::operator-=(const EigenBase &other) return derived(); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_EIGENBASE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ForceAlignedAccess.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ForceAlignedAccess.h index 7b08b45e6..1ea0713a2 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ForceAlignedAccess.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ForceAlignedAccess.h @@ -10,7 +10,7 @@ #ifndef EIGEN_FORCEALIGNEDACCESS_H #define EIGEN_FORCEALIGNEDACCESS_H -namespace Eigen { +namespace StormEigen { /** \class ForceAlignedAccess * \ingroup Core_Module @@ -141,6 +141,6 @@ MatrixBase::forceAlignedAccessIf() return derived(); // FIXME This should not work but apparently is never used } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_FORCEALIGNEDACCESS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Fuzzy.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Fuzzy.h index 3e403a09d..bb86c281c 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Fuzzy.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Fuzzy.h @@ -11,7 +11,7 @@ #ifndef EIGEN_FUZZY_H #define EIGEN_FUZZY_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -150,6 +150,6 @@ bool DenseBase::isMuchSmallerThan( return internal::isMuchSmallerThan_object_selector::run(derived(), other.derived(), prec); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_FUZZY_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/GeneralProduct.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/GeneralProduct.h index fe8204ac3..c25668b86 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/GeneralProduct.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/GeneralProduct.h @@ -11,7 +11,7 @@ #ifndef EIGEN_GENERAL_PRODUCT_H #define EIGEN_GENERAL_PRODUCT_H -namespace Eigen { +namespace StormEigen { enum { Large = 2, @@ -452,6 +452,6 @@ MatrixBase::lazyProduct(const MatrixBase &other) const return Product(derived(), other.derived()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_PRODUCT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/GenericPacketMath.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/GenericPacketMath.h index 8ad51bad5..df8da975c 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/GenericPacketMath.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/GenericPacketMath.h @@ -11,7 +11,7 @@ #ifndef EIGEN_GENERIC_PACKET_MATH_H #define EIGEN_GENERIC_PACKET_MATH_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -572,6 +572,6 @@ pblend(const Selector::size>& ifPacket, const Packet& th } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_GENERIC_PACKET_MATH_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/GlobalFunctions.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/GlobalFunctions.h index 62fec7008..7fa11a5cd 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/GlobalFunctions.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/GlobalFunctions.h @@ -13,9 +13,9 @@ #define EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(NAME,FUNCTOR) \ template \ - inline const Eigen::CwiseUnaryOp, const Derived> \ - (NAME)(const Eigen::ArrayBase& x) { \ - return Eigen::CwiseUnaryOp, const Derived>(x.derived()); \ + inline const StormEigen::CwiseUnaryOp, const Derived> \ + (NAME)(const StormEigen::ArrayBase& x) { \ + return StormEigen::CwiseUnaryOp, const Derived>(x.derived()); \ } #define EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(NAME,FUNCTOR) \ @@ -23,18 +23,18 @@ template \ struct NAME##_retval > \ { \ - typedef const Eigen::CwiseUnaryOp, const Derived> type; \ + typedef const StormEigen::CwiseUnaryOp, const Derived> type; \ }; \ template \ struct NAME##_impl > \ { \ - static inline typename NAME##_retval >::type run(const Eigen::ArrayBase& x) \ + static inline typename NAME##_retval >::type run(const StormEigen::ArrayBase& x) \ { \ return typename NAME##_retval >::type(x.derived()); \ } \ }; -namespace Eigen +namespace StormEigen { EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(real,scalar_real_op) EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(imag,scalar_imag_op) @@ -70,8 +70,8 @@ namespace Eigen EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sign,scalar_sign_op) template - inline const Eigen::CwiseUnaryOp, const Derived> - pow(const Eigen::ArrayBase& x, const typename Derived::Scalar& exponent) { + inline const StormEigen::CwiseUnaryOp, const Derived> + pow(const StormEigen::ArrayBase& x, const typename Derived::Scalar& exponent) { return x.derived().pow(exponent); } @@ -85,10 +85,10 @@ namespace Eigen * \sa ArrayBase::pow() */ template - inline const Eigen::CwiseBinaryOp, const Derived, const ExponentDerived> - pow(const Eigen::ArrayBase& x, const Eigen::ArrayBase& exponents) + inline const StormEigen::CwiseBinaryOp, const Derived, const ExponentDerived> + pow(const StormEigen::ArrayBase& x, const StormEigen::ArrayBase& exponents) { - return Eigen::CwiseBinaryOp, const Derived, const ExponentDerived>( + return StormEigen::CwiseBinaryOp, const Derived, const ExponentDerived>( x.derived(), exponents.derived() ); @@ -105,11 +105,11 @@ namespace Eigen * \sa ArrayBase::pow() */ template - inline const Eigen::CwiseBinaryOp, const typename Derived::ConstantReturnType, const Derived> - pow(const typename Derived::Scalar& x, const Eigen::ArrayBase& exponents) + inline const StormEigen::CwiseBinaryOp, const typename Derived::ConstantReturnType, const Derived> + pow(const typename Derived::Scalar& x, const StormEigen::ArrayBase& exponents) { typename Derived::ConstantReturnType constant_x(exponents.rows(), exponents.cols(), x); - return Eigen::CwiseBinaryOp, const typename Derived::ConstantReturnType, const Derived>( + return StormEigen::CwiseBinaryOp, const typename Derived::ConstantReturnType, const Derived>( constant_x, exponents.derived() ); @@ -119,12 +119,12 @@ namespace Eigen * \brief Component-wise division of a scalar by array elements. **/ template - inline const Eigen::CwiseUnaryOp, const Derived> - operator/(const typename Derived::Scalar& s, const Eigen::ArrayBase& a) + inline const StormEigen::CwiseUnaryOp, const Derived> + operator/(const typename Derived::Scalar& s, const StormEigen::ArrayBase& a) { - return Eigen::CwiseUnaryOp, const Derived>( + return StormEigen::CwiseUnaryOp, const Derived>( a.derived(), - Eigen::internal::scalar_inverse_mult_op(s) + StormEigen::internal::scalar_inverse_mult_op(s) ); } diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/IO.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/IO.h index 9ae37bb5a..5f63d2edb 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/IO.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/IO.h @@ -11,7 +11,7 @@ #ifndef EIGEN_IO_H #define EIGEN_IO_H -namespace Eigen { +namespace StormEigen { enum { DontAlignCols = 1 }; enum { StreamPrecision = -1, @@ -236,7 +236,7 @@ std::ostream & print_matrix(std::ostream & s, const Derived& _m, const IOFormat& * If you wish to print the matrix with a format different than the default, use DenseBase::format(). * * It is also possible to change the default format by defining EIGEN_DEFAULT_IO_FORMAT before including Eigen headers. - * If not defined, this will automatically be defined to Eigen::IOFormat(), that is the Eigen::IOFormat with default parameters. + * If not defined, this will automatically be defined to StormEigen::IOFormat(), that is the StormEigen::IOFormat with default parameters. * * \sa DenseBase::format() */ @@ -248,6 +248,6 @@ std::ostream & operator << return internal::print_matrix(s, m.eval(), EIGEN_DEFAULT_IO_FORMAT); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_IO_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Inverse.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Inverse.h index f3ec84990..1bb0d95f5 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Inverse.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Inverse.h @@ -10,7 +10,7 @@ #ifndef EIGEN_INVERSE_H #define EIGEN_INVERSE_H -namespace Eigen { +namespace StormEigen { template class InverseImpl; @@ -112,6 +112,6 @@ protected: } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_INVERSE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Map.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Map.h index 3a8375da9..d090dd062 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Map.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Map.h @@ -11,7 +11,7 @@ #ifndef EIGEN_MAP_H #define EIGEN_MAP_H -namespace Eigen { +namespace StormEigen { /** \class Map * \ingroup Core_Module @@ -160,6 +160,6 @@ template class Ma }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_MAP_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/MapBase.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/MapBase.h index 75a80daaa..f45979e65 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/MapBase.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/MapBase.h @@ -15,7 +15,7 @@ EIGEN_STATIC_ASSERT((int(internal::evaluator::Flags) & LinearAccessBit) || Derived::IsVectorAtCompileTime, \ YOU_ARE_TRYING_TO_USE_AN_INDEX_BASED_ACCESSOR_ON_AN_EXPRESSION_THAT_DOES_NOT_SUPPORT_THAT) -namespace Eigen { +namespace StormEigen { /** \class MapBase * \ingroup Core_Module @@ -256,6 +256,6 @@ template class MapBase #undef EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_MAPBASE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/MathFunctions.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/MathFunctions.h index 48cf565fb..f94c41583 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/MathFunctions.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/MathFunctions.h @@ -13,7 +13,7 @@ // source: http://www.geom.uiuc.edu/~huberty/math5337/groupe/digits.html #define EIGEN_PI 3.141592653589793238462643383279502884197169399375105820974944592307816406 -namespace Eigen { +namespace StormEigen { // On WINCE, std::abs is defined for int only, so let's defined our own overloads: // This issue has been confirmed with MSVC 2008 only, but the issue might exist for more recent versions too. @@ -63,8 +63,8 @@ struct global_math_functions_filtering_base typedef typename T::Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl type; }; -#define EIGEN_MATHFUNC_IMPL(func, scalar) Eigen::internal::func##_impl::type> -#define EIGEN_MATHFUNC_RETVAL(func, scalar) typename Eigen::internal::func##_retval::type>::type +#define EIGEN_MATHFUNC_IMPL(func, scalar) StormEigen::internal::func##_impl::type> +#define EIGEN_MATHFUNC_RETVAL(func, scalar) typename StormEigen::internal::func##_retval::type>::type /**************************************************************************** * Implementation of real * @@ -1122,6 +1122,6 @@ template<> struct scalar_fuzzy_impl } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_MATHFUNCTIONS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Matrix.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Matrix.h index ce1b70d23..3c6e924d9 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Matrix.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Matrix.h @@ -11,7 +11,7 @@ #ifndef EIGEN_MATRIX_H #define EIGEN_MATRIX_H -namespace Eigen { +namespace StormEigen { /** \class Matrix * \ingroup Core_Module @@ -54,13 +54,13 @@ namespace Eigen { * You can access elements of vectors and matrices using normal subscripting: * * \code - * Eigen::VectorXd v(10); + * StormEigen::VectorXd v(10); * v[0] = 0.1; * v[1] = 0.2; * v(0) = 0.3; * v(1) = 0.4; * - * Eigen::MatrixXi m(10, 10); + * StormEigen::MatrixXi m(10, 10); * m(0, 1) = 1; * m(0, 2) = 2; * m(0, 3) = 3; @@ -105,7 +105,7 @@ namespace Eigen { * \code Matrix \endcode\code * struct { * T *data; // with (size_t(data)%EIGEN_MAX_ALIGN_BYTES)==0 - * Eigen::Index rows, cols; + * StormEigen::Index rows, cols; * }; * \endcode * \code @@ -113,7 +113,7 @@ namespace Eigen { * Matrix \endcode\code * struct { * T *data; // with (size_t(data)%EIGEN_MAX_ALIGN_BYTES)==0 - * Eigen::Index size; + * StormEigen::Index size; * }; * \endcode * \code Matrix \endcode\code @@ -124,7 +124,7 @@ namespace Eigen { * \code Matrix \endcode\code * struct { * T data[MaxRows*MaxCols]; // with (size_t(data)%A(MaxRows*MaxCols*sizeof(T)))==0 - * Eigen::Index rows, cols; + * StormEigen::Index rows, cols; * }; * \endcode * @@ -155,7 +155,7 @@ private: public: typedef _Scalar Scalar; typedef Dense StorageKind; - typedef Eigen::Index StorageIndex; + typedef StormEigen::Index StorageIndex; typedef MatrixXpr XprKind; enum { RowsAtCompileTime = _Rows, @@ -456,6 +456,6 @@ EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex, cd) #undef EIGEN_MAKE_TYPEDEFS #undef EIGEN_MAKE_FIXED_TYPEDEFS -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_MATRIX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/MatrixBase.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/MatrixBase.h index 9d612c852..010d95ca5 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/MatrixBase.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/MatrixBase.h @@ -11,7 +11,7 @@ #ifndef EIGEN_MATRIXBASE_H #define EIGEN_MATRIXBASE_H -namespace Eigen { +namespace StormEigen { /** \class MatrixBase * \ingroup Core_Module @@ -34,7 +34,7 @@ namespace Eigen { * * \code template - void printFirstRow(const Eigen::MatrixBase& x) + void printFirstRow(const StormEigen::MatrixBase& x) { cout << x.row(0) << endl; } @@ -122,7 +122,7 @@ template class MatrixBase internal::traits::ColsAtCompileTime> BasisReturnType; #endif // not EIGEN_PARSED_BY_DOXYGEN -#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::MatrixBase +#define EIGEN_CURRENT_STORAGE_BASE_CLASS StormEigen::MatrixBase # include "../plugins/CommonCwiseUnaryOps.h" # include "../plugins/CommonCwiseBinaryOps.h" # include "../plugins/MatrixCwiseUnaryOps.h" @@ -303,7 +303,7 @@ template class MatrixBase inline bool operator!=(const MatrixBase& other) const { return cwiseNotEqual(other).any(); } - NoAlias noalias(); + NoAlias noalias(); // TODO forceAlignedAccess is temporarily disabled // Need to find a nicer workaround. @@ -319,10 +319,10 @@ template class MatrixBase EIGEN_DEVICE_FUNC MatrixBase& matrix() { return *this; } EIGEN_DEVICE_FUNC const MatrixBase& matrix() const { return *this; } - /** \returns an \link Eigen::ArrayBase Array \endlink expression of this matrix + /** \returns an \link StormEigen::ArrayBase Array \endlink expression of this matrix * \sa ArrayBase::matrix() */ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ArrayWrapper array() { return ArrayWrapper(derived()); } - /** \returns a const \link Eigen::ArrayBase Array \endlink expression of this matrix + /** \returns a const \link StormEigen::ArrayBase Array \endlink expression of this matrix * \sa ArrayBase::matrix() */ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArrayWrapper array() const { return ArrayWrapper(derived()); } @@ -522,6 +522,6 @@ inline void MatrixBase::applyOnTheLeft(const EigenBase &o other.derived().applyThisOnTheLeft(derived()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_MATRIXBASE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/NestByValue.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/NestByValue.h index 9aeaf8d18..98a15cf51 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/NestByValue.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/NestByValue.h @@ -11,7 +11,7 @@ #ifndef EIGEN_NESTBYVALUE_H #define EIGEN_NESTBYVALUE_H -namespace Eigen { +namespace StormEigen { /** \class NestByValue * \ingroup Core_Module @@ -106,6 +106,6 @@ DenseBase::nestByValue() const return NestByValue(derived()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_NESTBYVALUE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/NoAlias.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/NoAlias.h index 0ade75255..30a70e1ae 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/NoAlias.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/NoAlias.h @@ -10,7 +10,7 @@ #ifndef EIGEN_NOALIAS_H #define EIGEN_NOALIAS_H -namespace Eigen { +namespace StormEigen { /** \class NoAlias * \ingroup Core_Module @@ -100,9 +100,9 @@ class NoAlias template NoAlias MatrixBase::noalias() { - return NoAlias(derived()); + return NoAlias(derived()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_NOALIAS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/NumTraits.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/NumTraits.h index 1d85dec72..7f475b306 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/NumTraits.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/NumTraits.h @@ -10,7 +10,7 @@ #ifndef EIGEN_NUMTRAITS_H #define EIGEN_NUMTRAITS_H -namespace Eigen { +namespace StormEigen { /** \class NumTraits * \ingroup Core_Module @@ -166,6 +166,6 @@ struct NumTraits > static inline RealScalar dummy_precision() { return NumTraits::dummy_precision(); } }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_NUMTRAITS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/PermutationMatrix.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/PermutationMatrix.h index 90e1df233..56981c17f 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/PermutationMatrix.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/PermutationMatrix.h @@ -11,7 +11,7 @@ #ifndef EIGEN_PERMUTATIONMATRIX_H #define EIGEN_PERMUTATIONMATRIX_H -namespace Eigen { +namespace StormEigen { /** \class PermutationBase * \ingroup Core_Module @@ -631,6 +631,6 @@ template<> struct AssignmentKind { typedef EigenBas } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_PERMUTATIONMATRIX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/PlainObjectBase.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/PlainObjectBase.h index 1225e85b4..ec42f2078 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/PlainObjectBase.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/PlainObjectBase.h @@ -22,7 +22,7 @@ # define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED #endif -namespace Eigen { +namespace StormEigen { namespace internal { @@ -111,22 +111,22 @@ class PlainObjectBase : public internal::dense_xpr_base::type using Base::IsVectorAtCompileTime; using Base::Flags; - template friend class Eigen::Map; - friend class Eigen::Map; - typedef Eigen::Map MapType; - friend class Eigen::Map; - typedef const Eigen::Map ConstMapType; + template friend class StormEigen::Map; + friend class StormEigen::Map; + typedef StormEigen::Map MapType; + friend class StormEigen::Map; + typedef const StormEigen::Map ConstMapType; #if EIGEN_MAX_ALIGN_BYTES>0 // for EIGEN_MAX_ALIGN_BYTES==0, AlignedMax==Unaligned, and many compilers generate warnings for friend-ing a class twice. - friend class Eigen::Map; - friend class Eigen::Map; + friend class StormEigen::Map; + friend class StormEigen::Map; #endif - typedef Eigen::Map AlignedMapType; - typedef const Eigen::Map ConstAlignedMapType; - template struct StridedMapType { typedef Eigen::Map type; }; - template struct StridedConstMapType { typedef Eigen::Map type; }; - template struct StridedAlignedMapType { typedef Eigen::Map type; }; - template struct StridedConstAlignedMapType { typedef Eigen::Map type; }; + typedef StormEigen::Map AlignedMapType; + typedef const StormEigen::Map ConstAlignedMapType; + template struct StridedMapType { typedef StormEigen::Map type; }; + template struct StridedConstMapType { typedef StormEigen::Map type; }; + template struct StridedAlignedMapType { typedef StormEigen::Map type; }; + template struct StridedConstAlignedMapType { typedef StormEigen::Map type; }; protected: DenseStorage m_storage; @@ -989,6 +989,6 @@ struct matrix_swap_impl } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_DENSESTORAGEBASE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Product.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Product.h index fdd2fed3f..fb50926ab 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Product.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Product.h @@ -10,7 +10,7 @@ #ifndef EIGEN_PRODUCT_H #define EIGEN_PRODUCT_H -namespace Eigen { +namespace StormEigen { template class ProductImpl; @@ -217,6 +217,6 @@ class ProductImpl }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_PRODUCT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ProductEvaluators.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ProductEvaluators.h index 794038a2a..e38804644 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ProductEvaluators.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ProductEvaluators.h @@ -13,7 +13,7 @@ #ifndef EIGEN_PRODUCTEVALUATORS_H #define EIGEN_PRODUCTEVALUATORS_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -1056,6 +1056,6 @@ struct generic_product_impl, MatrixShape, TranspositionsShap } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_PRODUCT_EVALUATORS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Random.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Random.h index 02038e9e3..b9c380723 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Random.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Random.h @@ -10,7 +10,7 @@ #ifndef EIGEN_RANDOM_H #define EIGEN_RANDOM_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -178,6 +178,6 @@ PlainObjectBase::setRandom(Index rows, Index cols) return setRandom(); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_RANDOM_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Redux.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Redux.h index d170cae29..3d3881eff 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Redux.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Redux.h @@ -11,7 +11,7 @@ #ifndef EIGEN_REDUX_H #define EIGEN_REDUX_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -423,7 +423,7 @@ template EIGEN_STRONG_INLINE typename internal::traits::Scalar DenseBase::minCoeff() const { - return derived().redux(Eigen::internal::scalar_min_op()); + return derived().redux(StormEigen::internal::scalar_min_op()); } /** \returns the maximum of all coefficients of \c *this. @@ -433,7 +433,7 @@ template EIGEN_STRONG_INLINE typename internal::traits::Scalar DenseBase::maxCoeff() const { - return derived().redux(Eigen::internal::scalar_max_op()); + return derived().redux(StormEigen::internal::scalar_max_op()); } /** \returns the sum of all coefficients of *this @@ -446,7 +446,7 @@ DenseBase::sum() const { if(SizeAtCompileTime==0 || (SizeAtCompileTime==Dynamic && size()==0)) return Scalar(0); - return derived().redux(Eigen::internal::scalar_sum_op()); + return derived().redux(StormEigen::internal::scalar_sum_op()); } /** \returns the mean of all coefficients of *this @@ -457,7 +457,7 @@ template EIGEN_STRONG_INLINE typename internal::traits::Scalar DenseBase::mean() const { - return Scalar(derived().redux(Eigen::internal::scalar_sum_op())) / Scalar(this->size()); + return Scalar(derived().redux(StormEigen::internal::scalar_sum_op())) / Scalar(this->size()); } /** \returns the product of all coefficients of *this @@ -473,7 +473,7 @@ DenseBase::prod() const { if(SizeAtCompileTime==0 || (SizeAtCompileTime==Dynamic && size()==0)) return Scalar(1); - return derived().redux(Eigen::internal::scalar_product_op()); + return derived().redux(StormEigen::internal::scalar_product_op()); } /** \returns the trace of \c *this, i.e. the sum of the coefficients on the main diagonal. @@ -489,6 +489,6 @@ MatrixBase::trace() const return derived().diagonal().sum(); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_REDUX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Ref.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Ref.h index 61de5ed17..951e23d62 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Ref.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Ref.h @@ -10,7 +10,7 @@ #ifndef EIGEN_REF_H #define EIGEN_REF_H -namespace Eigen { +namespace StormEigen { /** \class Ref * \ingroup Core_Module @@ -271,6 +271,6 @@ template class Ref< TPlainObjectType m_object; }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_REF_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Replicate.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Replicate.h index bec598310..7fb5bb37a 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Replicate.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Replicate.h @@ -10,7 +10,7 @@ #ifndef EIGEN_REPLICATE_H #define EIGEN_REPLICATE_H -namespace Eigen { +namespace StormEigen { /** * \class Replicate @@ -136,6 +136,6 @@ VectorwiseOp::replicate(Index factor) const (_expression(),Direction==Vertical?factor:1,Direction==Horizontal?factor:1); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_REPLICATE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ReturnByValue.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ReturnByValue.h index 7feb6e01c..ff87ecde8 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ReturnByValue.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/ReturnByValue.h @@ -11,7 +11,7 @@ #ifndef EIGEN_RETURNBYVALUE_H #define EIGEN_RETURNBYVALUE_H -namespace Eigen { +namespace StormEigen { /** \class ReturnByValue * \ingroup Core_Module @@ -113,6 +113,6 @@ protected: } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_RETURNBYVALUE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Reverse.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Reverse.h index d7c380c78..c5db38ae9 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Reverse.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Reverse.h @@ -12,7 +12,7 @@ #ifndef EIGEN_REVERSE_H #define EIGEN_REVERSE_H -namespace Eigen { +namespace StormEigen { /** \class Reverse * \ingroup Core_Module @@ -206,6 +206,6 @@ void VectorwiseOp::reverseInPlace() internal::vectorwise_reverse_inplace_impl::run(_expression().const_cast_derived()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_REVERSE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Select.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Select.h index 79eec1b5b..4d7efd27d 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Select.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Select.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SELECT_H #define EIGEN_SELECT_H -namespace Eigen { +namespace StormEigen { /** \class Select * \ingroup Core_Module @@ -157,6 +157,6 @@ DenseBase::select(const typename ElseDerived::Scalar& thenScalar, derived(), ElseDerived::Constant(rows(),cols(),thenScalar), elseMatrix.derived()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SELECT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SelfAdjointView.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SelfAdjointView.h index 87e87ab3a..ec08e236e 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SelfAdjointView.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SelfAdjointView.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SELFADJOINTMATRIX_H #define EIGEN_SELFADJOINTMATRIX_H -namespace Eigen { +namespace StormEigen { /** \class SelfAdjointView * \ingroup Core_Module @@ -269,6 +269,6 @@ MatrixBase::selfadjointView() return typename SelfAdjointViewReturnType::Type(derived()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SELFADJOINTMATRIX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SelfCwiseBinaryOp.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SelfCwiseBinaryOp.h index 38185d9d7..8047d6ab2 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SelfCwiseBinaryOp.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SelfCwiseBinaryOp.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SELFCWISEBINARYOP_H #define EIGEN_SELFCWISEBINARYOP_H -namespace Eigen { +namespace StormEigen { template inline Derived& DenseBase::operator*=(const Scalar& other) @@ -44,6 +44,6 @@ inline Derived& DenseBase::operator/=(const Scalar& other) return derived(); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SELFCWISEBINARYOP_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Solve.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Solve.h index ba2ee53b8..964b9a0af 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Solve.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Solve.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SOLVE_H #define EIGEN_SOLVE_H -namespace Eigen { +namespace StormEigen { template class SolveImpl; @@ -168,6 +168,6 @@ struct Assignment struct triangular_solv } // namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SOLVETRIANGULAR_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SolverBase.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SolverBase.h index 8a4adc229..fabc54c54 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SolverBase.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SolverBase.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SOLVERBASE_H #define EIGEN_SOLVERBASE_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -125,6 +125,6 @@ struct generic_xpr_base } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SOLVERBASE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SpecialFunctions.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SpecialFunctions.h index d43cf23a1..4c42c9f38 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SpecialFunctions.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/SpecialFunctions.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPECIAL_FUNCTIONS_H #define EIGEN_SPECIAL_FUNCTIONS_H -namespace Eigen { +namespace StormEigen { namespace internal { /**************************************************************************** @@ -155,6 +155,6 @@ inline EIGEN_MATHFUNC_RETVAL(erfc, Scalar) erfc(const Scalar& x) } // end namespace numext -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPECIAL_FUNCTIONS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/StableNorm.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/StableNorm.h index 7fe39808b..332724280 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/StableNorm.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/StableNorm.h @@ -10,7 +10,7 @@ #ifndef EIGEN_STABLENORM_H #define EIGEN_STABLENORM_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -214,6 +214,6 @@ MatrixBase::hypotNorm() const return this->cwiseAbs().redux(internal::scalar_hypot_op()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_STABLENORM_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Stride.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Stride.h index 9a2f4f1eb..e4cc23212 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Stride.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Stride.h @@ -10,7 +10,7 @@ #ifndef EIGEN_STRIDE_H #define EIGEN_STRIDE_H -namespace Eigen { +namespace StormEigen { /** \class Stride * \ingroup Core_Module @@ -44,7 +44,7 @@ template class Stride { public: - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 enum { InnerStrideAtCompileTime = _InnerStrideAtCompileTime, OuterStrideAtCompileTime = _OuterStrideAtCompileTime @@ -106,6 +106,6 @@ class OuterStride : public Stride EIGEN_DEVICE_FUNC OuterStride(Index v) : Base(v,0) {} // FIXME making this explicit could break valid code }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_STRIDE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Swap.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Swap.h index d70200918..17448a98e 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Swap.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Swap.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SWAP_H #define EIGEN_SWAP_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -62,6 +62,6 @@ public: } // namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SWAP_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Transpose.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Transpose.h index 5b66eb5e1..5c7afa75b 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Transpose.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Transpose.h @@ -11,7 +11,7 @@ #ifndef EIGEN_TRANSPOSE_H #define EIGEN_TRANSPOSE_H -namespace Eigen { +namespace StormEigen { /** \class Transpose * \ingroup Core_Module @@ -392,6 +392,6 @@ void check_for_aliasing(const Dst &dst, const Src &src) #endif // EIGEN_NO_DEBUG -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_TRANSPOSE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Transpositions.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Transpositions.h index 3b1c1815d..2f90011cb 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Transpositions.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Transpositions.h @@ -10,7 +10,7 @@ #ifndef EIGEN_TRANSPOSITIONS_H #define EIGEN_TRANSPOSITIONS_H -namespace Eigen { +namespace StormEigen { /** \class Transpositions * \ingroup Core_Module @@ -50,7 +50,7 @@ class TranspositionsBase typedef typename Traits::IndicesType IndicesType; typedef typename IndicesType::Scalar StorageIndex; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 Derived& derived() { return *static_cast(this); } const Derived& derived() const { return *static_cast(this); } @@ -402,6 +402,6 @@ class Transpose > const TranspositionType& m_transpositions; }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_TRANSPOSITIONS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/TriangularMatrix.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/TriangularMatrix.h index 099a02ec3..647092c3e 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/TriangularMatrix.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/TriangularMatrix.h @@ -11,7 +11,7 @@ #ifndef EIGEN_TRIANGULARMATRIX_H #define EIGEN_TRIANGULARMATRIX_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -977,6 +977,6 @@ struct Assignment, internal::sub_ass } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_TRIANGULARMATRIX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/VectorBlock.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/VectorBlock.h index 216c568c4..f47b50c7a 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/VectorBlock.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/VectorBlock.h @@ -11,7 +11,7 @@ #ifndef EIGEN_VECTORBLOCK_H #define EIGEN_VECTORBLOCK_H -namespace Eigen { +namespace StormEigen { /** \class VectorBlock * \ingroup Core_Module @@ -92,6 +92,6 @@ template class VectorBlock }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_VECTORBLOCK_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/VectorwiseOp.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/VectorwiseOp.h index 483f71909..fc7081d89 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/VectorwiseOp.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/VectorwiseOp.h @@ -11,7 +11,7 @@ #ifndef EIGEN_PARTIAL_REDUX_H #define EIGEN_PARTIAL_REDUX_H -namespace Eigen { +namespace StormEigen { /** \class PartialReduxExpr * \ingroup Core_Module @@ -159,7 +159,7 @@ template class VectorwiseOp typedef typename ExpressionType::Scalar Scalar; typedef typename ExpressionType::RealScalar RealScalar; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 typedef typename internal::ref_selector::non_const_type ExpressionTypeNested; typedef typename internal::remove_all::type ExpressionTypeNestedCleaned; @@ -679,6 +679,6 @@ DenseBase::rowwise() return RowwiseReturnType(derived()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_PARTIAL_REDUX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Visitor.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Visitor.h index 7aac0b6e1..dd39ad5a6 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Visitor.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/Visitor.h @@ -10,7 +10,7 @@ #ifndef EIGEN_VISITOR_H #define EIGEN_VISITOR_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -266,6 +266,6 @@ DenseBase::maxCoeff(IndexType* index) const return maxVisitor.res; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_VISITOR_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/Complex.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/Complex.h index b16e0ddd4..dbf537bdb 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/Complex.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/Complex.h @@ -10,7 +10,7 @@ #ifndef EIGEN_COMPLEX_AVX_H #define EIGEN_COMPLEX_AVX_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -210,7 +210,7 @@ template<> struct conj_helper { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Packet4cf pmul(const Packet8f& x, const Packet4cf& y) const - { return Packet4cf(Eigen::internal::pmul(x, y.v)); } + { return Packet4cf(StormEigen::internal::pmul(x, y.v)); } }; template<> struct conj_helper @@ -219,7 +219,7 @@ template<> struct conj_helper { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Packet4cf pmul(const Packet4cf& x, const Packet8f& y) const - { return Packet4cf(Eigen::internal::pmul(x.v, y)); } + { return Packet4cf(StormEigen::internal::pmul(x.v, y)); } }; template<> EIGEN_STRONG_INLINE Packet4cf pdiv(const Packet4cf& a, const Packet4cf& b) @@ -406,7 +406,7 @@ template<> struct conj_helper { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Packet2cd pmul(const Packet4d& x, const Packet2cd& y) const - { return Packet2cd(Eigen::internal::pmul(x, y.v)); } + { return Packet2cd(StormEigen::internal::pmul(x, y.v)); } }; template<> struct conj_helper @@ -415,7 +415,7 @@ template<> struct conj_helper { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Packet2cd pmul(const Packet2cd& x, const Packet4d& y) const - { return Packet2cd(Eigen::internal::pmul(x.v, y)); } + { return Packet2cd(StormEigen::internal::pmul(x.v, y)); } }; template<> EIGEN_STRONG_INLINE Packet2cd pdiv(const Packet2cd& a, const Packet2cd& b) @@ -458,6 +458,6 @@ ptranspose(PacketBlock& kernel) { } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_COMPLEX_AVX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/MathFunctions.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/MathFunctions.h index c4bd6bd53..232602ab7 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/MathFunctions.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/MathFunctions.h @@ -19,7 +19,7 @@ * Julien Pommier's sse math library: http://gruntthepeon.free.fr/ssemath/ */ -namespace Eigen { +namespace StormEigen { namespace internal { @@ -436,6 +436,6 @@ Packet4d prsqrt(const Packet4d& x) { } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_MATH_FUNCTIONS_AVX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/PacketMath.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/PacketMath.h index 717ae67c5..abd33dd70 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/PacketMath.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/PacketMath.h @@ -10,7 +10,7 @@ #ifndef EIGEN_PACKET_MATH_AVX_H #define EIGEN_PACKET_MATH_AVX_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -602,6 +602,6 @@ template<> EIGEN_STRONG_INLINE Packet4d pblend(const Selector<4>& ifPacket, cons } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_PACKET_MATH_AVX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/TypeCasting.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/TypeCasting.h index 83bfdc604..b81b2716a 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/TypeCasting.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AVX/TypeCasting.h @@ -10,7 +10,7 @@ #ifndef EIGEN_TYPE_CASTING_AVX_H #define EIGEN_TYPE_CASTING_AVX_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -46,6 +46,6 @@ template<> EIGEN_STRONG_INLINE Packet8f pcast(const Packet8i } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_TYPE_CASTING_AVX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AltiVec/Complex.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AltiVec/Complex.h index 58c296171..6aa5d83d8 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AltiVec/Complex.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AltiVec/Complex.h @@ -10,7 +10,7 @@ #ifndef EIGEN_COMPLEX32_ALTIVEC_H #define EIGEN_COMPLEX32_ALTIVEC_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -425,6 +425,6 @@ EIGEN_STRONG_INLINE void ptranspose(PacketBlock& kernel) #endif // __VSX__ } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_COMPLEX32_ALTIVEC_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AltiVec/MathFunctions.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AltiVec/MathFunctions.h index 9e37e93f8..b82e47918 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AltiVec/MathFunctions.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AltiVec/MathFunctions.h @@ -15,7 +15,7 @@ #ifndef EIGEN_MATH_FUNCTIONS_ALTIVEC_H #define EIGEN_MATH_FUNCTIONS_ALTIVEC_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -285,6 +285,6 @@ Packet2d pexp(const Packet2d& _x) } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_MATH_FUNCTIONS_ALTIVEC_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AltiVec/PacketMath.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AltiVec/PacketMath.h index 0dbbc2e42..f6c21cdf0 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AltiVec/PacketMath.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/AltiVec/PacketMath.h @@ -10,7 +10,7 @@ #ifndef EIGEN_PACKET_MATH_ALTIVEC_H #define EIGEN_PACKET_MATH_ALTIVEC_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -934,6 +934,6 @@ ptranspose(PacketBlock& kernel) { #endif // __VSX__ } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_PACKET_MATH_ALTIVEC_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/CUDA/MathFunctions.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/CUDA/MathFunctions.h index ecd5c444e..0ef0266a9 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/CUDA/MathFunctions.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/CUDA/MathFunctions.h @@ -10,7 +10,7 @@ #ifndef EIGEN_MATH_FUNCTIONS_CUDA_H #define EIGEN_MATH_FUNCTIONS_CUDA_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -107,6 +107,6 @@ double2 perfc(const double2& a) } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_MATH_FUNCTIONS_CUDA_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/CUDA/PacketMath.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/CUDA/PacketMath.h index cb1b547e0..70c1e9225 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/CUDA/PacketMath.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/CUDA/PacketMath.h @@ -10,7 +10,7 @@ #ifndef EIGEN_PACKET_MATH_CUDA_H #define EIGEN_PACKET_MATH_CUDA_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -303,7 +303,7 @@ ptranspose(PacketBlock& kernel) { } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_PACKET_MATH_CUDA_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/NEON/Complex.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/NEON/Complex.h index d2d467936..82631de0f 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/NEON/Complex.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/NEON/Complex.h @@ -10,7 +10,7 @@ #ifndef EIGEN_COMPLEX_NEON_H #define EIGEN_COMPLEX_NEON_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -461,6 +461,6 @@ EIGEN_STRONG_INLINE void ptranspose(PacketBlock& kernel) } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_COMPLEX_NEON_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/NEON/MathFunctions.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/NEON/MathFunctions.h index 6bb05bb92..c7cb29563 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/NEON/MathFunctions.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/NEON/MathFunctions.h @@ -12,7 +12,7 @@ #ifndef EIGEN_MATH_FUNCTIONS_NEON_H #define EIGEN_MATH_FUNCTIONS_NEON_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -86,6 +86,6 @@ Packet4f pexp(const Packet4f& _x) } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_MATH_FUNCTIONS_NEON_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/NEON/PacketMath.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/NEON/PacketMath.h index fc4c0d03a..25e21beb7 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/NEON/PacketMath.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/NEON/PacketMath.h @@ -12,7 +12,7 @@ #ifndef EIGEN_PACKET_MATH_NEON_H #define EIGEN_PACKET_MATH_NEON_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -726,6 +726,6 @@ ptranspose(PacketBlock& kernel) { } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_PACKET_MATH_NEON_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/Complex.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/Complex.h index 4f45ddfbf..fc105d559 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/Complex.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/Complex.h @@ -10,7 +10,7 @@ #ifndef EIGEN_COMPLEX_SSE_H #define EIGEN_COMPLEX_SSE_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -235,7 +235,7 @@ template<> struct conj_helper { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Packet2cf pmul(const Packet4f& x, const Packet2cf& y) const - { return Packet2cf(Eigen::internal::pmul(x, y.v)); } + { return Packet2cf(StormEigen::internal::pmul(x, y.v)); } }; template<> struct conj_helper @@ -244,7 +244,7 @@ template<> struct conj_helper { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& x, const Packet4f& y) const - { return Packet2cf(Eigen::internal::pmul(x.v, y)); } + { return Packet2cf(StormEigen::internal::pmul(x.v, y)); } }; template<> EIGEN_STRONG_INLINE Packet2cf pdiv(const Packet2cf& a, const Packet2cf& b) @@ -436,7 +436,7 @@ template<> struct conj_helper { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Packet1cd pmul(const Packet2d& x, const Packet1cd& y) const - { return Packet1cd(Eigen::internal::pmul(x, y.v)); } + { return Packet1cd(StormEigen::internal::pmul(x, y.v)); } }; template<> struct conj_helper @@ -445,7 +445,7 @@ template<> struct conj_helper { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& x, const Packet2d& y) const - { return Packet1cd(Eigen::internal::pmul(x.v, y)); } + { return Packet1cd(StormEigen::internal::pmul(x.v, y)); } }; template<> EIGEN_STRONG_INLINE Packet1cd pdiv(const Packet1cd& a, const Packet1cd& b) @@ -478,6 +478,6 @@ template<> EIGEN_STRONG_INLINE Packet2cf pblend(const Selector<2>& ifPacket, co } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_COMPLEX_SSE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/MathFunctions.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/MathFunctions.h index 3b8b7303f..bf0dc60d0 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/MathFunctions.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/MathFunctions.h @@ -15,7 +15,7 @@ #ifndef EIGEN_MATH_FUNCTIONS_SSE_H #define EIGEN_MATH_FUNCTIONS_SSE_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -518,6 +518,6 @@ Packet2d prsqrt(const Packet2d& x) { } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_MATH_FUNCTIONS_SSE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/PacketMath.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/PacketMath.h index eb517b871..2105fe324 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/PacketMath.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/PacketMath.h @@ -10,7 +10,7 @@ #ifndef EIGEN_PACKET_MATH_SSE_H #define EIGEN_PACKET_MATH_SSE_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -869,6 +869,6 @@ template<> EIGEN_STRONG_INLINE Packet2d pblend(const Selector<2>& ifPacket, cons } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_PACKET_MATH_SSE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/TypeCasting.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/TypeCasting.h index c84893230..f00203bfa 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/TypeCasting.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/arch/SSE/TypeCasting.h @@ -10,7 +10,7 @@ #ifndef EIGEN_TYPE_CASTING_SSE_H #define EIGEN_TYPE_CASTING_SSE_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -72,6 +72,6 @@ template<> EIGEN_STRONG_INLINE Packet2d pcast(const Packet4f } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_TYPE_CASTING_SSE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/AssignmentFunctors.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/AssignmentFunctors.h index d55ae6096..471c6cd66 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/AssignmentFunctors.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/AssignmentFunctors.h @@ -10,7 +10,7 @@ #ifndef EIGEN_ASSIGNMENT_FUNCTORS_H #define EIGEN_ASSIGNMENT_FUNCTORS_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -161,6 +161,6 @@ struct functor_traits > { } // namespace internal -} // namespace Eigen +} // namespace StormEigen #endif // EIGEN_ASSIGNMENT_FUNCTORS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/BinaryFunctors.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/BinaryFunctors.h index 330f1370c..b865ce237 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/BinaryFunctors.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/BinaryFunctors.h @@ -10,7 +10,7 @@ #ifndef EIGEN_BINARY_FUNCTORS_H #define EIGEN_BINARY_FUNCTORS_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -517,6 +517,6 @@ struct scalar_inverse_mult_op { } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_BINARY_FUNCTORS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/NullaryFunctors.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/NullaryFunctors.h index cd9fbf267..c2c70e5ba 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/NullaryFunctors.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/NullaryFunctors.h @@ -10,7 +10,7 @@ #ifndef EIGEN_NULLARY_FUNCTORS_H #define EIGEN_NULLARY_FUNCTORS_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -145,6 +145,6 @@ template struct functor_has_linear_access > } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_STL_FUNCTORS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/UnaryFunctors.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/UnaryFunctors.h index 6891cfdda..cff01d55e 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/UnaryFunctors.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/functors/UnaryFunctors.h @@ -10,7 +10,7 @@ #ifndef EIGEN_UNARY_FUNCTORS_H #define EIGEN_UNARY_FUNCTORS_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -773,6 +773,6 @@ struct functor_traits > } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_FUNCTORS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralBlockPanelKernel.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralBlockPanelKernel.h index 229e96ceb..2691d8649 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralBlockPanelKernel.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralBlockPanelKernel.h @@ -11,7 +11,7 @@ #define EIGEN_GENERAL_BLOCK_PANEL_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -2234,6 +2234,6 @@ inline void setCpuCacheSizes(std::ptrdiff_t l1, std::ptrdiff_t l2, std::ptrdiff_ internal::manage_caching_sizes(SetAction, &l1, &l2, &l3); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_GENERAL_BLOCK_PANEL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrix.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrix.h index d830dfb96..d7a7ecd1d 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrix.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrix.h @@ -10,7 +10,7 @@ #ifndef EIGEN_GENERAL_MATRIX_MATRIX_H #define EIGEN_GENERAL_MATRIX_MATRIX_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -491,6 +491,6 @@ struct generic_product_impl } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_GENERAL_MATRIX_MATRIX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h index a36eb2fe0..97c313f7d 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h @@ -10,7 +10,7 @@ #ifndef EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_H #define EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_H -namespace Eigen { +namespace StormEigen { template struct selfadjoint_rank1_update; @@ -277,6 +277,6 @@ TriangularView& TriangularViewImpl::_ass return derived(); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h index 3deed068e..471fbef7f 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h @@ -33,7 +33,7 @@ #ifndef EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_MKL_H #define EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_MKL_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -141,6 +141,6 @@ EIGEN_MKL_RANKUPDATE_R(float, float, ssyrk) } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_MKL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h index b6ae729b2..a8179f981 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h @@ -33,7 +33,7 @@ #ifndef EIGEN_GENERAL_MATRIX_MATRIX_MKL_H #define EIGEN_GENERAL_MATRIX_MATRIX_MKL_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -115,6 +115,6 @@ GEMM_SPECIALIZATION(scomplex, cf, MKL_Complex8, c) } // end namespase internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_GENERAL_MATRIX_MATRIX_MKL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixVector.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixVector.h index 8b7dca45f..9e6391641 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixVector.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/GeneralMatrixVector.h @@ -10,7 +10,7 @@ #ifndef EIGEN_GENERAL_MATRIX_VECTOR_H #define EIGEN_GENERAL_MATRIX_VECTOR_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -614,6 +614,6 @@ EIGEN_DONT_INLINE void general_matrix_vector_product1)) return func(0,rows, 0,cols); - Eigen::initParallel(); + StormEigen::initParallel(); func.initParallelSession(threads); if(transpose) @@ -150,6 +150,6 @@ void parallelize_gemm(const Functor& func, Index rows, Index cols, bool transpos } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_PARALLELIZER_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixMatrix.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixMatrix.h index f84f54982..a794f264c 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixMatrix.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SELFADJOINT_MATRIX_MATRIX_H #define EIGEN_SELFADJOINT_MATRIX_MATRIX_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -516,6 +516,6 @@ struct selfadjoint_product_impl } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SELFADJOINT_MATRIX_MATRIX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h index dfa687fef..fb88633ff 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h @@ -33,7 +33,7 @@ #ifndef EIGEN_SELFADJOINT_MATRIX_MATRIX_MKL_H #define EIGEN_SELFADJOINT_MATRIX_MATRIX_MKL_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -290,6 +290,6 @@ EIGEN_MKL_HEMM_R(scomplex, MKL_Complex8, cf, c) } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SELFADJOINT_MATRIX_MATRIX_MKL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixVector.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixVector.h index d8d30267e..599c1f81a 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixVector.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixVector.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SELFADJOINT_MATRIX_VECTOR_H #define EIGEN_SELFADJOINT_MATRIX_VECTOR_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -255,6 +255,6 @@ struct selfadjoint_product_impl } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SELFADJOINT_MATRIX_VECTOR_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h index a08f385bc..a6d2c4b18 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h @@ -33,7 +33,7 @@ #ifndef EIGEN_SELFADJOINT_MATRIX_VECTOR_MKL_H #define EIGEN_SELFADJOINT_MATRIX_VECTOR_MKL_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -108,6 +108,6 @@ EIGEN_MKL_SYMV_SPECIALIZATION(scomplex, MKL_Complex8, chemv) } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SELFADJOINT_MATRIX_VECTOR_MKL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointProduct.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointProduct.h index 2af00058d..200e7af22 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointProduct.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointProduct.h @@ -16,7 +16,7 @@ * It corresponds to the level 3 SYRK and level 2 SYR Blas routines. **********************************************************************/ -namespace Eigen { +namespace StormEigen { template @@ -116,6 +116,6 @@ SelfAdjointView& SelfAdjointView return *this; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SELFADJOINT_PRODUCT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointRank2Update.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointRank2Update.h index 2ae364111..5bed5864a 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointRank2Update.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/SelfadjointRank2Update.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SELFADJOINTRANK2UPTADE_H #define EIGEN_SELFADJOINTRANK2UPTADE_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -88,6 +88,6 @@ SelfAdjointView& SelfAdjointView return *this; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SELFADJOINTRANK2UPTADE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixMatrix.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixMatrix.h index 39ab87df8..4df9b2266 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixMatrix.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixMatrix.h @@ -10,7 +10,7 @@ #ifndef EIGEN_TRIANGULAR_MATRIX_MATRIX_H #define EIGEN_TRIANGULAR_MATRIX_MATRIX_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -432,6 +432,6 @@ struct triangular_product_impl } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_TRIANGULAR_MATRIX_MATRIX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h index d9e7cf852..43871de64 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h @@ -33,7 +33,7 @@ #ifndef EIGEN_TRIANGULAR_MATRIX_MATRIX_MKL_H #define EIGEN_TRIANGULAR_MATRIX_MATRIX_MKL_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -304,6 +304,6 @@ EIGEN_MKL_TRMM_R(scomplex, MKL_Complex8, cf, c) } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_TRIANGULAR_MATRIX_MATRIX_MKL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixVector.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixVector.h index 7c014b72a..3cb4b1652 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixVector.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixVector.h @@ -10,7 +10,7 @@ #ifndef EIGEN_TRIANGULARMATRIXVECTOR_H #define EIGEN_TRIANGULARMATRIXVECTOR_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -331,6 +331,6 @@ template struct trmv_selector } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_TRIANGULARMATRIXVECTOR_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixVector_MKL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixVector_MKL.h index 3672b1240..fdb679aea 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixVector_MKL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularMatrixVector_MKL.h @@ -33,7 +33,7 @@ #ifndef EIGEN_TRIANGULAR_MATRIX_VECTOR_MKL_H #define EIGEN_TRIANGULAR_MATRIX_VECTOR_MKL_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -240,6 +240,6 @@ EIGEN_MKL_TRMV_RM(scomplex, MKL_Complex8, cf, c) } // end namespase internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_TRIANGULAR_MATRIX_VECTOR_MKL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularSolverMatrix.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularSolverMatrix.h index 208593718..2fcbee51b 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularSolverMatrix.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/products/TriangularSolverMatrix.h @@ -10,7 +10,7 @@ #ifndef EIGEN_TRIANGULAR_SOLVER_MATRIX_H #define EIGEN_TRIANGULAR_SOLVER_MATRIX_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -329,6 +329,6 @@ EIGEN_DONT_INLINE void triangular_solve_matrix const typename T::Scalar* extract_data(const T& m) } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_BLASUTIL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Constants.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Constants.h index a364f48d1..e0131e420 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Constants.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Constants.h @@ -11,7 +11,7 @@ #ifndef EIGEN_CONSTANTS_H #define EIGEN_CONSTANTS_H -namespace Eigen { +namespace StormEigen { /** This value means that a positive quantity (e.g., a size) is not known at compile-time, and that instead the value is * stored in some runtime variable. @@ -541,6 +541,6 @@ enum ComparisonName { }; } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_CONSTANTS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/DisableStupidWarnings.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/DisableStupidWarnings.h index 747232938..3b2a9188a 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/DisableStupidWarnings.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/DisableStupidWarnings.h @@ -26,7 +26,7 @@ // 279 - controlling expression is constant // ICC 12 generates this warning on assert(constant_expression_depending_on_template_params) and frankly this is a legitimate use case. // 1684 - conversion from pointer to same-sized integral type (potential portability problem) - // 2259 - non-pointer conversion from "Eigen::Index={ptrdiff_t={long}}" to "int" may lose significant bits + // 2259 - non-pointer conversion from "StormEigen::Index={ptrdiff_t={long}}" to "int" may lose significant bits #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS #pragma warning push #endif diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/ForwardDeclarations.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/ForwardDeclarations.h index 483af876f..21f413c08 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/ForwardDeclarations.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/ForwardDeclarations.h @@ -11,7 +11,7 @@ #ifndef EIGEN_FORWARDDECLARATIONS_H #define EIGEN_FORWARDDECLARATIONS_H -namespace Eigen { +namespace StormEigen { namespace internal { template struct traits; @@ -61,12 +61,12 @@ template class Array; @@ -294,6 +294,6 @@ struct stem_function }; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_FORWARDDECLARATIONS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/MKL_support.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/MKL_support.h index 1ef3b61db..40711c8a8 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/MKL_support.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/MKL_support.h @@ -108,7 +108,7 @@ #define EIGEN_MKL_DOMAIN_PARDISO MKL_PARDISO #endif -namespace Eigen { +namespace StormEigen { typedef std::complex dcomplex; typedef std::complex scomplex; @@ -151,7 +151,7 @@ inline void assign_conj_scalar_eig2mkl(MKL_Complex8& mklS } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Macros.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Macros.h index 9b4f8faa7..569bfce9e 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Macros.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Macros.h @@ -311,9 +311,9 @@ #define EIGEN_NOT_A_MACRO #ifdef EIGEN_DEFAULT_TO_ROW_MAJOR -#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Eigen::RowMajor +#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION StormEigen::RowMajor #else -#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Eigen::ColMajor +#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION StormEigen::ColMajor #endif #ifndef EIGEN_DEFAULT_DENSE_INDEX_TYPE @@ -435,7 +435,7 @@ // it uses __attribute__((always_inline)) on GCC, which most of the time is useless and can severely harm compile times. // FIXME with the always_inline attribute, // gcc 3.4.x reports the following compilation error: -// Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval Eigen::MatrixBase::eval() const' +// Eval.h:91: sorry, unimplemented: inlining failed in call to 'const StormEigen::Eval StormEigen::MatrixBase::eval() const' // : function body not available #if EIGEN_GNUC_AT_LEAST(4,0) #define EIGEN_ALWAYS_INLINE __attribute__((always_inline)) inline @@ -475,7 +475,7 @@ #define eigen_plain_assert(x) #else #if EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO - namespace Eigen { + namespace StormEigen { namespace internal { inline bool copy_bool(bool b) { return b; } } @@ -486,7 +486,7 @@ #include // for abort #include // for std::cerr - namespace Eigen { + namespace StormEigen { namespace internal { // trivial function copying a bool. Must be EIGEN_DONT_INLINE, so we implement it after including Eigen headers. // see bug 89. @@ -502,8 +502,8 @@ } #define eigen_plain_assert(x) \ do { \ - if(!Eigen::internal::copy_bool(x)) \ - Eigen::internal::assert_fail(EIGEN_MAKESTRING(x), __PRETTY_FUNCTION__, __FILE__, __LINE__); \ + if(!StormEigen::internal::copy_bool(x)) \ + StormEigen::internal::assert_fail(EIGEN_MAKESTRING(x), __PRETTY_FUNCTION__, __FILE__, __LINE__); \ } while(false) #endif #endif @@ -544,12 +544,12 @@ #endif // Suppresses 'unused variable' warnings. -namespace Eigen { +namespace StormEigen { namespace internal { template EIGEN_DEVICE_FUNC void ignore_unused_variable(const T&) {} } } -#define EIGEN_UNUSED_VARIABLE(var) Eigen::internal::ignore_unused_variable(var); +#define EIGEN_UNUSED_VARIABLE(var) StormEigen::internal::ignore_unused_variable(var); #if !defined(EIGEN_ASM_COMMENT) #if EIGEN_COMP_GNUC && (EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM_OR_ARM64) @@ -731,9 +731,9 @@ namespace Eigen { #ifdef EIGEN_MAKING_DOCS // format used in Eigen's documentation // needed to define it here as escaping characters in CMake add_definition's argument seems very problematic. -#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat(3, 0, " ", "\n", "", "") +#define EIGEN_DEFAULT_IO_FORMAT StormEigen::IOFormat(3, 0, " ", "\n", "", "") #else -#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat() +#define EIGEN_DEFAULT_IO_FORMAT StormEigen::IOFormat() #endif #endif @@ -775,15 +775,15 @@ namespace Eigen { **/ #define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \ - typedef typename Eigen::internal::traits::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex. */ \ - typedef typename Eigen::NumTraits::Real RealScalar; /*!< \brief The underlying numeric type for composed scalar types. \details In cases where Scalar is e.g. std::complex, T were corresponding to RealScalar. */ \ + typedef typename StormEigen::internal::traits::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex. */ \ + typedef typename StormEigen::NumTraits::Real RealScalar; /*!< \brief The underlying numeric type for composed scalar types. \details In cases where Scalar is e.g. std::complex, T were corresponding to RealScalar. */ \ typedef typename Base::CoeffReturnType CoeffReturnType; /*!< \brief The return type for coefficient access. \details Depending on whether the object allows direct coefficient access (e.g. for a MatrixXd), this type is either 'const Scalar&' or simply 'Scalar' for objects that do not allow direct coefficient access. */ \ - typedef typename Eigen::internal::ref_selector::type Nested; \ - typedef typename Eigen::internal::traits::StorageKind StorageKind; \ - typedef typename Eigen::internal::traits::StorageIndex StorageIndex; \ - enum { RowsAtCompileTime = Eigen::internal::traits::RowsAtCompileTime, \ - ColsAtCompileTime = Eigen::internal::traits::ColsAtCompileTime, \ - Flags = Eigen::internal::traits::Flags, \ + typedef typename StormEigen::internal::ref_selector::type Nested; \ + typedef typename StormEigen::internal::traits::StorageKind StorageKind; \ + typedef typename StormEigen::internal::traits::StorageIndex StorageIndex; \ + enum { RowsAtCompileTime = StormEigen::internal::traits::RowsAtCompileTime, \ + ColsAtCompileTime = StormEigen::internal::traits::ColsAtCompileTime, \ + Flags = StormEigen::internal::traits::Flags, \ SizeAtCompileTime = Base::SizeAtCompileTime, \ MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \ IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \ diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Memory.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Memory.h index 1fc535a3a..66aa9bbc3 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Memory.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Memory.h @@ -81,7 +81,7 @@ #define EIGEN_HAS_MM_MALLOC 0 #endif -namespace Eigen { +namespace StormEigen { namespace internal { @@ -642,14 +642,14 @@ template class aligned_stack_memory_handler : noncopyable : m_ptr(ptr), m_size(size), m_deallocate(dealloc) { if(NumTraits::RequireInitialization && m_ptr) - Eigen::internal::construct_elements_of_array(m_ptr, size); + StormEigen::internal::construct_elements_of_array(m_ptr, size); } ~aligned_stack_memory_handler() { if(NumTraits::RequireInitialization && m_ptr) - Eigen::internal::destruct_elements_of_array(m_ptr, m_size); + StormEigen::internal::destruct_elements_of_array(m_ptr, m_size); if(m_deallocate) - Eigen::internal::aligned_free(m_ptr); + StormEigen::internal::aligned_free(m_ptr); } protected: T* m_ptr; @@ -709,19 +709,19 @@ template void swap(scoped_array &a,scoped_array &b) #endif #define ei_declare_aligned_stack_constructed_variable(TYPE,NAME,SIZE,BUFFER) \ - Eigen::internal::check_size_for_overflow(SIZE); \ + StormEigen::internal::check_size_for_overflow(SIZE); \ TYPE* NAME = (BUFFER)!=0 ? (BUFFER) \ : reinterpret_cast( \ (sizeof(TYPE)*SIZE<=EIGEN_STACK_ALLOCATION_LIMIT) ? EIGEN_ALIGNED_ALLOCA(sizeof(TYPE)*SIZE) \ - : Eigen::internal::aligned_malloc(sizeof(TYPE)*SIZE) ); \ - Eigen::internal::aligned_stack_memory_handler EIGEN_CAT(NAME,_stack_memory_destructor)((BUFFER)==0 ? NAME : 0,SIZE,sizeof(TYPE)*SIZE>EIGEN_STACK_ALLOCATION_LIMIT) + : StormEigen::internal::aligned_malloc(sizeof(TYPE)*SIZE) ); \ + StormEigen::internal::aligned_stack_memory_handler EIGEN_CAT(NAME,_stack_memory_destructor)((BUFFER)==0 ? NAME : 0,SIZE,sizeof(TYPE)*SIZE>EIGEN_STACK_ALLOCATION_LIMIT) #else #define ei_declare_aligned_stack_constructed_variable(TYPE,NAME,SIZE,BUFFER) \ - Eigen::internal::check_size_for_overflow(SIZE); \ - TYPE* NAME = (BUFFER)!=0 ? BUFFER : reinterpret_cast(Eigen::internal::aligned_malloc(sizeof(TYPE)*SIZE)); \ - Eigen::internal::aligned_stack_memory_handler EIGEN_CAT(NAME,_stack_memory_destructor)((BUFFER)==0 ? NAME : 0,SIZE,true) + StormEigen::internal::check_size_for_overflow(SIZE); \ + TYPE* NAME = (BUFFER)!=0 ? BUFFER : reinterpret_cast(StormEigen::internal::aligned_malloc(sizeof(TYPE)*SIZE)); \ + StormEigen::internal::aligned_stack_memory_handler EIGEN_CAT(NAME,_stack_memory_destructor)((BUFFER)==0 ? NAME : 0,SIZE,true) #endif @@ -733,20 +733,20 @@ template void swap(scoped_array &a,scoped_array &b) #if EIGEN_MAX_ALIGN_BYTES!=0 #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \ void* operator new(size_t size, const std::nothrow_t&) EIGEN_NO_THROW { \ - EIGEN_TRY { return Eigen::internal::conditional_aligned_malloc(size); } \ + EIGEN_TRY { return StormEigen::internal::conditional_aligned_malloc(size); } \ EIGEN_CATCH (...) { return 0; } \ } #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) \ void *operator new(size_t size) { \ - return Eigen::internal::conditional_aligned_malloc(size); \ + return StormEigen::internal::conditional_aligned_malloc(size); \ } \ void *operator new[](size_t size) { \ - return Eigen::internal::conditional_aligned_malloc(size); \ + return StormEigen::internal::conditional_aligned_malloc(size); \ } \ - void operator delete(void * ptr) EIGEN_NO_THROW { Eigen::internal::conditional_aligned_free(ptr); } \ - void operator delete[](void * ptr) EIGEN_NO_THROW { Eigen::internal::conditional_aligned_free(ptr); } \ - void operator delete(void * ptr, std::size_t /* sz */) EIGEN_NO_THROW { Eigen::internal::conditional_aligned_free(ptr); } \ - void operator delete[](void * ptr, std::size_t /* sz */) EIGEN_NO_THROW { Eigen::internal::conditional_aligned_free(ptr); } \ + void operator delete(void * ptr) EIGEN_NO_THROW { StormEigen::internal::conditional_aligned_free(ptr); } \ + void operator delete[](void * ptr) EIGEN_NO_THROW { StormEigen::internal::conditional_aligned_free(ptr); } \ + void operator delete(void * ptr, std::size_t /* sz */) EIGEN_NO_THROW { StormEigen::internal::conditional_aligned_free(ptr); } \ + void operator delete[](void * ptr, std::size_t /* sz */) EIGEN_NO_THROW { StormEigen::internal::conditional_aligned_free(ptr); } \ /* in-place new and delete. since (at least afaik) there is no actual */ \ /* memory allocated we can safely let the default implementation handle */ \ /* this particular case. */ \ @@ -757,7 +757,7 @@ template void swap(scoped_array &a,scoped_array &b) /* nothrow-new (returns zero instead of std::bad_alloc) */ \ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \ void operator delete(void *ptr, const std::nothrow_t&) EIGEN_NO_THROW { \ - Eigen::internal::conditional_aligned_free(ptr); \ + StormEigen::internal::conditional_aligned_free(ptr); \ } \ typedef void eigen_aligned_operator_new_marker_type; #else @@ -766,7 +766,7 @@ template void swap(scoped_array &a,scoped_array &b) #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(true) #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar,Size) \ - EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(bool(((Size)!=Eigen::Dynamic) && ((sizeof(Scalar)*(Size))%EIGEN_MAX_ALIGN_BYTES==0))) + EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(bool(((Size)!=StormEigen::Dynamic) && ((sizeof(Scalar)*(Size))%EIGEN_MAX_ALIGN_BYTES==0))) /****************************************************************************/ @@ -1049,6 +1049,6 @@ inline int queryTopLevelCacheSize() } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_MEMORY_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Meta.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Meta.h index 3dee2bd7c..28152829a 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Meta.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/Meta.h @@ -16,7 +16,7 @@ #include #endif -namespace Eigen { +namespace StormEigen { namespace internal { @@ -385,6 +385,6 @@ T div_ceil(const T &a, const T &b) } // end namespace numext -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_META_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/StaticAssert.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/StaticAssert.h index 1fe365aa7..2938cd568 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/StaticAssert.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/StaticAssert.h @@ -33,7 +33,7 @@ #else // not CXX0X - namespace Eigen { + namespace StormEigen { namespace internal { @@ -103,7 +103,7 @@ } // end namespace internal - } // end namespace Eigen + } // end namespace StormEigen // Specialized implementation for MSVC to avoid "conditional // expression is constant" warnings. This implementation doesn't @@ -111,12 +111,12 @@ #if EIGEN_COMP_MSVC #define EIGEN_STATIC_ASSERT(CONDITION,MSG) \ - {Eigen::internal::static_assertion::MSG;} + {StormEigen::internal::static_assertion::MSG;} #else // In some cases clang interprets bool(CONDITION) as function declaration #define EIGEN_STATIC_ASSERT(CONDITION,MSG) \ - if (Eigen::internal::static_assertion(CONDITION)>::MSG) {} + if (StormEigen::internal::static_assertion(CONDITION)>::MSG) {} #endif @@ -136,12 +136,12 @@ // static assertion failing if the type \a TYPE is not fixed-size #define EIGEN_STATIC_ASSERT_FIXED_SIZE(TYPE) \ - EIGEN_STATIC_ASSERT(TYPE::SizeAtCompileTime!=Eigen::Dynamic, \ + EIGEN_STATIC_ASSERT(TYPE::SizeAtCompileTime!=StormEigen::Dynamic, \ YOU_CALLED_A_FIXED_SIZE_METHOD_ON_A_DYNAMIC_SIZE_MATRIX_OR_VECTOR) // static assertion failing if the type \a TYPE is not dynamic-size #define EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(TYPE) \ - EIGEN_STATIC_ASSERT(TYPE::SizeAtCompileTime==Eigen::Dynamic, \ + EIGEN_STATIC_ASSERT(TYPE::SizeAtCompileTime==StormEigen::Dynamic, \ YOU_CALLED_A_DYNAMIC_SIZE_METHOD_ON_A_FIXED_SIZE_MATRIX_OR_VECTOR) // static assertion failing if the type \a TYPE is not a vector type of the given size @@ -157,8 +157,8 @@ // static assertion failing if the two vector expression types are not compatible (same fixed-size or dynamic size) #define EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(TYPE0,TYPE1) \ EIGEN_STATIC_ASSERT( \ - (int(TYPE0::SizeAtCompileTime)==Eigen::Dynamic \ - || int(TYPE1::SizeAtCompileTime)==Eigen::Dynamic \ + (int(TYPE0::SizeAtCompileTime)==StormEigen::Dynamic \ + || int(TYPE1::SizeAtCompileTime)==StormEigen::Dynamic \ || int(TYPE0::SizeAtCompileTime)==int(TYPE1::SizeAtCompileTime)),\ YOU_MIXED_VECTORS_OF_DIFFERENT_SIZES) @@ -166,11 +166,11 @@ ( \ (int(internal::size_of_xpr_at_compile_time::ret)==0 && int(internal::size_of_xpr_at_compile_time::ret)==0) \ || (\ - (int(TYPE0::RowsAtCompileTime)==Eigen::Dynamic \ - || int(TYPE1::RowsAtCompileTime)==Eigen::Dynamic \ + (int(TYPE0::RowsAtCompileTime)==StormEigen::Dynamic \ + || int(TYPE1::RowsAtCompileTime)==StormEigen::Dynamic \ || int(TYPE0::RowsAtCompileTime)==int(TYPE1::RowsAtCompileTime)) \ - && (int(TYPE0::ColsAtCompileTime)==Eigen::Dynamic \ - || int(TYPE1::ColsAtCompileTime)==Eigen::Dynamic \ + && (int(TYPE0::ColsAtCompileTime)==StormEigen::Dynamic \ + || int(TYPE1::ColsAtCompileTime)==StormEigen::Dynamic \ || int(TYPE0::ColsAtCompileTime)==int(TYPE1::ColsAtCompileTime))\ ) \ ) diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/XprHelper.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/XprHelper.h index f9e2959cc..763010b82 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/XprHelper.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Core/util/XprHelper.h @@ -22,7 +22,7 @@ #define EIGEN_EMPTY_STRUCT_CTOR(X) #endif -namespace Eigen { +namespace StormEigen { typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex; @@ -709,6 +709,6 @@ std::string demangle_flags(int f) : int(internal::is_same_or_void::value)), \ YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_XPRHELPER_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/ComplexEigenSolver.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/ComplexEigenSolver.h index ec3b1633e..195fbaeda 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/ComplexEigenSolver.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/ComplexEigenSolver.h @@ -14,7 +14,7 @@ #include "./ComplexSchur.h" -namespace Eigen { +namespace StormEigen { /** \eigenvalues_module \ingroup Eigenvalues_Module * @@ -60,7 +60,7 @@ template class ComplexEigenSolver /** \brief Scalar type for matrices of type #MatrixType. */ typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 /** \brief Complex scalar type for #MatrixType. * @@ -339,6 +339,6 @@ void ComplexEigenSolver::sortEigenvalues(bool computeEigenvectors) } } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_COMPLEX_EIGEN_SOLVER_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/ComplexSchur.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/ComplexSchur.h index 7f38919f7..017817697 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/ComplexSchur.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/ComplexSchur.h @@ -14,7 +14,7 @@ #include "./HessenbergDecomposition.h" -namespace Eigen { +namespace StormEigen { namespace internal { template struct complex_schur_reduce_to_hessenberg; @@ -63,7 +63,7 @@ template class ComplexSchur /** \brief Scalar type for matrices of type \p _MatrixType. */ typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 /** \brief Complex scalar type for \p _MatrixType. * @@ -454,6 +454,6 @@ void ComplexSchur::reduceToTriangularForm(bool computeU) m_matUisUptodate = computeU; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_COMPLEX_SCHUR_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/ComplexSchur_MKL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/ComplexSchur_MKL.h index e20c3725b..1e74a9c70 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/ComplexSchur_MKL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/ComplexSchur_MKL.h @@ -35,7 +35,7 @@ #include "Eigen/src/Core/util/MKL_support.h" -namespace Eigen { +namespace StormEigen { /** \internal Specialization for the data types supported by MKL */ @@ -88,6 +88,6 @@ EIGEN_MKL_SCHUR_COMPLEX(scomplex, MKL_Complex8, c, C, ColMajor, LAPACK_COL_MAJO EIGEN_MKL_SCHUR_COMPLEX(dcomplex, MKL_Complex16, z, Z, RowMajor, LAPACK_ROW_MAJOR) EIGEN_MKL_SCHUR_COMPLEX(scomplex, MKL_Complex8, c, C, RowMajor, LAPACK_ROW_MAJOR) -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_COMPLEX_SCHUR_MKL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/EigenSolver.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/EigenSolver.h index 532ca7d63..51ec3132d 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/EigenSolver.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/EigenSolver.h @@ -13,7 +13,7 @@ #include "./RealSchur.h" -namespace Eigen { +namespace StormEigen { /** \eigenvalues_module \ingroup Eigenvalues_Module * @@ -79,7 +79,7 @@ template class EigenSolver /** \brief Scalar type for matrices of type #MatrixType. */ typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 /** \brief Complex scalar type for #MatrixType. * @@ -635,6 +635,6 @@ void EigenSolver::doComputeEigenvectors() } } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_EIGENSOLVER_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h index a9d6790d5..472862335 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h @@ -13,7 +13,7 @@ #include "./RealQZ.h" -namespace Eigen { +namespace StormEigen { /** \eigenvalues_module \ingroup Eigenvalues_Module * @@ -72,7 +72,7 @@ template class GeneralizedEigenSolver /** \brief Scalar type for matrices of type #MatrixType. */ typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 /** \brief Complex scalar type for #MatrixType. * @@ -345,6 +345,6 @@ GeneralizedEigenSolver::compute(const MatrixType& A, const MatrixTyp return *this; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_GENERALIZEDEIGENSOLVER_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h index 5f6bb8289..7c25a7148 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h @@ -13,7 +13,7 @@ #include "./Tridiagonalization.h" -namespace Eigen { +namespace StormEigen { /** \eigenvalues_module \ingroup Eigenvalues_Module * @@ -221,6 +221,6 @@ compute(const MatrixType& matA, const MatrixType& matB, int options) return *this; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_GENERALIZEDSELFADJOINTEIGENSOLVER_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/HessenbergDecomposition.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/HessenbergDecomposition.h index f647f69b0..97e529581 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/HessenbergDecomposition.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/HessenbergDecomposition.h @@ -11,7 +11,7 @@ #ifndef EIGEN_HESSENBERGDECOMPOSITION_H #define EIGEN_HESSENBERGDECOMPOSITION_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -71,7 +71,7 @@ template class HessenbergDecomposition /** \brief Scalar type for matrices of type #MatrixType. */ typedef typename MatrixType::Scalar Scalar; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 /** \brief Type for vector of Householder coefficients. * @@ -369,6 +369,6 @@ template struct HessenbergDecompositionMatrixHReturnType } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_HESSENBERGDECOMPOSITION_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h index 4fec8af0a..745ce2bcd 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h @@ -11,7 +11,7 @@ #ifndef EIGEN_MATRIXBASEEIGENVALUES_H #define EIGEN_MATRIXBASEEIGENVALUES_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -155,6 +155,6 @@ SelfAdjointView::operatorNorm() const return eigenvalues().cwiseAbs().maxCoeff(); } -} // end namespace Eigen +} // end namespace StormEigen #endif diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/RealQZ.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/RealQZ.h index a62071d42..d86dd7522 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/RealQZ.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/RealQZ.h @@ -10,7 +10,7 @@ #ifndef EIGEN_REAL_QZ_H #define EIGEN_REAL_QZ_H -namespace Eigen { +namespace StormEigen { /** \eigenvalues_module \ingroup Eigenvalues_Module * @@ -67,7 +67,7 @@ namespace Eigen { }; typedef typename MatrixType::Scalar Scalar; typedef std::complex::Real> ComplexScalar; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 typedef Matrix EigenvalueType; typedef Matrix ColumnVectorType; @@ -619,6 +619,6 @@ namespace Eigen { return *this; } // end compute -} // end namespace Eigen +} // end namespace StormEigen #endif //EIGEN_REAL_QZ diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/RealSchur.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/RealSchur.h index f4ded69b6..8bda25b56 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/RealSchur.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/RealSchur.h @@ -13,7 +13,7 @@ #include "./HessenbergDecomposition.h" -namespace Eigen { +namespace StormEigen { /** \eigenvalues_module \ingroup Eigenvalues_Module * @@ -64,7 +64,7 @@ template class RealSchur }; typedef typename MatrixType::Scalar Scalar; typedef std::complex::Real> ComplexScalar; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 typedef Matrix EigenvalueType; typedef Matrix ColumnVectorType; @@ -523,6 +523,6 @@ inline void RealSchur::performFrancisQRStep(Index il, Index im, Inde } } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_REAL_SCHUR_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/RealSchur_MKL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/RealSchur_MKL.h index e80926400..8a1766945 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/RealSchur_MKL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/RealSchur_MKL.h @@ -35,7 +35,7 @@ #include "Eigen/src/Core/util/MKL_support.h" -namespace Eigen { +namespace StormEigen { /** \internal Specialization for the data types supported by MKL */ @@ -74,6 +74,6 @@ EIGEN_MKL_SCHUR_REAL(float, float, s, S, ColMajor, LAPACK_COL_MAJOR) EIGEN_MKL_SCHUR_REAL(double, double, d, D, RowMajor, LAPACK_ROW_MAJOR) EIGEN_MKL_SCHUR_REAL(float, float, s, S, RowMajor, LAPACK_ROW_MAJOR) -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_REAL_SCHUR_MKL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h index c64555096..0e07a6513 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h @@ -13,7 +13,7 @@ #include "./Tridiagonalization.h" -namespace Eigen { +namespace StormEigen { template class GeneralizedSelfAdjointEigenSolver; @@ -81,7 +81,7 @@ template class SelfAdjointEigenSolver /** \brief Scalar type for matrices of type \p _MatrixType. */ typedef typename MatrixType::Scalar Scalar; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 typedef Matrix EigenvectorsType; @@ -642,7 +642,7 @@ template struct direct_selfadjoint_eigenvalues::epsilon()) + if((eivals(2)-eivals(0))<=StormEigen::NumTraits::epsilon()) { // All three eigenvalues are numerically the same eivecs.setIdentity(); @@ -670,7 +670,7 @@ template struct direct_selfadjoint_eigenvalues::epsilon()*d1) + if(d0<=2*StormEigen::NumTraits::epsilon()*d1) { // If d0 is too small, then the two other eigenvalues are numerically the same, // and thus we only have to ortho-normalize the near orthogonal vector we saved above. @@ -746,7 +746,7 @@ struct direct_selfadjoint_eigenvalues // compute the eigen vectors if(computeEigenvectors) { - if((eivals(1)-eivals(0))<=abs(eivals(1))*Eigen::NumTraits::epsilon()) + if((eivals(1)-eivals(0))<=abs(eivals(1))*StormEigen::NumTraits::epsilon()) { eivecs.setIdentity(); } @@ -854,6 +854,6 @@ static void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index sta } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SELFADJOINTEIGENSOLVER_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h index 3499dc78a..dfc1b0d07 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h @@ -35,7 +35,7 @@ #include "Eigen/src/Core/util/MKL_support.h" -namespace Eigen { +namespace StormEigen { /** \internal Specialization for the data types supported by MKL */ @@ -87,6 +87,6 @@ EIGEN_MKL_EIG_SELFADJ(float, float, float, ssyev, RowMajor, LAPACK_R EIGEN_MKL_EIG_SELFADJ(dcomplex, MKL_Complex16, double, zheev, RowMajor, LAPACK_ROW_MAJOR) EIGEN_MKL_EIG_SELFADJ(scomplex, MKL_Complex8, float, cheev, RowMajor, LAPACK_ROW_MAJOR) -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SAEIGENSOLVER_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/Tridiagonalization.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/Tridiagonalization.h index 2030b5be1..e42034ddf 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/Tridiagonalization.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Eigenvalues/Tridiagonalization.h @@ -11,7 +11,7 @@ #ifndef EIGEN_TRIDIAGONALIZATION_H #define EIGEN_TRIDIAGONALIZATION_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -69,7 +69,7 @@ template class Tridiagonalization typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 enum { Size = MatrixType::RowsAtCompileTime, @@ -551,6 +551,6 @@ template struct TridiagonalizationMatrixTReturnType } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_TRIDIAGONALIZATION_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/AlignedBox.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/AlignedBox.h index 03f1a11f8..cde93564f 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/AlignedBox.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/AlignedBox.h @@ -10,7 +10,7 @@ #ifndef EIGEN_ALIGNEDBOX_H #define EIGEN_ALIGNEDBOX_H -namespace Eigen { +namespace StormEigen { /** \geometry_module \ingroup Geometry_Module * @@ -34,7 +34,7 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim) enum { AmbientDimAtCompileTime = _AmbientDim }; typedef _Scalar Scalar; typedef NumTraits ScalarTraits; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 typedef typename ScalarTraits::Real RealScalar; typedef typename ScalarTraits::NonInteger NonInteger; typedef Matrix VectorType; @@ -387,6 +387,6 @@ EIGEN_MAKE_TYPEDEFS_ALL_SIZES(double, d) #undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES #undef EIGEN_MAKE_TYPEDEFS -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_ALIGNEDBOX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/AngleAxis.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/AngleAxis.h index 7fdb8ae83..0ca78f757 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/AngleAxis.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/AngleAxis.h @@ -10,7 +10,7 @@ #ifndef EIGEN_ANGLEAXIS_H #define EIGEN_ANGLEAXIS_H -namespace Eigen { +namespace StormEigen { /** \geometry_module \ingroup Geometry_Module * @@ -235,6 +235,6 @@ AngleAxis::toRotationMatrix(void) const return res; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_ANGLEAXIS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/EulerAngles.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/EulerAngles.h index b875b7a13..a5b49d3eb 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/EulerAngles.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/EulerAngles.h @@ -10,7 +10,7 @@ #ifndef EIGEN_EULERANGLES_H #define EIGEN_EULERANGLES_H -namespace Eigen { +namespace StormEigen { /** \geometry_module \ingroup Geometry_Module * @@ -99,6 +99,6 @@ MatrixBase::eulerAngles(Index a0, Index a1, Index a2) const return res; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_EULERANGLES_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Homogeneous.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Homogeneous.h index 4107fba4d..9cb7f6fe9 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Homogeneous.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Homogeneous.h @@ -10,7 +10,7 @@ #ifndef EIGEN_HOMOGENEOUS_H #define EIGEN_HOMOGENEOUS_H -namespace Eigen { +namespace StormEigen { /** \geometry_module \ingroup Geometry_Module * @@ -452,6 +452,6 @@ struct permutation_matrix_product::Real RealScalar; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 typedef Matrix VectorType; typedef Matrix::unitOrthogonal() const return internal::unitOrthogonal_selector::run(derived()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_ORTHOMETHODS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/ParametrizedLine.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/ParametrizedLine.h index 93edd9148..ce80f21f0 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/ParametrizedLine.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/ParametrizedLine.h @@ -11,7 +11,7 @@ #ifndef EIGEN_PARAMETRIZEDLINE_H #define EIGEN_PARAMETRIZEDLINE_H -namespace Eigen { +namespace StormEigen { /** \geometry_module \ingroup Geometry_Module * @@ -37,7 +37,7 @@ public: }; typedef _Scalar Scalar; typedef typename NumTraits::Real RealScalar; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 typedef Matrix VectorType; /** Default constructor without initialization */ @@ -190,6 +190,6 @@ ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersectionPoint(const Hyperpl return pointAt(intersectionParameter(hyperplane)); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_PARAMETRIZEDLINE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Quaternion.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Quaternion.h index 32e7e76fa..1a7481c83 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Quaternion.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Quaternion.h @@ -10,7 +10,7 @@ #ifndef EIGEN_QUATERNION_H #define EIGEN_QUATERNION_H -namespace Eigen { +namespace StormEigen { /*************************************************************************** @@ -44,7 +44,7 @@ class QuaternionBase : public RotationBase typedef typename NumTraits::Real RealScalar; typedef typename internal::traits::Coefficients Coefficients; enum { - Flags = Eigen::internal::traits::Flags + Flags = StormEigen::internal::traits::Flags }; // typedef typename Matrix Coefficients; @@ -788,6 +788,6 @@ struct quaternionbase_assign_impl } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_QUATERNION_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Rotation2D.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Rotation2D.h index 8b0ddcfb0..b5ef487d1 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Rotation2D.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Rotation2D.h @@ -10,7 +10,7 @@ #ifndef EIGEN_ROTATION2D_H #define EIGEN_ROTATION2D_H -namespace Eigen { +namespace StormEigen { /** \geometry_module \ingroup Geometry_Module * @@ -194,6 +194,6 @@ Rotation2D::toRotationMatrix(void) const return (Matrix2() << cosA, -sinA, sinA, cosA).finished(); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_ROTATION2D_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/RotationBase.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/RotationBase.h index b88661de6..742bfaa57 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/RotationBase.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/RotationBase.h @@ -10,7 +10,7 @@ #ifndef EIGEN_ROTATIONBASE_H #define EIGEN_ROTATIONBASE_H -namespace Eigen { +namespace StormEigen { // forward declaration namespace internal { @@ -201,6 +201,6 @@ static inline const MatrixBase& toRotationMatrix(const MatrixBase< } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_ROTATIONBASE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Scaling.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Scaling.h index 023fba2ee..956ef3ea6 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Scaling.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Scaling.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SCALING_H #define EIGEN_SCALING_H -namespace Eigen { +namespace StormEigen { /** \geometry_module \ingroup Geometry_Module * @@ -161,6 +161,6 @@ UniformScaling::operator* (const Translation& t) const return res; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SCALING_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Transform.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Transform.h index 75f20bda6..c8171d64d 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Transform.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Transform.h @@ -12,7 +12,7 @@ #ifndef EIGEN_TRANSFORM_H #define EIGEN_TRANSFORM_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -66,7 +66,7 @@ template struct traits > { typedef _Scalar Scalar; - typedef Eigen::Index StorageIndex; + typedef StormEigen::Index StorageIndex; typedef Dense StorageKind; enum { Dim1 = _Dim==Dynamic ? _Dim : _Dim + 1, @@ -210,8 +210,8 @@ public: }; /** the scalar type of the coefficients */ typedef _Scalar Scalar; - typedef Eigen::Index StorageIndex; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index StorageIndex; + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 /** type of the matrix used to represent the transformation */ typedef typename internal::make_proper_matrix_type::type MatrixType; /** constified MatrixType */ @@ -497,11 +497,11 @@ public: #if EIGEN_COMP_ICC private: // this intermediate structure permits to workaround a bug in ICC 11: - // error: template instantiation resulted in unexpected function type of "Eigen::Transform - // (const Eigen::Transform &) const" + // error: template instantiation resulted in unexpected function type of "StormEigen::Transform + // (const StormEigen::Transform &) const" // (the meaning of a name may have changed since the template declaration -- the type of the template is: - // "Eigen::internal::transform_transform_product_impl, - // Eigen::Transform, >::ResultType (const Eigen::Transform &) const") + // "StormEigen::internal::transform_transform_product_impl, + // StormEigen::Transform, >::ResultType (const StormEigen::Transform &) const") // template struct icc_11_workaround { @@ -1493,6 +1493,6 @@ struct transform_transform_product_impl::operator* (const EigenBase& linear) const return res; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_TRANSLATION_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Umeyama.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Umeyama.h index 8d9b7a154..24e11f0b9 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Umeyama.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/Umeyama.h @@ -16,7 +16,7 @@ // * Eigen/SVD // * Eigen/Array -namespace Eigen { +namespace StormEigen { #ifndef EIGEN_PARSED_BY_DOXYGEN @@ -88,7 +88,7 @@ struct umeyama_transform_matrix_type * T = \begin{bmatrix} c\mathbf{R} & \mathbf{t} \\ \mathbf{0} & 1 \end{bmatrix} * \f} * minimizing the resudiual above. This transformation is always returned as an -* Eigen::Matrix. +* StormEigen::Matrix. */ template typename internal::umeyama_transform_matrix_type::type @@ -171,6 +171,6 @@ umeyama(const MatrixBase& src, const MatrixBase& dst, boo return Rt; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_UMEYAMA_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/arch/Geometry_SSE.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/arch/Geometry_SSE.h index 1a86ff837..3d4ab4172 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/arch/Geometry_SSE.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Geometry/arch/Geometry_SSE.h @@ -11,7 +11,7 @@ #ifndef EIGEN_GEOMETRY_SSE_H #define EIGEN_GEOMETRY_SSE_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -136,6 +136,6 @@ struct quat_conj } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_GEOMETRY_SSE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Householder/BlockHouseholder.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Householder/BlockHouseholder.h index 39bf8c83d..82608b3df 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Householder/BlockHouseholder.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Householder/BlockHouseholder.h @@ -13,7 +13,7 @@ // This file contains some helper function to deal with block householder reflectors -namespace Eigen { +namespace StormEigen { namespace internal { @@ -97,6 +97,6 @@ void apply_block_householder_on_the_left(MatrixType& mat, const VectorsType& vec } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_BLOCK_HOUSEHOLDER_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Householder/Householder.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Householder/Householder.h index 4c1f499a1..ee7a65d6c 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Householder/Householder.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Householder/Householder.h @@ -11,7 +11,7 @@ #ifndef EIGEN_HOUSEHOLDER_H #define EIGEN_HOUSEHOLDER_H -namespace Eigen { +namespace StormEigen { namespace internal { template struct decrement_size @@ -167,6 +167,6 @@ void MatrixBase::applyHouseholderOnTheRight( } } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_HOUSEHOLDER_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Householder/HouseholderSequence.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Householder/HouseholderSequence.h index 74cd0a472..5a0c99e35 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Householder/HouseholderSequence.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Householder/HouseholderSequence.h @@ -11,7 +11,7 @@ #ifndef EIGEN_HOUSEHOLDER_SEQUENCE_H #define EIGEN_HOUSEHOLDER_SEQUENCE_H -namespace Eigen { +namespace StormEigen { /** \ingroup Householder_Module * \householder_module @@ -466,6 +466,6 @@ HouseholderSequence rightHouseholderSequence( return HouseholderSequence(v, h); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_HOUSEHOLDER_SEQUENCE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h index 358444aff..512ba08e0 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h @@ -10,7 +10,7 @@ #ifndef EIGEN_BASIC_PRECONDITIONERS_H #define EIGEN_BASIC_PRECONDITIONERS_H -namespace Eigen { +namespace StormEigen { /** \ingroup IterativeLinearSolvers_Module * \brief A preconditioner based on the digonal entries @@ -206,6 +206,6 @@ class IdentityPreconditioner ComputationInfo info() { return Success; } }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_BASIC_PRECONDITIONERS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h index 454f46814..5af750fea 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h @@ -11,7 +11,7 @@ #ifndef EIGEN_BICGSTAB_H #define EIGEN_BICGSTAB_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -223,6 +223,6 @@ protected: }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_BICGSTAB_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h index 395daa8e4..1026ed23e 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h @@ -10,7 +10,7 @@ #ifndef EIGEN_CONJUGATE_GRADIENT_H #define EIGEN_CONJUGATE_GRADIENT_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -240,6 +240,6 @@ protected: }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_CONJUGATE_GRADIENT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h index 284e37f13..be74d8f48 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h @@ -14,7 +14,7 @@ #include #include -namespace Eigen { +namespace StormEigen { /** * \brief Modified Incomplete Cholesky with dual threshold * @@ -363,6 +363,6 @@ inline void IncompleteCholesky::updateList(Ref::factorize(const _MatrixType& amat) m_info = Success; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_INCOMPLETE_LUT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h index 3d62fef6e..7620a1016 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h @@ -10,7 +10,7 @@ #ifndef EIGEN_ITERATIVE_SOLVER_BASE_H #define EIGEN_ITERATIVE_SOLVER_BASE_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -337,8 +337,8 @@ public: Index rhsCols = b.cols(); Index size = b.rows(); - Eigen::Matrix tb(size); - Eigen::Matrix tx(cols()); + StormEigen::Matrix tb(size); + StormEigen::Matrix tx(cols()); // We do not directly fill dest because sparse expressions have to be free of aliasing issue. // For non square least-square problems, b and dest might not have the same size whereas they might alias each-other. SparseMatrix tmp(cols(),rhsCols); @@ -387,6 +387,6 @@ protected: mutable bool m_analysisIsOk, m_factorizationIsOk; }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_ITERATIVE_SOLVER_BASE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h index 0aea0e099..ad74c375c 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h @@ -10,7 +10,7 @@ #ifndef EIGEN_LEAST_SQUARE_CONJUGATE_GRADIENT_H #define EIGEN_LEAST_SQUARE_CONJUGATE_GRADIENT_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -211,6 +211,6 @@ public: }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_LEAST_SQUARE_CONJUGATE_GRADIENT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h index 35923be3d..ed52a69a3 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SOLVEWITHGUESS_H #define EIGEN_SOLVEWITHGUESS_H -namespace Eigen { +namespace StormEigen { template class SolveWithGuess; @@ -104,6 +104,6 @@ struct Assignment, interna } // end namepsace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SOLVEWITHGUESS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Jacobi/Jacobi.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Jacobi/Jacobi.h index 55de15e87..730a8ba13 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Jacobi/Jacobi.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/Jacobi/Jacobi.h @@ -11,7 +11,7 @@ #ifndef EIGEN_JACOBI_H #define EIGEN_JACOBI_H -namespace Eigen { +namespace StormEigen { /** \ingroup Jacobi_Module * \jacobi_module @@ -427,6 +427,6 @@ void /*EIGEN_DONT_INLINE*/ apply_rotation_in_the_plane(DenseBase& xpr_x } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_JACOBI_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/Determinant.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/Determinant.h index d6a3c1e5a..23f094d45 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/Determinant.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/Determinant.h @@ -10,7 +10,7 @@ #ifndef EIGEN_DETERMINANT_H #define EIGEN_DETERMINANT_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -96,6 +96,6 @@ inline typename internal::traits::Scalar MatrixBase::determina return internal::determinant_impl::type>::run(derived()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_DETERMINANT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/FullPivLU.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/FullPivLU.h index 0c4d63923..05c1de97c 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/FullPivLU.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/FullPivLU.h @@ -10,7 +10,7 @@ #ifndef EIGEN_LU_H #define EIGEN_LU_H -namespace Eigen { +namespace StormEigen { namespace internal { template struct traits > @@ -275,8 +275,8 @@ template class FullPivLU /** Allows to come back to the default behavior, letting Eigen use its default formula for * determining the threshold. * - * You should pass the special object Eigen::Default as parameter here. - * \code lu.setThreshold(Eigen::Default); \endcode + * You should pass the special object StormEigen::Default as parameter here. + * \code lu.setThreshold(StormEigen::Default); \endcode * * See the documentation of setThreshold(const RealScalar&). */ @@ -856,6 +856,6 @@ MatrixBase::fullPivLu() const } #endif -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_LU_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/InverseImpl.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/InverseImpl.h index e202a55cb..410aa0de2 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/InverseImpl.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/InverseImpl.h @@ -11,7 +11,7 @@ #ifndef EIGEN_INVERSE_IMPL_H #define EIGEN_INVERSE_IMPL_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -406,6 +406,6 @@ inline void MatrixBase::computeInverseWithCheck( computeInverseAndDetWithCheck(inverse,determinant,invertible,absDeterminantThreshold); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_INVERSE_IMPL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/PartialPivLU.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/PartialPivLU.h index 50e920609..d256696e0 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/PartialPivLU.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/PartialPivLU.h @@ -11,7 +11,7 @@ #ifndef EIGEN_PARTIALLU_H #define EIGEN_PARTIALLU_H -namespace Eigen { +namespace StormEigen { namespace internal { template struct traits > @@ -558,6 +558,6 @@ MatrixBase::lu() const } #endif -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_PARTIALLU_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/PartialPivLU_MKL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/PartialPivLU_MKL.h index 9035953c8..ba33a78fd 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/PartialPivLU_MKL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/PartialPivLU_MKL.h @@ -35,7 +35,7 @@ #include "Eigen/src/Core/util/MKL_support.h" -namespace Eigen { +namespace StormEigen { namespace internal { @@ -80,6 +80,6 @@ EIGEN_MKL_LU_PARTPIV(scomplex, MKL_Complex8, c) } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_PARTIALLU_LAPACK_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/arch/Inverse_SSE.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/arch/Inverse_SSE.h index e1470c664..51335bc73 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/arch/Inverse_SSE.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/LU/arch/Inverse_SSE.h @@ -27,7 +27,7 @@ #ifndef EIGEN_INVERSE_SSE_H #define EIGEN_INVERSE_SSE_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -329,6 +329,6 @@ struct compute_inverse_size4 } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_INVERSE_SSE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/MetisSupport/MetisSupport.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/MetisSupport/MetisSupport.h index 4c15304ad..5b3dc1f4e 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/MetisSupport/MetisSupport.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/MetisSupport/MetisSupport.h @@ -9,7 +9,7 @@ #ifndef METIS_SUPPORT_H #define METIS_SUPPORT_H -namespace Eigen { +namespace StormEigen { /** * Get the fill-reducing ordering from the METIS package * diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/OrderingMethods/Amd.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/OrderingMethods/Amd.h index 323255e0a..ef9f52cfa 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/OrderingMethods/Amd.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/OrderingMethods/Amd.h @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef EIGEN_SPARSE_AMD_H #define EIGEN_SPARSE_AMD_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -437,6 +437,6 @@ void minimum_degree_ordering(SparseMatrix& C, Perm } // namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSE_AMD_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/OrderingMethods/Eigen_Colamd.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/OrderingMethods/Eigen_Colamd.h index 6238676e5..6943d22a2 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/OrderingMethods/Eigen_Colamd.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/OrderingMethods/Eigen_Colamd.h @@ -436,7 +436,7 @@ static bool colamd(IndexType n_row, IndexType n_col, IndexType Alen, IndexType * /* === Construct the row and column data structures ===================== */ - if (!Eigen::internal::init_rows_cols (n_row, n_col, Row, Col, A, p, stats)) + if (!StormEigen::internal::init_rows_cols (n_row, n_col, Row, Col, A, p, stats)) { /* input matrix is invalid */ COLAMD_DEBUG0 (("colamd: Matrix invalid\n")) ; @@ -445,17 +445,17 @@ static bool colamd(IndexType n_row, IndexType n_col, IndexType Alen, IndexType * /* === Initialize scores, kill dense rows/columns ======================= */ - Eigen::internal::init_scoring (n_row, n_col, Row, Col, A, p, knobs, + StormEigen::internal::init_scoring (n_row, n_col, Row, Col, A, p, knobs, &n_row2, &n_col2, &max_deg) ; /* === Order the supercolumns =========================================== */ - ngarbage = Eigen::internal::find_ordering (n_row, n_col, Alen, Row, Col, A, p, + ngarbage = StormEigen::internal::find_ordering (n_row, n_col, Alen, Row, Col, A, p, n_col2, max_deg, 2*nnz) ; /* === Order the non-principal columns ================================== */ - Eigen::internal::order_children (n_col, Col, p) ; + StormEigen::internal::order_children (n_col, Col, p) ; /* === Return statistics in stats ======================================= */ @@ -993,7 +993,7 @@ static IndexType find_ordering /* return the number of garbage collections */ /* === Initialization and clear mark ==================================== */ max_mark = INT_MAX - n_col ; /* INT_MAX defined in */ - tag_mark = Eigen::internal::clear_mark (n_row, Row) ; + tag_mark = StormEigen::internal::clear_mark (n_row, Row) ; min_score = 0 ; ngarbage = 0 ; COLAMD_DEBUG1 (("colamd: Ordering, n_col2=%d\n", n_col2)) ; @@ -1043,12 +1043,12 @@ static IndexType find_ordering /* return the number of garbage collections */ needed_memory = COLAMD_MIN (pivot_col_score, n_col - k) ; if (pfree + needed_memory >= Alen) { - pfree = Eigen::internal::garbage_collection (n_row, n_col, Row, Col, A, &A [pfree]) ; + pfree = StormEigen::internal::garbage_collection (n_row, n_col, Row, Col, A, &A [pfree]) ; ngarbage++ ; /* after garbage collection we will have enough */ COLAMD_ASSERT (pfree + needed_memory < Alen) ; /* garbage collection has wiped out the Row[].shared2.mark array */ - tag_mark = Eigen::internal::clear_mark (n_row, Row) ; + tag_mark = StormEigen::internal::clear_mark (n_row, Row) ; } @@ -1336,7 +1336,7 @@ static IndexType find_ordering /* return the number of garbage collections */ COLAMD_DEBUG3 (("** Supercolumn detection phase. **\n")) ; - Eigen::internal::detect_super_cols (Col, A, head, pivot_row_start, pivot_row_length) ; + StormEigen::internal::detect_super_cols (Col, A, head, pivot_row_start, pivot_row_length) ; /* === Kill the pivotal column ====================================== */ @@ -1348,7 +1348,7 @@ static IndexType find_ordering /* return the number of garbage collections */ if (tag_mark >= max_mark) { COLAMD_DEBUG2 (("clearing tag_mark\n")) ; - tag_mark = Eigen::internal::clear_mark (n_row, Row) ; + tag_mark = StormEigen::internal::clear_mark (n_row, Row) ; } /* === Finalize the new pivot row, and column scores ================ */ diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/OrderingMethods/Ordering.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/OrderingMethods/Ordering.h index 25792a828..736e057fc 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/OrderingMethods/Ordering.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/OrderingMethods/Ordering.h @@ -11,7 +11,7 @@ #ifndef EIGEN_ORDERING_H #define EIGEN_ORDERING_H -namespace Eigen { +namespace StormEigen { #include "Eigen_Colamd.h" @@ -151,6 +151,6 @@ class COLAMDOrdering } }; -} // end namespace Eigen +} // end namespace StormEigen #endif diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/PaStiXSupport/PaStiXSupport.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/PaStiXSupport/PaStiXSupport.h index 1999fd289..9b7dead19 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/PaStiXSupport/PaStiXSupport.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/PaStiXSupport/PaStiXSupport.h @@ -10,7 +10,7 @@ #ifndef EIGEN_PASTIXSUPPORT_H #define EIGEN_PASTIXSUPPORT_H -namespace Eigen { +namespace StormEigen { #if defined(DCOMPLEX) #define PASTIX_COMPLEX COMPLEX @@ -671,6 +671,6 @@ class PastixLDLT : public PastixBase< PastixLDLT<_MatrixType, _UpLo> > } }; -} // end namespace Eigen +} // end namespace StormEigen #endif diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/PardisoSupport/PardisoSupport.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/PardisoSupport/PardisoSupport.h index 7c238ce3c..0f52df335 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/PardisoSupport/PardisoSupport.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/PardisoSupport/PardisoSupport.h @@ -32,7 +32,7 @@ #ifndef EIGEN_PARDISOSUPPORT_H #define EIGEN_PARDISOSUPPORT_H -namespace Eigen { +namespace StormEigen { template class PardisoLU; template class PardisoLLT; @@ -529,6 +529,6 @@ class PardisoLDLT : public PardisoImpl< PardisoLDLT > } }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_PARDISOSUPPORT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/ColPivHouseholderQR.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/ColPivHouseholderQR.h index 172e4a89f..95afa0c50 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/ColPivHouseholderQR.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/ColPivHouseholderQR.h @@ -11,7 +11,7 @@ #ifndef EIGEN_COLPIVOTINGHOUSEHOLDERQR_H #define EIGEN_COLPIVOTINGHOUSEHOLDERQR_H -namespace Eigen { +namespace StormEigen { namespace internal { template struct traits > @@ -339,8 +339,8 @@ template class ColPivHouseholderQR /** Allows to come back to the default behavior, letting Eigen use its default formula for * determining the threshold. * - * You should pass the special object Eigen::Default as parameter here. - * \code qr.setThreshold(Eigen::Default); \endcode + * You should pass the special object StormEigen::Default as parameter here. + * \code qr.setThreshold(StormEigen::Default); \endcode * * See the documentation of setThreshold(const RealScalar&). */ @@ -609,6 +609,6 @@ MatrixBase::colPivHouseholderQr() const } #endif // __CUDACC__ -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_COLPIVOTINGHOUSEHOLDERQR_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/ColPivHouseholderQR_MKL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/ColPivHouseholderQR_MKL.h index 1203d0d36..dc8d72eb3 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/ColPivHouseholderQR_MKL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/ColPivHouseholderQR_MKL.h @@ -36,7 +36,7 @@ #include "Eigen/src/Core/util/MKL_support.h" -namespace Eigen { +namespace StormEigen { /** \internal Specialization for the data types supported by MKL */ @@ -93,6 +93,6 @@ EIGEN_MKL_QR_COLPIV(float, float, s, RowMajor, LAPACK_ROW_MAJOR) EIGEN_MKL_QR_COLPIV(dcomplex, MKL_Complex16, z, RowMajor, LAPACK_ROW_MAJOR) EIGEN_MKL_QR_COLPIV(scomplex, MKL_Complex8, c, RowMajor, LAPACK_ROW_MAJOR) -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_COLPIVOTINGHOUSEHOLDERQR_MKL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/FullPivHouseholderQR.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/FullPivHouseholderQR.h index 64fe6b7b8..e3fc0db12 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/FullPivHouseholderQR.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/FullPivHouseholderQR.h @@ -11,7 +11,7 @@ #ifndef EIGEN_FULLPIVOTINGHOUSEHOLDERQR_H #define EIGEN_FULLPIVOTINGHOUSEHOLDERQR_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -333,8 +333,8 @@ template class FullPivHouseholderQR /** Allows to come back to the default behavior, letting Eigen use its default formula for * determining the threshold. * - * You should pass the special object Eigen::Default as parameter here. - * \code qr.setThreshold(Eigen::Default); \endcode + * You should pass the special object StormEigen::Default as parameter here. + * \code qr.setThreshold(StormEigen::Default); \endcode * * See the documentation of setThreshold(const RealScalar&). */ @@ -657,6 +657,6 @@ MatrixBase::fullPivHouseholderQr() const } #endif // __CUDACC__ -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_FULLPIVOTINGHOUSEHOLDERQR_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/HouseholderQR.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/HouseholderQR.h index 1eb861025..91cb3e4c3 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/HouseholderQR.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/HouseholderQR.h @@ -12,7 +12,7 @@ #ifndef EIGEN_QR_H #define EIGEN_QR_H -namespace Eigen { +namespace StormEigen { /** \ingroup QR_Module * @@ -387,6 +387,6 @@ MatrixBase::householderQr() const } #endif // __CUDACC__ -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_QR_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/HouseholderQR_MKL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/HouseholderQR_MKL.h index 84ab640a1..47963ed54 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/HouseholderQR_MKL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/QR/HouseholderQR_MKL.h @@ -36,7 +36,7 @@ #include "../Core/util/MKL_support.h" -namespace Eigen { +namespace StormEigen { namespace internal { @@ -65,6 +65,6 @@ EIGEN_MKL_QR_NOPIV(scomplex, MKL_Complex8, c) } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_QR_MKL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h index d9c3113e7..4d0a00c8d 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h @@ -11,7 +11,7 @@ #ifndef EIGEN_SUITESPARSEQRSUPPORT_H #define EIGEN_SUITESPARSEQRSUPPORT_H -namespace Eigen { +namespace StormEigen { template class SPQR; template struct SPQRMatrixQReturnType; @@ -308,5 +308,5 @@ struct SPQRMatrixQTransposeReturnType{ const SPQRType& m_spqr; }; -}// End namespace Eigen +}// End namespace StormEigen #endif diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/BDCSVD.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/BDCSVD.h index 896246e46..8fc9117cc 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/BDCSVD.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/BDCSVD.h @@ -21,7 +21,7 @@ #define EIGEN_BDCSVD_H // #define EIGEN_BDCSVD_DEBUG_VERBOSE // #define EIGEN_BDCSVD_SANITY_CHECKS -namespace Eigen { +namespace StormEigen { #ifdef EIGEN_BDCSVD_DEBUG_VERBOSE IOFormat bdcsvdfmt(8, 0, ", ", "\n", " [", "]"); @@ -1203,6 +1203,6 @@ MatrixBase::bdcSvd(unsigned int computationOptions) const } #endif -} // end namespace Eigen +} // end namespace StormEigen #endif diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/JacobiSVD.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/JacobiSVD.h index 59c965e15..6580c089d 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/JacobiSVD.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/JacobiSVD.h @@ -11,7 +11,7 @@ #ifndef EIGEN_JACOBISVD_H #define EIGEN_JACOBISVD_H -namespace Eigen { +namespace StormEigen { namespace internal { // forward declaration (needed by ICC) @@ -798,6 +798,6 @@ MatrixBase::jacobiSvd(unsigned int computationOptions) const } #endif // __CUDACC__ -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_JACOBISVD_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/JacobiSVD_MKL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/JacobiSVD_MKL.h index 14e461c4e..94788910d 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/JacobiSVD_MKL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/JacobiSVD_MKL.h @@ -35,7 +35,7 @@ #include "Eigen/src/Core/util/MKL_support.h" -namespace Eigen { +namespace StormEigen { /** \internal Specialization for the data types supported by MKL */ @@ -87,6 +87,6 @@ EIGEN_MKL_SVD(float, float, float , s, RowMajor, LAPACK_ROW_MAJOR) EIGEN_MKL_SVD(dcomplex, MKL_Complex16, double, z, RowMajor, LAPACK_ROW_MAJOR) EIGEN_MKL_SVD(scomplex, MKL_Complex8, float , c, RowMajor, LAPACK_ROW_MAJOR) -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_JACOBISVD_MKL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/SVDBase.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/SVDBase.h index ad191085e..39a6dbee9 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/SVDBase.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/SVDBase.h @@ -16,7 +16,7 @@ #ifndef EIGEN_SVDBASE_H #define EIGEN_SVDBASE_H -namespace Eigen { +namespace StormEigen { /** \ingroup SVD_Module * * @@ -53,7 +53,7 @@ public: typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef typename MatrixType::StorageIndex StorageIndex; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 enum { RowsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime, @@ -163,8 +163,8 @@ public: /** Allows to come back to the default behavior, letting Eigen use its default formula for * determining the threshold. * - * You should pass the special object Eigen::Default as parameter here. - * \code svd.setThreshold(Eigen::Default); \endcode + * You should pass the special object StormEigen::Default as parameter here. + * \code svd.setThreshold(StormEigen::Default); \endcode * * See the documentation of setThreshold(const RealScalar&). */ diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/UpperBidiagonalization.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/UpperBidiagonalization.h index 0b1460894..8f6fc68c4 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/UpperBidiagonalization.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SVD/UpperBidiagonalization.h @@ -11,7 +11,7 @@ #ifndef EIGEN_BIDIAGONALIZATION_H #define EIGEN_BIDIAGONALIZATION_H -namespace Eigen { +namespace StormEigen { namespace internal { // UpperBidiagonalization will probably be replaced by a Bidiagonalization class, don't want to make it stable API. @@ -29,7 +29,7 @@ template class UpperBidiagonalization }; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef StormEigen::Index Index; ///< \deprecated since Eigen 3.3 typedef Matrix RowVectorType; typedef Matrix ColVectorType; typedef BandMatrix BidiagonalType; @@ -407,6 +407,6 @@ MatrixBase::bidiagonalization() const } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_BIDIAGONALIZATION_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCholesky/SimplicialCholesky.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCholesky/SimplicialCholesky.h index 1343eb15c..00e75e6c0 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCholesky/SimplicialCholesky.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCholesky/SimplicialCholesky.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SIMPLICIAL_CHOLESKY_H #define EIGEN_SIMPLICIAL_CHOLESKY_H -namespace Eigen { +namespace StormEigen { enum SimplicialCholeskyMode { SimplicialCholeskyLLT, @@ -279,8 +279,8 @@ template struct traits CholMatrixType; - typedef TriangularView MatrixL; - typedef TriangularView MatrixU; + typedef TriangularView MatrixL; + typedef TriangularView MatrixU; static inline MatrixL getL(const MatrixType& m) { return MatrixL(m); } static inline MatrixU getU(const MatrixType& m) { return MatrixU(m.adjoint()); } }; @@ -293,8 +293,8 @@ template struct traits CholMatrixType; - typedef TriangularView MatrixL; - typedef TriangularView MatrixU; + typedef TriangularView MatrixL; + typedef TriangularView MatrixU; static inline MatrixL getL(const MatrixType& m) { return MatrixL(m); } static inline MatrixU getU(const MatrixType& m) { return MatrixU(m.adjoint()); } }; @@ -686,6 +686,6 @@ void SimplicialCholeskyBase::ordering(const MatrixType& a, ConstCholMat } } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SIMPLICIAL_CHOLESKY_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h index 31e06995b..2ddcb9882 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h @@ -45,7 +45,7 @@ LDL License: #ifndef EIGEN_SIMPLICIAL_CHOLESKY_IMPL_H #define EIGEN_SIMPLICIAL_CHOLESKY_IMPL_H -namespace Eigen { +namespace StormEigen { template void SimplicialCholeskyBase::analyzePattern_preordered(const CholMatrixType& ap, bool doLDLT) @@ -194,6 +194,6 @@ void SimplicialCholeskyBase::factorize_preordered(const CholMatrixType& m_factorizationIsOk = true; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SIMPLICIAL_CHOLESKY_IMPL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/AmbiVector.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/AmbiVector.h index 1233e164e..b5c45c0dc 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/AmbiVector.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/AmbiVector.h @@ -10,7 +10,7 @@ #ifndef EIGEN_AMBIVECTOR_H #define EIGEN_AMBIVECTOR_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -372,6 +372,6 @@ class AmbiVector<_Scalar,_StorageIndex>::Iterator } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_AMBIVECTOR_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/CompressedStorage.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/CompressedStorage.h index 2199848e9..61996074b 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/CompressedStorage.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/CompressedStorage.h @@ -10,7 +10,7 @@ #ifndef EIGEN_COMPRESSED_STORAGE_H #define EIGEN_COMPRESSED_STORAGE_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -248,6 +248,6 @@ class CompressedStorage } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_COMPRESSED_STORAGE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h index 0f6835846..db646f918 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h @@ -10,7 +10,7 @@ #ifndef EIGEN_CONSERVATIVESPARSESPARSEPRODUCT_H #define EIGEN_CONSERVATIVESPARSESPARSEPRODUCT_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -340,6 +340,6 @@ struct sparse_sparse_to_dense_product_selector > * \class MappedSparseMatrix @@ -62,6 +62,6 @@ struct evaluator > } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_MAPPED_SPARSEMATRIX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseAssign.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseAssign.h index 4a8dd12e4..ccd23bdfa 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseAssign.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseAssign.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSEASSIGN_H #define EIGEN_SPARSEASSIGN_H -namespace Eigen { +namespace StormEigen { template template @@ -200,6 +200,6 @@ struct Assignment }; } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSEASSIGN_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseBlock.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseBlock.h index 10be84856..703be7b16 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseBlock.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseBlock.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSE_BLOCK_H #define EIGEN_SPARSE_BLOCK_H -namespace Eigen { +namespace StormEigen { // Subset of columns or rows template @@ -581,6 +581,6 @@ struct unary_evaluator class SparseCompressedBase; @@ -37,8 +37,8 @@ class SparseCompressedBase protected: typedef typename Base::IndexVector IndexVector; - Eigen::Map innerNonZeros() { return Eigen::Map(innerNonZeroPtr(), isCompressed()?0:derived().outerSize()); } - const Eigen::Map innerNonZeros() const { return Eigen::Map(innerNonZeroPtr(), isCompressed()?0:derived().outerSize()); } + StormEigen::Map innerNonZeros() { return StormEigen::Map(innerNonZeroPtr(), isCompressed()?0:derived().outerSize()); } + const StormEigen::Map innerNonZeros() const { return StormEigen::Map(innerNonZeroPtr(), isCompressed()?0:derived().outerSize()); } public: @@ -272,6 +272,6 @@ struct evaluator > } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSE_COMPRESSED_BASE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseCwiseBinaryOp.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseCwiseBinaryOp.h index d9420ac63..7648e41d2 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseCwiseBinaryOp.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSE_CWISE_BINARY_OP_H #define EIGEN_SPARSE_CWISE_BINARY_OP_H -namespace Eigen { +namespace StormEigen { // Here we have to handle 3 cases: // 1 - sparse op dense @@ -428,6 +428,6 @@ SparseMatrixBase::cwiseProduct(const MatrixBase &other) c return typename CwiseProductDenseReturnType::Type(derived(), other.derived()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSE_CWISE_BINARY_OP_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseCwiseUnaryOp.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseCwiseUnaryOp.h index fe4a97120..6d79ab5e4 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseCwiseUnaryOp.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSE_CWISE_UNARY_OP_H #define EIGEN_SPARSE_CWISE_UNARY_OP_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -193,6 +193,6 @@ SparseMatrixBase::operator/=(const Scalar& other) return derived(); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSE_CWISE_UNARY_OP_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseDenseProduct.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseDenseProduct.h index 87c946b9b..848493a77 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseDenseProduct.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseDenseProduct.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSEDENSEPRODUCT_H #define EIGEN_SPARSEDENSEPRODUCT_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -37,8 +37,8 @@ struct sparse_time_dense_product_impl, OuterProduct, DenseS } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSEDENSEPRODUCT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseDiagonalProduct.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseDiagonalProduct.h index e4af49e09..1354f28f6 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseDiagonalProduct.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseDiagonalProduct.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSE_DIAGONAL_PRODUCT_H #define EIGEN_SPARSE_DIAGONAL_PRODUCT_H -namespace Eigen { +namespace StormEigen { // The product of a diagonal matrix with a sparse matrix can be easily // implemented using expression template. @@ -129,6 +129,6 @@ protected: } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSE_DIAGONAL_PRODUCT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseDot.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseDot.h index 38bc4aa9e..227357705 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseDot.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseDot.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSE_DOT_H #define EIGEN_SPARSE_DOT_H -namespace Eigen { +namespace StormEigen { template template @@ -93,6 +93,6 @@ SparseMatrixBase::blueNorm() const { return internal::blueNorm_impl(*this); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSE_DOT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseFuzzy.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseFuzzy.h index 7d47eb94d..077be230c 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseFuzzy.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseFuzzy.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSE_FUZZY_H #define EIGEN_SPARSE_FUZZY_H -namespace Eigen { +namespace StormEigen { template template @@ -24,6 +24,6 @@ bool SparseMatrixBase::isApprox(const SparseMatrixBase& o return (actualA - actualB).squaredNorm() <= prec * prec * numext::mini(actualA.squaredNorm(), actualB.squaredNorm()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSE_FUZZY_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseMap.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseMap.h index 36c09ab0c..0b4368126 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseMap.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseMap.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSE_MAP_H #define EIGEN_SPARSE_MAP_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -249,6 +249,6 @@ struct evaluator, Options, } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSE_MAP_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseMatrix.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseMatrix.h index 1fd628790..041d805a6 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseMatrix.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseMatrix.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSEMATRIX_H #define EIGEN_SPARSEMATRIX_H -namespace Eigen { +namespace StormEigen { /** \ingroup SparseCore_Module * @@ -271,7 +271,7 @@ class SparseMatrix const value_type& operator[](i) const; \endcode * for \c i in the [0,this->outerSize()[ range. - * Typical choices include std::vector, Eigen::VectorXi, Eigen::VectorXi::Constant, etc. + * Typical choices include std::vector, StormEigen::VectorXi, StormEigen::VectorXi::Constant, etc. */ template inline void reserve(const SizesType& reserveSizes); @@ -735,9 +735,9 @@ class SparseMatrix { eigen_assert(rows() == cols() && "ONLY FOR SQUARED MATRICES"); this->m_data.resize(rows()); - Eigen::Map(&this->m_data.index(0), rows()).setLinSpaced(0, StorageIndex(rows()-1)); - Eigen::Map(&this->m_data.value(0), rows()).setOnes(); - Eigen::Map(this->m_outerIndex, rows()+1).setLinSpaced(0, StorageIndex(rows())); + StormEigen::Map(&this->m_data.index(0), rows()).setLinSpaced(0, StorageIndex(rows()-1)); + StormEigen::Map(&this->m_data.value(0), rows()).setOnes(); + StormEigen::Map(this->m_outerIndex, rows()+1).setLinSpaced(0, StorageIndex(rows())); std::free(m_innerNonZeros); m_innerNonZeros = 0; } @@ -949,7 +949,7 @@ void set_from_triplets(const InputIterator& begin, const InputIterator& end, Spa * Scalar row() const; // the row index i * Scalar col() const; // the column index j * \endcode - * See for instance the Eigen::Triplet template class. + * See for instance the StormEigen::Triplet template class. * * Here is a typical usage example: * \code @@ -1062,7 +1062,7 @@ EIGEN_DONT_INLINE SparseMatrix& SparseMatrix (dest.m_outerIndex,dest.outerSize()).setZero(); + StormEigen::Map (dest.m_outerIndex,dest.outerSize()).setZero(); // pass 1 // FIXME the above copy could be merged with that pass @@ -1380,6 +1380,6 @@ struct evaluator > } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSEMATRIX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseMatrixBase.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseMatrixBase.h index 648ae1f8a..4f3ca7799 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseMatrixBase.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseMatrixBase.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSEMATRIXBASE_H #define EIGEN_SPARSEMATRIXBASE_H -namespace Eigen { +namespace StormEigen { /** \ingroup SparseCore_Module * @@ -106,7 +106,7 @@ template class SparseMatrixBase /** \internal the return type of MatrixBase::adjoint() */ typedef typename internal::conditional::IsComplex, - CwiseUnaryOp, Eigen::Transpose >, + CwiseUnaryOp, StormEigen::Transpose >, Transpose >::type AdjointReturnType; typedef Transpose TransposeReturnType; @@ -147,7 +147,7 @@ template class SparseMatrixBase using Base::operator/; #endif // not EIGEN_PARSED_BY_DOXYGEN -#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase +#define EIGEN_CURRENT_STORAGE_BASE_CLASS StormEigen::SparseMatrixBase # include "../plugins/CommonCwiseUnaryOps.h" # include "../plugins/CommonCwiseBinaryOps.h" # include "../plugins/MatrixCwiseUnaryOps.h" @@ -385,6 +385,6 @@ template class SparseMatrixBase template void evalTo(Dest &) const; }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSEMATRIXBASE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparsePermutation.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparsePermutation.h index ef38357ae..618313082 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparsePermutation.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparsePermutation.h @@ -12,7 +12,7 @@ // This file implements sparse * permutation products -namespace Eigen { +namespace StormEigen { namespace internal { @@ -173,6 +173,6 @@ operator*(const InverseImpl& tperm, const Sp return Product, SparseDerived, AliasFreeProduct>(tperm.derived(), matrix.derived()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSE_SELFADJOINTVIEW_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseProduct.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseProduct.h index cbd0db71b..05c3bc236 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseProduct.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseProduct.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSEPRODUCT_H #define EIGEN_SPARSEPRODUCT_H -namespace Eigen { +namespace StormEigen { /** \returns an expression of the product of two sparse matrices. * By default a conservative product preserving the symbolic non zeros is performed. @@ -159,6 +159,6 @@ protected: } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSEPRODUCT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseRedux.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseRedux.h index 50ebb2e53..315d3c032 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseRedux.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseRedux.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSEREDUX_H #define EIGEN_SPARSEREDUX_H -namespace Eigen { +namespace StormEigen { template typename internal::traits::Scalar @@ -41,6 +41,6 @@ SparseVector<_Scalar,_Options,_Index>::sum() const return Matrix::Map(&m_data.value(0), m_data.size()).sum(); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSEREDUX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseRef.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseRef.h index 19e06fc80..27132dab9 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseRef.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseRef.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSE_REF_H #define EIGEN_SPARSE_REF_H -namespace Eigen { +namespace StormEigen { enum { StandardCompressedFormat = 2 @@ -362,6 +362,6 @@ struct evaluator, Options, } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSE_REF_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseSelfAdjointView.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseSelfAdjointView.h index 46c6ce1d3..f20c07adb 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseSelfAdjointView.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseSelfAdjointView.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSE_SELFADJOINTVIEW_H #define EIGEN_SPARSE_SELFADJOINTVIEW_H -namespace Eigen { +namespace StormEigen { /** \ingroup SparseCore_Module * \class SparseSelfAdjointView @@ -602,6 +602,6 @@ struct Assignment } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSE_SELFADJOINTVIEW_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseSolverBase.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseSolverBase.h index 1cb7080cf..f20b4a1f6 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseSolverBase.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseSolverBase.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSESOLVERBASE_H #define EIGEN_SPARSESOLVERBASE_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -29,8 +29,8 @@ void solve_sparse_through_dense_panels(const Decomposition &dec, const Rhs& rhs, Index size = rhs.rows(); // the temporary matrices do not need more columns than NbColsAtOnce: Index tmpCols = (std::min)(rhsCols, NbColsAtOnce); - Eigen::Matrix tmp(size,tmpCols); - Eigen::Matrix tmpX(size,tmpCols); + StormEigen::Matrix tmp(size,tmpCols); + StormEigen::Matrix tmpX(size,tmpCols); for(Index k=0; k(rhsCols-k, NbColsAtOnce); @@ -105,6 +105,6 @@ class SparseSolverBase : internal::noncopyable mutable bool m_isInitialized; }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSESOLVERBASE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseSparseProductWithPruning.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseSparseProductWithPruning.h index 20078f72c..b14b59bc0 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseSparseProductWithPruning.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSESPARSEPRODUCTWITHPRUNING_H #define EIGEN_SPARSESPARSEPRODUCTWITHPRUNING_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -193,6 +193,6 @@ struct sparse_sparse_product_with_pruning_selector @@ -99,6 +99,6 @@ struct unary_evaluator, IteratorBased> } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSETRANSPOSE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseTriangularView.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseTriangularView.h index 7c718e4e1..b05964e5e 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseTriangularView.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseTriangularView.h @@ -11,7 +11,7 @@ #ifndef EIGEN_SPARSE_TRIANGULARVIEW_H #define EIGEN_SPARSE_TRIANGULARVIEW_H -namespace Eigen { +namespace StormEigen { /** \ingroup SparseCore_Module * @@ -284,6 +284,6 @@ SparseMatrixBase::triangularView() const return TriangularView(derived()); } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSE_TRIANGULARVIEW_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseUtil.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseUtil.h index 74df0d496..b84ab545b 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseUtil.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseUtil.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSEUTIL_H #define EIGEN_SPARSEUTIL_H -namespace Eigen { +namespace StormEigen { #ifdef NDEBUG #define EIGEN_DBG_SPARSE(X) @@ -20,7 +20,7 @@ namespace Eigen { #define EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \ template \ -EIGEN_STRONG_INLINE Derived& operator Op(const Eigen::SparseMatrixBase& other) \ +EIGEN_STRONG_INLINE Derived& operator Op(const StormEigen::SparseMatrixBase& other) \ { \ return Base::operator Op(other.derived()); \ } \ @@ -173,6 +173,6 @@ protected: Scalar m_value; }; -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSEUTIL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseVector.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseVector.h index 2cfcae35b..c4e4228cf 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseVector.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseVector.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSEVECTOR_H #define EIGEN_SPARSEVECTOR_H -namespace Eigen { +namespace StormEigen { /** \ingroup SparseCore_Module * \class SparseVector @@ -430,6 +430,6 @@ struct sparse_vector_assign_selector { } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSEVECTOR_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseView.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseView.h index c945c4dab..3428a07db 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseView.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/SparseView.h @@ -11,7 +11,7 @@ #ifndef EIGEN_SPARSEVIEW_H #define EIGEN_SPARSEVIEW_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -217,6 +217,6 @@ SparseMatrixBase::pruned(const Scalar& reference, return SparseView(derived(), reference, epsilon); } -} // end namespace Eigen +} // end namespace StormEigen #endif diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/TriangularSolver.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/TriangularSolver.h index 19f8f6704..494d498af 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/TriangularSolver.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseCore/TriangularSolver.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSETRIANGULARSOLVER_H #define EIGEN_SPARSETRIANGULARSOLVER_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -305,6 +305,6 @@ void TriangularViewImpl::solveInPlace(SparseMatrixBa // other = otherCopy; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSETRIANGULARSOLVER_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU.h index 04e602e1b..22ef79c9f 100755 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU.h @@ -11,7 +11,7 @@ #ifndef EIGEN_SPARSE_LU_H #define EIGEN_SPARSE_LU_H -namespace Eigen { +namespace StormEigen { template > class SparseLU; template struct SparseLUMatrixLReturnType; @@ -769,6 +769,6 @@ struct SparseLUMatrixUReturnType : internal::no_assignment_operator const MatrixUType& m_mapU; }; -} // End namespace Eigen +} // End namespace StormEigen #endif diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLUImpl.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLUImpl.h index 81ac38c1e..cf3f700d9 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLUImpl.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLUImpl.h @@ -9,7 +9,7 @@ #ifndef SPARSELU_IMPL_H #define SPARSELU_IMPL_H -namespace Eigen { +namespace StormEigen { namespace internal { /** \ingroup SparseLU_Module @@ -62,6 +62,6 @@ class SparseLUImpl }; } // end namespace internal -} // namespace Eigen +} // namespace StormEigen #endif diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_Memory.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_Memory.h index 4dc42e87b..a6ff7eccd 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_Memory.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_Memory.h @@ -31,7 +31,7 @@ #ifndef EIGEN_SPARSELU_MEMORY #define EIGEN_SPARSELU_MEMORY -namespace Eigen { +namespace StormEigen { namespace internal { enum { LUNoMarker = 3 }; @@ -222,5 +222,5 @@ Index SparseLUImpl::memXpand(VectorType& vec, Index& maxlen } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSELU_MEMORY diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_Structs.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_Structs.h index cf5ec449b..c6c113646 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_Structs.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_Structs.h @@ -68,7 +68,7 @@ #ifndef EIGEN_LU_STRUCTS #define EIGEN_LU_STRUCTS -namespace Eigen { +namespace StormEigen { namespace internal { typedef enum {LUSUP, UCOL, LSUB, USUB, LLVL, ULVL} MemType; @@ -106,5 +106,5 @@ struct perfvalues { } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_LU_STRUCTS diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h index f0856db85..9e652e06e 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h @@ -11,7 +11,7 @@ #ifndef EIGEN_SPARSELU_SUPERNODAL_MATRIX_H #define EIGEN_SPARSELU_SUPERNODAL_MATRIX_H -namespace Eigen { +namespace StormEigen { namespace internal { /** \ingroup SparseLU_Module @@ -296,6 +296,6 @@ void MappedSuperNodalMatrix::solveInPlace( MatrixBase&X) co } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSELU_MATRIX_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_Utils.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_Utils.h index 9e3dab44d..0b7ac7b41 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_Utils.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_Utils.h @@ -11,7 +11,7 @@ #ifndef EIGEN_SPARSELU_UTILS_H #define EIGEN_SPARSELU_UTILS_H -namespace Eigen { +namespace StormEigen { namespace internal { /** @@ -76,5 +76,5 @@ void SparseLUImpl::fixupL(const Index n, const IndexVector& } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_SPARSELU_UTILS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_column_bmod.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_column_bmod.h index e5764b128..e75767f76 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_column_bmod.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_column_bmod.h @@ -31,7 +31,7 @@ #ifndef SPARSELU_COLUMN_BMOD_H #define SPARSELU_COLUMN_BMOD_H -namespace Eigen { +namespace StormEigen { namespace internal { /** @@ -176,6 +176,6 @@ Index SparseLUImpl::column_bmod(const Index jcol, const Ind } } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // SPARSELU_COLUMN_BMOD_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_column_dfs.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_column_dfs.h index c98b30e32..00888932e 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_column_dfs.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_column_dfs.h @@ -31,7 +31,7 @@ #define SPARSELU_COLUMN_DFS_H template class SparseLUImpl; -namespace Eigen { +namespace StormEigen { namespace internal { @@ -174,6 +174,6 @@ Index SparseLUImpl::column_dfs(const Index m, const Index j } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h index 9a5608b90..af04f1d5f 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h @@ -29,7 +29,7 @@ #ifndef SPARSELU_COPY_TO_UCOL_H #define SPARSELU_COPY_TO_UCOL_H -namespace Eigen { +namespace StormEigen { namespace internal { /** @@ -102,6 +102,6 @@ Index SparseLUImpl::copy_to_ucol(const Index jcol, const In } } // namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // SPARSELU_COPY_TO_UCOL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_gemm_kernel.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_gemm_kernel.h index ae3685ac8..cb3991bf7 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_gemm_kernel.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SPARSELU_GEMM_KERNEL_H #define EIGEN_SPARSELU_GEMM_KERNEL_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -25,7 +25,7 @@ template EIGEN_DONT_INLINE void sparselu_gemm(Index m, Index n, Index d, const Scalar* A, Index lda, const Scalar* B, Index ldb, Scalar* C, Index ldc) { - using namespace Eigen::internal; + using namespace StormEigen::internal; typedef typename packet_traits::type Packet; enum { @@ -274,6 +274,6 @@ void sparselu_gemm(Index m, Index n, Index d, const Scalar* A, Index lda, const } // namespace internal -} // namespace Eigen +} // namespace StormEigen #endif // EIGEN_SPARSELU_GEMM_KERNEL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h index 6f75d500e..4516b28c7 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h @@ -28,7 +28,7 @@ #ifndef SPARSELU_HEAP_RELAX_SNODE_H #define SPARSELU_HEAP_RELAX_SNODE_H -namespace Eigen { +namespace StormEigen { namespace internal { /** @@ -122,5 +122,5 @@ void SparseLUImpl::heap_relax_snode (const Index n, IndexVe } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // SPARSELU_HEAP_RELAX_SNODE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_kernel_bmod.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_kernel_bmod.h index e71a13b89..855154859 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_kernel_bmod.h @@ -11,7 +11,7 @@ #ifndef SPARSELU_KERNEL_BMOD_H #define SPARSELU_KERNEL_BMOD_H -namespace Eigen { +namespace StormEigen { namespace internal { /** @@ -127,5 +127,5 @@ EIGEN_DONT_INLINE void LU_kernel_bmod<1>::run(const Index /*segsize*/, BlockScal } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // SPARSELU_KERNEL_BMOD_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_panel_bmod.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_panel_bmod.h index 3c1f37398..906d84559 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_panel_bmod.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_panel_bmod.h @@ -31,7 +31,7 @@ #ifndef SPARSELU_PANEL_BMOD_H #define SPARSELU_PANEL_BMOD_H -namespace Eigen { +namespace StormEigen { namespace internal { /** @@ -218,6 +218,6 @@ void SparseLUImpl::panel_bmod(const Index m, const Index w, } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // SPARSELU_PANEL_BMOD_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_panel_dfs.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_panel_dfs.h index 155df7336..cfbe671a1 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_panel_dfs.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_panel_dfs.h @@ -30,7 +30,7 @@ #ifndef SPARSELU_PANEL_DFS_H #define SPARSELU_PANEL_DFS_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -253,6 +253,6 @@ void SparseLUImpl::panel_dfs(const Index m, const Index w, } } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // SPARSELU_PANEL_DFS_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_pivotL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_pivotL.h index 3bbe074c2..9c552da64 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_pivotL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_pivotL.h @@ -30,7 +30,7 @@ #ifndef SPARSELU_PIVOTL_H #define SPARSELU_PIVOTL_H -namespace Eigen { +namespace StormEigen { namespace internal { template::value, int>::type = 0> @@ -163,6 +163,6 @@ Index SparseLUImpl::pivotL(const Index jcol, const RealScal } } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // SPARSELU_PIVOTL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_pruneL.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_pruneL.h index ad32fed5e..3e1b94f51 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_pruneL.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_pruneL.h @@ -30,7 +30,7 @@ #ifndef SPARSELU_PRUNEL_H #define SPARSELU_PRUNEL_H -namespace Eigen { +namespace StormEigen { namespace internal { /** @@ -131,6 +131,6 @@ void SparseLUImpl::pruneL(const Index jcol, const IndexVect } } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif // SPARSELU_PRUNEL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_relax_snode.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_relax_snode.h index c408d01b4..43031df77 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_relax_snode.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseLU/SparseLU_relax_snode.h @@ -28,7 +28,7 @@ #ifndef SPARSELU_RELAX_SNODE_H #define SPARSELU_RELAX_SNODE_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -79,5 +79,5 @@ void SparseLUImpl::relax_snode (const Index n, IndexVector& } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseQR/SparseQR.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseQR/SparseQR.h index 4f26c19ca..ec5c44e6c 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseQR/SparseQR.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SparseQR/SparseQR.h @@ -11,7 +11,7 @@ #ifndef EIGEN_SPARSE_QR_H #define EIGEN_SPARSE_QR_H -namespace Eigen { +namespace StormEigen { template class SparseQR; template struct SparseQRMatrixQReturnType; @@ -724,6 +724,6 @@ struct Assignment, internal: } // end namespace internal -} // end namespace Eigen +} // end namespace StormEigen #endif diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/StdDeque.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/StdDeque.h index 25930cb85..5f9f2f102 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/StdDeque.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/StdDeque.h @@ -79,10 +79,10 @@ namespace std { template class deque > : public deque > + StormEigen::aligned_allocator_indirection > { typedef deque > deque_base; + StormEigen::aligned_allocator_indirection > deque_base; EIGEN_STD_DEQUE_SPECIALIZATION_BODY void resize(size_type new_size) diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/StdList.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/StdList.h index 7412b50aa..463d0259d 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/StdList.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/StdList.h @@ -79,10 +79,10 @@ namespace std template class list > : public list > + StormEigen::aligned_allocator_indirection > { typedef list > list_base; + StormEigen::aligned_allocator_indirection > list_base; EIGEN_STD_LIST_SPECIALIZATION_BODY void resize(size_type new_size) diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/StdVector.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/StdVector.h index ec22821d2..20ba970ee 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/StdVector.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/StdVector.h @@ -71,10 +71,10 @@ namespace std { template class vector > : public vector > + StormEigen::aligned_allocator_indirection > { typedef vector > vector_base; + StormEigen::aligned_allocator_indirection > vector_base; EIGEN_STD_VECTOR_SPECIALIZATION_BODY void resize(size_type new_size) diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/details.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/details.h index e42ec024f..afcab21f6 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/details.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/StlSupport/details.h @@ -12,10 +12,10 @@ #define EIGEN_STL_DETAILS_H #ifndef EIGEN_ALIGNED_ALLOCATOR - #define EIGEN_ALIGNED_ALLOCATOR Eigen::aligned_allocator + #define EIGEN_ALIGNED_ALLOCATOR StormEigen::aligned_allocator #endif -namespace Eigen { +namespace StormEigen { // This one is needed to prevent reimplementing the whole std::vector. template @@ -52,10 +52,10 @@ namespace Eigen { // in std::vector::resize(size_t s,T x) won't be aligned and generate an error // even if this function is never called. Whence this little wrapper. #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) \ - typename Eigen::internal::conditional< \ - Eigen::internal::is_arithmetic::value, \ + typename StormEigen::internal::conditional< \ + StormEigen::internal::is_arithmetic::value, \ T, \ - Eigen::internal::workaround_msvc_stl_support \ + StormEigen::internal::workaround_msvc_stl_support \ >::type namespace internal { diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SuperLUSupport/SuperLUSupport.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SuperLUSupport/SuperLUSupport.h index fd2b26581..58d34f8b2 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SuperLUSupport/SuperLUSupport.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/SuperLUSupport/SuperLUSupport.h @@ -10,7 +10,7 @@ #ifndef EIGEN_SUPERLUSUPPORT_H #define EIGEN_SUPERLUSUPPORT_H -namespace Eigen { +namespace StormEigen { #define DECL_GSSVX(PREFIX,FLOATTYPE,KEYTYPE) \ extern "C" { \ @@ -993,6 +993,6 @@ void SuperILU::_solve_impl(const MatrixBase &b, MatrixBase::_solve_impl(const MatrixBase &b, MatrixBas return true; } -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_UMFPACKSUPPORT_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/misc/Image.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/misc/Image.h index b8b8a0455..8d4adc084 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/misc/Image.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/misc/Image.h @@ -10,7 +10,7 @@ #ifndef EIGEN_MISC_IMAGE_H #define EIGEN_MISC_IMAGE_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -68,7 +68,7 @@ template struct image_retval_base typedef typename DecompositionType::MatrixType MatrixType; \ typedef typename MatrixType::Scalar Scalar; \ typedef typename MatrixType::RealScalar RealScalar; \ - typedef Eigen::internal::image_retval_base Base; \ + typedef StormEigen::internal::image_retval_base Base; \ using Base::dec; \ using Base::originalMatrix; \ using Base::rank; \ @@ -77,6 +77,6 @@ template struct image_retval_base image_retval(const DecompositionType& dec, const MatrixType& originalMatrix) \ : Base(dec, originalMatrix) {} -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_MISC_IMAGE_H diff --git a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/misc/Kernel.h b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/misc/Kernel.h index bef5d6ff5..5afd4c911 100644 --- a/resources/3rdparty/eigen-3.3-beta1/Eigen/src/misc/Kernel.h +++ b/resources/3rdparty/eigen-3.3-beta1/Eigen/src/misc/Kernel.h @@ -10,7 +10,7 @@ #ifndef EIGEN_MISC_KERNEL_H #define EIGEN_MISC_KERNEL_H -namespace Eigen { +namespace StormEigen { namespace internal { @@ -67,13 +67,13 @@ template struct kernel_retval_base typedef typename DecompositionType::MatrixType MatrixType; \ typedef typename MatrixType::Scalar Scalar; \ typedef typename MatrixType::RealScalar RealScalar; \ - typedef Eigen::internal::kernel_retval_base Base; \ + typedef StormEigen::internal::kernel_retval_base Base; \ using Base::dec; \ using Base::rank; \ using Base::rows; \ using Base::cols; \ kernel_retval(const DecompositionType& dec) : Base(dec) {} -} // end namespace Eigen +} // end namespace StormEigen #endif // EIGEN_MISC_KERNEL_H diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/BenchSparseUtil.h b/resources/3rdparty/eigen-3.3-beta1/bench/BenchSparseUtil.h index 13981f6b7..366982b50 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/BenchSparseUtil.h +++ b/resources/3rdparty/eigen-3.3-beta1/bench/BenchSparseUtil.h @@ -4,8 +4,8 @@ #include using namespace std; -using namespace Eigen; -using namespace Eigen; +using namespace StormEigen; +using namespace StormEigen; #ifndef SIZE #define SIZE 1024 diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/BenchTimer.h b/resources/3rdparty/eigen-3.3-beta1/bench/BenchTimer.h index 64666d75f..ad0c746c6 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/BenchTimer.h +++ b/resources/3rdparty/eigen-3.3-beta1/bench/BenchTimer.h @@ -38,7 +38,7 @@ static void clobber() { #include -namespace Eigen +namespace StormEigen { enum { diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/BenchUtil.h b/resources/3rdparty/eigen-3.3-beta1/bench/BenchUtil.h index 8883a1380..438ee5a16 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/BenchUtil.h +++ b/resources/3rdparty/eigen-3.3-beta1/bench/BenchUtil.h @@ -6,7 +6,7 @@ #include "BenchTimer.h" using namespace std; -using namespace Eigen; +using namespace StormEigen; #include #include diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/basicbenchmark.h b/resources/3rdparty/eigen-3.3-beta1/bench/basicbenchmark.h index 3fdc35732..036c09792 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/basicbenchmark.h +++ b/resources/3rdparty/eigen-3.3-beta1/bench/basicbenchmark.h @@ -15,19 +15,19 @@ void benchBasic_loop(const MatrixType& I, MatrixType& m, int iterations) if (Mode==LazyEval) { asm("#begin_bench_loop LazyEval"); - if (MatrixType::SizeAtCompileTime!=Eigen::Dynamic) asm("#fixedsize"); + if (MatrixType::SizeAtCompileTime!=StormEigen::Dynamic) asm("#fixedsize"); m = (I + 0.00005 * (m + m.lazy() * m)).eval(); } else if (Mode==OmpEval) { asm("#begin_bench_loop OmpEval"); - if (MatrixType::SizeAtCompileTime!=Eigen::Dynamic) asm("#fixedsize"); + if (MatrixType::SizeAtCompileTime!=StormEigen::Dynamic) asm("#fixedsize"); m = (I + 0.00005 * (m + m.lazy() * m)).evalOMP(); } else { asm("#begin_bench_loop EarlyEval"); - if (MatrixType::SizeAtCompileTime!=Eigen::Dynamic) asm("#fixedsize"); + if (MatrixType::SizeAtCompileTime!=StormEigen::Dynamic) asm("#fixedsize"); m = I + 0.00005 * (m + m * m); } asm("#end_bench_loop"); @@ -48,7 +48,7 @@ double benchBasic(const MatrixType& mat, int iterations, int tries) initMatrix_identity(I); - Eigen::BenchTimer timer; + StormEigen::BenchTimer timer; for(uint t=0; t MyMatrix; +typedef StormEigen::Matrix MyMatrix; void bench_eigengemm(MyMatrix& mc, const MyMatrix& ma, const MyMatrix& mb, int nbloops); void check_product(int M, int N, int K); void check_product(void); @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) mb = MyMatrix::Random(K,N); mc = MyMatrix::Random(M,N); - Eigen::BenchTimer timer; + StormEigen::BenchTimer timer; // we simply compute c += a*b, so: alpha = 1; @@ -153,14 +153,14 @@ int main(int argc, char *argv[]) std::cout << M << " : " << timer.value() << " ; " << 1e-3*floor(1e-6*nbmad/timer.value()) << "\n"; } - std::cout << "l1: " << Eigen::l1CacheSize() << std::endl; - std::cout << "l2: " << Eigen::l2CacheSize() << std::endl; + std::cout << "l1: " << StormEigen::l1CacheSize() << std::endl; + std::cout << "l2: " << StormEigen::l2CacheSize() << std::endl; return 0; } -using namespace Eigen; +using namespace StormEigen; void bench_eigengemm(MyMatrix& mc, const MyMatrix& ma, const MyMatrix& mb, int nbloops) { diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/benchCholesky.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/benchCholesky.cpp index 42b3e1285..a9f02f020 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/benchCholesky.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/benchCholesky.cpp @@ -13,7 +13,7 @@ #include #include #include -using namespace Eigen; +using namespace StormEigen; #ifndef REPEAT #define REPEAT 10000 diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/benchEigenSolver.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/benchEigenSolver.cpp index dd78c7e01..3081750f7 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/benchEigenSolver.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/benchEigenSolver.cpp @@ -14,7 +14,7 @@ #include #include #include -using namespace Eigen; +using namespace StormEigen; #ifndef REPEAT #define REPEAT 1000 diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/benchFFT.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/benchFFT.cpp index 3eb1a1ac0..efc4765de 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/benchFFT.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/benchFFT.cpp @@ -16,7 +16,7 @@ #include -using namespace Eigen; +using namespace StormEigen; using namespace std; @@ -38,7 +38,7 @@ template <> string nameof() {return "long double";} #define NDATA 1000000 #endif -using namespace Eigen; +using namespace StormEigen; template void bench(int nfft,bool fwd,bool unscaled=false, bool halfspec=false) diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/benchGeometry.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/benchGeometry.cpp index 6e16c0331..2ea5f3381 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/benchGeometry.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/benchGeometry.cpp @@ -4,7 +4,7 @@ #include #include -using namespace Eigen; +using namespace StormEigen; using namespace std; #ifndef REPEAT diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/benchVecAdd.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/benchVecAdd.cpp index ce8e1e911..41b8c61d0 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/benchVecAdd.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/benchVecAdd.cpp @@ -2,7 +2,7 @@ #include #include #include -using namespace Eigen; +using namespace StormEigen; #ifndef SIZE #define SIZE 50 diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/bench_gemm.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/bench_gemm.cpp index 8528c5587..ab98f0806 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/bench_gemm.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/bench_gemm.cpp @@ -15,7 +15,7 @@ #include using namespace std; -using namespace Eigen; +using namespace StormEigen; #ifndef SCALAR // #define SCALAR std::complex @@ -222,7 +222,7 @@ int main(int argc, char ** argv) // check the parallel product is correct #if defined EIGEN_HAS_OPENMP - Eigen::initParallel(); + StormEigen::initParallel(); int procs = omp_get_max_threads(); if(procs>1) { @@ -274,7 +274,7 @@ int main(int argc, char ** argv) { BenchTimer tmono; omp_set_num_threads(1); - Eigen::setNbThreads(1); + StormEigen::setNbThreads(1); c = rc; BENCH(tmono, tries, rep, gemm(a,b,c)); std::cout << "eigen mono cpu " << tmono.best(CPU_TIMER)/rep << "s \t" << (double(m)*n*p*rep*2/tmono.best(CPU_TIMER))*1e-9 << " GFLOPS \t(" << tmono.total(CPU_TIMER) << "s)\n"; diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/bench_norm.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/bench_norm.cpp index 129afcfb2..2d921a286 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/bench_norm.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/bench_norm.cpp @@ -2,7 +2,7 @@ #include #include #include "BenchTimer.h" -using namespace Eigen; +using namespace StormEigen; using namespace std; template @@ -82,7 +82,7 @@ EIGEN_DONT_INLINE typename T::Scalar divacNorm(T& v) return std::sqrt(v(0)); } -namespace Eigen { +namespace StormEigen { namespace internal { #ifdef EIGEN_VECTORIZE Packet4f plt(const Packet4f& a, Packet4f& b) { return _mm_cmplt_ps(a,b); } @@ -224,7 +224,7 @@ EIGEN_DONT_INLINE typename T::Scalar pblueNorm(const T& v) #define BENCH_PERF(NRM) { \ float af = 0; double ad = 0; std::complex ac = 0; \ - Eigen::BenchTimer tf, td, tcf; tf.reset(); td.reset(); tcf.reset();\ + StormEigen::BenchTimer tf, td, tcf; tf.reset(); td.reset(); tcf.reset();\ for (int k=0; k #include #include -using namespace Eigen; +using namespace StormEigen; #ifndef REPEAT #define REPEAT 100000 diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/bench_sum.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/bench_sum.cpp index a3d925e4f..06b945f3a 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/bench_sum.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/bench_sum.cpp @@ -1,11 +1,11 @@ #include #include -using namespace Eigen; +using namespace StormEigen; using namespace std; int main() { - typedef Matrix Vec; + typedef Matrix Vec; Vec v(SIZE); v.setZero(); v[0] = 1; diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/benchmark-blocking-sizes.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/benchmark-blocking-sizes.cpp index 827be2880..dc234fe92 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/benchmark-blocking-sizes.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/benchmark-blocking-sizes.cpp @@ -25,7 +25,7 @@ int eigen_block_size_k, eigen_block_size_m, eigen_block_size_n; #include -using namespace Eigen; +using namespace StormEigen; using namespace std; static BenchTimer timer; diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/benchmark.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/benchmark.cpp index c721b9081..0b8b3e023 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/benchmark.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/benchmark.cpp @@ -9,7 +9,7 @@ #endif using namespace std; -using namespace Eigen; +using namespace StormEigen; #ifndef REPEAT #define REPEAT 40000000 diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/benchmarkSlice.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/benchmarkSlice.cpp index c5b89c545..f0ac09e9a 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/benchmarkSlice.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/benchmarkSlice.cpp @@ -5,7 +5,7 @@ #include using namespace std; -using namespace Eigen; +using namespace StormEigen; #ifndef REPEAT #define REPEAT 10000 @@ -17,17 +17,17 @@ using namespace Eigen; int main(int argc, char *argv[]) { - typedef Matrix Mat; + typedef Matrix Mat; Mat m(100, 100); m.setRandom(); for(int a = 0; a < REPEAT; a++) { int r, c, nr, nc; - r = Eigen::internal::random(0,10); - c = Eigen::internal::random(0,10); - nr = Eigen::internal::random(50,80); - nc = Eigen::internal::random(50,80); + r = StormEigen::internal::random(0,10); + c = StormEigen::internal::random(0,10); + nr = StormEigen::internal::random(50,80); + nc = StormEigen::internal::random(50,80); m.block(r,c,nr,nc) += Mat::Ones(nr,nc); m.block(r,c,nr,nc) *= SCALAR(10); m.block(r,c,nr,nc) -= Mat::constant(nr,nc,10); diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/benchmarkX.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/benchmarkX.cpp index 8e4b60c2b..9abfd4510 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/benchmarkX.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/benchmarkX.cpp @@ -5,7 +5,7 @@ #include using namespace std; -using namespace Eigen; +using namespace StormEigen; #ifndef MATTYPE #define MATTYPE MatrixXLd diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/benchmarkXcwise.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/benchmarkXcwise.cpp index 62437435e..8bacee9a6 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/benchmarkXcwise.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/benchmarkXcwise.cpp @@ -4,7 +4,7 @@ #include using namespace std; -using namespace Eigen; +using namespace StormEigen; #ifndef VECTYPE #define VECTYPE VectorXLd diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/btl/data/go_mean b/resources/3rdparty/eigen-3.3-beta1/bench/btl/data/go_mean index 42338ca27..cda34a6ef 100755 --- a/resources/3rdparty/eigen-3.3-beta1/bench/btl/data/go_mean +++ b/resources/3rdparty/eigen-3.3-beta1/bench/btl/data/go_mean @@ -55,4 +55,4 @@ fi ## compile the web page ## -#echo `cat footer.html` >> $webpagefilename \ No newline at end of file +#echo `cat footer.html` >> $webpagefilename diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/btl/libs/eigen2/eigen2_interface.hh b/resources/3rdparty/eigen-3.3-beta1/bench/btl/libs/eigen2/eigen2_interface.hh index 1deabdae2..61505167c 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/btl/libs/eigen2/eigen2_interface.hh +++ b/resources/3rdparty/eigen-3.3-beta1/bench/btl/libs/eigen2/eigen2_interface.hh @@ -25,7 +25,7 @@ #include #include "btl.hh" -using namespace Eigen; +using namespace StormEigen; template class eigen2_interface @@ -40,8 +40,8 @@ public : typedef std::vector stl_vector; typedef std::vector stl_matrix; - typedef Eigen::Matrix gene_matrix; - typedef Eigen::Matrix gene_vector; + typedef StormEigen::Matrix gene_matrix; + typedef StormEigen::Matrix gene_vector; static inline std::string name( void ) { diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/btl/libs/eigen3/eigen3_interface.hh b/resources/3rdparty/eigen-3.3-beta1/bench/btl/libs/eigen3/eigen3_interface.hh index b821fd721..691ca4e5e 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/btl/libs/eigen3/eigen3_interface.hh +++ b/resources/3rdparty/eigen-3.3-beta1/bench/btl/libs/eigen3/eigen3_interface.hh @@ -22,7 +22,7 @@ #include #include "btl.hh" -using namespace Eigen; +using namespace StormEigen; template class eigen3_interface @@ -37,8 +37,8 @@ public : typedef std::vector stl_vector; typedef std::vector stl_matrix; - typedef Eigen::Matrix gene_matrix; - typedef Eigen::Matrix gene_vector; + typedef StormEigen::Matrix gene_matrix; + typedef StormEigen::Matrix gene_vector; static inline std::string name( void ) { diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/btl/libs/tensors/tensor_interface.hh b/resources/3rdparty/eigen-3.3-beta1/bench/btl/libs/tensors/tensor_interface.hh index 97b8e0f0b..00e6574db 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/btl/libs/tensors/tensor_interface.hh +++ b/resources/3rdparty/eigen-3.3-beta1/bench/btl/libs/tensors/tensor_interface.hh @@ -13,20 +13,20 @@ #include #include "btl.hh" -using namespace Eigen; +using namespace StormEigen; template class tensor_interface { public : typedef real real_type; - typedef typename Eigen::Tensor::Index Index; + typedef typename StormEigen::Tensor::Index Index; typedef std::vector stl_vector; typedef std::vector stl_matrix; - typedef Eigen::Tensor gene_matrix; - typedef Eigen::Tensor gene_vector; + typedef StormEigen::Tensor gene_matrix; + typedef StormEigen::Tensor gene_vector; static inline std::string name( void ) @@ -39,11 +39,11 @@ public : static void free_vector(gene_vector & /*B*/) {} static BTL_DONT_INLINE void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){ - A.resize(Eigen::array(A_stl[0].size(), A_stl.size())); + A.resize(StormEigen::array(A_stl[0].size(), A_stl.size())); for (unsigned int j=0; j(i,j)) = A_stl[j][i]; + A.coeffRef(StormEigen::array(i,j)) = A_stl[j][i]; } } } @@ -68,20 +68,20 @@ public : for (int j=0;j(i,j)); + A_stl[j][i] = A.coeff(StormEigen::array(i,j)); } } } static inline void matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int /*N*/){ - typedef typename Eigen::Tensor::DimensionPair DimPair; - const Eigen::array dims(DimPair(1, 0)); + typedef typename StormEigen::Tensor::DimensionPair DimPair; + const StormEigen::array dims(DimPair(1, 0)); X/*.noalias()*/ = A.contract(B, dims); } static inline void matrix_vector_product(const gene_matrix & A, const gene_vector & B, gene_vector & X, int /*N*/){ - typedef typename Eigen::Tensor::DimensionPair DimPair; - const Eigen::array dims(DimPair(1, 0)); + typedef typename StormEigen::Tensor::DimensionPair DimPair; + const StormEigen::array dims(DimPair(1, 0)); X/*.noalias()*/ = A.contract(B, dims); } diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/check_cache_queries.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/check_cache_queries.cpp index 029d44cf6..a69db5462 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/check_cache_queries.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/check_cache_queries.cpp @@ -3,7 +3,7 @@ #include #include "../Eigen/Core" -using namespace Eigen; +using namespace StormEigen; using namespace std; #define DUMP_CPUID(CODE) {\ diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/dense_solvers.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/dense_solvers.cpp index f37a8bb5f..03eb2edb1 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/dense_solvers.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/dense_solvers.cpp @@ -3,7 +3,7 @@ #include #include #include -using namespace Eigen; +using namespace StormEigen; std::map > results; diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/eig33.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/eig33.cpp index 47947a9be..bf508dd4e 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/eig33.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/eig33.cpp @@ -42,7 +42,7 @@ #include #include -using namespace Eigen; +using namespace StormEigen; using namespace std; template @@ -132,7 +132,7 @@ void eigen33(const Matrix& mat, Matrix& evecs, Vector& evals) // evecs.col(2) = tmp.row(0).cross(tmp.row(1)).normalized(); // a more stable version: - if((evals(2)-evals(0))<=Eigen::NumTraits::epsilon()) + if((evals(2)-evals(0))<=StormEigen::NumTraits::epsilon()) { evecs.setIdentity(); } @@ -147,7 +147,7 @@ void eigen33(const Matrix& mat, Matrix& evecs, Vector& evals) tmp.diagonal ().array () -= evals (1); evecs.col(1) = tmp.row (0).cross(tmp.row (1)); Scalar n1 = evecs.col(1).norm(); - if(n1<=Eigen::NumTraits::epsilon()) + if(n1<=StormEigen::NumTraits::epsilon()) evecs.col(1) = evecs.col(2).unitOrthogonal(); else evecs.col(1) /= n1; diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/geometry.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/geometry.cpp index b187a515f..60af89786 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/geometry.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/geometry.cpp @@ -4,7 +4,7 @@ #include using namespace std; -using namespace Eigen; +using namespace StormEigen; #ifndef SCALAR #define SCALAR float diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/perf_monitoring/gemm/gemm.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/perf_monitoring/gemm/gemm.cpp index 614bd4737..64b1e5fa4 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/perf_monitoring/gemm/gemm.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/perf_monitoring/gemm/gemm.cpp @@ -3,7 +3,7 @@ #include #include #include "../../BenchTimer.h" -using namespace Eigen; +using namespace StormEigen; #ifndef SCALAR #error SCALAR must be defined diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/perf_monitoring/gemm/lazy_gemm.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/perf_monitoring/gemm/lazy_gemm.cpp index b443218d7..3d738abcd 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/perf_monitoring/gemm/lazy_gemm.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/perf_monitoring/gemm/lazy_gemm.cpp @@ -3,7 +3,7 @@ #include #include #include "../../BenchTimer.h" -using namespace Eigen; +using namespace StormEigen; #ifndef SCALAR #error SCALAR must be defined diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/perf_monitoring/gemm/make_plot.sh b/resources/3rdparty/eigen-3.3-beta1/bench/perf_monitoring/gemm/make_plot.sh index 4d6053501..607fe80b7 100755 --- a/resources/3rdparty/eigen-3.3-beta1/bench/perf_monitoring/gemm/make_plot.sh +++ b/resources/3rdparty/eigen-3.3-beta1/bench/perf_monitoring/gemm/make_plot.sh @@ -35,4 +35,4 @@ gnuplot -persist < $WHAT.gnuplot # convert -background white -density 120 -rotate 90 -resize 800 +dither -colors 256 -quality 0 $WHAT.ps -background white -flatten .$WHAT.png # clean -rm $WHAT.out.header $WHAT.gnuplot \ No newline at end of file +rm $WHAT.out.header $WHAT.gnuplot diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/product_threshold.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/product_threshold.cpp index dd6d15a07..3f8f26155 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/product_threshold.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/product_threshold.cpp @@ -3,7 +3,7 @@ #include #include -using namespace Eigen; +using namespace StormEigen; using namespace std; #define END 9 diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/quat_slerp.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/quat_slerp.cpp index bffb3bf11..ccd2513f1 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/quat_slerp.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/quat_slerp.cpp @@ -2,7 +2,7 @@ #include #include #include -using namespace Eigen; +using namespace StormEigen; using namespace std; diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/quatmul.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/quatmul.cpp index 8d9d7922c..e42fe4f0d 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/quatmul.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/quatmul.cpp @@ -3,7 +3,7 @@ #include #include -using namespace Eigen; +using namespace StormEigen; template EIGEN_DONT_INLINE void quatmul_default(const Quat& a, const Quat& b, Quat& c) diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/sparse_cholesky.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/sparse_cholesky.cpp index ecb226786..ce39b92d6 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/sparse_cholesky.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/sparse_cholesky.cpp @@ -124,14 +124,14 @@ int main(int argc, char *argv[]) #endif // eigen sparse matrices - doEigen("Eigen/Sparse", sm1, Eigen::IncompleteFactorization); + doEigen("Eigen/Sparse", sm1, StormEigen::IncompleteFactorization); #ifdef EIGEN_CHOLMOD_SUPPORT - doEigen("Eigen/Cholmod", sm1, Eigen::IncompleteFactorization); + doEigen("Eigen/Cholmod", sm1, StormEigen::IncompleteFactorization); #endif #ifdef EIGEN_TAUCS_SUPPORT - doEigen("Eigen/Taucs", sm1, Eigen::IncompleteFactorization); + doEigen("Eigen/Taucs", sm1, StormEigen::IncompleteFactorization); #endif #if 0 diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/sparse_lu.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/sparse_lu.cpp index 5c7500182..d9cfb27b7 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/sparse_lu.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/sparse_lu.cpp @@ -114,15 +114,15 @@ int main(int argc, char *argv[]) #ifdef EIGEN_UMFPACK_SUPPORT x.setZero(); - doEigen("Eigen/UmfPack (auto)", sm1, b, x, 0); + doEigen("Eigen/UmfPack (auto)", sm1, b, x, 0); #endif #ifdef EIGEN_SUPERLU_SUPPORT x.setZero(); - doEigen("Eigen/SuperLU (nat)", sm1, b, x, Eigen::NaturalOrdering); -// doEigen("Eigen/SuperLU (MD AT+A)", sm1, b, x, Eigen::MinimumDegree_AT_PLUS_A); -// doEigen("Eigen/SuperLU (MD ATA)", sm1, b, x, Eigen::MinimumDegree_ATA); - doEigen("Eigen/SuperLU (COLAMD)", sm1, b, x, Eigen::ColApproxMinimumDegree); + doEigen("Eigen/SuperLU (nat)", sm1, b, x, StormEigen::NaturalOrdering); +// doEigen("Eigen/SuperLU (MD AT+A)", sm1, b, x, StormEigen::MinimumDegree_AT_PLUS_A); +// doEigen("Eigen/SuperLU (MD ATA)", sm1, b, x, StormEigen::MinimumDegree_ATA); + doEigen("Eigen/SuperLU (COLAMD)", sm1, b, x, StormEigen::ColApproxMinimumDegree); #endif } diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/sparse_setter.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/sparse_setter.cpp index a9f0b11cc..673504788 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/sparse_setter.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/sparse_setter.cpp @@ -193,7 +193,7 @@ int main(int argc, char *argv[]) EIGEN_DONT_INLINE Scalar* setinnerrand_eigen(const Coordinates& coords, const Values& vals) { - using namespace Eigen; + using namespace StormEigen; SparseMatrix mat(SIZE,SIZE); //mat.startFill(2000000/*coords.size()*/); for (int i=0; i mat(SIZE,SIZE); mat.reserve(coords.size()/10); for (int i=0; i mat(SIZE,SIZE); for (int j=0; j setter(SIZE,SIZE); setter.reserve(coords.size()/10); for (int i=0; i mat(SIZE,SIZE); { RandomSetter, StdMapTraits > setter(mat); @@ -270,7 +270,7 @@ EIGEN_DONT_INLINE Scalar* setrand_eigen_gnu_hash(const Coordinates& coords, cons #ifndef NOGOOGLE EIGEN_DONT_INLINE Scalar* setrand_eigen_google_dense(const Coordinates& coords, const Values& vals) { - using namespace Eigen; + using namespace StormEigen; SparseMatrix mat(SIZE,SIZE); { RandomSetter, GoogleDenseHashMapTraits> setter(mat); @@ -283,7 +283,7 @@ EIGEN_DONT_INLINE Scalar* setrand_eigen_google_dense(const Coordinates& coords, EIGEN_DONT_INLINE Scalar* setrand_eigen_google_sparse(const Coordinates& coords, const Values& vals) { - using namespace Eigen; + using namespace StormEigen; SparseMatrix mat(SIZE,SIZE); { RandomSetter, GoogleSparseHashMapTraits> setter(mat); @@ -404,7 +404,7 @@ void csr_sum_duplicates(const I n_row, EIGEN_DONT_INLINE Scalar* setrand_scipy(const Coordinates& coords, const Values& vals) { - using namespace Eigen; + using namespace StormEigen; SparseMatrix mat(SIZE,SIZE); mat.resizeNonZeros(coords.size()); // std::cerr << "setrand_scipy...\n"; diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/spbench/sp_solver.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/spbench/sp_solver.cpp index a1f4bac8a..0389eba24 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/spbench/sp_solver.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/spbench/sp_solver.cpp @@ -15,7 +15,7 @@ #include #include using namespace std; -using namespace Eigen; +using namespace StormEigen; int main(int argc, char **args) { @@ -122,4 +122,4 @@ int main(int argc, char **args) // std::cout< - \ No newline at end of file + diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/spbench/spbenchsolver.h b/resources/3rdparty/eigen-3.3-beta1/bench/spbench/spbenchsolver.h index 19c719c04..ed72b74c7 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/spbench/spbenchsolver.h +++ b/resources/3rdparty/eigen-3.3-beta1/bench/spbench/spbenchsolver.h @@ -72,7 +72,7 @@ #define EIGEN_CG 170 #define EIGEN_CG_PRECOND 180 -using namespace Eigen; +using namespace StormEigen; using namespace std; diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/spbench/test_sparseLU.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/spbench/test_sparseLU.cpp index f8ecbe69b..187eaca15 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/spbench/test_sparseLU.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/spbench/test_sparseLU.cpp @@ -12,7 +12,7 @@ #endif using namespace std; -using namespace Eigen; +using namespace StormEigen; int main(int argc, char **args) { @@ -90,4 +90,4 @@ int main(int argc, char **args) cout << "Number of nonzeros in the factor : " << solver.nnzL() + solver.nnzU() << std::endl; return 0; -} \ No newline at end of file +} diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/tensors/tensor_benchmarks.h b/resources/3rdparty/eigen-3.3-beta1/bench/tensors/tensor_benchmarks.h index 525b9acda..4a084f4da 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/tensors/tensor_benchmarks.h +++ b/resources/3rdparty/eigen-3.3-beta1/bench/tensors/tensor_benchmarks.h @@ -7,8 +7,8 @@ typedef int TensorIndex; #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" #include "testing/base/public/benchmark.h" -using Eigen::Tensor; -using Eigen::TensorMap; +using StormEigen::Tensor; +using StormEigen::TensorMap; // TODO(bsteiner): also templatize on the input type since we have users @@ -43,8 +43,8 @@ template class BenchmarkSuite { void random(int num_iters) { eigen_assert(m_ == k_ && k_ == n_); - const Eigen::array sizes(m_, m_); - TensorMap, Eigen::Aligned> C(c_, sizes); + const StormEigen::array sizes(m_, m_); + TensorMap, StormEigen::Aligned> C(c_, sizes); StartBenchmarkTiming(); for (int iter = 0; iter < num_iters; ++iter) { @@ -56,16 +56,16 @@ template class BenchmarkSuite { void slicing(int num_iters) { eigen_assert(m_ == k_ && k_ == n_); - const Eigen::array sizes(m_, m_); - const TensorMap, Eigen::Aligned> A(a_, sizes); - const TensorMap, Eigen::Aligned> B(b_, sizes); - TensorMap, Eigen::Aligned> C(c_, sizes); + const StormEigen::array sizes(m_, m_); + const TensorMap, StormEigen::Aligned> A(a_, sizes); + const TensorMap, StormEigen::Aligned> B(b_, sizes); + TensorMap, StormEigen::Aligned> C(c_, sizes); - const Eigen::DSizes quarter_sizes(Eigen::array(m_/2, m_/2)); - const Eigen::DSizes first_quadrant(Eigen::array(0, 0)); - const Eigen::DSizes second_quadrant(Eigen::array(0, m_/2)); - const Eigen::DSizes third_quadrant(Eigen::array(m_/2, 0)); - const Eigen::DSizes fourth_quadrant(Eigen::array(m_/2, m_/2)); + const StormEigen::DSizes quarter_sizes(StormEigen::array(m_/2, m_/2)); + const StormEigen::DSizes first_quadrant(StormEigen::array(0, 0)); + const StormEigen::DSizes second_quadrant(StormEigen::array(0, m_/2)); + const StormEigen::DSizes third_quadrant(StormEigen::array(m_/2, 0)); + const StormEigen::DSizes fourth_quadrant(StormEigen::array(m_/2, m_/2)); StartBenchmarkTiming(); for (int iter = 0; iter < num_iters; ++iter) { @@ -85,12 +85,12 @@ template class BenchmarkSuite { void shuffling(int num_iters) { eigen_assert(m_ == n_); - const Eigen::array size_a(m_, k_); - const TensorMap, Eigen::Aligned> A(a_, size_a); - const Eigen::array size_b(k_, m_); - TensorMap, Eigen::Aligned> B(b_, size_b); + const StormEigen::array size_a(m_, k_); + const TensorMap, StormEigen::Aligned> A(a_, size_a); + const StormEigen::array size_b(k_, m_); + TensorMap, StormEigen::Aligned> B(b_, size_b); - const Eigen::array shuffle(1, 0); + const StormEigen::array shuffle(1, 0); StartBenchmarkTiming(); for (int iter = 0; iter < num_iters; ++iter) { @@ -102,14 +102,14 @@ template class BenchmarkSuite { void padding(int num_iters) { eigen_assert(m_ == k_); - const Eigen::array size_a(m_, k_-3); - const TensorMap, Eigen::Aligned> A(a_, size_a); - const Eigen::array size_b(k_, m_); - TensorMap, Eigen::Aligned> B(b_, size_b); + const StormEigen::array size_a(m_, k_-3); + const TensorMap, StormEigen::Aligned> A(a_, size_a); + const StormEigen::array size_b(k_, m_); + TensorMap, StormEigen::Aligned> B(b_, size_b); - Eigen::array, 2> paddings; - paddings[0] = Eigen::IndexPair(0, 0); - paddings[1] = Eigen::IndexPair(2, 1); + StormEigen::array, 2> paddings; + paddings[0] = StormEigen::IndexPair(0, 0); + paddings[1] = StormEigen::IndexPair(2, 1); StartBenchmarkTiming(); for (int iter = 0; iter < num_iters; ++iter) { @@ -121,12 +121,12 @@ template class BenchmarkSuite { void striding(int num_iters) { eigen_assert(m_ == k_); - const Eigen::array size_a(m_, k_); - const TensorMap, Eigen::Aligned> A(a_, size_a); - const Eigen::array size_b(m_, k_ / 2); - TensorMap, Eigen::Aligned> B(b_, size_b); + const StormEigen::array size_a(m_, k_); + const TensorMap, StormEigen::Aligned> A(a_, size_a); + const StormEigen::array size_b(m_, k_ / 2); + TensorMap, StormEigen::Aligned> B(b_, size_b); - const Eigen::array strides(1, 2); + const StormEigen::array strides(1, 2); StartBenchmarkTiming(); for (int iter = 0; iter < num_iters; ++iter) { @@ -137,18 +137,18 @@ template class BenchmarkSuite { } void broadcasting(int num_iters) { - const Eigen::array size_a(m_, 1); - const TensorMap, Eigen::Aligned> A(a_, size_a); - const Eigen::array size_c(m_, n_); - TensorMap, Eigen::Aligned> C(c_, size_c); + const StormEigen::array size_a(m_, 1); + const TensorMap, StormEigen::Aligned> A(a_, size_a); + const StormEigen::array size_c(m_, n_); + TensorMap, StormEigen::Aligned> C(c_, size_c); #if defined(__CUDACC__) // nvcc doesn't support cxx11 - const Eigen::array broadcast(1, n_); + const StormEigen::array broadcast(1, n_); #else // Take advantage of cxx11 to give the compiler information it can use to // optimize the code. - Eigen::IndexList, int> broadcast; + StormEigen::IndexList, int> broadcast; broadcast.set(1, n_); #endif @@ -162,10 +162,10 @@ template class BenchmarkSuite { void coeffWiseOp(int num_iters) { eigen_assert(m_ == k_ && k_ == n_); - const Eigen::array sizes(m_, m_); - const TensorMap, Eigen::Aligned> A(a_, sizes); - const TensorMap, Eigen::Aligned> B(b_, sizes); - TensorMap, Eigen::Aligned> C(c_, sizes); + const StormEigen::array sizes(m_, m_); + const TensorMap, StormEigen::Aligned> A(a_, sizes); + const TensorMap, StormEigen::Aligned> B(b_, sizes); + TensorMap, StormEigen::Aligned> C(c_, sizes); StartBenchmarkTiming(); for (int iter = 0; iter < num_iters; ++iter) { @@ -178,10 +178,10 @@ template class BenchmarkSuite { void algebraicFunc(int num_iters) { eigen_assert(m_ == k_ && k_ == n_); - const Eigen::array sizes(m_, m_); - const TensorMap, Eigen::Aligned> A(a_, sizes); - const TensorMap, Eigen::Aligned> B(b_, sizes); - TensorMap, Eigen::Aligned> C(c_, sizes); + const StormEigen::array sizes(m_, m_); + const TensorMap, StormEigen::Aligned> A(a_, sizes); + const TensorMap, StormEigen::Aligned> B(b_, sizes); + TensorMap, StormEigen::Aligned> C(c_, sizes); StartBenchmarkTiming(); for (int iter = 0; iter < num_iters; ++iter) { @@ -194,10 +194,10 @@ template class BenchmarkSuite { void transcendentalFunc(int num_iters) { eigen_assert(m_ == k_ && k_ == n_); - const Eigen::array sizes(m_, m_); - const TensorMap, Eigen::Aligned> A(a_, sizes); - const TensorMap, Eigen::Aligned> B(b_, sizes); - TensorMap, Eigen::Aligned> C(c_, sizes); + const StormEigen::array sizes(m_, m_); + const TensorMap, StormEigen::Aligned> A(a_, sizes); + const TensorMap, StormEigen::Aligned> B(b_, sizes); + TensorMap, StormEigen::Aligned> C(c_, sizes); StartBenchmarkTiming(); for (int iter = 0; iter < num_iters; ++iter) { @@ -210,12 +210,12 @@ template class BenchmarkSuite { // Simple reduction void reduction(int num_iters) { - const Eigen::array input_size(k_, n_); - const TensorMap, Eigen::Aligned> B(b_, input_size); - const Eigen::array output_size(n_); - TensorMap, Eigen::Aligned> C(c_, output_size); + const StormEigen::array input_size(k_, n_); + const TensorMap, StormEigen::Aligned> B(b_, input_size); + const StormEigen::array output_size(n_); + TensorMap, StormEigen::Aligned> C(c_, output_size); - const Eigen::array sum_along_dim(0); + const StormEigen::array sum_along_dim(0); StartBenchmarkTiming(); for (int iter = 0; iter < num_iters; ++iter) { @@ -228,16 +228,16 @@ template class BenchmarkSuite { // do a contraction which is equivalent to a matrix multiplication void contraction(int num_iters) { - const Eigen::array sizeA(m_, k_); - const Eigen::array sizeB(k_, n_); - const Eigen::array sizeC(m_, n_); + const StormEigen::array sizeA(m_, k_); + const StormEigen::array sizeB(k_, n_); + const StormEigen::array sizeC(m_, n_); - const TensorMap, Eigen::Aligned> A(a_, sizeA); - const TensorMap, Eigen::Aligned> B(b_, sizeB); - TensorMap, Eigen::Aligned> C(c_, sizeC); + const TensorMap, StormEigen::Aligned> A(a_, sizeA); + const TensorMap, StormEigen::Aligned> B(b_, sizeB); + TensorMap, StormEigen::Aligned> C(c_, sizeC); typedef typename Tensor::DimensionPair DimPair; - const Eigen::array dims(DimPair(1, 0)); + const StormEigen::array dims(DimPair(1, 0)); StartBenchmarkTiming(); for (int iter = 0; iter < num_iters; ++iter) { @@ -249,14 +249,14 @@ template class BenchmarkSuite { } void convolution(int num_iters, int kernel_x, int kernel_y) { - const Eigen::array input_sizes(m_, n_); - TensorMap, Eigen::Aligned> A(a_, input_sizes); - const Eigen::array kernel_sizes(kernel_x, kernel_y); - TensorMap, Eigen::Aligned> B(b_, kernel_sizes); - const Eigen::array result_sizes( + const StormEigen::array input_sizes(m_, n_); + TensorMap, StormEigen::Aligned> A(a_, input_sizes); + const StormEigen::array kernel_sizes(kernel_x, kernel_y); + TensorMap, StormEigen::Aligned> B(b_, kernel_sizes); + const StormEigen::array result_sizes( m_ - kernel_x + 1, n_ - kernel_y + 1); - TensorMap, Eigen::Aligned> C(c_, result_sizes); - Eigen::array::Index, 2> dims(0, 1); + TensorMap, StormEigen::Aligned> C(c_, result_sizes); + StormEigen::array::Index, 2> dims(0, 1); StartBenchmarkTiming(); for (int iter = 0; iter < num_iters; ++iter) { @@ -285,7 +285,7 @@ template class BenchmarkSuite { inline void finalizeBenchmark(int64 num_items) { #if defined(EIGEN_USE_GPU) && defined(__CUDACC__) - if (Eigen::internal::is_same::value) { + if (StormEigen::internal::is_same::value) { device_.synchronize(); } #endif diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/tensors/tensor_benchmarks_cpu.cc b/resources/3rdparty/eigen-3.3-beta1/bench/tensors/tensor_benchmarks_cpu.cc index 68653ba15..25418f144 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/tensors/tensor_benchmarks_cpu.cc +++ b/resources/3rdparty/eigen-3.3-beta1/bench/tensors/tensor_benchmarks_cpu.cc @@ -7,12 +7,12 @@ #ifdef __ANDROID__ #define CREATE_THREAD_POOL(threads) \ -Eigen::ThreadPoolDevice device(threads); +StormEigen::ThreadPoolDevice device(threads); #else #define CREATE_THREAD_POOL(threads) \ ThreadPool tp(threads); \ tp.StartWorkers(); \ -Eigen::ThreadPoolDevice device(&tp, threads); +StormEigen::ThreadPoolDevice device(&tp, threads); #endif // Simple functions @@ -20,7 +20,7 @@ Eigen::ThreadPoolDevice device(&tp, threads); static void BM_##FUNC##_##THREADS##T(int iters, int N) { \ StopBenchmarkTiming(); \ CREATE_THREAD_POOL(THREADS); \ - BenchmarkSuite suite(device, N); \ + BenchmarkSuite suite(device, N); \ suite.FUNC(iters); \ SetBenchmarkLabel(StrCat("using ", THREADS, " threads")); \ } \ @@ -76,12 +76,12 @@ BM_FuncCPU(reduction, 12); static void BM_##FUNC##_##D1##x##D2##x##D3##_##THREADS##T(int iters, int N) {\ StopBenchmarkTiming(); \ if (THREADS == 1) { \ - Eigen::DefaultDevice device; \ - BenchmarkSuite suite(device, D1, D2, D3); \ + StormEigen::DefaultDevice device; \ + BenchmarkSuite suite(device, D1, D2, D3); \ suite.FUNC(iters); \ } else { \ CREATE_THREAD_POOL(THREADS); \ - BenchmarkSuite suite(device, D1, D2, D3); \ + BenchmarkSuite suite(device, D1, D2, D3); \ suite.FUNC(iters); \ } \ SetBenchmarkLabel(StrCat("using ", THREADS, " threads")); \ @@ -125,7 +125,7 @@ BM_FuncWithInputDimsCPU(contraction, N, N, 1, 16); static void BM_##FUNC##_##DIM1##x##DIM2##_##THREADS##T(int iters, int N) { \ StopBenchmarkTiming(); \ CREATE_THREAD_POOL(THREADS); \ - BenchmarkSuite suite(device, N); \ + BenchmarkSuite suite(device, N); \ suite.FUNC(iters, DIM1, DIM2); \ SetBenchmarkLabel(StrCat("using ", THREADS, " threads")); \ } \ diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/tensors/tensor_benchmarks_gpu.cc b/resources/3rdparty/eigen-3.3-beta1/bench/tensors/tensor_benchmarks_gpu.cc index adea754ad..1d3e8beeb 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/tensors/tensor_benchmarks_gpu.cc +++ b/resources/3rdparty/eigen-3.3-beta1/bench/tensors/tensor_benchmarks_gpu.cc @@ -14,8 +14,8 @@ StopBenchmarkTiming(); \ cudaStream_t stream; \ cudaStreamCreate(&stream); \ - Eigen::GpuDevice device(&stream); \ - BenchmarkSuite suite(device, N); \ + StormEigen::GpuDevice device(&stream); \ + BenchmarkSuite suite(device, N); \ cudaDeviceSynchronize(); \ suite.FUNC(iters); \ cudaStreamDestroy(stream); \ @@ -39,8 +39,8 @@ BM_FuncGPU(reduction); StopBenchmarkTiming(); \ cudaStream_t stream; \ cudaStreamCreate(&stream); \ - Eigen::GpuDevice device(&stream); \ - BenchmarkSuite suite(device, D1, D2, D3); \ + StormEigen::GpuDevice device(&stream); \ + BenchmarkSuite suite(device, D1, D2, D3); \ cudaDeviceSynchronize(); \ suite.FUNC(iters); \ cudaStreamDestroy(stream); \ @@ -59,8 +59,8 @@ BM_FuncWithInputDimsGPU(contraction, N, 64, N); StopBenchmarkTiming(); \ cudaStream_t stream; \ cudaStreamCreate(&stream); \ - Eigen::GpuDevice device(&stream); \ - BenchmarkSuite suite(device, N); \ + StormEigen::GpuDevice device(&stream); \ + BenchmarkSuite suite(device, N); \ cudaDeviceSynchronize(); \ suite.FUNC(iters, DIM1, DIM2); \ cudaStreamDestroy(stream); \ diff --git a/resources/3rdparty/eigen-3.3-beta1/bench/vdw_new.cpp b/resources/3rdparty/eigen-3.3-beta1/bench/vdw_new.cpp index d2604049f..fde1859aa 100644 --- a/resources/3rdparty/eigen-3.3-beta1/bench/vdw_new.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/bench/vdw_new.cpp @@ -1,7 +1,7 @@ #include #include -using namespace Eigen; +using namespace StormEigen; #ifndef SCALAR #define SCALAR float @@ -15,7 +15,7 @@ using namespace Eigen; #define REPEAT 10000 #endif -typedef Matrix Vec; +typedef Matrix Vec; using namespace std; diff --git a/resources/3rdparty/eigen-3.3-beta1/blas/common.h b/resources/3rdparty/eigen-3.3-beta1/blas/common.h index 5ecb153e2..71b6a4dc8 100644 --- a/resources/3rdparty/eigen-3.3-beta1/blas/common.h +++ b/resources/3rdparty/eigen-3.3-beta1/blas/common.h @@ -71,7 +71,7 @@ inline bool check_uplo(const char* uplo) } -namespace Eigen { +namespace StormEigen { #include "BandTriangularSolver.h" #include "GeneralRank1Update.h" #include "PackedSelfadjointProduct.h" @@ -80,7 +80,7 @@ namespace Eigen { #include "Rank2Update.h" } -using namespace Eigen; +using namespace StormEigen; typedef SCALAR Scalar; typedef NumTraits::Real RealScalar; @@ -88,7 +88,7 @@ typedef std::complex Complex; enum { - IsComplex = Eigen::NumTraits::IsComplex, + IsComplex = StormEigen::NumTraits::IsComplex, Conj = IsComplex }; diff --git a/resources/3rdparty/eigen-3.3-beta1/blas/level1_cplx_impl.h b/resources/3rdparty/eigen-3.3-beta1/blas/level1_cplx_impl.h index 719f5bac9..ecb36c3bf 100644 --- a/resources/3rdparty/eigen-3.3-beta1/blas/level1_cplx_impl.h +++ b/resources/3rdparty/eigen-3.3-beta1/blas/level1_cplx_impl.h @@ -14,7 +14,7 @@ struct scalar_norm1_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_norm1_op) inline RealScalar operator() (const Scalar& a) const { return numext::norm1(a); } }; -namespace Eigen { +namespace StormEigen { namespace internal { template<> struct functor_traits { diff --git a/resources/3rdparty/eigen-3.3-beta1/blas/level3_impl.h b/resources/3rdparty/eigen-3.3-beta1/blas/level3_impl.h index 6a6b00728..199f9b861 100644 --- a/resources/3rdparty/eigen-3.3-beta1/blas/level3_impl.h +++ b/resources/3rdparty/eigen-3.3-beta1/blas/level3_impl.h @@ -12,7 +12,7 @@ int EIGEN_BLAS_FUNC(gemm)(char *opa, char *opb, int *m, int *n, int *k, RealScalar *palpha, RealScalar *pa, int *lda, RealScalar *pb, int *ldb, RealScalar *pbeta, RealScalar *pc, int *ldc) { // std::cerr << "in gemm " << *opa << " " << *opb << " " << *m << " " << *n << " " << *k << " " << *lda << " " << *ldb << " " << *ldc << " " << *palpha << " " << *pbeta << "\n"; - typedef void (*functype)(DenseIndex, DenseIndex, DenseIndex, const Scalar *, DenseIndex, const Scalar *, DenseIndex, Scalar *, DenseIndex, Scalar, internal::level3_blocking&, Eigen::internal::GemmParallelInfo*); + typedef void (*functype)(DenseIndex, DenseIndex, DenseIndex, const Scalar *, DenseIndex, const Scalar *, DenseIndex, Scalar *, DenseIndex, Scalar, internal::level3_blocking&, StormEigen::internal::GemmParallelInfo*); static functype func[12]; static bool init = false; diff --git a/resources/3rdparty/eigen-3.3-beta1/cmake/FindSPQR.cmake b/resources/3rdparty/eigen-3.3-beta1/cmake/FindSPQR.cmake index 1e958c3c1..edf46ae75 100644 --- a/resources/3rdparty/eigen-3.3-beta1/cmake/FindSPQR.cmake +++ b/resources/3rdparty/eigen-3.3-beta1/cmake/FindSPQR.cmake @@ -38,4 +38,4 @@ endif(SPQR_LIBRARIES) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(SPQR DEFAULT_MSG SPQR_INCLUDES SPQR_LIBRARIES) -mark_as_advanced(SPQR_INCLUDES SPQR_LIBRARIES) \ No newline at end of file +mark_as_advanced(SPQR_INCLUDES SPQR_LIBRARIES) diff --git a/resources/3rdparty/eigen-3.3-beta1/cmake/RegexUtils.cmake b/resources/3rdparty/eigen-3.3-beta1/cmake/RegexUtils.cmake index b59dfc340..14303f6e4 100644 --- a/resources/3rdparty/eigen-3.3-beta1/cmake/RegexUtils.cmake +++ b/resources/3rdparty/eigen-3.3-beta1/cmake/RegexUtils.cmake @@ -16,4 +16,4 @@ function(test_escape_string_as_regex) if(NOT test2 STREQUAL testRef) message("Error in the escape_string_for_regex function : \n ${test1} was escaped as ${test2}, should be ${testRef}") endif(NOT test2 STREQUAL testRef) -endfunction() \ No newline at end of file +endfunction() diff --git a/resources/3rdparty/eigen-3.3-beta1/debug/gdb/printers.py b/resources/3rdparty/eigen-3.3-beta1/debug/gdb/printers.py index 0d67a5f99..576966aaf 100644 --- a/resources/3rdparty/eigen-3.3-beta1/debug/gdb/printers.py +++ b/resources/3rdparty/eigen-3.3-beta1/debug/gdb/printers.py @@ -8,7 +8,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -# Pretty printers for Eigen::Matrix +# Pretty printers for StormEigen::Matrix # This is still pretty basic as the python extension to gdb is still pretty basic. # It cannot handle complex eigen types and it doesn't support any of the other eigen types # Such as quaternion or some other type. @@ -127,7 +127,7 @@ class EigenMatrixPrinter: return self._iterator(self.rows, self.cols, self.data, self.rowMajor) def to_string(self): - return "Eigen::%s<%s,%d,%d,%s> (data ptr: %s)" % (self.variety, self.innerType, self.rows, self.cols, "RowMajor" if self.rowMajor else "ColMajor", self.data) + return "StormEigen::%s<%s,%d,%d,%s> (data ptr: %s)" % (self.variety, self.innerType, self.rows, self.cols, "RowMajor" if self.rowMajor else "ColMajor", self.data) class EigenQuaternionPrinter: "Print an Eigen Quaternion" @@ -175,12 +175,12 @@ class EigenQuaternionPrinter: return self._iterator(self.data) def to_string(self): - return "Eigen::Quaternion<%s> (data ptr: %s)" % (self.innerType, self.data) + return "StormEigen::Quaternion<%s> (data ptr: %s)" % (self.innerType, self.data) def build_eigen_dictionary (): - pretty_printers_dict[re.compile('^Eigen::Quaternion<.*>$')] = lambda val: EigenQuaternionPrinter(val) - pretty_printers_dict[re.compile('^Eigen::Matrix<.*>$')] = lambda val: EigenMatrixPrinter("Matrix", val) - pretty_printers_dict[re.compile('^Eigen::Array<.*>$')] = lambda val: EigenMatrixPrinter("Array", val) + pretty_printers_dict[re.compile('^StormEigen::Quaternion<.*>$')] = lambda val: EigenQuaternionPrinter(val) + pretty_printers_dict[re.compile('^StormEigen::Matrix<.*>$')] = lambda val: EigenMatrixPrinter("Matrix", val) + pretty_printers_dict[re.compile('^StormEigen::Array<.*>$')] = lambda val: EigenMatrixPrinter("Array", val) def register_eigen_printers(obj): "Register eigen pretty-printers with objfile Obj" diff --git a/resources/3rdparty/eigen-3.3-beta1/debug/msvc/eigen.natvis b/resources/3rdparty/eigen-3.3-beta1/debug/msvc/eigen.natvis index da8985717..c6cf88447 100644 --- a/resources/3rdparty/eigen-3.3-beta1/debug/msvc/eigen.natvis +++ b/resources/3rdparty/eigen-3.3-beta1/debug/msvc/eigen.natvis @@ -3,8 +3,8 @@ - - + + [{$T2}, {$T3}] (fixed matrix) @@ -22,8 +22,8 @@ - - + + [2, 2] (fixed matrix) @@ -42,8 +42,8 @@ - - + + [3, 3] (fixed matrix) @@ -68,8 +68,8 @@ - - + + [4, 4] (fixed matrix) @@ -100,8 +100,8 @@ - - + + empty [{m_storage.m_rows}, {m_storage.m_cols}] (dynamic matrix) @@ -120,8 +120,8 @@ - - + + empty [{$T2}, {m_storage.m_cols}] (dynamic column matrix) @@ -140,8 +140,8 @@ - - + + empty [{m_storage.m_rows}, {$T2}] (dynamic row matrix) @@ -160,8 +160,8 @@ - - + + empty [{m_storage.m_cols}] (dynamic column vector) @@ -174,8 +174,8 @@ - - + + empty [{m_storage.m_rows}] (dynamic row vector) @@ -188,18 +188,18 @@ - - + + [1] ({m_storage.m_data.array[0]}) m_storage.m_data.array[0] - - - - + + + + [2] ({m_storage.m_data.array[0]}, {m_storage.m_data.array[1]}) m_storage.m_data.array[0] @@ -207,10 +207,10 @@ - - - - + + + + [3] ({m_storage.m_data.array[0]}, {m_storage.m_data.array[1]}, {m_storage.m_data.array[2]}) m_storage.m_data.array[0] @@ -219,10 +219,10 @@ - - - - + + + + [4] ({m_storage.m_data.array[0]}, {m_storage.m_data.array[1]}, {m_storage.m_data.array[2]}, {m_storage.m_data.array[3]}) m_storage.m_data.array[0] diff --git a/resources/3rdparty/eigen-3.3-beta1/debug/msvc/eigen_autoexp_part.dat b/resources/3rdparty/eigen-3.3-beta1/debug/msvc/eigen_autoexp_part.dat index 07aa43739..7f53e0981 100644 --- a/resources/3rdparty/eigen-3.3-beta1/debug/msvc/eigen_autoexp_part.dat +++ b/resources/3rdparty/eigen-3.3-beta1/debug/msvc/eigen_autoexp_part.dat @@ -6,13 +6,13 @@ ; * Support the enhanced debugging of the following Eigen ; * types (*: any, +:fixed dimension) : ; * -; * - Eigen::Matrix<*,4,1,*,*,*> and Eigen::Matrix<*,1,4,*,*,*> -; * - Eigen::Matrix<*,3,1,*,*,*> and Eigen::Matrix<*,1,3,*,*,*> -; * - Eigen::Matrix<*,2,1,*,*,*> and Eigen::Matrix<*,1,2,*,*,*> -; * - Eigen::Matrix<*,-1,-1,*,*,*> -; * - Eigen::Matrix<*,+,-1,*,*,*> -; * - Eigen::Matrix<*,-1,+,*,*,*> -; * - Eigen::Matrix<*,+,+,*,*,*> +; * - StormEigen::Matrix<*,4,1,*,*,*> and StormEigen::Matrix<*,1,4,*,*,*> +; * - StormEigen::Matrix<*,3,1,*,*,*> and StormEigen::Matrix<*,1,3,*,*,*> +; * - StormEigen::Matrix<*,2,1,*,*,*> and StormEigen::Matrix<*,1,2,*,*,*> +; * - StormEigen::Matrix<*,-1,-1,*,*,*> +; * - StormEigen::Matrix<*,+,-1,*,*,*> +; * - StormEigen::Matrix<*,-1,+,*,*,*> +; * - StormEigen::Matrix<*,+,+,*,*,*> ; * ; * Matrices are displayed properly independantly of the memory ; * alignment (RowMajor vs. ColMajor). @@ -25,7 +25,7 @@ [Visualizer] ; Fixed size 4-vectors -Eigen::Matrix<*,4,1,*,*,*>|Eigen::Matrix<*,1,4,*,*,*>{ +StormEigen::Matrix<*,4,1,*,*,*>|StormEigen::Matrix<*,1,4,*,*,*>{ children ( #( @@ -50,7 +50,7 @@ Eigen::Matrix<*,4,1,*,*,*>|Eigen::Matrix<*,1,4,*,*,*>{ } ; Fixed size 3-vectors -Eigen::Matrix<*,3,1,*,*,*>|Eigen::Matrix<*,1,3,*,*,*>{ +StormEigen::Matrix<*,3,1,*,*,*>|StormEigen::Matrix<*,1,3,*,*,*>{ children ( #( @@ -74,7 +74,7 @@ Eigen::Matrix<*,3,1,*,*,*>|Eigen::Matrix<*,1,3,*,*,*>{ } ; Fixed size 2-vectors -Eigen::Matrix<*,2,1,*,*,*>|Eigen::Matrix<*,1,2,*,*,*>{ +StormEigen::Matrix<*,2,1,*,*,*>|StormEigen::Matrix<*,1,2,*,*,*>{ children ( #( @@ -97,7 +97,7 @@ Eigen::Matrix<*,2,1,*,*,*>|Eigen::Matrix<*,1,2,*,*,*>{ } ; Fixed size 1-vectors -Eigen::Matrix<*,1,1,*,*,*>|Eigen::Matrix<*,1,1,*,*,*>{ +StormEigen::Matrix<*,1,1,*,*,*>|StormEigen::Matrix<*,1,1,*,*,*>{ children ( #( @@ -119,7 +119,7 @@ Eigen::Matrix<*,1,1,*,*,*>|Eigen::Matrix<*,1,1,*,*,*>{ } ; Dynamic matrices (ColMajor and RowMajor support) -Eigen::Matrix<*,-1,-1,*,*,*>{ +StormEigen::Matrix<*,-1,-1,*,*,*>{ children ( #( @@ -163,7 +163,7 @@ Eigen::Matrix<*,-1,-1,*,*,*>{ } ; Fixed rows, dynamic columns matrix (ColMajor and RowMajor support) -Eigen::Matrix<*,*,-1,*,*,*>{ +StormEigen::Matrix<*,*,-1,*,*,*>{ children ( #( @@ -207,7 +207,7 @@ Eigen::Matrix<*,*,-1,*,*,*>{ } ; Dynamic rows, fixed columns matrix (ColMajor and RowMajor support) -Eigen::Matrix<*,-1,*,*,*,*>{ +StormEigen::Matrix<*,-1,*,*,*,*>{ children ( #( @@ -251,7 +251,7 @@ Eigen::Matrix<*,-1,*,*,*,*>{ } ; Fixed size matrix (ColMajor and RowMajor support) -Eigen::Matrix<*,*,*,*,*,*>{ +StormEigen::Matrix<*,*,*,*,*,*>{ children ( #( diff --git a/resources/3rdparty/eigen-3.3-beta1/demos/mandelbrot/mandelbrot.cpp b/resources/3rdparty/eigen-3.3-beta1/demos/mandelbrot/mandelbrot.cpp index 5d575d5b6..86da5a96d 100644 --- a/resources/3rdparty/eigen-3.3-beta1/demos/mandelbrot/mandelbrot.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/demos/mandelbrot/mandelbrot.cpp @@ -30,8 +30,8 @@ template<> struct iters_before_test { enum { ret = 16 }; }; template void MandelbrotThread::render(int img_width, int img_height) { - enum { packetSize = Eigen::internal::packet_traits::size }; // number of reals in a Packet - typedef Eigen::Array Packet; // wrap a Packet as a vector + enum { packetSize = StormEigen::internal::packet_traits::size }; // number of reals in a Packet + typedef StormEigen::Array Packet; // wrap a Packet as a vector enum { iters_before_test = iters_before_test::ret }; max_iter = (max_iter / iters_before_test) * iters_before_test; @@ -40,7 +40,7 @@ template void MandelbrotThread::render(int img_width, int img_hei const double xradius = widget->xradius; const double yradius = xradius * img_height / img_width; const int threadcount = widget->threadcount; - typedef Eigen::Array Vector2; + typedef StormEigen::Array Vector2; Vector2 start(widget->center.x() - widget->xradius, widget->center.y() - yradius); Vector2 step(2*widget->xradius/img_width, 2*yradius/img_height); total_iter = 0; @@ -64,7 +64,7 @@ template void MandelbrotThread::render(int img_width, int img_hei // do the iterations. Every iters_before_test iterations we check for divergence, // in which case we can stop iterating. int j = 0; - typedef Eigen::Matrix Packeti; + typedef StormEigen::Matrix Packeti; Packeti pix_iter = Packeti::Zero(), // number of iteration per pixel in the packet pix_dont_diverge; // whether or not each pixel has already diverged do @@ -148,8 +148,8 @@ void MandelbrotWidget::paintEvent(QPaintEvent *) << elapsed << " ms, " << speed << " iters/s (max " << max_speed << ")" << std::endl; int packetSize = threads[0]->single_precision - ? int(Eigen::internal::packet_traits::size) - : int(Eigen::internal::packet_traits::size); + ? int(StormEigen::internal::packet_traits::size) + : int(StormEigen::internal::packet_traits::size); setWindowTitle(QString("resolution ")+QString::number(xradius*2/width(), 'e', 2) +QString(", %1 iterations per pixel, ").arg(threads[0]->max_iter) +(threads[0]->single_precision ? QString("single ") : QString("double ")) @@ -176,7 +176,7 @@ void MandelbrotWidget::mousePressEvent(QMouseEvent *event) { lastpos = event->pos(); double yradius = xradius * height() / width(); - center = Eigen::Vector2d(center.x() + (event->pos().x() - width()/2) * xradius * 2 / width(), + center = StormEigen::Vector2d(center.x() + (event->pos().x() - width()/2) * xradius * 2 / width(), center.y() + (event->pos().y() - height()/2) * yradius * 2 / height()); draft = 16; for(int th = 0; th < threadcount; th++) diff --git a/resources/3rdparty/eigen-3.3-beta1/demos/mandelbrot/mandelbrot.h b/resources/3rdparty/eigen-3.3-beta1/demos/mandelbrot/mandelbrot.h index a687fd016..e83273143 100644 --- a/resources/3rdparty/eigen-3.3-beta1/demos/mandelbrot/mandelbrot.h +++ b/resources/3rdparty/eigen-3.3-beta1/demos/mandelbrot/mandelbrot.h @@ -36,7 +36,7 @@ class MandelbrotWidget : public QWidget Q_OBJECT friend class MandelbrotThread; - Eigen::Vector2d center; + StormEigen::Vector2d center; double xradius; int size; unsigned char *buffer; diff --git a/resources/3rdparty/eigen-3.3-beta1/demos/mix_eigen_and_c/README b/resources/3rdparty/eigen-3.3-beta1/demos/mix_eigen_and_c/README index 21dba8679..d9cc9275d 100644 --- a/resources/3rdparty/eigen-3.3-beta1/demos/mix_eigen_and_c/README +++ b/resources/3rdparty/eigen-3.3-beta1/demos/mix_eigen_and_c/README @@ -6,4 +6,4 @@ To try this with GCC, do: gcc example.c binary_library.o -o example -lstdc++ ./example -TODO: add CMakeLists, add more explanations here \ No newline at end of file +TODO: add CMakeLists, add more explanations here diff --git a/resources/3rdparty/eigen-3.3-beta1/demos/mix_eigen_and_c/binary_library.cpp b/resources/3rdparty/eigen-3.3-beta1/demos/mix_eigen_and_c/binary_library.cpp index 15a2d03e9..7e9e164a1 100644 --- a/resources/3rdparty/eigen-3.3-beta1/demos/mix_eigen_and_c/binary_library.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/demos/mix_eigen_and_c/binary_library.cpp @@ -14,7 +14,7 @@ #include -using namespace Eigen; +using namespace StormEigen; /************************* pointer conversion methods **********************************************/ diff --git a/resources/3rdparty/eigen-3.3-beta1/demos/mix_eigen_and_c/binary_library.h b/resources/3rdparty/eigen-3.3-beta1/demos/mix_eigen_and_c/binary_library.h index 0b983ad3a..2061ee623 100644 --- a/resources/3rdparty/eigen-3.3-beta1/demos/mix_eigen_and_c/binary_library.h +++ b/resources/3rdparty/eigen-3.3-beta1/demos/mix_eigen_and_c/binary_library.h @@ -23,7 +23,7 @@ extern "C" struct C_Map_MatrixXd {}; // the C_MatrixXd class, wraps some of the functionality - // of Eigen::MatrixXd. + // of StormEigen::MatrixXd. struct C_MatrixXd* MatrixXd_new(int rows, int cols); void MatrixXd_delete (struct C_MatrixXd *m); double* MatrixXd_data (struct C_MatrixXd *m); @@ -46,7 +46,7 @@ extern "C" struct C_MatrixXd *result); // the C_Map_MatrixXd class, wraps some of the functionality - // of Eigen::Map + // of StormEigen::Map struct C_Map_MatrixXd* Map_MatrixXd_new(double *array, int rows, int cols); void Map_MatrixXd_delete (struct C_Map_MatrixXd *m); void Map_MatrixXd_set_zero (struct C_Map_MatrixXd *m); @@ -68,4 +68,4 @@ extern "C" #ifdef __cplusplus } // end extern "C" -#endif \ No newline at end of file +#endif diff --git a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/CMakeLists.txt b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/CMakeLists.txt index 299aa441d..c4d5adfc4 100644 --- a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/CMakeLists.txt +++ b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/CMakeLists.txt @@ -25,4 +25,4 @@ else() message(STATUS "OpenGL demo disabled because Qt4 and/or OpenGL have not been found.") -endif() \ No newline at end of file +endif() diff --git a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/camera.cpp b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/camera.cpp index 8a2344c85..44fcecb3c 100644 --- a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/camera.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/camera.cpp @@ -13,7 +13,7 @@ #include #include "Eigen/LU" -using namespace Eigen; +using namespace StormEigen; Camera::Camera() : mViewIsUptodate(false), mProjIsUptodate(false) diff --git a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/camera.h b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/camera.h index 15714d2e6..d5b77b76b 100644 --- a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/camera.h +++ b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/camera.h @@ -19,8 +19,8 @@ class Frame public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW - inline Frame(const Eigen::Vector3f& pos = Eigen::Vector3f::Zero(), - const Eigen::Quaternionf& o = Eigen::Quaternionf()) + inline Frame(const StormEigen::Vector3f& pos = StormEigen::Vector3f::Zero(), + const StormEigen::Quaternionf& o = StormEigen::Quaternionf()) : orientation(o), position(pos) {} Frame lerp(float alpha, const Frame& other) const @@ -29,8 +29,8 @@ class Frame orientation.slerp(alpha,other.orientation)); } - Eigen::Quaternionf orientation; - Eigen::Vector3f position; + StormEigen::Quaternionf orientation; + StormEigen::Vector3f position; }; class Camera @@ -57,38 +57,38 @@ class Camera inline float fovY(void) const { return mFovY; } void setFovY(float value); - void setPosition(const Eigen::Vector3f& pos); - inline const Eigen::Vector3f& position(void) const { return mFrame.position; } + void setPosition(const StormEigen::Vector3f& pos); + inline const StormEigen::Vector3f& position(void) const { return mFrame.position; } - void setOrientation(const Eigen::Quaternionf& q); - inline const Eigen::Quaternionf& orientation(void) const { return mFrame.orientation; } + void setOrientation(const StormEigen::Quaternionf& q); + inline const StormEigen::Quaternionf& orientation(void) const { return mFrame.orientation; } void setFrame(const Frame& f); const Frame& frame(void) const { return mFrame; } - void setDirection(const Eigen::Vector3f& newDirection); - Eigen::Vector3f direction(void) const; - void setUp(const Eigen::Vector3f& vectorUp); - Eigen::Vector3f up(void) const; - Eigen::Vector3f right(void) const; + void setDirection(const StormEigen::Vector3f& newDirection); + StormEigen::Vector3f direction(void) const; + void setUp(const StormEigen::Vector3f& vectorUp); + StormEigen::Vector3f up(void) const; + StormEigen::Vector3f right(void) const; - void setTarget(const Eigen::Vector3f& target); - inline const Eigen::Vector3f& target(void) { return mTarget; } + void setTarget(const StormEigen::Vector3f& target); + inline const StormEigen::Vector3f& target(void) { return mTarget; } - const Eigen::Affine3f& viewMatrix(void) const; - const Eigen::Matrix4f& projectionMatrix(void) const; + const StormEigen::Affine3f& viewMatrix(void) const; + const StormEigen::Matrix4f& projectionMatrix(void) const; - void rotateAroundTarget(const Eigen::Quaternionf& q); - void localRotate(const Eigen::Quaternionf& q); + void rotateAroundTarget(const StormEigen::Quaternionf& q); + void localRotate(const StormEigen::Quaternionf& q); void zoom(float d); - void localTranslate(const Eigen::Vector3f& t); + void localTranslate(const StormEigen::Vector3f& t); /** Setup OpenGL matrices and viewport */ void activateGL(void); - Eigen::Vector3f unProject(const Eigen::Vector2f& uv, float depth, const Eigen::Matrix4f& invModelview) const; - Eigen::Vector3f unProject(const Eigen::Vector2f& uv, float depth) const; + StormEigen::Vector3f unProject(const StormEigen::Vector2f& uv, float depth, const Eigen::Matrix4f& invModelview) const; + StormEigen::Vector3f unProject(const StormEigen::Vector2f& uv, float depth) const; protected: void updateViewMatrix(void) const; @@ -101,14 +101,14 @@ class Camera Frame mFrame; - mutable Eigen::Affine3f mViewMatrix; - mutable Eigen::Matrix4f mProjectionMatrix; + mutable StormEigen::Affine3f mViewMatrix; + mutable StormEigen::Matrix4f mProjectionMatrix; mutable bool mViewIsUptodate; mutable bool mProjIsUptodate; // used by rotateAroundTarget - Eigen::Vector3f mTarget; + StormEigen::Vector3f mTarget; float mFovY; float mNearDist; diff --git a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/gpuhelper.h b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/gpuhelper.h index 9ff98e9dc..68621fc7e 100644 --- a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/gpuhelper.h +++ b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/gpuhelper.h @@ -14,7 +14,7 @@ #include #include -using namespace Eigen; +using namespace StormEigen; typedef Vector4f Color; @@ -48,11 +48,11 @@ class GpuHelper \sa Matrix, multMatrix(), forceMatrixMode() */ template - void loadMatrix(const Eigen::Matrix& mat, GLenum matrixTarget); + void loadMatrix(const StormEigen::Matrix& mat, GLenum matrixTarget); template void loadMatrix( - const Eigen::CwiseNullaryOp,Derived>&, + const StormEigen::CwiseNullaryOp,Derived>&, GLenum matrixTarget); /** Make the matrix \a matrixTarget the current OpenGL matrix target. @@ -71,7 +71,7 @@ class GpuHelper template void pushMatrix( - const Eigen::CwiseNullaryOp,Derived>&, + const StormEigen::CwiseNullaryOp,Derived>&, GLenum matrixTarget); /** Push and clone the OpenGL matrix \a matrixTarget @@ -141,12 +141,12 @@ template void GpuHelper::multMatrix(const Matrix& mat, GLenum matrixTarget) { setMatrixTarget(matrixTarget); - GlMatrixHelper<_Flags&Eigen::RowMajorBit, _Flags>::multMatrix(mat); + GlMatrixHelper<_Flags&StormEigen::RowMajorBit, _Flags>::multMatrix(mat); } template void GpuHelper::loadMatrix( - const Eigen::CwiseNullaryOp,Derived>&, + const StormEigen::CwiseNullaryOp,Derived>&, GLenum matrixTarget) { setMatrixTarget(matrixTarget); @@ -154,10 +154,10 @@ void GpuHelper::loadMatrix( } template -void GpuHelper::loadMatrix(const Eigen::Matrix& mat, GLenum matrixTarget) +void GpuHelper::loadMatrix(const StormEigen::Matrix& mat, GLenum matrixTarget) { setMatrixTarget(matrixTarget); - GlMatrixHelper<(_Flags&Eigen::RowMajorBit)!=0, _Flags>::loadMatrix(mat); + GlMatrixHelper<(_Flags&StormEigen::RowMajorBit)!=0, _Flags>::loadMatrix(mat); } inline void GpuHelper::pushMatrix(GLenum matrixTarget) @@ -170,12 +170,12 @@ template inline void GpuHelper::pushMatrix(const Matrix& mat, GLenum matrixTarget) { pushMatrix(matrixTarget); - GlMatrixHelper<_Flags&Eigen::RowMajorBit,_Flags>::loadMatrix(mat); + GlMatrixHelper<_Flags&StormEigen::RowMajorBit,_Flags>::loadMatrix(mat); } template void GpuHelper::pushMatrix( - const Eigen::CwiseNullaryOp,Derived>&, + const StormEigen::CwiseNullaryOp,Derived>&, GLenum matrixTarget) { pushMatrix(matrixTarget); diff --git a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/icosphere.cpp b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/icosphere.cpp index 39444cbb6..3ea3e9a62 100644 --- a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/icosphere.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/icosphere.cpp @@ -12,7 +12,7 @@ #include #include -using namespace Eigen; +using namespace StormEigen; //-------------------------------------------------------------------------------- // icosahedron data diff --git a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/icosphere.h b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/icosphere.h index b0210edc5..b34ddf205 100644 --- a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/icosphere.h +++ b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/icosphere.h @@ -17,12 +17,12 @@ class IcoSphere { public: IcoSphere(unsigned int levels=1); - const std::vector& vertices() const { return mVertices; } + const std::vector& vertices() const { return mVertices; } const std::vector& indices(int level) const; void draw(int level); protected: void _subdivide(); - std::vector mVertices; + std::vector mVertices; std::vector*> mIndices; std::vector mListIds; }; diff --git a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/quaternion_demo.cpp b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/quaternion_demo.cpp index dd323a4c9..72114e81a 100644 --- a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/quaternion_demo.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/quaternion_demo.cpp @@ -25,7 +25,7 @@ #include #include -using namespace Eigen; +using namespace StormEigen; class FancySpheres { @@ -293,7 +293,7 @@ void RenderingWidget::animate() if (mLerpMode==LerpEulerAngles) currentFrame = ::lerpFrame >(s, lo->second, hi->second); else if (mLerpMode==LerpQuaternion) - currentFrame = ::lerpFrame(s, lo->second, hi->second); + currentFrame = ::lerpFrame(s, lo->second, hi->second); else { std::cerr << "Invalid rotation interpolation mode (abort)\n"; diff --git a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/trackball.cpp b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/trackball.cpp index 7c2da8e96..79f7edf45 100644 --- a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/trackball.cpp +++ b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/trackball.cpp @@ -10,7 +10,7 @@ #include "trackball.h" #include "camera.h" -using namespace Eigen; +using namespace StormEigen; void Trackball::track(const Vector2i& point2D) { diff --git a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/trackball.h b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/trackball.h index 1ea842f11..a2c903837 100644 --- a/resources/3rdparty/eigen-3.3-beta1/demos/opengl/trackball.h +++ b/resources/3rdparty/eigen-3.3-beta1/demos/opengl/trackball.h @@ -26,14 +26,14 @@ class Trackball void setCamera(Camera* pCam) { mpCamera = pCam; } - void track(const Eigen::Vector2i& newPoint2D); + void track(const StormEigen::Vector2i& newPoint2D); protected: - bool mapToSphere( const Eigen::Vector2i& p2, Eigen::Vector3f& v3); + bool mapToSphere( const StormEigen::Vector2i& p2, StormEigen::Vector3f& v3); Camera* mpCamera; - Eigen::Vector3f mLastPoint3D; + StormEigen::Vector3f mLastPoint3D; Mode mMode; bool mLastPointOk; diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/A05_PortingFrom2To3.dox b/resources/3rdparty/eigen-3.3-beta1/doc/A05_PortingFrom2To3.dox index 2d9182bbb..7bc45cd83 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/A05_PortingFrom2To3.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/A05_PortingFrom2To3.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page Eigen2ToEigen3 Porting from Eigen2 to Eigen3 @@ -16,7 +16,7 @@ You can still use them by first Eigen 2Eigen 3 diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/B01_Experimental.dox b/resources/3rdparty/eigen-3.3-beta1/doc/B01_Experimental.dox index e1f031db8..1e5f18a93 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/B01_Experimental.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/B01_Experimental.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page Experimental Experimental parts of Eigen diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/ClassHierarchy.dox b/resources/3rdparty/eigen-3.3-beta1/doc/ClassHierarchy.dox index 468e60a76..95e5068a9 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/ClassHierarchy.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/ClassHierarchy.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page TopicClassHierarchy The class hierarchy diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/CustomizingEigen.dox b/resources/3rdparty/eigen-3.3-beta1/doc/CustomizingEigen.dox index cb25f4ec9..31955130d 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/CustomizingEigen.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/CustomizingEigen.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page TopicCustomizingEigen Customizing/Extending Eigen @@ -92,11 +92,11 @@ Output: \verbinclude CustomizingEigen_Inheritance.out This is the kind of error you can get if you don't provide those methods \verbatim -error: no match for ‘operator=’ in ‘v = Eigen::operator*( -const Eigen::MatrixBase >::Scalar&, -const Eigen::MatrixBase >::StorageBaseType&) -(((const Eigen::MatrixBase >::StorageBaseType&) -((const Eigen::MatrixBase >::StorageBaseType*)(& v))))’ +error: no match for ‘operator=’ in ‘v = StormEigen::operator*( +const StormEigen::MatrixBase >::Scalar&, +const StormEigen::MatrixBase >::StorageBaseType&) +(((const StormEigen::MatrixBase >::StorageBaseType&) +((const StormEigen::MatrixBase >::StorageBaseType*)(& v))))’ \endverbatim \anchor user_defined_scalars \section CustomScalarType Using custom scalar types @@ -106,7 +106,7 @@ On x86-64 systems, \c long \c double permits to locally enforces the use of x87 In order to add support for a custom type \c T you need: -# make sure the common operator (+,-,*,/,etc.) are supported by the type \c T --# add a specialization of struct Eigen::NumTraits (see \ref NumTraits) +-# add a specialization of struct StormEigen::NumTraits (see \ref NumTraits) -# define the math functions that makes sense for your type. This includes standard ones like sqrt, pow, sin, tan, conj, real, imag, etc, as well as abs2 which is Eigen specific. (see the file Eigen/src/Core/MathFunctions.h) @@ -122,7 +122,7 @@ Here is a concrete example adding support for the Adolc's \c adouble type. #include -namespace Eigen { +namespace StormEigen { template<> struct NumTraits : NumTraits // permits to get the epsilon, dummy_precision, lowest, highest functions @@ -164,7 +164,7 @@ This other example adds support for the \c mpq_class type from . diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/LeastSquares.dox b/resources/3rdparty/eigen-3.3-beta1/doc/LeastSquares.dox index e2191a22f..1cbefe8ea 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/LeastSquares.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/LeastSquares.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage LeastSquares Solving linear least squares systems @@ -67,4 +67,4 @@ lose twice as many digits using normal equation than if you use the other method */ -} \ No newline at end of file +} diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/Manual.dox b/resources/3rdparty/eigen-3.3-beta1/doc/Manual.dox index c10c490a7..9126f3022 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/Manual.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/Manual.dox @@ -1,7 +1,7 @@ // This file strutures pages and modules into a convenient hierarchical structure. -namespace Eigen { +namespace StormEigen { /** \page UserManual_Generalities General topics - \subpage Eigen2ToEigen3 diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/MatrixfreeSolverExample.dox b/resources/3rdparty/eigen-3.3-beta1/doc/MatrixfreeSolverExample.dox index 000cb0bbe..d0217e9d6 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/MatrixfreeSolverExample.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/MatrixfreeSolverExample.dox @@ -1,5 +1,5 @@ -namespace Eigen { +namespace StormEigen { /** @@ -9,12 +9,12 @@ Iterative solvers such as ConjugateGradient and BiCGSTAB can be used in a matrix - Index rows() and Index cols(): returns number of rows and columns respectively - operator* with and %Eigen dense column vector (its actual implementation goes in a specialization of the internal::generic_product_impl class) -Eigen::internal::traits<> must also be specialized for the wrapper type. +StormEigen::internal::traits<> must also be specialized for the wrapper type. -Here is a complete example wrapping a Eigen::SparseMatrix: +Here is a complete example wrapping a StormEigen::SparseMatrix: \include matrixfree_cg.cpp Output: \verbinclude matrixfree_cg.out */ -} \ No newline at end of file +} diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/NewExpressionType.dox b/resources/3rdparty/eigen-3.3-beta1/doc/NewExpressionType.dox index ad8b7f86b..4fa09fd2e 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/NewExpressionType.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/NewExpressionType.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page TopicNewExpressionType Adding a new expression type @@ -51,7 +51,7 @@ to the \c makeCirculant function. \section TopicTraits The traits class For every expression class \c X, there should be a traits class -\c Traits in the \c Eigen::internal namespace containing +\c Traits in the \c StormEigen::internal namespace containing information about \c X known as compile time. As explained in \ref TopicSetting, we designed the \c Circulant diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/Overview.dox b/resources/3rdparty/eigen-3.3-beta1/doc/Overview.dox index 9ab96233a..64e69263c 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/Overview.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/Overview.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \mainpage notitle diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/PassingByValue.dox b/resources/3rdparty/eigen-3.3-beta1/doc/PassingByValue.dox index bf4d0ef4b..b4f7d368f 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/PassingByValue.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/PassingByValue.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TopicPassingByValue Passing Eigen objects by value to functions @@ -9,13 +9,13 @@ With Eigen, this is even more important: passing \ref TopicFixedSizeVectorizable So for example, a function like this, where v is passed by value: \code -void my_function(Eigen::Vector2d v); +void my_function(StormEigen::Vector2d v); \endcode needs to be rewritten as follows, passing v by reference: \code -void my_function(const Eigen::Vector2d& v); +void my_function(const StormEigen::Vector2d& v); \endcode Likewise if you have a class having a Eigen object as member: @@ -23,7 +23,7 @@ Likewise if you have a class having a Eigen object as member: \code struct Foo { - Eigen::Vector2d v; + StormEigen::Vector2d v; }; void my_function(Foo v); \endcode diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/Pitfalls.dox b/resources/3rdparty/eigen-3.3-beta1/doc/Pitfalls.dox index cf42effef..7f35040c5 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/Pitfalls.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/Pitfalls.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page TopicPitfalls Common pitfalls diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/PreprocessorDirectives.dox b/resources/3rdparty/eigen-3.3-beta1/doc/PreprocessorDirectives.dox index 7cde1a36f..e84ce42ad 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/PreprocessorDirectives.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/PreprocessorDirectives.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page TopicPreprocessorDirectives Preprocessor directives diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/QuickReference.dox b/resources/3rdparty/eigen-3.3-beta1/doc/QuickReference.dox index 62b39b201..2c1bc46c8 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/QuickReference.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/QuickReference.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage QuickRefPage Quick reference guide @@ -153,8 +153,8 @@ vector.resizeLike(other_vector); vector.conservativeResize(size); \endcode\code matrix.resize(nb_rows, nb_cols); -matrix.resize(Eigen::NoChange, nb_cols); -matrix.resize(nb_rows, Eigen::NoChange); +matrix.resize(StormEigen::NoChange, nb_cols); +matrix.resize(nb_rows, StormEigen::NoChange); matrix.resizeLike(other_matrix); matrix.conservativeResize(nb_rows, nb_cols); \endcodeno-op if the new sizes match,
otherwise data are lost

resizing with data preservation @@ -650,18 +650,18 @@ m.triangularView() Writing to a specific triangular part:\n (only the referenced triangular part is evaluated) \code -m1.triangularView() = m2 + m3 \endcode +m1.triangularView() = m2 + m3 \endcode Conversion to a dense matrix setting the opposite triangular part to zero: \code -m2 = m1.triangularView()\endcode +m2 = m1.triangularView()\endcode Products: \code -m3 += s1 * m1.adjoint().triangularView() * m2 -m3 -= s1 * m2.conjugate() * m1.adjoint().triangularView() \endcode +m3 += s1 * m1.adjoint().triangularView() * m2 +m3 -= s1 * m2.conjugate() * m1.adjoint().triangularView() \endcode Solving linear equations:\n @@ -669,9 +669,9 @@ Solving linear equations:\n \f$ M_3 := {L_1^*}^{-1} M_3 \f$ \n \f$ M_4 := M_4 U_1^{-1} \f$ \n \code -L1.triangularView().solveInPlace(M2) -L1.triangularView().adjoint().solveInPlace(M3) -U1.triangularView().solveInPlace(M4)\endcode +L1.triangularView().solveInPlace(M2) +L1.triangularView().adjoint().solveInPlace(M3) +U1.triangularView().solveInPlace(M4)\endcode @@ -689,35 +689,35 @@ object of a type that depends on a template parameter; see \ref TopicTemplateKey Conversion to a dense matrix: \code -m2 = m.selfadjointView();\endcode +m2 = m.selfadjointView();\endcode Product with another general matrix or vector: \code -m3 = s1 * m1.conjugate().selfadjointView() * m3; -m3 -= s1 * m3.adjoint() * m1.selfadjointView();\endcode +m3 = s1 * m1.conjugate().selfadjointView() * m3; +m3 -= s1 * m3.adjoint() * m1.selfadjointView();\endcode Rank 1 and rank K update: \n \f$ upper(M_1) \mathrel{{+}{=}} s_1 M_2 M_2^* \f$ \n \f$ lower(M_1) \mathbin{{-}{=}} M_2^* M_2 \f$ \n \code -M1.selfadjointView().rankUpdate(M2,s1); -M1.selfadjointView().rankUpdate(M2.adjoint(),-1); \endcode +M1.selfadjointView().rankUpdate(M2,s1); +M1.selfadjointView().rankUpdate(M2.adjoint(),-1); \endcode Rank 2 update: (\f$ M \mathrel{{+}{=}} s u v^* + s v u^* \f$) \code -M.selfadjointView().rankUpdate(u,v,s); +M.selfadjointView().rankUpdate(u,v,s); \endcode Solving linear equations:\n(\f$ M_2 := M_1^{-1} M_2 \f$) \code // via a standard Cholesky factorization -m2 = m1.selfadjointView().llt().solve(m2); +m2 = m1.selfadjointView().llt().solve(m2); // via a Cholesky factorization with pivoting -m2 = m1.selfadjointView().ldlt().solve(m2); +m2 = m1.selfadjointView().ldlt().solve(m2); \endcode diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/QuickStartGuide.dox b/resources/3rdparty/eigen-3.3-beta1/doc/QuickStartGuide.dox index ea32c3b3d..30d494ace 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/QuickStartGuide.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/QuickStartGuide.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page GettingStarted Getting started diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/SparseLinearSystems.dox b/resources/3rdparty/eigen-3.3-beta1/doc/SparseLinearSystems.dox index 9fb3282e7..4e89fbe25 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/SparseLinearSystems.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/SparseLinearSystems.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TopicSparseSystems Solving Sparse Linear Systems In Eigen, there are several methods available to solve linear systems when the coefficient matrix is sparse. Because of the special representation of this class of matrices, special care should be taken in order to get a good performance. See \ref TutorialSparse for a detailed introduction about sparse matrices in Eigen. This page lists the sparse solvers available in Eigen. The main steps that are common to all these linear solvers are introduced as well. Depending on the properties of the matrix, the desired accuracy, the end-user is able to tune those steps in order to improve the performance of its code. Note that it is not required to know deeply what's hiding behind these steps: the last section presents a benchmark routine that can be easily used to get an insight on the performance of all the available solvers. @@ -112,7 +112,7 @@ For \c SPD solvers, a second optional template argument allows to specify which \code #include -ConjugateGradient, Eigen::Upper> solver; +ConjugateGradient, StormEigen::Upper> solver; x = solver.compute(A).solve(b); \endcode In the above example, only the upper triangular part of the input matrix A is considered for solving. The opposite triangle might either be empty or contain arbitrary values. @@ -180,9 +180,9 @@ To export your matrices and right-hand-side vectors in the matrix-market format, \code #include ... -Eigen::saveMarket(A, "filename.mtx"); -Eigen::saveMarket(A, "filename_SPD.mtx", Eigen::Symmetric); // if A is symmetric-positive-definite -Eigen::saveMarketVector(B, "filename_b.mtx"); +StormEigen::saveMarket(A, "filename.mtx"); +StormEigen::saveMarket(A, "filename_SPD.mtx", StormEigen::Symmetric); // if A is symmetric-positive-definite +StormEigen::saveMarketVector(B, "filename_b.mtx"); \endcode The following table gives an example of XML statistics from several Eigen built-in and external solvers. diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/SparseQuickReference.dox b/resources/3rdparty/eigen-3.3-beta1/doc/SparseQuickReference.dox index d04ac35c5..616656690 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/SparseQuickReference.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/SparseQuickReference.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage SparseQuickRefPage Quick reference guide for sparse matrices \eigenAutoToc @@ -59,7 +59,7 @@ i.e either row major or column major. The default is column major. Most arithmet Batch insertion \code - std::vector< Eigen::Triplet > tripletList; + std::vector< StormEigen::Triplet > tripletList; tripletList.reserve(estimation_of_entries); // -- Fill tripletList with nonzero elements... sm1.setFromTriplets(TripletList.begin(), TripletList.end()); diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/StlContainers.dox b/resources/3rdparty/eigen-3.3-beta1/doc/StlContainers.dox index e0f8714a9..6196027e8 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/StlContainers.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/StlContainers.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TopicStlContainers Using STL Containers with Eigen @@ -15,34 +15,34 @@ These issues arise only with \ref TopicFixedSizeVectorizable "fixed-size vectori \section allocator Using an aligned allocator -STL containers take an optional template parameter, the allocator type. When using STL containers on \ref TopicFixedSizeVectorizable "fixed-size vectorizable Eigen types", you need tell the container to use an allocator that will always allocate memory at 16-byte-aligned locations. Fortunately, Eigen does provide such an allocator: Eigen::aligned_allocator. +STL containers take an optional template parameter, the allocator type. When using STL containers on \ref TopicFixedSizeVectorizable "fixed-size vectorizable Eigen types", you need tell the container to use an allocator that will always allocate memory at 16-byte-aligned locations. Fortunately, Eigen does provide such an allocator: StormEigen::aligned_allocator. For example, instead of \code -std::map +std::map \endcode you need to use \code -std::map, - Eigen::aligned_allocator > > +std::map, + StormEigen::aligned_allocator > > \endcode Note that the third parameter "std::less" is just the default value, but we have to include it because we want to specify the fourth parameter, which is the allocator type. \section StlContainers_vector The case of std::vector -The situation with std::vector was even worse (explanation below) so we had to specialize it for the Eigen::aligned_allocator type. In practice you \b must use the Eigen::aligned_allocator (not another aligned allocator), \b and \#include . +The situation with std::vector was even worse (explanation below) so we had to specialize it for the StormEigen::aligned_allocator type. In practice you \b must use the StormEigen::aligned_allocator (not another aligned allocator), \b and \#include . Here is an example: \code #include /* ... */ -std::vector > +std::vector > \endcode \subsection vector_spec An alternative - specializing std::vector for Eigen types As an alternative to the recommended approach described above, you have the option to specialize std::vector for Eigen types requiring alignment. -The advantage is that you won't need to declare std::vector all over with Eigen::allocator. One drawback on the other hand side is that +The advantage is that you won't need to declare std::vector all over with StormEigen::allocator. One drawback on the other hand side is that the specialization needs to be defined before all code pieces in which e.g. std::vector is used. Otherwise, without knowing the specialization the compiler will compile that particular instance with the default std::allocator and you program is most likely to crash. @@ -51,10 +51,10 @@ Here is an example: #include /* ... */ EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix2d) -std::vector +std::vector \endcode -\b Explanation: The resize() method of std::vector takes a value_type argument (defaulting to value_type()). So with std::vector, some Eigen::Vector4f objects will be passed by value, which discards any alignment modifiers, so a Eigen::Vector4f can be created at an unaligned location. In order to avoid that, the only solution we saw was to specialize std::vector to make it work on a slight modification of, here, Eigen::Vector4f, that is able to deal properly with this situation. +\b Explanation: The resize() method of std::vector takes a value_type argument (defaulting to value_type()). So with std::vector, some StormEigen::Vector4f objects will be passed by value, which discards any alignment modifiers, so a Eigen::Vector4f can be created at an unaligned location. In order to avoid that, the only solution we saw was to specialize std::vector to make it work on a slight modification of, here, Eigen::Vector4f, that is able to deal properly with this situation. */ diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/StorageOrders.dox b/resources/3rdparty/eigen-3.3-beta1/doc/StorageOrders.dox index 61645313e..e1b16c65c 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/StorageOrders.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/StorageOrders.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TopicStorageOrders Storage orders diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/StructHavingEigenMembers.dox b/resources/3rdparty/eigen-3.3-beta1/doc/StructHavingEigenMembers.dox index bd4fa7599..0d358635b 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/StructHavingEigenMembers.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/StructHavingEigenMembers.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TopicStructHavingEigenMembers Structures Having Eigen Members @@ -16,7 +16,7 @@ The kind of code that needs to be changed is this: class Foo { ... - Eigen::Vector2d v; + StormEigen::Vector2d v; ... }; @@ -35,7 +35,7 @@ Very easy, you just need to put a EIGEN_MAKE_ALIGNED_OPERATOR_NEW macro in a pub class Foo { ... - Eigen::Vector2d v; + StormEigen::Vector2d v; ... public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW @@ -58,7 +58,7 @@ OK let's say that your code looks like this: class Foo { ... - Eigen::Vector2d v; + StormEigen::Vector2d v; ... }; @@ -67,11 +67,11 @@ class Foo Foo *foo = new Foo; \endcode -A Eigen::Vector2d consists of 2 doubles, which is 128 bits. Which is exactly the size of a SSE packet, which makes it possible to use SSE for all sorts of operations on this vector. But SSE instructions (at least the ones that Eigen uses, which are the fast ones) require 128-bit alignment. Otherwise you get a segmentation fault. +A StormEigen::Vector2d consists of 2 doubles, which is 128 bits. Which is exactly the size of a SSE packet, which makes it possible to use SSE for all sorts of operations on this vector. But SSE instructions (at least the ones that Eigen uses, which are the fast ones) require 128-bit alignment. Otherwise you get a segmentation fault. -For this reason, Eigen takes care by itself to require 128-bit alignment for Eigen::Vector2d, by doing two things: -\li Eigen requires 128-bit alignment for the Eigen::Vector2d's array (of 2 doubles). With GCC, this is done with a __attribute__ ((aligned(16))). -\li Eigen overloads the "operator new" of Eigen::Vector2d so it will always return 128-bit aligned pointers. +For this reason, Eigen takes care by itself to require 128-bit alignment for StormEigen::Vector2d, by doing two things: +\li Eigen requires 128-bit alignment for the StormEigen::Vector2d's array (of 2 doubles). With GCC, this is done with a __attribute__ ((aligned(16))). +\li Eigen overloads the "operator new" of StormEigen::Vector2d so it will always return 128-bit aligned pointers. Thus, normally, you don't have to worry about anything, Eigen handles alignment for you... @@ -89,7 +89,7 @@ That's not required. Since Eigen takes care of declaring 128-bit alignment, all class Foo { double x; - Eigen::Vector2d v; + StormEigen::Vector2d v; public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; @@ -97,7 +97,7 @@ public: \section StructHavingEigenMembers_dynamicsize What about dynamic-size matrices and vectors? -Dynamic-size matrices and vectors, such as Eigen::VectorXd, allocate dynamically their own array of coefficients, so they take care of requiring absolute alignment automatically. So they don't cause this issue. The issue discussed here is only with \ref TopicFixedSizeVectorizable "fixed-size vectorizable matrices and vectors". +Dynamic-size matrices and vectors, such as StormEigen::VectorXd, allocate dynamically their own array of coefficients, so they take care of requiring absolute alignment automatically. So they don't cause this issue. The issue discussed here is only with \ref TopicFixedSizeVectorizable "fixed-size vectorizable matrices and vectors". \section StructHavingEigenMembers_bugineigen So is this a bug in Eigen? @@ -112,7 +112,7 @@ Example: \code template class Foo { - typedef Eigen::Matrix Vector; + typedef StormEigen::Matrix Vector; enum { NeedsToAlign = (sizeof(Vector)%16)==0 }; ... Vector v; @@ -139,7 +139,7 @@ The first is to disable alignment requirement for the fixed size members: class Foo { ... - Eigen::Matrix v; + StormEigen::Matrix v; ... }; \endcode @@ -148,7 +148,7 @@ If a function of Foo uses it several times, then it still possible to re-enable \code void Foo::bar() { - Eigen::Vector2d av(v); + StormEigen::Vector2d av(v); // use av instead of v ... // if av changed, then do: diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TemplateKeyword.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TemplateKeyword.dox index e06aba7ba..3a743eef5 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TemplateKeyword.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TemplateKeyword.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page TopicTemplateKeyword The template and typename keywords in C++ diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TopicAliasing.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TopicAliasing.dox index c2654aed2..e2d6ee68f 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TopicAliasing.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TopicAliasing.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TopicAliasing Aliasing @@ -64,8 +64,8 @@ Again, the output shows the aliasing issue. However, by default %Eigen uses a ru and exits with a message like \verbatim -void Eigen::DenseBase::checkTransposeAliasing(const OtherDerived&) const -[with OtherDerived = Eigen::Transpose >, Derived = Eigen::Matrix]: +void StormEigen::DenseBase::checkTransposeAliasing(const OtherDerived&) const +[with OtherDerived = StormEigen::Transpose >, Derived = Eigen::Matrix]: Assertion `(!internal::check_transpose_aliasing_selector::IsTransposed,OtherDerived>::run(internal::extract_data(derived()), other)) && "aliasing detected during transposition, use transposeInPlace() or evaluate the rhs into a temporary using .eval()"' failed. \endverbatim diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TopicAssertions.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TopicAssertions.dox index 4ead40174..b61d1cab1 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TopicAssertions.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TopicAssertions.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page TopicAssertions Assertions @@ -41,7 +41,7 @@ One can easily come up with static assertions without messages, such as: switch(0) { case 0: case x:; } \endcode -However, the example above obviously cannot tell why the assertion failed. Therefore, we define a \c struct in namespace Eigen::internal to handle available messages. +However, the example above obviously cannot tell why the assertion failed. Therefore, we define a \c struct in namespace StormEigen::internal to handle available messages. \code template @@ -58,7 +58,7 @@ struct static_assertion }; \endcode -And then, we define EIGEN_STATIC_ASSERT(CONDITION,MSG) to access Eigen::internal::static_assertion::MSG. If the condition evaluates into \c false, your compiler displays a lot of messages explaining there is no MSG in static_assert. Nevertheless, this is \a not in what we are interested. As you can see, all members of static_assert are ALL_CAPS_AND_THEY_ARE_SHOUTING. +And then, we define EIGEN_STATIC_ASSERT(CONDITION,MSG) to access StormEigen::internal::static_assertion::MSG. If the condition evaluates into \c false, your compiler displays a lot of messages explaining there is no MSG in static_assert. Nevertheless, this is \a not in what we are interested. As you can see, all members of static_assert are ALL_CAPS_AND_THEY_ARE_SHOUTING. \warning When using this macro, MSG should be a member of static_assertion, or the static assertion \b always fails. diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TopicEigenExpressionTemplates.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TopicEigenExpressionTemplates.dox index b31fd47f9..ef9f95dd0 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TopicEigenExpressionTemplates.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TopicEigenExpressionTemplates.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page TopicEigenExpressionTemplates Expression templates in Eigen diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TopicLazyEvaluation.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TopicLazyEvaluation.dox index 393bc41d8..2bc4de03a 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TopicLazyEvaluation.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TopicLazyEvaluation.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page TopicLazyEvaluation Lazy Evaluation and Aliasing diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TopicLinearAlgebraDecompositions.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TopicLinearAlgebraDecompositions.dox index 5bcff2c96..63e5a4b6d 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TopicLinearAlgebraDecompositions.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TopicLinearAlgebraDecompositions.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TopicLinearAlgebraDecompositions Catalogue of dense decompositions diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TopicMultithreading.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TopicMultithreading.dox index 47c9b261f..fbeb4f46e 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TopicMultithreading.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TopicMultithreading.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page TopicMultiThreading Eigen and multi-threading @@ -12,12 +12,12 @@ You can control the number of thread that will be used using either the OpenMP A \code OMP_NUM_THREADS=n ./my_program omp_set_num_threads(n); - Eigen::setNbThreads(n); + StormEigen::setNbThreads(n); \endcode Unless setNbThreads has been called, Eigen uses the number of threads specified by OpenMP. You can restore this behavior by calling \code setNbThreads(0); \endcode You can query the number of threads that will be used with: \code -n = Eigen::nbThreads( ); +n = StormEigen::nbThreads( ); \endcode You can disable Eigen's multi threading at compile time by defining the EIGEN_DONT_PARALLELIZE preprocessor token. @@ -37,7 +37,7 @@ In the case your own application is multithreaded, and multiple threads make cal int main(int argc, char** argv) { - Eigen::initParallel(); + StormEigen::initParallel(); ... } @@ -45,7 +45,7 @@ int main(int argc, char** argv) \note With Eigen 3.3, and a fully C++11 compliant compiler (i.e.,
thread-safe static local variable initialization), then calling \c initParallel() is optional. -\warning note that all functions generating random matrices are \b not re-entrant nor thread-safe. Those include DenseBase::Random(), and DenseBase::setRandom() despite a call to Eigen::initParallel(). This is because these functions are based on std::rand which is not re-entrant. For thread-safe random generator, we recommend the use of boost::random or c++11 random feature. +\warning note that all functions generating random matrices are \b not re-entrant nor thread-safe. Those include DenseBase::Random(), and DenseBase::setRandom() despite a call to StormEigen::initParallel(). This is because these functions are based on std::rand which is not re-entrant. For thread-safe random generator, we recommend the use of boost::random or c++11 random feature. In the case your application is parallelized with OpenMP, you might want to disable Eigen's own parallization as detailed in the previous section. diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TopicResizing.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TopicResizing.dox index c323e17ad..397c2620f 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TopicResizing.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TopicResizing.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page TopicResizing Resizing diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TopicScalarTypes.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TopicScalarTypes.dox index 2ff03c198..831a2a8ea 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TopicScalarTypes.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TopicScalarTypes.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page TopicScalarTypes Scalar types diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TopicVectorization.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TopicVectorization.dox index 274d0451b..99e771530 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TopicVectorization.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TopicVectorization.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \page TopicVectorization Vectorization diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialAdvancedInitialization.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialAdvancedInitialization.dox index 50374d0d0..0e0333eb3 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialAdvancedInitialization.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialAdvancedInitialization.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TutorialAdvancedInitialization Advanced initialization diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialArrayClass.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialArrayClass.dox index 6432684aa..0005ffbd5 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialArrayClass.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialArrayClass.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TutorialArrayClass The Array class and coefficient-wise operations @@ -111,7 +111,7 @@ arrays can be multiplied if and only if they have the same dimensions. The Array class defines other coefficient-wise operations besides the addition, subtraction and multiplication operators described above. For example, the \link ArrayBase::abs() .abs() \endlink method takes the absolute value of each coefficient, while \link ArrayBase::sqrt() .sqrt() \endlink computes the square root of the -coefficients. If you have two arrays of the same size, you can call \link ArrayBase::min(const Eigen::ArrayBase&) const .min(.) \endlink to +coefficients. If you have two arrays of the same size, you can call \link ArrayBase::min(const StormEigen::ArrayBase&) const .min(.) \endlink to construct the array whose coefficients are the minimum of the corresponding coefficients of the two given arrays. These operations are illustrated in the following example. diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialBlockOperations.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialBlockOperations.dox index a2d8c97cc..45eed2dcb 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialBlockOperations.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialBlockOperations.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TutorialBlockOperations Block operations diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialGeometry.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialGeometry.dox index 2e1420f98..0b83ae9b6 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialGeometry.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialGeometry.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TutorialGeometry Space transformations diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialLinearAlgebra.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialLinearAlgebra.dox index cb92ceeae..68602d8f2 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialLinearAlgebra.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialLinearAlgebra.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TutorialLinearAlgebra Linear algebra and decompositions diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialMapClass.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialMapClass.dox index f8fb0fd2f..fc3283420 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialMapClass.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialMapClass.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TutorialMapClass Interfacing with raw buffers: the Map class diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialMatrixArithmetic.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialMatrixArithmetic.dox index 5fc569a30..a55d0f6fd 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialMatrixArithmetic.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialMatrixArithmetic.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TutorialMatrixArithmetic Matrix and vector arithmetic diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialMatrixClass.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialMatrixClass.dox index 7ea0cd789..ed28b6daa 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialMatrixClass.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialMatrixClass.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TutorialMatrixClass The Matrix class diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialReductionsVisitorsBroadcasting.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialReductionsVisitorsBroadcasting.dox index 908a1b4b2..279626afa 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialReductionsVisitorsBroadcasting.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialReductionsVisitorsBroadcasting.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TutorialReductionsVisitorsBroadcasting Reductions, visitors and broadcasting diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialSparse.dox b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialSparse.dox index fb07adaa2..1afb0b23b 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/TutorialSparse.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/TutorialSparse.dox @@ -1,4 +1,4 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TutorialSparse Sparse matrix manipulations @@ -195,7 +195,7 @@ The simplest way to create a sparse matrix while guaranteeing good performance i Here is a typical usage example: \code -typedef Eigen::Triplet T; +typedef StormEigen::Triplet T; std::vector tripletList; tripletList.reserve(estimation_of_entries); for(...) diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/UnalignedArrayAssert.dox b/resources/3rdparty/eigen-3.3-beta1/doc/UnalignedArrayAssert.dox index 8c97d7874..6d6f71499 100644 --- a/resources/3rdparty/eigen-3.3-beta1/doc/UnalignedArrayAssert.dox +++ b/resources/3rdparty/eigen-3.3-beta1/doc/UnalignedArrayAssert.dox @@ -1,11 +1,11 @@ -namespace Eigen { +namespace StormEigen { /** \eigenManualPage TopicUnalignedArrayAssert Explanation of the assertion on unaligned arrays Hello! You are seeing this webpage because your program terminated on an assertion failure like this one:
 my_program: path/to/eigen/Eigen/src/Core/DenseStorage.h:44:
-Eigen::internal::matrix_array::internal::matrix_array()
+StormEigen::internal::matrix_array::internal::matrix_array()
 [with T = double, int Size = 2, int MatrixOptions = 2, bool Align = true]:
 Assertion `(reinterpret_cast(array) & 0xf) == 0 && "this assertion
 is explained here: http://eigen.tuxfamily.org/dox/UnalignedArrayAssert.html
@@ -35,7 +35,7 @@ If you have code like this,
 class Foo
 {
   //...
-  Eigen::Vector2d v;
+  StormEigen::Vector2d v;
   //...
 };
 //...
@@ -44,33 +44,33 @@ Foo *foo = new Foo;
 
 then you need to read this separate page: \ref TopicStructHavingEigenMembers "Structures Having Eigen Members".
 
-Note that here, Eigen::Vector2d is only used as an example, more generally the issue arises for all \ref TopicFixedSizeVectorizable "fixed-size vectorizable Eigen types".
+Note that here, StormEigen::Vector2d is only used as an example, more generally the issue arises for all \ref TopicFixedSizeVectorizable "fixed-size vectorizable Eigen types".
 
 \section c2 Cause 2: STL Containers
 
 If you use STL Containers such as std::vector, std::map, ..., with Eigen objects, or with classes containing Eigen objects, like this,
 
 \code
-std::vector my_vector;
-struct my_class { ... Eigen::Matrix2f m; ... };
+std::vector my_vector;
+struct my_class { ... StormEigen::Matrix2f m; ... };
 std::map my_map;
 \endcode
 
 then you need to read this separate page: \ref TopicStlContainers "Using STL Containers with Eigen".
 
-Note that here, Eigen::Matrix2f is only used as an example, more generally the issue arises for all \ref TopicFixedSizeVectorizable "fixed-size vectorizable Eigen types" and \ref TopicStructHavingEigenMembers "structures having such Eigen objects as member".
+Note that here, StormEigen::Matrix2f is only used as an example, more generally the issue arises for all \ref TopicFixedSizeVectorizable "fixed-size vectorizable Eigen types" and \ref TopicStructHavingEigenMembers "structures having such Eigen objects as member".
 
 \section c3 Cause 3: Passing Eigen objects by value
 
 If some function in your code is getting an Eigen object passed by value, like this,
 
 \code
-void func(Eigen::Vector4d v);
+void func(StormEigen::Vector4d v);
 \endcode
 
 then you need to read this separate page: \ref TopicPassingByValue "Passing Eigen objects by value to functions".
 
-Note that here, Eigen::Vector4d is only used as an example, more generally the issue arises for all \ref TopicFixedSizeVectorizable "fixed-size vectorizable Eigen types".
+Note that here, StormEigen::Vector4d is only used as an example, more generally the issue arises for all \ref TopicFixedSizeVectorizable "fixed-size vectorizable Eigen types".
 
 \section c4 Cause 4: Compiler making a wrong assumption on stack alignment (for instance GCC on Windows)
 
@@ -79,14 +79,14 @@ This is a must-read for people using GCC on Windows (like MinGW or TDM-GCC). If
 \code
 void foo()
 {
-  Eigen::Quaternionf q;
+  StormEigen::Quaternionf q;
   //...
 }
 \endcode
 
 then you need to read this separate page: \ref TopicWrongStackAlignment "Compiler making a wrong assumption on stack alignment".
 
-Note that here, Eigen::Quaternionf is only used as an example, more generally the issue arises for all \ref TopicFixedSizeVectorizable "fixed-size vectorizable Eigen types".
+Note that here, StormEigen::Quaternionf is only used as an example, more generally the issue arises for all \ref TopicFixedSizeVectorizable "fixed-size vectorizable Eigen types".
 
 \section explanation General explanation of this assertion
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/UsingIntelMKL.dox b/resources/3rdparty/eigen-3.3-beta1/doc/UsingIntelMKL.dox
index 84db992b6..671d5f7ab 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/UsingIntelMKL.dox
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/UsingIntelMKL.dox
@@ -30,7 +30,7 @@
  ********************************************************************************
 */
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \page TopicUsingIntelMKL Using Intel® Math Kernel Library from Eigen
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/UsingNVCC.dox b/resources/3rdparty/eigen-3.3-beta1/doc/UsingNVCC.dox
index f8e755b79..7b151b478 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/UsingNVCC.dox
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/UsingNVCC.dox
@@ -1,5 +1,5 @@
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \page TopicCUDA Using Eigen in CUDA kernels
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/WrongStackAlignment.dox b/resources/3rdparty/eigen-3.3-beta1/doc/WrongStackAlignment.dox
index 17d5513a7..e5684175c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/WrongStackAlignment.dox
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/WrongStackAlignment.dox
@@ -1,4 +1,4 @@
-namespace Eigen {
+namespace StormEigen {
 
 /** \eigenManualPage TopicWrongStackAlignment Compiler making a wrong assumption on stack alignment
 
@@ -12,7 +12,7 @@ By default, in a function like this,
 \code
 void foo()
 {
-  Eigen::Quaternionf q;
+  StormEigen::Quaternionf q;
   //...
 }
 \endcode
@@ -28,7 +28,7 @@ A local solution is to mark such a function with this attribute:
 \code
 __attribute__((force_align_arg_pointer)) void foo()
 {
-  Eigen::Quaternionf q;
+  StormEigen::Quaternionf q;
   //...
 }
 \endcode
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/CustomizingEigen_Inheritance.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/CustomizingEigen_Inheritance.cpp
index 48df64ee3..d347ed811 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/CustomizingEigen_Inheritance.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/CustomizingEigen_Inheritance.cpp
@@ -1,22 +1,22 @@
 #include 
 #include 
 
-class MyVectorType : public Eigen::VectorXd
+class MyVectorType : public StormEigen::VectorXd
 {
 public:
-    MyVectorType(void):Eigen::VectorXd() {}
+    MyVectorType(void):StormEigen::VectorXd() {}
 
     // This constructor allows you to construct MyVectorType from Eigen expressions
     template
-    MyVectorType(const Eigen::MatrixBase& other)
-        : Eigen::VectorXd(other)
+    MyVectorType(const StormEigen::MatrixBase& other)
+        : StormEigen::VectorXd(other)
     { }
 
     // This method allows you to assign Eigen expressions to MyVectorType
     template
-    MyVectorType& operator=(const Eigen::MatrixBase & other)
+    MyVectorType& operator=(const StormEigen::MatrixBase & other)
     {
-        this->Eigen::VectorXd::operator=(other);
+        this->StormEigen::VectorXd::operator=(other);
         return *this;
     }
 };
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_middleCols_int.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_middleCols_int.cpp
index 0ebd955ec..04f41c787 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_middleCols_int.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_middleCols_int.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main(void)
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_middleRows_int.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_middleRows_int.cpp
index a6fe9e844..f8cdbc5c8 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_middleRows_int.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_middleRows_int.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main(void)
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_template_int_middleCols.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_template_int_middleCols.cpp
index 6191d79c8..b1a1220f0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_template_int_middleCols.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_template_int_middleCols.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main(void)
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_template_int_middleRows.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_template_int_middleRows.cpp
index 7e8b6573f..fe16d58f9 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_template_int_middleRows.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/DenseBase_template_int_middleRows.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main(void)
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/QuickStart_example.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/QuickStart_example.cpp
index 7238c0c43..c4783bcf7 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/QuickStart_example.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/QuickStart_example.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using Eigen::MatrixXd;
+using StormEigen::MatrixXd;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/QuickStart_example2_dynamic.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/QuickStart_example2_dynamic.cpp
index ff6746e21..611c4b988 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/QuickStart_example2_dynamic.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/QuickStart_example2_dynamic.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main()
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/QuickStart_example2_fixed.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/QuickStart_example2_fixed.cpp
index d91175273..73f9f9867 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/QuickStart_example2_fixed.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/QuickStart_example2_fixed.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main()
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TemplateKeyword_flexible.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TemplateKeyword_flexible.cpp
index 9d85292dd..cded27efa 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TemplateKeyword_flexible.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TemplateKeyword_flexible.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 template 
 void copyUpperTriangularPart(MatrixBase& dst, const MatrixBase& src)
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TemplateKeyword_simple.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TemplateKeyword_simple.cpp
index 6998c1769..2d533a389 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TemplateKeyword_simple.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TemplateKeyword_simple.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void copyUpperTriangularPart(MatrixXf& dst, const MatrixXf& src)
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgComputeTwice.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgComputeTwice.cpp
index 06ba6461a..6bc8a788b 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgComputeTwice.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgComputeTwice.cpp
@@ -2,7 +2,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgExComputeSolveError.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgExComputeSolveError.cpp
index f362fb71a..f7dbb22ae 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgExComputeSolveError.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgExComputeSolveError.cpp
@@ -2,7 +2,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgExSolveColPivHouseholderQR.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgExSolveColPivHouseholderQR.cpp
index 3a99a94d7..4fd2ae698 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgExSolveColPivHouseholderQR.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgExSolveColPivHouseholderQR.cpp
@@ -2,7 +2,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgExSolveLDLT.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgExSolveLDLT.cpp
index f8beacd27..7cc3080af 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgExSolveLDLT.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgExSolveLDLT.cpp
@@ -2,7 +2,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgInverseDeterminant.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgInverseDeterminant.cpp
index 14dde5b35..f77953b0d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgInverseDeterminant.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgInverseDeterminant.cpp
@@ -2,7 +2,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgRankRevealing.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgRankRevealing.cpp
index c5165077f..0eec4adb9 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgRankRevealing.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgRankRevealing.cpp
@@ -2,7 +2,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgSVDSolve.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgSVDSolve.cpp
index 9fbc031de..7e2be1d4d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgSVDSolve.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgSVDSolve.cpp
@@ -2,7 +2,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgSelfAdjointEigenSolver.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgSelfAdjointEigenSolver.cpp
index 8d1d1ed65..a0d6a56cc 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgSelfAdjointEigenSolver.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgSelfAdjointEigenSolver.cpp
@@ -2,7 +2,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgSetThreshold.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgSetThreshold.cpp
index 3956b13a3..f05798bee 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgSetThreshold.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/TutorialLinAlgSetThreshold.cpp
@@ -2,7 +2,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_accessors.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_accessors.cpp
index dc720ff58..eb1c95b9b 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_accessors.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_accessors.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main()
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_addition.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_addition.cpp
index 480ffb00f..de92bbbfc 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_addition.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_addition.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main()
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_cwise_other.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_cwise_other.cpp
index d9046c63d..dac36dc13 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_cwise_other.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_cwise_other.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main()
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_interop.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_interop.cpp
index 371f07068..9a62a357c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_interop.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_interop.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main()
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_interop_matrix.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_interop_matrix.cpp
index 101427511..7eb61400d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_interop_matrix.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_interop_matrix.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main()
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_mult.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_mult.cpp
index 6cb439ff7..e178da1c8 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_mult.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ArrayClass_mult.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main()
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_block_assignment.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_block_assignment.cpp
index 76f49f2fb..2f9e83901 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_block_assignment.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_block_assignment.cpp
@@ -2,7 +2,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_colrow.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_colrow.cpp
index 2e7eb009b..73a46a378 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_colrow.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_colrow.cpp
@@ -5,7 +5,7 @@ using namespace std;
 
 int main()
 {
-  Eigen::MatrixXf m(3,3);
+  StormEigen::MatrixXf m(3,3);
   m << 1,2,3,
        4,5,6,
        7,8,9;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_corner.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_corner.cpp
index 3a31507aa..4ae08a95d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_corner.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_corner.cpp
@@ -5,7 +5,7 @@ using namespace std;
 
 int main()
 {
-  Eigen::Matrix4f m;
+  StormEigen::Matrix4f m;
   m << 1, 2, 3, 4,
        5, 6, 7, 8,
        9, 10,11,12,
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_print_block.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_print_block.cpp
index edea4aefe..d756dfb15 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_print_block.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_print_block.cpp
@@ -5,7 +5,7 @@ using namespace std;
 
 int main()
 {
-  Eigen::MatrixXf m(4,4);
+  StormEigen::MatrixXf m(4,4);
   m <<  1, 2, 3, 4,
         5, 6, 7, 8,
         9,10,11,12,
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_vector.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_vector.cpp
index 4a0b02342..89b1c12a0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_vector.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_BlockOperations_vector.cpp
@@ -5,7 +5,7 @@ using namespace std;
 
 int main()
 {
-  Eigen::ArrayXf v(6);
+  StormEigen::ArrayXf v(6);
   v << 1, 2, 3, 4, 5, 6;
   cout << "v.head(3) =" << endl << v.head(3) << endl << endl;
   cout << "v.tail<3>() = " << endl << v.tail<3>() << endl << endl;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_PartialLU_solve.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_PartialLU_solve.cpp
index a5608792f..49fde6360 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_PartialLU_solve.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_PartialLU_solve.cpp
@@ -3,7 +3,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_broadcast_1nn.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_broadcast_1nn.cpp
index 334b4d852..aa01e8beb 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_broadcast_1nn.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_broadcast_1nn.cpp
@@ -2,12 +2,12 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
-  Eigen::MatrixXf m(2,4);
-  Eigen::VectorXf v(2);
+  StormEigen::MatrixXf m(2,4);
+  StormEigen::VectorXf v(2);
   
   m << 1, 23, 6, 9,
        3, 11, 7, 2;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_broadcast_simple.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_broadcast_simple.cpp
index e6c87c6a4..c39da7ba5 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_broadcast_simple.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_broadcast_simple.cpp
@@ -4,8 +4,8 @@
 using namespace std;
 int main()
 {
-  Eigen::MatrixXf mat(2,4);
-  Eigen::VectorXf v(2);
+  StormEigen::MatrixXf mat(2,4);
+  StormEigen::VectorXf v(2);
   
   mat << 1, 2, 6, 9,
          3, 1, 7, 2;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_broadcast_simple_rowwise.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_broadcast_simple_rowwise.cpp
index d87c96ab1..6fbe689a8 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_broadcast_simple_rowwise.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_broadcast_simple_rowwise.cpp
@@ -4,8 +4,8 @@
 using namespace std;
 int main()
 {
-  Eigen::MatrixXf mat(2,4);
-  Eigen::VectorXf v(4);
+  StormEigen::MatrixXf mat(2,4);
+  StormEigen::VectorXf v(4);
   
   mat << 1, 2, 6, 9,
          3, 1, 7, 2;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_colwise.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_colwise.cpp
index df6825663..7e24fdcc5 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_colwise.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_colwise.cpp
@@ -4,7 +4,7 @@
 using namespace std;
 int main()
 {
-  Eigen::MatrixXf mat(2,4);
+  StormEigen::MatrixXf mat(2,4);
   mat << 1, 2, 6, 9,
          3, 1, 7, 2;
   
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_maxnorm.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_maxnorm.cpp
index 049c747b0..c214ebc88 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_maxnorm.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_maxnorm.cpp
@@ -2,7 +2,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 int main()
 {
   MatrixXf mat(2,4);
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_bool.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_bool.cpp
index 0cca37f36..4e0c980cd 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_bool.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_bool.cpp
@@ -2,7 +2,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_norm.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_norm.cpp
index 740439fb3..3810dfa1d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_norm.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_norm.cpp
@@ -2,7 +2,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_operatornorm.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_operatornorm.cpp
index 62e28fc31..77fcdaca0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_operatornorm.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_operatornorm.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main()
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_rowwise.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_rowwise.cpp
index 80427c9f7..4878ab723 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_rowwise.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_rowwise.cpp
@@ -4,7 +4,7 @@
 using namespace std;
 int main()
 {
-  Eigen::MatrixXf mat(2,4);
+  StormEigen::MatrixXf mat(2,4);
   mat << 1, 2, 6, 9,
          3, 1, 7, 2;
   
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_visitors.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_visitors.cpp
index b54e9aa31..32d3a7552 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_visitors.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_visitors.cpp
@@ -2,11 +2,11 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
-  Eigen::MatrixXf m(2,2);
+  StormEigen::MatrixXf m(2,2);
   
   m << 1, 2,
        3, 4;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_simple_example_dynamic_size.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_simple_example_dynamic_size.cpp
index 0f0280e0e..66ae544d6 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_simple_example_dynamic_size.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_simple_example_dynamic_size.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_simple_example_fixed_size.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_simple_example_fixed_size.cpp
index bc4f95d79..54639f309 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_simple_example_fixed_size.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/Tutorial_simple_example_fixed_size.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_Block.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_Block.cpp
index ace719afc..c5c23240e 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_Block.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_Block.cpp
@@ -1,20 +1,20 @@
 #include 
 #include 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 template
-Eigen::Block
+StormEigen::Block
 topLeftCorner(MatrixBase& m, int rows, int cols)
 {
-  return Eigen::Block(m.derived(), 0, 0, rows, cols);
+  return StormEigen::Block(m.derived(), 0, 0, rows, cols);
 }
 
 template
-const Eigen::Block
+const StormEigen::Block
 topLeftCorner(const MatrixBase& m, int rows, int cols)
 {
-  return Eigen::Block(m.derived(), 0, 0, rows, cols);
+  return StormEigen::Block(m.derived(), 0, 0, rows, cols);
 }
 
 int main(int, char**)
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_CwiseBinaryOp.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_CwiseBinaryOp.cpp
index 682af46de..9b69c8000 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_CwiseBinaryOp.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_CwiseBinaryOp.cpp
@@ -1,6 +1,6 @@
 #include 
 #include 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 // define a custom template binary functor
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_CwiseUnaryOp.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_CwiseUnaryOp.cpp
index a5fcc153d..c7b022923 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_CwiseUnaryOp.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_CwiseUnaryOp.cpp
@@ -1,6 +1,6 @@
 #include 
 #include 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 // define a custom template unary functor
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_CwiseUnaryOp_ptrfun.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_CwiseUnaryOp_ptrfun.cpp
index 36706d8ed..b0ad773f4 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_CwiseUnaryOp_ptrfun.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_CwiseUnaryOp_ptrfun.cpp
@@ -1,6 +1,6 @@
 #include 
 #include 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 // define function to be applied coefficient-wise
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_FixedBlock.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_FixedBlock.cpp
index 9978b32e8..fa8e8ab87 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_FixedBlock.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_FixedBlock.cpp
@@ -1,20 +1,20 @@
 #include 
 #include 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 template
-Eigen::Block
+StormEigen::Block
 topLeft2x2Corner(MatrixBase& m)
 {
-  return Eigen::Block(m.derived(), 0, 0);
+  return StormEigen::Block(m.derived(), 0, 0);
 }
 
 template
-const Eigen::Block
+const StormEigen::Block
 topLeft2x2Corner(const MatrixBase& m)
 {
-  return Eigen::Block(m.derived(), 0, 0);
+  return StormEigen::Block(m.derived(), 0, 0);
 }
 
 int main(int, char**)
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_FixedVectorBlock.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_FixedVectorBlock.cpp
index c88c9fbf1..c72e38a6c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_FixedVectorBlock.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_FixedVectorBlock.cpp
@@ -1,20 +1,20 @@
 #include 
 #include 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 template
-Eigen::VectorBlock
+StormEigen::VectorBlock
 firstTwo(MatrixBase& v)
 {
-  return Eigen::VectorBlock(v.derived(), 0);
+  return StormEigen::VectorBlock(v.derived(), 0);
 }
 
 template
-const Eigen::VectorBlock
+const StormEigen::VectorBlock
 firstTwo(const MatrixBase& v)
 {
-  return Eigen::VectorBlock(v.derived(), 0);
+  return StormEigen::VectorBlock(v.derived(), 0);
 }
 
 int main(int, char**)
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_VectorBlock.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_VectorBlock.cpp
index dc213df20..7004ed7de 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_VectorBlock.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/class_VectorBlock.cpp
@@ -1,20 +1,20 @@
 #include 
 #include 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 template
-Eigen::VectorBlock
+StormEigen::VectorBlock
 segmentFromRange(MatrixBase& v, int start, int end)
 {
-  return Eigen::VectorBlock(v.derived(), start, end-start);
+  return StormEigen::VectorBlock(v.derived(), start, end-start);
 }
 
 template
-const Eigen::VectorBlock
+const StormEigen::VectorBlock
 segmentFromRange(const MatrixBase& v, int start, int end)
 {
-  return Eigen::VectorBlock(v.derived(), start, end-start);
+  return StormEigen::VectorBlock(v.derived(), start, end-start);
 }
 
 int main(int, char**)
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/function_taking_eigenbase.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/function_taking_eigenbase.cpp
index 49d94b3d6..301bf6f17 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/function_taking_eigenbase.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/function_taking_eigenbase.cpp
@@ -1,6 +1,6 @@
 #include 
 #include 
-using namespace Eigen;
+using namespace StormEigen;
 
 template 
 void print_size(const EigenBase& b)
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/function_taking_ref.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/function_taking_ref.cpp
index 162a202e4..832a3993a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/function_taking_ref.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/function_taking_ref.cpp
@@ -1,6 +1,6 @@
 #include 
 #include 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 float inv_cond(const Ref& a)
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.entry b/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.entry
index f9d2eb8a9..7a6308036 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.entry
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.entry
@@ -1,5 +1,5 @@
 template 
-Circulant makeCirculant(const Eigen::MatrixBase& arg)
+Circulant makeCirculant(const StormEigen::MatrixBase& arg)
 {
   return Circulant(arg.derived());
 }
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.evaluator b/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.evaluator
index 2ba79e783..4a4ec0427 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.evaluator
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.evaluator
@@ -1,4 +1,4 @@
-namespace Eigen {
+namespace StormEigen {
   namespace internal {
     template
     struct evaluator >
@@ -11,7 +11,7 @@ namespace Eigen {
 
       enum { 
         CoeffReadCost = evaluator::CoeffReadCost,
-        Flags = Eigen::ColMajor 
+        Flags = StormEigen::ColMajor 
       };
       
       evaluator(const XprType& xpr)
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.expression b/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.expression
index 380cd4450..ef49c3ab7 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.expression
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.expression
@@ -1,5 +1,5 @@
 template 
-class Circulant : public Eigen::MatrixBase >
+class Circulant : public StormEigen::MatrixBase >
 {
 public:
   Circulant(const ArgType& arg)
@@ -9,12 +9,12 @@ public:
                         YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX);
   }
 
-  typedef typename Eigen::internal::ref_selector::type Nested; 
+  typedef typename StormEigen::internal::ref_selector::type Nested; 
 
-  typedef Eigen::Index Index;
+  typedef StormEigen::Index Index;
   Index rows() const { return m_arg.rows(); }
   Index cols() const { return m_arg.rows(); }
 
-  typedef typename Eigen::internal::ref_selector::type ArgTypeNested;
+  typedef typename StormEigen::internal::ref_selector::type ArgTypeNested;
   ArgTypeNested m_arg;
 };
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.main b/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.main
index 877f97f62..7636ce668 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.main
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.main
@@ -1,8 +1,8 @@
 int main()
 {
-  Eigen::VectorXd vec(4);
+  StormEigen::VectorXd vec(4);
   vec << 1, 2, 4, 8;
-  Eigen::MatrixXd mat;
+  StormEigen::MatrixXd mat;
   mat = makeCirculant(vec);
   std::cout << mat << std::endl;
 }
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.traits b/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.traits
index 4e04535d3..438a89071 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.traits
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/make_circulant.cpp.traits
@@ -1,14 +1,14 @@
-namespace Eigen {
+namespace StormEigen {
   namespace internal {
     template 
     struct traits >
     {
-      typedef Eigen::Dense StorageKind;
-      typedef Eigen::MatrixXpr XprKind;
+      typedef StormEigen::Dense StorageKind;
+      typedef StormEigen::MatrixXpr XprKind;
       typedef typename ArgType::StorageIndex StorageIndex;
       typedef typename ArgType::Scalar Scalar;
       enum { 
-        Flags = Eigen::ColMajor,
+        Flags = StormEigen::ColMajor,
         RowsAtCompileTime = ArgType::RowsAtCompileTime,
         ColsAtCompileTime = ArgType::RowsAtCompileTime,
         MaxRowsAtCompileTime = ArgType::MaxRowsAtCompileTime,
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/matrixfree_cg.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/matrixfree_cg.cpp
index 6a205aea3..524de79db 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/matrixfree_cg.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/matrixfree_cg.cpp
@@ -5,28 +5,28 @@
 #include 
 
 class MatrixReplacement;
-using Eigen::SparseMatrix;
+using StormEigen::SparseMatrix;
 
-namespace Eigen {
+namespace StormEigen {
 namespace internal {
   // MatrixReplacement looks-like a SparseMatrix, so let's inherits its traits:
   template<>
-  struct traits :  public Eigen::internal::traits >
+  struct traits :  public StormEigen::internal::traits >
   {};
 }
 }
 
 // Example of a matrix-free wrapper from a user type to Eigen's compatible type
-// For the sake of simplicity, this example simply wrap a Eigen::SparseMatrix.
-class MatrixReplacement : public Eigen::EigenBase {
+// For the sake of simplicity, this example simply wrap a StormEigen::SparseMatrix.
+class MatrixReplacement : public StormEigen::EigenBase {
 public:
   // Required typedefs, constants, and method:
   typedef double Scalar;
   typedef double RealScalar;
   typedef int StorageIndex;
   enum {
-    ColsAtCompileTime = Eigen::Dynamic,
-    MaxColsAtCompileTime = Eigen::Dynamic,
+    ColsAtCompileTime = StormEigen::Dynamic,
+    MaxColsAtCompileTime = StormEigen::Dynamic,
     IsRowMajor = false
   };
 
@@ -34,8 +34,8 @@ public:
   Index cols() const { return mp_mat->cols(); }
 
   template
-  Eigen::Product operator*(const Eigen::MatrixBase& x) const {
-    return Eigen::Product(*this, x.derived());
+  StormEigen::Product operator*(const Eigen::MatrixBase& x) const {
+    return StormEigen::Product(*this, x.derived());
   }
 
   // Custom API:
@@ -51,8 +51,8 @@ private:
 };
 
 
-// Implementation of MatrixReplacement * Eigen::DenseVector though a specialization of internal::generic_product_impl:
-namespace Eigen {
+// Implementation of MatrixReplacement * StormEigen::DenseVector though a specialization of internal::generic_product_impl:
+namespace StormEigen {
 namespace internal {
 
   template
@@ -81,46 +81,46 @@ namespace internal {
 int main()
 {
   int n = 10;
-  Eigen::SparseMatrix S = Eigen::MatrixXd::Random(n,n).sparseView(0.5,1);
+  StormEigen::SparseMatrix S = StormEigen::MatrixXd::Random(n,n).sparseView(0.5,1);
   S = S.transpose()*S;
 
   MatrixReplacement A;
   A.attachMyMatrix(S);
 
-  Eigen::VectorXd b(n), x;
+  StormEigen::VectorXd b(n), x;
   b.setRandom();
 
   // Solve Ax = b using various iterative solver with matrix-free version:
   {
-    Eigen::ConjugateGradient cg;
+    StormEigen::ConjugateGradient cg;
     cg.compute(A);
     x = cg.solve(b);
     std::cout << "CG:       #iterations: " << cg.iterations() << ", estimated error: " << cg.error() << std::endl;
   }
 
   {
-    Eigen::BiCGSTAB bicg;
+    StormEigen::BiCGSTAB bicg;
     bicg.compute(A);
     x = bicg.solve(b);
     std::cout << "BiCGSTAB: #iterations: " << bicg.iterations() << ", estimated error: " << bicg.error() << std::endl;
   }
 
   {
-    Eigen::GMRES gmres;
+    StormEigen::GMRES gmres;
     gmres.compute(A);
     x = gmres.solve(b);
     std::cout << "GMRES:    #iterations: " << gmres.iterations() << ", estimated error: " << gmres.error() << std::endl;
   }
 
   {
-    Eigen::DGMRES gmres;
+    StormEigen::DGMRES gmres;
     gmres.compute(A);
     x = gmres.solve(b);
     std::cout << "DGMRES:   #iterations: " << gmres.iterations() << ", estimated error: " << gmres.error() << std::endl;
   }
 
   {
-    Eigen::MINRES minres;
+    StormEigen::MINRES minres;
     minres.compute(A);
     x = minres.solve(b);
     std::cout << "MINRES:   #iterations: " << minres.iterations() << ", estimated error: " << minres.error() << std::endl;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_add_sub.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_add_sub.cpp
index e97477b6e..99a2f98a5 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_add_sub.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_add_sub.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_dot_cross.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_dot_cross.cpp
index 631c9a5e0..6d727d22a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_dot_cross.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_dot_cross.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_matrix_mul.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_matrix_mul.cpp
index f21390241..064ee5c72 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_matrix_mul.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_matrix_mul.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 int main()
 {
   Matrix2d mat;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_redux_basic.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_redux_basic.cpp
index 5632fb52e..6da344f9e 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_redux_basic.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_redux_basic.cpp
@@ -4,7 +4,7 @@
 using namespace std;
 int main()
 {
-  Eigen::Matrix2d mat;
+  StormEigen::Matrix2d mat;
   mat << 1, 2,
          3, 4;
   cout << "Here is mat.sum():       " << mat.sum()       << endl;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_scalar_mul_div.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_scalar_mul_div.cpp
index d5f65b53e..b26323d36 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_scalar_mul_div.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_arithmetic_scalar_mul_div.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_matrix_coefficient_accessors.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_matrix_coefficient_accessors.cpp
index c2da17158..82eaf16bf 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_matrix_coefficient_accessors.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_matrix_coefficient_accessors.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_matrix_resize.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_matrix_resize.cpp
index 0392c3aa5..1b4610306 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_matrix_resize.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_matrix_resize.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_matrix_resize_fixed_size.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_matrix_resize_fixed_size.cpp
index dcbdfa783..b21c0499b 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_matrix_resize_fixed_size.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/examples/tut_matrix_resize_fixed_size.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/BiCGSTAB_simple.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/BiCGSTAB_simple.cpp
index 5520f4f1f..8c8829fd3 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/BiCGSTAB_simple.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/BiCGSTAB_simple.cpp
@@ -8,4 +8,4 @@
   std::cout << "#iterations:     " << solver.iterations() << std::endl;
   std::cout << "estimated error: " << solver.error()      << std::endl;
   /* ... update b ... */
-  x = solver.solve(b); // solve again
\ No newline at end of file
+  x = solver.solve(b); // solve again
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/BiCGSTAB_step_by_step.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/BiCGSTAB_step_by_step.cpp
index 06147bb81..6c95d5a9c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/BiCGSTAB_step_by_step.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/BiCGSTAB_step_by_step.cpp
@@ -11,4 +11,4 @@
     x = solver.solveWithGuess(b,x);
     std::cout << i << " : " << solver.error() << std::endl;
     ++i;
-  } while (solver.info()!=Success && i<100);
\ No newline at end of file
+  } while (solver.info()!=Success && i<100);
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Cwise_array_power_array.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Cwise_array_power_array.cpp
index 432a76ee5..4151f3562 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Cwise_array_power_array.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Cwise_array_power_array.cpp
@@ -1,4 +1,4 @@
 Array x(8,25,3),
                   e(1./3.,0.5,2.);
 cout << "[" << x << "]^[" << e << "] = " << x.pow(e) << endl; // using ArrayBase::pow
-cout << "[" << x << "]^[" << e << "] = " << pow(x,e) << endl; // using Eigen::pow
+cout << "[" << x << "]^[" << e << "] = " << pow(x,e) << endl; // using StormEigen::pow
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/DirectionWise_hnormalized.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/DirectionWise_hnormalized.cpp
index 3410790a8..a6193e8a0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/DirectionWise_hnormalized.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/DirectionWise_hnormalized.cpp
@@ -4,4 +4,4 @@ Projective3d P(Matrix4d::Random());
 cout << "The matrix M is:" << endl << M << endl << endl;
 cout << "M.colwise().hnormalized():" << endl << M.colwise().hnormalized() << endl << endl;
 cout << "P*M:" << endl << P*M << endl << endl;
-cout << "(P*M).colwise().hnormalized():" << endl << (P*M).colwise().hnormalized() << endl << endl;
\ No newline at end of file
+cout << "(P*M).colwise().hnormalized():" << endl << (P*M).colwise().hnormalized() << endl << endl;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Jacobi_makeGivens.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Jacobi_makeGivens.cpp
index 4b733c306..6f8ec054a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Jacobi_makeGivens.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Jacobi_makeGivens.cpp
@@ -3,4 +3,4 @@ JacobiRotation G;
 G.makeGivens(v.x(), v.y());
 cout << "Here is the vector v:" << endl << v << endl;
 v.applyOnTheLeft(0, 1, G.adjoint());
-cout << "Here is the vector J' * v:" << endl << v << endl;
\ No newline at end of file
+cout << "Here is the vector J' * v:" << endl << v << endl;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Jacobi_makeJacobi.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Jacobi_makeJacobi.cpp
index 0cc331d9f..a86e80a62 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Jacobi_makeJacobi.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Jacobi_makeJacobi.cpp
@@ -5,4 +5,4 @@ J.makeJacobi(m, 0, 1);
 cout << "Here is the matrix m:" << endl << m << endl;
 m.applyOnTheLeft(0, 1, J.adjoint());
 m.applyOnTheRight(0, 1, J);
-cout << "Here is the matrix J' * m * J:" << endl << m << endl;
\ No newline at end of file
+cout << "Here is the matrix J' * m * J:" << endl << m << endl;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Map_placement_new.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Map_placement_new.cpp
index 2e40eca32..83b83a893 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Map_placement_new.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Map_placement_new.cpp
@@ -2,4 +2,4 @@ int data[] = {1,2,3,4,5,6,7,8,9};
 Map v(data,4);
 cout << "The mapped vector v is: " << v << "\n";
 new (&v) Map(data+4,5);
-cout << "Now v is: " << v << "\n";
\ No newline at end of file
+cout << "Now v is: " << v << "\n";
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/MatrixBase_hnormalized.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/MatrixBase_hnormalized.cpp
index 652cd77c0..b714adcc3 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/MatrixBase_hnormalized.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/MatrixBase_hnormalized.cpp
@@ -3,4 +3,4 @@ Projective3d P(Matrix4d::Random());
 cout << "v                   = " << v.transpose() << "]^T" << endl;
 cout << "v.hnormalized()     = " << v.hnormalized().transpose() << "]^T" << endl;
 cout << "P*v                 = " << (P*v).transpose() << "]^T" << endl;
-cout << "(P*v).hnormalized() = " << (P*v).hnormalized().transpose() << "]^T" << endl;
\ No newline at end of file
+cout << "(P*v).hnormalized() = " << (P*v).hnormalized().transpose() << "]^T" << endl;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/MatrixBase_homogeneous.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/MatrixBase_homogeneous.cpp
index 457c28f91..263196097 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/MatrixBase_homogeneous.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/MatrixBase_homogeneous.cpp
@@ -3,4 +3,4 @@ Projective3d P(Matrix4d::Random());
 cout << "v                                   = [" << v.transpose() << "]^T" << endl;
 cout << "h.homogeneous()                     = [" << v.homogeneous().transpose() << "]^T" << endl;
 cout << "(P * v.homogeneous())               = [" << (P * v.homogeneous()).transpose() << "]^T" << endl;
-cout << "(P * v.homogeneous()).hnormalized() = [" << (P * v.homogeneous()).eval().hnormalized().transpose() << "]^T" << endl;
\ No newline at end of file
+cout << "(P * v.homogeneous()).hnormalized() = [" << (P * v.homogeneous()).eval().hnormalized().transpose() << "]^T" << endl;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/MatrixBase_triangularView.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/MatrixBase_triangularView.cpp
index 03aa303f0..b4e382844 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/MatrixBase_triangularView.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/MatrixBase_triangularView.cpp
@@ -1,9 +1,9 @@
 Matrix3i m = Matrix3i::Random();
 cout << "Here is the matrix m:" << endl << m << endl;
 cout << "Here is the upper-triangular matrix extracted from m:" << endl
-     << Matrix3i(m.triangularView()) << endl;
+     << Matrix3i(m.triangularView()) << endl;
 cout << "Here is the strictly-upper-triangular matrix extracted from m:" << endl
-     << Matrix3i(m.triangularView()) << endl;
+     << Matrix3i(m.triangularView()) << endl;
 cout << "Here is the unit-lower-triangular matrix extracted from m:" << endl
-     << Matrix3i(m.triangularView()) << endl;
+     << Matrix3i(m.triangularView()) << endl;
 // FIXME need to implement output for triangularViews (Bug 885)
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Triangular_solve.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Triangular_solve.cpp
index 548442467..ac61874b6 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Triangular_solve.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/Triangular_solve.cpp
@@ -1,11 +1,11 @@
 Matrix3d m = Matrix3d::Zero();
-m.triangularView().setOnes();
+m.triangularView().setOnes();
 cout << "Here is the matrix m:\n" << m << endl;
 Matrix3d n = Matrix3d::Ones();
-n.triangularView() *= 2;
+n.triangularView() *= 2;
 cout << "Here is the matrix n:\n" << n << endl;
 cout << "And now here is m.inverse()*n, taking advantage of the fact that"
         " m is upper-triangular:\n"
-     << m.triangularView().solve(n) << endl;
+     << m.triangularView().solve(n) << endl;
 cout << "And this is n*m.inverse():\n"
-     << m.triangularView().solve(n);
+     << m.triangularView().solve(n);
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/VectorwiseOp_homogeneous.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/VectorwiseOp_homogeneous.cpp
index aba4fed0e..7e58ebfa0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/VectorwiseOp_homogeneous.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/VectorwiseOp_homogeneous.cpp
@@ -4,4 +4,4 @@ Projective3d P(Matrix4d::Random());
 cout << "The matrix M is:" << endl << M << endl << endl;
 cout << "M.colwise().homogeneous():" << endl << M.colwise().homogeneous() << endl << endl;
 cout << "P * M.colwise().homogeneous():" << endl << P * M.colwise().homogeneous() << endl << endl;
-cout << "P * M.colwise().homogeneous().hnormalized(): " << endl << (P * M.colwise().homogeneous()).colwise().hnormalized() << endl << endl;
\ No newline at end of file
+cout << "P * M.colwise().homogeneous().hnormalized(): " << endl << (P * M.colwise().homogeneous()).colwise().hnormalized() << endl << endl;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/class_FullPivLU.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/class_FullPivLU.cpp
index fce7fac09..904ea4504 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/class_FullPivLU.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/class_FullPivLU.cpp
@@ -2,7 +2,7 @@ typedef Matrix Matrix5x3;
 typedef Matrix Matrix5x5;
 Matrix5x3 m = Matrix5x3::Random();
 cout << "Here is the matrix m:" << endl << m << endl;
-Eigen::FullPivLU lu(m);
+StormEigen::FullPivLU lu(m);
 cout << "Here is, up to permutations, its LU decomposition matrix:"
      << endl << lu.matrixLU() << endl;
 cout << "Here is the L part:" << endl;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/compile_snippet.cpp.in b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/compile_snippet.cpp.in
index fdae39bcf..dcea17583 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/compile_snippet.cpp.in
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/compile_snippet.cpp.in
@@ -6,7 +6,7 @@
 #endif
 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main(int, char**)
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/tut_arithmetic_transpose_aliasing.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/tut_arithmetic_transpose_aliasing.cpp
index c8e4746d0..f82e6f2ac 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/tut_arithmetic_transpose_aliasing.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/tut_arithmetic_transpose_aliasing.cpp
@@ -2,4 +2,4 @@ Matrix2i a; a << 1, 2, 3, 4;
 cout << "Here is the matrix a:\n" << a << endl;
 
 a = a.transpose(); // !!! do NOT do this !!!
-cout << "and the result of the aliasing effect:\n" << a << endl;
\ No newline at end of file
+cout << "and the result of the aliasing effect:\n" << a << endl;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/tut_arithmetic_transpose_inplace.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/tut_arithmetic_transpose_inplace.cpp
index 7a069ff23..5c81c9e02 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/snippets/tut_arithmetic_transpose_inplace.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/snippets/tut_arithmetic_transpose_inplace.cpp
@@ -3,4 +3,4 @@ cout << "Here is the initial matrix a:\n" << a << endl;
 
 
 a.transposeInPlace();
-cout << "and after being transposed:\n" << a << endl;
\ No newline at end of file
+cout << "and after being transposed:\n" << a << endl;
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/special_examples/Tutorial_sparse_example.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/special_examples/Tutorial_sparse_example.cpp
index 830e196ea..a40b553f6 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/special_examples/Tutorial_sparse_example.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/special_examples/Tutorial_sparse_example.cpp
@@ -1,11 +1,11 @@
 #include 
 #include 
 
-typedef Eigen::SparseMatrix SpMat; // declares a column-major sparse matrix type of double
-typedef Eigen::Triplet T;
+typedef StormEigen::SparseMatrix SpMat; // declares a column-major sparse matrix type of double
+typedef StormEigen::Triplet T;
 
-void buildProblem(std::vector& coefficients, Eigen::VectorXd& b, int n);
-void saveAsBitmap(const Eigen::VectorXd& x, int n, const char* filename);
+void buildProblem(std::vector& coefficients, StormEigen::VectorXd& b, int n);
+void saveAsBitmap(const StormEigen::VectorXd& x, int n, const char* filename);
 
 int main(int argc, char** argv)
 {
@@ -16,15 +16,15 @@ int main(int argc, char** argv)
 
   // Assembly:
   std::vector coefficients;            // list of non-zeros coefficients
-  Eigen::VectorXd b(m);                   // the right hand side-vector resulting from the constraints
+  StormEigen::VectorXd b(m);                   // the right hand side-vector resulting from the constraints
   buildProblem(coefficients, b, n);
 
   SpMat A(m,m);
   A.setFromTriplets(coefficients.begin(), coefficients.end());
 
   // Solving:
-  Eigen::SimplicialCholesky chol(A);  // performs a Cholesky factorization of A
-  Eigen::VectorXd x = chol.solve(b);         // use the factorization to solve for the given right hand side
+  StormEigen::SimplicialCholesky chol(A);  // performs a Cholesky factorization of A
+  StormEigen::VectorXd x = chol.solve(b);         // use the factorization to solve for the given right hand side
 
   // Export the result to a file:
   saveAsBitmap(x, n, argv[1]);
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/special_examples/Tutorial_sparse_example_details.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/special_examples/Tutorial_sparse_example_details.cpp
index bc18b0188..dab74e2f2 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/special_examples/Tutorial_sparse_example_details.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/special_examples/Tutorial_sparse_example_details.cpp
@@ -2,11 +2,11 @@
 #include 
 #include 
 
-typedef Eigen::SparseMatrix SpMat; // declares a column-major sparse matrix type of double
-typedef Eigen::Triplet T;
+typedef StormEigen::SparseMatrix SpMat; // declares a column-major sparse matrix type of double
+typedef StormEigen::Triplet T;
 
 void insertCoefficient(int id, int i, int j, double w, std::vector& coeffs,
-                       Eigen::VectorXd& b, const Eigen::VectorXd& boundary)
+                       StormEigen::VectorXd& b, const StormEigen::VectorXd& boundary)
 {
   int n = int(boundary.size());
   int id1 = i+j*n;
@@ -16,10 +16,10 @@ void insertCoefficient(int id, int i, int j, double w, std::vector& coeffs,
   else  coeffs.push_back(T(id,id1,w));              // unknown coefficient
 }
 
-void buildProblem(std::vector& coefficients, Eigen::VectorXd& b, int n)
+void buildProblem(std::vector& coefficients, StormEigen::VectorXd& b, int n)
 {
   b.setZero();
-  Eigen::ArrayXd boundary = Eigen::ArrayXd::LinSpaced(n, 0,M_PI).sin().pow(2);
+  StormEigen::ArrayXd boundary = StormEigen::ArrayXd::LinSpaced(n, 0,M_PI).sin().pow(2);
   for(int j=0; j& coefficients, Eigen::VectorXd& b, int n)
   }
 }
 
-void saveAsBitmap(const Eigen::VectorXd& x, int n, const char* filename)
+void saveAsBitmap(const StormEigen::VectorXd& x, int n, const char* filename)
 {
-  Eigen::Array bits = (x*255).cast();
+  StormEigen::Array bits = (x*255).cast();
   QImage img(bits.data(), n,n,QImage::Format_Indexed8);
   img.setColorCount(256);
   for(int i=0;i<256;i++) img.setColor(i,qRgb(i,i,i));
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/special_examples/random_cpp11.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/special_examples/random_cpp11.cpp
index adc3c110c..968884a6d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/special_examples/random_cpp11.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/special_examples/random_cpp11.cpp
@@ -2,12 +2,12 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main() {
   std::default_random_engine generator;
   std::poisson_distribution distribution(4.1);
-  auto poisson = [&] (Eigen::Index) {return distribution(generator);};
+  auto poisson = [&] (StormEigen::Index) {return distribution(generator);};
 
   RowVectorXi v = RowVectorXi::NullaryExpr(10, poisson );
   std::cout << v << "\n";
diff --git a/resources/3rdparty/eigen-3.3-beta1/doc/tutorial.cpp b/resources/3rdparty/eigen-3.3-beta1/doc/tutorial.cpp
index 62be7c270..054876329 100644
--- a/resources/3rdparty/eigen-3.3-beta1/doc/tutorial.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/doc/tutorial.cpp
@@ -5,8 +5,8 @@ int main(int argc, char *argv[])
   std::cout.precision(2);
 
   // demo static functions
-  Eigen::Matrix3f m3 = Eigen::Matrix3f::Random();
-  Eigen::Matrix4f m4 = Eigen::Matrix4f::Identity();
+  StormEigen::Matrix3f m3 = StormEigen::Matrix3f::Random();
+  StormEigen::Matrix4f m4 = StormEigen::Matrix4f::Identity();
 
   std::cout << "*** Step 1 ***\nm3:\n" << m3 << "\nm4:\n" << m4 << std::endl;
 
@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
 
   // demo intelligent auto-evaluation
   m4 = m4 * m4; // auto-evaluates so no aliasing problem (performance penalty is low)
-  Eigen::Matrix4f other = (m4 * m4).lazy(); // forces lazy evaluation
+  StormEigen::Matrix4f other = (m4 * m4).lazy(); // forces lazy evaluation
   m4 = m4 + m4; // here Eigen goes for lazy evaluation, as with most expressions
   m4 = -m4 + m4 + 5 * m4; // same here, Eigen chooses lazy evaluation for all that.
   m4 = m4 * (m4 + m4); // here Eigen chooses to first evaluate m4 + m4 into a temporary.
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/bdcsvd_int.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/bdcsvd_int.cpp
index 670752cf5..63a153035 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/bdcsvd_int.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/bdcsvd_int.cpp
@@ -6,7 +6,7 @@
 #define SCALAR float
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/block_nonconst_ctor_on_const_xpr_0.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/block_nonconst_ctor_on_const_xpr_0.cpp
index 40b82014f..fd0e7ae12 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/block_nonconst_ctor_on_const_xpr_0.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/block_nonconst_ctor_on_const_xpr_0.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER Matrix3d &m){
     Block b(m,0,0);
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/block_nonconst_ctor_on_const_xpr_1.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/block_nonconst_ctor_on_const_xpr_1.cpp
index ef6d53702..3b282cd5a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/block_nonconst_ctor_on_const_xpr_1.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/block_nonconst_ctor_on_const_xpr_1.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER Matrix3d &m){
     Block b(m,0,0,3,3);
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/block_nonconst_ctor_on_const_xpr_2.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/block_nonconst_ctor_on_const_xpr_2.cpp
index 43f18aecf..7b4837da4 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/block_nonconst_ctor_on_const_xpr_2.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/block_nonconst_ctor_on_const_xpr_2.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER Matrix3d &m){
     // row/column constructor
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/block_on_const_type_actually_const_0.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/block_on_const_type_actually_const_0.cpp
index 009bebece..a2ffeb4f2 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/block_on_const_type_actually_const_0.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/block_on_const_type_actually_const_0.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(){
     Matrix3f m;
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/block_on_const_type_actually_const_1.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/block_on_const_type_actually_const_1.cpp
index 4c3e93ffe..421a08a22 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/block_on_const_type_actually_const_1.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/block_on_const_type_actually_const_1.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(){
     MatrixXf m;
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/colpivqr_int.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/colpivqr_int.cpp
index db11910d4..626ee6101 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/colpivqr_int.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/colpivqr_int.cpp
@@ -6,7 +6,7 @@
 #define SCALAR float
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_block_method_retval_0.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_block_method_retval_0.cpp
index a6bd5fee2..9556667a1 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_block_method_retval_0.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_block_method_retval_0.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER Matrix3d &m){
     Block b(m.block<3,3>(0,0));
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_block_method_retval_1.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_block_method_retval_1.cpp
index ef40c247c..4de78730a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_block_method_retval_1.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_block_method_retval_1.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER Matrix3d &m){
     Block b(m.block(0,0,3,3));
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_diagonal_method_retval.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_diagonal_method_retval.cpp
index 809594aab..925a57180 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_diagonal_method_retval.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_diagonal_method_retval.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER Matrix3d &m){
     Diagonal b(m.diagonal());
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_transpose_method_retval.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_transpose_method_retval.cpp
index 2d7f19cab..16bfc4fc0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_transpose_method_retval.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/const_qualified_transpose_method_retval.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER Matrix3d &m){
     Transpose b(m.transpose());
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/cwiseunaryview_nonconst_ctor_on_const_xpr.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/cwiseunaryview_nonconst_ctor_on_const_xpr.cpp
index e23cf8fd8..5637e140c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/cwiseunaryview_nonconst_ctor_on_const_xpr.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/cwiseunaryview_nonconst_ctor_on_const_xpr.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER Matrix3d &m){
     CwiseUnaryView,Matrix3d> t(m);
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/cwiseunaryview_on_const_type_actually_const.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/cwiseunaryview_on_const_type_actually_const.cpp
index fcd41dfdb..9bd9bce3b 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/cwiseunaryview_on_const_type_actually_const.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/cwiseunaryview_on_const_type_actually_const.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(){
     MatrixXf m;
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/diagonal_nonconst_ctor_on_const_xpr.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/diagonal_nonconst_ctor_on_const_xpr.cpp
index 76398a2c2..9b53e36a3 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/diagonal_nonconst_ctor_on_const_xpr.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/diagonal_nonconst_ctor_on_const_xpr.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER Matrix3d &m){
     Diagonal d(m);
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/diagonal_on_const_type_actually_const.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/diagonal_on_const_type_actually_const.cpp
index d4b2fd9b8..7e369722d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/diagonal_on_const_type_actually_const.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/diagonal_on_const_type_actually_const.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(){
     MatrixXf m;
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/eigensolver_cplx.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/eigensolver_cplx.cpp
index c2e21e189..d7969d496 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/eigensolver_cplx.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/eigensolver_cplx.cpp
@@ -6,7 +6,7 @@
 #define SCALAR float
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/eigensolver_int.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/eigensolver_int.cpp
index eda8dc20b..1f17a6dca 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/eigensolver_int.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/eigensolver_int.cpp
@@ -6,7 +6,7 @@
 #define SCALAR float
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/fullpivlu_int.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/fullpivlu_int.cpp
index e9d2c6eb3..cf663bd31 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/fullpivlu_int.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/fullpivlu_int.cpp
@@ -6,7 +6,7 @@
 #define SCALAR float
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/fullpivqr_int.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/fullpivqr_int.cpp
index d182a7b6b..a04d1920a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/fullpivqr_int.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/fullpivqr_int.cpp
@@ -6,7 +6,7 @@
 #define SCALAR float
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/jacobisvd_int.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/jacobisvd_int.cpp
index 12790aef1..9242405d3 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/jacobisvd_int.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/jacobisvd_int.cpp
@@ -6,7 +6,7 @@
 #define SCALAR float
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/ldlt_int.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/ldlt_int.cpp
index 243e45746..ddd0713ea 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/ldlt_int.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/ldlt_int.cpp
@@ -6,7 +6,7 @@
 #define SCALAR float
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/llt_int.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/llt_int.cpp
index cb020650d..1dd398729 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/llt_int.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/llt_int.cpp
@@ -6,7 +6,7 @@
 #define SCALAR float
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_0.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_0.cpp
index d75686f58..4659f9995 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_0.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_0.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER float *ptr){
     Map m(ptr);
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_1.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_1.cpp
index eda134dc8..ab8839369 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_1.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_1.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER float *ptr, DenseIndex size){
     Map m(ptr, size);
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_2.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_2.cpp
index 06b4b6275..f5e8b48f0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_2.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_2.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER float *ptr, DenseIndex rows, DenseIndex cols){
     Map m(ptr, rows, cols);
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_3.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_3.cpp
index 830f6f0c9..815a3b4f2 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_3.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_3.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER float *ptr, DenseIndex rows, DenseIndex cols){
     Map > m(ptr, rows, cols, InnerStride<2>());
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_4.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_4.cpp
index c3e8c952c..4bb9b4c50 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_4.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/map_nonconst_ctor_on_const_ptr_4.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER const
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(const float *ptr, DenseIndex rows, DenseIndex cols){
     Map > m(ptr, rows, cols, OuterStride<>(2));
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/map_on_const_type_actually_const_0.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/map_on_const_type_actually_const_0.cpp
index 8cb6aa0cd..60b309241 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/map_on_const_type_actually_const_0.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/map_on_const_type_actually_const_0.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(float *ptr){
     Map(ptr, 1, 1).coeffRef(0,0) = 1.0f;
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/map_on_const_type_actually_const_1.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/map_on_const_type_actually_const_1.cpp
index 04e067c34..e761f0044 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/map_on_const_type_actually_const_1.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/map_on_const_type_actually_const_1.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(float *ptr){
     Map(ptr).coeffRef(0) = 1.0f;
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/partialpivlu_int.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/partialpivlu_int.cpp
index 98ef282ea..9627cd67e 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/partialpivlu_int.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/partialpivlu_int.cpp
@@ -6,7 +6,7 @@
 #define SCALAR float
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/qr_int.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/qr_int.cpp
index ce200e818..103dca65e 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/qr_int.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/qr_int.cpp
@@ -6,7 +6,7 @@
 #define SCALAR float
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/ref_1.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/ref_1.cpp
index 8b798d53d..95f926e4d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/ref_1.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/ref_1.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void call_ref(Ref a) { }
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/ref_2.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/ref_2.cpp
index 0b779ccf5..531d314f9 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/ref_2.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/ref_2.cpp
@@ -1,6 +1,6 @@
 #include "../Eigen/Core"
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void call_ref(Ref a) { }
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/ref_3.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/ref_3.cpp
index f46027d48..24921e220 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/ref_3.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/ref_3.cpp
@@ -1,6 +1,6 @@
 #include "../Eigen/Core"
 
-using namespace Eigen;
+using namespace StormEigen;
 
 #ifdef EIGEN_SHOULD_FAIL_TO_BUILD
 void call_ref(Ref a) { }
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/ref_4.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/ref_4.cpp
index 6c11fa4cb..4e22d7c01 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/ref_4.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/ref_4.cpp
@@ -1,6 +1,6 @@
 #include "../Eigen/Core"
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void call_ref(Ref > a) {}
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/ref_5.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/ref_5.cpp
index 846d52795..705cc60ed 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/ref_5.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/ref_5.cpp
@@ -1,6 +1,6 @@
 #include "../Eigen/Core"
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void call_ref(Ref a) { }
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/selfadjointview_nonconst_ctor_on_const_xpr.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/selfadjointview_nonconst_ctor_on_const_xpr.cpp
index a240f8184..58d3dab72 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/selfadjointview_nonconst_ctor_on_const_xpr.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/selfadjointview_nonconst_ctor_on_const_xpr.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER Matrix3d &m){
     SelfAdjointView t(m);
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/selfadjointview_on_const_type_actually_const.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/selfadjointview_on_const_type_actually_const.cpp
index 19aaad6d0..bf00c11a9 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/selfadjointview_on_const_type_actually_const.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/selfadjointview_on_const_type_actually_const.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(){
     MatrixXf m;
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_1.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_1.cpp
index d78d1f9b1..589435ce6 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_1.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_1.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void call_ref(Ref > a) { }
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_2.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_2.cpp
index 46c9440c2..01035d555 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_2.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_2.cpp
@@ -1,6 +1,6 @@
 #include "../Eigen/Sparse"
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void call_ref(Ref > a) { }
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_3.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_3.cpp
index a9949b552..b8e431a0a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_3.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_3.cpp
@@ -1,6 +1,6 @@
 #include "../Eigen/Sparse"
 
-using namespace Eigen;
+using namespace StormEigen;
 
 #ifdef EIGEN_SHOULD_FAIL_TO_BUILD
 void call_ref(Ref > a) { }
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_4.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_4.cpp
index 57bb6a1fc..91a32ca37 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_4.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_4.cpp
@@ -1,6 +1,6 @@
 #include "../Eigen/Sparse"
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void call_ref(Ref > a) {}
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_5.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_5.cpp
index 4478f6f2f..9824e41b6 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_5.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_ref_5.cpp
@@ -1,6 +1,6 @@
 #include "../Eigen/Sparse"
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void call_ref(Ref > a) { }
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_storage_mismatch.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_storage_mismatch.cpp
index 51840d416..784a9494a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_storage_mismatch.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/sparse_storage_mismatch.cpp
@@ -1,5 +1,5 @@
 #include "../Eigen/Sparse"
-using namespace Eigen;
+using namespace StormEigen;
 
 typedef SparseMatrix Mat1;
 #ifdef EIGEN_SHOULD_FAIL_TO_BUILD
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/swap_1.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/swap_1.cpp
index 106379720..e12e33fba 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/swap_1.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/swap_1.cpp
@@ -1,6 +1,6 @@
 #include "../Eigen/Core"
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/swap_2.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/swap_2.cpp
index c130ba6e4..f580f5fe9 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/swap_2.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/swap_2.cpp
@@ -1,6 +1,6 @@
 #include "../Eigen/Core"
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
@@ -11,4 +11,4 @@ int main()
 #else
   b.swap(ac.const_cast_derived());
 #endif
-}
\ No newline at end of file
+}
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/ternary_1.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/ternary_1.cpp
index b40bcb0cc..b33ceb8c6 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/ternary_1.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/ternary_1.cpp
@@ -1,6 +1,6 @@
 #include "../Eigen/Core"
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main(int argc,char **)
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/ternary_2.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/ternary_2.cpp
index a46b12b2b..49b252787 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/ternary_2.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/ternary_2.cpp
@@ -1,6 +1,6 @@
 #include "../Eigen/Core"
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main(int argc,char **)
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/transpose_nonconst_ctor_on_const_xpr.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/transpose_nonconst_ctor_on_const_xpr.cpp
index 4223e7fd7..8255bf336 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/transpose_nonconst_ctor_on_const_xpr.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/transpose_nonconst_ctor_on_const_xpr.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER Matrix3d &m){
     Transpose t(m);
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/transpose_on_const_type_actually_const.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/transpose_on_const_type_actually_const.cpp
index d0b7d0df6..7668303cc 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/transpose_on_const_type_actually_const.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/transpose_on_const_type_actually_const.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(){
     MatrixXf m;
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/triangularview_nonconst_ctor_on_const_xpr.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/triangularview_nonconst_ctor_on_const_xpr.cpp
index 807447e4b..ce6f1e88e 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/triangularview_nonconst_ctor_on_const_xpr.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/triangularview_nonconst_ctor_on_const_xpr.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(CV_QUALIFIER Matrix3d &m){
   TriangularView t(m);
diff --git a/resources/3rdparty/eigen-3.3-beta1/failtest/triangularview_on_const_type_actually_const.cpp b/resources/3rdparty/eigen-3.3-beta1/failtest/triangularview_on_const_type_actually_const.cpp
index 0a381a612..1146b7e00 100644
--- a/resources/3rdparty/eigen-3.3-beta1/failtest/triangularview_on_const_type_actually_const.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/failtest/triangularview_on_const_type_actually_const.cpp
@@ -6,7 +6,7 @@
 #define CV_QUALIFIER
 #endif
 
-using namespace Eigen;
+using namespace StormEigen;
 
 void foo(){
     MatrixXf m;
diff --git a/resources/3rdparty/eigen-3.3-beta1/lapack/lapack_common.h b/resources/3rdparty/eigen-3.3-beta1/lapack/lapack_common.h
index a93598784..39d821748 100644
--- a/resources/3rdparty/eigen-3.3-beta1/lapack/lapack_common.h
+++ b/resources/3rdparty/eigen-3.3-beta1/lapack/lapack_common.h
@@ -16,7 +16,7 @@
   extern "C" { int EIGEN_BLAS_FUNC(FUNC) ARGLIST; }   \
   int EIGEN_BLAS_FUNC(FUNC) ARGLIST
 
-typedef Eigen::Map > PivotsType;
+typedef StormEigen::Map > PivotsType;
 
 #if ISCOMPLEX
 #define EIGEN_LAPACK_ARG_IF_COMPLEX(X) X,
diff --git a/resources/3rdparty/eigen-3.3-beta1/lapack/lu.cpp b/resources/3rdparty/eigen-3.3-beta1/lapack/lu.cpp
index 90cebe0f4..3eedaba45 100644
--- a/resources/3rdparty/eigen-3.3-beta1/lapack/lu.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/lapack/lu.cpp
@@ -28,7 +28,7 @@ EIGEN_LAPACK_FUNC(getrf,(int *m, int *n, RealScalar *pa, int *lda, int *ipiv, in
 
   Scalar* a = reinterpret_cast(pa);
   int nb_transpositions;
-  int ret = int(Eigen::internal::partial_lu_impl
+  int ret = int(StormEigen::internal::partial_lu_impl
                      ::blocked_lu(*m, *n, a, *lda, ipiv, nb_transpositions));
 
   for(int i=0; i void array_real(const ArrayType& m)
   VERIFY_IS_APPROX(m1.round(), round(m1));
   VERIFY_IS_APPROX(m1.floor(), floor(m1));
   VERIFY_IS_APPROX(m1.ceil(), ceil(m1));
-  VERIFY((m1.isNaN() == (Eigen::isnan)(m1)).all());
-  VERIFY((m1.isInf() == (Eigen::isinf)(m1)).all());
-  VERIFY((m1.isFinite() == (Eigen::isfinite)(m1)).all());
+  VERIFY((m1.isNaN() == (StormEigen::isnan)(m1)).all());
+  VERIFY((m1.isInf() == (StormEigen::isinf)(m1)).all());
+  VERIFY((m1.isFinite() == (StormEigen::isfinite)(m1)).all());
   VERIFY_IS_APPROX(m1.inverse(), inverse(m1));
   VERIFY_IS_APPROX(m1.abs(), abs(m1));
   VERIFY_IS_APPROX(m1.abs2(), abs2(m1));
@@ -256,9 +256,9 @@ template void array_real(const ArrayType& m)
   VERIFY_IS_APPROX(tanh(m1), (0.5*(exp(m1)-exp(-m1)))/(0.5*(exp(m1)+exp(-m1))));
   VERIFY_IS_APPROX(arg(m1), ((m1<0).template cast())*std::acos(-1.0));
   VERIFY((round(m1) <= ceil(m1) && round(m1) >= floor(m1)).all());
-  VERIFY((Eigen::isnan)((m1*0.0)/0.0).all());
-  VERIFY((Eigen::isinf)(m4/0.0).all());
-  VERIFY(((Eigen::isfinite)(m1) && (!(Eigen::isfinite)(m1*0.0/0.0)) && (!(Eigen::isfinite)(m4/0.0))).all());
+  VERIFY((StormEigen::isnan)((m1*0.0)/0.0).all());
+  VERIFY((StormEigen::isinf)(m4/0.0).all());
+  VERIFY(((StormEigen::isfinite)(m1) && (!(StormEigen::isfinite)(m1*0.0/0.0)) && (!(Eigen::isfinite)(m4/0.0))).all());
   VERIFY_IS_APPROX(inverse(inverse(m1)),m1);
   VERIFY((abs(m1) == m1 || abs(m1) == -m1).all());
   VERIFY_IS_APPROX(m3, sqrt(abs2(m1)));
@@ -287,11 +287,11 @@ template void array_real(const ArrayType& m)
   VERIFY_IS_APPROX(pow(2*m1,3), 8*m1.cube());
 
   ArrayType exponents = ArrayType::Constant(rows, cols, RealScalar(2));
-  VERIFY_IS_APPROX(Eigen::pow(m1,exponents), m1.square());
+  VERIFY_IS_APPROX(StormEigen::pow(m1,exponents), m1.square());
   VERIFY_IS_APPROX(m1.pow(exponents), m1.square());
-  VERIFY_IS_APPROX(Eigen::pow(2*m1,exponents), 4*m1.square());
+  VERIFY_IS_APPROX(StormEigen::pow(2*m1,exponents), 4*m1.square());
   VERIFY_IS_APPROX((2*m1).pow(exponents), 4*m1.square());
-  VERIFY_IS_APPROX(Eigen::pow(m1,2*exponents), m1.square().square());
+  VERIFY_IS_APPROX(StormEigen::pow(m1,2*exponents), m1.square().square());
   VERIFY_IS_APPROX(m1.pow(2*exponents), m1.square().square());
   VERIFY_IS_APPROX(pow(m1(0,0), exponents), ArrayType::Constant(rows,cols,m1(0,0)*m1(0,0)));
   
@@ -350,9 +350,9 @@ template void array_complex(const ArrayType& m)
   VERIFY_IS_APPROX(m1.cosh(), cosh(m1));
   VERIFY_IS_APPROX(m1.tanh(), tanh(m1));
   VERIFY_IS_APPROX(m1.arg(), arg(m1));
-  VERIFY((m1.isNaN() == (Eigen::isnan)(m1)).all());
-  VERIFY((m1.isInf() == (Eigen::isinf)(m1)).all());
-  VERIFY((m1.isFinite() == (Eigen::isfinite)(m1)).all());
+  VERIFY((m1.isNaN() == (StormEigen::isnan)(m1)).all());
+  VERIFY((m1.isInf() == (StormEigen::isinf)(m1)).all());
+  VERIFY((m1.isFinite() == (StormEigen::isfinite)(m1)).all());
   VERIFY_IS_APPROX(m1.inverse(), inverse(m1));
   VERIFY_IS_APPROX(m1.log(), log(m1));
   VERIFY_IS_APPROX(m1.log10(), log10(m1));
@@ -379,26 +379,26 @@ template void array_complex(const ArrayType& m)
   VERIFY_IS_APPROX(arg(m1), m3);
 
   std::complex zero(0.0,0.0);
-  VERIFY((Eigen::isnan)(m1*zero/zero).all());
+  VERIFY((StormEigen::isnan)(m1*zero/zero).all());
 #if EIGEN_COMP_MSVC
   // msvc complex division is not robust
-  VERIFY((Eigen::isinf)(m4/RealScalar(0)).all());
+  VERIFY((StormEigen::isinf)(m4/RealScalar(0)).all());
 #else
 #if EIGEN_COMP_CLANG
   // clang's complex division is notoriously broken too
   if((numext::isinf)(m4(0,0)/RealScalar(0))) {
 #endif
-    VERIFY((Eigen::isinf)(m4/zero).all());
+    VERIFY((StormEigen::isinf)(m4/zero).all());
 #if EIGEN_COMP_CLANG
   }
   else
   {
-    VERIFY((Eigen::isinf)(m4.real()/zero.real()).all());
+    VERIFY((StormEigen::isinf)(m4.real()/zero.real()).all());
   }
 #endif
 #endif // MSVC
 
-  VERIFY(((Eigen::isfinite)(m1) && (!(Eigen::isfinite)(m1*zero/zero)) && (!(Eigen::isfinite)(m1/zero))).all());
+  VERIFY(((StormEigen::isfinite)(m1) && (!(StormEigen::isfinite)(m1*zero/zero)) && (!(Eigen::isfinite)(m1/zero))).all());
 
   VERIFY_IS_APPROX(inverse(inverse(m1)),m1);
   VERIFY_IS_APPROX(conj(m1.conjugate()), m1);
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/bandmatrix.cpp b/resources/3rdparty/eigen-3.3-beta1/test/bandmatrix.cpp
index f8c38f7c3..2bc53d031 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/bandmatrix.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/bandmatrix.cpp
@@ -57,7 +57,7 @@ template void bandmatrix(const MatrixType& _m)
 
 }
 
-using Eigen::internal::BandMatrix;
+using StormEigen::internal::BandMatrix;
 
 void test_bandmatrix()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/block.cpp b/resources/3rdparty/eigen-3.3-beta1/test/block.cpp
index 3b77b704a..6bc95d068 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/block.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/block.cpp
@@ -11,7 +11,7 @@
 #include "main.h"
 
 template
-typename Eigen::internal::enable_if::IsComplex,typename MatrixType::Scalar>::type
+typename StormEigen::internal::enable_if::IsComplex,typename MatrixType::Scalar>::type
 block_real_only(const MatrixType &m1, Index r1, Index r2, Index c1, Index c2, const Scalar& s1) {
   // check cwise-Functions:
   VERIFY_IS_APPROX(m1.row(r1).cwiseMax(s1), m1.cwiseMax(s1).row(r1));
@@ -24,7 +24,7 @@ block_real_only(const MatrixType &m1, Index r1, Index r2, Index c1, Index c2, co
 }
 
 template
-typename Eigen::internal::enable_if::IsComplex,typename MatrixType::Scalar>::type
+typename StormEigen::internal::enable_if::IsComplex,typename MatrixType::Scalar>::type
 block_real_only(const MatrixType &, Index, Index, Index, Index, const Scalar&) {
   return Scalar(0);
 }
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/conservative_resize.cpp b/resources/3rdparty/eigen-3.3-beta1/test/conservative_resize.cpp
index 498421b4c..ec3fcfc17 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/conservative_resize.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/conservative_resize.cpp
@@ -11,12 +11,12 @@
 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 template 
 void run_matrix_tests()
 {
-  typedef Matrix MatrixType;
+  typedef Matrix MatrixType;
   typedef typename MatrixType::Index Index;
 
   MatrixType m, n;
@@ -60,7 +60,7 @@ void run_matrix_tests()
 template 
 void run_vector_tests()
 {
-  typedef Matrix VectorType;
+  typedef Matrix VectorType;
 
   VectorType m, n;
 
@@ -114,16 +114,16 @@ void test_conservative_resize()
 {
   for(int i=0; i()));
-    CALL_SUBTEST_1((run_matrix_tests()));
-    CALL_SUBTEST_2((run_matrix_tests()));
-    CALL_SUBTEST_2((run_matrix_tests()));
-    CALL_SUBTEST_3((run_matrix_tests()));
-    CALL_SUBTEST_3((run_matrix_tests()));
-    CALL_SUBTEST_4((run_matrix_tests, Eigen::RowMajor>()));
-    CALL_SUBTEST_4((run_matrix_tests, Eigen::ColMajor>()));
-    CALL_SUBTEST_5((run_matrix_tests, Eigen::RowMajor>()));
-    CALL_SUBTEST_6((run_matrix_tests, Eigen::ColMajor>()));
+    CALL_SUBTEST_1((run_matrix_tests()));
+    CALL_SUBTEST_1((run_matrix_tests()));
+    CALL_SUBTEST_2((run_matrix_tests()));
+    CALL_SUBTEST_2((run_matrix_tests()));
+    CALL_SUBTEST_3((run_matrix_tests()));
+    CALL_SUBTEST_3((run_matrix_tests()));
+    CALL_SUBTEST_4((run_matrix_tests, StormEigen::RowMajor>()));
+    CALL_SUBTEST_4((run_matrix_tests, StormEigen::ColMajor>()));
+    CALL_SUBTEST_5((run_matrix_tests, StormEigen::RowMajor>()));
+    CALL_SUBTEST_6((run_matrix_tests, StormEigen::ColMajor>()));
 
     CALL_SUBTEST_1((run_vector_tests()));
     CALL_SUBTEST_2((run_vector_tests()));
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/cuda_basic.cu b/resources/3rdparty/eigen-3.3-beta1/test/cuda_basic.cu
index b36ed888d..102a47165 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/cuda_basic.cu
+++ b/resources/3rdparty/eigen-3.3-beta1/test/cuda_basic.cu
@@ -20,7 +20,7 @@
 // struct Foo{
 //   EIGEN_DEVICE_FUNC
 //   void operator()(int i, const float* mats, float* vecs) const {
-//     using namespace Eigen;
+//     using namespace StormEigen;
 //   //   Matrix3f M(data);
 //   //   Vector3f x(data+9);
 //   //   Map(data+9) = M.inverse() * x;
@@ -38,7 +38,7 @@ struct coeff_wise {
   EIGEN_DEVICE_FUNC
   void operator()(int i, const typename T::Scalar* in, typename T::Scalar* out) const
   {
-    using namespace Eigen;
+    using namespace StormEigen;
     T x1(in+i);
     T x2(in+i+1);
     T x3(in+i+2);
@@ -53,7 +53,7 @@ struct replicate {
   EIGEN_DEVICE_FUNC
   void operator()(int i, const typename T::Scalar* in, typename T::Scalar* out) const
   {
-    using namespace Eigen;
+    using namespace StormEigen;
     T x1(in+i);
     int step   = x1.size() * 4;
     int stride = 3 * step;
@@ -70,7 +70,7 @@ struct redux {
   EIGEN_DEVICE_FUNC
   void operator()(int i, const typename T::Scalar* in, typename T::Scalar* out) const
   {
-    using namespace Eigen;
+    using namespace StormEigen;
     int N = 10;
     T x1(in+i);
     out[i*N+0] = x1.minCoeff();
@@ -90,7 +90,7 @@ struct prod_test {
   EIGEN_DEVICE_FUNC
   void operator()(int i, const typename T1::Scalar* in, typename T1::Scalar* out) const
   {
-    using namespace Eigen;
+    using namespace StormEigen;
     typedef Matrix T3;
     T1 x1(in+i);
     T2 x2(in+i+1);
@@ -104,7 +104,7 @@ struct diagonal {
   EIGEN_DEVICE_FUNC
   void operator()(int i, const typename T1::Scalar* in, typename T1::Scalar* out) const
   {
-    using namespace Eigen;
+    using namespace StormEigen;
     T1 x1(in+i);
     Map res(out+i*T2::MaxSizeAtCompileTime);
     res += x1.diagonal();
@@ -116,7 +116,7 @@ struct eigenvalues {
   EIGEN_DEVICE_FUNC
   void operator()(int i, const typename T::Scalar* in, typename T::Scalar* out) const
   {
-    using namespace Eigen;
+    using namespace StormEigen;
     typedef Matrix Vec;
     T M(in+i);
     Map res(out+i*Vec::MaxSizeAtCompileTime);
@@ -132,7 +132,7 @@ void test_cuda_basic()
   ei_test_init_cuda();
   
   int nthreads = 100;
-  Eigen::VectorXf in, out;
+  StormEigen::VectorXf in, out;
   
   #ifndef __CUDA_ARCH__
   int data_size = nthreads * 512;
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/denseLM.cpp b/resources/3rdparty/eigen-3.3-beta1/test/denseLM.cpp
index 0aa736ea3..820dd6b04 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/denseLM.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/denseLM.cpp
@@ -15,7 +15,7 @@
 #include "main.h"
 #include 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 template
 struct DenseLM : DenseFunctor
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/eigensolver_generic.cpp b/resources/3rdparty/eigen-3.3-beta1/test/eigensolver_generic.cpp
index 566546310..8220289fc 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/eigensolver_generic.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/eigensolver_generic.cpp
@@ -122,7 +122,7 @@ void test_eigensolver_generic()
   {
      MatrixXd A(1,1);
      A(0,0) = std::sqrt(-1.); // is Not-a-Number
-     Eigen::EigenSolver solver(A);
+     StormEigen::EigenSolver solver(A);
      VERIFY_IS_EQUAL(solver.info(), NumericalIssue);
   }
   );
@@ -134,7 +134,7 @@ void test_eigensolver_generic()
      a << 0,  0,  1,
           1,  1, 1,
           1, 1e+200,  1;
-     Eigen::EigenSolver eig(a);
+     StormEigen::EigenSolver eig(a);
      VERIFY_IS_APPROX(a * eig.pseudoEigenvectors(), eig.pseudoEigenvectors() * eig.pseudoEigenvalueMatrix());
      VERIFY_IS_APPROX(a * eig.eigenvectors(), eig.eigenvectors() * eig.eigenvalues().asDiagonal());
   }
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/evaluators.cpp b/resources/3rdparty/eigen-3.3-beta1/test/evaluators.cpp
index 876dffe22..a0940b190 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/evaluators.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/evaluators.cpp
@@ -1,7 +1,7 @@
 
 #include "main.h"
 
-namespace Eigen {
+namespace StormEigen {
 
   template
   const Product
@@ -94,7 +94,7 @@ namespace Eigen {
   
 }
 
-template long get_cost(const XprType& ) { return Eigen::internal::evaluator::CoeffReadCost; }
+template long get_cost(const XprType& ) { return StormEigen::internal::evaluator::CoeffReadCost; }
 
 using namespace std;
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/exceptions.cpp b/resources/3rdparty/eigen-3.3-beta1/test/exceptions.cpp
index b83fb82ba..2ce3de2e8 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/exceptions.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/exceptions.cpp
@@ -91,8 +91,8 @@ int ScalarWithExceptions::countdown = 0;
 
 void memoryleak()
 {
-  typedef Eigen::Matrix VectorType;
-  typedef Eigen::Matrix MatrixType;
+  typedef StormEigen::Matrix VectorType;
+  typedef StormEigen::Matrix MatrixType;
   
   {
     int n = 50;
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/geo_transformations.cpp b/resources/3rdparty/eigen-3.3-beta1/test/geo_transformations.cpp
index 51f90036d..9893ed826 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/geo_transformations.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/geo_transformations.cpp
@@ -277,9 +277,9 @@ template void transformations()
   // mat * aligned scaling and mat * translation
   t1 = (Matrix3(q1) * AlignedScaling3(v0)) * Translation3(v0);
   VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-  t1 = (Matrix3(q1) * Eigen::Scaling(v0)) * Translation3(v0);
+  t1 = (Matrix3(q1) * StormEigen::Scaling(v0)) * Translation3(v0);
   VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-  t1 = (q1 * Eigen::Scaling(v0)) * Translation3(v0);
+  t1 = (q1 * StormEigen::Scaling(v0)) * Translation3(v0);
   VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
   // mat * transformation and aligned scaling * translation
   t1 = Matrix3(q1) * (AlignedScaling3(v0) * Translation3(v0));
@@ -288,26 +288,26 @@ template void transformations()
 
   t0.setIdentity();
   t0.scale(s0).translate(v0);
-  t1 = Eigen::Scaling(s0) * Translation3(v0);
+  t1 = StormEigen::Scaling(s0) * Translation3(v0);
   VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
   t0.prescale(s0);
-  t1 = Eigen::Scaling(s0) * t1;
+  t1 = StormEigen::Scaling(s0) * t1;
   VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
   
   t0 = t3;
   t0.scale(s0);
-  t1 = t3 * Eigen::Scaling(s0,s0,s0);
+  t1 = t3 * StormEigen::Scaling(s0,s0,s0);
   VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
   t0.prescale(s0);
-  t1 = Eigen::Scaling(s0,s0,s0) * t1;
+  t1 = StormEigen::Scaling(s0,s0,s0) * t1;
   VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
 
   t0 = t3;
   t0.scale(s0);
-  t1 = t3 * Eigen::Scaling(s0);
+  t1 = t3 * StormEigen::Scaling(s0);
   VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
   t0.prescale(s0);
-  t1 = Eigen::Scaling(s0) * t1;
+  t1 = StormEigen::Scaling(s0) * t1;
   VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
 
   t0.setIdentity();
@@ -440,12 +440,12 @@ template void transformations()
   s1 = internal::random(-100,100);
   Rotation2D R0(s0), R1(s1);
   
-  t20 = Translation2(v20) * (R0 * Eigen::Scaling(s0));
-  t21 = Translation2(v20) * R0 * Eigen::Scaling(s0);
+  t20 = Translation2(v20) * (R0 * StormEigen::Scaling(s0));
+  t21 = Translation2(v20) * R0 * StormEigen::Scaling(s0);
   VERIFY_IS_APPROX(t20,t21);
   
-  t20 = Translation2(v20) * (R0 * R0.inverse() * Eigen::Scaling(s0));
-  t21 = Translation2(v20) * Eigen::Scaling(s0);
+  t20 = Translation2(v20) * (R0 * R0.inverse() * StormEigen::Scaling(s0));
+  t21 = Translation2(v20) * StormEigen::Scaling(s0);
   VERIFY_IS_APPROX(t20,t21);
   
   VERIFY_IS_APPROX(s0, (R0.slerp(0, R1)).angle());
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/main.h b/resources/3rdparty/eigen-3.3-beta1/test/main.h
index 2797e8623..567e50671 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/main.h
+++ b/resources/3rdparty/eigen-3.3-beta1/test/main.h
@@ -115,7 +115,7 @@ inline void on_temporary_creation(long int size) {
 
 #define DEFAULT_REPEAT 10
 
-namespace Eigen
+namespace StormEigen
 {
   static std::vector g_test_stack;
   // level == 0 <=> abort if test fail
@@ -140,7 +140,7 @@ namespace Eigen
 
 #ifndef EIGEN_NO_ASSERTION_CHECKING
 
-  namespace Eigen
+  namespace StormEigen
   {
     static const bool should_raise_an_assert = false;
 
@@ -153,7 +153,7 @@ namespace Eigen
     struct eigen_assert_exception
     {
       eigen_assert_exception(void) {}
-      ~eigen_assert_exception() { Eigen::no_more_assert = false; }
+      ~eigen_assert_exception() { StormEigen::no_more_assert = false; }
     };
   }
   // If EIGEN_DEBUG_ASSERTS is defined and if no assertion is triggered while
@@ -165,7 +165,7 @@ namespace Eigen
   // some memory errors.
   #ifdef EIGEN_DEBUG_ASSERTS
 
-    namespace Eigen
+    namespace StormEigen
     {
       namespace internal
       {
@@ -178,10 +178,10 @@ namespace Eigen
       { \
         if(report_on_cerr_on_assert_failure) \
           std::cerr <<  #a << " " __FILE__ << "(" << __LINE__ << ")\n"; \
-        Eigen::no_more_assert = true;       \
-        EIGEN_THROW_X(Eigen::eigen_assert_exception()); \
+        StormEigen::no_more_assert = true;       \
+        EIGEN_THROW_X(StormEigen::eigen_assert_exception()); \
       }                                     \
-      else if (Eigen::internal::push_assert)       \
+      else if (StormEigen::internal::push_assert)       \
       {                                     \
         eigen_assert_list.push_back(std::string(EI_PP_MAKE_STRING(__FILE__) " (" EI_PP_MAKE_STRING(__LINE__) ") : " #a) ); \
       }
@@ -189,45 +189,45 @@ namespace Eigen
     #ifdef EIGEN_EXCEPTIONS
     #define VERIFY_RAISES_ASSERT(a)                                                   \
       {                                                                               \
-        Eigen::no_more_assert = false;                                                \
-        Eigen::eigen_assert_list.clear();                                             \
-        Eigen::internal::push_assert = true;                                          \
-        Eigen::report_on_cerr_on_assert_failure = false;                              \
+        StormEigen::no_more_assert = false;                                                \
+        StormEigen::eigen_assert_list.clear();                                             \
+        StormEigen::internal::push_assert = true;                                          \
+        StormEigen::report_on_cerr_on_assert_failure = false;                              \
         try {                                                                         \
           a;                                                                          \
           std::cerr << "One of the following asserts should have been triggered:\n";  \
           for (uint ai=0 ; ai0)
+    if(StormEigen::g_test_level>0)
       std::cerr << "WARNING: ";
     std::cerr << "Test " << testname << " failed in " << file << " (" << line << ")"
       << std::endl << "    " << condition_as_string << std::endl;
     std::cerr << "Stack:\n";
-    const int test_stack_size = static_cast(Eigen::g_test_stack.size());
+    const int test_stack_size = static_cast(StormEigen::g_test_stack.size());
     for(int i=test_stack_size-1; i>=0; --i)
-      std::cerr << "  - " << Eigen::g_test_stack[i] << "\n";
+      std::cerr << "  - " << StormEigen::g_test_stack[i] << "\n";
     std::cerr << "\n";
-    if(Eigen::g_test_level==0)
+    if(StormEigen::g_test_level==0)
       abort();
   }
 }
@@ -289,7 +289,7 @@ inline void verify_impl(bool condition, const char *testname, const char *file,
   } while (0)
 
 
-namespace Eigen {
+namespace StormEigen {
 
 template inline typename NumTraits::Real test_precision() { return NumTraits::dummy_precision(); }
 template<> inline float test_precision() { return 1e-3f; }
@@ -596,7 +596,7 @@ template bool isMinusInf(const T& x)
   return x < NumTraits::lowest();
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 template struct GetDifferentType;
 
@@ -620,7 +620,7 @@ template<> std::string type_name >()          { return "comple
 // forward declaration of the main test function
 void EIGEN_CAT(test_,EIGEN_TEST_FUNC)();
 
-using namespace Eigen;
+using namespace StormEigen;
 
 inline void set_repeat_from_string(const char *str)
 {
@@ -706,7 +706,7 @@ int main(int argc, char *argv[])
     srand(g_seed);
     std::cout << "Repeating each test " << g_repeat << " times" << std::endl;
 
-    Eigen::g_test_stack.push_back(std::string(EI_PP_MAKE_STRING(EIGEN_TEST_FUNC)));
+    StormEigen::g_test_stack.push_back(std::string(EI_PP_MAKE_STRING(EIGEN_TEST_FUNC)));
 
     EIGEN_CAT(test_,EIGEN_TEST_FUNC)();
     return 0;
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/nomalloc.cpp b/resources/3rdparty/eigen-3.3-beta1/test/nomalloc.cpp
index 060276a20..abf630050 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/nomalloc.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/nomalloc.cpp
@@ -94,18 +94,18 @@ void ctms_decompositions()
   const int maxSize = 16;
   const int size    = 12;
 
-  typedef Eigen::Matrix Matrix;
 
-  typedef Eigen::Matrix Vector;
 
-  typedef Eigen::Matrix,
-                        Eigen::Dynamic, Eigen::Dynamic,
+  typedef StormEigen::Matrix,
+                        StormEigen::Dynamic, StormEigen::Dynamic,
                         0,
                         maxSize, maxSize> ComplexMatrix;
 
@@ -117,51 +117,51 @@ void ctms_decompositions()
   Vector x(size);
 
   // Cholesky module
-  Eigen::LLT  LLT;  LLT.compute(A);
+  StormEigen::LLT  LLT;  LLT.compute(A);
   X = LLT.solve(B);
   x = LLT.solve(b);
-  Eigen::LDLT LDLT; LDLT.compute(A);
+  StormEigen::LDLT LDLT; LDLT.compute(A);
   X = LDLT.solve(B);
   x = LDLT.solve(b);
 
   // Eigenvalues module
-  Eigen::HessenbergDecomposition hessDecomp;        hessDecomp.compute(complexA);
-  Eigen::ComplexSchur            cSchur(size);      cSchur.compute(complexA);
-  Eigen::ComplexEigenSolver      cEigSolver;        cEigSolver.compute(complexA);
-  Eigen::EigenSolver                    eigSolver;         eigSolver.compute(A);
-  Eigen::SelfAdjointEigenSolver         saEigSolver(size); saEigSolver.compute(saA);
-  Eigen::Tridiagonalization             tridiag;           tridiag.compute(saA);
+  StormEigen::HessenbergDecomposition hessDecomp;        hessDecomp.compute(complexA);
+  StormEigen::ComplexSchur            cSchur(size);      cSchur.compute(complexA);
+  StormEigen::ComplexEigenSolver      cEigSolver;        cEigSolver.compute(complexA);
+  StormEigen::EigenSolver                    eigSolver;         eigSolver.compute(A);
+  StormEigen::SelfAdjointEigenSolver         saEigSolver(size); saEigSolver.compute(saA);
+  StormEigen::Tridiagonalization             tridiag;           tridiag.compute(saA);
 
   // LU module
-  Eigen::PartialPivLU ppLU; ppLU.compute(A);
+  StormEigen::PartialPivLU ppLU; ppLU.compute(A);
   X = ppLU.solve(B);
   x = ppLU.solve(b);
-  Eigen::FullPivLU    fpLU; fpLU.compute(A);
+  StormEigen::FullPivLU    fpLU; fpLU.compute(A);
   X = fpLU.solve(B);
   x = fpLU.solve(b);
 
   // QR module
-  Eigen::HouseholderQR        hQR;  hQR.compute(A);
+  StormEigen::HouseholderQR        hQR;  hQR.compute(A);
   X = hQR.solve(B);
   x = hQR.solve(b);
-  Eigen::ColPivHouseholderQR  cpQR; cpQR.compute(A);
+  StormEigen::ColPivHouseholderQR  cpQR; cpQR.compute(A);
   X = cpQR.solve(B);
   x = cpQR.solve(b);
-  Eigen::FullPivHouseholderQR fpQR; fpQR.compute(A);
+  StormEigen::FullPivHouseholderQR fpQR; fpQR.compute(A);
   // FIXME X = fpQR.solve(B);
   x = fpQR.solve(b);
 
   // SVD module
-  Eigen::JacobiSVD jSVD; jSVD.compute(A, ComputeFullU | ComputeFullV);
+  StormEigen::JacobiSVD jSVD; jSVD.compute(A, ComputeFullU | ComputeFullV);
 }
 
 void test_zerosized() {
   // default constructors:
-  Eigen::MatrixXd A;
-  Eigen::VectorXd v;
+  StormEigen::MatrixXd A;
+  StormEigen::VectorXd v;
   // explicit zero-sized:
-  Eigen::ArrayXXd A0(0,0);
-  Eigen::ArrayXd v0(0);
+  StormEigen::ArrayXXd A0(0,0);
+  StormEigen::ArrayXd v0(0);
 
   // assigning empty objects to each other:
   A=A0;
@@ -170,14 +170,14 @@ void test_zerosized() {
 
 template void test_reference(const MatrixType& m) {
   typedef typename MatrixType::Scalar Scalar;
-  enum { Flag          =  MatrixType::IsRowMajor ? Eigen::RowMajor : Eigen::ColMajor};
-  enum { TransposeFlag = !MatrixType::IsRowMajor ? Eigen::RowMajor : Eigen::ColMajor};
+  enum { Flag          =  MatrixType::IsRowMajor ? StormEigen::RowMajor : StormEigen::ColMajor};
+  enum { TransposeFlag = !MatrixType::IsRowMajor ? StormEigen::RowMajor : StormEigen::ColMajor};
   typename MatrixType::Index rows = m.rows(), cols=m.cols();
-  typedef Eigen::Matrix MatrixX;
-  typedef Eigen::Matrix MatrixXT;
+  typedef StormEigen::Matrix MatrixX;
+  typedef StormEigen::Matrix MatrixXT;
   // Dynamic reference:
-  typedef Eigen::Ref Ref;
-  typedef Eigen::Ref RefT;
+  typedef StormEigen::Ref Ref;
+  typedef StormEigen::Ref RefT;
 
   Ref r1(m);
   Ref r2(m.block(rows/3, cols/4, rows/2, cols/2));
@@ -193,10 +193,10 @@ template void test_reference(const MatrixType& m) {
   RefT r9 = r3;
 
   // Initializing from a compatible Ref shall also never malloc
-  Eigen::Ref > r10=r8, r11=m;
+  StormEigen::Ref > r10=r8, r11=m;
 
   // Initializing from an incompatible Ref will malloc:
-  typedef Eigen::Ref RefAligned;
+  typedef StormEigen::Ref RefAligned;
   VERIFY_RAISES_ASSERT(RefAligned r12=r10);
   VERIFY_RAISES_ASSERT(Ref r13=r10); // r10 has more dynamic strides
 
@@ -205,11 +205,11 @@ template void test_reference(const MatrixType& m) {
 void test_nomalloc()
 {
   // create some dynamic objects
-  Eigen::MatrixXd M1 = MatrixXd::Random(3,3);
+  StormEigen::MatrixXd M1 = MatrixXd::Random(3,3);
   Ref R1 = 2.0*M1; // Ref requires temporary
 
   // from here on prohibit malloc:
-  Eigen::internal::set_is_malloc_allowed(false);
+  StormEigen::internal::set_is_malloc_allowed(false);
 
   // check that our operator new is indeed called:
   VERIFY_RAISES_ASSERT(MatrixXd dummy(MatrixXd::Random(3,3)));
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/packetmath.cpp b/resources/3rdparty/eigen-3.3-beta1/test/packetmath.cpp
index e09a361bf..788f5da52 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/packetmath.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/packetmath.cpp
@@ -10,9 +10,9 @@
 
 #include "main.h"
 
-// using namespace Eigen;
+// using namespace StormEigen;
 
-namespace Eigen {
+namespace StormEigen {
 namespace internal {
 template T negate(const T& x) { return -x; }
 }
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/pastix_support.cpp b/resources/3rdparty/eigen-3.3-beta1/test/pastix_support.cpp
index 49239e3a5..38f51ce6e 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/pastix_support.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/pastix_support.cpp
@@ -16,10 +16,10 @@
 
 template void test_pastix_T()
 {
-  PastixLLT< SparseMatrix, Eigen::Lower > pastix_llt_lower;
-  PastixLDLT< SparseMatrix, Eigen::Lower > pastix_ldlt_lower;
-  PastixLLT< SparseMatrix, Eigen::Upper > pastix_llt_upper;
-  PastixLDLT< SparseMatrix, Eigen::Upper > pastix_ldlt_upper;
+  PastixLLT< SparseMatrix, StormEigen::Lower > pastix_llt_lower;
+  PastixLDLT< SparseMatrix, StormEigen::Lower > pastix_ldlt_lower;
+  PastixLLT< SparseMatrix, StormEigen::Upper > pastix_llt_upper;
+  PastixLDLT< SparseMatrix, StormEigen::Upper > pastix_ldlt_upper;
   PastixLU< SparseMatrix > pastix_lu;
 
   check_sparse_spd_solving(pastix_llt_lower);
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/product_extra.cpp b/resources/3rdparty/eigen-3.3-beta1/test/product_extra.cpp
index d253fd7ed..093ac281c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/product_extra.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/product_extra.cpp
@@ -103,7 +103,7 @@ template void product_extra(const MatrixType& m)
 // Regression test for bug reported at http://forum.kde.org/viewtopic.php?f=74&t=96947
 void mat_mat_scalar_scalar_product()
 {
-  Eigen::Matrix2Xd dNdxy(2, 3);
+  StormEigen::Matrix2Xd dNdxy(2, 3);
   dNdxy << -0.5, 0.5, 0,
            -0.3, 0, 0.3;
   double det = 6.0, wt = 0.5;
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/product_large.cpp b/resources/3rdparty/eigen-3.3-beta1/test/product_large.cpp
index 7207973c2..05c38bb22 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/product_large.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/product_large.cpp
@@ -63,7 +63,7 @@ void test_product_large()
   }
 
   {
-    Eigen::MatrixXd A(10,10), B, C;
+    StormEigen::MatrixXd A(10,10), B, C;
     A.setRandom();
     C = A;
     for(int k=0; k<79; ++k)
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/product_small.cpp b/resources/3rdparty/eigen-3.3-beta1/test/product_small.cpp
index c35db6f65..fb55d140c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/product_small.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/product_small.cpp
@@ -213,15 +213,15 @@ void test_product_small()
   
   {
     // regression test for pull-request #93
-    Eigen::Matrix A;  A.setRandom();
-    Eigen::Matrix B; B.setRandom();
-    Eigen::Matrix C; C.setRandom();
+    StormEigen::Matrix A;  A.setRandom();
+    StormEigen::Matrix B; B.setRandom();
+    StormEigen::Matrix C; C.setRandom();
     VERIFY_IS_APPROX(B * A.inverse(), B * A.inverse()[0]);
     VERIFY_IS_APPROX(A.inverse() * C, A.inverse()[0] * C);
   }
 
   {
-    Eigen::Matrix A, B, C;
+    StormEigen::Matrix A, B, C;
     A.setRandom();
     C = A;
     for(int k=0; k<79; ++k)
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/product_trmv.cpp b/resources/3rdparty/eigen-3.3-beta1/test/product_trmv.cpp
index 57a202afc..7dbf29859 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/product_trmv.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/product_trmv.cpp
@@ -30,43 +30,43 @@ template void trmv(const MatrixType& m)
   m1 = MatrixType::Random(rows, cols);
 
   // check with a column-major matrix
-  m3 = m1.template triangularView();
-  VERIFY((m3 * v1).isApprox(m1.template triangularView() * v1, largerEps));
-  m3 = m1.template triangularView();
-  VERIFY((m3 * v1).isApprox(m1.template triangularView() * v1, largerEps));
-  m3 = m1.template triangularView();
-  VERIFY((m3 * v1).isApprox(m1.template triangularView() * v1, largerEps));
-  m3 = m1.template triangularView();
-  VERIFY((m3 * v1).isApprox(m1.template triangularView() * v1, largerEps));
+  m3 = m1.template triangularView();
+  VERIFY((m3 * v1).isApprox(m1.template triangularView() * v1, largerEps));
+  m3 = m1.template triangularView();
+  VERIFY((m3 * v1).isApprox(m1.template triangularView() * v1, largerEps));
+  m3 = m1.template triangularView();
+  VERIFY((m3 * v1).isApprox(m1.template triangularView() * v1, largerEps));
+  m3 = m1.template triangularView();
+  VERIFY((m3 * v1).isApprox(m1.template triangularView() * v1, largerEps));
 
   // check conjugated and scalar multiple expressions (col-major)
-  m3 = m1.template triangularView();
-  VERIFY(((s1*m3).conjugate() * v1).isApprox((s1*m1).conjugate().template triangularView() * v1, largerEps));
-  m3 = m1.template triangularView();
-  VERIFY((m3.conjugate() * v1.conjugate()).isApprox(m1.conjugate().template triangularView() * v1.conjugate(), largerEps));
+  m3 = m1.template triangularView();
+  VERIFY(((s1*m3).conjugate() * v1).isApprox((s1*m1).conjugate().template triangularView() * v1, largerEps));
+  m3 = m1.template triangularView();
+  VERIFY((m3.conjugate() * v1.conjugate()).isApprox(m1.conjugate().template triangularView() * v1.conjugate(), largerEps));
 
   // check with a row-major matrix
-  m3 = m1.template triangularView();
-  VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView() * v1, largerEps));
-  m3 = m1.template triangularView();
-  VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView() * v1, largerEps));
-  m3 = m1.template triangularView();
-  VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView() * v1, largerEps));
-  m3 = m1.template triangularView();
-  VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView() * v1, largerEps));
+  m3 = m1.template triangularView();
+  VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView() * v1, largerEps));
+  m3 = m1.template triangularView();
+  VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView() * v1, largerEps));
+  m3 = m1.template triangularView();
+  VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView() * v1, largerEps));
+  m3 = m1.template triangularView();
+  VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView() * v1, largerEps));
 
   // check conjugated and scalar multiple expressions (row-major)
-  m3 = m1.template triangularView();
-  VERIFY((m3.adjoint() * v1).isApprox(m1.adjoint().template triangularView() * v1, largerEps));
-  m3 = m1.template triangularView();
-  VERIFY((m3.adjoint() * (s1*v1.conjugate())).isApprox(m1.adjoint().template triangularView() * (s1*v1.conjugate()), largerEps));
-  m3 = m1.template triangularView();
+  m3 = m1.template triangularView();
+  VERIFY((m3.adjoint() * v1).isApprox(m1.adjoint().template triangularView() * v1, largerEps));
+  m3 = m1.template triangularView();
+  VERIFY((m3.adjoint() * (s1*v1.conjugate())).isApprox(m1.adjoint().template triangularView() * (s1*v1.conjugate()), largerEps));
+  m3 = m1.template triangularView();
 
   // check transposed cases:
-  m3 = m1.template triangularView();
-  VERIFY((v1.transpose() * m3).isApprox(v1.transpose() * m1.template triangularView(), largerEps));
-  VERIFY((v1.adjoint() * m3).isApprox(v1.adjoint() * m1.template triangularView(), largerEps));
-  VERIFY((v1.adjoint() * m3.adjoint()).isApprox(v1.adjoint() * m1.template triangularView().adjoint(), largerEps));
+  m3 = m1.template triangularView();
+  VERIFY((v1.transpose() * m3).isApprox(v1.transpose() * m1.template triangularView(), largerEps));
+  VERIFY((v1.adjoint() * m3).isApprox(v1.adjoint() * m1.template triangularView(), largerEps));
+  VERIFY((v1.adjoint() * m3.adjoint()).isApprox(v1.adjoint() * m1.template triangularView().adjoint(), largerEps));
 
   // TODO check with sub-matrices
 }
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/schur_complex.cpp b/resources/3rdparty/eigen-3.3-beta1/test/schur_complex.cpp
index deb78e44e..9c33f9ece 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/schur_complex.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/schur_complex.cpp
@@ -84,7 +84,7 @@ void test_schur_complex()
   CALL_SUBTEST_1(( schur() ));
   CALL_SUBTEST_2(( schur(internal::random(1,EIGEN_TEST_MAX_SIZE/4)) ));
   CALL_SUBTEST_3(( schur, 1, 1> >() ));
-  CALL_SUBTEST_4(( schur >() ));
+  CALL_SUBTEST_4(( schur >() ));
 
   // Test problem size constructors
   CALL_SUBTEST_5(ComplexSchur(10));
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/schur_real.cpp b/resources/3rdparty/eigen-3.3-beta1/test/schur_real.cpp
index cfe4570d4..d2c72fea3 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/schur_real.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/schur_real.cpp
@@ -105,7 +105,7 @@ void test_schur_real()
   CALL_SUBTEST_1(( schur() ));
   CALL_SUBTEST_2(( schur(internal::random(1,EIGEN_TEST_MAX_SIZE/4)) ));
   CALL_SUBTEST_3(( schur >() ));
-  CALL_SUBTEST_4(( schur >() ));
+  CALL_SUBTEST_4(( schur >() ));
 
   // Test problem size constructors
   CALL_SUBTEST_5(RealSchur(10));
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/sparseLM.cpp b/resources/3rdparty/eigen-3.3-beta1/test/sparseLM.cpp
index 8e148f9bc..9d04a9050 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/sparseLM.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/sparseLM.cpp
@@ -15,7 +15,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 template 
 struct sparseGaussianTest : SparseFunctor
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/sparse_basic.cpp b/resources/3rdparty/eigen-3.3-beta1/test/sparse_basic.cpp
index d803e7dae..dcda1c32c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/sparse_basic.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/sparse_basic.cpp
@@ -487,8 +487,8 @@ void big_sparse_triplet(Index rows, Index cols, double density) {
 void test_sparse_basic()
 {
   for(int i = 0; i < g_repeat; i++) {
-    int r = Eigen::internal::random(1,200), c = Eigen::internal::random(1,200);
-    if(Eigen::internal::random(0,4) == 0) {
+    int r = StormEigen::internal::random(1,200), c = StormEigen::internal::random(1,200);
+    if(StormEigen::internal::random(0,4) == 0) {
       r = c; // check square matrices in 25% of tries
     }
     EIGEN_UNUSED_VARIABLE(r+c);
@@ -500,9 +500,9 @@ void test_sparse_basic()
     CALL_SUBTEST_5(( sparse_basic(SparseMatrix(r, c)) ));
     CALL_SUBTEST_5(( sparse_basic(SparseMatrix(r, c)) ));
     
-    r = Eigen::internal::random(1,100);
-    c = Eigen::internal::random(1,100);
-    if(Eigen::internal::random(0,4) == 0) {
+    r = StormEigen::internal::random(1,100);
+    c = StormEigen::internal::random(1,100);
+    if(StormEigen::internal::random(0,4) == 0) {
       r = c; // check square matrices in 25% of tries
     }
     
@@ -517,7 +517,7 @@ void test_sparse_basic()
   // Regression test for bug 1105
 #ifdef EIGEN_TEST_PART_6
   {
-    int n = Eigen::internal::random(200,600);
+    int n = StormEigen::internal::random(200,600);
     SparseMatrix,0, long> mat(n, n);
     std::complex val;
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/sparse_block.cpp b/resources/3rdparty/eigen-3.3-beta1/test/sparse_block.cpp
index 8a6e0687c..db59e929d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/sparse_block.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/sparse_block.cpp
@@ -228,8 +228,8 @@ template void sparse_block(const SparseMatrixType& re
 void test_sparse_block()
 {
   for(int i = 0; i < g_repeat; i++) {
-    int r = Eigen::internal::random(1,200), c = Eigen::internal::random(1,200);
-    if(Eigen::internal::random(0,4) == 0) {
+    int r = StormEigen::internal::random(1,200), c = StormEigen::internal::random(1,200);
+    if(StormEigen::internal::random(0,4) == 0) {
       r = c; // check square matrices in 25% of tries
     }
     EIGEN_UNUSED_VARIABLE(r+c);
@@ -242,9 +242,9 @@ void test_sparse_block()
     CALL_SUBTEST_3(( sparse_block(SparseMatrix(r, c)) ));
     CALL_SUBTEST_3(( sparse_block(SparseMatrix(r, c)) ));
     
-    r = Eigen::internal::random(1,100);
-    c = Eigen::internal::random(1,100);
-    if(Eigen::internal::random(0,4) == 0) {
+    r = StormEigen::internal::random(1,100);
+    c = StormEigen::internal::random(1,100);
+    if(StormEigen::internal::random(0,4) == 0) {
       r = c; // check square matrices in 25% of tries
     }
     
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/sparse_permutations.cpp b/resources/3rdparty/eigen-3.3-beta1/test/sparse_permutations.cpp
index b82cceff8..a3fd7ef18 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/sparse_permutations.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/sparse_permutations.cpp
@@ -223,7 +223,7 @@ template void sparse_permutations_all(int size)
 void test_sparse_permutations()
 {
   for(int i = 0; i < g_repeat; i++) {
-    int s = Eigen::internal::random(1,50);
+    int s = StormEigen::internal::random(1,50);
     CALL_SUBTEST_1((  sparse_permutations_all(s) ));
     CALL_SUBTEST_2((  sparse_permutations_all >(s) ));
   }
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/sparse_solver.h b/resources/3rdparty/eigen-3.3-beta1/test/sparse_solver.h
index b67653496..a64441235 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/sparse_solver.h
+++ b/resources/3rdparty/eigen-3.3-beta1/test/sparse_solver.h
@@ -291,7 +291,7 @@ template void check_sparse_spd_solving(Solver& solver, int maxS
           if(Solver::UpLo == (Lower|Upper))
             halfA = A;
           else
-            halfA.template selfadjointView() = A.template triangularView().twistedBy(pnull);
+            halfA.template selfadjointView() = A.template triangularView().twistedBy(pnull);
           
           std::cout << "INFO | Testing " << sym_to_string(it.sym()) << "sparse problem " << it.matname()
                   << " (" << A.rows() << "x" << A.cols() << ") using " << typeid(Solver).name() << "..." << std::endl;
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/stddeque.cpp b/resources/3rdparty/eigen-3.3-beta1/test/stddeque.cpp
index bb4b476f3..6d7046c7a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/stddeque.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/stddeque.cpp
@@ -20,14 +20,14 @@ void check_stddeque_matrix(const MatrixType& m)
   Index rows = m.rows();
   Index cols = m.cols();
   MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
-  std::deque > v(10, MatrixType(rows,cols)), w(20, y);
+  std::deque > v(10, MatrixType(rows,cols)), w(20, y);
   v.front() = x;
   w.front() = w.back();
   VERIFY_IS_APPROX(w.front(), w.back());
   v = w;
 
-  typename std::deque >::iterator vi = v.begin();
-  typename std::deque >::iterator wi = w.begin();
+  typename std::deque >::iterator vi = v.begin();
+  typename std::deque >::iterator wi = w.begin();
   for(int i = 0; i < 20; i++)
   {
     VERIFY_IS_APPROX(*vi, *wi);
@@ -49,14 +49,14 @@ void check_stddeque_transform(const TransformType&)
 {
   typedef typename TransformType::MatrixType MatrixType;
   TransformType x(MatrixType::Random()), y(MatrixType::Random());
-  std::deque > v(10), w(20, y);
+  std::deque > v(10), w(20, y);
   v.front() = x;
   w.front() = w.back();
   VERIFY_IS_APPROX(w.front(), w.back());
   v = w;
 
-  typename std::deque >::iterator vi = v.begin();
-  typename std::deque >::iterator wi = w.begin();
+  typename std::deque >::iterator vi = v.begin();
+  typename std::deque >::iterator wi = w.begin();
   for(int i = 0; i < 20; i++)
   {
     VERIFY_IS_APPROX(*vi, *wi);
@@ -78,14 +78,14 @@ void check_stddeque_quaternion(const QuaternionType&)
 {
   typedef typename QuaternionType::Coefficients Coefficients;
   QuaternionType x(Coefficients::Random()), y(Coefficients::Random());
-  std::deque > v(10), w(20, y);
+  std::deque > v(10), w(20, y);
   v.front() = x;
   w.front() = w.back();
   VERIFY_IS_APPROX(w.front(), w.back());
   v = w;
 
-  typename std::deque >::iterator vi = v.begin();
-  typename std::deque >::iterator wi = w.begin();
+  typename std::deque >::iterator vi = v.begin();
+  typename std::deque >::iterator wi = w.begin();
   for(int i = 0; i < 20; i++)
   {
     VERIFY_IS_APPROX(*vi, *wi);
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/stdlist.cpp b/resources/3rdparty/eigen-3.3-beta1/test/stdlist.cpp
index 17cce779a..4ace2c38e 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/stdlist.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/stdlist.cpp
@@ -20,14 +20,14 @@ void check_stdlist_matrix(const MatrixType& m)
   Index rows = m.rows();
   Index cols = m.cols();
   MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
-  std::list > v(10, MatrixType(rows,cols)), w(20, y);
+  std::list > v(10, MatrixType(rows,cols)), w(20, y);
   v.front() = x;
   w.front() = w.back();
   VERIFY_IS_APPROX(w.front(), w.back());
   v = w;
 
-  typename std::list >::iterator vi = v.begin();
-  typename std::list >::iterator wi = w.begin();
+  typename std::list >::iterator vi = v.begin();
+  typename std::list >::iterator wi = w.begin();
   for(int i = 0; i < 20; i++)
   {
     VERIFY_IS_APPROX(*vi, *wi);
@@ -49,14 +49,14 @@ void check_stdlist_transform(const TransformType&)
 {
   typedef typename TransformType::MatrixType MatrixType;
   TransformType x(MatrixType::Random()), y(MatrixType::Random());
-  std::list > v(10), w(20, y);
+  std::list > v(10), w(20, y);
   v.front() = x;
   w.front() = w.back();
   VERIFY_IS_APPROX(w.front(), w.back());
   v = w;
 
-  typename std::list >::iterator vi = v.begin();
-  typename std::list >::iterator wi = w.begin();
+  typename std::list >::iterator vi = v.begin();
+  typename std::list >::iterator wi = w.begin();
   for(int i = 0; i < 20; i++)
   {
     VERIFY_IS_APPROX(*vi, *wi);
@@ -78,14 +78,14 @@ void check_stdlist_quaternion(const QuaternionType&)
 {
   typedef typename QuaternionType::Coefficients Coefficients;
   QuaternionType x(Coefficients::Random()), y(Coefficients::Random());
-  std::list > v(10), w(20, y);
+  std::list > v(10), w(20, y);
   v.front() = x;
   w.front() = w.back();
   VERIFY_IS_APPROX(w.front(), w.back());
   v = w;
 
-  typename std::list >::iterator vi = v.begin();
-  typename std::list >::iterator wi = w.begin();
+  typename std::list >::iterator vi = v.begin();
+  typename std::list >::iterator wi = w.begin();
   for(int i = 0; i < 20; i++)
   {
     VERIFY_IS_APPROX(*vi, *wi);
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/stdvector.cpp b/resources/3rdparty/eigen-3.3-beta1/test/stdvector.cpp
index 6e173c678..055f7d495 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/stdvector.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/stdvector.cpp
@@ -17,7 +17,7 @@ void check_stdvector_matrix(const MatrixType& m)
   typename MatrixType::Index rows = m.rows();
   typename MatrixType::Index cols = m.cols();
   MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
-  std::vector > v(10, MatrixType(rows,cols)), w(20, y);
+  std::vector > v(10, MatrixType(rows,cols)), w(20, y);
   v[5] = x;
   w[6] = v[5];
   VERIFY_IS_APPROX(w[6], v[5]);
@@ -52,7 +52,7 @@ void check_stdvector_transform(const TransformType&)
 {
   typedef typename TransformType::MatrixType MatrixType;
   TransformType x(MatrixType::Random()), y(MatrixType::Random());
-  std::vector > v(10), w(20, y);
+  std::vector > v(10), w(20, y);
   v[5] = x;
   w[6] = v[5];
   VERIFY_IS_APPROX(w[6], v[5]);
@@ -87,7 +87,7 @@ void check_stdvector_quaternion(const QuaternionType&)
 {
   typedef typename QuaternionType::Coefficients Coefficients;
   QuaternionType x(Coefficients::Random()), y(Coefficients::Random());
-  std::vector > v(10), w(20, y);
+  std::vector > v(10), w(20, y);
   v[5] = x;
   w[6] = v[5];
   VERIFY_IS_APPROX(w[6], v[5]);
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/triangular.cpp b/resources/3rdparty/eigen-3.3-beta1/test/triangular.cpp
index 936c2aef3..733c75fae 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/triangular.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/triangular.cpp
@@ -90,14 +90,14 @@ template void triangular_square(const MatrixType& m)
 
   // check M * inv(L) using in place API
   m4 = m3;
-  m1.transpose().template triangularView().solveInPlace(trm4);
-  VERIFY_IS_APPROX(m4 * m1.template triangularView(), m3);
+  m1.transpose().template triangularView().solveInPlace(trm4);
+  VERIFY_IS_APPROX(m4 * m1.template triangularView(), m3);
 
   // check M * inv(U) using in place API
   m3 = m1.template triangularView();
   m4 = m3;
-  m3.transpose().template triangularView().solveInPlace(trm4);
-  VERIFY_IS_APPROX(m4 * m1.template triangularView(), m3);
+  m3.transpose().template triangularView().solveInPlace(trm4);
+  VERIFY_IS_APPROX(m4 * m1.template triangularView(), m3);
 
   // check solve with unit diagonal
   m3 = m1.template triangularView();
diff --git a/resources/3rdparty/eigen-3.3-beta1/test/umeyama.cpp b/resources/3rdparty/eigen-3.3-beta1/test/umeyama.cpp
index 2e8092434..f72a7a8bf 100644
--- a/resources/3rdparty/eigen-3.3-beta1/test/umeyama.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/test/umeyama.cpp
@@ -15,14 +15,14 @@
 #include  // required for MatrixBase::determinant
 #include  // required for SVD
 
-using namespace Eigen;
+using namespace StormEigen;
 
 //  Constructs a random matrix from the unitary group U(size).
 template 
-Eigen::Matrix randMatrixUnitary(int size)
+StormEigen::Matrix randMatrixUnitary(int size)
 {
   typedef T Scalar;
-  typedef Eigen::Matrix MatrixType;
+  typedef StormEigen::Matrix MatrixType;
 
   MatrixType Q;
 
@@ -72,11 +72,11 @@ Eigen::Matrix randMatrixUnitary(int size)
 
 //  Constructs a random matrix from the special unitary group SU(size).
 template 
-Eigen::Matrix randMatrixSpecialUnitary(int size)
+StormEigen::Matrix randMatrixSpecialUnitary(int size)
 {
   typedef T Scalar;
 
-  typedef Eigen::Matrix MatrixType;
+  typedef StormEigen::Matrix MatrixType;
 
   // initialize unitary matrix
   MatrixType Q = randMatrixUnitary(size);
@@ -92,8 +92,8 @@ void run_test(int dim, int num_elements)
 {
   using std::abs;
   typedef typename internal::traits::Scalar Scalar;
-  typedef Matrix MatrixX;
-  typedef Matrix VectorX;
+  typedef Matrix MatrixX;
+  typedef Matrix VectorX;
 
   // MUST be positive because in any other case det(cR_t) may become negative for
   // odd dimensions!
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/AdolcForward b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/AdolcForward
index 15f5f0731..a225b975a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/AdolcForward
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/AdolcForward
@@ -42,7 +42,7 @@
 
 #include 
 
-namespace Eigen {
+namespace StormEigen {
 
 /**
   * \defgroup AdolcForward_Module Adolc forward module
@@ -50,7 +50,7 @@ namespace Eigen {
   * ADOL-C is a C++ automatic differentiation library,
   * see https://projects.coin-or.org/ADOL-C for more information.
   * It mainly consists in:
-  *  - a struct Eigen::NumTraits specialization
+  *  - a struct StormEigen::NumTraits specialization
   *  - overloads of internal::* math function for adtl::adouble type.
   *
   * Note that the maximal number of directions is controlled by
@@ -62,7 +62,7 @@ namespace Eigen {
   */
   //@{
 
-} // namespace Eigen
+} // namespace StormEigen
 
 // Eigen's require a few additional functions which must be defined in the same namespace
 // than the custom scalar type own namespace
@@ -76,7 +76,7 @@ inline adouble abs2(const adouble& x)  { return x*x; }
 
 }
 
-namespace Eigen {
+namespace StormEigen {
 
 template<> struct NumTraits
     : NumTraits
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/AlignedVector3 b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/AlignedVector3
index f5c40a189..143e236c8 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/AlignedVector3
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/AlignedVector3
@@ -12,7 +12,7 @@
 
 #include 
 
-namespace Eigen {
+namespace StormEigen {
 
 /**
   * \defgroup AlignedVector3_Module Aligned vector3 module
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/AutoDiff b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/AutoDiff
index abf5b7d67..9434c0815 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/AutoDiff
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/AutoDiff
@@ -10,7 +10,7 @@
 #ifndef EIGEN_AUTODIFF_MODULE
 #define EIGEN_AUTODIFF_MODULE
 
-namespace Eigen {
+namespace StormEigen {
 
 /**
   * \defgroup AutoDiff_Module Auto Diff module
@@ -33,7 +33,7 @@ namespace Eigen {
 // #include "src/AutoDiff/AutoDiffVector.h"
 #include "src/AutoDiff/AutoDiffJacobian.h"
 
-namespace Eigen {
+namespace StormEigen {
 //@}
 }
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/BVH b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/BVH
index 0161a5402..66ce48fb0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/BVH
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/BVH
@@ -16,7 +16,7 @@
 #include 
 #include 
 
-namespace Eigen {
+namespace StormEigen {
 
 /**
   * \defgroup BVH_Module BVH module
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CMakeLists.txt b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CMakeLists.txt
index 6d0cf4f9d..e79858ae2 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CMakeLists.txt
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CMakeLists.txt
@@ -26,4 +26,4 @@ install(FILES
   )
 
 add_subdirectory(src)
-add_subdirectory(CXX11)
\ No newline at end of file
+add_subdirectory(CXX11)
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/CXX11Meta.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/CXX11Meta.h
index 3f149c6a3..c523c2fc8 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/CXX11Meta.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/CXX11Meta.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11META_H
 #define EIGEN_CXX11META_H
 
-namespace Eigen {
+namespace StormEigen {
 
 namespace internal {
 
@@ -525,6 +525,6 @@ InstType instantiate_by_c_array(ArrType* arr)
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11META_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/CXX11Workarounds.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/CXX11Workarounds.h
index b1528aa66..ceab98a52 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/CXX11Workarounds.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/CXX11Workarounds.h
@@ -37,7 +37,7 @@
 #error This library needs at least a C++11 compliant compiler. If you use g++/clang, please enable the -std=c++11 compiler flag. (-std=c++0x on older versions.)
 #endif
 
-namespace Eigen {
+namespace StormEigen {
 
 namespace internal {
 
@@ -77,7 +77,7 @@ template constexpr inline T const& array_get(std::vector
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11WORKAROUNDS_H
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/EmulateArray.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/EmulateArray.h
index ab9c2ec3e..5f2a3d421 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/EmulateArray.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/EmulateArray.h
@@ -17,7 +17,7 @@
 // Moreover, CUDA doesn't support the STL containers, so we use our own instead.
 #if __cplusplus <= 199711L || defined(__CUDACC__) || defined(EIGEN_AVOID_STL_ARRAY)
 
-namespace Eigen {
+namespace StormEigen {
 template  class array {
  public:
   EIGEN_DEVICE_FUNC
@@ -172,13 +172,13 @@ template struct array_size& > {
 };
 
 }  // end namespace internal
-}  // end namespace Eigen
+}  // end namespace StormEigen
 
 #else
 
 // The compiler supports c++11, and we're not targetting cuda: use std::array as Eigen array
 #include 
-namespace Eigen {
+namespace StormEigen {
 
 template  using array = std::array;
 
@@ -214,7 +214,7 @@ template struct array_size > {
   static const size_t value = N;
 };
 }  // end namespace internal
-}  // end namespace Eigen
+}  // end namespace StormEigen
 
 #endif
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/EmulateCXX11Meta.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/EmulateCXX11Meta.h
index d685d4f9d..390612b64 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/EmulateCXX11Meta.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Core/util/EmulateCXX11Meta.h
@@ -12,7 +12,7 @@
 
 
 
-namespace Eigen {
+namespace StormEigen {
 
 namespace internal {
 
@@ -304,7 +304,7 @@ inline bool array_zip_and_reduce(const array& a, const array& b) {
 
 }  // end namespace internal
 
-}  // end namespace Eigen
+}  // end namespace StormEigen
 
 
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/README.md b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/README.md
index 407485090..e806b6e0c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/README.md
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/README.md
@@ -38,7 +38,7 @@ dimensions.
 
 Constructor where the sizes for the constructor are specified as an array of
 values instead of an explicitly list of parameters.  The array type to use is
-```Eigen::array<Eigen::Index>```.  The array can be constructed automatically
+```StormEigen::array<StormEigen::Index>```.  The array can be constructed automatically
 from an initializer list.
 
     // Create a tensor of strings of rank 2 with sizes 5, 7.
@@ -411,7 +411,7 @@ before the assignment of the result.  For technical C++ reasons this requires
 that the Tensor for the result be declared on its own.  This means that you
 have to know the size of the result.
 
-    Eigen::Tensor c(30, 40);
+    StormEigen::Tensor c(30, 40);
     c.device(...) = a + b;
 
 The call to ```device()``` must be the last call on the left of the operator=.
@@ -431,10 +431,10 @@ This is exactly the same as not inserting a ```device()``` call.
 #### Evaluating with a Thread Pool
 
     // Create the Eigen ThreadPoolDevice.
-    Eigen::ThreadPoolDevice my_device(4 /* number of threads to use */);
+    StormEigen::ThreadPoolDevice my_device(4 /* number of threads to use */);
 
     // Now just use the device when evaluating expressions.
-    Eigen::Tensor c(30, 50);
+    StormEigen::Tensor c(30, 50);
     c.device(my_device) = a.contract(b, dot_product_dims);
 
 
@@ -494,7 +494,7 @@ Tensor, TensorFixedSize, and TensorMap.
 Constant value indicating the number of dimensions of a Tensor.  This is also
 known as the tensor "rank".
 
-      Eigen::Tensor a(3, 4);
+      StormEigen::Tensor a(3, 4);
       cout << "Dims " << a.NumDimensions;
       => Dims 2
 
@@ -503,8 +503,8 @@ known as the tensor "rank".
 Returns an array-like object representing the dimensions of the tensor.
 The actual type of the dimensions() result is ::Dimensions.
 
-    Eigen::Tensor a(3, 4);
-    const Eigen::Tensor::Dimensions& d = a.dimensions();
+    StormEigen::Tensor a(3, 4);
+    const StormEigen::Tensor::Dimensions& d = a.dimensions();
     cout << "Dim size: " << d.size << ", dim 0: " << d[0]
          << ", dim 1: " << d[1];
     => Dim size: 2, dim 0: 3, dim 1: 4
@@ -522,7 +522,7 @@ Returns the n-th dimension of the tensor.  The actual type of the
 ```dimension()``` result is ```::Index```, but you can
 always use it like an int.
 
-      Eigen::Tensor a(3, 4);
+      StormEigen::Tensor a(3, 4);
       int dim1 = a.dimension(1);
       cout << "Dim 1: " << dim1;
       => Dim 1: 4
@@ -533,7 +533,7 @@ Returns the total number of elements in the tensor.  This is the product of all
 the tensor dimensions.  The actual type of the ```size()``` result is
 ```::Index```, but you can always use it like an int.
 
-    Eigen::Tensor a(3, 4);
+    StormEigen::Tensor a(3, 4);
     cout << "Size: " << a.size();
     => Size: 12
 
@@ -561,7 +561,7 @@ dimensionality while remaining agnostic to the underlying type.
 Creates a tensor of the specified size. The number of arguments must be equal
 to the rank of the tensor. The content of the tensor is not initialized.
 
-    Eigen::Tensor a(3, 4);
+    StormEigen::Tensor a(3, 4);
     cout << "NumRows: " << a.dimension(0) << " NumCols: " << a.dimension(1) << endl;
     => NumRows: 3 NumCols: 4
 
@@ -571,7 +571,7 @@ Creates a tensor of the specified size. The number of arguments in the Size<>
 template parameter determines the rank of the tensor. The content of the tensor
 is not initialized.
 
-    Eigen::TensorFixedSize> a;
+    StormEigen::TensorFixedSize> a;
     cout << "Rank: " << a.rank() << endl;
     => Rank: 2
     cout << "NumRows: " << a.dimension(0) << " NumCols: " << a.dimension(1) << endl;
@@ -584,7 +584,7 @@ until the TensorMap is discarded, and the size of the data must be large enough
 to accomodate of the coefficients of the tensor.
 
     float data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
-    Eigen::TensorMap a(data, 3, 4);
+    StormEigen::TensorMap a(data, 3, 4);
     cout << "NumRows: " << a.dimension(0) << " NumCols: " << a.dimension(1) << endl;
     => NumRows: 3 NumCols: 4
     cout << "a(1, 2): " << a(1, 2) << endl;
@@ -621,7 +621,7 @@ Returns the tensor itself in case you want to chain another call.
 Note that ```setConstant()``` can be used on any tensor where the element type
 has a copy constructor and an ```operator=()```:
 
-    Eigen::Tensor a(2, 3);
+    StormEigen::Tensor a(2, 3);
     a.setConstant("yolo");
     cout << "String tensor: " << endl << a << endl << endl;
     =>
@@ -659,7 +659,7 @@ contains 2 lists of 3 floats each.
 ```setValues()``` returns the tensor itself in case you want to chain another
 call.
 
-    Eigen::Tensor a(2, 3);
+    StormEigen::Tensor a(2, 3);
     a.setValues({{0.0f, 1.0f, 2.0f}, {3.0f, 4.0f, 5.0f}});
     cout << "a" << endl << a << endl << endl;
     =>
@@ -671,7 +671,7 @@ If a list is too short, the corresponding elements of the tensor will not be
 changed.  This is valid at each level of nesting.  For example the following
 code only sets the values of the first row of the tensor.
 
-    Eigen::Tensor a(2, 3);
+    StormEigen::Tensor a(2, 3);
     a.setConstant(1000);
     a.setValues({{10, 20, 30}});
     cout << "a" << endl << a << endl << endl;
@@ -713,14 +713,14 @@ See ```struct UniformRandomGenerator``` in TensorFunctors.h for an example.
       // Return a random value to be used.  "element_location" is the
       // location of the entry to set in the tensor, it can typically
       // be ignored.
-      Scalar operator()(Eigen::DenseIndex element_location,
-                        Eigen::DenseIndex /*unused*/ = 0) const {
+      Scalar operator()(StormEigen::DenseIndex element_location,
+                        StormEigen::DenseIndex /*unused*/ = 0) const {
         return ;
       }
 
       // Same as above but generates several numbers at a time.
       typename internal::packet_traits::type packetOp(
-          Eigen::DenseIndex packet_location, Eigen::DenseIndex /*unused*/ = 0) const {
+          StormEigen::DenseIndex packet_location, StormEigen::DenseIndex /*unused*/ = 0) const {
         return ;
       }
     };
@@ -758,7 +758,7 @@ Eigen Tensor code with other libraries.
 
 Scalar is the type of data stored in the tensor.
 
-    Eigen::Tensor a(3, 4);
+    StormEigen::Tensor a(3, 4);
     float* a_data = a.data();
     a_data[0] = 123.45f;
     cout << "a(0, 0): " << a(0, 0);
@@ -783,10 +783,10 @@ where all elements have the value ```val```.
 This is useful, for example, when you want to add or subtract a constant from a
 tensor, or multiply every element of a tensor by a scalar.
 
-    Eigen::Tensor a(2, 3);
+    StormEigen::Tensor a(2, 3);
     a.setConstant(1.0f);
-    Eigen::Tensor b = a + a.constant(2.0f);
-    Eigen::Tensor c = b * b.constant(0.2f);
+    StormEigen::Tensor b = a + a.constant(2.0f);
+    StormEigen::Tensor c = b * b.constant(0.2f);
     cout << "a" << endl << a << endl << endl;
     cout << "b" << endl << b << endl << endl;
     cout << "c" << endl << c << endl << endl;
@@ -812,9 +812,9 @@ This is for example useful to add random values to an existing tensor.
 The generation of random values can be customized in the same manner
 as for ```setRandom()```.
 
-    Eigen::Tensor a(2, 3);
+    StormEigen::Tensor a(2, 3);
     a.setConstant(1.0f);
-    Eigen::Tensor b = a + a.random();
+    StormEigen::Tensor b = a + a.random();
     cout << "a" << endl << a << endl << endl;
     cout << "b" << endl << b << endl << endl;
     =>
@@ -838,9 +838,9 @@ requested operations are applied to each element independently.
 Returns a tensor of the same type and dimensions as the original tensor
 containing the opposite values of the original tensor.
 
-    Eigen::Tensor a(2, 3);
+    StormEigen::Tensor a(2, 3);
     a.setConstant(1.0f);
-    Eigen::Tensor b = -a;
+    StormEigen::Tensor b = -a;
     cout << "a" << endl << a << endl << endl;
     cout << "b" << endl << b << endl << endl;
     =>
@@ -900,9 +900,9 @@ conjuntion with tensors of integer values.
 You can use cast() to lift this restriction.  For example this computes
 cubic roots of an int Tensor:
 
-    Eigen::Tensor a(2, 3);
+    StormEigen::Tensor a(2, 3);
     a.setValues({{0, 1, 8}, {27, 64, 125}});
-    Eigen::Tensor b = a.cast().pow(1.0 / 3.0);
+    StormEigen::Tensor b = a.cast().pow(1.0 / 3.0);
     cout << "a" << endl << a << endl << endl;
     cout << "b" << endl << b << endl << endl;
     =>
@@ -1010,18 +1010,18 @@ Tensor *contractions* are a generalization of the matrix product to the
 multidimensional case.
 
     // Create 2 matrices using tensors of rank 2
-    Eigen::Tensor a(2, 3);
+    StormEigen::Tensor a(2, 3);
     a.setValues({{1, 2, 3}, {6, 5, 4}});
-    Eigen::Tensor b(3, 2);
+    StormEigen::Tensor b(3, 2);
     a.setValues({{1, 2}, {4, 5}, {5, 6}});
 
     // Compute the traditional matrix product
     array, 1> product_dims = { IndexPair(1, 0) };
-    Eigen::Tensor AB = a.contract(b, product_dims);
+    StormEigen::Tensor AB = a.contract(b, product_dims);
 
     // Compute the product of the transpose of the matrices
     array, 1> transpose_product_dims = { IndexPair(0, 1) };
-    Eigen::Tensor AtBt = a.contract(b, transposed_product_dims);
+    StormEigen::Tensor AtBt = a.contract(b, transposed_product_dims);
 
 
 ## Reduction Operations
@@ -1055,14 +1055,14 @@ increasing order.
 Example: Reduction along one dimension.
 
     // Create a tensor of 2 dimensions
-    Eigen::Tensor a(2, 3);
+    StormEigen::Tensor a(2, 3);
     a.setValues({{1, 2, 3}, {6, 5, 4}});
     // Reduce it along the second dimension (1)...
-    Eigen::array dims({1 /* dimension to reduce */});
+    StormEigen::array dims({1 /* dimension to reduce */});
     // ...using the "maximum" operator.
     // The result is a tensor with one dimension.  The size of
     // that dimension is the same as the first (non-reduced) dimension of a.
-    Eigen::Tensor b = a.maximum(dims);
+    StormEigen::Tensor b = a.maximum(dims);
     cout << "a" << endl << a << endl << endl;
     cout << "b" << endl << b << endl << endl;
     =>
@@ -1076,7 +1076,7 @@ Example: Reduction along one dimension.
 
 Example: Reduction along two dimensions.
 
-    Eigen::Tensor a(2, 3, 4);
+    StormEigen::Tensor a(2, 3, 4);
     a.setValues({{{0.0f, 1.0f, 2.0f, 3.0f},
                   {7.0f, 6.0f, 5.0f, 4.0f},
                   {8.0f, 9.0f, 10.0f, 11.0f}},
@@ -1088,8 +1088,8 @@ Example: Reduction along two dimensions.
     // of size 4 (the last dimension of a.)
     // Note that we pass the array of reduction dimensions
     // directly to the maximum() call.
-    Eigen::Tensor b =
-        a.maximum(Eigen::array({0, 1}));
+    StormEigen::Tensor b =
+        a.maximum(StormEigen::array({0, 1}));
     cout << "b" << endl << b << endl << endl;
     =>
     b
@@ -1104,7 +1104,7 @@ As a special case, if you pass no parameter to a reduction operation the
 original tensor is reduced along *all* its dimensions.  The result is a
 one-dimension tensor with a single value.
 
-    Eigen::Tensor a(2, 3, 4);
+    StormEigen::Tensor a(2, 3, 4);
     a.setValues({{{0.0f, 1.0f, 2.0f, 3.0f},
                   {7.0f, 6.0f, 5.0f, 4.0f},
                   {8.0f, 9.0f, 10.0f, 11.0f}},
@@ -1112,7 +1112,7 @@ one-dimension tensor with a single value.
                   {19.0f, 18.0f, 17.0f, 16.0f},
                   {20.0f, 21.0f, 22.0f, 23.0f}}});
     // Reduce along all dimensions using the sum() operator.
-    Eigen::Tensor b = a.sum();
+    StormEigen::Tensor b = a.sum();
     cout << "b" << endl << b << endl << endl;
     =>
     b
@@ -1188,7 +1188,7 @@ for the last dimension).
     input.setRandom();
     kernel.setRandom();
 
-    Eigen::array dims({1, 2});  // Specify second and third dimension for convolution.
+    StormEigen::array dims({1, 2});  // Specify second and third dimension for convolution.
     output = input.convolve(kernel, dims);
 
     for (int i = 0; i < 3; ++i) {
@@ -1238,10 +1238,10 @@ contents of a reshaped Tensor depend on the data layout of the original Tensor.
 For example this is what happens when you ```reshape()``` a 2D ColMajor tensor
 to one dimension:
 
-    Eigen::Tensor a(2, 3);
+    StormEigen::Tensor a(2, 3);
     a.setValues({{0.0f, 100.0f, 200.0f}, {300.0f, 400.0f, 500.0f}});
-    Eigen::array one_dim({3 * 2});
-    Eigen::Tensor b = a.reshape(one_dim);
+    StormEigen::array one_dim({3 * 2});
+    StormEigen::Tensor b = a.reshape(one_dim);
     cout << "b" << endl << b << endl;
     =>
     b
@@ -1254,10 +1254,10 @@ to one dimension:
 
 This is what happens when the 2D Tensor is RowMajor:
 
-    Eigen::Tensor a(2, 3);
+    StormEigen::Tensor a(2, 3);
     a.setValues({{0.0f, 100.0f, 200.0f}, {300.0f, 400.0f, 500.0f}});
-    Eigen::array one_dim({3 * 2});
-    Eigen::Tensor b = a.reshape(one_dim);
+    StormEigen::array one_dim({3 * 2});
+    StormEigen::Tensor b = a.reshape(one_dim);
     cout << "b" << endl << b << endl;
     =>
     b
@@ -1273,10 +1273,10 @@ side of the assignment operator.
 
 The previous example can be rewritten as follow:
 
-    Eigen::Tensor a(2, 3);
+    StormEigen::Tensor a(2, 3);
     a.setValues({{0.0f, 100.0f, 200.0f}, {300.0f, 400.0f, 500.0f}});
-    Eigen::array two_dim({2, 3});
-    Eigen::Tensor b;
+    StormEigen::array two_dim({2, 3});
+    StormEigen::Tensor b;
     b.reshape(two_dim) = a;
     cout << "b" << endl << b << endl;
     =>
@@ -1342,10 +1342,10 @@ ceil(input_dimensions[i] / strides[i]).
 
 For example this is what happens when you ```stride()``` a 2D tensor:
 
-    Eigen::Tensor a(4, 3);
+    StormEigen::Tensor a(4, 3);
     a.setValues({{0, 100, 200}, {300, 400, 500}, {600, 700, 800}, {900, 1000, 1100}});
-    Eigen::array strides({3, 2});
-    Eigen::Tensor b = a.stride(strides);
+    StormEigen::array strides({3, 2});
+    StormEigen::Tensor b = a.stride(strides);
     cout << "b" << endl << b << endl;
     =>
     b
@@ -1365,12 +1365,12 @@ Returns a sub-tensor of the given tensor. For each dimension i, the slice is
 made of the coefficients stored between offset[i] and offset[i] + extents[i] in
 the input tensor.
 
-    Eigen::Tensor a(4, 3);
+    StormEigen::Tensor a(4, 3);
     a.setValues({{0, 100, 200}, {300, 400, 500},
                  {600, 700, 800}, {900, 1000, 1100}});
-    Eigen::array offsets = {1, 0};
-    Eigen::array extents = {2, 2};
-    Eigen::Tensor slice = a.slice(offsets, extents);
+    StormEigen::array offsets = {1, 0};
+    StormEigen::array extents = {2, 2};
+    StormEigen::Tensor slice = a.slice(offsets, extents);
     cout << "a" << endl << a << endl;
     =>
     a
@@ -1394,11 +1394,11 @@ tensor: the dimension dim is removed.
 For example, a matrix chip would be either a row or a column of the input
 matrix.
 
-    Eigen::Tensor a(4, 3);
+    StormEigen::Tensor a(4, 3);
     a.setValues({{0, 100, 200}, {300, 400, 500},
                  {600, 700, 800}, {900, 1000, 1100}});
-    Eigen::Tensor row_3 = a.chip(2, 0);
-    Eigen::Tensor col_2 = a.chip(1, 1);
+    StormEigen::Tensor row_3 = a.chip(2, 0);
+    StormEigen::Tensor col_2 = a.chip(1, 1);
     cout << "a" << endl << a << endl;
     =>
     a
@@ -1418,9 +1418,9 @@ matrix.
 It is possible to assign values to a tensor chip since the chip operation is a
 lvalue. For example:
 
-    Eigen::Tensor a(3);
+    StormEigen::Tensor a(3);
     a.setValues({{100, 200, 300}});
-    Eigen::Tensor b(2, 3);
+    StormEigen::Tensor b(2, 3);
     b.setZero();
     b.chip(0, 0) = a;
     cout << "a" << endl << a << endl;
@@ -1447,11 +1447,11 @@ of the input tensor.
 For example this is what happens when you ```reverse()``` the first dimension
 of a 2D tensor:
 
-    Eigen::Tensor a(4, 3);
+    StormEigen::Tensor a(4, 3);
     a.setValues({{0, 100, 200}, {300, 400, 500},
                 {600, 700, 800}, {900, 1000, 1100}});
-    Eigen::array reverse({true, false});
-    Eigen::Tensor b = a.reverse(reverse);
+    StormEigen::array reverse({true, false});
+    StormEigen::Tensor b = a.reverse(reverse);
     cout << "a" << endl << a << endl << "b" << endl << b << endl;
     =>
     a
@@ -1473,10 +1473,10 @@ times.
 The broadcast argument specifies how many copies of the input tensor need to be
 made in each of the dimensions.
 
-    Eigen::Tensor a(2, 3);
+    StormEigen::Tensor a(2, 3);
     a.setValues({{0, 100, 200}, {300, 400, 500}});
-    Eigen::array bcast({3, 2});
-    Eigen::Tensor b = a.broadcast(bcast);
+    StormEigen::array bcast({3, 2});
+    StormEigen::Tensor b = a.broadcast(bcast);
     cout << "a" << endl << a << endl << "b" << endl << b << endl;
     =>
     a
@@ -1498,12 +1498,12 @@ TODO
 
 Returns a view of the input tensor in which the input is padded with zeros.
 
-    Eigen::Tensor a(2, 3);
+    StormEigen::Tensor a(2, 3);
     a.setValues({{0, 100, 200}, {300, 400, 500}});
-    Eigen::array, 2> paddings;
+    StormEigen::array, 2> paddings;
     paddings[0] = make_pair(0, 1);
     paddings[1] = make_pair(2, 3);
-    Eigen::Tensor b = a.pad(paddings);
+    StormEigen::Tensor b = a.pad(paddings);
     cout << "a" << endl << a << endl << "b" << endl << b << endl;
     =>
     a
@@ -1530,7 +1530,7 @@ dimension in RowMajor layout.
 
 For example, given the following input tensor:
 
-  Eigen::Tensor tensor(3,4);
+  StormEigen::Tensor tensor(3,4);
   tensor.setValues({{0.0f, 1.0f, 2.0f, 3.0f},
                     {4.0f, 5.0f, 6.0f, 7.0f},
                     {8.0f, 9.0f, 10.0f, 11.0f}});
@@ -1544,8 +1544,8 @@ tensor:
 
 Six 2x2 patches can be extracted and indexed using the following code:
 
-  Eigen::Tensor patch;
-  Eigen::array patch_dims;
+  StormEigen::Tensor patch;
+  StormEigen::array patch_dims;
   patch_dims[0] = 2;
   patch_dims[1] = 2;
   patch = tensor.extract_patches(patch_dims);
@@ -1669,16 +1669,16 @@ Returns a tensor of type T with the same dimensions as the original tensor.
 The returned tensor contains the values of the original tensor converted to
 type T.
 
-    Eigen::Tensor a(2, 3);
-    Eigen::Tensor b = a.cast();
+    StormEigen::Tensor a(2, 3);
+    StormEigen::Tensor b = a.cast();
 
 This can be useful for example if you need to do element-wise division of
 Tensors of integers.  This is not currently supported by the Tensor library
 but you can easily cast the tensors to floats to do the division:
 
-    Eigen::Tensor a(2, 3);
+    StormEigen::Tensor a(2, 3);
     a.setValues({{0, 1, 2}, {3, 4, 5}});
-    Eigen::Tensor b =
+    StormEigen::Tensor b =
         (a.cast() / a.constant(2).cast()).cast();
     cout << "a" << endl << a << endl << endl;
     cout << "b" << endl << b << endl << endl;
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/Tensor.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/Tensor.h
index ad525bac8..0d81dcf8f 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/Tensor.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/Tensor.h
@@ -11,7 +11,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_H
 #define EIGEN_CXX11_TENSOR_TENSOR_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class Tensor
   * \ingroup CXX11_Tensor_Module
@@ -37,7 +37,7 @@ namespace Eigen {
   * You can access elements of tensors using normal subscripting:
   *
   * \code
-  * Eigen::Tensor t(10, 10, 10, 10);
+  * StormEigen::Tensor t(10, 10, 10, 10);
   * t(0, 1, 2, 3) = 42.0;
   * \endcode
   *
@@ -65,7 +65,7 @@ class Tensor : public TensorBase Self;
     typedef TensorBase > Base;
-    typedef typename Eigen::internal::nested::type Nested;
+    typedef typename StormEigen::internal::nested::type Nested;
     typedef typename internal::traits::StorageKind StorageKind;
     typedef typename internal::traits::Index Index;
     typedef Scalar_ Scalar;
@@ -524,6 +524,6 @@ class Tensor : public TensorBase > : public traits
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorIndexTupleOp& type;
 };
@@ -53,11 +53,11 @@ template
 class TensorIndexTupleOp : public TensorBase, ReadOnlyAccessors>
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::NumTraits::Real RealScalar;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
   typedef Tuple CoeffReturnType;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorIndexTupleOp(const XprType& expr)
@@ -139,7 +139,7 @@ struct traits > : public traits
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorTupleReducerOp& type;
 };
@@ -157,11 +157,11 @@ template
 class TensorTupleReducerOp : public TensorBase, ReadOnlyAccessors>
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::NumTraits::Real RealScalar;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
   typedef Index CoeffReturnType;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorTupleReducerOp(const XprType& expr,
@@ -279,6 +279,6 @@ struct TensorEvaluator, Devi
   Index m_stride_div;
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_ARG_MAX_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h
index a41d4d265..b3f6afd7d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_ASSIGN_H
 #define EIGEN_CXX11_TENSOR_TENSOR_ASSIGN_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorAssign
   * \ingroup CXX11_Tensor_Module
@@ -42,7 +42,7 @@ struct traits >
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorAssignOp& type;
 };
@@ -61,14 +61,14 @@ template
 class TensorAssignOp : public TensorBase >
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename LhsXprType::CoeffReturnType CoeffReturnType;
   typedef typename LhsXprType::PacketReturnType PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorAssignOp(LhsXprType& lhs, const RhsXprType& rhs)
       : m_lhs_xpr(lhs), m_rhs_xpr(rhs) {}
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h
index 392acf302..7f981db6a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h
@@ -12,7 +12,7 @@
 
 // clang-format off
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorBase
   * \ingroup CXX11_Tensor_Module
@@ -349,7 +349,7 @@ class TensorBase
     }
 
     // Contractions.
-    typedef Eigen::IndexPair DimensionPair;
+    typedef StormEigen::IndexPair DimensionPair;
 
     template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
     const TensorContractionOp
@@ -833,6 +833,6 @@ class TensorBase : public TensorBase(this); }
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_BASE_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorBroadcasting.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorBroadcasting.h
index dc64959e1..4b0de8b05 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorBroadcasting.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorBroadcasting.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_BROADCASTING_H
 #define EIGEN_CXX11_TENSOR_TENSOR_BROADCASTING_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorBroadcasting
   * \ingroup CXX11_Tensor_Module
@@ -35,7 +35,7 @@ struct traits > : public traits
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorBroadcastingOp& type;
 };
@@ -54,14 +54,14 @@ template
 class TensorBroadcastingOp : public TensorBase, ReadOnlyAccessors>
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename XprType::CoeffReturnType CoeffReturnType;
   typedef typename XprType::PacketReturnType PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBroadcastingOp(const XprType& expr, const Broadcast& broadcast)
       : m_xpr(expr), m_broadcast(broadcast) {}
@@ -340,6 +340,6 @@ struct TensorEvaluator, Device>
 };
 
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_BROADCASTING_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorChipping.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorChipping.h
index c9fa39e51..1c799e535 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorChipping.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorChipping.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_CHIPPING_H
 #define EIGEN_CXX11_TENSOR_TENSOR_CHIPPING_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorKChippingReshaping
   * \ingroup CXX11_Tensor_Module
@@ -36,7 +36,7 @@ struct traits > : public traits
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorChippingOp& type;
 };
@@ -79,14 +79,14 @@ template
 class TensorChippingOp : public TensorBase >
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename XprType::CoeffReturnType CoeffReturnType;
   typedef typename XprType::PacketReturnType PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorChippingOp(const XprType& expr, const Index offset, const Index dim)
       : m_xpr(expr), m_offset(offset), m_dim(dim) {
@@ -360,6 +360,6 @@ struct TensorEvaluator, Device>
 };
 
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_CHIPPING_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorConcatenation.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorConcatenation.h
index 3d153bb94..ac739c760 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorConcatenation.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorConcatenation.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_CONCATENATION_H
 #define EIGEN_CXX11_TENSOR_TENSOR_CONCATENATION_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorConcatenationOp
   * \ingroup CXX11_Tensor_Module
@@ -41,7 +41,7 @@ struct traits >
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorConcatenationOp& type;
 };
@@ -343,6 +343,6 @@ template >
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorContractionOp& type;
 };
@@ -427,15 +427,15 @@ template
 class TensorContractionOp : public TensorBase, ReadOnlyAccessors>
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
   typedef typename internal::promote_storage_type::ret CoeffReturnType;
   typedef typename internal::promote_storage_type::ret PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorContractionOp(
       const LhsXprType& lhs, const RhsXprType& rhs, const Indices& dims)
@@ -975,6 +975,6 @@ struct TensorEvaluator
@@ -1377,7 +1377,7 @@ struct TensorEvaluator
@@ -389,7 +389,7 @@ struct TensorEvaluator >
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorConversionOp& type;
 };
@@ -204,6 +204,6 @@ struct TensorEvaluator, Device>
     TensorEvaluator m_impl;
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_CONVERSION_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorConvolution.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorConvolution.h
index a82bfc0aa..491a2c127 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorConvolution.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorConvolution.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_CONVOLUTION_H
 #define EIGEN_CXX11_TENSOR_TENSOR_CONVOLUTION_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorConvolution
   * \ingroup CXX11_Tensor_Module
@@ -239,7 +239,7 @@ struct traits >
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorConvolutionOp& type;
 };
@@ -258,16 +258,16 @@ template
 class TensorConvolutionOp : public TensorBase >
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename internal::promote_storage_type::ret CoeffReturnType;
   typedef typename internal::promote_storage_type::ret PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorConvolutionOp(const InputXprType& input, const KernelXprType& kernel, const Indices& dims)
       : m_input_xpr(input), m_kernel_xpr(kernel), m_indices(dims) {}
@@ -1064,6 +1064,6 @@ struct TensorEvaluator >
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorCustomUnaryOp& type;
 };
@@ -55,7 +55,7 @@ class TensorCustomUnaryOp : public TensorBase::Scalar Scalar;
   typedef typename internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename XprType::CoeffReturnType CoeffReturnType;
   typedef typename XprType::PacketReturnType PacketReturnType;
   typedef typename internal::nested::type Nested;
@@ -184,7 +184,7 @@ struct traits >
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorCustomBinaryOp& type;
 };
@@ -205,7 +205,7 @@ class TensorCustomBinaryOp : public TensorBase::Scalar Scalar;
   typedef typename internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename internal::traits::CoeffReturnType CoeffReturnType;
   typedef typename internal::traits::PacketReturnType PacketReturnType;
   typedef typename internal::nested::type Nested;
@@ -305,6 +305,6 @@ struct TensorEvaluator class TensorDevice {
     ExpressionType& m_expression;
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_DEVICE_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceCuda.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceCuda.h
index c76d1ee3f..82b1e5f83 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceCuda.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceCuda.h
@@ -11,7 +11,7 @@
 #define EIGEN_CXX11_TENSOR_TENSOR_DEVICE_CUDA_H
 
 
-namespace Eigen {
+namespace StormEigen {
 
 // This defines an interface that GPUDevice can take to use
 // CUDA streams underneath.
@@ -253,6 +253,6 @@ static inline void setCudaSharedMemConfig(cudaSharedMemConfig config) {
 }
 #endif
 
-}  // end namespace Eigen
+}  // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_DEVICE_TYPE_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceDefault.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceDefault.h
index 267f6f8e3..072ce4753 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceDefault.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceDefault.h
@@ -11,7 +11,7 @@
 #define EIGEN_CXX11_TENSOR_TENSOR_DEVICE_DEFAULT_H
 
 
-namespace Eigen {
+namespace StormEigen {
 
 // Default device for the machine (typically a single cpu core)
 struct DefaultDevice {
@@ -56,6 +56,6 @@ struct DefaultDevice {
   }
 };
 
-}  // namespace Eigen
+}  // namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_DEVICE_DEFAULT_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h
index dcbef5b03..f2011990c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h
@@ -10,7 +10,7 @@
 #if defined(EIGEN_USE_THREADS) && !defined(EIGEN_CXX11_TENSOR_TENSOR_DEVICE_THREAD_POOL_H)
 #define EIGEN_CXX11_TENSOR_TENSOR_DEVICE_THREAD_POOL_H
 
-namespace Eigen {
+namespace StormEigen {
 
 // This defines an interface that ThreadPoolDevice can take to use
 // custom thread pools underneath.
@@ -219,6 +219,6 @@ struct ThreadPoolDevice {
 };
 
 
-}  // end namespace Eigen
+}  // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_DEVICE_THREAD_POOL_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDimensionList.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDimensionList.h
index ca9ac79df..6f4c2ca83 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDimensionList.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDimensionList.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_DIMENSION_LIST_H
 #define EIGEN_CXX11_TENSOR_TENSOR_DIMENSION_LIST_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \internal
   *
@@ -230,7 +230,7 @@ struct index_statically_lt_impl > {
 #endif
 
 }  // end namespace internal
-}  // end namespace Eigen
+}  // end namespace StormEigen
 
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_DIMENSION_LIST_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h
index f3c9a3148..a9096c0c7 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h
@@ -11,7 +11,7 @@
 #define EIGEN_CXX11_TENSOR_TENSOR_DIMENSIONS_H
 
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \internal
   *
@@ -431,6 +431,6 @@ bool dimensions_match(Dims1& dims1, Dims2& dims2) {
   return internal::sizes_match_below_dim::value, internal::array_size::value>::run(dims1, dims2);
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_DIMENSIONS_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorEvalTo.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorEvalTo.h
index ff4373f59..4ca769597 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorEvalTo.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorEvalTo.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_EVAL_TO_H
 #define EIGEN_CXX11_TENSOR_TENSOR_EVAL_TO_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorForcedEval
   * \ingroup CXX11_Tensor_Module
@@ -40,7 +40,7 @@ struct traits >
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorEvalToOp& type;
 };
@@ -60,14 +60,14 @@ template
 class TensorEvalToOp : public TensorBase >
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename internal::remove_const::type CoeffReturnType;
   typedef typename internal::remove_const::type PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvalToOp(CoeffReturnType* buffer, const XprType& expr)
       : m_xpr(expr), m_buffer(buffer) {}
@@ -149,6 +149,6 @@ struct TensorEvaluator, Device>
 };
 
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_EVAL_TO_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h
index 902f25247..69507b63a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_EVALUATOR_H
 #define EIGEN_CXX11_TENSOR_TENSOR_EVALUATOR_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorEvaluator
   * \ingroup CXX11_Tensor_Module
@@ -440,6 +440,6 @@ struct TensorEvaluator
 };
 
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_EVALUATOR_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h
index d93e1de1b..af115de06 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_EXECUTOR_H
 #define EIGEN_CXX11_TENSOR_TENSOR_EXECUTOR_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorExecutor
   * \ingroup CXX11_Tensor_Module
@@ -253,6 +253,6 @@ inline void TensorExecutor::run(const Expression& e
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_EXECUTOR_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorExpr.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorExpr.h
index 194c68929..efaac9eb8 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorExpr.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorExpr.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_EXPR_H
 #define EIGEN_CXX11_TENSOR_TENSOR_EXPR_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorExpr
   * \ingroup CXX11_Tensor_Module
@@ -53,14 +53,14 @@ template
 class TensorCwiseNullaryOp : public TensorBase, ReadOnlyAccessors>
 {
   public:
-    typedef typename Eigen::internal::traits::Scalar Scalar;
-    typedef typename Eigen::internal::traits::Packet Packet;
-    typedef typename Eigen::NumTraits::Real RealScalar;
+    typedef typename StormEigen::internal::traits::Scalar Scalar;
+    typedef typename StormEigen::internal::traits::Packet Packet;
+    typedef typename StormEigen::NumTraits::Real RealScalar;
     typedef typename XprType::CoeffReturnType CoeffReturnType;
     typedef typename XprType::PacketReturnType PacketReturnType;
     typedef TensorCwiseNullaryOp Nested;
-    typedef typename Eigen::internal::traits::StorageKind StorageKind;
-    typedef typename Eigen::internal::traits::Index Index;
+    typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+    typedef typename StormEigen::internal::traits::Index Index;
 
     EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorCwiseNullaryOp(const XprType& xpr, const NullaryOp& func = NullaryOp())
         : m_xpr(xpr), m_functor(func) {}
@@ -96,7 +96,7 @@ struct traits >
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorCwiseUnaryOp& type;
 };
@@ -117,14 +117,14 @@ class TensorCwiseUnaryOp : public TensorBase::Scalar Scalar;
-    typedef typename Eigen::internal::traits::Packet Packet;
-    typedef typename Eigen::NumTraits::Real RealScalar;
+    typedef typename StormEigen::internal::traits::Scalar Scalar;
+    typedef typename StormEigen::internal::traits::Packet Packet;
+    typedef typename StormEigen::NumTraits::Real RealScalar;
     typedef Scalar CoeffReturnType;
     typedef typename internal::packet_traits::type PacketReturnType;
-    typedef typename Eigen::internal::nested::type Nested;
-    typedef typename Eigen::internal::traits::StorageKind StorageKind;
-    typedef typename Eigen::internal::traits::Index Index;
+    typedef typename StormEigen::internal::nested::type Nested;
+    typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+    typedef typename StormEigen::internal::traits::Index Index;
 
     EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorCwiseUnaryOp(const XprType& xpr, const UnaryOp& func = UnaryOp())
       : m_xpr(xpr), m_functor(func) {}
@@ -175,7 +175,7 @@ struct traits >
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorCwiseBinaryOp& type;
 };
@@ -196,14 +196,14 @@ class TensorCwiseBinaryOp : public TensorBase::Scalar Scalar;
-    typedef typename Eigen::internal::traits::Packet Packet;
-    typedef typename Eigen::NumTraits::Real RealScalar;
+    typedef typename StormEigen::internal::traits::Scalar Scalar;
+    typedef typename StormEigen::internal::traits::Packet Packet;
+    typedef typename StormEigen::NumTraits::Real RealScalar;
     typedef Scalar CoeffReturnType;
     typedef typename internal::packet_traits::type PacketReturnType;
-    typedef typename Eigen::internal::nested::type Nested;
-    typedef typename Eigen::internal::traits::StorageKind StorageKind;
-    typedef typename Eigen::internal::traits::Index Index;
+    typedef typename StormEigen::internal::nested::type Nested;
+    typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+    typedef typename StormEigen::internal::traits::Index Index;
 
     EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorCwiseBinaryOp(const LhsXprType& lhs, const RhsXprType& rhs, const BinaryOp& func = BinaryOp())
         : m_lhs_xpr(lhs), m_rhs_xpr(rhs), m_functor(func) {}
@@ -247,7 +247,7 @@ struct traits >
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorSelectOp& type;
 };
@@ -265,16 +265,16 @@ template
 class TensorSelectOp : public TensorBase >
 {
   public:
-    typedef typename Eigen::internal::traits::Scalar Scalar;
-    typedef typename Eigen::internal::traits::Packet Packet;
-    typedef typename Eigen::NumTraits::Real RealScalar;
+    typedef typename StormEigen::internal::traits::Scalar Scalar;
+    typedef typename StormEigen::internal::traits::Packet Packet;
+    typedef typename StormEigen::NumTraits::Real RealScalar;
     typedef typename internal::promote_storage_type::ret CoeffReturnType;
     typedef typename internal::promote_storage_type::ret PacketReturnType;
-    typedef typename Eigen::internal::nested::type Nested;
-    typedef typename Eigen::internal::traits::StorageKind StorageKind;
-    typedef typename Eigen::internal::traits::Index Index;
+    typedef typename StormEigen::internal::nested::type Nested;
+    typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+    typedef typename StormEigen::internal::traits::Index Index;
 
     EIGEN_DEVICE_FUNC
     TensorSelectOp(const IfXprType& a_condition,
@@ -299,6 +299,6 @@ class TensorSelectOp : public TensorBase > : public traits
 };
 
 template 
-struct eval, Eigen::Dense> {
+struct eval, StormEigen::Dense> {
   typedef const TensorFFTOp& type;
 };
 
@@ -87,14 +87,14 @@ struct nested, 1, typenam
 template 
 class TensorFFTOp : public TensorBase, ReadOnlyAccessors> {
  public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename std::complex ComplexScalar;
   typedef typename internal::conditional::type OutputScalar;
   typedef OutputScalar CoeffReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorFFTOp(const XprType& expr, const FFT& fft)
       : m_xpr(expr), m_fft(fft) {}
@@ -120,7 +120,7 @@ struct TensorEvaluator, D
   static const int NumDims = internal::array_size::Dimensions>::value;
   typedef DSizes Dimensions;
   typedef typename XprType::Scalar Scalar;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename std::complex ComplexScalar;
   typedef typename TensorEvaluator::Dimensions InputDimensions;
   typedef internal::traits XprTraits;
@@ -590,7 +590,7 @@ struct TensorEvaluator, D
   };
 };
 
-}  // end namespace Eigen
+}  // end namespace StormEigen
 
 #endif  // __CUDACC__
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h
index a4d6ce6b3..0b5c7dc6e 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_FIXED_SIZE_H
 #define EIGEN_CXX11_TENSOR_TENSOR_FIXED_SIZE_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorFixedSize
   * \ingroup CXX11_Tensor_Module
@@ -18,9 +18,9 @@ namespace Eigen {
   * \brief The fixed sized version of the tensor class.
   *
   * The fixed sized equivalent of
-  * Eigen::Tensor t(3, 5, 7);
+  * StormEigen::Tensor t(3, 5, 7);
   * is
-  * Eigen::TensorFixedSize> t;
+  * StormEigen::TensorFixedSize> t;
   */
 
 template
@@ -29,7 +29,7 @@ class TensorFixedSize : public TensorBase Self;
     typedef TensorBase > Base;
-    typedef typename Eigen::internal::nested::type Nested;
+    typedef typename StormEigen::internal::nested::type Nested;
     typedef typename internal::traits::StorageKind StorageKind;
     typedef typename internal::traits::Index Index;
     typedef Scalar_ Scalar;
@@ -295,6 +295,6 @@ class TensorFixedSize : public TensorBase >
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorForcedEvalOp& type;
 };
@@ -59,14 +59,14 @@ template
 class TensorForcedEvalOp : public TensorBase >
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename internal::remove_const::type CoeffReturnType;
   typedef typename internal::remove_const::type PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorForcedEvalOp(const XprType& expr)
       : m_xpr(expr) {}
@@ -147,6 +147,6 @@ struct TensorEvaluator, Device>
 };
 
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_FORCED_EVAL_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorForwardDeclarations.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorForwardDeclarations.h
index a8bd8b888..0cb9347d5 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorForwardDeclarations.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorForwardDeclarations.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_FORWARD_DECLARATIONS_H
 #define EIGEN_CXX11_TENSOR_TENSOR_FORWARD_DECLARATIONS_H
 
-namespace Eigen {
+namespace StormEigen {
 
 template class Tensor;
 template class TensorFixedSize;
@@ -90,6 +90,6 @@ class TensorExecutor;
 
 }  // end namespace internal
 
-}  // end namespace Eigen
+}  // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_FORWARD_DECLARATIONS_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h
index 34ba4e392..183179efd 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_FUNCTORS_H
 #define EIGEN_CXX11_TENSOR_TENSOR_FUNCTORS_H
 
-namespace Eigen {
+namespace StormEigen {
 namespace internal {
 
 
@@ -742,6 +742,6 @@ class GaussianGenerator {
 
 
 } // end namespace internal
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_FUNCTORS_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorGenerator.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorGenerator.h
index 9316c9831..06f53fe6d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorGenerator.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorGenerator.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_GENERATOR_H
 #define EIGEN_CXX11_TENSOR_TENSOR_GENERATOR_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorGenerator
   * \ingroup CXX11_Tensor_Module
@@ -35,7 +35,7 @@ struct traits > : public traits
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorGeneratorOp& type;
 };
@@ -54,14 +54,14 @@ template
 class TensorGeneratorOp : public TensorBase, ReadOnlyAccessors>
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename XprType::CoeffReturnType CoeffReturnType;
   typedef typename XprType::PacketReturnType PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorGeneratorOp(const XprType& expr, const Generator& generator)
       : m_xpr(expr), m_generator(generator) {}
@@ -176,6 +176,6 @@ struct TensorEvaluator, Device>
   Generator m_generator;
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_GENERATOR_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorIO.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorIO.h
index 38a833f82..e2e1eca4e 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorIO.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorIO.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_IO_H
 #define EIGEN_CXX11_TENSOR_TENSOR_IO_H
 
-namespace Eigen {
+namespace StormEigen {
 
 namespace internal {
 template<>
@@ -40,7 +40,7 @@ std::ostream& operator << (std::ostream& os, const TensorBase > array(const_cast(tensor.data()), total_size);
     os << array;
   } else {
-    const Index first_dim = Eigen::internal::array_get<0>(tensor.dimensions());
+    const Index first_dim = StormEigen::internal::array_get<0>(tensor.dimensions());
     static const int layout = TensorEvaluator, DefaultDevice>::Layout;
     Map > matrix(const_cast(tensor.data()), first_dim, total_size/first_dim);
     os << matrix;
@@ -51,6 +51,6 @@ std::ostream& operator << (std::ostream& os, const TensorBase > : public traits
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorImagePatchOp& type;
 };
@@ -59,14 +59,14 @@ template
 class TensorImagePatchOp : public TensorBase, ReadOnlyAccessors>
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename XprType::CoeffReturnType CoeffReturnType;
   typedef typename XprType::PacketReturnType PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorImagePatchOp(const XprType& expr, DenseIndex patch_rows, DenseIndex patch_cols,
                                                            DenseIndex row_strides, DenseIndex col_strides,
@@ -549,6 +549,6 @@ struct TensorEvaluator, Device>
 };
 
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_IMAGE_PATCH_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorIndexList.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorIndexList.h
index 74ce6d0ec..20e7e3271 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorIndexList.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorIndexList.h
@@ -14,7 +14,7 @@
 
 #define EIGEN_HAS_INDEX_LIST
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \internal
   *
@@ -347,14 +347,14 @@ struct indices_statically_known_to_increase_impl {
 template 
   struct indices_statically_known_to_increase_impl > {
   static constexpr bool run() {
-    return Eigen::IndexList().values_statically_known_to_increase();
+    return StormEigen::IndexList().values_statically_known_to_increase();
   }
 };
 
 template 
   struct indices_statically_known_to_increase_impl > {
   static constexpr bool run() {
-    return Eigen::IndexList().values_statically_known_to_increase();
+    return StormEigen::IndexList().values_statically_known_to_increase();
   }
 };
 
@@ -456,11 +456,11 @@ struct index_statically_lt_impl > {
 };
 
 }  // end namespace internal
-}  // end namespace Eigen
+}  // end namespace StormEigen
 
 #else
 
-namespace Eigen {
+namespace StormEigen {
 namespace internal {
 
 template 
@@ -513,12 +513,12 @@ struct index_statically_lt_impl {
 };
 
 }  // end namespace internal
-}  // end namespace Eigen
+}  // end namespace StormEigen
 
 #endif
 
 
-namespace Eigen {
+namespace StormEigen {
 namespace internal {
 template 
 static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_known_statically(DenseIndex i) {
@@ -556,7 +556,7 @@ static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_statically_lt(DenseIndex i,
 }
 
 }  // end namespace internal
-}  // end namespace Eigen
+}  // end namespace StormEigen
 
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_INDEX_LIST_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorInflation.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorInflation.h
index ae9e9f751..6c920ad91 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorInflation.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorInflation.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_INFLATION_H
 #define EIGEN_CXX11_TENSOR_TENSOR_INFLATION_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorInflation
   * \ingroup CXX11_Tensor_Module
@@ -35,7 +35,7 @@ struct traits > : public traits
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorInflationOp& type;
 };
@@ -52,14 +52,14 @@ template
 class TensorInflationOp : public TensorBase, ReadOnlyAccessors>
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename XprType::CoeffReturnType CoeffReturnType;
   typedef typename XprType::PacketReturnType PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorInflationOp(const XprType& expr, const Strides& strides)
       : m_xpr(expr), m_strides(strides) {}
@@ -214,6 +214,6 @@ struct TensorEvaluator, Device>
   array, NumDims> m_fastStrides;
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_INFLATION_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorInitializer.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorInitializer.h
index ad2a1e6ac..f2e102118 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorInitializer.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorInitializer.h
@@ -14,7 +14,7 @@
 
 #include 
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorInitializer
   * \ingroup CXX11_Tensor_Module
@@ -29,7 +29,7 @@ struct Initializer {
     typename Initializer::InitList> InitList;
 
   static void run(TensorEvaluator& tensor,
-                  Eigen::array::Index, traits::NumDimensions>* indices,
+                  StormEigen::array::Index, traits::NumDimensions>* indices,
                   const InitList& vals) {
     int i = 0;
     for (auto v : vals) {
@@ -44,7 +44,7 @@ struct Initializer {
   typedef std::initializer_list::Scalar> InitList;
 
   static void run(TensorEvaluator& tensor,
-                  Eigen::array::Index, traits::NumDimensions>* indices,
+                  StormEigen::array::Index, traits::NumDimensions>* indices,
                   const InitList& vals) {
     int i = 0;
     // There is likely a faster way to do that than iterating.
@@ -60,7 +60,7 @@ struct Initializer {
   typedef typename traits::Scalar InitList;
 
   static void run(TensorEvaluator& tensor,
-                  Eigen::array::Index, traits::NumDimensions>*/* indices*/,
+                  StormEigen::array::Index, traits::NumDimensions>*/* indices*/,
                   const InitList& v) {
     tensor.coeffRef(0) = v;
   }
@@ -70,12 +70,12 @@ struct Initializer {
 template 
 void initialize_tensor(TensorEvaluator& tensor,
                        const typename Initializer::NumDimensions>::InitList& vals) {
-  Eigen::array::Index, traits::NumDimensions> indices;
+  StormEigen::array::Index, traits::NumDimensions> indices;
   Initializer::NumDimensions>::run(tensor, &indices, vals);
 }
 
 }  // namespace internal
-}  // namespace Eigen
+}  // namespace StormEigen
 
 #endif  // EIGEN_HAS_VARIADIC_TEMPLATES
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h
index b58173e58..1828b4932 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h
@@ -11,7 +11,7 @@
 #define EIGEN_CXX11_TENSOR_TENSOR_INTDIV_H
 
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \internal
   *
@@ -224,6 +224,6 @@ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T operator / (const T& numerator, c
 
 
 } // end namespace internal
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_INTDIV_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h
index f612bbd45..5388af501 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H
 #define EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorLayoutSwap
   * \ingroup CXX11_Tensor_Module
@@ -50,7 +50,7 @@ struct traits > : public traits
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorLayoutSwapOp& type;
 };
@@ -69,14 +69,14 @@ template
 class TensorLayoutSwapOp : public TensorBase, WriteAccessors>
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename internal::remove_const::type CoeffReturnType;
   typedef typename internal::remove_const::type PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorLayoutSwapOp(const XprType& expr)
       : m_xpr(expr) {}
@@ -202,6 +202,6 @@ template
   }
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorMap.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorMap.h
index 5c759af09..7fcdcad14 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorMap.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorMap.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_MAP_H
 #define EIGEN_CXX11_TENSOR_TENSOR_MAP_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorMap
   * \ingroup CXX11_Tensor_Module
@@ -24,7 +24,7 @@ template class TensorMap : public Tensor
   public:
     typedef TensorMap Self;
     typedef typename PlainObjectType::Base Base;
-    typedef typename Eigen::internal::nested::type Nested;
+    typedef typename StormEigen::internal::nested::type Nested;
     typedef typename internal::traits::StorageKind StorageKind;
     typedef typename internal::traits::Index Index;
     typedef typename internal::traits::Scalar Scalar;
@@ -310,6 +310,6 @@ template class TensorMap : public Tensor
     Dimensions m_dimensions;
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_MAP_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h
index 785321666..5f0bfb2c9 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_META_H
 #define EIGEN_CXX11_TENSOR_TENSOR_META_H
 
-namespace Eigen {
+namespace StormEigen {
 
 template struct Cond {};
 
@@ -143,6 +143,6 @@ namespace internal{
 
 
 
-}  // namespace Eigen
+}  // namespace StormEigen
 
 #endif  // EIGEN_CXX11_TENSOR_TENSOR_META_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
index bdc86e0fa..5d89ff308 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_MORPHING_H
 #define EIGEN_CXX11_TENSOR_TENSOR_MORPHING_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorReshaping
   * \ingroup CXX11_Tensor_Module
@@ -35,7 +35,7 @@ struct traits > : public traits
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorReshapingOp& type;
 };
@@ -54,14 +54,14 @@ template
 class TensorReshapingOp : public TensorBase, WriteAccessors>
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename internal::remove_const::type CoeffReturnType;
   typedef typename internal::remove_const::type PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorReshapingOp(const XprType& expr, const NewDimensions& dims)
       : m_xpr(expr), m_dims(dims) {}
@@ -216,7 +216,7 @@ struct traits > : public traits
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorSlicingOp& type;
 };
@@ -235,14 +235,14 @@ template
 class TensorSlicingOp : public TensorBase >
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename XprType::CoeffReturnType CoeffReturnType;
   typedef typename XprType::PacketReturnType PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorSlicingOp(const XprType& expr, const StartIndices& indices, const Sizes& sizes)
       : m_xpr(expr), m_indices(indices), m_sizes(sizes) {}
@@ -616,6 +616,6 @@ struct TensorEvaluator, Device>
 };
 
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_MORPHING_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorPadding.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorPadding.h
index 91e32d200..4d5669267 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorPadding.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorPadding.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_PADDING_H
 #define EIGEN_CXX11_TENSOR_TENSOR_PADDING_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorPadding
   * \ingroup CXX11_Tensor_Module
@@ -35,7 +35,7 @@ struct traits > : public traits
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorPaddingOp& type;
 };
@@ -54,14 +54,14 @@ template
 class TensorPaddingOp : public TensorBase, ReadOnlyAccessors>
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename XprType::CoeffReturnType CoeffReturnType;
   typedef typename XprType::PacketReturnType PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorPaddingOp(const XprType& expr, const PaddingDimensions& padding_dims)
       : m_xpr(expr), m_padding_dims(padding_dims) {}
@@ -365,6 +365,6 @@ struct TensorEvaluator, Device
 
 
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_PADDING_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorPatch.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorPatch.h
index 8fb53f4f2..097db26bc 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorPatch.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorPatch.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_PATCH_H
 #define EIGEN_CXX11_TENSOR_TENSOR_PATCH_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorPatch
   * \ingroup CXX11_Tensor_Module
@@ -35,7 +35,7 @@ struct traits > : public traits
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorPatchOp& type;
 };
@@ -54,14 +54,14 @@ template
 class TensorPatchOp : public TensorBase, ReadOnlyAccessors>
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename XprType::CoeffReturnType CoeffReturnType;
   typedef typename XprType::PacketReturnType PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorPatchOp(const XprType& expr, const PatchDim& patch_dims)
       : m_xpr(expr), m_patch_dims(patch_dims) {}
@@ -308,6 +308,6 @@ struct TensorEvaluator, Device>
   TensorEvaluator m_impl;
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_PATCH_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h
index bd15295b8..2b5817dd0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_REDUCTION_H
 #define EIGEN_CXX11_TENSOR_TENSOR_REDUCTION_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorReduction
   * \ingroup CXX11_Tensor_Module
@@ -32,7 +32,7 @@ struct traits >
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorReductionOp& type;
 };
@@ -348,14 +348,14 @@ __global__ void FullReductionKernel(R, const S, I, typename S::CoeffReturnType*)
 template 
 class TensorReductionOp : public TensorBase, ReadOnlyAccessors> {
   public:
-    typedef typename Eigen::internal::traits::Scalar Scalar;
-    typedef typename Eigen::internal::traits::Packet Packet;
-    typedef typename Eigen::NumTraits::Real RealScalar;
+    typedef typename StormEigen::internal::traits::Scalar Scalar;
+    typedef typename StormEigen::internal::traits::Packet Packet;
+    typedef typename StormEigen::NumTraits::Real RealScalar;
     typedef typename internal::remove_const::type CoeffReturnType;
     typedef typename internal::remove_const::type PacketReturnType;
-    typedef typename Eigen::internal::nested::type Nested;
-    typedef typename Eigen::internal::traits::StorageKind StorageKind;
-    typedef typename Eigen::internal::traits::Index Index;
+    typedef typename StormEigen::internal::nested::type Nested;
+    typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+    typedef typename StormEigen::internal::traits::Index Index;
 
     EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
     TensorReductionOp(const XprType& expr, const Dims& dims) : m_expr(expr), m_dims(dims)
@@ -647,7 +647,7 @@ struct TensorEvaluator, Device>
 
   // For full reductions
 #if defined(EIGEN_USE_GPU) && defined(__CUDACC__)
-  static const bool RunningOnGPU = internal::is_same::value;
+  static const bool RunningOnGPU = internal::is_same::value;
 #else
   static const bool RunningOnGPU = false;
 #endif
@@ -656,6 +656,6 @@ struct TensorEvaluator, Device>
   const Device& m_device;
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_REDUCTION_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorReductionCuda.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorReductionCuda.h
index 49102fca2..73e139f89 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorReductionCuda.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorReductionCuda.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_REDUCTION_H
 #define EIGEN_CXX11_TENSOR_TENSOR_REDUCTION_H
 
-namespace Eigen {
+namespace StormEigen {
 namespace internal {
 
 
@@ -135,6 +135,6 @@ struct FullReducer {
 
 
 } // end namespace internal
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_REDUCTION_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorRef.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorRef.h
index 6b25b2ba0..aa9bf826d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorRef.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorRef.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_REF_H
 #define EIGEN_CXX11_TENSOR_TENSOR_REF_H
 
-namespace Eigen {
+namespace StormEigen {
 
 namespace internal {
 
@@ -121,7 +121,7 @@ template class TensorRef : public TensorBase Self;
     typedef typename PlainObjectType::Base Base;
-    typedef typename Eigen::internal::nested::type Nested;
+    typedef typename StormEigen::internal::nested::type Nested;
     typedef typename internal::traits::StorageKind StorageKind;
     typedef typename internal::traits::Index Index;
     typedef typename internal::traits::Scalar Scalar;
@@ -424,6 +424,6 @@ struct TensorEvaluator, Device> : public TensorEvaluator
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorReverseOp& type;
 };
@@ -54,15 +54,15 @@ class TensorReverseOp : public TensorBase, WriteAccessors>
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename XprType::CoeffReturnType CoeffReturnType;
   typedef typename XprType::PacketReturnType PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind
                                                                     StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorReverseOp(
       const XprType& expr, const ReverseDimensions& reverse_dims)
@@ -272,6 +272,6 @@ struct TensorEvaluator, Device>
 };
 
 
-}  // end namespace Eigen
+}  // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_REVERSE_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h
index 15a22aa1b..0e7d4cc6c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_SHUFFLING_H
 #define EIGEN_CXX11_TENSOR_TENSOR_SHUFFLING_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorShuffling
   * \ingroup CXX11_Tensor_Module
@@ -35,7 +35,7 @@ struct traits > : public traits
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorShufflingOp& type;
 };
@@ -54,14 +54,14 @@ template
 class TensorShufflingOp : public TensorBase >
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename XprType::CoeffReturnType CoeffReturnType;
   typedef typename XprType::PacketReturnType PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorShufflingOp(const XprType& expr, const Shuffle& shuffle)
       : m_xpr(expr), m_shuffle(shuffle) {}
@@ -254,6 +254,6 @@ struct TensorEvaluator, Device>
 };
 
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_SHUFFLING_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h
index 98631fc7f..1d558a28d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h
@@ -17,7 +17,7 @@
   #define EIGEN_INTERNAL_TENSOR_STORAGE_CTOR_PLUGIN
 #endif
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \internal
   *
@@ -132,6 +132,6 @@ class TensorStorage, Options_>
   Dimensions m_dimensions;
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSORSTORAGE_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorStriding.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorStriding.h
index 97b6168a9..8d06cda5e 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorStriding.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorStriding.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_STRIDING_H
 #define EIGEN_CXX11_TENSOR_TENSOR_STRIDING_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorStriding
   * \ingroup CXX11_Tensor_Module
@@ -35,7 +35,7 @@ struct traits > : public traits
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorStridingOp& type;
 };
@@ -54,14 +54,14 @@ template
 class TensorStridingOp : public TensorBase >
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename XprType::CoeffReturnType CoeffReturnType;
   typedef typename XprType::PacketReturnType PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorStridingOp(const XprType& expr, const Strides& dims)
       : m_xpr(expr), m_dims(dims) {}
@@ -320,6 +320,6 @@ struct TensorEvaluator, Device>
 };
 
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_STRIDING_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h
index 7a9568b36..fa7df6ed6 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_TRAITS_H
 #define EIGEN_CXX11_TENSOR_TENSOR_TRAITS_H
 
-namespace Eigen {
+namespace StormEigen {
 namespace internal {
 
 
@@ -108,49 +108,49 @@ struct traits >
 
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const Tensor<_Scalar, NumIndices_, Options, IndexType_>& type;
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const Tensor<_Scalar, NumIndices_, Options, IndexType_>& type;
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorFixedSize& type;
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorFixedSize& type;
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorMap& type;
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorMap& type;
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorRef& type;
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorRef& type;
 };
@@ -256,6 +256,6 @@ typedef enum {
   PADDING_SAME = 2,
 } PaddingType;
 
-}  // end namespace Eigen
+}  // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_TRAITS_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h
index f5cca0ad7..dbdd9ef32 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_UINT128_H
 #define EIGEN_CXX11_TENSOR_TENSOR_UINT128_H
 
-namespace Eigen {
+namespace StormEigen {
 namespace internal {
 
 
@@ -227,7 +227,7 @@ static TensorUInt128 operator / (const TensorUInt128
 
 
 }  // namespace internal
-}  // namespace Eigen
+}  // namespace StormEigen
 
 
 #endif  // EIGEN_CXX11_TENSOR_TENSOR_UINT128_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorVolumePatch.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorVolumePatch.h
index 6625c66d5..327374f9d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorVolumePatch.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/Tensor/TensorVolumePatch.h
@@ -4,7 +4,7 @@
 #ifndef EIGEN_CXX11_TENSOR_TENSOR_VOLUME_PATCH_H
 #define EIGEN_CXX11_TENSOR_TENSOR_VOLUME_PATCH_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /** \class TensorVolumePatch
   * \ingroup CXX11_Tensor_Module
@@ -37,7 +37,7 @@ struct traits > : public traits
 };
 
 template
-struct eval, Eigen::Dense>
+struct eval, StormEigen::Dense>
 {
   typedef const TensorVolumePatchOp& type;
 };
@@ -54,14 +54,14 @@ template
 class TensorVolumePatchOp : public TensorBase, ReadOnlyAccessors>
 {
   public:
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  typedef typename Eigen::internal::traits::Packet Packet;
-  typedef typename Eigen::NumTraits::Real RealScalar;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  typedef typename StormEigen::internal::traits::Packet Packet;
+  typedef typename StormEigen::NumTraits::Real RealScalar;
   typedef typename XprType::CoeffReturnType CoeffReturnType;
   typedef typename XprType::PacketReturnType PacketReturnType;
-  typedef typename Eigen::internal::nested::type Nested;
-  typedef typename Eigen::internal::traits::StorageKind StorageKind;
-  typedef typename Eigen::internal::traits::Index Index;
+  typedef typename StormEigen::internal::nested::type Nested;
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind;
+  typedef typename StormEigen::internal::traits::Index Index;
 
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorVolumePatchOp(const XprType& expr, DenseIndex patch_planes, DenseIndex patch_rows, DenseIndex patch_cols,
                                                             DenseIndex plane_strides, DenseIndex row_strides, DenseIndex col_strides,
@@ -672,6 +672,6 @@ struct TensorEvaluator, D
 };
 
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSOR_TENSOR_VOLUME_PATCH_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/DynamicSymmetry.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/DynamicSymmetry.h
index bc4f2025f..2504f20d1 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/DynamicSymmetry.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/DynamicSymmetry.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSORSYMMETRY_DYNAMICSYMMETRY_H
 #define EIGEN_CXX11_TENSORSYMMETRY_DYNAMICSYMMETRY_H
 
-namespace Eigen {
+namespace StormEigen {
 
 class DynamicSGroup
 {
@@ -284,7 +284,7 @@ inline void DynamicSGroup::updateGlobalFlags(int flagDiffOfSameGenerator)
     }
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSORSYMMETRY_DYNAMICSYMMETRY_H
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/StaticSymmetry.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/StaticSymmetry.h
index 942293bd7..58d224929 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/StaticSymmetry.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/StaticSymmetry.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSORSYMMETRY_STATICSYMMETRY_H
 #define EIGEN_CXX11_TENSORSYMMETRY_STATICSYMMETRY_H
 
-namespace Eigen {
+namespace StormEigen {
 
 namespace internal {
 
@@ -227,7 +227,7 @@ class StaticSGroup
     }
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSORSYMMETRY_STATICSYMMETRY_H
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/Symmetry.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/Symmetry.h
index 879d6cd77..00036a488 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/Symmetry.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/Symmetry.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSORSYMMETRY_SYMMETRY_H
 #define EIGEN_CXX11_TENSORSYMMETRY_SYMMETRY_H
 
-namespace Eigen {
+namespace StormEigen {
 
 enum {
   NegationFlag           = 0x01,
@@ -329,7 +329,7 @@ class tensor_symmetry_value_setter
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSORSYMMETRY_SYMMETRY_H
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/util/TemplateGroupTheory.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/util/TemplateGroupTheory.h
index 0fe0b7c46..91b80af70 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/util/TemplateGroupTheory.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/CXX11/src/TensorSymmetry/util/TemplateGroupTheory.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_CXX11_TENSORSYMMETRY_TEMPLATEGROUPTHEORY_H
 #define EIGEN_CXX11_TENSORSYMMETRY_TEMPLATEGROUPTHEORY_H
 
-namespace Eigen {
+namespace StormEigen {
 
 namespace internal {
 
@@ -657,7 +657,7 @@ struct enumerate_group_elements
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CXX11_TENSORSYMMETRY_TEMPLATEGROUPTHEORY_H
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/FFT b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/FFT
index 2c45b3999..223307d53 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/FFT
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/FFT
@@ -72,7 +72,7 @@
 // FFTW: faster, GPL -- incompatible with Eigen in LGPL form, bigger code size
 #  include 
 #  include "src/FFT/ei_fftw_impl.h"
-   namespace Eigen {
+   namespace StormEigen {
      //template  typedef struct internal::fftw_impl  default_fft_impl; this does not work
      template  struct default_fft_impl : public internal::fftw_impl {};
    }
@@ -80,20 +80,20 @@
 // TODO 
 // intel Math Kernel Library: fastest, commercial -- may be incompatible with Eigen in GPL form
 #  include "src/FFT/ei_imklfft_impl.h"
-   namespace Eigen {
+   namespace StormEigen {
      template  struct default_fft_impl : public internal::imklfft_impl {};
    }
 #else
 // internal::kissfft_impl:  small, free, reasonably efficient default, derived from kissfft
 //
 # include "src/FFT/ei_kissfft_impl.h"
-  namespace Eigen {
+  namespace StormEigen {
      template  
        struct default_fft_impl : public internal::kissfft_impl {};
   }
 #endif
 
-namespace Eigen {
+namespace StormEigen {
 
  
 // 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/KroneckerProduct b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/KroneckerProduct
index c932c06a6..607273456 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/KroneckerProduct
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/KroneckerProduct
@@ -13,7 +13,7 @@
 
 #include "../../Eigen/src/Core/util/DisableStupidWarnings.h"
 
-namespace Eigen {
+namespace StormEigen {
 
 /**
   * \defgroup KroneckerProduct_Module KroneckerProduct module
@@ -25,7 +25,7 @@ namespace Eigen {
   * \endcode
   */
 
-} // namespace Eigen
+} // namespace StormEigen
 
 #include "src/KroneckerProduct/KroneckerTensorProduct.h"
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/MPRealSupport b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/MPRealSupport
index 89036886b..317a04224 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/MPRealSupport
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/MPRealSupport
@@ -15,7 +15,7 @@
 #include 
 #include 
 
-namespace Eigen {
+namespace StormEigen {
   
 /**
   * \defgroup MPRealSupport_Module MPFRC++ Support module
@@ -38,7 +38,7 @@ namespace Eigen {
 #include 
 #include 
 using namespace mpfr;
-using namespace Eigen;
+using namespace StormEigen;
 int main()
 {
   // set precision to 256 bits (double has only 53 bits)
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/MatrixFunctions b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/MatrixFunctions
index 0320606c1..34e82f796 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/MatrixFunctions
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/MatrixFunctions
@@ -279,7 +279,7 @@ against inaccurate result, e.g. \code
 
 int main()
 {
-  Eigen::Matrix4d A;
+  StormEigen::Matrix4d A;
   A << 0, 0, 2, 3,
        0, 0, 4, 5,
        0, 0, 6, 7,
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/MoreVectorization b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/MoreVectorization
index 470e72430..ff74affce 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/MoreVectorization
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/MoreVectorization
@@ -11,7 +11,7 @@
 
 #include 
 
-namespace Eigen {
+namespace StormEigen {
 
 /**
   * \defgroup MoreVectorization More vectorization module
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/NumericalDiff b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/NumericalDiff
index 433334ca8..a8b93ba7c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/NumericalDiff
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/NumericalDiff
@@ -12,7 +12,7 @@
 
 #include 
 
-namespace Eigen {
+namespace StormEigen {
 
 /**
   * \defgroup NumericalDiff_Module Numerical differentiation module
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/OpenGLSupport b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/OpenGLSupport
index 288c6b0fb..08498039f 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/OpenGLSupport
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/OpenGLSupport
@@ -18,7 +18,7 @@
   #include 
 #endif
 
-namespace Eigen {
+namespace StormEigen {
 
 /**
   * \defgroup OpenGLSUpport_Module OpenGL Support module
@@ -63,7 +63,7 @@ namespace internal {
   };                                                                                                                \
 }                                                                                                                   \
                                                                                                                     \
-template inline void FUNC(const Eigen::DenseBase& p) {                                   \
+template inline void FUNC(const StormEigen::DenseBase& p) {                                   \
   EIGEN_CAT(EIGEN_CAT(internal::gl_,FUNC),_impl)::run(p.derived());                                        \
 }
 
@@ -215,7 +215,7 @@ namespace internal {
   };                                                                                                                            \
 }                                                                                                                               \
                                                                                                                                 \
-template inline void FUNC(ARG1 a,EIGEN_GL_EVAL(EIGEN_GL_MAKE_CONST_##CONST) Eigen::DenseBase& p) {   \
+template inline void FUNC(ARG1 a,EIGEN_GL_EVAL(EIGEN_GL_MAKE_CONST_##CONST) StormEigen::DenseBase& p) {   \
   EIGEN_CAT(EIGEN_CAT(internal::gl_,FUNC),_impl)::run(a,p.derived());                                                  \
 }
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/Splines b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/Splines
index 322e6b9f5..9e18006ad 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/Splines
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/Splines
@@ -10,7 +10,7 @@
 #ifndef EIGEN_SPLINES_MODULE_H
 #define EIGEN_SPLINES_MODULE_H
 
-namespace Eigen 
+namespace StormEigen 
 {
 /**
   * \defgroup Splines_Module Spline and spline fitting module
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h
index 1a61e3367..8e10c39dd 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_AUTODIFF_JACOBIAN_H
 #define EIGEN_AUTODIFF_JACOBIAN_H
 
-namespace Eigen
+namespace StormEigen
 {
 
 template class AutoDiffJacobian : public Functor
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h
index e30ad5b6d..a22dcb9fc 100755
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_AUTODIFF_SCALAR_H
 #define EIGEN_AUTODIFF_SCALAR_H
 
-namespace Eigen {
+namespace StormEigen {
 
 namespace internal {
 
@@ -50,7 +50,7 @@ template struct auto_diff_special_op;
   *  - internal::abs, internal::sqrt, numext::pow, internal::exp, internal::log, internal::sin, internal::cos,
   *  - internal::conj, internal::real, internal::imag, numext::abs2.
   *
-  * AutoDiffScalar can be used as the scalar type of an Eigen::Matrix object. However,
+  * AutoDiffScalar can be used as the scalar type of an StormEigen::Matrix object. However,
   * in that case, the expression template mechanism only occurs at the top Matrix level,
   * while derivatives are computed right away.
   *
@@ -533,11 +533,11 @@ struct scalar_product_traits >
 
 #define EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(FUNC,CODE) \
   template \
-  inline const Eigen::AutoDiffScalar::type>::Scalar>, const typename Eigen::internal::remove_all::type> > \
-  FUNC(const Eigen::AutoDiffScalar& x) { \
-    using namespace Eigen; \
-    typedef typename Eigen::internal::traits::type>::Scalar Scalar; \
-    typedef AutoDiffScalar, const typename Eigen::internal::remove_all::type> > ReturnType; \
+  inline const StormEigen::AutoDiffScalar::type>::Scalar>, const typename Eigen::internal::remove_all::type> > \
+  FUNC(const StormEigen::AutoDiffScalar& x) { \
+    using namespace StormEigen; \
+    typedef typename StormEigen::internal::traits::type>::Scalar Scalar; \
+    typedef AutoDiffScalar, const typename StormEigen::internal::remove_all::type> > ReturnType; \
     CODE; \
   }
 
@@ -589,12 +589,12 @@ EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(log,
   return ReturnType(log(x.value()),x.derivatives() * (Scalar(1)/x.value()));)
 
 template
-inline const Eigen::AutoDiffScalar::Scalar>, const DerType> >
-pow(const Eigen::AutoDiffScalar& x, typename Eigen::internal::traits::Scalar y)
+inline const StormEigen::AutoDiffScalar::Scalar>, const DerType> >
+pow(const StormEigen::AutoDiffScalar& x, typename StormEigen::internal::traits::Scalar y)
 {
-  using namespace Eigen;
-  typedef typename Eigen::internal::traits::Scalar Scalar;
-  return AutoDiffScalar, const DerType> >(
+  using namespace StormEigen;
+  typedef typename StormEigen::internal::traits::Scalar Scalar;
+  return AutoDiffScalar, const DerType> >(
     std::pow(x.value(),y),
     x.derivatives() * (y * std::pow(x.value(),y-1)));
 }
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h
index 8c2d04830..c2a798768 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_AUTODIFF_VECTOR_H
 #define EIGEN_AUTODIFF_VECTOR_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /* \class AutoDiffScalar
   * \brief A scalar type replacement with automatic differentation capability
@@ -24,7 +24,7 @@ namespace Eigen {
   *  - internal::abs, internal::sqrt, numext::pow, internal::exp, internal::log, internal::sin, internal::cos,
   *  - internal::conj, internal::real, internal::imag, numext::abs2.
   *
-  * AutoDiffScalar can be used as the scalar type of an Eigen::Matrix object. However,
+  * AutoDiffScalar can be used as the scalar type of an StormEigen::Matrix object. However,
   * in that case, the expression template mechanism only occurs at the top Matrix level,
   * while derivatives are computed right away.
   *
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/BVH/BVAlgorithms.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/BVH/BVAlgorithms.h
index 994c8af54..9bebaa812 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/BVH/BVAlgorithms.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/BVH/BVAlgorithms.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_BVALGORITHMS_H
 #define EIGEN_BVALGORITHMS_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -288,6 +288,6 @@ typename Minimizer::Scalar BVMinimize(const BVH1 &tree1, const BVH2 &tree2, Mini
   return minimum;
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_BVALGORITHMS_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/BVH/KdBVH.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/BVH/KdBVH.h
index 1b8d75865..fda6bc1cf 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/BVH/KdBVH.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/BVH/KdBVH.h
@@ -10,7 +10,7 @@
 #ifndef KDBVH_H_INCLUDED
 #define KDBVH_H_INCLUDED
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -217,6 +217,6 @@ private:
   ObjectList objects;
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif //KDBVH_H_INCLUDED
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Eigenvalues/ArpackSelfAdjointEigenSolver.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Eigenvalues/ArpackSelfAdjointEigenSolver.h
index 3b6a69aff..02d336db2 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Eigenvalues/ArpackSelfAdjointEigenSolver.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Eigenvalues/ArpackSelfAdjointEigenSolver.h
@@ -27,7 +27,7 @@
 
 #include 
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
   template struct arpack_wrapper;
@@ -799,7 +799,7 @@ struct OP
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_ARPACKSELFADJOINTEIGENSOLVER_H
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/FFT/ei_fftw_impl.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/FFT/ei_fftw_impl.h
index d49aa17f5..1a8889a9b 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/FFT/ei_fftw_impl.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/FFT/ei_fftw_impl.h
@@ -7,7 +7,7 @@
 // Public License v. 2.0. If a copy of the MPL was not distributed
 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -256,6 +256,6 @@ namespace internal {
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 /* vim: set filetype=cpp et sw=2 ts=2 ai: */
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/FFT/ei_kissfft_impl.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/FFT/ei_kissfft_impl.h
index be51b4e6f..82e053d20 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/FFT/ei_kissfft_impl.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/FFT/ei_kissfft_impl.h
@@ -7,7 +7,7 @@
 // Public License v. 2.0. If a copy of the MPL was not distributed
 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -415,6 +415,6 @@ struct kissfft_impl
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 /* vim: set filetype=cpp et sw=2 ts=2 ai: */
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h
index 792a18425..43c1d9944 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h
@@ -35,7 +35,7 @@
 
 #include 
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -186,6 +186,6 @@ void constrained_cg(const TMatrix& A, const CMatrix& C, VectorX& x,
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_CONSTRAINEDCG_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/DGMRES.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/DGMRES.h
index bae04fc30..ae58509cb 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/DGMRES.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/DGMRES.h
@@ -12,7 +12,7 @@
 
 #include 
 
-namespace Eigen { 
+namespace StormEigen { 
   
 template< typename _MatrixType,
           typename _Preconditioner = DiagonalPreconditioner >
@@ -509,5 +509,5 @@ int DGMRES<_MatrixType, _Preconditioner>::dgmresApplyDeflation(const RhsType &x,
   return 0; 
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 #endif 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/GMRES.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/GMRES.h
index fbe21fc7e..e74c01d84 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/GMRES.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/GMRES.h
@@ -11,7 +11,7 @@
 #ifndef EIGEN_GMRES_H
 #define EIGEN_GMRES_H
 
-namespace Eigen {
+namespace StormEigen {
 
 namespace internal {
 
@@ -337,6 +337,6 @@ protected:
 
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_GMRES_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/IncompleteLU.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/IncompleteLU.h
index 7d08c3515..dcb647e24 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/IncompleteLU.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/IncompleteLU.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_INCOMPLETE_LU_H
 #define EIGEN_INCOMPLETE_LU_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 template 
 class IncompleteLU : public SparseSolverBase >
@@ -85,6 +85,6 @@ class IncompleteLU : public SparseSolverBase >
     FactorType m_lu;
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_INCOMPLETE_LU_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/IterationController.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/IterationController.h
index c9c1a4be2..d4cc6731d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/IterationController.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/IterationController.h
@@ -58,7 +58,7 @@
 #ifndef EIGEN_ITERATION_CONTROLLER_H
 #define EIGEN_ITERATION_CONTROLLER_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 /** \ingroup IterativeSolvers_Module
   * \class IterationController
@@ -149,6 +149,6 @@ class IterationController
 
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_ITERATION_CONTROLLER_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/MINRES.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/MINRES.h
index 256990c1a..91b575f6b 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/MINRES.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/MINRES.h
@@ -13,7 +13,7 @@
 #define EIGEN_MINRES_H_
 
 
-namespace Eigen {
+namespace StormEigen {
     
     namespace internal {
         
@@ -283,7 +283,7 @@ namespace Eigen {
         
     };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_MINRES_H
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/Scaling.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/Scaling.h
index d113e6e90..62233030c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/Scaling.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/IterativeSolvers/Scaling.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_ITERSCALING_H
 #define EIGEN_ITERSCALING_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /**
   * \ingroup IterativeSolvers_Module
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h
index 4d3e5358e..3f6041e30 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h
@@ -12,7 +12,7 @@
 #ifndef KRONECKER_TENSOR_PRODUCT_H
 #define KRONECKER_TENSOR_PRODUCT_H
 
-namespace Eigen {
+namespace StormEigen {
 
 /*!
  * \ingroup KroneckerProduct_Module
@@ -159,8 +159,8 @@ void KroneckerProductSparse::evalTo(Dest& dst) const
   const Rhs1 rhs1(m_B);
     
   // 2 - construct respective iterators
-  typedef Eigen::InnerIterator LhsInnerIterator;
-  typedef Eigen::InnerIterator RhsInnerIterator;
+  typedef StormEigen::InnerIterator LhsInnerIterator;
+  typedef StormEigen::InnerIterator RhsInnerIterator;
   
   // compute number of non-zeros per innervectors of dst
   {
@@ -300,6 +300,6 @@ KroneckerProductSparse kroneckerProduct(const EigenBase& a, const EigenB
   return KroneckerProductSparse(a.derived(), b.derived());
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // KRONECKER_TENSOR_PRODUCT_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMcovar.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMcovar.h
index b75bea25f..95479baa3 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMcovar.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMcovar.h
@@ -12,7 +12,7 @@
 #ifndef EIGEN_LMCOVAR_H
 #define EIGEN_LMCOVAR_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -79,6 +79,6 @@ void covar(
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_LMCOVAR_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMonestep.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMonestep.h
index 25b32ec5b..55063b338 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMonestep.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMonestep.h
@@ -14,7 +14,7 @@
 #ifndef EIGEN_LMONESTEP_H
 #define EIGEN_LMONESTEP_H
 
-namespace Eigen {
+namespace StormEigen {
 
 template
 LevenbergMarquardtSpace::Status
@@ -197,6 +197,6 @@ LevenbergMarquardt::minimizeOneStep(FVectorType  &x)
 }
 
   
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_LMONESTEP_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMpar.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMpar.h
index 9a4836547..086c35b4c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMpar.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMpar.h
@@ -12,7 +12,7 @@
 #ifndef EIGEN_LMPAR_H
 #define EIGEN_LMPAR_H
 
-namespace Eigen {
+namespace StormEigen {
 
 namespace internal {
   
@@ -155,6 +155,6 @@ namespace internal {
   }
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_LMPAR_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMqrsolv.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMqrsolv.h
index ae9d793b1..93bb21d9f 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMqrsolv.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LMqrsolv.h
@@ -15,7 +15,7 @@
 #ifndef EIGEN_LMQRSOLV_H
 #define EIGEN_LMQRSOLV_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -183,6 +183,6 @@ void lmqrsolv(
 }
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_LMQRSOLV_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LevenbergMarquardt.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LevenbergMarquardt.h
index b30e0a90a..1f03a00a6 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LevenbergMarquardt.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/LevenbergMarquardt/LevenbergMarquardt.h
@@ -20,7 +20,7 @@
 #define EIGEN_LEVENBERGMARQUARDT_H
 
 
-namespace Eigen {
+namespace StormEigen {
 namespace LevenbergMarquardtSpace {
     enum Status {
         NotStarted = -2,
@@ -391,6 +391,6 @@ LevenbergMarquardt::lmdif1(
     return info;
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_LEVENBERGMARQUARDT_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h
index 14a8aef58..ecc0e7187 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h
@@ -13,7 +13,7 @@
 
 #include "StemFunction.h"
 
-namespace Eigen {
+namespace StormEigen {
 namespace internal {
 
 /** \brief Scaling operator.
@@ -362,7 +362,7 @@ void matrix_exp_compute(const MatrixType& arg, ResultType &result)
     result *= result;   // undo scaling by repeated squaring
 }
 
-} // end namespace Eigen::internal
+} // end namespace StormEigen::internal
 
 /** \ingroup MatrixFunctions_Module
   *
@@ -418,6 +418,6 @@ const MatrixExponentialReturnValue MatrixBase::exp() const
   return MatrixExponentialReturnValue(derived());
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_MATRIX_EXPONENTIAL
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h
index 8f7a6f3b0..442082ef5 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h
@@ -13,7 +13,7 @@
 #include "StemFunction.h"
 
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -577,6 +577,6 @@ const MatrixFunctionReturnValue MatrixBase::cosh() const
   return MatrixFunctionReturnValue(derived(), internal::stem_function_cosh);
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_MATRIX_FUNCTION
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h
index 463d7be0c..0cd81ad3b 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h
@@ -15,7 +15,7 @@
 #define M_PI 3.141592653589793238462643383279503L
 #endif
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal { 
 
@@ -372,6 +372,6 @@ const MatrixLogarithmReturnValue MatrixBase::log() const
   return MatrixLogarithmReturnValue(derived());
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_MATRIX_LOGARITHM
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h
index 1e5a59c55..8bf91f4e3 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_MATRIX_POWER
 #define EIGEN_MATRIX_POWER
 
-namespace Eigen {
+namespace StormEigen {
 
 template class MatrixPower;
 
@@ -704,6 +704,6 @@ template
 const MatrixComplexPowerReturnValue MatrixBase::pow(const std::complex& p) const
 { return MatrixComplexPowerReturnValue(derived(), p); }
 
-} // namespace Eigen
+} // namespace StormEigen
 
 #endif // EIGEN_MATRIX_POWER
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixSquareRoot.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixSquareRoot.h
index 9f08c6162..cd3ddc501 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixSquareRoot.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/MatrixSquareRoot.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_MATRIX_SQUARE_ROOT
 #define EIGEN_MATRIX_SQUARE_ROOT
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -366,6 +366,6 @@ const MatrixSquareRootReturnValue MatrixBase::sqrt() const
   return MatrixSquareRootReturnValue(derived());
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_MATRIX_FUNCTION
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/StemFunction.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/StemFunction.h
index 7604df903..4afd7a138 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/StemFunction.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MatrixFunctions/StemFunction.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_STEM_FUNCTION
 #define EIGEN_STEM_FUNCTION
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -112,6 +112,6 @@ Scalar stem_function_sinh(Scalar x, int n)
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_STEM_FUNCTION
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MoreVectorization/MathFunctions.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MoreVectorization/MathFunctions.h
index 63cb28dea..fb11ee6e2 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MoreVectorization/MathFunctions.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/MoreVectorization/MathFunctions.h
@@ -11,7 +11,7 @@
 #ifndef EIGEN_MOREVECTORIZATION_MATHFUNCTIONS_H
 #define EIGEN_MOREVECTORIZATION_MATHFUNCTIONS_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -90,6 +90,6 @@ template<> EIGEN_DONT_INLINE Packet4f pasin(Packet4f x)
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_MOREVECTORIZATION_MATHFUNCTIONS_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h
index b8ba6ddcb..3e4ea89a1 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h
@@ -13,7 +13,7 @@
 #ifndef EIGEN_HYBRIDNONLINEARSOLVER_H
 #define EIGEN_HYBRIDNONLINEARSOLVER_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace HybridNonLinearSolverSpace { 
     enum Status {
@@ -594,7 +594,7 @@ HybridNonLinearSolver::solveNumericalDiff(FVectorType  &x)
     return status;
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_HYBRIDNONLINEARSOLVER_H
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h
index 69106ddc5..45939448b 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h
@@ -13,7 +13,7 @@
 #ifndef EIGEN_LEVENBERGMARQUARDT__H
 #define EIGEN_LEVENBERGMARQUARDT__H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace LevenbergMarquardtSpace {
     enum Status {
@@ -650,7 +650,7 @@ LevenbergMarquardt::lmdif1(
     return info;
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_LEVENBERGMARQUARDT__H
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/chkder.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/chkder.h
index db8ff7d6e..2a00dfbb0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/chkder.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/chkder.h
@@ -1,7 +1,7 @@
 #define chkder_log10e 0.43429448190325182765
 #define chkder_factor 100.
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -63,4 +63,4 @@ void chkder(
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/covar.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/covar.h
index 68260d191..d213f30ac 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/covar.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/covar.h
@@ -1,4 +1,4 @@
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -67,4 +67,4 @@ void covar(
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/dogleg.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/dogleg.h
index 80c5d277b..e9a9cb698 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/dogleg.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/dogleg.h
@@ -1,4 +1,4 @@
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -104,4 +104,4 @@ algo_end:
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h
index bb7cf267b..99eadc695 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h
@@ -1,4 +1,4 @@
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -76,4 +76,4 @@ DenseIndex fdjac1(
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/lmpar.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/lmpar.h
index 4c17d4cdf..beb51c4b8 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/lmpar.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/lmpar.h
@@ -1,4 +1,4 @@
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -295,4 +295,4 @@ void lmpar2(
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h
index feafd62a8..766307c7f 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h
@@ -1,4 +1,4 @@
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -88,4 +88,4 @@ void qrsolv(
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h
index 36ff700e9..637490127 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h
@@ -1,4 +1,4 @@
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal {
 
@@ -27,4 +27,4 @@ void r1mpyq(DenseIndex m, DenseIndex n, Scalar *a, const std::vector::balance()
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_COMPANION_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Polynomials/PolynomialSolver.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Polynomials/PolynomialSolver.h
index 03198ec8e..571fb22ef 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Polynomials/PolynomialSolver.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Polynomials/PolynomialSolver.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_POLYNOMIAL_SOLVER_H
 #define EIGEN_POLYNOMIAL_SOLVER_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 /** \ingroup Polynomials_Module
  *  \class PolynomialSolverBase.
@@ -401,6 +401,6 @@ class PolynomialSolver<_Scalar,1> : public PolynomialSolverBase<_Scalar,1>
     using                   PS_Base::m_roots;
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_POLYNOMIAL_SOLVER_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Polynomials/PolynomialUtils.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Polynomials/PolynomialUtils.h
index 40ba65b7e..b05d022c1 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Polynomials/PolynomialUtils.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Polynomials/PolynomialUtils.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_POLYNOMIAL_UTILS_H
 #define EIGEN_POLYNOMIAL_UTILS_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 /** \ingroup Polynomials_Module
  * \returns the evaluation of the polynomial at x using Horner algorithm.
@@ -138,6 +138,6 @@ void roots_to_monicPolynomial( const RootVector& rv, Polynomial& poly )
   }
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_POLYNOMIAL_UTILS_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h
index a1f54ed35..5f3fe26b1 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_SKYLINEINPLACELU_H
 #define EIGEN_SKYLINEINPLACELU_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 /** \ingroup Skyline_Module
  *
@@ -35,7 +35,7 @@ public:
      * flags \a flags. */
     SkylineInplaceLU(MatrixType& matrix, int flags = 0)
     : /*m_matrix(matrix.rows(), matrix.cols()),*/ m_flags(flags), m_status(0), m_lu(matrix) {
-        m_precision = RealScalar(0.1) * Eigen::dummy_precision ();
+        m_precision = RealScalar(0.1) * StormEigen::dummy_precision ();
         m_lu.IsRowMajor ? computeRowMajor() : compute();
     }
 
@@ -347,6 +347,6 @@ bool SkylineInplaceLU::solve(const MatrixBase &b, MatrixBa
     return true;
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_SKYLINELU_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineMatrix.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineMatrix.h
index a2a8933ca..b8ab4254b 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineMatrix.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineMatrix.h
@@ -13,7 +13,7 @@
 #include "SkylineStorage.h"
 #include "SkylineMatrixBase.h"
 
-namespace Eigen { 
+namespace StormEigen { 
 
 /** \ingroup Skyline_Module
  *
@@ -857,6 +857,6 @@ protected:
     const Index m_end;
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_SkylineMatrix_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h
index b3a237230..502bf8688 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h
@@ -12,7 +12,7 @@
 
 #include "SkylineUtil.h"
 
-namespace Eigen { 
+namespace StormEigen { 
 
 /** \ingroup Skyline_Module
  *
@@ -207,6 +207,6 @@ protected:
     bool m_isRValue;
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_SkylineMatrixBase_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineProduct.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineProduct.h
index d9eb814c1..70d0ab9a9 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineProduct.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineProduct.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_SKYLINEPRODUCT_H
 #define EIGEN_SKYLINEPRODUCT_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 template
 struct SkylineProductReturnType {
@@ -290,6 +290,6 @@ SkylineMatrixBase::operator*(const MatrixBase &other) con
     return typename SkylineProductReturnType::Type(derived(), other.derived());
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_SKYLINEPRODUCT_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineStorage.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineStorage.h
index 378a8deb4..587c31ec7 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineStorage.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineStorage.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_SKYLINE_STORAGE_H
 #define EIGEN_SKYLINE_STORAGE_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 /** Stores a skyline set of values in three structures :
  * The diagonal elements
@@ -254,6 +254,6 @@ public:
 
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_COMPRESSED_STORAGE_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineUtil.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineUtil.h
index 75eb612f4..df3282608 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineUtil.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Skyline/SkylineUtil.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_SKYLINEUTIL_H
 #define EIGEN_SKYLINEUTIL_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 #ifdef NDEBUG
 #define EIGEN_DBG_SKYLINE(X)
@@ -26,7 +26,7 @@ enum {IsSkyline = SkylineBit};
 
 #define EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
 template \
-EIGEN_STRONG_INLINE Derived& operator Op(const Eigen::SkylineMatrixBase& other) \
+EIGEN_STRONG_INLINE Derived& operator Op(const StormEigen::SkylineMatrixBase& other) \
 { \
   return Base::operator Op(other.derived()); \
 } \
@@ -51,14 +51,14 @@ EIGEN_STRONG_INLINE Derived& operator Op(const Other& scalar) \
 
 #define _EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived, BaseClass) \
   typedef BaseClass Base; \
-  typedef typename Eigen::internal::traits::Scalar Scalar; \
-  typedef typename Eigen::NumTraits::Real RealScalar; \
-  typedef typename Eigen::internal::traits::StorageKind StorageKind; \
-  typedef typename Eigen::internal::index::type Index; \
-  enum {  Flags = Eigen::internal::traits::Flags, };
+  typedef typename StormEigen::internal::traits::Scalar Scalar; \
+  typedef typename StormEigen::NumTraits::Real RealScalar; \
+  typedef typename StormEigen::internal::traits::StorageKind StorageKind; \
+  typedef typename StormEigen::internal::index::type Index; \
+  enum {  Flags = StormEigen::internal::traits::Flags, };
 
 #define EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived) \
-  _EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::SkylineMatrixBase)
+  _EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived, StormEigen::SkylineMatrixBase)
 
 template class SkylineMatrixBase;
 template class SkylineMatrix;
@@ -84,6 +84,6 @@ template class eval
 
 } // end namespace internal
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_SKYLINEUTIL_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/BlockOfDynamicSparseMatrix.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/BlockOfDynamicSparseMatrix.h
index e9ec746e3..c7b759e88 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/BlockOfDynamicSparseMatrix.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/BlockOfDynamicSparseMatrix.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_SPARSE_BLOCKFORDYNAMICMATRIX_H
 #define EIGEN_SPARSE_BLOCKFORDYNAMICMATRIX_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 #if 0
 
@@ -117,6 +117,6 @@ class SparseInnerVectorSet, Size>
 
 #endif
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_SPARSE_BLOCKFORDYNAMICMATRIX_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/BlockSparseMatrix.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/BlockSparseMatrix.h
index 0e8350a7d..e91425a5e 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/BlockSparseMatrix.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/BlockSparseMatrix.h
@@ -11,7 +11,7 @@
 #ifndef EIGEN_SPARSEBLOCKMATRIX_H
 #define EIGEN_SPARSEBLOCKMATRIX_H
 
-namespace Eigen { 
+namespace StormEigen { 
 /** \ingroup SparseCore_Module
   *
   * \class BlockSparseMatrix
@@ -1074,6 +1074,6 @@ class BlockSparseMatrix<_Scalar, _BlockAtCompileTime, _Options, _StorageIndex>::
     Index m_end; // starting inner index of the next block
 
 };
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_SPARSEBLOCKMATRIX_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/DynamicSparseMatrix.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/DynamicSparseMatrix.h
index e6ec9051b..a7bb05c1d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/DynamicSparseMatrix.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/DynamicSparseMatrix.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_DYNAMIC_SPARSEMATRIX_H
 #define EIGEN_DYNAMIC_SPARSEMATRIX_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 /** \deprecated use a SparseMatrix in an uncompressed mode
   *
@@ -387,6 +387,6 @@ struct evaluator >
 
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_DYNAMIC_SPARSEMATRIX_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/MarketIO.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/MarketIO.h
index cdc14f86e..c844d507a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/MarketIO.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/MarketIO.h
@@ -13,7 +13,7 @@
 
 #include 
 
-namespace Eigen { 
+namespace StormEigen { 
 
 namespace internal 
 {
@@ -269,6 +269,6 @@ bool saveMarketVector (const VectorType& vec, const std::string& filename)
   return true; 
 }
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_SPARSE_MARKET_IO_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/MatrixMarketIterator.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/MatrixMarketIterator.h
index 02916ea6f..1de897fd4 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/MatrixMarketIterator.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/MatrixMarketIterator.h
@@ -11,7 +11,7 @@
 #ifndef EIGEN_BROWSE_MATRICES_H
 #define EIGEN_BROWSE_MATRICES_H
 
-namespace Eigen {
+namespace StormEigen {
 
 enum {
   SPD = 0x100,
@@ -242,6 +242,6 @@ class MatrixMarketIterator
     
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/RandomSetter.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/RandomSetter.h
index eb3e17330..60cede841 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/RandomSetter.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/SparseExtra/RandomSetter.h
@@ -10,7 +10,7 @@
 #ifndef EIGEN_RANDOMSETTER_H
 #define EIGEN_RANDOMSETTER_H
 
-namespace Eigen { 
+namespace StormEigen { 
 
 /** Represents a std::map
   *
@@ -322,6 +322,6 @@ class RandomSetter
     unsigned char m_keyBitsOffset;
 };
 
-} // end namespace Eigen
+} // end namespace StormEigen
 
 #endif // EIGEN_RANDOMSETTER_H
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Splines/Spline.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Splines/Spline.h
index d1636f466..0d921d7a2 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Splines/Spline.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Splines/Spline.h
@@ -12,7 +12,7 @@
 
 #include "SplineFwd.h"
 
-namespace Eigen
+namespace StormEigen
 {
     /**
      * \ingroup Splines_Module
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Splines/SplineFitting.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Splines/SplineFitting.h
index d3c245fa9..5a79c1414 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Splines/SplineFitting.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Splines/SplineFitting.h
@@ -20,7 +20,7 @@
 #include 
 #include 
 
-namespace Eigen
+namespace StormEigen
 {
   /**
    * \brief Computes knot averages.
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Splines/SplineFwd.h b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Splines/SplineFwd.h
index 0a95fbf3e..7f7f94d5c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Splines/SplineFwd.h
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/Eigen/src/Splines/SplineFwd.h
@@ -12,7 +12,7 @@
 
 #include 
 
-namespace Eigen
+namespace StormEigen
 {
     template  class Spline;
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/bench/bench_svd.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/bench/bench_svd.cpp
index 01d8231ae..9ed345564 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/bench/bench_svd.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/bench/bench_svd.cpp
@@ -17,7 +17,7 @@
 #include 
 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 // number of computations of each algorithm before the print of the time
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/Overview.dox b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/Overview.dox
index 45464a545..cc8cc9886 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/Overview.dox
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/Overview.dox
@@ -1,5 +1,5 @@
 /// \brief Namespace containing all symbols from the %Eigen library.
-namespace Eigen {
+namespace StormEigen {
 
 /** \mainpage %Eigen's unsupported modules
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/BVH_Example.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/BVH_Example.cpp
index 6b6fac075..7df9a995c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/BVH_Example.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/BVH_Example.cpp
@@ -2,10 +2,10 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 typedef AlignedBox Box2d;
 
-namespace Eigen {
+namespace StormEigen {
     namespace internal {
         Box2d bounding_box(const Vector2d &v) { return Box2d(v, v); } //compute the bounding box of a single point
     }
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/FFT.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/FFT.cpp
index fcbf81276..6832f6728 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/FFT.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/FFT.cpp
@@ -17,7 +17,7 @@
 #include 
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 template 
 T mag2(T a)
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixExponential.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixExponential.cpp
index ebd3b9675..42af994f2 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixExponential.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixExponential.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixFunction.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixFunction.cpp
index a4172e4ae..e1dd3987e 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixFunction.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixFunction.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 std::complex expfn(std::complex x, int)
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixLogarithm.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixLogarithm.cpp
index 8c5d97054..f9fb47753 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixLogarithm.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixLogarithm.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixPower.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixPower.cpp
index 222452476..d0dd8f03b 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixPower.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixPower.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixPower_optimal.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixPower_optimal.cpp
index 86470ba0a..bc9858716 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixPower_optimal.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixPower_optimal.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixSine.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixSine.cpp
index 9eea9a081..f408969ba 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixSine.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixSine.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixSinh.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixSinh.cpp
index f77186724..4332bf0c4 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixSinh.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixSinh.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixSquareRoot.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixSquareRoot.cpp
index 88e7557d7..dc7df9e49 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixSquareRoot.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/MatrixSquareRoot.cpp
@@ -1,7 +1,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 
 int main()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/PolynomialSolver1.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/PolynomialSolver1.cpp
index cd777a4e2..109d9b2be 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/PolynomialSolver1.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/PolynomialSolver1.cpp
@@ -2,7 +2,7 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main()
@@ -11,7 +11,7 @@ int main()
 
   Vector5d roots = Vector5d::Random();
   cout << "Roots: " << roots.transpose() << endl;
-  Eigen::Matrix polynomial;
+  StormEigen::Matrix polynomial;
   roots_to_monicPolynomial( roots, polynomial );
 
   PolynomialSolver psolve( polynomial );
@@ -25,13 +25,13 @@ int main()
   cout << endl;
   cout << "Illustration of the convergence problem with the QR algorithm: " << endl;
   cout << "---------------------------------------------------------------" << endl;
-  Eigen::Matrix hardCase_polynomial;
+  StormEigen::Matrix hardCase_polynomial;
   hardCase_polynomial <<
   -0.957, 0.9219, 0.3516, 0.9453, -0.4023, -0.5508, -0.03125;
   cout << "Hard case polynomial defined by floats: " << hardCase_polynomial.transpose() << endl;
   PolynomialSolver psolvef( hardCase_polynomial );
   cout << "Complex roots: " << psolvef.roots().transpose() << endl;
-  Eigen::Matrix evals;
+  StormEigen::Matrix evals;
   for( int i=0; i<6; ++i ){ evals[i] = std::abs( poly_eval( hardCase_polynomial, psolvef.roots()[i] ) ); }
   cout << "Norms of the evaluations of the polynomial at the roots: " << evals.transpose() << endl << endl;
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/PolynomialUtils1.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/PolynomialUtils1.cpp
index dbfe520b5..d9f050bad 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/PolynomialUtils1.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/doc/examples/PolynomialUtils1.cpp
@@ -1,14 +1,14 @@
 #include 
 #include 
 
-using namespace Eigen;
+using namespace StormEigen;
 using namespace std;
 
 int main()
 {
   Vector4d roots = Vector4d::Random();
   cout << "Roots: " << roots.transpose() << endl;
-  Eigen::Matrix polynomial;
+  StormEigen::Matrix polynomial;
   roots_to_monicPolynomial( roots, polynomial );
   cout << "Polynomial: ";
   for( int i=0; i<4; ++i ){ cout << polynomial[i] << ".x^" << i << "+ "; }
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/BVH.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/BVH.cpp
index ff5b3299d..3e420c05e 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/BVH.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/BVH.cpp
@@ -12,7 +12,7 @@
 #include 
 #include 
 
-namespace Eigen {
+namespace StormEigen {
 
 template AlignedBox bounding_box(const Matrix &v) { return AlignedBox(v); }
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/FFTW.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/FFTW.cpp
index d3718e2d2..bb2e791ed 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/FFTW.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/FFTW.cpp
@@ -14,7 +14,7 @@ template 
 std::complex RandomCpx() { return std::complex( (T)(rand()/(T)RAND_MAX - .5), (T)(rand()/(T)RAND_MAX - .5) ); }
 
 using namespace std;
-using namespace Eigen;
+using namespace StormEigen;
 
 
 template < typename T>
@@ -181,21 +181,21 @@ void test_complex(int nfft)
 template 
 void test_complex2d()
 {
-    typedef typename Eigen::FFT::Complex Complex;
+    typedef typename StormEigen::FFT::Complex Complex;
     FFT fft;
-    Eigen::Matrix src,src2,dst,dst2;
+    StormEigen::Matrix src,src2,dst,dst2;
 
-    src = Eigen::Matrix::Random();
-    //src =  Eigen::Matrix::Identity();
+    src = StormEigen::Matrix::Random();
+    //src =  StormEigen::Matrix::Identity();
 
     for (int k=0;k tmpOut;
+        StormEigen::Matrix tmpOut;
         fft.fwd( tmpOut,src.col(k) );
         dst2.col(k) = tmpOut;
     }
 
     for (int k=0;k tmpOut;
+        StormEigen::Matrix tmpOut;
         fft.fwd( tmpOut,  dst2.row(k) );
         dst2.row(k) = tmpOut;
     }
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/alignedvector3.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/alignedvector3.cpp
index 252cb1d3f..15357f350 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/alignedvector3.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/alignedvector3.cpp
@@ -10,7 +10,7 @@
 #include "main.h"
 #include 
 
-namespace Eigen {
+namespace StormEigen {
 
 template
 T test_relative_error(const AlignedVector3 &a, const MatrixBase &b)
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/autodiff.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/autodiff.cpp
index 1aa1b3d2d..7bb3b10b0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/autodiff.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/autodiff.cpp
@@ -170,9 +170,9 @@ template 
 void test_autodiff_hessian()
 {
   typedef AutoDiffScalar AD;
-  typedef Matrix VectorAD;
+  typedef Matrix VectorAD;
   typedef AutoDiffScalar ADD;
-  typedef Matrix VectorADD;
+  typedef Matrix VectorADD;
   VectorADD x(2);
   double s1 = internal::random(), s2 = internal::random(), s3 = internal::random(), s4 = internal::random();
   x(0).value()=s1;
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_meta.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_meta.cpp
index 4f45e1dd3..9b66d67af 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_meta.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_meta.cpp
@@ -11,40 +11,40 @@
 
 #include 
 
-using Eigen::internal::is_same;
-using Eigen::internal::type_list;
-using Eigen::internal::numeric_list;
-using Eigen::internal::gen_numeric_list;
-using Eigen::internal::gen_numeric_list_reversed;
-using Eigen::internal::gen_numeric_list_swapped_pair;
-using Eigen::internal::gen_numeric_list_repeated;
-using Eigen::internal::concat;
-using Eigen::internal::mconcat;
-using Eigen::internal::take;
-using Eigen::internal::skip;
-using Eigen::internal::slice;
-using Eigen::internal::get;
-using Eigen::internal::id_numeric;
-using Eigen::internal::id_type;
-using Eigen::internal::is_same_gf;
-using Eigen::internal::apply_op_from_left;
-using Eigen::internal::apply_op_from_right;
-using Eigen::internal::contained_in_list;
-using Eigen::internal::contained_in_list_gf;
-using Eigen::internal::arg_prod;
-using Eigen::internal::arg_sum;
-using Eigen::internal::sum_op;
-using Eigen::internal::product_op;
-using Eigen::internal::array_reverse;
-using Eigen::internal::array_sum;
-using Eigen::internal::array_prod;
-using Eigen::internal::array_reduce;
-using Eigen::internal::array_zip;
-using Eigen::internal::array_zip_and_reduce;
-using Eigen::internal::array_apply;
-using Eigen::internal::array_apply_and_reduce;
-using Eigen::internal::repeat;
-using Eigen::internal::instantiate_by_c_array;
+using StormEigen::internal::is_same;
+using StormEigen::internal::type_list;
+using StormEigen::internal::numeric_list;
+using StormEigen::internal::gen_numeric_list;
+using StormEigen::internal::gen_numeric_list_reversed;
+using StormEigen::internal::gen_numeric_list_swapped_pair;
+using StormEigen::internal::gen_numeric_list_repeated;
+using StormEigen::internal::concat;
+using StormEigen::internal::mconcat;
+using StormEigen::internal::take;
+using StormEigen::internal::skip;
+using StormEigen::internal::slice;
+using StormEigen::internal::get;
+using StormEigen::internal::id_numeric;
+using StormEigen::internal::id_type;
+using StormEigen::internal::is_same_gf;
+using StormEigen::internal::apply_op_from_left;
+using StormEigen::internal::apply_op_from_right;
+using StormEigen::internal::contained_in_list;
+using StormEigen::internal::contained_in_list_gf;
+using StormEigen::internal::arg_prod;
+using StormEigen::internal::arg_sum;
+using StormEigen::internal::sum_op;
+using StormEigen::internal::product_op;
+using StormEigen::internal::array_reverse;
+using StormEigen::internal::array_sum;
+using StormEigen::internal::array_prod;
+using StormEigen::internal::array_reduce;
+using StormEigen::internal::array_zip;
+using StormEigen::internal::array_zip_and_reduce;
+using StormEigen::internal::array_apply;
+using StormEigen::internal::array_apply_and_reduce;
+using StormEigen::internal::repeat;
+using StormEigen::internal::instantiate_by_c_array;
 
 struct dummy_a {};
 struct dummy_b {};
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_argmax.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_argmax.cpp
index 482dfa7de..f3445e99d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_argmax.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_argmax.cpp
@@ -12,9 +12,9 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::array;
-using Eigen::Tuple;
+using StormEigen::Tensor;
+using StormEigen::array;
+using StormEigen::Tuple;
 
 template 
 static void test_simple_index_tuples()
@@ -44,7 +44,7 @@ static void test_index_tuples_dim()
 
   index_tuples = tensor.index_tuples();
 
-  for (Eigen::DenseIndex n = 0; n < tensor.size(); ++n) {
+  for (StormEigen::DenseIndex n = 0; n < tensor.size(); ++n) {
     const Tuple& v = index_tuples(n); //(i, j, k, l);
     VERIFY_IS_EQUAL(v.first, n);
     VERIFY_IS_EQUAL(v.second, tensor(n));
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_argmax_cuda.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_argmax_cuda.cpp
index d37490d15..db089cea8 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_argmax_cuda.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_argmax_cuda.cpp
@@ -15,14 +15,14 @@
 #include "main.h"
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 template 
 void test_cuda_simple_argmax()
 {
-  Tensor in(Eigen::array(72,53,97));
-  Tensor out_max(Eigen::array(1));
-  Tensor out_min(Eigen::array(1));
+  Tensor in(StormEigen::array(72,53,97));
+  Tensor out_max(StormEigen::array(1));
+  Tensor out_min(StormEigen::array(1));
   in.setRandom();
   in *= in.constant(100.0);
   in(0, 0, 0) = -1000.0;
@@ -40,12 +40,12 @@ void test_cuda_simple_argmax()
 
   cudaMemcpy(d_in, in.data(), in_bytes, cudaMemcpyHostToDevice);
 
-  Eigen::CudaStreamDevice stream;
-  Eigen::GpuDevice gpu_device(&stream);
+  StormEigen::CudaStreamDevice stream;
+  StormEigen::GpuDevice gpu_device(&stream);
 
-  Eigen::TensorMap, Aligned > gpu_in(d_in, Eigen::array(72,53,97));
-  Eigen::TensorMap, Aligned > gpu_out_max(d_out_max, Eigen::array(1));
-  Eigen::TensorMap, Aligned > gpu_out_min(d_out_min, Eigen::array(1));
+  StormEigen::TensorMap, Aligned > gpu_in(d_in, Eigen::array(72,53,97));
+  StormEigen::TensorMap, Aligned > gpu_out_max(d_out_max, Eigen::array(1));
+  StormEigen::TensorMap, Aligned > gpu_out_min(d_out_min, Eigen::array(1));
 
   gpu_out_max.device(gpu_device) = gpu_in.argmax();
   gpu_out_min.device(gpu_device) = gpu_in.argmin();
@@ -54,8 +54,8 @@ void test_cuda_simple_argmax()
   assert(cudaMemcpyAsync(out_min.data(), d_out_min, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess);
   assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess);
 
-  VERIFY_IS_EQUAL(out_max(Eigen::array(0)), 72*53*97 - 1);
-  VERIFY_IS_EQUAL(out_min(Eigen::array(0)), 0);
+  VERIFY_IS_EQUAL(out_max(StormEigen::array(0)), 72*53*97 - 1);
+  VERIFY_IS_EQUAL(out_min(StormEigen::array(0)), 0);
 }
 
 template 
@@ -98,11 +98,11 @@ void test_cuda_argmax_dim()
 
     cudaMemcpy(d_in, tensor.data(), in_bytes, cudaMemcpyHostToDevice);
 
-    Eigen::CudaStreamDevice stream;
-    Eigen::GpuDevice gpu_device(&stream);
+    StormEigen::CudaStreamDevice stream;
+    StormEigen::GpuDevice gpu_device(&stream);
 
-    Eigen::TensorMap, Aligned > gpu_in(d_in, Eigen::array(2, 3, 5, 7));
-    Eigen::TensorMap, Aligned > gpu_out(d_out, out_shape);
+    StormEigen::TensorMap, Aligned > gpu_in(d_in, Eigen::array(2, 3, 5, 7));
+    StormEigen::TensorMap, Aligned > gpu_out(d_out, out_shape);
 
     gpu_out.device(gpu_device) = gpu_in.argmax(dim);
 
@@ -184,11 +184,11 @@ void test_cuda_argmin_dim()
 
     cudaMemcpy(d_in, tensor.data(), in_bytes, cudaMemcpyHostToDevice);
 
-    Eigen::CudaStreamDevice stream;
-    Eigen::GpuDevice gpu_device(&stream);
+    StormEigen::CudaStreamDevice stream;
+    StormEigen::GpuDevice gpu_device(&stream);
 
-    Eigen::TensorMap, Aligned > gpu_in(d_in, Eigen::array(2, 3, 5, 7));
-    Eigen::TensorMap, Aligned > gpu_out(d_out, out_shape);
+    StormEigen::TensorMap, Aligned > gpu_in(d_in, Eigen::array(2, 3, 5, 7));
+    StormEigen::TensorMap, Aligned > gpu_out(d_out, out_shape);
 
     gpu_out.device(gpu_device) = gpu_in.argmin(dim);
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_assign.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_assign.cpp
index e5cf61fe1..2e8bc6112 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_assign.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_assign.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::RowMajor;
+using StormEigen::Tensor;
+using StormEigen::RowMajor;
 
 static void test_1d()
 {
@@ -327,7 +327,7 @@ static void test_std_initializers_tensor() {
   VERIFY_IS_EQUAL(b(1, 1), 4);
   VERIFY_IS_EQUAL(b(1, 2), 5);
 
-  Eigen::Tensor c(3, 2, 4);
+  StormEigen::Tensor c(3, 2, 4);
   c.setValues({{{0, 1, 2, 3}, {4, 5, 6, 7}},
                {{10, 11, 12, 13}, {14, 15, 16, 17}},
                {{20, 21, 22, 23}, {24, 25, 26, 27}}});
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_broadcasting.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_broadcasting.cpp
index 2ddf47234..857babe5e 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_broadcasting.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_broadcasting.cpp
@@ -11,7 +11,7 @@
 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 template 
 static void test_simple_broadcasting()
@@ -116,9 +116,9 @@ static void test_static_broadcasting()
   tensor.setRandom();
 
 #ifdef EIGEN_HAS_CONSTEXPR
-  Eigen::IndexList, Eigen::type2index<3>, Eigen::type2index<4>> broadcasts;
+  StormEigen::IndexList, Eigen::type2index<3>, Eigen::type2index<4>> broadcasts;
 #else
-  Eigen::array broadcasts;
+  StormEigen::array broadcasts;
   broadcasts[0] = 2;
   broadcasts[1] = 3;
   broadcasts[2] = 4;
@@ -167,13 +167,13 @@ static void test_fixed_size_broadcasting()
   TensorFixedSize, DataLayout> t2;
   t2 = t2.constant(20.0f);
 
-  Tensor t3 = t1 + t2.broadcast(Eigen::array{{10}});
+  Tensor t3 = t1 + t2.broadcast(StormEigen::array{{10}});
   for (int i = 0; i < 10; ++i) {
     VERIFY_IS_APPROX(t3(i), t1(i) + t2(0));
   }
 
   TensorMap, DataLayout> > t4(t2.data(), {{1}});
-  Tensor t5 = t1 + t4.broadcast(Eigen::array{{10}});
+  Tensor t5 = t1 + t4.broadcast(StormEigen::array{{10}});
   for (int i = 0; i < 10; ++i) {
     VERIFY_IS_APPROX(t5(i), t1(i) + t2(0));
   }
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_casts.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_casts.cpp
index 3c6d0d2ff..c86dc3685 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_casts.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_casts.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::array;
+using StormEigen::Tensor;
+using StormEigen::array;
 
 static void test_simple_cast()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_chipping.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_chipping.cpp
index 1832dec8b..2196873c9 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_chipping.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_chipping.cpp
@@ -11,7 +11,7 @@
 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 template
 static void test_simple_chip()
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_comparisons.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_comparisons.cpp
index b1ff8aecb..871217571 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_comparisons.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_comparisons.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::RowMajor;
+using StormEigen::Tensor;
+using StormEigen::RowMajor;
 
 static void test_orderings()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_concatenation.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_concatenation.cpp
index 03ef12e63..ecc9733be 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_concatenation.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_concatenation.cpp
@@ -11,7 +11,7 @@
 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 template
 static void test_dimension_failures()
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_const.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_const.cpp
index ad9c9da39..aadcc1beb 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_const.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_const.cpp
@@ -10,7 +10,7 @@
 #include "main.h"
 
 #include 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 
 static void test_simple_assign()
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_contract_cuda.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_contract_cuda.cpp
index 035a093e6..e98301db1 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_contract_cuda.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_contract_cuda.cpp
@@ -18,7 +18,7 @@
 #include "main.h"
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 typedef Tensor::DimensionPair DimPair;
 
 template
@@ -28,11 +28,11 @@ static void test_cuda_contraction(int m_size, int k_size, int n_size)
   // with these dimensions, the output has 300 * 140 elements, which is
   // more than 30 * 1024, which is the number of threads in blocks on
   // a 15 SM GK110 GPU
-  Tensor t_left(Eigen::array(m_size, k_size));
-  Tensor t_right(Eigen::array(k_size, n_size));
-  Tensor t_result(Eigen::array(m_size, n_size));
-  Tensor t_result_gpu(Eigen::array(m_size, n_size));
-  Eigen::array dims(DimPair(1, 0));
+  Tensor t_left(StormEigen::array(m_size, k_size));
+  Tensor t_right(StormEigen::array(k_size, n_size));
+  Tensor t_result(StormEigen::array(m_size, n_size));
+  Tensor t_result_gpu(StormEigen::array(m_size, n_size));
+  StormEigen::array dims(DimPair(1, 0));
 
   t_left.setRandom();
   t_right.setRandom();
@@ -52,15 +52,15 @@ static void test_cuda_contraction(int m_size, int k_size, int n_size)
   cudaMemcpy(d_t_left, t_left.data(), t_left_bytes, cudaMemcpyHostToDevice);
   cudaMemcpy(d_t_right, t_right.data(), t_right_bytes, cudaMemcpyHostToDevice);
 
-  Eigen::CudaStreamDevice stream;
-  Eigen::GpuDevice gpu_device(&stream);
+  StormEigen::CudaStreamDevice stream;
+  StormEigen::GpuDevice gpu_device(&stream);
 
-  Eigen::TensorMap >
-      gpu_t_left(d_t_left, Eigen::array(m_size, k_size));
-  Eigen::TensorMap >
-      gpu_t_right(d_t_right, Eigen::array(k_size, n_size));
-  Eigen::TensorMap >
-      gpu_t_result(d_t_result, Eigen::array(m_size, n_size));
+  StormEigen::TensorMap >
+      gpu_t_left(d_t_left, StormEigen::array(m_size, k_size));
+  StormEigen::TensorMap >
+      gpu_t_right(d_t_right, StormEigen::array(k_size, n_size));
+  StormEigen::TensorMap >
+      gpu_t_result(d_t_result, StormEigen::array(m_size, n_size));
 
 
   gpu_t_result.device(gpu_device) = gpu_t_left.contract(gpu_t_right, dims);
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_contraction.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_contraction.cpp
index b0d52c6cf..c669239a0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_contraction.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_contraction.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::DefaultDevice;
-using Eigen::Tensor;
+using StormEigen::DefaultDevice;
+using StormEigen::Tensor;
 
 typedef Tensor::DimensionPair DimPair;
 
@@ -29,7 +29,7 @@ static void test_evals()
 
   Tensor mat4(3,3);
   mat4.setZero();
-  Eigen::array dims3({{DimPair(0, 0)}});
+  StormEigen::array dims3({{DimPair(0, 0)}});
   typedef TensorEvaluator Evaluator;
   Evaluator eval(mat1.contract(mat2, dims3), DefaultDevice());
   eval.evalTo(mat4.data());
@@ -49,7 +49,7 @@ static void test_evals()
 
   Tensor mat5(2,2);
   mat5.setZero();
-  Eigen::array dims4({{DimPair(1, 1)}});
+  StormEigen::array dims4({{DimPair(1, 1)}});
   typedef TensorEvaluator Evaluator2;
   Evaluator2 eval2(mat1.contract(mat2, dims4), DefaultDevice());
   eval2.evalTo(mat5.data());
@@ -64,7 +64,7 @@ static void test_evals()
 
   Tensor mat6(2,2);
   mat6.setZero();
-  Eigen::array dims6({{DimPair(1, 0)}});
+  StormEigen::array dims6({{DimPair(1, 0)}});
   typedef TensorEvaluator Evaluator3;
   Evaluator3 eval3(mat1.contract(mat3, dims6), DefaultDevice());
   eval3.evalTo(mat6.data());
@@ -89,7 +89,7 @@ static void test_scalar()
 
   Tensor scalar(1);
   scalar.setZero();
-  Eigen::array dims({{DimPair(0, 0)}});
+  StormEigen::array dims({{DimPair(0, 0)}});
   typedef TensorEvaluator Evaluator;
   Evaluator eval(vec1.contract(vec2, dims), DefaultDevice());
   eval.evalTo(scalar.data());
@@ -113,7 +113,7 @@ static void test_multidims()
 
   Tensor mat3(2, 2, 2);
   mat3.setZero();
-  Eigen::array dims({{DimPair(1, 2), DimPair(2, 3)}});
+  StormEigen::array dims({{DimPair(1, 2), DimPair(2, 3)}});
   typedef TensorEvaluator Evaluator;
   Evaluator eval(mat1.contract(mat2, dims), DefaultDevice());
   eval.evalTo(mat3.data());
@@ -147,7 +147,7 @@ static void test_holes() {
   t1.setRandom();
   t2.setRandom();
 
-  Eigen::array dims({{DimPair(0, 0), DimPair(3, 4)}});
+  StormEigen::array dims({{DimPair(0, 0), DimPair(3, 4)}});
   Tensor result = t1.contract(t2, dims);
   VERIFY_IS_EQUAL(result.dimension(0), 5);
   VERIFY_IS_EQUAL(result.dimension(1), 7);
@@ -182,7 +182,7 @@ static void test_full_redux()
   t1.setRandom();
   t2.setRandom();
 
-  Eigen::array dims({{DimPair(0, 0), DimPair(1, 1)}});
+  StormEigen::array dims({{DimPair(0, 0), DimPair(1, 1)}});
   Tensor result = t1.contract(t2, dims);
   VERIFY_IS_EQUAL(result.dimension(0), 2);
   VERIFY_IS_APPROX(result(0), t1(0, 0) * t2(0, 0, 0) +  t1(1, 0) * t2(1, 0, 0)
@@ -212,7 +212,7 @@ static void test_contraction_of_contraction()
   t3.setRandom();
   t4.setRandom();
 
-  Eigen::array dims({{DimPair(1, 0)}});
+  StormEigen::array dims({{DimPair(1, 0)}});
   auto contract1 = t1.contract(t2, dims);
   auto diff = t3 - contract1;
   auto contract2 = t1.contract(t4, dims);
@@ -221,10 +221,10 @@ static void test_contraction_of_contraction()
   VERIFY_IS_EQUAL(result.dimension(0), 2);
   VERIFY_IS_EQUAL(result.dimension(1), 2);
 
-  Eigen::Map>
+  StormEigen::Map>
       m1(t1.data(), 2, 2), m2(t2.data(), 2, 2), m3(t3.data(), 2, 2),
       m4(t4.data(), 2, 2);
-  Eigen::Matrix
+  StormEigen::Matrix
       expected = (m1 * m4) * (m3 - m1 * m2);
 
   VERIFY_IS_APPROX(result(0, 0), expected(0, 0));
@@ -243,7 +243,7 @@ static void test_expr()
 
   Tensor mat3(2,2);
 
-  Eigen::array dims({{DimPair(1, 0)}});
+  StormEigen::array dims({{DimPair(1, 0)}});
   mat3 = mat1.contract(mat2, dims);
 
   VERIFY_IS_APPROX(mat3(0,0), mat1(0,0)*mat2(0,0) + mat1(0,1)*mat2(1,0) + mat1(0,2)*mat2(2,0));
@@ -263,7 +263,7 @@ static void test_out_of_order_contraction()
 
   Tensor mat3(2, 2);
 
-  Eigen::array dims({{DimPair(2, 0), DimPair(0, 2)}});
+  StormEigen::array dims({{DimPair(2, 0), DimPair(0, 2)}});
   mat3 = mat1.contract(mat2, dims);
 
   VERIFY_IS_APPROX(mat3(0, 0),
@@ -279,7 +279,7 @@ static void test_out_of_order_contraction()
                    mat1(0,1,0)*mat2(0,1,0) + mat1(1,1,0)*mat2(0,1,1) +
                    mat1(0,1,1)*mat2(1,1,0) + mat1(1,1,1)*mat2(1,1,1));
 
-  Eigen::array dims2({{DimPair(0, 2), DimPair(2, 0)}});
+  StormEigen::array dims2({{DimPair(0, 2), DimPair(2, 0)}});
   mat3 = mat1.contract(mat2, dims2);
 
   VERIFY_IS_APPROX(mat3(0, 0),
@@ -311,8 +311,8 @@ static void test_consistency()
   Tensor mat4(2, 1, 5, 5);
 
   // contract on dimensions of size 4 and 3
-  Eigen::array dims1({{DimPair(0, 4), DimPair(1, 0)}});
-  Eigen::array dims2({{DimPair(4, 0), DimPair(0, 1)}});
+  StormEigen::array dims1({{DimPair(0, 4), DimPair(1, 0)}});
+  StormEigen::array dims2({{DimPair(4, 0), DimPair(0, 1)}});
 
   mat3 = mat1.contract(mat2, dims1);
   mat4 = mat2.contract(mat1, dims2);
@@ -348,13 +348,13 @@ static void test_large_contraction()
   t_left += t_left.constant(1.0f);
   t_right += t_right.constant(1.0f);
 
-  typedef Map> MapXf;
+  typedef Map> MapXf;
   MapXf m_left(t_left.data(), 1500, 248);
   MapXf m_right(t_right.data(), 248, 1400);
-  Eigen::Matrix m_result(1500, 1400);
+  StormEigen::Matrix m_result(1500, 1400);
 
   // this contraction should be equivalent to a single matrix multiplication
-  Eigen::array dims({{DimPair(2, 0), DimPair(3, 1)}});
+  StormEigen::array dims({{DimPair(2, 0), DimPair(3, 1)}});
 
   // compute results by separate methods
   t_result = t_left.contract(t_right, dims);
@@ -376,13 +376,13 @@ static void test_matrix_vector()
   t_left.setRandom();
   t_right.setRandom();
 
-  typedef Map> MapXf;
+  typedef Map> MapXf;
   MapXf m_left(t_left.data(), 30, 50);
   MapXf m_right(t_right.data(), 50, 1);
-  Eigen::Matrix m_result(30, 1);
+  StormEigen::Matrix m_result(30, 1);
 
   // this contraction should be equivalent to a single matrix multiplication
-  Eigen::array dims{{DimPair(1, 0)}};
+  StormEigen::array dims{{DimPair(1, 0)}};
 
   // compute results by separate methods
   t_result = t_left.contract(t_right, dims);
@@ -404,13 +404,13 @@ static void test_tensor_vector()
   t_right.setRandom();
   
   typedef typename Tensor::DimensionPair DimensionPair;
-  Eigen::array dim_pair01{{{0, 1}}};
+  StormEigen::array dim_pair01{{{0, 1}}};
   Tensor t_result = t_left.contract(t_right, dim_pair01);
 
-  typedef Map> MapXf;
+  typedef Map> MapXf;
   MapXf m_left(t_left.data(), 7, 13*17);
   MapXf m_right(t_right.data(), 1, 7);
-  Eigen::Matrix m_result = m_left.transpose() * m_right.transpose();
+  StormEigen::Matrix m_result = m_left.transpose() * m_right.transpose();
 
   for (int i = 0; i < t_result.dimensions().TotalSize(); i++) {
     VERIFY(internal::isApprox(t_result(i), m_result(i, 0), 1));
@@ -431,17 +431,17 @@ static void test_small_blocking_factors()
   t_right += t_right.constant(1.0f);
 
   // Force the cache sizes, which results in smaller blocking factors.
-  Eigen::setCpuCacheSizes(896, 1920, 2944);
+  StormEigen::setCpuCacheSizes(896, 1920, 2944);
 
   // this contraction should be equivalent to a single matrix multiplication
-  Eigen::array dims({{DimPair(2, 0), DimPair(3, 1)}});
+  StormEigen::array dims({{DimPair(2, 0), DimPair(3, 1)}});
   Tensor t_result;
   t_result = t_left.contract(t_right, dims);
 
   // compute result using a simple eigen matrix product
-  Map> m_left(t_left.data(), 150, 93);
-  Map> m_right(t_right.data(), 93, 140);
-  Eigen::Matrix m_result = m_left * m_right;
+  Map> m_left(t_left.data(), 150, 93);
+  Map> m_right(t_right.data(), 93, 140);
+  StormEigen::Matrix m_result = m_left * m_right;
 
   for (int i = 0; i < t_result.dimensions().TotalSize(); i++) {
     VERIFY_IS_APPROX(t_result.data()[i], m_result.data()[i]);
@@ -456,7 +456,7 @@ static void test_tensor_product()
   mat1.setRandom();
   mat2.setRandom();
 
-  Tensor result = mat1.contract(mat2, Eigen::array{{}});
+  Tensor result = mat1.contract(mat2, StormEigen::array{{}});
 
   VERIFY_IS_EQUAL(result.dimension(0), 2);
   VERIFY_IS_EQUAL(result.dimension(1), 3);
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_convolution.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_convolution.cpp
index e3d4675eb..d19e3a8c8 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_convolution.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_convolution.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::DefaultDevice;
+using StormEigen::Tensor;
+using StormEigen::DefaultDevice;
 
 template 
 static void test_evals()
@@ -25,7 +25,7 @@ static void test_evals()
 
   Tensor result(2,3);
   result.setZero();
-  Eigen::array::Index, 1> dims3{{0}};
+  StormEigen::array::Index, 1> dims3{{0}};
 
   typedef TensorEvaluator Evaluator;
   Evaluator eval(input.convolve(kernel, dims3), DefaultDevice());
@@ -51,7 +51,7 @@ static void test_expr()
   kernel.setRandom();
 
   Tensor result(2,2);
-  Eigen::array dims;
+  StormEigen::array dims;
   dims[0] = 0;
   dims[1] = 1;
   result = input.convolve(kernel, dims);
@@ -77,9 +77,9 @@ static void test_modes() {
   kernel(1) = 1.0f;
   kernel(2) = 0.0f;
 
-  Eigen::array dims;
+  StormEigen::array dims;
   dims[0] = 0;
-  Eigen::array, 1> padding;
+  StormEigen::array, 1> padding;
 
   // Emulate VALID mode (as defined in
   // http://docs.scipy.org/doc/numpy/reference/generated/numpy.convolve.html).
@@ -119,11 +119,11 @@ static void test_strides() {
   input.setRandom();
   kernel.setRandom();
 
-  Eigen::array dims;
+  StormEigen::array dims;
   dims[0] = 0;
-  Eigen::array stride_of_3;
+  StormEigen::array stride_of_3;
   stride_of_3[0] = 3;
-  Eigen::array stride_of_2;
+  StormEigen::array stride_of_2;
   stride_of_2[0] = 2;
 
   Tensor result;
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_cuda.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_cuda.cpp
index 49e1894ab..bf44f50a6 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_cuda.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_cuda.cpp
@@ -19,12 +19,12 @@
 #include "main.h"
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 void test_cuda_elementwise_small() {
-  Tensor in1(Eigen::array(2));
-  Tensor in2(Eigen::array(2));
-  Tensor out(Eigen::array(2));
+  Tensor in1(StormEigen::array(2));
+  Tensor in2(StormEigen::array(2));
+  Tensor out(StormEigen::array(2));
   in1.setRandom();
   in2.setRandom();
 
@@ -42,15 +42,15 @@ void test_cuda_elementwise_small() {
   cudaMemcpy(d_in1, in1.data(), in1_bytes, cudaMemcpyHostToDevice);
   cudaMemcpy(d_in2, in2.data(), in2_bytes, cudaMemcpyHostToDevice);
 
-  Eigen::CudaStreamDevice stream;
-  Eigen::GpuDevice gpu_device(&stream);
+  StormEigen::CudaStreamDevice stream;
+  StormEigen::GpuDevice gpu_device(&stream);
 
-  Eigen::TensorMap, Eigen::Aligned> gpu_in1(
-      d_in1, Eigen::array(2));
-  Eigen::TensorMap, Eigen::Aligned> gpu_in2(
-      d_in2, Eigen::array(2));
-  Eigen::TensorMap, Eigen::Aligned> gpu_out(
-      d_out, Eigen::array(2));
+  StormEigen::TensorMap, Eigen::Aligned> gpu_in1(
+      d_in1, StormEigen::array(2));
+  StormEigen::TensorMap, Eigen::Aligned> gpu_in2(
+      d_in2, StormEigen::array(2));
+  StormEigen::TensorMap, Eigen::Aligned> gpu_out(
+      d_out, StormEigen::array(2));
 
   gpu_out.device(gpu_device) = gpu_in1 + gpu_in2;
 
@@ -60,17 +60,17 @@ void test_cuda_elementwise_small() {
 
   for (int i = 0; i < 2; ++i) {
     VERIFY_IS_APPROX(
-        out(Eigen::array(i)),
-        in1(Eigen::array(i)) + in2(Eigen::array(i)));
+        out(StormEigen::array(i)),
+        in1(StormEigen::array(i)) + in2(StormEigen::array(i)));
   }
 }
 
 void test_cuda_elementwise()
 {
-  Tensor in1(Eigen::array(72,53,97));
-  Tensor in2(Eigen::array(72,53,97));
-  Tensor in3(Eigen::array(72,53,97));
-  Tensor out(Eigen::array(72,53,97));
+  Tensor in1(StormEigen::array(72,53,97));
+  Tensor in2(StormEigen::array(72,53,97));
+  Tensor in3(StormEigen::array(72,53,97));
+  Tensor out(StormEigen::array(72,53,97));
   in1.setRandom();
   in2.setRandom();
   in3.setRandom();
@@ -93,13 +93,13 @@ void test_cuda_elementwise()
   cudaMemcpy(d_in2, in2.data(), in2_bytes, cudaMemcpyHostToDevice);
   cudaMemcpy(d_in3, in3.data(), in3_bytes, cudaMemcpyHostToDevice);
 
-  Eigen::CudaStreamDevice stream;
-  Eigen::GpuDevice gpu_device(&stream);
+  StormEigen::CudaStreamDevice stream;
+  StormEigen::GpuDevice gpu_device(&stream);
 
-  Eigen::TensorMap > gpu_in1(d_in1, Eigen::array(72,53,97));
-  Eigen::TensorMap > gpu_in2(d_in2, Eigen::array(72,53,97));
-  Eigen::TensorMap > gpu_in3(d_in3, Eigen::array(72,53,97));
-  Eigen::TensorMap > gpu_out(d_out, Eigen::array(72,53,97));
+  StormEigen::TensorMap > gpu_in1(d_in1, Eigen::array(72,53,97));
+  StormEigen::TensorMap > gpu_in2(d_in2, Eigen::array(72,53,97));
+  StormEigen::TensorMap > gpu_in3(d_in3, Eigen::array(72,53,97));
+  StormEigen::TensorMap > gpu_out(d_out, Eigen::array(72,53,97));
 
   gpu_out.device(gpu_device) = gpu_in1 + gpu_in2 * gpu_in3;
 
@@ -109,7 +109,7 @@ void test_cuda_elementwise()
   for (int i = 0; i < 72; ++i) {
     for (int j = 0; j < 53; ++j) {
       for (int k = 0; k < 97; ++k) {
-        VERIFY_IS_APPROX(out(Eigen::array(i,j,k)), in1(Eigen::array(i,j,k)) + in2(Eigen::array(i,j,k)) * in3(Eigen::array(i,j,k)));
+        VERIFY_IS_APPROX(out(StormEigen::array(i,j,k)), in1(StormEigen::array(i,j,k)) + in2(Eigen::array(i,j,k)) * in3(Eigen::array(i,j,k)));
       }
     }
   }
@@ -133,10 +133,10 @@ void test_cuda_reduction()
 
   cudaStream_t stream;
   assert(cudaStreamCreate(&stream) == cudaSuccess);
-  Eigen::GpuDevice gpu_device(&stream);
+  StormEigen::GpuDevice gpu_device(&stream);
 
-  Eigen::TensorMap > gpu_in1(d_in1, 72,53,97,113);
-  Eigen::TensorMap > gpu_out(d_out, 72,97);
+  StormEigen::TensorMap > gpu_in1(d_in1, 72,53,97,113);
+  StormEigen::TensorMap > gpu_out(d_out, 72,97);
 
   array reduction_axis;
   reduction_axis[0] = 1;
@@ -168,8 +168,8 @@ static void test_cuda_contraction()
   // more than 30 * 1024, which is the number of threads in blocks on
   // a 15 SM GK110 GPU
   Tensor t_left(6, 50, 3, 31);
-  Tensor t_right(Eigen::array(3, 31, 7, 20, 1));
-  Tensor t_result(Eigen::array(6, 50, 7, 20, 1));
+  Tensor t_right(StormEigen::array(3, 31, 7, 20, 1));
+  Tensor t_result(StormEigen::array(6, 50, 7, 20, 1));
 
   t_left.setRandom();
   t_right.setRandom();
@@ -191,19 +191,19 @@ static void test_cuda_contraction()
 
   cudaStream_t stream;
   assert(cudaStreamCreate(&stream) == cudaSuccess);
-  Eigen::GpuDevice gpu_device(&stream);
+  StormEigen::GpuDevice gpu_device(&stream);
 
-  Eigen::TensorMap > gpu_t_left(d_t_left, 6, 50, 3, 31);
-  Eigen::TensorMap > gpu_t_right(d_t_right, 3, 31, 7, 20, 1);
-  Eigen::TensorMap > gpu_t_result(d_t_result, 6, 50, 7, 20, 1);
+  StormEigen::TensorMap > gpu_t_left(d_t_left, 6, 50, 3, 31);
+  StormEigen::TensorMap > gpu_t_right(d_t_right, 3, 31, 7, 20, 1);
+  StormEigen::TensorMap > gpu_t_result(d_t_result, 6, 50, 7, 20, 1);
 
-  typedef Eigen::Map > MapXf;
+  typedef StormEigen::Map > MapXf;
   MapXf m_left(t_left.data(), 300, 93);
   MapXf m_right(t_right.data(), 93, 140);
-  Eigen::Matrix m_result(300, 140);
+  StormEigen::Matrix m_result(300, 140);
 
   typedef Tensor::DimensionPair DimPair;
-  Eigen::array dims;
+  StormEigen::array dims;
   dims[0] = DimPair(2, 0);
   dims[1] = DimPair(3, 1);
 
@@ -245,13 +245,13 @@ static void test_cuda_convolution_1d()
 
   cudaStream_t stream;
   assert(cudaStreamCreate(&stream) == cudaSuccess);
-  Eigen::GpuDevice gpu_device(&stream);
+  StormEigen::GpuDevice gpu_device(&stream);
 
-  Eigen::TensorMap > gpu_input(d_input, 74,37,11,137);
-  Eigen::TensorMap > gpu_kernel(d_kernel, 4);
-  Eigen::TensorMap > gpu_out(d_out, 74,34,11,137);
+  StormEigen::TensorMap > gpu_input(d_input, 74,37,11,137);
+  StormEigen::TensorMap > gpu_kernel(d_kernel, 4);
+  StormEigen::TensorMap > gpu_out(d_out, 74,34,11,137);
 
-  Eigen::array dims(1);
+  StormEigen::array dims(1);
   gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims);
 
   assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess);
@@ -295,13 +295,13 @@ static void test_cuda_convolution_inner_dim_col_major_1d()
 
   cudaStream_t stream;
   assert(cudaStreamCreate(&stream) == cudaSuccess);
-  Eigen::GpuDevice gpu_device(&stream);
+  StormEigen::GpuDevice gpu_device(&stream);
 
-  Eigen::TensorMap > gpu_input(d_input,74,9,11,7);
-  Eigen::TensorMap > gpu_kernel(d_kernel,4);
-  Eigen::TensorMap > gpu_out(d_out,71,9,11,7);
+  StormEigen::TensorMap > gpu_input(d_input,74,9,11,7);
+  StormEigen::TensorMap > gpu_kernel(d_kernel,4);
+  StormEigen::TensorMap > gpu_out(d_out,71,9,11,7);
 
-  Eigen::array dims(0);
+  StormEigen::array dims(0);
   gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims);
 
   assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess);
@@ -345,13 +345,13 @@ static void test_cuda_convolution_inner_dim_row_major_1d()
 
   cudaStream_t stream;
   assert(cudaStreamCreate(&stream) == cudaSuccess);
-  Eigen::GpuDevice gpu_device(&stream);
+  StormEigen::GpuDevice gpu_device(&stream);
 
-  Eigen::TensorMap > gpu_input(d_input, 7,9,11,74);
-  Eigen::TensorMap > gpu_kernel(d_kernel, 4);
-  Eigen::TensorMap > gpu_out(d_out, 7,9,11,71);
+  StormEigen::TensorMap > gpu_input(d_input, 7,9,11,74);
+  StormEigen::TensorMap > gpu_kernel(d_kernel, 4);
+  StormEigen::TensorMap > gpu_out(d_out, 7,9,11,71);
 
-  Eigen::array dims(3);
+  StormEigen::array dims(3);
   gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims);
 
   assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess);
@@ -396,13 +396,13 @@ static void test_cuda_convolution_2d()
 
   cudaStream_t stream;
   assert(cudaStreamCreate(&stream) == cudaSuccess);
-  Eigen::GpuDevice gpu_device(&stream);
+  StormEigen::GpuDevice gpu_device(&stream);
 
-  Eigen::TensorMap > gpu_input(d_input,74,37,11,137);
-  Eigen::TensorMap > gpu_kernel(d_kernel,3,4);
-  Eigen::TensorMap > gpu_out(d_out,74,35,8,137);
+  StormEigen::TensorMap > gpu_input(d_input,74,37,11,137);
+  StormEigen::TensorMap > gpu_kernel(d_kernel,3,4);
+  StormEigen::TensorMap > gpu_out(d_out,74,35,8,137);
 
-  Eigen::array dims(1,2);
+  StormEigen::array dims(1,2);
   gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims);
 
   assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess);
@@ -435,9 +435,9 @@ static void test_cuda_convolution_2d()
 template
 static void test_cuda_convolution_3d()
 {
-  Tensor input(Eigen::array(74,37,11,137,17));
+  Tensor input(StormEigen::array(74,37,11,137,17));
   Tensor kernel(3,4,2);
-  Tensor out(Eigen::array(74,35,8,136,17));
+  Tensor out(StormEigen::array(74,35,8,136,17));
   input = input.constant(10.0f) + input.random();
   kernel = kernel.constant(7.0f) + kernel.random();
 
@@ -457,13 +457,13 @@ static void test_cuda_convolution_3d()
 
   cudaStream_t stream;
   assert(cudaStreamCreate(&stream) == cudaSuccess);
-  Eigen::GpuDevice gpu_device(&stream);
+  StormEigen::GpuDevice gpu_device(&stream);
 
-  Eigen::TensorMap > gpu_input(d_input,74,37,11,137,17);
-  Eigen::TensorMap > gpu_kernel(d_kernel,3,4,2);
-  Eigen::TensorMap > gpu_out(d_out,74,35,8,136,17);
+  StormEigen::TensorMap > gpu_input(d_input,74,37,11,137,17);
+  StormEigen::TensorMap > gpu_kernel(d_kernel,3,4,2);
+  StormEigen::TensorMap > gpu_out(d_out,74,35,8,136,17);
 
-  Eigen::array dims(1,2,3);
+  StormEigen::array dims(1,2,3);
   gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims);
 
   assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess);
@@ -526,11 +526,11 @@ void test_cuda_lgamma(const Scalar stddev)
 
   cudaMemcpy(d_in, in.data(), bytes, cudaMemcpyHostToDevice);
 
-  Eigen::CudaStreamDevice stream;
-  Eigen::GpuDevice gpu_device(&stream);
+  StormEigen::CudaStreamDevice stream;
+  StormEigen::GpuDevice gpu_device(&stream);
 
-  Eigen::TensorMap > gpu_in(d_in, 72, 97);
-  Eigen::TensorMap > gpu_out(d_out, 72, 97);
+  StormEigen::TensorMap > gpu_in(d_in, 72, 97);
+  StormEigen::TensorMap > gpu_out(d_out, 72, 97);
 
   gpu_out.device(gpu_device) = gpu_in.lgamma();
 
@@ -562,11 +562,11 @@ void test_cuda_erf(const Scalar stddev)
 
   cudaMemcpy(d_in, in.data(), bytes, cudaMemcpyHostToDevice);
 
-  Eigen::CudaStreamDevice stream;
-  Eigen::GpuDevice gpu_device(&stream);
+  StormEigen::CudaStreamDevice stream;
+  StormEigen::GpuDevice gpu_device(&stream);
 
-  Eigen::TensorMap > gpu_in(d_in, 72, 97);
-  Eigen::TensorMap > gpu_out(d_out, 72, 97);
+  StormEigen::TensorMap > gpu_in(d_in, 72, 97);
+  StormEigen::TensorMap > gpu_out(d_out, 72, 97);
 
   gpu_out.device(gpu_device) = gpu_in.erf();
 
@@ -598,11 +598,11 @@ void test_cuda_erfc(const Scalar stddev)
 
   cudaMemcpy(d_in, in.data(), bytes, cudaMemcpyHostToDevice);
 
-  Eigen::CudaStreamDevice stream;
-  Eigen::GpuDevice gpu_device(&stream);
+  StormEigen::CudaStreamDevice stream;
+  StormEigen::GpuDevice gpu_device(&stream);
 
-  Eigen::TensorMap > gpu_in(d_in, 72, 97);
-  Eigen::TensorMap > gpu_out(d_out, 72, 97);
+  StormEigen::TensorMap > gpu_in(d_in, 72, 97);
+  StormEigen::TensorMap > gpu_out(d_out, 72, 97);
 
   gpu_out.device(gpu_device) = gpu_in.erfc();
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_custom_index.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_custom_index.cpp
index 4528cc176..bd3e77be8 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_custom_index.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_custom_index.cpp
@@ -14,7 +14,7 @@
 #include 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 
 template 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_custom_op.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_custom_op.cpp
index 8baa477cc..c3516f3b3 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_custom_op.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_custom_op.cpp
@@ -11,7 +11,7 @@
 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 
 struct InsertZeros {
@@ -30,8 +30,8 @@ struct InsertZeros {
     strides[1] = 2;
     output.stride(strides).device(device) = input;
 
-    Eigen::DSizes offsets(1,1);
-    Eigen::DSizes extents(output.dimension(0)-1, output.dimension(1)-1);
+    StormEigen::DSizes offsets(1,1);
+    StormEigen::DSizes extents(output.dimension(0)-1, output.dimension(1)-1);
     output.slice(offsets, extents).stride(strides).device(device) = input.constant(0.0f);
   }
 };
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_device.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_device.cpp
index ed5dd7505..fb5002e89 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_device.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_device.cpp
@@ -17,12 +17,12 @@
 #include "main.h"
 #include 
 
-using Eigen::Tensor;
-using Eigen::RowMajor;
+using StormEigen::Tensor;
+using StormEigen::RowMajor;
 
 // Context for evaluation on cpu
 struct CPUContext {
-  CPUContext(const Eigen::Tensor& in1, Eigen::Tensor& in2, Eigen::Tensor& out) : in1_(in1), in2_(in2), out_(out), kernel_1d_(2), kernel_2d_(2,2), kernel_3d_(2,2,2) {
+  CPUContext(const StormEigen::Tensor& in1, StormEigen::Tensor& in2, Eigen::Tensor& out) : in1_(in1), in2_(in2), out_(out), kernel_1d_(2), kernel_2d_(2,2), kernel_3d_(2,2,2) {
     kernel_1d_(0) = 3.14f;
     kernel_1d_(1) = 2.7f;
 
@@ -41,31 +41,31 @@ struct CPUContext {
     kernel_3d_(1,1,1) = -0.5f;
   }
 
-  const Eigen::DefaultDevice& device() const { return cpu_device_; }
+  const StormEigen::DefaultDevice& device() const { return cpu_device_; }
 
-  const Eigen::Tensor& in1() const { return in1_; }
-  const Eigen::Tensor& in2() const { return in2_; }
-  Eigen::Tensor& out() { return out_; }
-  const Eigen::Tensor& kernel1d() const { return kernel_1d_; }
-  const Eigen::Tensor& kernel2d() const { return kernel_2d_; }
-  const Eigen::Tensor& kernel3d() const { return kernel_3d_; }
+  const StormEigen::Tensor& in1() const { return in1_; }
+  const StormEigen::Tensor& in2() const { return in2_; }
+  StormEigen::Tensor& out() { return out_; }
+  const StormEigen::Tensor& kernel1d() const { return kernel_1d_; }
+  const StormEigen::Tensor& kernel2d() const { return kernel_2d_; }
+  const StormEigen::Tensor& kernel3d() const { return kernel_3d_; }
 
  private:
-  const Eigen::Tensor& in1_;
-  const Eigen::Tensor& in2_;
-  Eigen::Tensor& out_;
+  const StormEigen::Tensor& in1_;
+  const StormEigen::Tensor& in2_;
+  StormEigen::Tensor& out_;
 
-  Eigen::Tensor kernel_1d_;
-  Eigen::Tensor kernel_2d_;
-  Eigen::Tensor kernel_3d_;
+  StormEigen::Tensor kernel_1d_;
+  StormEigen::Tensor kernel_2d_;
+  StormEigen::Tensor kernel_3d_;
 
-  Eigen::DefaultDevice cpu_device_;
+  StormEigen::DefaultDevice cpu_device_;
 };
 
 
 // Context for evaluation on GPU
 struct GPUContext {
-  GPUContext(const Eigen::TensorMap >& in1, Eigen::TensorMap >& in2, Eigen::TensorMap >& out) : in1_(in1), in2_(in2), out_(out), gpu_device_(&stream_) {
+  GPUContext(const StormEigen::TensorMap >& in1, Eigen::TensorMap >& in2, Eigen::TensorMap >& out) : in1_(in1), in2_(in2), out_(out), gpu_device_(&stream_) {
     assert(cudaMalloc((void**)(&kernel_1d_), 2*sizeof(float)) == cudaSuccess);
     float kernel_1d_val[] = {3.14f, 2.7f};
     assert(cudaMemcpy(kernel_1d_, kernel_1d_val, 2*sizeof(float), cudaMemcpyHostToDevice) == cudaSuccess);
@@ -84,26 +84,26 @@ struct GPUContext {
     assert(cudaFree(kernel_3d_) == cudaSuccess);
   }
 
-  const Eigen::GpuDevice& device() const { return gpu_device_; }
+  const StormEigen::GpuDevice& device() const { return gpu_device_; }
 
-  const Eigen::TensorMap >& in1() const { return in1_; }
-  const Eigen::TensorMap >& in2() const { return in2_; }
-  Eigen::TensorMap >& out() { return out_; }
-  Eigen::TensorMap > kernel1d() const { return Eigen::TensorMap >(kernel_1d_, 2); }
-  Eigen::TensorMap > kernel2d() const { return Eigen::TensorMap >(kernel_2d_, 2, 2); }
-  Eigen::TensorMap > kernel3d() const { return Eigen::TensorMap >(kernel_3d_, 2, 2, 2); }
+  const StormEigen::TensorMap >& in1() const { return in1_; }
+  const StormEigen::TensorMap >& in2() const { return in2_; }
+  StormEigen::TensorMap >& out() { return out_; }
+  StormEigen::TensorMap > kernel1d() const { return Eigen::TensorMap >(kernel_1d_, 2); }
+  StormEigen::TensorMap > kernel2d() const { return Eigen::TensorMap >(kernel_2d_, 2, 2); }
+  StormEigen::TensorMap > kernel3d() const { return Eigen::TensorMap >(kernel_3d_, 2, 2, 2); }
 
  private:
-  const Eigen::TensorMap >& in1_;
-  const Eigen::TensorMap >& in2_;
-  Eigen::TensorMap >& out_;
+  const StormEigen::TensorMap >& in1_;
+  const StormEigen::TensorMap >& in2_;
+  StormEigen::TensorMap >& out_;
 
   float* kernel_1d_;
   float* kernel_2d_;
   float* kernel_3d_;
 
-  Eigen::CudaStreamDevice stream_;
-  Eigen::GpuDevice gpu_device_;
+  StormEigen::CudaStreamDevice stream_;
+  StormEigen::GpuDevice gpu_device_;
 };
 
 
@@ -131,14 +131,14 @@ static void test_compound_assignment(Context* context)
 template 
 static void test_contraction(Context* context)
 {
-  Eigen::array, 2> dims;
+  StormEigen::array, 2> dims;
   dims[0] = std::make_pair(1, 1);
   dims[1] = std::make_pair(2, 2);
 
-  Eigen::array shape(40, 50*70);
+  StormEigen::array shape(40, 50*70);
 
-  Eigen::DSizes indices(0,0);
-  Eigen::DSizes sizes(40,40);
+  StormEigen::DSizes indices(0,0);
+  StormEigen::DSizes sizes(40,40);
 
   context->out().reshape(shape).slice(indices, sizes).device(context->device()) = context->in1().contract(context->in2(), dims);
 }
@@ -147,38 +147,38 @@ static void test_contraction(Context* context)
 template 
 static void test_1d_convolution(Context* context)
 {
-  Eigen::DSizes indices(0,0,0);
-  Eigen::DSizes sizes(40,49,70);
+  StormEigen::DSizes indices(0,0,0);
+  StormEigen::DSizes sizes(40,49,70);
 
-  Eigen::array dims(1);
+  StormEigen::array dims(1);
   context->out().slice(indices, sizes).device(context->device()) = context->in1().convolve(context->kernel1d(), dims);
 }
 
 template 
 static void test_2d_convolution(Context* context)
 {
-  Eigen::DSizes indices(0,0,0);
-  Eigen::DSizes sizes(40,49,69);
+  StormEigen::DSizes indices(0,0,0);
+  StormEigen::DSizes sizes(40,49,69);
 
-  Eigen::array dims(1,2);
+  StormEigen::array dims(1,2);
   context->out().slice(indices, sizes).device(context->device()) = context->in1().convolve(context->kernel2d(), dims);
 }
 
 template 
 static void test_3d_convolution(Context* context)
 {
-  Eigen::DSizes indices(0,0,0);
-  Eigen::DSizes sizes(39,49,69);
+  StormEigen::DSizes indices(0,0,0);
+  StormEigen::DSizes sizes(39,49,69);
 
-  Eigen::array dims(0,1,2);
+  StormEigen::array dims(0,1,2);
   context->out().slice(indices, sizes).device(context->device()) = context->in1().convolve(context->kernel3d(), dims);
 }
 
 
 static void test_cpu() {
-  Eigen::Tensor in1(40,50,70);
-  Eigen::Tensor in2(40,50,70);
-  Eigen::Tensor out(40,50,70);
+  StormEigen::Tensor in1(40,50,70);
+  StormEigen::Tensor in2(40,50,70);
+  StormEigen::Tensor out(40,50,70);
 
   in1 = in1.random() + in1.constant(10.0f);
   in2 = in2.random() + in2.constant(10.0f);
@@ -268,9 +268,9 @@ static void test_cpu() {
 }
 
 static void test_gpu() {
-  Eigen::Tensor in1(40,50,70);
-  Eigen::Tensor in2(40,50,70);
-  Eigen::Tensor out(40,50,70);
+  StormEigen::Tensor in1(40,50,70);
+  StormEigen::Tensor in2(40,50,70);
+  StormEigen::Tensor out(40,50,70);
   in1 = in1.random() + in1.constant(10.0f);
   in2 = in2.random() + in2.constant(10.0f);
 
@@ -288,9 +288,9 @@ static void test_gpu() {
   cudaMemcpy(d_in1, in1.data(), in1_bytes, cudaMemcpyHostToDevice);
   cudaMemcpy(d_in2, in2.data(), in2_bytes, cudaMemcpyHostToDevice);
 
-  Eigen::TensorMap > gpu_in1(d_in1, 40,50,70);
-  Eigen::TensorMap > gpu_in2(d_in2, 40,50,70);
-  Eigen::TensorMap > gpu_out(d_out, 40,50,70);
+  StormEigen::TensorMap > gpu_in1(d_in1, 40,50,70);
+  StormEigen::TensorMap > gpu_in2(d_in2, 40,50,70);
+  StormEigen::TensorMap > gpu_out(d_out, 40,50,70);
 
   GPUContext context(gpu_in1, gpu_in2, gpu_out);
   test_contextual_eval(&context);
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_dimension.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_dimension.cpp
index ce78efe52..2cd24918a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_dimension.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_dimension.cpp
@@ -11,16 +11,16 @@
 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 
 static void test_dynamic_size()
 {
-  Eigen::DSizes dimensions(2,3,7);
+  StormEigen::DSizes dimensions(2,3,7);
 
-  VERIFY_IS_EQUAL((int)Eigen::internal::array_get<0>(dimensions), 2);
-  VERIFY_IS_EQUAL((int)Eigen::internal::array_get<1>(dimensions), 3);
-  VERIFY_IS_EQUAL((int)Eigen::internal::array_get<2>(dimensions), 7);
+  VERIFY_IS_EQUAL((int)StormEigen::internal::array_get<0>(dimensions), 2);
+  VERIFY_IS_EQUAL((int)StormEigen::internal::array_get<1>(dimensions), 3);
+  VERIFY_IS_EQUAL((int)StormEigen::internal::array_get<2>(dimensions), 7);
   VERIFY_IS_EQUAL(dimensions.TotalSize(), 2*3*7);
   VERIFY_IS_EQUAL((int)dimensions[0], 2);
   VERIFY_IS_EQUAL((int)dimensions[1], 3);
@@ -29,24 +29,24 @@ static void test_dynamic_size()
 
 static void test_fixed_size()
 {
-  Eigen::Sizes<2,3,7> dimensions;
+  StormEigen::Sizes<2,3,7> dimensions;
 
-  VERIFY_IS_EQUAL((int)Eigen::internal::array_get<0>(dimensions), 2);
-  VERIFY_IS_EQUAL((int)Eigen::internal::array_get<1>(dimensions), 3);
-  VERIFY_IS_EQUAL((int)Eigen::internal::array_get<2>(dimensions), 7);
+  VERIFY_IS_EQUAL((int)StormEigen::internal::array_get<0>(dimensions), 2);
+  VERIFY_IS_EQUAL((int)StormEigen::internal::array_get<1>(dimensions), 3);
+  VERIFY_IS_EQUAL((int)StormEigen::internal::array_get<2>(dimensions), 7);
   VERIFY_IS_EQUAL(dimensions.TotalSize(), 2*3*7);
 }
 
 
 static void test_match()
 {
-  Eigen::DSizes dyn(2,3,7);
-  Eigen::Sizes<2,3,7> stat;
-  VERIFY_IS_EQUAL(Eigen::dimensions_match(dyn, stat), true);
+  StormEigen::DSizes dyn(2,3,7);
+  StormEigen::Sizes<2,3,7> stat;
+  VERIFY_IS_EQUAL(StormEigen::dimensions_match(dyn, stat), true);
 
-  Eigen::DSizes dyn1(2,3,7);
-  Eigen::DSizes dyn2(2,3);
-  VERIFY_IS_EQUAL(Eigen::dimensions_match(dyn1, dyn2), false);
+  StormEigen::DSizes dyn1(2,3,7);
+  StormEigen::DSizes dyn2(2,3);
+  VERIFY_IS_EQUAL(StormEigen::dimensions_match(dyn1, dyn2), false);
 }
 
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_expr.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_expr.cpp
index 8389e9840..4eba7659d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_expr.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_expr.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::RowMajor;
+using StormEigen::Tensor;
+using StormEigen::RowMajor;
 
 static void test_1d()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_fft.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_fft.cpp
index 0f6e09106..20ecc8031 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_fft.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_fft.cpp
@@ -10,7 +10,7 @@
 #include "main.h"
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 template 
 static void test_fft_2D_golden() {
@@ -26,7 +26,7 @@ static void test_fft_2D_golden() {
   fft[0] = 0;
   fft[1] = 1;
 
-  Tensor, 2, DataLayout, long> output = input.template fft(fft);
+  Tensor, 2, DataLayout, long> output = input.template fft(fft);
 
   std::complex output_golden[6]; // in ColMajor order
   output_golden[0] = std::complex(21, 0);
@@ -178,7 +178,7 @@ static void test_fft_real_input_golden() {
 template 
 static void test_fft_real_input_energy() {
 
-  Eigen::DSizes dimensions;
+  StormEigen::DSizes dimensions;
   int total_size = 1;
   for (int i = 0; i < TensorRank; ++i) {
     dimensions[i] = rand() % 20 + 1;
@@ -197,7 +197,7 @@ static void test_fft_real_input_energy() {
     fft[i] = i;
   }
 
-  typedef typename internal::conditional, RealScalar>::type OutputScalar;
+  typedef typename internal::conditional, RealScalar>::type OutputScalar;
   Tensor output;
   output = input.template fft(fft);
 
@@ -231,43 +231,43 @@ void test_cxx11_tensor_fft() {
     test_fft_2D_golden();
     test_fft_2D_golden();
 
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
-    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
+    test_fft_real_input_energy();
 }
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_fixed_size.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_fixed_size.cpp
index 1c33fefb3..fdc5fc975 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_fixed_size.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_fixed_size.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::RowMajor;
+using StormEigen::Tensor;
+using StormEigen::RowMajor;
 
 
 static void test_0d()
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_forced_eval.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_forced_eval.cpp
index ad9de867d..42330ad12 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_forced_eval.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_forced_eval.cpp
@@ -12,8 +12,8 @@
 #include 
 #include 
 
-using Eigen::MatrixXf;
-using Eigen::Tensor;
+using StormEigen::MatrixXf;
+using StormEigen::Tensor;
 
 static void test_simple()
 {
@@ -29,7 +29,7 @@ static void test_simple()
   mat3 = mat1;
 
   typedef Tensor::DimensionPair DimPair;
-  Eigen::array dims({{DimPair(1, 0)}});
+  StormEigen::array dims({{DimPair(1, 0)}});
 
   mat3 = mat3.contract(mat2, dims).eval();
 
@@ -52,12 +52,12 @@ static void test_const()
   MatrixXf output = input;
   output.rowwise() -= input.colwise().maxCoeff();
 
-  Eigen::array depth_dim;
+  StormEigen::array depth_dim;
   depth_dim[0] = 0;
   Tensor::Dimensions dims2d;
   dims2d[0] = 1;
   dims2d[1] = 3;
-  Eigen::array bcast;
+  StormEigen::array bcast;
   bcast[0] = 3;
   bcast[1] = 1;
   const TensorMap> input_tensor(input.data(), 3, 3);
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_generator.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_generator.cpp
index dcb928714..ed7f7a975 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_generator.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_generator.cpp
@@ -14,7 +14,7 @@
 struct Generator1D {
   Generator1D() { }
 
-  float operator()(const array& coordinates) const {
+  float operator()(const array& coordinates) const {
     return coordinates[0];
   }
 };
@@ -34,7 +34,7 @@ static void test_1D()
 struct Generator2D {
   Generator2D() { }
 
-  float operator()(const array& coordinates) const {
+  float operator()(const array& coordinates) const {
     return 3 * coordinates[0] + 11 * coordinates[1];
   }
 };
@@ -64,7 +64,7 @@ static void test_gaussian()
   array std_devs;
   std_devs[0] = 3.14f;
   std_devs[1] = 2.7f;
-  internal::GaussianGenerator gaussian_gen(means, std_devs);
+  internal::GaussianGenerator gaussian_gen(means, std_devs);
 
   Tensor matrix(rows, cols);
   Tensor result = matrix.generate(gaussian_gen);
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_ifft.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_ifft.cpp
index 5fd88fa6c..c68c43bba 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_ifft.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_ifft.cpp
@@ -12,7 +12,7 @@
 #include 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 template 
 static void test_1D_fft_ifft_invariant(int sequence_length) {
@@ -25,8 +25,8 @@ static void test_1D_fft_ifft_invariant(int sequence_length) {
   Tensor, 1, DataLayout> tensor_after_fft;
   Tensor, 1, DataLayout> tensor_after_fft_ifft;
 
-  tensor_after_fft = tensor.template fft(fft);
-  tensor_after_fft_ifft = tensor_after_fft.template fft(fft);
+  tensor_after_fft = tensor.template fft(fft);
+  tensor_after_fft_ifft = tensor_after_fft.template fft(fft);
 
   VERIFY_IS_EQUAL(tensor_after_fft.dimension(0), sequence_length);
   VERIFY_IS_EQUAL(tensor_after_fft_ifft.dimension(0), sequence_length);
@@ -48,8 +48,8 @@ static void test_2D_fft_ifft_invariant(int dim0, int dim1) {
   Tensor, 2, DataLayout> tensor_after_fft;
   Tensor, 2, DataLayout> tensor_after_fft_ifft;
 
-  tensor_after_fft = tensor.template fft(fft);
-  tensor_after_fft_ifft = tensor_after_fft.template fft(fft);
+  tensor_after_fft = tensor.template fft(fft);
+  tensor_after_fft_ifft = tensor_after_fft.template fft(fft);
 
   VERIFY_IS_EQUAL(tensor_after_fft.dimension(0), dim0);
   VERIFY_IS_EQUAL(tensor_after_fft.dimension(1), dim1);
@@ -77,8 +77,8 @@ static void test_3D_fft_ifft_invariant(int dim0, int dim1, int dim2) {
   Tensor, 3, DataLayout> tensor_after_fft;
   Tensor, 3, DataLayout> tensor_after_fft_ifft;
 
-  tensor_after_fft = tensor.template fft(fft);
-  tensor_after_fft_ifft = tensor_after_fft.template fft(fft);
+  tensor_after_fft = tensor.template fft(fft);
+  tensor_after_fft_ifft = tensor_after_fft.template fft(fft);
 
   VERIFY_IS_EQUAL(tensor_after_fft.dimension(0), dim0);
   VERIFY_IS_EQUAL(tensor_after_fft.dimension(1), dim1);
@@ -108,8 +108,8 @@ static void test_sub_fft_ifft_invariant(int dim0, int dim1, int dim2, int dim3)
   Tensor, 4, DataLayout> tensor_after_fft;
   Tensor tensor_after_fft_ifft;
 
-  tensor_after_fft = tensor.template fft(fft);
-  tensor_after_fft_ifft = tensor_after_fft.template fft(fft);
+  tensor_after_fft = tensor.template fft(fft);
+  tensor_after_fft_ifft = tensor_after_fft.template fft(fft);
 
   VERIFY_IS_EQUAL(tensor_after_fft.dimension(0), dim0);
   VERIFY_IS_EQUAL(tensor_after_fft.dimension(1), dim1);
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_image_patch.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_image_patch.cpp
index 5d6a49181..4095fae11 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_image_patch.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_image_patch.cpp
@@ -11,7 +11,7 @@
 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 static void test_simple_patch()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_index_list.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_index_list.cpp
index 4ce8dea20..8752ec857 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_index_list.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_index_list.cpp
@@ -51,11 +51,11 @@ static void test_type2index_list()
   tensor.setRandom();
   tensor += tensor.constant(10.0f);
 
-  typedef Eigen::IndexList> Dims0;
-  typedef Eigen::IndexList, Eigen::type2index<1>> Dims1;
-  typedef Eigen::IndexList, Eigen::type2index<1>, Eigen::type2index<2>> Dims2;
-  typedef Eigen::IndexList, Eigen::type2index<1>, Eigen::type2index<2>, Eigen::type2index<3>> Dims3;
-  typedef Eigen::IndexList, Eigen::type2index<1>, Eigen::type2index<2>, Eigen::type2index<3>, Eigen::type2index<4>> Dims4;
+  typedef StormEigen::IndexList> Dims0;
+  typedef StormEigen::IndexList, Eigen::type2index<1>> Dims1;
+  typedef StormEigen::IndexList, Eigen::type2index<1>, Eigen::type2index<2>> Dims2;
+  typedef StormEigen::IndexList, Eigen::type2index<1>, Eigen::type2index<2>, Eigen::type2index<3>> Dims3;
+  typedef StormEigen::IndexList, Eigen::type2index<1>, Eigen::type2index<2>, Eigen::type2index<3>, Eigen::type2index<4>> Dims4;
 
 #if 0
   EIGEN_STATIC_ASSERT((internal::indices_statically_known_to_increase() == true), YOU_MADE_A_PROGRAMMING_MISTAKE);
@@ -258,9 +258,9 @@ static void test_mixed_index_list()
 
 static void test_dim_check()
 {
-  Eigen::IndexList, int> dim1;
+  StormEigen::IndexList, int> dim1;
   dim1.set(1, 2);
-  Eigen::IndexList, int> dim2;
+  StormEigen::IndexList, int> dim2;
   dim2.set(1, 2);
   VERIFY(dimensions_match(dim1, dim2));
 }
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_inflation.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_inflation.cpp
index 4997935e9..836df48a1 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_inflation.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_inflation.cpp
@@ -11,7 +11,7 @@
 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 template
 static void test_simple_inflation()
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_intdiv.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_intdiv.cpp
index 48aa6d368..8f64a67b6 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_intdiv.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_intdiv.cpp
@@ -15,7 +15,7 @@
 void test_signed_32bit()
 {
   // Divide by one
-  const Eigen::internal::TensorIntDivisor div_by_one(1);
+  const StormEigen::internal::TensorIntDivisor div_by_one(1);
 
   for (int32_t j = 0; j < 25000; ++j) {
     const int32_t fast_div = j / div_by_one;
@@ -25,7 +25,7 @@ void test_signed_32bit()
 
   // Standard divide by 2 or more
   for (int32_t i = 2; i < 25000; ++i) {
-    const Eigen::internal::TensorIntDivisor div(i);
+    const StormEigen::internal::TensorIntDivisor div(i);
 
     for (int32_t j = 0; j < 25000; ++j) {
       const int32_t fast_div = j / div;
@@ -36,7 +36,7 @@ void test_signed_32bit()
 
   // Optimized divide by 2 or more
   for (int32_t i = 2; i < 25000; ++i) {
-    const Eigen::internal::TensorIntDivisor div(i);
+    const StormEigen::internal::TensorIntDivisor div(i);
 
     for (int32_t j = 0; j < 25000; ++j) {
       const int32_t fast_div = j / div;
@@ -50,7 +50,7 @@ void test_signed_32bit()
 void test_unsigned_32bit()
 {
   for (uint32_t i = 1; i < 25000; ++i) {
-    const Eigen::internal::TensorIntDivisor div(i);
+    const StormEigen::internal::TensorIntDivisor div(i);
 
     for (uint32_t j = 0; j < 25000; ++j) {
       const uint32_t fast_div = j / div;
@@ -64,7 +64,7 @@ void test_unsigned_32bit()
 void test_signed_64bit()
 {
   for (int64_t i = 1; i < 25000; ++i) {
-    const Eigen::internal::TensorIntDivisor div(i);
+    const StormEigen::internal::TensorIntDivisor div(i);
 
     for (int64_t j = 0; j < 25000; ++j) {
       const int64_t fast_div = j / div;
@@ -78,7 +78,7 @@ void test_signed_64bit()
 void test_unsigned_64bit()
 {
   for (uint64_t i = 1; i < 25000; ++i) {
-    const Eigen::internal::TensorIntDivisor div(i);
+    const StormEigen::internal::TensorIntDivisor div(i);
 
     for (uint64_t j = 0; j < 25000; ++j) {
       const uint64_t fast_div = j / div;
@@ -97,8 +97,8 @@ void test_powers_32bit() {
       if (start_num < 0)
         start_num = 0;
       for (int32_t num = start_num; num < end_num; num++) {
-        Eigen::internal::TensorIntDivisor divider =
-          Eigen::internal::TensorIntDivisor(div);
+        StormEigen::internal::TensorIntDivisor divider =
+          StormEigen::internal::TensorIntDivisor(div);
         int32_t result = num/div;
         int32_t result_op = divider.divide(num);
         VERIFY_IS_EQUAL(result_op, result);
@@ -116,7 +116,7 @@ void test_powers_64bit() {
       if (start_num < 0)
         start_num = 0;
       for (int64_t num = start_num; num < end_num; num++) {
-        Eigen::internal::TensorIntDivisor divider(div);
+        StormEigen::internal::TensorIntDivisor divider(div);
         int64_t result = num/div;
         int64_t result_op = divider.divide(num);
         VERIFY_IS_EQUAL(result_op, result);
@@ -129,7 +129,7 @@ void test_specific() {
   // A particular combination that was previously failing
   int64_t div = 209715200;
   int64_t num = 3238002688;
-  Eigen::internal::TensorIntDivisor divider(div);
+  StormEigen::internal::TensorIntDivisor divider(div);
   int64_t result = num/div;
   int64_t result_op = divider.divide(num);
   VERIFY_IS_EQUAL(result, result_op);
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_layout_swap.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_layout_swap.cpp
index ae297a9da..02c0b1349 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_layout_swap.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_layout_swap.cpp
@@ -11,7 +11,7 @@
 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 static void test_simple_swap()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_lvalue.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_lvalue.cpp
index 071f5b406..a63e772ce 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_lvalue.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_lvalue.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::RowMajor;
+using StormEigen::Tensor;
+using StormEigen::RowMajor;
 
 
 static void test_compound_assignment()
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_map.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_map.cpp
index a8a095e38..e94616bc4 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_map.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_map.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::RowMajor;
+using StormEigen::Tensor;
+using StormEigen::RowMajor;
 
 static void test_0d()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_math.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_math.cpp
index d247bebaa..d105db05c 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_math.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_math.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::RowMajor;
+using StormEigen::Tensor;
+using StormEigen::RowMajor;
 
 static void test_tanh()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_morphing.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_morphing.cpp
index eb3b891fd..6dbcb8df0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_morphing.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_morphing.cpp
@@ -11,7 +11,7 @@
 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 static void test_simple_reshape()
 {
@@ -77,7 +77,7 @@ static void test_reshape_as_lvalue()
 
   float scratch[2*3*1*7*1];
   TensorMap> tensor5d(scratch, 2,3,1,7,1);
-  tensor5d.reshape(dim).device(Eigen::DefaultDevice()) = tensor;
+  tensor5d.reshape(dim).device(StormEigen::DefaultDevice()) = tensor;
 
   for (int i = 0; i < 2; ++i) {
     for (int j = 0; j < 3; ++j) {
@@ -96,14 +96,14 @@ static void test_simple_slice()
   tensor.setRandom();
 
   Tensor slice1(1,1,1,1,1);
-  Eigen::DSizes indices(1,2,3,4,5);
-  Eigen::DSizes sizes(1,1,1,1,1);
+  StormEigen::DSizes indices(1,2,3,4,5);
+  StormEigen::DSizes sizes(1,1,1,1,1);
   slice1 = tensor.slice(indices, sizes);
   VERIFY_IS_EQUAL(slice1(0,0,0,0,0), tensor(1,2,3,4,5));
 
   Tensor slice2(1,1,2,2,3);
-  Eigen::DSizes indices2(1,1,3,4,5);
-  Eigen::DSizes sizes2(1,1,2,2,3);
+  StormEigen::DSizes indices2(1,1,3,4,5);
+  StormEigen::DSizes sizes2(1,1,2,2,3);
   slice2 = tensor.slice(indices2, sizes2);
   for (int i = 0; i < 2; ++i) {
     for (int j = 0; j < 2; ++j) {
@@ -140,10 +140,10 @@ static void test_slice_in_expr() {
   typedef Tensor::DimensionPair DimPair;
   array contract_along{{DimPair(1, 0)}};
 
-  Eigen::DSizes indices1(1,2);
-  Eigen::DSizes sizes1(3,3);
-  Eigen::DSizes indices2(0,2);
-  Eigen::DSizes sizes2(3,1);
+  StormEigen::DSizes indices1(1,2);
+  StormEigen::DSizes sizes1(3,3);
+  StormEigen::DSizes indices2(0,2);
+  StormEigen::DSizes sizes2(3,1);
   tensor3 = tensor1.slice(indices1, sizes1).contract(tensor2.slice(indices2, sizes2), contract_along);
 
   Map res(tensor3.data(), 3, 1);
@@ -176,18 +176,18 @@ static void test_slice_as_lvalue()
   tensor5.setRandom();
 
   Tensor result(4,5,7);
-  Eigen::DSizes sizes12(2,2,7);
-  Eigen::DSizes first_slice(0,0,0);
+  StormEigen::DSizes sizes12(2,2,7);
+  StormEigen::DSizes first_slice(0,0,0);
   result.slice(first_slice, sizes12) = tensor1;
-  Eigen::DSizes second_slice(2,0,0);
-  result.slice(second_slice, sizes12).device(Eigen::DefaultDevice()) = tensor2;
+  StormEigen::DSizes second_slice(2,0,0);
+  result.slice(second_slice, sizes12).device(StormEigen::DefaultDevice()) = tensor2;
 
-  Eigen::DSizes sizes3(4,3,5);
-  Eigen::DSizes third_slice(0,2,0);
+  StormEigen::DSizes sizes3(4,3,5);
+  StormEigen::DSizes third_slice(0,2,0);
   result.slice(third_slice, sizes3) = tensor3;
 
-  Eigen::DSizes sizes4(4,3,2);
-  Eigen::DSizes fourth_slice(0,2,5);
+  StormEigen::DSizes sizes4(4,3,2);
+  StormEigen::DSizes fourth_slice(0,2,5);
   result.slice(fourth_slice, sizes4) = tensor4;
 
   for (int j = 0; j < 2; ++j) {
@@ -209,8 +209,8 @@ static void test_slice_as_lvalue()
     }
   }
 
-  Eigen::DSizes sizes5(4,5,7);
-  Eigen::DSizes fifth_slice(0,0,0);
+  StormEigen::DSizes sizes5(4,5,7);
+  StormEigen::DSizes fifth_slice(0,0,0);
   result.slice(fifth_slice, sizes5) = tensor5.slice(fifth_slice, sizes5);
   for (int i = 0; i < 4; ++i) {
     for (int j = 2; j < 5; ++j) {
@@ -227,35 +227,35 @@ static void test_slice_raw_data()
   Tensor tensor(3,5,7,11);
   tensor.setRandom();
 
-  Eigen::DSizes offsets(1,2,3,4);
-  Eigen::DSizes extents(1,1,1,1);
+  StormEigen::DSizes offsets(1,2,3,4);
+  StormEigen::DSizes extents(1,1,1,1);
   typedef TensorEvaluator SliceEvaluator;
   auto slice1 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
   VERIFY_IS_EQUAL(slice1.dimensions().TotalSize(), 1);
   VERIFY_IS_EQUAL(slice1.data()[0], tensor(1,2,3,4));
 
   if (DataLayout == ColMajor) {
-    extents = Eigen::DSizes(2,1,1,1);
+    extents = StormEigen::DSizes(2,1,1,1);
     auto slice2 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
     VERIFY_IS_EQUAL(slice2.dimensions().TotalSize(), 2);
     VERIFY_IS_EQUAL(slice2.data()[0], tensor(1,2,3,4));
     VERIFY_IS_EQUAL(slice2.data()[1], tensor(2,2,3,4));
   } else {
-    extents = Eigen::DSizes(1,1,1,2);
+    extents = StormEigen::DSizes(1,1,1,2);
     auto slice2 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
     VERIFY_IS_EQUAL(slice2.dimensions().TotalSize(), 2);
     VERIFY_IS_EQUAL(slice2.data()[0], tensor(1,2,3,4));
     VERIFY_IS_EQUAL(slice2.data()[1], tensor(1,2,3,5));
   }
 
-  extents = Eigen::DSizes(1,2,1,1);
+  extents = StormEigen::DSizes(1,2,1,1);
   auto slice3 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
   VERIFY_IS_EQUAL(slice3.dimensions().TotalSize(), 2);
   VERIFY_IS_EQUAL(slice3.data(), static_cast(0));
 
   if (DataLayout == ColMajor) {
-    offsets = Eigen::DSizes(0,2,3,4);
-    extents = Eigen::DSizes(3,2,1,1);
+    offsets = StormEigen::DSizes(0,2,3,4);
+    extents = StormEigen::DSizes(3,2,1,1);
     auto slice4 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
     VERIFY_IS_EQUAL(slice4.dimensions().TotalSize(), 6);
     for (int i = 0; i < 3; ++i) {
@@ -264,8 +264,8 @@ static void test_slice_raw_data()
       }
     }
   } else {
-    offsets = Eigen::DSizes(1,2,3,0);
-    extents = Eigen::DSizes(1,1,2,11);
+    offsets = StormEigen::DSizes(1,2,3,0);
+    extents = StormEigen::DSizes(1,1,2,11);
     auto slice4 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
     VERIFY_IS_EQUAL(slice4.dimensions().TotalSize(), 22);
     for (int l = 0; l < 11; ++l) {
@@ -276,8 +276,8 @@ static void test_slice_raw_data()
   }
 
   if (DataLayout == ColMajor) {
-    offsets = Eigen::DSizes(0,0,0,4);
-    extents = Eigen::DSizes(3,5,7,2);
+    offsets = StormEigen::DSizes(0,0,0,4);
+    extents = StormEigen::DSizes(3,5,7,2);
     auto slice5 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
     VERIFY_IS_EQUAL(slice5.dimensions().TotalSize(), 210);
     for (int i = 0; i < 3; ++i) {
@@ -291,8 +291,8 @@ static void test_slice_raw_data()
       }
     }
   } else {
-    offsets = Eigen::DSizes(1,0,0,0);
-    extents = Eigen::DSizes(2,5,7,11);
+    offsets = StormEigen::DSizes(1,0,0,0);
+    extents = StormEigen::DSizes(2,5,7,11);
     auto slice5 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
     VERIFY_IS_EQUAL(slice5.dimensions().TotalSize(), 770);
     for (int l = 0; l < 11; ++l) {
@@ -308,8 +308,8 @@ static void test_slice_raw_data()
 
   }
 
-  offsets = Eigen::DSizes(0,0,0,0);
-  extents = Eigen::DSizes(3,5,7,11);
+  offsets = StormEigen::DSizes(0,0,0,0);
+  extents = StormEigen::DSizes(3,5,7,11);
   auto slice6 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
   VERIFY_IS_EQUAL(slice6.dimensions().TotalSize(), 3*5*7*11);
   VERIFY_IS_EQUAL(slice6.data(), tensor.data());
@@ -318,11 +318,11 @@ static void test_slice_raw_data()
 template
 static void test_composition()
 {
-  Eigen::Tensor matrix(7, 11);
+  StormEigen::Tensor matrix(7, 11);
   matrix.setRandom();
 
   const DSizes newDims(1, 1, 11);
-  Eigen::Tensor tensor =
+  StormEigen::Tensor tensor =
       matrix.slice(DSizes(2, 0), DSizes(1, 11)).reshape(newDims);
 
   VERIFY_IS_EQUAL(tensor.dimensions().TotalSize(), 11);
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_of_complex.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_of_complex.cpp
index 8ad04f699..c8f156764 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_of_complex.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_of_complex.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::TensorMap;
+using StormEigen::Tensor;
+using StormEigen::TensorMap;
 
 
 
@@ -64,7 +64,7 @@ static void test_contractions()
 
   // This contraction should be equivalent to a regular matrix multiplication
   typedef Tensor::DimensionPair DimPair;
-  Eigen::array dims({{DimPair(2, 0), DimPair(3, 1)}});
+  StormEigen::array dims({{DimPair(2, 0), DimPair(3, 1)}});
   t_result = t_left.contract(t_right, dims);
   m_result = m_left * m_right;
   for (int i = 0; i < t_result.dimensions().TotalSize(); i++) {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_of_const_values.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_of_const_values.cpp
index f179a0c21..aaf69def3 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_of_const_values.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_of_const_values.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::RowMajor;
+using StormEigen::Tensor;
+using StormEigen::RowMajor;
 
 static void test_assign()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_of_strings.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_of_strings.cpp
index 4ef9aed91..81465698a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_of_strings.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_of_strings.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::TensorMap;
+using StormEigen::Tensor;
+using StormEigen::TensorMap;
 
 static void test_assign()
 {
@@ -94,9 +94,9 @@ static void test_slices()
     }
   }
 
-  const Eigen::DSizes half_size(2, 3);
-  const Eigen::DSizes first_half(0, 0);
-  const Eigen::DSizes second_half(0, 3);
+  const StormEigen::DSizes half_size(2, 3);
+  const StormEigen::DSizes first_half(0, 0);
+  const StormEigen::DSizes second_half(0, 3);
 
   Tensor t1 = data.slice(first_half, half_size);
   Tensor t2 = data.slice(second_half, half_size);
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_padding.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_padding.cpp
index ffa19896e..8b4460c5b 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_padding.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_padding.cpp
@@ -11,7 +11,7 @@
 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 template
 static void test_simple_padding()
@@ -60,7 +60,7 @@ static void test_padded_expr()
   paddings[2] = std::make_pair(3, 4);
   paddings[3] = std::make_pair(0, 0);
 
-  Eigen::DSizes reshape_dims;
+  StormEigen::DSizes reshape_dims;
   reshape_dims[0] = 12;
   reshape_dims[1] = 84;
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_patch.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_patch.cpp
index 434359730..82e36b462 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_patch.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_patch.cpp
@@ -11,7 +11,7 @@
 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 template
 static void test_simple_patch()
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_random.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_random.cpp
index 389896c54..b583f3460 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_random.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_random.cpp
@@ -26,7 +26,7 @@ static void test_default()
 static void test_normal()
 {
   Tensor vec(6);
-  vec.setRandom>();
+  vec.setRandom>();
 
   // Fixme: we should check that the generated numbers follow a gaussian
   // distribution instead.
@@ -43,13 +43,13 @@ struct MyGenerator {
   // Return a random value to be used.  "element_location" is the
   // location of the entry to set in the tensor, it can typically
   // be ignored.
-  int operator()(Eigen::DenseIndex element_location, Eigen::DenseIndex /*unused*/ = 0) const {
+  int operator()(StormEigen::DenseIndex element_location, StormEigen::DenseIndex /*unused*/ = 0) const {
     return static_cast(3 * element_location);
   }
 
   // Same as above but generates several numbers at a time.
   typename internal::packet_traits::type packetOp(
-      Eigen::DenseIndex packet_location, Eigen::DenseIndex /*unused*/ = 0) const {
+      StormEigen::DenseIndex packet_location, StormEigen::DenseIndex /*unused*/ = 0) const {
     const int packetSize = internal::packet_traits::size;
     EIGEN_ALIGN_MAX int values[packetSize];
     for (int i = 0; i < packetSize; ++i) {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_reduction.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_reduction.cpp
index 0ec316991..43315283f 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_reduction.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_reduction.cpp
@@ -11,7 +11,7 @@
 #include 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 template 
 static void test_trivial_reductions() {
@@ -345,7 +345,7 @@ static void test_static_dims() {
   reduction_axis[0] = 1;
   reduction_axis[1] = 3;
 #else
-  Eigen::IndexList, Eigen::type2index<3> > reduction_axis;
+  StormEigen::IndexList, Eigen::type2index<3> > reduction_axis;
 #endif
 
   out = in.maximum(reduction_axis);
@@ -376,7 +376,7 @@ static void test_innermost_last_dims() {
   reduction_axis[1] = 1;
 #else
   // This triggers the use of packets for ColMajor.
-  Eigen::IndexList, Eigen::type2index<1> > reduction_axis;
+  StormEigen::IndexList, Eigen::type2index<1> > reduction_axis;
 #endif
 
   out = in.maximum(reduction_axis);
@@ -407,7 +407,7 @@ static void test_innermost_first_dims() {
   reduction_axis[1] = 3;
 #else
   // This triggers the use of packets for RowMajor.
-  Eigen::IndexList, Eigen::type2index<3>> reduction_axis;
+  StormEigen::IndexList, Eigen::type2index<3>> reduction_axis;
 #endif
 
   out = in.maximum(reduction_axis);
@@ -438,7 +438,7 @@ static void test_reduce_middle_dims() {
   reduction_axis[1] = 2;
 #else
   // This triggers the use of packets for RowMajor.
-  Eigen::IndexList, Eigen::type2index<2>> reduction_axis;
+  StormEigen::IndexList, Eigen::type2index<2>> reduction_axis;
 #endif
 
   out = in.maximum(reduction_axis);
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_reduction_cuda.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_reduction_cuda.cpp
index 9e06eb126..18d607c77 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_reduction_cuda.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_reduction_cuda.cpp
@@ -19,8 +19,8 @@
 template
 static void test_full_reductions() {
 
-  Eigen::CudaStreamDevice stream;
-  Eigen::GpuDevice gpu_device(&stream);
+  StormEigen::CudaStreamDevice stream;
+  StormEigen::GpuDevice gpu_device(&stream);
 
   const int num_rows = internal::random(1024, 5*1024);
   const int num_cols = internal::random(1024, 5*1024);
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_ref.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_ref.cpp
index c8f105e3d..a8bc4eec0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_ref.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_ref.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::RowMajor;
+using StormEigen::Tensor;
+using StormEigen::RowMajor;
 
 static void test_simple_lvalue_ref()
 {
@@ -93,13 +93,13 @@ static void test_slice()
   Tensor tensor(2,3,5,7,11);
   tensor.setRandom();
 
-  Eigen::DSizes indices(1,2,3,4,5);
-  Eigen::DSizes sizes(1,1,1,1,1);
+  StormEigen::DSizes indices(1,2,3,4,5);
+  StormEigen::DSizes sizes(1,1,1,1,1);
   TensorRef> slice = tensor.slice(indices, sizes);
   VERIFY_IS_EQUAL(slice(0,0,0,0,0), tensor(1,2,3,4,5));
 
-  Eigen::DSizes indices2(1,1,3,4,5);
-  Eigen::DSizes sizes2(1,1,2,2,3);
+  StormEigen::DSizes indices2(1,1,3,4,5);
+  StormEigen::DSizes sizes2(1,1,2,2,3);
   slice = tensor.slice(indices2, sizes2);
   for (int i = 0; i < 2; ++i) {
     for (int j = 0; j < 2; ++j) {
@@ -109,8 +109,8 @@ static void test_slice()
     }
   }
 
-  Eigen::DSizes indices3(0,0,0,0,0);
-  Eigen::DSizes sizes3(2,3,1,1,1);
+  StormEigen::DSizes indices3(0,0,0,0,0);
+  StormEigen::DSizes sizes3(2,3,1,1,1);
   slice = tensor.slice(indices3, sizes3);
   VERIFY_IS_EQUAL(slice.data(), tensor.data());
 }
@@ -206,7 +206,7 @@ static void test_nested_ops_with_ref()
   paddings[1] = std::make_pair(2, 1);
   paddings[2] = std::make_pair(3, 4);
   paddings[3] = std::make_pair(0, 0);
-  DSizes shuffle_dims(0, 1, 2, 3);
+  DSizes shuffle_dims(0, 1, 2, 3);
   TensorRef > ref(m.pad(paddings));
   array, 4> trivial;
   trivial[0] = std::make_pair(0, 0);
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_reverse.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_reverse.cpp
index b35b8d29e..d8547bfd2 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_reverse.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_reverse.cpp
@@ -12,8 +12,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::array;
+using StormEigen::Tensor;
+using StormEigen::array;
 
 template 
 static void test_simple_reverse()
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_shuffling.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_shuffling.cpp
index d11444a14..f7f553bdc 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_shuffling.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_shuffling.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::array;
+using StormEigen::Tensor;
+using StormEigen::array;
 
 template 
 static void test_simple_shuffling()
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_simple.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_simple.cpp
index 47d4d8636..a25e4dd2d 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_simple.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_simple.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::RowMajor;
+using StormEigen::Tensor;
+using StormEigen::RowMajor;
 
 static void test_0d()
 {
@@ -195,7 +195,7 @@ static void test_3d()
   VERIFY_IS_EQUAL((epsilon(0,2,1)), -1);
   VERIFY_IS_EQUAL((epsilon(1,0,2)), -1);
 
-  array dims{{2,3,4}};
+  array dims{{2,3,4}};
   Tensor t1(dims);
   Tensor t2(dims);
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_striding.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_striding.cpp
index 935b908cc..c26df4f55 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_striding.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_striding.cpp
@@ -11,7 +11,7 @@
 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 template
 static void test_simple_striding()
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_sugar.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_sugar.cpp
index adac472cf..d7a0b33bd 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_sugar.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_sugar.cpp
@@ -2,8 +2,8 @@
 
 #include 
 
-using Eigen::Tensor;
-using Eigen::RowMajor;
+using StormEigen::Tensor;
+using StormEigen::RowMajor;
 
 static void test_comparison_sugar() {
   // we already trust comparisons between tensors, we're simply checking that
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_symmetry.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_symmetry.cpp
index d680e9b3b..886e4cd33 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_symmetry.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_symmetry.cpp
@@ -15,20 +15,20 @@
 #include 
 #include 
 
-using Eigen::Tensor;
-using Eigen::SGroup;
-using Eigen::DynamicSGroup;
-using Eigen::StaticSGroup;
-using Eigen::Symmetry;
-using Eigen::AntiSymmetry;
-using Eigen::Hermiticity;
-using Eigen::AntiHermiticity;
-
-using Eigen::NegationFlag;
-using Eigen::ConjugationFlag;
-using Eigen::GlobalZeroFlag;
-using Eigen::GlobalRealFlag;
-using Eigen::GlobalImagFlag;
+using StormEigen::Tensor;
+using StormEigen::SGroup;
+using StormEigen::DynamicSGroup;
+using StormEigen::StaticSGroup;
+using StormEigen::Symmetry;
+using StormEigen::AntiSymmetry;
+using StormEigen::Hermiticity;
+using StormEigen::AntiHermiticity;
+
+using StormEigen::NegationFlag;
+using StormEigen::ConjugationFlag;
+using StormEigen::GlobalZeroFlag;
+using StormEigen::GlobalRealFlag;
+using StormEigen::GlobalImagFlag;
 
 // helper function to determine if the compiler intantiated a static
 // or dynamic symmetry group
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_thread_pool.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_thread_pool.cpp
index e28cf55e2..7ea037a71 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_thread_pool.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_thread_pool.cpp
@@ -14,7 +14,7 @@
 #include 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 
 static void test_multithread_elementwise()
@@ -26,8 +26,8 @@ static void test_multithread_elementwise()
   in1.setRandom();
   in2.setRandom();
 
-  Eigen::ThreadPool tp(internal::random(3, 11));
-  Eigen::ThreadPoolDevice thread_pool_device(&tp, internal::random(3, 11));
+  StormEigen::ThreadPool tp(internal::random(3, 11));
+  StormEigen::ThreadPoolDevice thread_pool_device(&tp, internal::random(3, 11));
   out.device(thread_pool_device) = in1 + in2 * 3.14f;
 
   for (int i = 0; i < 2; ++i) {
@@ -49,8 +49,8 @@ static void test_multithread_compound_assignment()
   in1.setRandom();
   in2.setRandom();
 
-  Eigen::ThreadPool tp(internal::random(3, 11));
-  Eigen::ThreadPoolDevice thread_pool_device(&tp, internal::random(3, 11));
+  StormEigen::ThreadPool tp(internal::random(3, 11));
+  StormEigen::ThreadPoolDevice thread_pool_device(&tp, internal::random(3, 11));
   out.device(thread_pool_device) = in1;
   out.device(thread_pool_device) += in2 * 3.14f;
 
@@ -75,15 +75,15 @@ static void test_multithread_contraction()
 
   // this contraction should be equivalent to a single matrix multiplication
   typedef Tensor::DimensionPair DimPair;
-  Eigen::array dims({{DimPair(2, 0), DimPair(3, 1)}});
+  StormEigen::array dims({{DimPair(2, 0), DimPair(3, 1)}});
 
   typedef Map> MapXf;
   MapXf m_left(t_left.data(), 1500, 1147);
   MapXf m_right(t_right.data(), 1147, 1400);
   Matrix m_result(1500, 1400);
 
-  Eigen::ThreadPool tp(4);
-  Eigen::ThreadPoolDevice thread_pool_device(&tp, 4);
+  StormEigen::ThreadPool tp(4);
+  StormEigen::ThreadPoolDevice thread_pool_device(&tp, 4);
 
   // compute results by separate methods
   t_result.device(thread_pool_device) = t_left.contract(t_right, dims);
@@ -111,15 +111,15 @@ static void test_contraction_corner_cases()
 
   // this contraction should be equivalent to a single matrix multiplication
   typedef Tensor::DimensionPair DimPair;
-  Eigen::array dims{{DimPair(0, 0)}};
+  StormEigen::array dims{{DimPair(0, 0)}};
 
   typedef Map> MapXf;
   MapXf m_left(t_left.data(), 32, 500);
   MapXf m_right(t_right.data(), 32, 28*28);
   Matrix m_result(500, 28*28);
 
-  Eigen::ThreadPool tp(12);
-  Eigen::ThreadPoolDevice thread_pool_device(&tp, 12);
+  StormEigen::ThreadPool tp(12);
+  StormEigen::ThreadPoolDevice thread_pool_device(&tp, 12);
 
   // compute results by separate methods
   t_result.device(thread_pool_device) = t_left.contract(t_right, dims);
@@ -206,10 +206,10 @@ static void test_multithread_contraction_agrees_with_singlethread() {
   right += right.constant(1.5f);
 
   typedef Tensor::DimensionPair DimPair;
-  Eigen::array dims({{DimPair(1, 2)}});
+  StormEigen::array dims({{DimPair(1, 2)}});
 
-  Eigen::ThreadPool tp(internal::random(2, 11));
-  Eigen::ThreadPoolDevice thread_pool_device(&tp, internal::random(2, 11));
+  StormEigen::ThreadPool tp(internal::random(2, 11));
+  StormEigen::ThreadPoolDevice thread_pool_device(&tp, internal::random(2, 11));
 
   Tensor st_result;
   st_result = left.contract(right, dims);
@@ -232,7 +232,7 @@ template
 static void test_multithreaded_reductions() {
   const int num_threads = internal::random(3, 11);
   ThreadPool thread_pool(num_threads);
-  Eigen::ThreadPoolDevice thread_pool_device(&thread_pool, num_threads);
+  StormEigen::ThreadPoolDevice thread_pool_device(&thread_pool, num_threads);
 
   const int num_rows = internal::random(13, 732);
   const int num_cols = internal::random(13, 732);
@@ -255,8 +255,8 @@ static void test_memcpy() {
 
   for (int i = 0; i < 5; ++i) {
     const int num_threads = internal::random(3, 11);
-    Eigen::ThreadPool tp(num_threads);
-    Eigen::ThreadPoolDevice thread_pool_device(&tp, num_threads);
+    StormEigen::ThreadPool tp(num_threads);
+    StormEigen::ThreadPoolDevice thread_pool_device(&tp, num_threads);
 
     const int size = internal::random(13, 7632);
     Tensor t1(size);
@@ -272,10 +272,10 @@ static void test_memcpy() {
 
 static void test_multithread_random()
 {
-  Eigen::ThreadPool tp(2);
-  Eigen::ThreadPoolDevice device(&tp, 2);
+  StormEigen::ThreadPool tp(2);
+  StormEigen::ThreadPoolDevice device(&tp, 2);
   Tensor t(1 << 20);
-  t.device(device) = t.random>();
+  t.device(device) = t.random>();
 }
 
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_uint128.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_uint128.cpp
index ee3767e58..1713138c0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_uint128.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_uint128.cpp
@@ -11,8 +11,8 @@
 
 #include 
 
-using Eigen::internal::TensorUInt128;
-using Eigen::internal::static_val;
+using StormEigen::internal::TensorUInt128;
+using StormEigen::internal::static_val;
 
 void VERIFY_EQUAL(TensorUInt128 actual, __uint128_t expected) {
   bool matchl = actual.lower() == static_cast(expected);
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_volume_patch.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_volume_patch.cpp
index ca6840f3b..ed678c5e0 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_volume_patch.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/cxx11_tensor_volume_patch.cpp
@@ -2,7 +2,7 @@
 
 #include 
 
-using Eigen::Tensor;
+using StormEigen::Tensor;
 
 static void test_single_voxel_patch()
 {
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/kronecker_product.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/kronecker_product.cpp
index 02411a262..6fcce753e 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/kronecker_product.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/kronecker_product.cpp
@@ -186,11 +186,11 @@ void test_kronecker_product()
   
   for(int i = 0; i < g_repeat; i++)
   {
-    double density = Eigen::internal::random(0.01,0.5);
-    int ra = Eigen::internal::random(1,50);
-    int ca = Eigen::internal::random(1,50);
-    int rb = Eigen::internal::random(1,50);
-    int cb = Eigen::internal::random(1,50);
+    double density = StormEigen::internal::random(0.01,0.5);
+    int ra = StormEigen::internal::random(1,50);
+    int ca = StormEigen::internal::random(1,50);
+    int rb = StormEigen::internal::random(1,50);
+    int cb = StormEigen::internal::random(1,50);
     SparseMatrix sA(ra,ca), sB(rb,cb), sC;
     SparseMatrix sC2;
     MatrixXf dA(ra,ca), dB(rb,cb), dC;
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/mpreal_support.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/mpreal_support.cpp
index 1aa9e786a..7e2b9e2bf 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/mpreal_support.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/mpreal_support.cpp
@@ -5,13 +5,13 @@
 #include 
 
 using namespace mpfr;
-using namespace Eigen;
+using namespace StormEigen;
 
 void test_mpreal_support()
 {
   // set precision to 256 bits (double has only 53 bits)
   mpreal::set_default_prec(256);
-  typedef Matrix MatrixXmp;
+  typedef Matrix MatrixXmp;
 
   std::cerr << "epsilon =         " << NumTraits::epsilon() << "\n";
   std::cerr << "dummy_precision = " << NumTraits::dummy_precision() << "\n";
@@ -19,7 +19,7 @@ void test_mpreal_support()
   std::cerr << "lowest =          " << NumTraits::lowest() << "\n";
 
   for(int i = 0; i < g_repeat; i++) {
-    int s = Eigen::internal::random(1,100);
+    int s = StormEigen::internal::random(1,100);
     MatrixXmp A = MatrixXmp::Random(s,s);
     MatrixXmp B = MatrixXmp::Random(s,s);
     MatrixXmp S = A.adjoint() * A;
@@ -27,7 +27,7 @@ void test_mpreal_support()
     
     // Basic stuffs
     VERIFY_IS_APPROX(A.real(), A);
-    VERIFY(Eigen::internal::isApprox(A.array().abs2().sum(), A.squaredNorm()));
+    VERIFY(StormEigen::internal::isApprox(A.array().abs2().sum(), A.squaredNorm()));
     VERIFY_IS_APPROX(A.array().exp(),         exp(A.array()));
     VERIFY_IS_APPROX(A.array().abs2().sqrt(), A.array().abs());
     VERIFY_IS_APPROX(A.array().sin(),         sin(A.array()));
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/openglsupport.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/openglsupport.cpp
index 706a816f7..634e12eb8 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/openglsupport.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/openglsupport.cpp
@@ -12,7 +12,7 @@
 #include 
 #include 
 #include 
-using namespace Eigen;
+using namespace StormEigen;
 
 
 
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/polynomialsolver.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/polynomialsolver.cpp
index 0c87478dd..09291c20a 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/polynomialsolver.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/polynomialsolver.cpp
@@ -14,7 +14,7 @@
 
 using namespace std;
 
-namespace Eigen {
+namespace StormEigen {
 namespace internal {
 template
 struct increment_if_fixed_size
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/polynomialutils.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/polynomialutils.cpp
index 5fc968402..a1faf9991 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/polynomialutils.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/polynomialutils.cpp
@@ -13,7 +13,7 @@
 
 using namespace std;
 
-namespace Eigen {
+namespace StormEigen {
 namespace internal {
 template
 struct increment_if_fixed_size
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/sparse_extra.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/sparse_extra.cpp
index a010ceb93..daac80785 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/sparse_extra.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/sparse_extra.cpp
@@ -118,7 +118,7 @@ template void sparse_extra(const SparseMatrixType& re
     DenseMatrix refM1 = DenseMatrix::Zero(rows, rows);
     initSparse(density, refM1, m1);
     {
-      Eigen::RandomSetter setter(m2);
+      StormEigen::RandomSetter setter(m2);
       for (int j=0; j void sparse_extra(const SparseMatrixType& re
 void test_sparse_extra()
 {
   for(int i = 0; i < g_repeat; i++) {
-    int s = Eigen::internal::random(1,50);
+    int s = StormEigen::internal::random(1,50);
     CALL_SUBTEST_1( sparse_extra(SparseMatrix(8, 8)) );
     CALL_SUBTEST_2( sparse_extra(SparseMatrix >(s, s)) );
     CALL_SUBTEST_1( sparse_extra(SparseMatrix(s, s)) );
diff --git a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/splines.cpp b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/splines.cpp
index 97665af96..b14153dc9 100644
--- a/resources/3rdparty/eigen-3.3-beta1/unsupported/test/splines.cpp
+++ b/resources/3rdparty/eigen-3.3-beta1/unsupported/test/splines.cpp
@@ -11,7 +11,7 @@
 
 #include 
 
-namespace Eigen {
+namespace StormEigen {
   
   // lets do some explicit instantiations and thus
   // force the compilation of all spline functions...
@@ -207,13 +207,13 @@ void check_global_interpolation2d()
   ControlPointVectorType points = ControlPointVectorType::Random(2,100);
 
   KnotVectorType chord_lengths; // knot parameters
-  Eigen::ChordLengths(points, chord_lengths);
+  StormEigen::ChordLengths(points, chord_lengths);
 
   // interpolation without knot parameters
   {
     const Spline2d spline = SplineFitting::Interpolate(points,3);  
 
-    for (Eigen::DenseIndex i=0; i::Interpolate(points,3,chord_lengths);  
 
-    for (Eigen::DenseIndex i=0; i(i);
 
   const Spline2d spline = SplineFitting::InterpolateWithDerivatives(
     points, derivatives, derivativeIndices, degree);  
     
-  for (Eigen::DenseIndex i = 0; i < points.cols(); ++i)
+  for (StormEigen::DenseIndex i = 0; i < points.cols(); ++i)
   {
     PointType point = spline(knots(i));
     PointType referencePoint = points.col(i);
diff --git a/resources/3rdparty/include_cudd.cmake b/resources/3rdparty/include_cudd.cmake
index 731758830..1c03de839 100644
--- a/resources/3rdparty/include_cudd.cmake
+++ b/resources/3rdparty/include_cudd.cmake
@@ -16,6 +16,11 @@ endif()
 
 set(CUDD_LIB_DIR ${STORM_3RDPARTY_BINARY_DIR}/cudd-3.0.0/lib)
 
+set(STORM_CUDD_FLAGS "CFLAGS=-O3 -w -DPIC -DHAVE_IEEE_754 -fno-common -ffast-math -fno-finite-math-only")
+if (NOT STORM_PORTABLE_RELEASE)
+	set(STORM_CUDD_FLAGS "${STORM_CUDD_FLAGS} -march=native")
+endif()
+
 ExternalProject_Add(
         cudd3
         DOWNLOAD_COMMAND ""
@@ -23,7 +28,7 @@ ExternalProject_Add(
         PREFIX ${STORM_3RDPARTY_BINARY_DIR}/cudd-3.0.0
         PATCH_COMMAND ${AUTORECONF}
         CONFIGURE_COMMAND ${STORM_3RDPARTY_SOURCE_DIR}/cudd-3.0.0/configure --enable-shared --enable-obj --with-pic=yes --prefix=${STORM_3RDPARTY_BINARY_DIR}/cudd-3.0.0 --libdir=${CUDD_LIB_DIR} CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER}
-        BUILD_COMMAND make "CFLAGS=-O2 -w"
+        BUILD_COMMAND make ${STORM_CUDD_FLAGS}
         INSTALL_COMMAND make install
         BUILD_IN_SOURCE 0
         LOG_CONFIGURE ON
@@ -49,4 +54,4 @@ else()
     list(APPEND STORM_DEP_TARGETS cudd_STATIC)
 endif()
 
-message(STATUS "Storm - Linking with CUDD ${CUDD_VERSION_STRING}.")
\ No newline at end of file
+message(STATUS "Storm - Linking with CUDD ${CUDD_VERSION_STRING}.")
diff --git a/resources/3rdparty/include_xerces.cmake b/resources/3rdparty/include_xerces.cmake
index 834f697d2..4a464835d 100644
--- a/resources/3rdparty/include_xerces.cmake
+++ b/resources/3rdparty/include_xerces.cmake
@@ -4,28 +4,28 @@ if(USE_XERCESC)
         message(STATUS "Storm - Use system version of xerces.")
     else()
         message(STATUS "Storm - Use shipped version of xerces.")
-        set(XERCESC_LIB_DIR ${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2/lib)
+        set(XercesC_LIB_DIR ${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2/lib)
         ExternalProject_Add(
                 xercesc
                 SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/xercesc-3.1.2
-                CONFIGURE_COMMAND ${STORM_3RDPARTY_SOURCE_DIR}/xercesc-3.1.2/configure --prefix=${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2 --libdir=${XERCESC_LIB_DIR} CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} CFLAGS=-O3 CXXFLAGS=-O3
+                CONFIGURE_COMMAND ${STORM_3RDPARTY_SOURCE_DIR}/xercesc-3.1.2/configure --prefix=${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2 --libdir=${XercesC_LIB_DIR} CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} CFLAGS=-O3 CXXFLAGS=-O3
                 PREFIX ${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2
                 BUILD_COMMAND make
                 BUILD_IN_SOURCE 0
                 LOG_CONFIGURE ON
                 LOG_BUILD ON
                 LOG_INSTALL ON
-                BUILD_BYPRODUCTS ${XERCESC_LIB_DIR}/libxerces-c${DYNAMIC_EXT} ${XERCESC_LIB_DIR}/libxerces-c${STATIC_EXT}
+                BUILD_BYPRODUCTS ${XercesC_LIB_DIR}/libxerces-c${DYNAMIC_EXT} ${XercesC_LIB_DIR}/libxerces-c${STATIC_EXT}
         )
 
-        set(XERCESC_ROOT ${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2)
-        set(XercesC_INCLUDE_DIRS ${XERCESC_ROOT}/include)
-        set(XERCESC_LIBRARY_PATH ${XERCESC_LIB_DIR})
+        set(XercesC_ROOT ${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2)
+        set(XercesC_INCLUDE_DIRS ${XercesC_ROOT}/include)
+        set(XercesC_LIBRARY_PATH ${XercesC_LIB_DIR})
 
         if(BUILD_STATIC)
-            set(XercesC_LIBRARIES ${XERCESC_LIBRARY_PATH}/libxerces-c${STATIC_EXT})
+            set(XercesC_LIBRARIES ${XercesC_LIBRARY_PATH}/libxerces-c${STATIC_EXT})
         else()
-            set(XercesC_LIBRARIES ${XERCESC_LIBRARY_PATH}/libxerces-c${DYNAMIC_EXT})
+            set(XercesC_LIBRARIES ${XercesC_LIBRARY_PATH}/libxerces-c${DYNAMIC_EXT})
         endif()
 
         add_dependencies(resources xercesc)
@@ -40,8 +40,9 @@ if(USE_XERCESC)
 		mark_as_advanced(COREFOUNDATION_LIBRARY)
 		mark_as_advanced(CORESERVICES_LIBRARY)
     endif()
-    find_package(CURL)
+    # find_package(CURL)
     list(APPEND STORM_GSPN_LINK_LIBRARIES ${XercesC_LIBRARIES} ${COREFOUNDATION_LIBRARY} ${CORESERVICES_LIBRARY} ${CURL_LIBRARIES})
 else()
+    set(STORM_HAVE_XERCES OFF)
     message (WARNING "Storm - Building without Xerces disables parsing XML formats (for GSPNs)")
 endif(USE_XERCESC)
diff --git a/resources/3rdparty/include_xerces.cmake.save b/resources/3rdparty/include_xerces.cmake.save
deleted file mode 100644
index e69de29bb..000000000
diff --git a/resources/3rdparty/include_xerces.cmake.save.1 b/resources/3rdparty/include_xerces.cmake.save.1
deleted file mode 100644
index 4480844f5..000000000
--- a/resources/3rdparty/include_xerces.cmake.save.1
+++ /dev/null
@@ -1,49 +0,0 @@
-if(USE_XERCESC)
-	set(XERCESC_FIND_QUIETLY ON)
-    set(XERCESC_STATIC OFF)
-    find_package(XercesC QUIET REQUIRED)
-    if(XERCESC_FOUND)
-        message(STATUS "Storm - Use system version of xerces.")
-    else()
-        message(STATUS "Storm - Use shipped version of xerces.")
-        set(XERCESC_LIB_DIR ${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2/lib)
-        ExternalProject_Add(
-                xercesc
-                SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/xercesc-3.1.2
-                CONFIGURE_COMMAND ${STORM_3RDPARTY_SOURCE_DIR}/xercesc-3.1.2/configure --prefix=${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2 --libdir=${XERCESC_LIB_DIR} CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} CFLAGS=-O3 CXXFLAGS=-O3
-                PREFIX ${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2
-                BUILD_COMMAND make
-                BUILD_IN_SOURCE 0
-                LOG_CONFIGURE ON
-                LOG_BUILD ON
-                LOG_INSTALL ON
-                BUILD_BYPRODUCTS ${XERCESC_LIB_DIR}/libxerces-c${DYNAMIC_EXT} ${XERCESC_LIB_DIR}/libxerces-c${STATIC_EXT}
-        )
-
-        set(XERCESC_ROOT ${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2)
-        set(XERCESC_INCLUDE ${XERCESC_ROOT}/include)
-        set(XERCESC_LIBRARY_PATH ${XERCESC_LIB_DIR})
-
-        if(BUILD_STATIC)
-            set(XERCESC_LIBRARIES ${XERCESC_LIBRARY_PATH}/libxerces-c${STATIC_EXT})
-        else()
-            set(XERCESC_LIBRARIES ${XERCESC_LIBRARY_PATH}/libxerces-c${DYNAMIC_EXT})
-        endif()
-
-        add_dependencies(resources xercesc)
-    endif()
-
-    message (STATUS "Storm - Linking with xercesc.")
-    set(STORM_HAVE_XERCES ON)
-    include_directories(${XERCESC_INCLUDE})
-    if(APPLE)
-        FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation )
-        FIND_LIBRARY(CORESERVICES_LIBRARY CoreServices )
-		mark_as_advanced(COREFOUNDATION_LIBRARY)
-		mark_as_advanced(CORESERVICES_LIBRARY)
-    endif()
-    find_package(CURL)
-    list(APPEND STORM_GSPN_LINK_LIBRARIES ${XERCESC_LIBRARIES} ${COREFOUNDATION_LIBRARY} ${CORESERVICES_LIBRARY} ${CURL_LIBRARIES})
-else()
-    message (WARNING "Storm - Building without Xerces disables parsing XML formats (for GSPNs)")
-endif(USE_XERCESC)
diff --git a/resources/3rdparty/sparsepp/README.md b/resources/3rdparty/sparsepp/README.md
index df473bed9..241b116b0 100644
--- a/resources/3rdparty/sparsepp/README.md
+++ b/resources/3rdparty/sparsepp/README.md
@@ -54,6 +54,12 @@ Since the full Sparsepp implementation is contained in a single header file `spa
 
 Optionally, a second header file `spp_utils.h` is provided, which implements only the spp::hash_combine() functionality. This is useful when we want to specify a hash function for a user-defined class in an header file, without including the full `sparsepp.h` header (this is demonstrated in [example 2](#example-2---providing-a-hash-function-for-a-user-defined-class) below).
 
+## Warning - iterator invalidation on erase/insert
+
+1. erasing elements is likely to invalidate iterators (for example when calling `erase()`)
+
+2. inserting new elements is likely to invalidate iterators (iterator invalidation can also happen with std::unordered_map if rehashing occurs due to the insertion)
+
 ## Usage
 
 As shown in the example above, you need to include the header file: `#include `
@@ -80,18 +86,47 @@ namespace spp
 
 These classes provide the same interface as std::unordered_map and std::unordered_set, with the following differences:
 
-- Calls to erase() may invalidate iterators. However, conformant to the C++11 standard, the position and range erase functions return an iterator pointing to the position immediately following the last of the elements erased. This makes it easy to traverse a sparse hash table and delete elements matching a condition. For example to delete odd values:
-
-```c++
-        for (auto it = c.begin(); it != c.end(); )
-        if (it->first % 2 == 1)
-            it = c.erase(it);
-        else
-            ++it;
-```
+- Calls to `erase()` may invalidate iterators. However, conformant to the C++11 standard, the position and range erase functions return an iterator pointing to the position immediately following the last of the elements erased. This makes it easy to traverse a sparse hash table and delete elements matching a condition. For example to delete odd values:
+   
+   ```c++
+   for (auto it = c.begin(); it != c.end(); )
+       if (it->first % 2 == 1)
+          it = c.erase(it);
+       else
+          ++it;
+   ```
+   
+   As for std::unordered_map, the order of the elements that are not erased is preserved.
 
 - Since items are not grouped into buckets, Bucket APIs have been adapted: `max_bucket_count` is equivalent to `max_size`, and `bucket_count` returns the sparsetable size, which is normally at least twice the number of items inserted into the hash_map.
 
+## Integer keys, and other hash function considerations.
+
+1. For basic integer types, sparsepp provides a default hash function which does some mixing of the bits of the keys (see [Integer Hashing](http://burtleburtle.net/bob/hash/integer.html)). This prevents a pathological case where inserted keys are sequential (1, 2, 3, 4, ...), and the lookup on non-present keys becomes very slow. 
+
+   Of course, the user of sparsepp may provide its own hash function,  as shown below:
+   
+   ```c++
+   #include 
+   
+   struct Hash64 {
+       size_t operator()(uint64_t k) const { return (k ^ 14695981039346656037ULL) * 1099511628211ULL; }
+   };
+   
+   struct Hash32 {
+       size_t operator()(uint32_t k) const { return (k ^ 2166136261U)  * 16777619UL; }
+   };
+   
+   int main() 
+   {
+       spp::sparse_hash_map map;
+       ...
+   }
+   
+   ```
+
+2. When the user provides its own hash function, for example when inserting custom classes into a hash map, sometimes the resulting hash keys have similar low order bits and cause many collisions, decreasing the efficiency of the hash map. To address this use case, sparsepp provides an optional 'mixing' of the hash key (see [Integer Hash Function](https://gist.github.com/badboy/6267743) which can be enabled by defining the proprocessor macro: SPP_HASH_MIX. 
+
 ## Example 2 - providing a hash function for a user-defined class
 
 In order to use a sparse_hash_set or sparse_hash_map, a hash function should be provided. Even though a the hash function can be provided via the HashFcn template parameter, we recommend injecting a specialization of `std::hash` for the class into the "std" namespace. For example:
diff --git a/resources/3rdparty/sparsepp/makefile b/resources/3rdparty/sparsepp/makefile
index 3443f0e27..eed3e5bca 100644
--- a/resources/3rdparty/sparsepp/makefile
+++ b/resources/3rdparty/sparsepp/makefile
@@ -7,5 +7,11 @@ test:
 	./spp_test
 
 spp_test: spp_test.cc sparsepp.h makefile
-	$(CXX) -O2 -std=c++0x -D_CRT_SECURE_NO_WARNINGS spp_test.cc -o spp_test
+	$(CXX) -O2 -std=c++0x -Wall -pedantic -Wextra -D_XOPEN_SOURCE=700 -D_CRT_SECURE_NO_WARNINGS spp_test.cc -o spp_test
+
+spp_alloc_test: spp_alloc_test.cc spp_alloc.h spp_bitset.h sparsepp.h makefile
+	$(CXX) -O2 -DNDEBUG  -std=c++11  spp_alloc_test.cc -o spp_alloc_test
+
+perftest1: perftest1.cc sparsepp.h makefile
+	$(CXX) -O2 -DNDEBUG  -std=c++11 perftest1.cc -o perftest1
 
diff --git a/resources/3rdparty/sparsepp/sparsepp.h b/resources/3rdparty/sparsepp/sparsepp.h
index 5706adb0d..8fc36ce47 100644
--- a/resources/3rdparty/sparsepp/sparsepp.h
+++ b/resources/3rdparty/sparsepp/sparsepp.h
@@ -920,6 +920,12 @@ template class HashObject; // for Google's benchmark, not in spp n
     #define SPP_NOEXCEPT noexcept
 #endif
 
+#ifdef SPP_NO_CXX11_CONSTEXPR
+    #define SPP_CONSTEXPR
+#else
+    #define SPP_CONSTEXPR constexpr
+#endif
+
 #define SPP_INLINE
 
 #ifndef SPP_NAMESPACE
@@ -955,75 +961,109 @@ struct spp_hash
 
     SPP_INLINE size_t operator()(const T *__v) const SPP_NOEXCEPT 
     {
-        static const size_t shift = spp_log2(1 + sizeof(T));
+        static const size_t shift = 3; // spp_log2(1 + sizeof(T)); // T might be incomplete!
         return static_cast((*(reinterpret_cast(&__v))) >> shift);
     }
 };
 
+// from http://burtleburtle.net/bob/hash/integer.html
+// fast and efficient for power of two table sizes where we always 
+// consider the last bits.
+// ---------------------------------------------------------------
+inline size_t spp_mix_32(uint32_t a)
+{
+    a = a ^ (a >> 4);
+    a = (a ^ 0xdeadbeef) + (a << 5);
+    a = a ^ (a >> 11);
+    return static_cast(a);
+}
+
+// Maybe we should do a more thorough scrambling as described in 
+// https://gist.github.com/badboy/6267743
+// -------------------------------------------------------------
+inline size_t spp_mix_64(uint64_t a)
+{
+    a = a ^ (a >> 4);
+    a = (a ^ 0xdeadbeef) + (a << 5);
+    a = a ^ (a >> 11);
+    return a;
+}
+
 template <>
 struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(bool __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(bool __v) const SPP_NOEXCEPT 
+    { return static_cast(__v); }
 };
 
 template <>
 struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(char __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(char __v) const SPP_NOEXCEPT 
+    { return static_cast(__v); }
 };
 
 template <>
 struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(signed char __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(signed char __v) const SPP_NOEXCEPT 
+    { return static_cast(__v); }
 };
 
 template <>
 struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(unsigned char __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(unsigned char __v) const SPP_NOEXCEPT 
+    { return static_cast(__v); }
 };
 
 template <>
 struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(wchar_t __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(wchar_t __v) const SPP_NOEXCEPT 
+    { return static_cast(__v); }
 };
 
 template <>
-struct spp_hash : public std::unary_function
+struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(short __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(int16_t __v) const SPP_NOEXCEPT 
+    { return spp_mix_32(static_cast(__v)); }
 };
 
 template <> 
-struct spp_hash : public std::unary_function
+struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(unsigned short __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(uint16_t __v) const SPP_NOEXCEPT 
+    { return spp_mix_32(static_cast(__v)); }
 };
 
 template <>
-struct spp_hash : public std::unary_function
+struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(int __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(int32_t __v) const SPP_NOEXCEPT 
+    { return spp_mix_32(static_cast(__v)); }
 };
 
 template <>
-struct spp_hash : public std::unary_function
+struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(unsigned int __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(uint32_t __v) const SPP_NOEXCEPT 
+    { return spp_mix_32(static_cast(__v)); }
 };
 
 template <>
-struct spp_hash : public std::unary_function
+struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(long __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(int64_t __v) const SPP_NOEXCEPT 
+    { return spp_mix_64(static_cast(__v)); }
 };
 
 template <>
-struct spp_hash : public std::unary_function
+struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(unsigned long __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(uint64_t __v) const SPP_NOEXCEPT 
+    { return spp_mix_64(static_cast(__v)); }
 };
 
 template <>
@@ -1033,22 +1073,20 @@ struct spp_hash : public std::unary_function
     {
         // -0.0 and 0.0 should return same hash
         uint32_t *as_int = reinterpret_cast(&__v);
-        return (__v == 0) ? static_cast(0) : static_cast(*as_int);
+        return (__v == 0) ? static_cast(0) : spp_mix_32(*as_int);
     }
 };
 
-#if 0
-// todo: we should not ignore half of the double => see libcxx/include/functional
 template <>
 struct spp_hash : public std::unary_function
 {
     SPP_INLINE size_t operator()(double __v) const SPP_NOEXCEPT
     {
         // -0.0 and 0.0 should return same hash
-        return (__v == 0) ? (size_t)0 : (size_t)*((uint64_t *)&__v);
+        uint64_t *as_int = reinterpret_cast(&__v);
+        return (__v == 0) ? static_cast(0) : spp_mix_64(*as_int);
     }
 };
-#endif
 
 template  struct Combiner
 {
@@ -1080,7 +1118,7 @@ inline void hash_combine(std::size_t& seed, T const& v)
     combiner(seed, hasher(v));
 }
     
-};
+}
 
 #endif // spp_utils_h_guard_
 
@@ -1412,30 +1450,36 @@ namespace sparsehash_internal
     // Settings contains parameters for growing and shrinking the table.
     // It also packages zero-size functor (ie. hasher).
     //
-    // It does some munging of the hash value in cases where we think
-    // (fear) the original hash function might not be very good.  In
-    // particular, the default hash of pointers is the identity hash,
-    // so probably all the low bits are 0.  We identify when we think
-    // we're hashing a pointer, and chop off the low bits.  Note this
-    // isn't perfect: even when the key is a pointer, we can't tell
-    // for sure that the hash is the identity hash.  If it's not, this
-    // is needless work (and possibly, though not likely, harmful).
+    // It does some munging of the hash value for the cases where 
+    // the original hash function is not be very good.
     // ---------------------------------------------------------------
-    template
+    template
     class sh_hashtable_settings : public HashFunc 
     {
     private:
+#ifndef SPP_MIX_HASH
+        template  struct Mixer
+        {
+            inline T operator()(T h) const { return h; }
+        };
+#else
         template  struct Mixer
         {
             inline T operator()(T h) const;
         };
 
-        template  struct Mixer
+         template  struct Mixer
         {
             inline T operator()(T h) const
             {
-                return h + (h >> 7) + (h >> 13) + (h >> 23);
+                // from Thomas Wang - https://gist.github.com/badboy/6267743
+                // ---------------------------------------------------------
+                h = (h ^ 61) ^ (h >> 16);
+                h = h + (h << 3);
+                h = h ^ (h >> 4);
+                h = h * 0x27d4eb2d;
+                h = h ^ (h >> 15);
+                return h;
             }
         };
 
@@ -1443,9 +1487,19 @@ namespace sparsehash_internal
         {
             inline T operator()(T h) const
             {
-                return h + (h >> 7) + (h >> 13) + (h >> 23) + (h >> 32);
+                // from Thomas Wang - https://gist.github.com/badboy/6267743
+                // ---------------------------------------------------------
+                h = (~h) + (h << 21);              // h = (h << 21) - h - 1;
+                h = h ^ (h >> 24);
+                h = (h + (h << 3)) + (h << 8);     // h * 265
+                h = h ^ (h >> 14);
+                h = (h + (h << 2)) + (h << 4);     // h * 21
+                h = h ^ (h >> 28);
+                h = h + (h << 31);
+                return h;
             }
         };
+#endif
 
     public:
         typedef Key key_type;
@@ -1507,8 +1561,8 @@ namespace sparsehash_internal
         // ------------------------------------------------------------
         void set_resizing_parameters(float shrink, float grow) 
         {
-            assert(shrink >= 0.0);
-            assert(grow <= 1.0);
+            assert(shrink >= 0.0f);
+            assert(grow <= 1.0f);
             if (shrink > grow/2.0f)
                 shrink = grow / 2.0f;     // otherwise we thrash hashtable size
             set_shrink_factor(shrink);
@@ -1724,34 +1778,6 @@ template  struct is_relocatable > :
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
-template 
-class table_element_adaptor 
-{
-public:
-    typedef typename tabletype::value_type value_type;
-    typedef typename tabletype::size_type  size_type;
-    typedef typename tabletype::reference  reference;
-    typedef typename tabletype::pointer    pointer;
-
-    table_element_adaptor(tabletype *tbl, size_type p) :
-        table(tbl), pos(p) 
-    { }
-
-    table_element_adaptor& operator=(const value_type &val)
-    {
-        table->set(pos, val, false);
-        return *this;
-    }
-
-    operator value_type() { return table->get(pos); }   // we look like a value
-
-    pointer operator& () { return &table->mutating_get(pos); }
-
-private:
-    tabletype* table;
-    size_type pos;
-};
-
 // Our iterator as simple as iterators can be: basically it's just
 // the index into our table.  Dereference, the only complicated
 // thing, we punt to the table class.  This just goes to show how
@@ -1774,23 +1800,11 @@ public:
     typedef typename tabletype::value_type       value_type;
     typedef typename tabletype::difference_type  difference_type;
     typedef typename tabletype::size_type        size_type;
-    typedef table_element_adaptor     reference;
-    typedef table_element_adaptor*    pointer;
 
     explicit table_iterator(tabletype *tbl = 0, size_type p = 0) : 
         table(tbl), pos(p) 
     { }
 
-    // The main thing our iterator does is dereference.  If the table entry
-    // we point to is empty, we return the default value type.
-    // This is the big different function from the const iterator.
-    reference operator*()            
-    {
-        return table_element_adaptor(table, pos);
-    }
-
-    pointer operator->()  { return &(operator*()); }
-
     // Helper function to assert things are ok; eg pos is still in range
     void check() const 
     {
@@ -1834,11 +1848,6 @@ public:
         return pos - it.pos;
     }
 
-    reference operator[](difference_type n) const 
-    {
-        return *(*this + n);            // simple though not totally efficient
-    }
-
     // Comparisons.
     bool operator==(const iterator& it) const 
     {
@@ -2306,7 +2315,6 @@ public:
     typedef value_type*                                    pointer;
     typedef const value_type*                              const_pointer;
 
-    typedef table_element_adaptor >  element_adaptor;
     typedef uint8_t                                        size_type;        // max # of buckets
 
     // These are our special iterators, that go over non-empty buckets in a
@@ -2332,16 +2340,6 @@ public:
     const_reverse_ne_iterator ne_rend() const    { return const_reverse_ne_iterator(ne_cbegin());  }
     const_reverse_ne_iterator ne_crend() const   { return const_reverse_ne_iterator(ne_cbegin());  }
 
-
-    // This gives us the "default" value to return for an empty bucket.
-    // We just use the default constructor on T, the template type
-    // ----------------------------------------------------------------
-    const_reference default_value() const 
-    {
-        static value_type defaultval = value_type();
-        return defaultval;
-    }
-
 private:
     // T can be std::pair, but we need to return std::pair
     // ---------------------------------------------------------------------
@@ -2566,16 +2564,6 @@ public:
     // We also may want to know how many *used* buckets there are
     size_type num_nonempty() const   { return (size_type)_num_items(); }
 
-    // get()/set() are explicitly const/non-const.  You can use [] if
-    // you want something that can be either (potentially more expensive).
-    const_reference get(size_type i) const 
-    {
-        if (_bmtest(i))           // bucket i is occupied
-            return (const_reference)_group[pos_to_offset(i)];
-        else
-            return default_value();  // return the default reference
-    }
-
     // TODO(csilvers): make protected + friend
     // This is used by sparse_hashtable to get an element from the table
     // when we know it exists.
@@ -2587,47 +2575,52 @@ public:
 
     typedef std::pair SetResult;
 
-    // returns a reference which can be assigned, so we have to create an entry if not 
-    // already there
-    // -------------------------------------------------------------------------------
-    reference mutating_get(Alloc &alloc, size_type i) 
-    {
-        // fills bucket i before getting
-        if (!_bmtest(i))
-        {
-            SetResult sr = set(alloc, i, false);
-            if (!sr.second)
-                ::new (sr.first) mutable_value_type();
-            return *((pointer)sr.first);
-        }
+private:
+    typedef spp_::integral_constant::value &&
+                                     spp_::is_same >::value)>
+            realloc_and_memmove_ok; 
 
-        return _group[pos_to_offset(i)];
+    // ------------------------- memory at *p is uninitialized => need to construct
+    void _init_val(mutable_value_type *p, reference val)
+    {
+#if !defined(SPP_NO_CXX11_RVALUE_REFERENCES)
+        ::new (p) mutable_value_type(std::move(val));
+#else
+        ::new (p) mutable_value_type(val);
+#endif
     }
 
-    // Syntactic sugar.  It's easy to return a const reference.  To
-    // return a non-const reference, we need to use the assigner adaptor.
-    const_reference operator[](size_type i) const 
+    // ------------------------- memory at *p is uninitialized => need to construct
+    void _init_val(mutable_value_type *p, const_reference val)
     {
-        return get(i);
+        ::new (p) mutable_value_type(val);
     }
 
-    element_adaptor operator[](size_type i)
+    // ------------------------------------------------ memory at *p is initialized
+    void _set_val(mutable_value_type *p, reference val)
     {
-        return element_adaptor(this, i);
+#if !defined(SPP_NO_CXX11_RVALUE_REFERENCES)
+        *p = std::move(val);
+#else
+        using std::swap;
+        swap(*p, spp_mutable_ref(val)); 
+#endif
     }
 
-private:
-    typedef spp_::integral_constant::value &&
-                                     spp_::is_same >::value)>
-            realloc_and_memmove_ok; 
+    // ------------------------------------------------ memory at *p is initialized
+    void _set_val(mutable_value_type *p, const_reference val)
+    {
+        *p = spp_const_mutable_ref(val);
+    }
 
     // Our default allocator - try to merge memory buffers
     // right now it uses Google's traits, but we should use something like folly::IsRelocatable
     // return true if the slot was constructed (i.e. contains a valid mutable_value_type
     // ---------------------------------------------------------------------------------
-    bool _set_aux(Alloc &alloc, size_type offset, spp_::true_type) 
+    template 
+    void _set_aux(Alloc &alloc, size_type offset, Val &val, spp_::true_type) 
     {
         //static int x=0;  if (++x < 10) printf("x\n"); // check we are getting here
         
@@ -2643,14 +2636,16 @@ private:
 
         for (uint32_t i = num_items; i > offset; --i)
             memcpy(_group + i, _group + i-1, sizeof(*_group));
-        return false;
+
+        _init_val(_group + offset, val);
     }
 
     // Create space at _group[offset], without special assumptions about value_type
     // and allocator_type, with a default value
     // return true if the slot was constructed (i.e. contains a valid mutable_value_type
     // ---------------------------------------------------------------------------------
-    bool _set_aux(Alloc &alloc, size_type offset, spp_::false_type) 
+    template 
+    void _set_aux(Alloc &alloc, size_type offset, Val &val, spp_::false_type) 
     {
         uint32_t  num_items = _num_items();
         uint32_t  num_alloc = _sizing(num_items);
@@ -2659,9 +2654,9 @@ private:
         if (num_items < num_alloc)
         {
             // create new object at end and rotate it to position
-            ::new (&_group[num_items]) mutable_value_type();
+            _init_val(&_group[num_items], val);
             std::rotate(_group + offset, _group + num_items, _group + num_items + 1);
-            return true;
+            return;
         }
 
         // This is valid because 0 <= offset <= num_items
@@ -2674,57 +2669,37 @@ private:
             std::uninitialized_copy(MK_MOVE_IT(_group + offset),
                                     MK_MOVE_IT(_group + num_items),
                                     p + offset + 1);
+        _init_val(p + offset, val);
         _free_group(alloc, num_alloc);
         _group = p;
-        return false;
     }
 
-public:
-
-    // TODO(austern): Make this exception safe: handle exceptions from
-    // value_type's copy constructor.
-    // return true if the slot was constructed (i.e. contains a valid mutable_value_type)
     // ----------------------------------------------------------------------------------
-    bool _set(Alloc &alloc, size_type i, size_type offset, bool erased)
+    template 
+    void _set(Alloc &alloc, size_type i, size_type offset, Val &val)
     {
-        if (erased)
-        {
-            // assert(_bme_test(i));
-            _bme_clear(i);
-        }
-
         if (!_bmtest(i)) 
         {
-            bool res = _set_aux(alloc, offset, realloc_and_memmove_ok());
+            _set_aux(alloc, offset, val, realloc_and_memmove_ok());
             _incr_num_items();
             _bmset(i);
-            return res;
         }
-        return true;
+        else
+            _set_val(&_group[offset], val);
     }
 
-    // This returns a pair (first is a pointer to the item's location, second is whether
-    // that location is constructed (i.e. contains a valid mutable_value_type)
-    // ---------------------------------------------------------------------------------
-    SetResult set(Alloc &alloc, size_type i, bool erased)
-    {
-        size_type offset = pos_to_offset(i);  
-        bool constructed =  _set(alloc, i, offset, erased); // may change _group pointer
-        return std::make_pair(_group + offset, constructed);
-    }
+public:
 
-    // used in _move_from (where we can move the old value instead of copying it
-    // -------------------------------------------------------------------------
-    void move(Alloc &alloc, size_type i, reference val)
+    // This returns the pointer to the inserted item
+    // ---------------------------------------------
+    template 
+    pointer set(Alloc &alloc, size_type i, Val &val)
     {
-        // assert(!_bmtest(i));
+        _bme_clear(i); // in case this was an "erased" location
 
-        size_type offset = pos_to_offset(i); 
-        if (!_set(alloc, i, offset, false))
-            ::new (&_group[offset]) mutable_value_type();
-
-        using std::swap;
-        swap(_group[offset], spp_mutable_ref(val)); // called from _move_from, OK to swap
+        size_type offset = pos_to_offset(i);  
+        _set(alloc, i, offset, val);            // may change _group pointer
+        return (pointer)(_group + offset);
     }
     
     // We let you see if a bucket is non-empty without retrieving it
@@ -3074,7 +3049,6 @@ public:
 
     typedef table_iterator >        iterator;       // defined with index
     typedef const_table_iterator >  const_iterator; // defined with index
-    typedef table_element_adaptor > element_adaptor;
     typedef std::reverse_iterator         const_reverse_iterator;
     typedef std::reverse_iterator               reverse_iterator;
 
@@ -3438,14 +3412,6 @@ public:
         return which_group(pos.pos).test(pos_in_group(pos.pos));
     }
 
-    // We only return const_references because it's really hard to
-    // return something settable for empty buckets.  Use set() instead.
-    const_reference get(size_type i) const 
-    {
-        assert(i < _table_size);
-        return which_group(i).get(pos_in_group(i));
-    }
-
     // TODO(csilvers): make protected + friend
     // This is used by sparse_hashtable to get an element from the table
     // when we know it exists (because the caller has called test(i)).
@@ -3457,30 +3423,6 @@ public:
         return which_group(i).unsafe_get(pos_in_group(i));
     }
 
-    // TODO(csilvers): make protected + friend element_adaptor
-    reference mutating_get(size_type i) 
-    {   
-        // fills bucket i before getting
-        assert(i < _table_size);
-
-        GroupsReference grp(which_group(i));
-        typename group_type::size_type old_numbuckets = grp.num_nonempty();
-        reference retval = grp.mutating_get(_alloc, pos_in_group(i));
-        _num_buckets += grp.num_nonempty() - old_numbuckets;
-        return retval;
-    }
-
-    // Syntactic sugar.  As in sparsegroup, the non-const version is harder
-    const_reference operator[](size_type i) const 
-    {
-        return get(i);
-    }
-
-    element_adaptor operator[](size_type i) 
-    {
-        return element_adaptor(this, i);
-    }
-
     // Needed for hashtables, gets as a ne_iterator.  Crashes for empty bcks
     const_ne_iterator get_iter(size_type i) const 
     {
@@ -3524,28 +3466,24 @@ public:
                 _first_group[current_row].offset_to_pos(current_col));
     }
 
-    // This returns a reference to the inserted item (which is a copy of val)
-    // The trick is to figure out whether we're replacing or inserting anew
-    // ----------------------------------------------------------------------
-    reference set(size_type i, const_reference val, bool erased = false) 
+    // Val can be reference or const_reference
+    // ---------------------------------------
+    template 
+    reference set(size_type i, Val &val) 
     {
         assert(i < _table_size);
         group_type &group = which_group(i);
         typename group_type::size_type old_numbuckets = group.num_nonempty();
-        typename group_type::SetResult sr(group.set(_alloc, pos_in_group(i), erased));
-        if (!sr.second)
-            ::new (sr.first) mutable_value_type(val);
-        else
-            *sr.first = spp_const_mutable_ref(val);
+        pointer p(group.set(_alloc, pos_in_group(i), val));
         _num_buckets += group.num_nonempty() - old_numbuckets;
-        return *((pointer)sr.first);
+        return *p;
     }
 
     // used in _move_from (where we can move the old value instead of copying it
     void move(size_type i, reference val) 
     {
         assert(i < _table_size);
-        which_group(i).move(_alloc, pos_in_group(i), val);
+        which_group(i).set(_alloc, pos_in_group(i), val);
         ++_num_buckets;
     }
 
@@ -3816,7 +3754,7 @@ private:
 public:
     typedef Key                                        key_type;
     typedef typename spp::cvt::type             value_type;
-    typedef HashFcn                                    hasher;
+    typedef HashFcn                                    hasher; // user provided or spp_hash
     typedef EqualKey                                   key_equal;
     typedef Alloc                                      allocator_type;
 
@@ -4101,7 +4039,7 @@ private:
                 assert(num_probes < bucket_count()
                        && "Hashtable is full: an error in key_equal<> or hash<>");
             }
-            table.set(bucknum, *it, false);               // copies the value to here
+            table.set(bucknum, *it);               // copies the value to here
         }
         settings.inc_num_ht_copies();
     }
@@ -4483,7 +4421,8 @@ public:
     // INSERTION ROUTINES
 private:
     // Private method used by insert_noresize and find_or_insert.
-    reference _insert_at(const_reference obj, size_type pos, bool erased) 
+    template 
+    reference _insert_at(T& obj, size_type pos, bool erased) 
     {
         if (size() >= max_size()) 
         {
@@ -4494,11 +4433,12 @@ private:
             assert(num_deleted);
             --num_deleted;
         }
-        return table.set(pos, obj, erased);
+        return table.set(pos, obj);
     }
 
     // If you know *this is big enough to hold obj, use this routine
-    std::pair _insert_noresize(const_reference obj) 
+    template 
+    std::pair _insert_noresize(T& obj) 
     {
         Position pos = _find_position(get_key(obj));
         bool already_there = (pos._t == pt_full);
@@ -4536,17 +4476,13 @@ private:
 
 public:
 
-#if 0 && !defined(SPP_NO_CXX11_VARIADIC_TEMPLATES)
+#if !defined(SPP_NO_CXX11_VARIADIC_TEMPLATES)
     template 
-    pair emplace(Args&&... args) 
+    std::pair emplace(Args&&... args) 
     {
-        return rep.emplace_unique(std::forward(args)...);
-    }
-
-    template 
-    iterator emplace_hint(const_iterator p, Args&&... args)
-    {
-        return rep.emplace_unique(std::forward(args)...).first;
+        _resize_delta(1);  
+        value_type obj(std::forward(args)...);
+        return _insert_noresize(obj);
     }
 #endif
 
@@ -4589,12 +4525,14 @@ public:
                 {
                     // needed to rehash to make room
                     // Since we resized, we can't use pos, so recalculate where to insert.
-                    return *(_insert_noresize(default_value(key)).first);
+                    value_type def(default_value(key));
+                    return *(_insert_noresize(def).first);
                 } 
                 else 
                 {
                     // no need to rehash, insert right here
-                    return _insert_at(default_value(key), erased ? erased_pos : bucknum, erased);
+                    value_type def(default_value(key));
+                    return _insert_at(def, erased ? erased_pos : bucknum, erased);
                 }
             }
             if (grp_pos.test())
@@ -5153,6 +5091,20 @@ public:
         return it->second;
     }
 
+#if !defined(SPP_NO_CXX11_VARIADIC_TEMPLATES)
+    template 
+    std::pair emplace(Args&&... args) 
+    {
+        return rep.emplace(std::forward(args)...);
+    }
+
+    template 
+    iterator emplace_hint(const_iterator , Args&&... args)
+    {
+        return rep.emplace(std::forward(args)...).first;
+    }
+#endif
+
     // Insert
     // ------
     std::pair 
@@ -5496,17 +5448,17 @@ public:
     std::pair 
     equal_range(const key_type& key) const       { return rep.equal_range(key); }
 
-#if 0 && !defined(SPP_NO_CXX11_VARIADIC_TEMPLATES)
+#if !defined(SPP_NO_CXX11_VARIADIC_TEMPLATES)
     template 
-    pair emplace(Args&&... args) 
+    std::pair emplace(Args&&... args) 
     {
-        return rep.emplace_unique(std::forward(args)...);
+        return rep.emplace(std::forward(args)...);
     }
 
     template 
-    iterator emplace_hint(const_iterator p, Args&&... args)
+    iterator emplace_hint(const_iterator , Args&&... args)
     {
-        return rep.emplace_unique(std::forward(args)...).first;
+        return rep.emplace(std::forward(args)...).first;
     }
 #endif
 
diff --git a/resources/3rdparty/sparsepp/spp_test.cc b/resources/3rdparty/sparsepp/spp_test.cc
index 281db9154..e17eb0f82 100644
--- a/resources/3rdparty/sparsepp/spp_test.cc
+++ b/resources/3rdparty/sparsepp/spp_test.cc
@@ -1,39 +1,9 @@
 // ----------------------------------------------------------------------
-// Copyright (c) 2016, Steven Gregory Popovitch - greg7mdp@gmail.com
+// Copyright (c) 2016, Gregory Popovitch - greg7mdp@gmail.com
 // All rights reserved.
 // 
 // This work is derived from Google's sparsehash library
-// (see https://github.com/sparsehash/sparsehash) whose copyright appears
-// below this one.
 //
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * The name of Steven Gregory Popovitch may not be used to 
-// endorse or promote products derived from this software without 
-// specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// ----------------------------------------------------------------------
-
-// ----------------------------------------------------------------------
 // Copyright (c) 2010, Google Inc.
 // All rights reserved.
 //
@@ -835,7 +805,7 @@ struct TypeList3
   typedef typelist::type1 classname##_type6;    \
   typedef typelist::type1 classname##_type7;   \
   typedef typelist::type1 classname##_type8;   \
-  typedef typelist::type1 classname##_type9; 
+  typedef typelist::type1 classname##_type9
 
 template 
@@ -862,7 +832,7 @@ struct TypeList9
   typedef typelist::type7 classname##_type7;    \
   typedef typelist::type8 classname##_type8;    \
   typedef typelist::type9 classname##_type9;    \
-  static const int classname##_numtypes = 9;
+  static const int classname##_numtypes = 9
 
 #define TYPED_TEST(superclass, testname)                                \
   template                                          \
@@ -1171,7 +1141,7 @@ struct Identity
 // This is just to avoid memory leaks -- it's a global pointer to
 // all the memory allocated by UniqueObjectHelper.  We'll use it
 // to semi-test sparsetable as well. :-)
-sparsetable g_unique_charstar_objects(16);
+std::vector g_unique_charstar_objects(16, (char *)0);
 
 // This is an object-generator: pass in an index, and it will return a
 // unique object of type ItemType.  We provide specializations for the
@@ -1190,20 +1160,20 @@ template<> string UniqueObjectHelper(int index)
 template<> char* UniqueObjectHelper(int index) 
 {
     // First grow the table if need be.
-    sparsetable::size_type table_size = g_unique_charstar_objects.size();
+    size_t table_size = g_unique_charstar_objects.size();
     while (index >= static_cast(table_size)) {
         assert(table_size * 2 > table_size);  // avoid overflow problems
         table_size *= 2;
     }
     if (table_size > g_unique_charstar_objects.size())
-        g_unique_charstar_objects.resize(table_size);
-
-    if (!g_unique_charstar_objects.test((size_t)index)) {
+        g_unique_charstar_objects.resize(table_size, (char *)0);
+    
+    if (!g_unique_charstar_objects[static_cast(index)]) {
         char buffer[64];
         snprintf(buffer, sizeof(buffer), "%d", index);
-        g_unique_charstar_objects[(size_t)index] = _strdup(buffer);
+        g_unique_charstar_objects[static_cast(index)] = _strdup(buffer);
     }
-    return g_unique_charstar_objects.get((size_t)index);
+    return g_unique_charstar_objects[static_cast(index)];
 }
 template<> const char* UniqueObjectHelper(int index) {
     return UniqueObjectHelper(index);
@@ -1475,6 +1445,8 @@ TYPED_TEST(HashtableIntTest, Typedefs)
     (void)dt;
     (void)p;
     (void)cp;
+    (void)kt;
+    (void)st;
     i = this->ht_.begin();
     ci = this->ht_.begin();
     li = this->ht_.begin(0);
@@ -1493,6 +1465,93 @@ TYPED_TEST(HashtableAllTest, NormalIterators)
     }
 }
 
+
+#if !defined(SPP_NO_CXX11_VARIADIC_TEMPLATES)
+
+template  struct MyHash;
+typedef std::pair StringPair;
+
+template<> struct MyHash
+{
+    size_t operator()(StringPair const& p) const 
+    {
+        return std::hash()(p.first);
+    }
+};
+
+class MovableOnlyType 
+{
+    std::string   _str;
+    std::uint64_t _int;
+
+public:
+    // Make object movable and non-copyable
+    MovableOnlyType(MovableOnlyType &&) = default;
+    MovableOnlyType(const MovableOnlyType &) = delete;
+    MovableOnlyType& operator=(MovableOnlyType &&) = default;
+    MovableOnlyType& operator=(const MovableOnlyType &) = delete;
+    MovableOnlyType() : _str("whatever"), _int(2) {}
+};
+
+void movable_emplace_test(std::size_t iterations, int container_size) 
+{
+    for (std::size_t i=0;i m;
+        m.reserve(static_cast(container_size));
+        char buff[20];
+        for (int j=0; j mymap;
+
+        mymap.emplace ("NCC-1701", "J.T. Kirk");
+        mymap.emplace ("NCC-1701-D", "J.L. Picard");
+        mymap.emplace ("NCC-74656", "K. Janeway");
+        EXPECT_TRUE(mymap["NCC-74656"] == std::string("K. Janeway"));
+
+        sparse_hash_set > myset;
+        myset.emplace ("NCC-1701", "J.T. Kirk");
+    }
+    
+    movable_emplace_test(10, 50);
+}
+#endif
+
+
+#if !defined(SPP_NO_CXX11_VARIADIC_TEMPLATES)
+TEST(HashtableTest, IncompleteTypes) 
+{
+    int i;
+    sparse_hash_map ht2;
+    ht2[&i] = 3;
+
+    struct Bogus;
+    sparse_hash_map ht3;
+    ht3[(Bogus *)0] = 8;
+}
+#endif
+
+
+#if !defined(SPP_NO_CXX11_VARIADIC_TEMPLATES)
+TEST(HashtableTest, ReferenceWrapper) 
+{
+    sparse_hash_map> x;
+    int a = 5;
+    x.insert(std::make_pair(3, std::ref(a)));
+    EXPECT_EQ(x.at(3), 5);
+}
+#endif
+
+
 TEST(HashtableTest, ModifyViaIterator) 
 {
     // This only works for hash-maps, since only they have non-const values.
diff --git a/resources/3rdparty/sparsepp/spp_utils.h b/resources/3rdparty/sparsepp/spp_utils.h
index 6b627233c..96a8f5bf3 100644
--- a/resources/3rdparty/sparsepp/spp_utils.h
+++ b/resources/3rdparty/sparsepp/spp_utils.h
@@ -114,6 +114,12 @@
     #define SPP_NOEXCEPT noexcept
 #endif
 
+#ifdef SPP_NO_CXX11_CONSTEXPR
+    #define SPP_CONSTEXPR
+#else
+    #define SPP_CONSTEXPR constexpr
+#endif
+
 #define SPP_INLINE
 
 #ifndef SPP_NAMESPACE
@@ -149,75 +155,109 @@ struct spp_hash
 
     SPP_INLINE size_t operator()(const T *__v) const SPP_NOEXCEPT 
     {
-        static const size_t shift = spp_log2(1 + sizeof(T));
+        static const size_t shift = 3; // spp_log2(1 + sizeof(T)); // T might be incomplete!
         return static_cast((*(reinterpret_cast(&__v))) >> shift);
     }
 };
 
+// from http://burtleburtle.net/bob/hash/integer.html
+// fast and efficient for power of two table sizes where we always 
+// consider the last bits.
+// ---------------------------------------------------------------
+inline size_t spp_mix_32(uint32_t a)
+{
+    a = a ^ (a >> 4);
+    a = (a ^ 0xdeadbeef) + (a << 5);
+    a = a ^ (a >> 11);
+    return static_cast(a);
+}
+
+// Maybe we should do a more thorough scrambling as described in 
+// https://gist.github.com/badboy/6267743
+// -------------------------------------------------------------
+inline size_t spp_mix_64(uint64_t a)
+{
+    a = a ^ (a >> 4);
+    a = (a ^ 0xdeadbeef) + (a << 5);
+    a = a ^ (a >> 11);
+    return a;
+}
+
 template <>
 struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(bool __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(bool __v) const SPP_NOEXCEPT 
+    { return static_cast(__v); }
 };
 
 template <>
 struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(char __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(char __v) const SPP_NOEXCEPT 
+    { return static_cast(__v); }
 };
 
 template <>
 struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(signed char __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(signed char __v) const SPP_NOEXCEPT 
+    { return static_cast(__v); }
 };
 
 template <>
 struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(unsigned char __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(unsigned char __v) const SPP_NOEXCEPT 
+    { return static_cast(__v); }
 };
 
 template <>
 struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(wchar_t __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(wchar_t __v) const SPP_NOEXCEPT 
+    { return static_cast(__v); }
 };
 
 template <>
-struct spp_hash : public std::unary_function
+struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(short __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(int16_t __v) const SPP_NOEXCEPT 
+    { return spp_mix_32(static_cast(__v)); }
 };
 
 template <> 
-struct spp_hash : public std::unary_function
+struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(unsigned short __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(uint16_t __v) const SPP_NOEXCEPT 
+    { return spp_mix_32(static_cast(__v)); }
 };
 
 template <>
-struct spp_hash : public std::unary_function
+struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(int __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(int32_t __v) const SPP_NOEXCEPT 
+    { return spp_mix_32(static_cast(__v)); }
 };
 
 template <>
-struct spp_hash : public std::unary_function
+struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(unsigned int __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(uint32_t __v) const SPP_NOEXCEPT 
+    { return spp_mix_32(static_cast(__v)); }
 };
 
 template <>
-struct spp_hash : public std::unary_function
+struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(long __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(int64_t __v) const SPP_NOEXCEPT 
+    { return spp_mix_64(static_cast(__v)); }
 };
 
 template <>
-struct spp_hash : public std::unary_function
+struct spp_hash : public std::unary_function
 {
-    SPP_INLINE size_t operator()(unsigned long __v) const SPP_NOEXCEPT {return static_cast(__v);}
+    SPP_INLINE size_t operator()(uint64_t __v) const SPP_NOEXCEPT 
+    { return spp_mix_64(static_cast(__v)); }
 };
 
 template <>
@@ -227,22 +267,20 @@ struct spp_hash : public std::unary_function
     {
         // -0.0 and 0.0 should return same hash
         uint32_t *as_int = reinterpret_cast(&__v);
-        return (__v == 0) ? static_cast(0) : static_cast(*as_int);
+        return (__v == 0) ? static_cast(0) : spp_mix_32(*as_int);
     }
 };
 
-#if 0
-// todo: we should not ignore half of the double => see libcxx/include/functional
 template <>
 struct spp_hash : public std::unary_function
 {
     SPP_INLINE size_t operator()(double __v) const SPP_NOEXCEPT
     {
         // -0.0 and 0.0 should return same hash
-        return (__v == 0) ? (size_t)0 : (size_t)*((uint64_t *)&__v);
+        uint64_t *as_int = reinterpret_cast(&__v);
+        return (__v == 0) ? static_cast(0) : spp_mix_64(*as_int);
     }
 };
-#endif
 
 template  struct Combiner
 {
@@ -274,7 +312,7 @@ inline void hash_combine(std::size_t& seed, T const& v)
     combiner(seed, hasher(v));
 }
     
-};
+}
 
 #endif // spp_utils_h_guard_
 
diff --git a/resources/3rdparty/sylvan/CMakeLists.txt b/resources/3rdparty/sylvan/CMakeLists.txt
index 9ad8ca880..3d7aaaca7 100644
--- a/resources/3rdparty/sylvan/CMakeLists.txt
+++ b/resources/3rdparty/sylvan/CMakeLists.txt
@@ -2,9 +2,17 @@ cmake_minimum_required(VERSION 2.6)
 project(sylvan C CXX)
 enable_testing()
 
+option(SYLVAN_PORTABLE "If set, the created library will be portable." OFF)
+
 set(CMAKE_C_FLAGS "-O3 -Wextra -Wall -fno-strict-aliasing -std=gnu11 -fPIC")
-set(CMAKE_CXX_FLAGS "-O3 -Wextra -Wall -fno-strict-aliasing -Wno-deprecated-register -std=gnu++11 -fPIC")
+set(CMAKE_CXX_FLAGS "-O3 -Wextra -Wall -fno-strict-aliasing -Wno-deprecated-register -std=c++14 -fPIC")
+
+if (NOT SYLVAN_PORTABLE)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
+endif()
 
+option(USE_CARL "Sets whether carl should be included." ON)
 option(WITH_COVERAGE "Add generation of test coverage" OFF)
 if(WITH_COVERAGE)
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -coverage")
@@ -28,12 +36,22 @@ if(WITH_COVERAGE)
     )
 endif()
 
+if(USE_CARL)
+	add_definitions(-DSYLVAN_HAVE_CARL)
+	include_directories("${carl_INCLUDE_DIR}")
+	message(STATUS "Sylvan - using CARL.")
+else()
+	message(STATUS "Sylvan - not using CARL.")
+endif()
+
+
 set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
 find_package(GMP REQUIRED)
 include_directories(${GMP_INCLUDE_DIR})
+include_directories("${PROJECT_SOURCE_DIR}/../../../src")
+include_directories("${PROJECT_BINARY_DIR}/../../../include")
 include_directories(src)
 
-include_directories(src)
 
 add_subdirectory(src)
 
diff --git a/resources/3rdparty/sylvan/examples/CMakeLists.txt b/resources/3rdparty/sylvan/examples/CMakeLists.txt
index bb335935d..ce2d0d740 100644
--- a/resources/3rdparty/sylvan/examples/CMakeLists.txt
+++ b/resources/3rdparty/sylvan/examples/CMakeLists.txt
@@ -12,6 +12,12 @@ target_link_libraries(lddmc sylvan)
 add_executable(simple simple.cpp)
 target_link_libraries(simple sylvan stdc++)
 
+if(USE_CARL)
+   message(STATUS "Sylvan - Example for Storm enabled.")
+   add_executable(storm-rf storm.cpp)
+   target_link_libraries(storm-rf sylvan stdc++ ${carl_LIBRARIES})
+endif(USE_CARL)
+
 include(CheckIncludeFiles)
 check_include_files("gperftools/profiler.h" HAVE_PROFILER)
 
diff --git a/resources/3rdparty/sylvan/examples/storm.cpp b/resources/3rdparty/sylvan/examples/storm.cpp
new file mode 100644
index 000000000..c9bcfb032
--- /dev/null
+++ b/resources/3rdparty/sylvan/examples/storm.cpp
@@ -0,0 +1,127 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+using namespace sylvan;
+
+VOID_TASK_0(storm_rf)
+{
+    Bdd one = Bdd::bddOne(); // the True terminal
+    Bdd zero = Bdd::bddZero(); // the False terminal
+
+    // check if they really are the True/False terminal
+    assert(one.GetBDD() == sylvan_true);
+    assert(zero.GetBDD() == sylvan_false);
+
+    Bdd a = Bdd::bddVar(0); // create a BDD variable x_0
+    Bdd b = Bdd::bddVar(1); // create a BDD variable x_1
+
+    // check if a really is the Boolean formula "x_0"
+    assert(!a.isConstant());
+    assert(a.TopVar() == 0);
+    assert(a.Then() == one);
+    assert(a.Else() == zero);
+
+    // check if b really is the Boolean formula "x_1"
+    assert(!b.isConstant());
+    assert(b.TopVar() == 1);
+    assert(b.Then() == one);
+    assert(b.Else() == zero);
+
+    // compute !a
+    Bdd not_a = !a;
+
+    // check if !!a is really a
+    assert((!not_a) == a);
+
+    // compute a * b and !(!a + !b) and check if they are equivalent
+    Bdd a_and_b = a * b;
+    Bdd not_not_a_or_not_b = !(!a + !b);
+    assert(a_and_b == not_not_a_or_not_b);
+
+    // perform some simple quantification and check the results
+    Bdd ex = a_and_b.ExistAbstract(a); // \exists a . a * b
+    assert(ex == b);
+    Bdd andabs = a.AndAbstract(b, a); // \exists a . a * b using AndAbstract
+    assert(ex == andabs);
+    Bdd univ = a_and_b.UnivAbstract(a); // \forall a . a * b
+    assert(univ == zero);
+
+    // alternative method to get the cube "ab" using bddCube
+    BddSet variables = a * b;
+    std::vector vec = {1, 1};
+    assert(a_and_b == Bdd::bddCube(variables, vec));
+
+    // test the bddCube method for all combinations
+    assert((!a * !b) == Bdd::bddCube(variables, std::vector({0, 0})));
+    assert((!a * b)  == Bdd::bddCube(variables, std::vector({0, 1})));
+    assert((!a)      == Bdd::bddCube(variables, std::vector({0, 2})));
+    assert((a * !b)  == Bdd::bddCube(variables, std::vector({1, 0})));
+    assert((a * b)   == Bdd::bddCube(variables, std::vector({1, 1})));
+    assert((a)       == Bdd::bddCube(variables, std::vector({1, 2})));
+    assert((!b)      == Bdd::bddCube(variables, std::vector({2, 0})));
+    assert((b)       == Bdd::bddCube(variables, std::vector({2, 1})));
+    assert(one       == Bdd::bddCube(variables, std::vector({2, 2})));
+}
+
+VOID_TASK_1(_main, void*, arg)
+{
+    // Initialize Sylvan
+    // With starting size of the nodes table 1 << 21, and maximum size 1 << 27.
+    // With starting size of the cache table 1 << 20, and maximum size 1 << 20.
+    // Memory usage: 24 bytes per node, and 36 bytes per cache bucket
+    // - 1<<24 nodes: 384 MB
+    // - 1<<25 nodes: 768 MB
+    // - 1<<26 nodes: 1536 MB
+    // - 1<<27 nodes: 3072 MB
+    // - 1<<24 cache: 576 MB
+    // - 1<<25 cache: 1152 MB
+    // - 1<<26 cache: 2304 MB
+    // - 1<<27 cache: 4608 MB
+    sylvan_init_package(1LL<<22, 1LL<<26, 1LL<<22, 1LL<<26);
+
+    // Initialize the BDD module with granularity 1 (cache every operation)
+    // A higher granularity (e.g. 6) often results in better performance in practice
+    sylvan_init_bdd(1);
+
+    // Now we can do some simple stuff using the C++ objects.
+    CALL(storm_rf);
+
+    // Report statistics (if SYLVAN_STATS is 1 in the configuration)
+    sylvan_stats_report(stdout, 1);
+
+    // And quit, freeing memory
+    sylvan_quit();
+
+    // We didn't use arg
+    (void)arg;
+}
+
+int
+main (int argc, char *argv[])
+{
+    int n_workers = 0; // automatically detect number of workers
+    size_t deque_size = 0; // default value for the size of task deques for the workers
+    size_t program_stack_size = 0; // default value for the program stack of each pthread
+
+    // Initialize the Lace framework for  workers.
+    lace_init(n_workers, deque_size);
+
+    // Spawn and start all worker pthreads; suspends current thread until done.
+    lace_startup(program_stack_size, TASK(_main), NULL);
+
+    // The lace_startup command also exits Lace after _main is completed.
+
+    return 0;
+    (void)argc; // unused variable
+    (void)argv; // unused variable
+}
diff --git a/resources/3rdparty/sylvan/src/CMakeLists.txt b/resources/3rdparty/sylvan/src/CMakeLists.txt
index 130c3a80f..94f31fb64 100644
--- a/resources/3rdparty/sylvan/src/CMakeLists.txt
+++ b/resources/3rdparty/sylvan/src/CMakeLists.txt
@@ -13,6 +13,8 @@ add_library(sylvan
     sha2.c
     stats.h
     stats.c
+    storm_function_wrapper.h
+    storm_function_wrapper.cpp
     sylvan.h
     sylvan_bdd.h
     sylvan_bdd.c
@@ -30,6 +32,8 @@ add_library(sylvan
     sylvan_mtbdd_int.h
     sylvan_obj.hpp
     sylvan_obj.cpp
+    sylvan_storm_rational_function.h
+    sylvan_storm_rational_function.c
     tls.h
 )
 
@@ -42,6 +46,11 @@ set_target_properties(sylvan PROPERTIES
 
 target_link_libraries(sylvan m pthread gmp)
 
+if(USE_CARL)
+   message(STATUS "Sylvan - linking CARL.")
+   target_link_libraries(sylvan ${carl_LIBRARIES})
+endif(USE_CARL)
+
 if(UNIX AND NOT APPLE)
     target_link_libraries(sylvan rt)
 endif()
diff --git a/resources/3rdparty/sylvan/src/storm_function_wrapper.cpp b/resources/3rdparty/sylvan/src/storm_function_wrapper.cpp
new file mode 100644
index 000000000..b5132f984
--- /dev/null
+++ b/resources/3rdparty/sylvan/src/storm_function_wrapper.cpp
@@ -0,0 +1,298 @@
+#include "storm_function_wrapper.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "storm/adapters/CarlAdapter.h"
+#include "sylvan_storm_rational_function.h"
+
+#include 
+#include 
+#include 
+#include 
+
+std::mutex carlMutex;
+
+void storm_rational_function_init(storm_rational_function_ptr* a) {
+	std::lock_guard lock(carlMutex);
+	{
+		storm_rational_function_ptr srf_ptr = new storm::RationalFunction(*((storm::RationalFunction*)(*a)));
+		
+		if (srf_ptr == nullptr) {
+			std::cerr << "Could not allocate memory in storm_rational_function_init()!" << std::endl;
+			return;
+		}
+	
+		*a = srf_ptr;
+	}
+}
+
+void storm_rational_function_destroy(storm_rational_function_ptr a) {
+	std::lock_guard lock(carlMutex);
+	{
+		storm::RationalFunction* srf = (storm::RationalFunction*)a;
+		delete srf;
+	}
+}
+
+int storm_rational_function_equals(storm_rational_function_ptr a, storm_rational_function_ptr b) {
+	std::lock_guard lock(carlMutex);
+	int result = 0;
+	{
+		storm::RationalFunction& srf_a = *(storm::RationalFunction*)a;
+		storm::RationalFunction& srf_b = *(storm::RationalFunction*)b;
+
+		if (srf_a == srf_b) {
+			result = 1;
+		}
+	}
+
+	return result;
+}
+
+storm_rational_function_ptr storm_rational_function_plus(storm_rational_function_ptr a, storm_rational_function_ptr b) {
+	std::lock_guard lock(carlMutex);
+	storm_rational_function_ptr result = (storm_rational_function_ptr)nullptr;
+
+	{
+		storm::RationalFunction& srf_a = *(storm::RationalFunction*)a;
+		storm::RationalFunction& srf_b = *(storm::RationalFunction*)b;
+	
+		storm::RationalFunction* result_srf = new storm::RationalFunction(srf_a);
+		if (result_srf == nullptr) {
+			std::cerr << "Could not allocate memory in storm_rational_function_plus()!" << std::endl;
+			return result;
+		}
+		
+		*result_srf += srf_b;
+		result = (storm_rational_function_ptr)result_srf;
+	}
+
+	return result;
+}
+
+storm_rational_function_ptr storm_rational_function_minus(storm_rational_function_ptr a, storm_rational_function_ptr b) {
+	std::lock_guard lock(carlMutex);
+	storm_rational_function_ptr result = (storm_rational_function_ptr)nullptr;
+
+	{
+		storm::RationalFunction& srf_a = *(storm::RationalFunction*)a;
+		storm::RationalFunction& srf_b = *(storm::RationalFunction*)b;
+	
+		storm::RationalFunction* result_srf = new storm::RationalFunction(srf_a);
+		if (result_srf == nullptr) {
+			std::cerr << "Could not allocate memory in storm_rational_function_minus()!" << std::endl;
+			return result;
+		}
+		
+		*result_srf -= srf_b;
+		result = (storm_rational_function_ptr)result_srf;
+	}
+	return result;
+}
+
+storm_rational_function_ptr storm_rational_function_times(storm_rational_function_ptr a, storm_rational_function_ptr b) {
+	std::lock_guard lock(carlMutex);
+	storm_rational_function_ptr result = (storm_rational_function_ptr)nullptr;
+
+	{
+		storm::RationalFunction& srf_a = *(storm::RationalFunction*)a;
+		storm::RationalFunction& srf_b = *(storm::RationalFunction*)b;
+	
+		storm::RationalFunction* result_srf = new storm::RationalFunction(srf_a);
+		if (result_srf == nullptr) {
+			std::cerr << "Could not allocate memory in storm_rational_function_times()!" << std::endl;
+			return result;
+		}
+		
+		*result_srf *= srf_b;
+		result = (storm_rational_function_ptr)result_srf;
+	}
+	return result;
+}
+
+storm_rational_function_ptr storm_rational_function_divide(storm_rational_function_ptr a, storm_rational_function_ptr b) {
+	std::lock_guard lock(carlMutex);
+	storm_rational_function_ptr result = (storm_rational_function_ptr)nullptr;
+
+	{
+		storm::RationalFunction& srf_a = *(storm::RationalFunction*)a;
+		storm::RationalFunction& srf_b = *(storm::RationalFunction*)b;
+	
+		storm::RationalFunction* result_srf = new storm::RationalFunction(srf_a);
+		if (result_srf == nullptr) {
+			std::cerr << "Could not allocate memory in storm_rational_function_divide()!" << std::endl;
+			return result;
+		}
+		
+		*result_srf /= srf_b;
+		result = (storm_rational_function_ptr)result_srf;
+	}
+	return result;
+}
+
+uint64_t storm_rational_function_hash(storm_rational_function_ptr const a, uint64_t const seed) {
+	std::lock_guard lock(carlMutex);
+	
+	uint64_t result = 0;
+	{
+		storm::RationalFunction& srf_a = *(storm::RationalFunction*)a;
+		size_t hash = carl::hash_value(srf_a);
+	
+		result = hash ^ seed;
+	}
+	return result;
+}
+
+storm_rational_function_ptr storm_rational_function_negate(storm_rational_function_ptr a) {
+	std::lock_guard lock(carlMutex);
+	storm_rational_function_ptr result = (storm_rational_function_ptr)nullptr;
+
+	{
+		storm::RationalFunction& srf_a = *(storm::RationalFunction*)a;
+	
+		storm::RationalFunction* result_srf = new storm::RationalFunction(srf_a);
+		if (result_srf == nullptr) {
+			std::cerr << "Could not allocate memory in storm_rational_function_negate()!" << std::endl;
+			return result;
+		}
+		
+		*result_srf = -srf_a;
+		result = (storm_rational_function_ptr)result_srf;
+	}
+	return result;
+}
+
+int storm_rational_function_is_zero(storm_rational_function_ptr a) {
+	std::lock_guard lock(carlMutex);
+
+	bool resultIsZero = false;
+	{
+		storm::RationalFunction& srf_a = *(storm::RationalFunction*)a;
+		resultIsZero = srf_a.isZero();
+	}
+
+	if (resultIsZero) {
+		return 1;
+	} else {
+		return 0;
+	}
+}
+
+double storm_rational_function_get_constant(storm_rational_function_ptr a) {
+	std::lock_guard lock(carlMutex);
+
+	double result = -1.0;
+	{
+		storm::RationalFunction& srf_a = *(storm::RationalFunction*)a;
+	
+		if (srf_a.isConstant()) {
+			result = carl::toDouble(storm::RationalNumber(srf_a.nominatorAsNumber() / srf_a.denominatorAsNumber()));
+		} else {
+			std::cout << "Defaulting to -1.0 since this is not a constant: " << srf_a << std::endl;
+		}
+	}
+	return result;
+}
+
+storm_rational_function_ptr storm_rational_function_get_zero() {
+	std::lock_guard lock(carlMutex);
+	storm_rational_function_ptr result = (storm_rational_function_ptr)nullptr;
+
+	{
+		storm::RationalFunction* result_srf = new storm::RationalFunction(0);
+		if (result_srf == nullptr) {
+			std::cerr << "Could not allocate memory in storm_rational_function_get_zero()!" << std::endl;
+			return result;
+		}
+		result = (storm_rational_function_ptr)result_srf;
+	}
+	
+	return result;
+}
+
+storm_rational_function_ptr storm_rational_function_get_one() {
+	std::lock_guard lock(carlMutex);
+	storm_rational_function_ptr result = (storm_rational_function_ptr)nullptr;
+
+	{
+		storm::RationalFunction* result_srf = new storm::RationalFunction(1);
+		if (result_srf == nullptr) {
+			std::cerr << "Could not allocate memory in storm_rational_function_get_one()!" << std::endl;
+			return result;
+		}
+		result = (storm_rational_function_ptr)result_srf;
+	}
+	
+	return result;
+}
+
+void print_storm_rational_function(storm_rational_function_ptr a) {
+	std::lock_guard lock(carlMutex);
+	{
+		storm::RationalFunction& srf_a = *(storm::RationalFunction*)a;
+		std::cout << srf_a << std::flush;
+	}
+}
+
+void print_storm_rational_function_to_file(storm_rational_function_ptr a, FILE* out) {
+	std::lock_guard lock(carlMutex);
+	{
+		std::stringstream ss;
+		storm::RationalFunction& srf_a = *(storm::RationalFunction*)a;
+		ss << srf_a;
+		std::string s = ss.str();
+		fprintf(out, "%s", s.c_str());
+	}
+}
+
+MTBDD testiTest(storm::RationalFunction const& currentFunction, std::map>> const& replacements) {
+	if (currentFunction.isConstant()) {
+		return mtbdd_storm_rational_function((storm_rational_function_ptr)¤tFunction);
+	}
+
+	std::set variablesInFunction = currentFunction.gatherVariables();
+	std::map>>::const_iterator it = replacements.cbegin();
+	std::map>>::const_iterator end = replacements.cend();
+
+	// Walking the (ordered) map enforces an ordering on the MTBDD
+	for (; it != end; ++it) {
+		if (variablesInFunction.find(it->second.first) != variablesInFunction.cend()) {
+			std::map highReplacement = {{it->second.first, it->second.second.first}};
+			std::map lowReplacement = {{it->second.first, it->second.second.second}};
+
+			std::lock_guard* lock = new std::lock_guard(carlMutex);
+			storm::RationalFunction const highSrf = currentFunction.substitute(highReplacement);
+			storm::RationalFunction const lowSrf = currentFunction.substitute(lowReplacement);
+			delete lock;
+			
+			MTBDD high = testiTest(highSrf, replacements);
+			MTBDD low = testiTest(lowSrf, replacements);
+			LACE_ME
+			return mtbdd_ite(mtbdd_ithvar(it->first), high, low);
+		} else {
+			//std::cout << "No match for variable " << it->second.first << std::endl;
+		}
+	}
+
+	return mtbdd_storm_rational_function((storm_rational_function_ptr)¤tFunction);
+}
+
+
+MTBDD storm_rational_function_leaf_parameter_replacement(MTBDD dd, storm_rational_function_ptr a, void* context) {	
+	storm::RationalFunction& srf_a = *(storm::RationalFunction*)a;
+	{
+		// Scope the lock.
+		std::lock_guard lock(carlMutex);
+		if (srf_a.isConstant()) {
+			return dd;
+		}
+	}
+	
+	std::map>>* replacements = (std::map>>*)context;
+	return testiTest(srf_a, *replacements);
+}
diff --git a/resources/3rdparty/sylvan/src/storm_function_wrapper.h b/resources/3rdparty/sylvan/src/storm_function_wrapper.h
new file mode 100644
index 000000000..104842972
--- /dev/null
+++ b/resources/3rdparty/sylvan/src/storm_function_wrapper.h
@@ -0,0 +1,42 @@
+#ifndef SYLVAN_STORM_FUNCTION_WRAPPER_H
+#define SYLVAN_STORM_FUNCTION_WRAPPER_H
+
+#include 
+#include 
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void* storm_rational_function_ptr;
+
+// equals, plus, minus, divide, times, create, destroy
+void storm_rational_function_init(storm_rational_function_ptr* a);
+void storm_rational_function_destroy(storm_rational_function_ptr a);
+int storm_rational_function_equals(storm_rational_function_ptr a, storm_rational_function_ptr b);
+storm_rational_function_ptr storm_rational_function_plus(storm_rational_function_ptr a, storm_rational_function_ptr b);
+storm_rational_function_ptr storm_rational_function_minus(storm_rational_function_ptr a, storm_rational_function_ptr b);
+storm_rational_function_ptr storm_rational_function_times(storm_rational_function_ptr a, storm_rational_function_ptr b);
+storm_rational_function_ptr storm_rational_function_divide(storm_rational_function_ptr a, storm_rational_function_ptr b);
+storm_rational_function_ptr storm_rational_function_negate(storm_rational_function_ptr a);
+uint64_t storm_rational_function_hash(storm_rational_function_ptr const a, uint64_t const seed);
+int storm_rational_function_is_zero(storm_rational_function_ptr a);
+
+storm_rational_function_ptr storm_rational_function_get_zero();
+storm_rational_function_ptr storm_rational_function_get_one();
+
+void print_storm_rational_function(storm_rational_function_ptr a);
+void print_storm_rational_function_to_file(storm_rational_function_ptr a, FILE* out);
+
+int storm_rational_function_is_zero(storm_rational_function_ptr a);
+
+MTBDD storm_rational_function_leaf_parameter_replacement(MTBDD dd, storm_rational_function_ptr a, void* context);
+
+double storm_rational_function_get_constant(storm_rational_function_ptr a);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // SYLVAN_STORM_FUNCTION_WRAPPER_H
diff --git a/resources/3rdparty/sylvan/src/sylvan_bdd.c b/resources/3rdparty/sylvan/src/sylvan_bdd.c
index 74936a62d..281c99bc3 100644
--- a/resources/3rdparty/sylvan/src/sylvan_bdd.c
+++ b/resources/3rdparty/sylvan/src/sylvan_bdd.c
@@ -30,69 +30,7 @@
 #include 
 #include 
 #include 
-
-/**
- * Complement handling macros
- */
-#define BDD_HASMARK(s)              (s&sylvan_complement?1:0)
-#define BDD_TOGGLEMARK(s)           (s^sylvan_complement)
-#define BDD_STRIPMARK(s)            (s&~sylvan_complement)
-#define BDD_TRANSFERMARK(from, to)  (to ^ (from & sylvan_complement))
-// Equal under mark
-#define BDD_EQUALM(a, b)            ((((a)^(b))&(~sylvan_complement))==0)
-
-/**
- * BDD node structure
- */
-typedef struct __attribute__((packed)) bddnode {
-    uint64_t a, b;
-} * bddnode_t; // 16 bytes
-
-#define GETNODE(bdd) ((bddnode_t)llmsset_index_to_ptr(nodes, bdd&0x000000ffffffffff))
-
-static inline int __attribute__((unused))
-bddnode_getcomp(bddnode_t n)
-{
-    return n->a & 0x8000000000000000 ? 1 : 0;
-}
-
-static inline uint64_t
-bddnode_getlow(bddnode_t n)
-{
-    return n->b & 0x000000ffffffffff; // 40 bits
-}
-
-static inline uint64_t
-bddnode_gethigh(bddnode_t n)
-{
-    return n->a & 0x800000ffffffffff; // 40 bits plus high bit of first
-}
-
-static inline uint32_t
-bddnode_getvariable(bddnode_t n)
-{
-    return (uint32_t)(n->b >> 40);
-}
-
-static inline int
-bddnode_getmark(bddnode_t n)
-{
-    return n->a & 0x2000000000000000 ? 1 : 0;
-}
-
-static inline void
-bddnode_setmark(bddnode_t n, int mark)
-{
-    if (mark) n->a |= 0x2000000000000000;
-    else n->a &= 0xdfffffffffffffff;
-}
-
-static inline void
-bddnode_makenode(bddnode_t n, uint32_t var, uint64_t low, uint64_t high)
-{
-    n->a = high;
-    n->b = ((uint64_t)var)<<40 | low;
-}
+#include 
 
 /**
  * Implementation of garbage collection.
@@ -104,7 +42,7 @@ VOID_TASK_IMPL_1(sylvan_gc_mark_rec, BDD, bdd)
     if (bdd == sylvan_false || bdd == sylvan_true) return;
 
     if (llmsset_mark(nodes, bdd&0x000000ffffffffff)) {
-        bddnode_t n = GETNODE(bdd);
+        bddnode_t n = BDD_GETNODE(bdd);
         SPAWN(sylvan_gc_mark_rec, bddnode_getlow(n));
         CALL(sylvan_gc_mark_rec, bddnode_gethigh(n));
         SYNC(sylvan_gc_mark_rec);
@@ -348,7 +286,7 @@ sylvan_ithvar(BDDVAR level)
 BDDVAR
 sylvan_var(BDD bdd)
 {
-    return bddnode_getvariable(GETNODE(bdd));
+    return bddnode_getvariable(BDD_GETNODE(bdd));
 }
 
 static BDD
@@ -367,14 +305,14 @@ BDD
 sylvan_low(BDD bdd)
 {
     if (sylvan_isconst(bdd)) return bdd;
-    return node_low(bdd, GETNODE(bdd));
+    return node_low(bdd, BDD_GETNODE(bdd));
 }
 
 BDD
 sylvan_high(BDD bdd)
 {
     if (sylvan_isconst(bdd)) return bdd;
-    return node_high(bdd, GETNODE(bdd));
+    return node_high(bdd, BDD_GETNODE(bdd));
 }
 
 /**
@@ -401,8 +339,8 @@ TASK_IMPL_3(BDD, sylvan_and, BDD, a, BDD, b, BDDVAR, prev_level)
         a = t;
     }
 
-    bddnode_t na = GETNODE(a);
-    bddnode_t nb = GETNODE(b);
+    bddnode_t na = BDD_GETNODE(a);
+    bddnode_t nb = BDD_GETNODE(b);
 
     BDDVAR va = bddnode_getvariable(na);
     BDDVAR vb = bddnode_getvariable(nb);
@@ -497,8 +435,8 @@ TASK_IMPL_3(BDD, sylvan_xor, BDD, a, BDD, b, BDDVAR, prev_level)
         b = sylvan_not(b);
     }
 
-    bddnode_t na = GETNODE(a);
-    bddnode_t nb = GETNODE(b);
+    bddnode_t na = BDD_GETNODE(a);
+    bddnode_t nb = BDD_GETNODE(b);
 
     BDDVAR va = bddnode_getvariable(na);
     BDDVAR vb = bddnode_getvariable(nb);
@@ -594,9 +532,9 @@ TASK_IMPL_4(BDD, sylvan_ite, BDD, a, BDD, b, BDD, c, BDDVAR, prev_level)
         mark = 1;
     }
 
-    bddnode_t na = GETNODE(a);
-    bddnode_t nb = GETNODE(b);
-    bddnode_t nc = GETNODE(c);
+    bddnode_t na = BDD_GETNODE(a);
+    bddnode_t nb = BDD_GETNODE(b);
+    bddnode_t nc = BDD_GETNODE(c);
 
     BDDVAR va = bddnode_getvariable(na);
     BDDVAR vb = bddnode_getvariable(nb);
@@ -699,8 +637,8 @@ TASK_IMPL_3(BDD, sylvan_constrain, BDD, a, BDD, b, BDDVAR, prev_level)
     sylvan_stats_count(BDD_CONSTRAIN);
 
     // a != constant and b != constant
-    bddnode_t na = GETNODE(a);
-    bddnode_t nb = GETNODE(b);
+    bddnode_t na = BDD_GETNODE(a);
+    bddnode_t nb = BDD_GETNODE(b);
 
     BDDVAR va = bddnode_getvariable(na);
     BDDVAR vb = bddnode_getvariable(nb);
@@ -788,8 +726,8 @@ TASK_IMPL_3(BDD, sylvan_restrict, BDD, a, BDD, b, BDDVAR, prev_level)
     sylvan_stats_count(BDD_RESTRICT);
 
     // a != constant and b != constant
-    bddnode_t na = GETNODE(a);
-    bddnode_t nb = GETNODE(b);
+    bddnode_t na = BDD_GETNODE(a);
+    bddnode_t nb = BDD_GETNODE(b);
 
     BDDVAR va = bddnode_getvariable(na);
     BDDVAR vb = bddnode_getvariable(nb);
@@ -850,15 +788,15 @@ TASK_IMPL_3(BDD, sylvan_exists, BDD, a, BDD, variables, BDDVAR, prev_level)
     if (sylvan_set_isempty(variables)) return a;
 
     // a != constant
-    bddnode_t na = GETNODE(a);
+    bddnode_t na = BDD_GETNODE(a);
     BDDVAR level = bddnode_getvariable(na);
 
-    bddnode_t nv = GETNODE(variables);
+    bddnode_t nv = BDD_GETNODE(variables);
     BDDVAR vv = bddnode_getvariable(nv);
     while (vv < level) {
         variables = node_high(variables, nv);
         if (sylvan_set_isempty(variables)) return a;
-        nv = GETNODE(variables);
+        nv = BDD_GETNODE(variables);
         vv = bddnode_getvariable(nv);
     }
 
@@ -956,9 +894,9 @@ TASK_IMPL_4(BDD, sylvan_and_exists, BDD, a, BDD, b, BDDSET, v, BDDVAR, prev_leve
     sylvan_stats_count(BDD_AND_EXISTS);
 
     // a != constant
-    bddnode_t na = GETNODE(a);
-    bddnode_t nb = GETNODE(b);
-    bddnode_t nv = GETNODE(v);
+    bddnode_t na = BDD_GETNODE(a);
+    bddnode_t nb = BDD_GETNODE(b);
+    bddnode_t nv = BDD_GETNODE(v);
 
     BDDVAR va = bddnode_getvariable(na);
     BDDVAR vb = bddnode_getvariable(nb);
@@ -969,7 +907,7 @@ TASK_IMPL_4(BDD, sylvan_and_exists, BDD, a, BDD, b, BDDSET, v, BDDVAR, prev_leve
     while (vv < level) {
         v = node_high(v, nv); // get next variable in conjunction
         if (sylvan_set_isempty(v)) return sylvan_and(a, b);
-        nv = GETNODE(v);
+        nv = BDD_GETNODE(v);
         vv = bddnode_getvariable(nv);
     }
 
@@ -1069,8 +1007,8 @@ TASK_IMPL_4(BDD, sylvan_relnext, BDD, a, BDD, b, BDDSET, vars, BDDVAR, prev_leve
     sylvan_stats_count(BDD_RELNEXT);
 
     /* Determine top level */
-    bddnode_t na = sylvan_isconst(a) ? 0 : GETNODE(a);
-    bddnode_t nb = sylvan_isconst(b) ? 0 : GETNODE(b);
+    bddnode_t na = sylvan_isconst(a) ? 0 : BDD_GETNODE(a);
+    bddnode_t nb = sylvan_isconst(b) ? 0 : BDD_GETNODE(b);
 
     BDDVAR va = na ? bddnode_getvariable(na) : 0xffffffff;
     BDDVAR vb = nb ? bddnode_getvariable(nb) : 0xffffffff;
@@ -1082,7 +1020,7 @@ TASK_IMPL_4(BDD, sylvan_relnext, BDD, a, BDD, b, BDDSET, vars, BDDVAR, prev_leve
     if (vars == sylvan_false) {
         is_s_or_t = 1;
     } else {
-        nv = GETNODE(vars);
+        nv = BDD_GETNODE(vars);
         for (;;) {
             /* check if level is s/t */
             BDDVAR vv = bddnode_getvariable(nv);
@@ -1094,7 +1032,7 @@ TASK_IMPL_4(BDD, sylvan_relnext, BDD, a, BDD, b, BDDSET, vars, BDDVAR, prev_leve
             if (level < vv) break;
             vars = node_high(vars, nv); // get next in vars
             if (sylvan_set_isempty(vars)) return a;
-            nv = GETNODE(vars);
+            nv = BDD_GETNODE(vars);
         }
     }
 
@@ -1131,7 +1069,7 @@ TASK_IMPL_4(BDD, sylvan_relnext, BDD, a, BDD, b, BDDSET, vars, BDDVAR, prev_leve
 
         BDD b00, b01, b10, b11;
         if (!sylvan_isconst(b0)) {
-            bddnode_t nb0 = GETNODE(b0);
+            bddnode_t nb0 = BDD_GETNODE(b0);
             if (bddnode_getvariable(nb0) == t) {
                 b00 = node_low(b0, nb0);
                 b01 = node_high(b0, nb0);
@@ -1142,7 +1080,7 @@ TASK_IMPL_4(BDD, sylvan_relnext, BDD, a, BDD, b, BDDSET, vars, BDDVAR, prev_leve
             b00 = b01 = b0;
         }
         if (!sylvan_isconst(b1)) {
-            bddnode_t nb1 = GETNODE(b1);
+            bddnode_t nb1 = BDD_GETNODE(b1);
             if (bddnode_getvariable(nb1) == t) {
                 b10 = node_low(b1, nb1);
                 b11 = node_high(b1, nb1);
@@ -1267,8 +1205,8 @@ TASK_IMPL_4(BDD, sylvan_relprev, BDD, a, BDD, b, BDDSET, vars, BDDVAR, prev_leve
     sylvan_stats_count(BDD_RELPREV);
 
     /* Determine top level */
-    bddnode_t na = sylvan_isconst(a) ? 0 : GETNODE(a);
-    bddnode_t nb = sylvan_isconst(b) ? 0 : GETNODE(b);
+    bddnode_t na = sylvan_isconst(a) ? 0 : BDD_GETNODE(a);
+    bddnode_t nb = sylvan_isconst(b) ? 0 : BDD_GETNODE(b);
 
     BDDVAR va = na ? bddnode_getvariable(na) : 0xffffffff;
     BDDVAR vb = nb ? bddnode_getvariable(nb) : 0xffffffff;
@@ -1280,7 +1218,7 @@ TASK_IMPL_4(BDD, sylvan_relprev, BDD, a, BDD, b, BDDSET, vars, BDDVAR, prev_leve
     if (vars == sylvan_false) {
         is_s_or_t = 1;
     } else {
-        nv = GETNODE(vars);
+        nv = BDD_GETNODE(vars);
         for (;;) {
             /* check if level is s/t */
             BDDVAR vv = bddnode_getvariable(nv);
@@ -1292,7 +1230,7 @@ TASK_IMPL_4(BDD, sylvan_relprev, BDD, a, BDD, b, BDDSET, vars, BDDVAR, prev_leve
             if (level < vv) break;
             vars = node_high(vars, nv); // get next in vars
             if (sylvan_set_isempty(vars)) return b;
-            nv = GETNODE(vars);
+            nv = BDD_GETNODE(vars);
         }
     }
 
@@ -1329,7 +1267,7 @@ TASK_IMPL_4(BDD, sylvan_relprev, BDD, a, BDD, b, BDDSET, vars, BDDVAR, prev_leve
 
         BDD a00, a01, a10, a11;
         if (!sylvan_isconst(a0)) {
-            bddnode_t na0 = GETNODE(a0);
+            bddnode_t na0 = BDD_GETNODE(a0);
             if (bddnode_getvariable(na0) == t) {
                 a00 = node_low(a0, na0);
                 a01 = node_high(a0, na0);
@@ -1340,7 +1278,7 @@ TASK_IMPL_4(BDD, sylvan_relprev, BDD, a, BDD, b, BDDSET, vars, BDDVAR, prev_leve
             a00 = a01 = a0;
         }
         if (!sylvan_isconst(a1)) {
-            bddnode_t na1 = GETNODE(a1);
+            bddnode_t na1 = BDD_GETNODE(a1);
             if (bddnode_getvariable(na1) == t) {
                 a10 = node_low(a1, na1);
                 a11 = node_high(a1, na1);
@@ -1353,7 +1291,7 @@ TASK_IMPL_4(BDD, sylvan_relprev, BDD, a, BDD, b, BDDSET, vars, BDDVAR, prev_leve
 
         BDD b00, b01, b10, b11;
         if (!sylvan_isconst(b0)) {
-            bddnode_t nb0 = GETNODE(b0);
+            bddnode_t nb0 = BDD_GETNODE(b0);
             if (bddnode_getvariable(nb0) == t) {
                 b00 = node_low(b0, nb0);
                 b01 = node_high(b0, nb0);
@@ -1364,7 +1302,7 @@ TASK_IMPL_4(BDD, sylvan_relprev, BDD, a, BDD, b, BDDSET, vars, BDDVAR, prev_leve
             b00 = b01 = b0;
         }
         if (!sylvan_isconst(b1)) {
-            bddnode_t nb1 = GETNODE(b1);
+            bddnode_t nb1 = BDD_GETNODE(b1);
             if (bddnode_getvariable(nb1) == t) {
                 b10 = node_low(b1, nb1);
                 b11 = node_high(b1, nb1);
@@ -1536,7 +1474,7 @@ TASK_IMPL_2(BDD, sylvan_closure, BDD, a, BDDVAR, prev_level)
     sylvan_stats_count(BDD_CLOSURE);
 
     /* Determine top level */
-    bddnode_t n = GETNODE(a);
+    bddnode_t n = BDD_GETNODE(a);
     BDDVAR level = bddnode_getvariable(n);
 
     /* Consult cache */
@@ -1562,7 +1500,7 @@ TASK_IMPL_2(BDD, sylvan_closure, BDD, a, BDDVAR, prev_level)
 
     BDD a00, a01, a10, a11;
     if (!sylvan_isconst(a0)) {
-        bddnode_t na0 = GETNODE(a0);
+        bddnode_t na0 = BDD_GETNODE(a0);
         if (bddnode_getvariable(na0) == t) {
             a00 = node_low(a0, na0);
             a01 = node_high(a0, na0);
@@ -1573,7 +1511,7 @@ TASK_IMPL_2(BDD, sylvan_closure, BDD, a, BDDVAR, prev_level)
         a00 = a01 = a0;
     }
     if (!sylvan_isconst(a1)) {
-        bddnode_t na1 = GETNODE(a1);
+        bddnode_t na1 = BDD_GETNODE(a1);
         if (bddnode_getvariable(na1) == t) {
             a10 = node_low(a1, na1);
             a11 = node_high(a1, na1);
@@ -1641,16 +1579,16 @@ TASK_IMPL_3(BDD, sylvan_compose, BDD, a, BDDMAP, map, BDDVAR, prev_level)
     sylvan_stats_count(BDD_COMPOSE);
 
     /* Determine top level */
-    bddnode_t n = GETNODE(a);
+    bddnode_t n = BDD_GETNODE(a);
     BDDVAR level = bddnode_getvariable(n);
 
     /* Skip map */
-    bddnode_t map_node = GETNODE(map);
+    bddnode_t map_node = BDD_GETNODE(map);
     BDDVAR map_var = bddnode_getvariable(map_node);
     while (map_var < level) {
         map = node_low(map, map_node);
         if (sylvan_map_isempty(map)) return a;
-        map_node = GETNODE(map);
+        map_node = BDD_GETNODE(map);
         map_var = bddnode_getvariable(map_node);
     }
 
@@ -1690,7 +1628,7 @@ TASK_IMPL_3(BDD, sylvan_compose, BDD, a, BDDMAP, map, BDDVAR, prev_level)
 uint64_t sylvan_nodecount_do_1(BDD a)
 {
     if (sylvan_isconst(a)) return 0;
-    bddnode_t na = GETNODE(a);
+    bddnode_t na = BDD_GETNODE(a);
     if (bddnode_getmark(na)) return 0;
     bddnode_setmark(na, 1);
     uint64_t result = 1;
@@ -1702,7 +1640,7 @@ uint64_t sylvan_nodecount_do_1(BDD a)
 void sylvan_nodecount_do_2(BDD a)
 {
     if (sylvan_isconst(a)) return;
-    bddnode_t na = GETNODE(a);
+    bddnode_t na = BDD_GETNODE(a);
     if (!bddnode_getmark(na)) return;
     bddnode_setmark(na, 0);
     sylvan_nodecount_do_2(bddnode_getlow(na));
@@ -1771,14 +1709,14 @@ TASK_IMPL_3(double, sylvan_satcount, BDD, bdd, BDDSET, variables, BDDVAR, prev_l
     /* Count variables before var(bdd) */
     size_t skipped = 0;
     BDDVAR var = sylvan_var(bdd);
-    bddnode_t set_node = GETNODE(variables);
+    bddnode_t set_node = BDD_GETNODE(variables);
     BDDVAR set_var = bddnode_getvariable(set_node);
     while (var != set_var) {
         skipped++;
         variables = node_high(variables, set_node);
         // if this assertion fails, then variables is not the support of 
         assert(!sylvan_set_isempty(variables));
-        set_node = GETNODE(variables);
+        set_node = BDD_GETNODE(variables);
         set_var = bddnode_getvariable(set_node);
     }
 
@@ -1816,11 +1754,11 @@ sylvan_sat_one(BDD bdd, BDDSET vars, uint8_t *str)
     if (sylvan_set_isempty(vars)) return 1;
 
     for (;;) {
-        bddnode_t n_vars = GETNODE(vars);
+        bddnode_t n_vars = BDD_GETNODE(vars);
         if (bdd == sylvan_true) {
             *str = 0;
         } else {
-            bddnode_t n_bdd = GETNODE(bdd);
+            bddnode_t n_bdd = BDD_GETNODE(bdd);
             if (bddnode_getvariable(n_bdd) != bddnode_getvariable(n_vars)) {
                 *str = 0;
             } else {
@@ -1849,7 +1787,7 @@ sylvan_sat_one_bdd(BDD bdd)
     if (bdd == sylvan_false) return sylvan_false;
     if (bdd == sylvan_true) return sylvan_true;
 
-    bddnode_t node = GETNODE(bdd);
+    bddnode_t node = BDD_GETNODE(bdd);
     BDD low = node_low(bdd, node);
     BDD high = node_high(bdd, node);
 
@@ -1880,7 +1818,7 @@ sylvan_cube(BDDSET vars, uint8_t *cube)
 {
     if (sylvan_set_isempty(vars)) return sylvan_true;
 
-    bddnode_t n = GETNODE(vars);
+    bddnode_t n = BDD_GETNODE(vars);
     BDDVAR v = bddnode_getvariable(n);
     vars = node_high(vars, n);
 
@@ -1901,7 +1839,7 @@ TASK_IMPL_3(BDD, sylvan_union_cube, BDD, bdd, BDDSET, vars, uint8_t *, cube)
     if (bdd == sylvan_false) return sylvan_cube(vars, cube);
     if (sylvan_set_isempty(vars)) return sylvan_true;
 
-    bddnode_t nv = GETNODE(vars);
+    bddnode_t nv = BDD_GETNODE(vars);
 
     for (;;) {
         if (*cube == 0 || *cube == 1) break;
@@ -1909,14 +1847,14 @@ TASK_IMPL_3(BDD, sylvan_union_cube, BDD, bdd, BDDSET, vars, uint8_t *, cube)
         cube++;
         vars = node_high(vars, nv);
         if (sylvan_set_isempty(vars)) return sylvan_true;
-        nv = GETNODE(vars);
+        nv = BDD_GETNODE(vars);
     }
 
     sylvan_gc_test();
 
     // missing: SV_CNT_OP
 
-    bddnode_t n = GETNODE(bdd);
+    bddnode_t n = BDD_GETNODE(bdd);
     BDD result = bdd;
     BDDVAR v = bddnode_getvariable(nv);
     BDDVAR n_level = bddnode_getvariable(n);
@@ -2138,7 +2076,7 @@ int
 sylvan_set_in(BDDSET set, BDDVAR level)
 {
     while (!sylvan_set_isempty(set)) {
-        bddnode_t n = GETNODE(set);
+        bddnode_t n = BDD_GETNODE(set);
         BDDVAR n_level = bddnode_getvariable(n);
         if (n_level == level) return 1;
         if (n_level > level) return 0; // BDDs are ordered
@@ -2161,7 +2099,7 @@ sylvan_set_toarray(BDDSET set, BDDVAR *arr)
 {
     size_t i = 0;
     while (!sylvan_set_isempty(set)) {
-        bddnode_t n = GETNODE(set);
+        bddnode_t n = BDD_GETNODE(set);
         arr[i++] = bddnode_getvariable(n);
         set = node_high(set, n);
     }
@@ -2183,7 +2121,7 @@ sylvan_test_isset(BDDSET set)
     while (set != sylvan_false) {
         assert(set != sylvan_true);
         assert(llmsset_is_marked(nodes, set));
-        bddnode_t n = GETNODE(set);
+        bddnode_t n = BDD_GETNODE(set);
         assert(node_low(set, n) == sylvan_true);
         set = node_high(set, n);
     }
@@ -2198,7 +2136,7 @@ sylvan_map_add(BDDMAP map, BDDVAR key, BDD value)
 {
     if (sylvan_map_isempty(map)) return sylvan_makenode(key, sylvan_map_empty(), value);
 
-    bddnode_t n = GETNODE(map);
+    bddnode_t n = BDD_GETNODE(map);
     BDDVAR key_m = bddnode_getvariable(n);
 
     if (key_m < key) {
@@ -2221,10 +2159,10 @@ sylvan_map_addall(BDDMAP map_1, BDDMAP map_2)
     if (sylvan_map_isempty(map_1)) return map_2;
     if (sylvan_map_isempty(map_2)) return map_1;
 
-    bddnode_t n_1 = GETNODE(map_1);
+    bddnode_t n_1 = BDD_GETNODE(map_1);
     BDDVAR key_1 = bddnode_getvariable(n_1);
 
-    bddnode_t n_2 = GETNODE(map_2);
+    bddnode_t n_2 = BDD_GETNODE(map_2);
     BDDVAR key_2 = bddnode_getvariable(n_2);
 
     BDDMAP result;
@@ -2249,7 +2187,7 @@ sylvan_map_remove(BDDMAP map, BDDVAR key)
 {
     if (sylvan_map_isempty(map)) return map;
 
-    bddnode_t n = GETNODE(map);
+    bddnode_t n = BDD_GETNODE(map);
     BDDVAR key_m = bddnode_getvariable(n);
 
     if (key_m < key) {
@@ -2269,10 +2207,10 @@ sylvan_map_removeall(BDDMAP map, BDDSET toremove)
     if (sylvan_map_isempty(map)) return map;
     if (sylvan_set_isempty(toremove)) return map;
 
-    bddnode_t n_1 = GETNODE(map);
+    bddnode_t n_1 = BDD_GETNODE(map);
     BDDVAR key_1 = bddnode_getvariable(n_1);
 
-    bddnode_t n_2 = GETNODE(toremove);
+    bddnode_t n_2 = BDD_GETNODE(toremove);
     BDDVAR key_2 = bddnode_getvariable(n_2);
 
     if (key_1 < key_2) {
@@ -2290,7 +2228,7 @@ int
 sylvan_map_in(BDDMAP map, BDDVAR key)
 {
     while (!sylvan_map_isempty(map)) {
-        bddnode_t n = GETNODE(map);
+        bddnode_t n = BDD_GETNODE(map);
         BDDVAR n_level = bddnode_getvariable(n);
         if (n_level == key) return 1;
         if (n_level > key) return 0; // BDDs are ordered
@@ -2312,7 +2250,7 @@ BDDMAP
 sylvan_set_to_map(BDDSET set, BDD value)
 {
     if (sylvan_set_isempty(set)) return sylvan_map_empty();
-    bddnode_t set_n = GETNODE(set);
+    bddnode_t set_n = BDD_GETNODE(set);
     BDD sub = sylvan_set_to_map(node_high(set, set_n), value);
     BDD result = sylvan_makenode(sub, bddnode_getvariable(set_n), value);
     return result;
@@ -2335,7 +2273,7 @@ TASK_IMPL_1(BDD, sylvan_support, BDD, bdd)
         return result;
     }
 
-    bddnode_t n = GETNODE(bdd);
+    bddnode_t n = BDD_GETNODE(bdd);
     BDD high, low, set;
 
     /* compute recursively */
@@ -2359,8 +2297,8 @@ sylvan_unmark_rec(bddnode_t node)
 {
     if (bddnode_getmark(node)) {
         bddnode_setmark(node, 0);
-        if (!sylvan_isconst(bddnode_getlow(node))) sylvan_unmark_rec(GETNODE(bddnode_getlow(node)));
-        if (!sylvan_isconst(bddnode_gethigh(node))) sylvan_unmark_rec(GETNODE(bddnode_gethigh(node)));
+        if (!sylvan_isconst(bddnode_getlow(node))) sylvan_unmark_rec(BDD_GETNODE(bddnode_getlow(node)));
+        if (!sylvan_isconst(bddnode_gethigh(node))) sylvan_unmark_rec(BDD_GETNODE(bddnode_gethigh(node)));
     }
 }
 
@@ -2575,7 +2513,7 @@ static size_t
 sylvan_serialize_assign_rec(BDD bdd)
 {
     if (sylvan_isnode(bdd)) {
-        bddnode_t n = GETNODE(bdd);
+        bddnode_t n = BDD_GETNODE(bdd);
 
         struct sylvan_ser s, *ss;
         s.bdd = BDD_STRIPMARK(bdd);
@@ -2648,7 +2586,7 @@ sylvan_serialize_totext(FILE *out)
 
     while ((s=sylvan_ser_reversed_iter_next(it))) {
         BDD bdd = s->bdd;
-        bddnode_t n = GETNODE(bdd);
+        bddnode_t n = BDD_GETNODE(bdd);
         fprintf(out, "(%zu,%u,%zu,%zu,%u),", s->assigned,
                                              bddnode_getvariable(n),
                                              (size_t)bddnode_getlow(n),
@@ -2683,7 +2621,7 @@ sylvan_serialize_tofile(FILE *out)
         index++;
         assert(s->assigned == index);
 
-        bddnode_t n = GETNODE(s->bdd);
+        bddnode_t n = BDD_GETNODE(s->bdd);
 
         struct bddnode node;
         bddnode_makenode(&node, bddnode_getvariable(n), sylvan_serialize_get(bddnode_getlow(n)), sylvan_serialize_get(bddnode_gethigh(n)));
@@ -2738,7 +2676,7 @@ sylvan_sha2_rec(BDD bdd, SHA256_CTX *ctx)
         return;
     }
 
-    bddnode_t node = GETNODE(bdd);
+    bddnode_t node = BDD_GETNODE(bdd);
     if (bddnode_getmark(node) == 0) {
         bddnode_setmark(node, 1);
         uint32_t level = bddnode_getvariable(node);
@@ -2769,7 +2707,7 @@ sylvan_getsha(BDD bdd, char *target)
     SHA256_CTX ctx;
     SHA256_Init(&ctx);
     sylvan_sha2_rec(bdd, &ctx);
-    if (bdd != sylvan_true && bdd != sylvan_false) sylvan_unmark_rec(GETNODE(bdd));
+    if (bdd != sylvan_true && bdd != sylvan_false) sylvan_unmark_rec(BDD_GETNODE(bdd));
     SHA256_End(&ctx, target);
 }
 
@@ -2790,7 +2728,7 @@ TASK_2(int, sylvan_test_isbdd_rec, BDD, bdd, BDDVAR, parent_var)
         return result;
     }
 
-    bddnode_t n = GETNODE(bdd);
+    bddnode_t n = BDD_GETNODE(bdd);
     BDDVAR var = bddnode_getvariable(n);
     if (var <= parent_var) {
         result = 0;
@@ -2811,10 +2749,12 @@ TASK_IMPL_1(int, sylvan_test_isbdd, BDD, bdd)
 
     assert(llmsset_is_marked(nodes, BDD_STRIPMARK(bdd)));
 
-    bddnode_t n = GETNODE(bdd);
+    bddnode_t n = BDD_GETNODE(bdd);
     BDDVAR var = bddnode_getvariable(n);
     SPAWN(sylvan_test_isbdd_rec, node_low(bdd, n), var);
     int result = CALL(sylvan_test_isbdd_rec, node_high(bdd, n), var);
     if (!SYNC(sylvan_test_isbdd_rec)) result = 0;
     return result;
 }
+
+#include "sylvan_bdd_storm.c"
diff --git a/resources/3rdparty/sylvan/src/sylvan_bdd_int.h b/resources/3rdparty/sylvan/src/sylvan_bdd_int.h
new file mode 100644
index 000000000..1849ba707
--- /dev/null
+++ b/resources/3rdparty/sylvan/src/sylvan_bdd_int.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2011-2015 Formal Methods and Tools, University of Twente
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Internals for BDDs
+ */
+ 
+#ifndef SYLVAN_BDD_INT_H
+#define SYLVAN_BDD_INT_H
+
+/**
+ * Complement handling macros
+ */
+#define BDD_HASMARK(s)              (s&sylvan_complement?1:0)
+#define BDD_TOGGLEMARK(s)           (s^sylvan_complement)
+#define BDD_STRIPMARK(s)            (s&~sylvan_complement)
+#define BDD_TRANSFERMARK(from, to)  (to ^ (from & sylvan_complement))
+// Equal under mark
+#define BDD_EQUALM(a, b)            ((((a)^(b))&(~sylvan_complement))==0)
+
+/**
+ * BDD node structure
+ */
+typedef struct __attribute__((packed)) bddnode {
+    uint64_t a, b;
+} * bddnode_t; // 16 bytes
+
+#define BDD_GETNODE(bdd) ((bddnode_t)llmsset_index_to_ptr(nodes, bdd&0x000000ffffffffff))
+
+static inline int __attribute__((unused))
+bddnode_getcomp(bddnode_t n)
+{
+    return n->a & 0x8000000000000000 ? 1 : 0;
+}
+
+static inline uint64_t
+bddnode_getlow(bddnode_t n)
+{
+    return n->b & 0x000000ffffffffff; // 40 bits
+}
+
+static inline uint64_t
+bddnode_gethigh(bddnode_t n)
+{
+    return n->a & 0x800000ffffffffff; // 40 bits plus high bit of first
+}
+
+static inline uint32_t
+bddnode_getvariable(bddnode_t n)
+{
+    return (uint32_t)(n->b >> 40);
+}
+
+static inline int
+bddnode_getmark(bddnode_t n)
+{
+    return n->a & 0x2000000000000000 ? 1 : 0;
+}
+
+static inline void
+bddnode_setmark(bddnode_t n, int mark)
+{
+    if (mark) n->a |= 0x2000000000000000;
+    else n->a &= 0xdfffffffffffffff;
+}
+
+static inline void
+bddnode_makenode(bddnode_t n, uint32_t var, uint64_t low, uint64_t high)
+{
+    n->a = high;
+    n->b = ((uint64_t)var)<<40 | low;
+}
+
+#endif
diff --git a/resources/3rdparty/sylvan/src/sylvan_bdd_storm.c b/resources/3rdparty/sylvan/src/sylvan_bdd_storm.c
new file mode 100644
index 000000000..d2c80b8b6
--- /dev/null
+++ b/resources/3rdparty/sylvan/src/sylvan_bdd_storm.c
@@ -0,0 +1,171 @@
+/* */
+
+/**
+ * Calculates \exists variables . a
+ */
+TASK_IMPL_3(BDD, sylvan_existsRepresentative, BDD, a, BDD, variables, BDDVAR, prev_level)
+{
+	int aIsNegated = (a & sylvan_complement) == ((uint64_t)0) ? 0 : 1;
+	
+	BDD aRegular = (aIsNegated) ? sylvan_not(a) : a;
+	
+	if (aRegular == sylvan_false) {
+		if (aIsNegated) {
+			if (sylvan_set_isempty(variables)) {
+				//printf("return in preprocessing...2\n");
+				return sylvan_true;
+			} else {
+				//printf("return in preprocessing...3\n");
+				BDD _v = sylvan_set_next(variables);
+				BDD res = CALL(sylvan_existsRepresentative, a, _v, prev_level);
+				if (res == sylvan_invalid) {
+					return sylvan_invalid;
+				}
+				sylvan_ref(res);
+
+				BDD res1 = sylvan_ite(sylvan_ithvar(bddnode_getvariable(BDD_GETNODE(variables))), sylvan_false, res);
+				if (res1 == sylvan_invalid) {
+					sylvan_deref(res);
+					return sylvan_invalid;
+				}
+				sylvan_deref(res);
+				return res1;
+			}
+		} else {
+			return a;
+		}
+	} else if (sylvan_set_isempty(variables)) {
+		//printf("return in preprocessing...4\n");
+		return a;
+	}
+	/* From now on, f and cube are non-constant. */
+	bddnode_t na = BDD_GETNODE(a);
+    BDDVAR level = bddnode_getvariable(na);
+
+    bddnode_t nv = BDD_GETNODE(variables);
+    BDDVAR vv = bddnode_getvariable(nv);
+
+	//printf("a level %i and cube level %i\n", level, vv);
+
+	/* Abstract a variable that does not appear in f. */
+    if (level > vv) {
+		BDD _v = sylvan_set_next(variables);
+        BDD res = CALL(sylvan_existsRepresentative, a, _v, level);
+        if (res == sylvan_invalid) {
+            return sylvan_invalid;
+        }
+        sylvan_ref(res);
+
+        BDD res1 = sylvan_ite(sylvan_ithvar(vv), sylvan_false, res);
+
+        if (res1 == sylvan_invalid) {
+            sylvan_deref(res);
+            return sylvan_invalid;
+        }
+        sylvan_deref(res);
+
+		//printf("return after abstr. var that does not appear in f...\n");
+       	return res1;
+    }
+
+	/* Compute the cofactors of a. */
+	BDD aLow = node_low(a, na); // ELSE
+    BDD aHigh = node_high(a, na); // THEN
+	
+	/* If the two indices are the same, so are their levels. */
+    if (level == vv) {
+		BDD _v = sylvan_set_next(variables);
+        BDD res1 = CALL(sylvan_existsRepresentative, aLow, _v, level);
+        if (res1 == sylvan_invalid) {
+            return sylvan_invalid;
+        }
+        if (res1 == sylvan_true) {
+			return sylvan_not(variables);
+        }
+        sylvan_ref(res1);
+        
+        BDD res2 = CALL(sylvan_existsRepresentative, aHigh, _v, level);
+        if (res2 == sylvan_invalid) {
+            sylvan_deref(res1);
+            return sylvan_invalid;
+        }
+        sylvan_ref(res2);
+        
+        BDD left = CALL(sylvan_exists, aLow, _v, 0);
+        if (left == sylvan_invalid) {
+            sylvan_deref(res1);
+			sylvan_deref(res2);
+            return sylvan_invalid;
+        }
+        sylvan_ref(left);
+
+        BDD res1Inf = sylvan_ite(left, res1, sylvan_false);
+        if (res1Inf == sylvan_invalid) {
+            sylvan_deref(res1);
+			sylvan_deref(res2);
+			sylvan_deref(left);
+            return sylvan_invalid;
+        }
+        sylvan_ref(res1Inf);
+		sylvan_deref(res1);
+
+        BDD res2Inf = sylvan_ite(left, sylvan_false, res2);
+        if (res2Inf == sylvan_invalid) {
+			sylvan_deref(res2);
+			sylvan_deref(left);
+			sylvan_deref(res1Inf);
+            return sylvan_invalid;
+        }
+        sylvan_ref(res2Inf);
+		sylvan_deref(res2);
+		sylvan_deref(left);
+        
+        assert(res1Inf != res2Inf);
+        BDD res = sylvan_ite(sylvan_ithvar(level), res2Inf, res1Inf);
+        if (res == sylvan_invalid) {
+            sylvan_deref(res1Inf);
+			sylvan_deref(res2Inf);
+            return sylvan_invalid;
+        }
+
+        // cuddCacheInsert2(manager, Cudd_bddExistAbstractRepresentative, f, cube, res);
+		// TODO: CACHING HERE
+		
+		sylvan_deref(res1Inf);
+		sylvan_deref(res2Inf);
+		
+		//printf("return properly computed result...\n");
+        return res;
+    } else { /* if (level == vv) */
+        BDD res1 = CALL(sylvan_existsRepresentative, aLow, variables, level);
+        if (res1 == sylvan_invalid){
+            return sylvan_invalid;
+        }
+        sylvan_ref(res1);
+        
+        BDD res2 = CALL(sylvan_existsRepresentative, aHigh, variables, level);
+        if (res2 == sylvan_invalid) {
+            sylvan_deref(res1);
+            return sylvan_invalid;
+        }
+        sylvan_ref(res2);
+        
+        /* ITE takes care of possible complementation of res1 and of the
+         ** case in which res1 == res2. */
+		BDD res = sylvan_ite(sylvan_ithvar(level), res2, res1);
+        if (res == sylvan_invalid) {
+            sylvan_deref(res1);
+			sylvan_deref(res2);
+            return sylvan_invalid;
+        }
+        
+		sylvan_deref(res1);
+		sylvan_deref(res2);
+		
+		//printf("return of last case...\n");
+        return res;
+    }
+	
+	// Prevent unused variable warning
+	(void)prev_level;
+}
diff --git a/resources/3rdparty/sylvan/src/sylvan_bdd_storm.h b/resources/3rdparty/sylvan/src/sylvan_bdd_storm.h
index 5806fba5d..f28259a84 100644
--- a/resources/3rdparty/sylvan/src/sylvan_bdd_storm.h
+++ b/resources/3rdparty/sylvan/src/sylvan_bdd_storm.h
@@ -1,3 +1,6 @@
 #define bdd_isnegated(dd) ((dd & sylvan_complement) ? 1 : 0)
 #define bdd_regular(dd) (dd & ~sylvan_complement)
-#define bdd_isterminal(dd) (dd == sylvan_false || dd == sylvan_true)
\ No newline at end of file
+#define bdd_isterminal(dd) (dd == sylvan_false || dd == sylvan_true)
+
+TASK_DECL_3(BDD, sylvan_existsRepresentative, BDD, BDD, BDDVAR);
+#define sylvan_existsRepresentative(a, vars) (CALL(sylvan_existsRepresentative, a, vars, 0))
diff --git a/resources/3rdparty/sylvan/src/sylvan_gmp.c b/resources/3rdparty/sylvan/src/sylvan_gmp.c
index 0437b1be8..5dd05f3ed 100644
--- a/resources/3rdparty/sylvan/src/sylvan_gmp.c
+++ b/resources/3rdparty/sylvan/src/sylvan_gmp.c
@@ -549,13 +549,13 @@ TASK_IMPL_3(MTBDD, gmp_and_exists, MTBDD, a, MTBDD, b, MTBDD, v)
     /* Get top variable */
     int la = mtbdd_isleaf(a);
     int lb = mtbdd_isleaf(b);
-    mtbddnode_t na = la ? 0 : GETNODE(a);
-    mtbddnode_t nb = lb ? 0 : GETNODE(b);
+    mtbddnode_t na = la ? 0 : MTBDD_GETNODE(a);
+    mtbddnode_t nb = lb ? 0 : MTBDD_GETNODE(b);
     uint32_t va = la ? 0xffffffff : mtbddnode_getvariable(na);
     uint32_t vb = lb ? 0xffffffff : mtbddnode_getvariable(nb);
     uint32_t var = va < vb ? va : vb;
 
-    mtbddnode_t nv = GETNODE(v);
+    mtbddnode_t nv = MTBDD_GETNODE(v);
     uint32_t vv = mtbddnode_getvariable(nv);
 
     if (vv < var) {
diff --git a/resources/3rdparty/sylvan/src/sylvan_mtbdd.c b/resources/3rdparty/sylvan/src/sylvan_mtbdd.c
index a4eb1bd62..a603e44ef 100644
--- a/resources/3rdparty/sylvan/src/sylvan_mtbdd.c
+++ b/resources/3rdparty/sylvan/src/sylvan_mtbdd.c
@@ -31,44 +31,49 @@
 #include 
 #include 
 
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+#include 
+#include 
+#endif
+
 /* Primitives */
 int
 mtbdd_isleaf(MTBDD bdd)
 {
     if (bdd == mtbdd_true || bdd == mtbdd_false) return 1;
-    return mtbddnode_isleaf(GETNODE(bdd));
+    return mtbddnode_isleaf(MTBDD_GETNODE(bdd));
 }
 
 // for nodes
 uint32_t
 mtbdd_getvar(MTBDD node)
 {
-    return mtbddnode_getvariable(GETNODE(node));
+    return mtbddnode_getvariable(MTBDD_GETNODE(node));
 }
 
 MTBDD
 mtbdd_getlow(MTBDD mtbdd)
 {
-    return node_getlow(mtbdd, GETNODE(mtbdd));
+    return node_getlow(mtbdd, MTBDD_GETNODE(mtbdd));
 }
 
 MTBDD
 mtbdd_gethigh(MTBDD mtbdd)
 {
-    return node_gethigh(mtbdd, GETNODE(mtbdd));
+    return node_gethigh(mtbdd, MTBDD_GETNODE(mtbdd));
 }
 
 // for leaves
 uint32_t
 mtbdd_gettype(MTBDD leaf)
 {
-    return mtbddnode_gettype(GETNODE(leaf));
+    return mtbddnode_gettype(MTBDD_GETNODE(leaf));
 }
 
 uint64_t
 mtbdd_getvalue(MTBDD leaf)
 {
-    return mtbddnode_getvalue(GETNODE(leaf));
+    return mtbddnode_getvalue(MTBDD_GETNODE(leaf));
 }
 
 // for leaf type 0 (integer)
@@ -98,7 +103,7 @@ VOID_TASK_IMPL_1(mtbdd_gc_mark_rec, MDD, mtbdd)
     if (mtbdd == mtbdd_false) return;
 
     if (llmsset_mark(nodes, mtbdd&(~mtbdd_complement))) {
-        mtbddnode_t n = GETNODE(mtbdd);
+        mtbddnode_t n = MTBDD_GETNODE(mtbdd);
         if (!mtbddnode_isleaf(n)) {
             SPAWN(mtbdd_gc_mark_rec, mtbddnode_getlow(n));
             CALL(mtbdd_gc_mark_rec, mtbddnode_gethigh(n));
@@ -264,9 +269,15 @@ _mtbdd_create_cb(uint64_t *a, uint64_t *b)
     // for leaf
     if ((*a & 0x4000000000000000) == 0) return; // huh?
     uint32_t type = *a & 0xffffffff;
-    if (type >= cl_registry_count) return; // not in registry
+    if (type >= cl_registry_count) { // not in registry
+		printf("ERROR: type >= cl_registry_count!");
+		return;
+	}
     customleaf_t *c = cl_registry + type;
-    if (c->create_cb == NULL) return; // not in registry
+    if (c->create_cb == NULL) { // not in registry
+		printf("ERROR: create_cb is NULL!");
+		return;
+	}
     c->create_cb(b);
 }
 
@@ -276,9 +287,15 @@ _mtbdd_destroy_cb(uint64_t a, uint64_t b)
     // for leaf
     if ((a & 0x4000000000000000) == 0) return; // huh?
     uint32_t type = a & 0xffffffff;
-    if (type >= cl_registry_count) return; // not in registry
+    if (type >= cl_registry_count) { // not in registry
+		printf("ERROR: type >= cl_registry_count! (2)");
+		return;
+	}
     customleaf_t *c = cl_registry + type;
-    if (c->destroy_cb == NULL) return; // not in registry
+    if (c->destroy_cb == NULL) { // not in registry
+		printf("ERROR: destroy_cb is NULL!");
+		return;
+	}
     c->destroy_cb(b);
 }
 
@@ -519,7 +536,7 @@ MTBDD
 mtbdd_cube(MTBDD variables, uint8_t *cube, MTBDD terminal)
 {
     if (variables == mtbdd_true) return terminal;
-    mtbddnode_t n = GETNODE(variables);
+    mtbddnode_t n = MTBDD_GETNODE(variables);
 
     BDD result;
     switch (*cube) {
@@ -536,7 +553,7 @@ mtbdd_cube(MTBDD variables, uint8_t *cube, MTBDD terminal)
     case 3:
     {
         MTBDD variables2 = node_gethigh(variables, n);
-        mtbddnode_t n2 = GETNODE(variables2);
+        mtbddnode_t n2 = MTBDD_GETNODE(variables2);
         uint32_t var2 = mtbddnode_getvariable(n2);
         result = mtbdd_cube(node_gethigh(variables2, n2), cube+2, terminal);
         BDD low = mtbdd_makenode(var2, result, mtbdd_false);
@@ -564,10 +581,10 @@ TASK_IMPL_4(MTBDD, mtbdd_union_cube, MTBDD, mtbdd, MTBDD, vars, uint8_t*, cube,
 
     sylvan_gc_test();
 
-    mtbddnode_t nv = GETNODE(vars);
+    mtbddnode_t nv = MTBDD_GETNODE(vars);
     uint32_t v = mtbddnode_getvariable(nv);
 
-    mtbddnode_t na = GETNODE(mtbdd);
+    mtbddnode_t na = MTBDD_GETNODE(mtbdd);
     uint32_t va = mtbddnode_getvariable(na);
 
     if (va < v) {
@@ -665,14 +682,14 @@ TASK_IMPL_3(MTBDD, mtbdd_apply, MTBDD, a, MTBDD, b, mtbdd_apply_op, op)
     mtbddnode_t na, nb;
     uint32_t va, vb;
     if (!la) {
-        na = GETNODE(a);
+        na = MTBDD_GETNODE(a);
         va = mtbddnode_getvariable(na);
     } else {
         na = 0;
         va = 0xffffffff;
     }
     if (!lb) {
-        nb = GETNODE(b);
+        nb = MTBDD_GETNODE(b);
         vb = mtbddnode_getvariable(nb);
     } else {
         nb = 0;
@@ -730,14 +747,14 @@ TASK_IMPL_5(MTBDD, mtbdd_applyp, MTBDD, a, MTBDD, b, size_t, p, mtbdd_applyp_op,
     mtbddnode_t na, nb;
     uint32_t va, vb;
     if (!la) {
-        na = GETNODE(a);
+        na = MTBDD_GETNODE(a);
         va = mtbddnode_getvariable(na);
     } else {
         na = 0;
         va = 0xffffffff;
     }
     if (!lb) {
-        nb = GETNODE(b);
+        nb = MTBDD_GETNODE(b);
         vb = mtbddnode_getvariable(nb);
     } else {
         nb = 0;
@@ -795,7 +812,7 @@ TASK_IMPL_3(MTBDD, mtbdd_uapply, MTBDD, dd, mtbdd_uapply_op, op, size_t, param)
     }
 
     /* Get cofactors */
-    mtbddnode_t ndd = GETNODE(dd);
+    mtbddnode_t ndd = MTBDD_GETNODE(dd);
     MTBDD ddlow = node_getlow(dd, ndd);
     MTBDD ddhigh = node_gethigh(dd, ndd);
 
@@ -817,7 +834,7 @@ TASK_2(MTBDD, mtbdd_uop_times_uint, MTBDD, a, size_t, k)
     if (a == mtbdd_true) return mtbdd_true;
 
     // a != constant
-    mtbddnode_t na = GETNODE(a);
+    mtbddnode_t na = MTBDD_GETNODE(a);
 
     if (mtbddnode_isleaf(na)) {
         if (mtbddnode_gettype(na) == 0) {
@@ -833,6 +850,11 @@ TASK_2(MTBDD, mtbdd_uop_times_uint, MTBDD, a, size_t, k)
             uint32_t c = gcd(d, (uint32_t)k);
             return mtbdd_fraction(n*(k/c), d/c);
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+			printf("ERROR mtbdd_uop_times_uint type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID");
+		}
+#endif
     }
 
     return mtbdd_invalid;
@@ -844,7 +866,7 @@ TASK_2(MTBDD, mtbdd_uop_pow_uint, MTBDD, a, size_t, k)
     if (a == mtbdd_true) return mtbdd_true;
 
     // a != constant
-    mtbddnode_t na = GETNODE(a);
+    mtbddnode_t na = MTBDD_GETNODE(a);
 
     if (mtbddnode_isleaf(na)) {
         if (mtbddnode_gettype(na) == 0) {
@@ -857,6 +879,11 @@ TASK_2(MTBDD, mtbdd_uop_pow_uint, MTBDD, a, size_t, k)
             uint64_t v = mtbddnode_getvalue(na);
             return mtbdd_fraction(pow((int32_t)(v>>32), k), (uint32_t)v);
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+			printf("ERROR mtbdd_uop_pow_uint type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID");
+		}
+#endif
     }
 
     return mtbdd_invalid;
@@ -906,14 +933,14 @@ TASK_IMPL_3(MTBDD, mtbdd_abstract, MTBDD, a, MTBDD, v, mtbdd_abstract_op, op)
     sylvan_gc_test();
 
     /* a != constant, v != constant */
-    mtbddnode_t na = GETNODE(a);
+    mtbddnode_t na = MTBDD_GETNODE(a);
 
     if (mtbddnode_isleaf(na)) {
         /* Count number of variables */
         uint64_t k = 0;
         while (v != mtbdd_true) {
             k++;
-            v = node_gethigh(v, GETNODE(v));
+            v = node_gethigh(v, MTBDD_GETNODE(v));
         }
 
         /* Check cache */
@@ -929,7 +956,7 @@ TASK_IMPL_3(MTBDD, mtbdd_abstract, MTBDD, a, MTBDD, v, mtbdd_abstract_op, op)
     }
 
     /* Possibly skip k variables */
-    mtbddnode_t nv = GETNODE(v);
+    mtbddnode_t nv = MTBDD_GETNODE(v);
     uint32_t var_a = mtbddnode_getvariable(na);
     uint32_t var_v = mtbddnode_getvariable(nv);
     uint64_t k = 0;
@@ -937,7 +964,7 @@ TASK_IMPL_3(MTBDD, mtbdd_abstract, MTBDD, a, MTBDD, v, mtbdd_abstract_op, op)
         k++;
         v = node_gethigh(v, nv);
         if (v == mtbdd_true) break;
-        nv = GETNODE(v);
+        nv = MTBDD_GETNODE(v);
         var_v = mtbddnode_getvariable(nv);
     }
 
@@ -988,8 +1015,8 @@ TASK_IMPL_2(MTBDD, mtbdd_op_plus, MTBDD*, pa, MTBDD*, pb)
     if (a == mtbdd_true) return mtbdd_true;
     if (b == mtbdd_true) return mtbdd_true;
 
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
 
     if (mtbddnode_isleaf(na) && mtbddnode_isleaf(nb)) {
         uint64_t val_a = mtbddnode_getvalue(na);
@@ -1017,6 +1044,11 @@ TASK_IMPL_2(MTBDD, mtbdd_op_plus, MTBDD*, pa, MTBDD*, pb)
             // add
             return mtbdd_fraction(nom_a + nom_b, denom_a);
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID && mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+			printf("ERROR mtbdd_op_plus type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID");
+		}
+#endif
     }
 
     if (a < b) {
@@ -1038,8 +1070,8 @@ TASK_IMPL_2(MTBDD, mtbdd_op_minus, MTBDD*, pa, MTBDD*, pb)
     if (a == mtbdd_false) return mtbdd_negate(b);
     if (b == mtbdd_false) return a;
 
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
 
     if (mtbddnode_isleaf(na) && mtbddnode_isleaf(nb)) {
         uint64_t val_a = mtbddnode_getvalue(na);
@@ -1066,6 +1098,11 @@ TASK_IMPL_2(MTBDD, mtbdd_op_minus, MTBDD*, pa, MTBDD*, pb)
             // subtract
             return mtbdd_fraction(nom_a - nom_b, denom_a);
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if ((mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) && (mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID)) {
+			printf("ERROR: mtbdd_op_minus type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID.\n");
+		}
+#endif
     }
 
     return mtbdd_invalid;
@@ -1086,8 +1123,8 @@ TASK_IMPL_2(MTBDD, mtbdd_op_times, MTBDD*, pa, MTBDD*, pb)
     if (a == mtbdd_true) return b;
     if (b == mtbdd_true) return a;
 
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
 
     if (mtbddnode_isleaf(na) && mtbddnode_isleaf(nb)) {
         uint64_t val_a = mtbddnode_getvalue(na);
@@ -1113,6 +1150,11 @@ TASK_IMPL_2(MTBDD, mtbdd_op_times, MTBDD*, pa, MTBDD*, pb)
             denom_a *= (denom_b/d);
             return mtbdd_fraction(nom_a, denom_a);
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if ((mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) && (mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID)) {
+			printf("ERROR: mtbdd_op_times type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID.\n");
+		}
+#endif
     }
 
     if (a < b) {
@@ -1137,11 +1179,11 @@ TASK_IMPL_2(MTBDD, mtbdd_op_min, MTBDD*, pa, MTBDD*, pb)
     if (a == b) return a;
 
     // Special case where "false" indicates a partial function
-    if (a == mtbdd_false && b != mtbdd_false && mtbddnode_isleaf(GETNODE(b))) return b;
-    if (b == mtbdd_false && a != mtbdd_false && mtbddnode_isleaf(GETNODE(a))) return a;
+    if (a == mtbdd_false && b != mtbdd_false && mtbddnode_isleaf(MTBDD_GETNODE(b))) return b;
+    if (b == mtbdd_false && a != mtbdd_false && mtbddnode_isleaf(MTBDD_GETNODE(a))) return a;
 
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
 
     if (mtbddnode_isleaf(na) && mtbddnode_isleaf(nb)) {
         uint64_t val_a = mtbddnode_getvalue(na);
@@ -1169,6 +1211,11 @@ TASK_IMPL_2(MTBDD, mtbdd_op_min, MTBDD*, pa, MTBDD*, pb)
             // compute lowest
             return nom_a < nom_b ? a : b;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if ((mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) && (mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID)) {
+			printf("ERROR: mtbdd_op_min type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID.\n");
+		}
+#endif
     }
 
     if (a < b) {
@@ -1194,8 +1241,8 @@ TASK_IMPL_2(MTBDD, mtbdd_op_max, MTBDD*, pa, MTBDD*, pb)
     if (b == mtbdd_false) return a;
     if (a == b) return a;
 
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
 
     if (mtbddnode_isleaf(na) && mtbddnode_isleaf(nb)) {
         uint64_t val_a = mtbddnode_getvalue(na);
@@ -1223,6 +1270,11 @@ TASK_IMPL_2(MTBDD, mtbdd_op_max, MTBDD*, pa, MTBDD*, pb)
             // compute highest
             return nom_a > nom_b ? a : b;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if ((mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) && (mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID)) {
+			printf("ERROR: mtbdd_op_max type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID.\n");
+		}
+#endif
     }
 
     if (a < b) {
@@ -1239,7 +1291,7 @@ TASK_IMPL_2(MTBDD, mtbdd_op_negate, MTBDD, a, size_t, k)
     if (a == mtbdd_false) return mtbdd_false;
 
     // a != constant
-    mtbddnode_t na = GETNODE(a);
+    mtbddnode_t na = MTBDD_GETNODE(a);
 
     if (mtbddnode_isleaf(na)) {
         if (mtbddnode_gettype(na) == 0) {
@@ -1252,6 +1304,11 @@ TASK_IMPL_2(MTBDD, mtbdd_op_negate, MTBDD, a, size_t, k)
             uint64_t v = mtbddnode_getvalue(na);
             return mtbdd_fraction(-(int32_t)(v>>32), (uint32_t)v);
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if ((mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID)) {
+			printf("ERROR: mtbdd_op_negate type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID.\n");
+		}
+#endif
     }
 
     return mtbdd_invalid;
@@ -1283,9 +1340,9 @@ TASK_IMPL_3(MTBDD, mtbdd_ite, MTBDD, f, MTBDD, g, MTBDD, h)
     /* Get top variable */
     int lg = mtbdd_isleaf(g);
     int lh = mtbdd_isleaf(h);
-    mtbddnode_t nf = GETNODE(f);
-    mtbddnode_t ng = lg ? 0 : GETNODE(g);
-    mtbddnode_t nh = lh ? 0 : GETNODE(h);
+    mtbddnode_t nf = MTBDD_GETNODE(f);
+    mtbddnode_t ng = lg ? 0 : MTBDD_GETNODE(g);
+    mtbddnode_t nh = lh ? 0 : MTBDD_GETNODE(h);
     uint32_t vf = mtbddnode_getvariable(nf);
     uint32_t vg = lg ? 0 : mtbddnode_getvariable(ng);
     uint32_t vh = lh ? 0 : mtbddnode_getvariable(nh);
@@ -1324,7 +1381,7 @@ TASK_IMPL_2(MTBDD, mtbdd_op_threshold_double, MTBDD, a, size_t, svalue)
     if (a == mtbdd_true) return mtbdd_invalid;
 
     // a != constant
-    mtbddnode_t na = GETNODE(a);
+    mtbddnode_t na = MTBDD_GETNODE(a);
 
     if (mtbddnode_isleaf(na)) {
         double value = *(double*)&svalue;
@@ -1335,6 +1392,11 @@ TASK_IMPL_2(MTBDD, mtbdd_op_threshold_double, MTBDD, a, size_t, svalue)
             d /= mtbdd_getdenom(a);
             return d >= value ? mtbdd_true : mtbdd_false;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if ((mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID)) {
+			printf("ERROR: mtbdd_op_threshold_double type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID.\n");
+		}
+#endif
     }
 
     return mtbdd_invalid;
@@ -1350,7 +1412,7 @@ TASK_IMPL_2(MTBDD, mtbdd_op_strict_threshold_double, MTBDD, a, size_t, svalue)
     if (a == mtbdd_true) return mtbdd_invalid;
 
     // a != constant
-    mtbddnode_t na = GETNODE(a);
+    mtbddnode_t na = MTBDD_GETNODE(a);
 
     if (mtbddnode_isleaf(na)) {
         double value = *(double*)&svalue;
@@ -1361,6 +1423,11 @@ TASK_IMPL_2(MTBDD, mtbdd_op_strict_threshold_double, MTBDD, a, size_t, svalue)
             d /= mtbdd_getdenom(a);
             return d > value ? mtbdd_true : mtbdd_false;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if ((mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID)) {
+			printf("ERROR: mtbdd_op_strict_threshold_double type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID.\n");
+		}
+#endif
     }
 
     return mtbdd_invalid;
@@ -1389,8 +1456,8 @@ TASK_4(MTBDD, mtbdd_equal_norm_d2, MTBDD, a, MTBDD, b, size_t, svalue, int*, sho
     if (a == mtbdd_false) return mtbdd_false;
     if (b == mtbdd_false) return mtbdd_false;
 
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
     int la = mtbddnode_isleaf(na);
     int lb = mtbddnode_isleaf(nb);
 
@@ -1461,8 +1528,8 @@ TASK_4(MTBDD, mtbdd_equal_norm_rel_d2, MTBDD, a, MTBDD, b, size_t, svalue, int*,
     if (a == mtbdd_false) return mtbdd_false;
     if (b == mtbdd_false) return mtbdd_false;
 
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
     int la = mtbddnode_isleaf(na);
     int lb = mtbddnode_isleaf(nb);
 
@@ -1537,8 +1604,8 @@ TASK_3(MTBDD, mtbdd_leq_rec, MTBDD, a, MTBDD, b, int*, shortcircuit)
     MTBDD result;
     if (cache_get3(CACHE_MTBDD_LEQ, a, b, 0, &result)) return result;
 
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
     int la = mtbddnode_isleaf(na);
     int lb = mtbddnode_isleaf(nb);
 
@@ -1566,6 +1633,11 @@ TASK_3(MTBDD, mtbdd_leq_rec, MTBDD, a, MTBDD, b, int*, shortcircuit)
             nom_b *= da/c;
             result = nom_a <= nom_b ? mtbdd_true : mtbdd_false;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID && mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+            printf("ERROR: mtbdd_leq_rec type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID\n");
+        }
+#endif
     } else {
         /* Get top variable */
         uint32_t va = la ? 0xffffffff : mtbddnode_getvariable(na);
@@ -1622,8 +1694,8 @@ TASK_3(MTBDD, mtbdd_less_rec, MTBDD, a, MTBDD, b, int*, shortcircuit)
     MTBDD result;
     if (cache_get3(CACHE_MTBDD_LESS, a, b, 0, &result)) return result;
 
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
     int la = mtbddnode_isleaf(na);
     int lb = mtbddnode_isleaf(nb);
 
@@ -1651,6 +1723,11 @@ TASK_3(MTBDD, mtbdd_less_rec, MTBDD, a, MTBDD, b, int*, shortcircuit)
             nom_b *= da/c;
             result = nom_a < nom_b ? mtbdd_true : mtbdd_false;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID && mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+            printf("ERROR: mtbdd_less_rec type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID\n");
+        }
+#endif
     } else {
         /* Get top variable */
         uint32_t va = la ? 0xffffffff : mtbddnode_getvariable(na);
@@ -1707,8 +1784,8 @@ TASK_3(MTBDD, mtbdd_geq_rec, MTBDD, a, MTBDD, b, int*, shortcircuit)
     MTBDD result;
     if (cache_get3(CACHE_MTBDD_GEQ, a, b, 0, &result)) return result;
 
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
     int la = mtbddnode_isleaf(na);
     int lb = mtbddnode_isleaf(nb);
 
@@ -1736,6 +1813,11 @@ TASK_3(MTBDD, mtbdd_geq_rec, MTBDD, a, MTBDD, b, int*, shortcircuit)
             nom_b *= da/c;
             result = nom_a >= nom_b ? mtbdd_true : mtbdd_false;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID && mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+            printf("ERROR: mtbdd_geq_rec type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID\n");
+        }
+#endif
     } else {
         /* Get top variable */
         uint32_t va = la ? 0xffffffff : mtbddnode_getvariable(na);
@@ -1792,8 +1874,8 @@ TASK_3(MTBDD, mtbdd_greater_rec, MTBDD, a, MTBDD, b, int*, shortcircuit)
     MTBDD result;
     if (cache_get3(CACHE_MTBDD_GREATER, a, b, 0, &result)) return result;
 
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
     int la = mtbddnode_isleaf(na);
     int lb = mtbddnode_isleaf(nb);
 
@@ -1821,6 +1903,11 @@ TASK_3(MTBDD, mtbdd_greater_rec, MTBDD, a, MTBDD, b, int*, shortcircuit)
             nom_b *= da/c;
             result = nom_a > nom_b ? mtbdd_true : mtbdd_false;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID && mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+            printf("ERROR: mtbdd_greater_rec type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID\n");
+        }
+#endif
     } else {
         /* Get top variable */
         uint32_t va = la ? 0xffffffff : mtbddnode_getvariable(na);
@@ -1881,13 +1968,13 @@ TASK_IMPL_3(MTBDD, mtbdd_and_exists, MTBDD, a, MTBDD, b, MTBDD, v)
     /* Get top variable */
     int la = mtbdd_isleaf(a);
     int lb = mtbdd_isleaf(b);
-    mtbddnode_t na = la ? 0 : GETNODE(a);
-    mtbddnode_t nb = lb ? 0 : GETNODE(b);
+    mtbddnode_t na = la ? 0 : MTBDD_GETNODE(a);
+    mtbddnode_t nb = lb ? 0 : MTBDD_GETNODE(b);
     uint32_t va = la ? 0xffffffff : mtbddnode_getvariable(na);
     uint32_t vb = lb ? 0xffffffff : mtbddnode_getvariable(nb);
     uint32_t var = va < vb ? va : vb;
 
-    mtbddnode_t nv = GETNODE(v);
+    mtbddnode_t nv = MTBDD_GETNODE(v);
     uint32_t vv = mtbddnode_getvariable(nv);
 
     if (vv < var) {
@@ -1942,7 +2029,7 @@ TASK_IMPL_1(MTBDD, mtbdd_support, MTBDD, dd)
     if (cache_get3(CACHE_MTBDD_SUPPORT, dd, 0, 0, &result)) return result;
 
     /* Recursive calls */
-    mtbddnode_t n = GETNODE(dd);
+    mtbddnode_t n = MTBDD_GETNODE(dd);
     mtbdd_refs_spawn(SPAWN(mtbdd_support, node_getlow(dd, n)));
     MTBDD high = mtbdd_refs_push(CALL(mtbdd_support, node_gethigh(dd, n)));
     MTBDD low = mtbdd_refs_push(mtbdd_refs_sync(SYNC(mtbdd_support)));
@@ -1967,7 +2054,7 @@ TASK_IMPL_2(MTBDD, mtbdd_compose, MTBDD, a, MTBDDMAP, map)
     if (mtbdd_isleaf(a) || mtbdd_map_isempty(map)) return a;
 
     /* Determine top level */
-    mtbddnode_t n = GETNODE(a);
+    mtbddnode_t n = MTBDD_GETNODE(a);
     uint32_t v = mtbddnode_getvariable(n);
 
     /* Find in map */
@@ -2006,7 +2093,7 @@ TASK_IMPL_1(MTBDD, mtbdd_minimum, MTBDD, a)
 {
     /* Check terminal case */
     if (a == mtbdd_false) return mtbdd_false;
-    mtbddnode_t na = GETNODE(a);
+    mtbddnode_t na = MTBDD_GETNODE(a);
     if (mtbddnode_isleaf(na)) return a;
 
     /* Maybe perform garbage collection */
@@ -2022,8 +2109,8 @@ TASK_IMPL_1(MTBDD, mtbdd_minimum, MTBDD, a)
     MTBDD low = SYNC(mtbdd_minimum);
 
     /* Determine lowest */
-    mtbddnode_t nl = GETNODE(low);
-    mtbddnode_t nh = GETNODE(high);
+    mtbddnode_t nl = MTBDD_GETNODE(low);
+    mtbddnode_t nh = MTBDD_GETNODE(high);
 
     if (mtbddnode_gettype(nl) == 0 && mtbddnode_gettype(nh) == 0) {
         result = mtbdd_getint64(low) < mtbdd_getint64(high) ? low : high;
@@ -2041,6 +2128,11 @@ TASK_IMPL_1(MTBDD, mtbdd_minimum, MTBDD, a)
         nom_h *= denom_l/c;
         result = nom_l < nom_h ? low : high;
     }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+	else if (mtbddnode_gettype(nl) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID && mtbddnode_gettype(nh) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+		printf("ERROR: mtbdd_minimum type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID\n");
+	}
+#endif
 
     /* Store in cache */
     cache_put3(CACHE_MTBDD_MINIMUM, a, 0, 0, result);
@@ -2054,7 +2146,7 @@ TASK_IMPL_1(MTBDD, mtbdd_maximum, MTBDD, a)
 {
     /* Check terminal case */
     if (a == mtbdd_false) return mtbdd_false;
-    mtbddnode_t na = GETNODE(a);
+    mtbddnode_t na = MTBDD_GETNODE(a);
     if (mtbddnode_isleaf(na)) return a;
 
     /* Maybe perform garbage collection */
@@ -2070,8 +2162,8 @@ TASK_IMPL_1(MTBDD, mtbdd_maximum, MTBDD, a)
     MTBDD low = SYNC(mtbdd_maximum);
 
     /* Determine highest */
-    mtbddnode_t nl = GETNODE(low);
-    mtbddnode_t nh = GETNODE(high);
+    mtbddnode_t nl = MTBDD_GETNODE(low);
+    mtbddnode_t nh = MTBDD_GETNODE(high);
 
     if (mtbddnode_gettype(nl) == 0 && mtbddnode_gettype(nh) == 0) {
         result = mtbdd_getint64(low) > mtbdd_getint64(high) ? low : high;
@@ -2089,6 +2181,11 @@ TASK_IMPL_1(MTBDD, mtbdd_maximum, MTBDD, a)
         nom_h *= denom_l/c;
         result = nom_l > nom_h ? low : high;
     }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+	else if (mtbddnode_gettype(nl) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID && mtbddnode_gettype(nh) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+		printf("ERROR: mtbdd_maximum type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID\n");
+	}
+#endif
 
     /* Store in cache */
     cache_put3(CACHE_MTBDD_MAXIMUM, a, 0, 0, result);
@@ -2151,7 +2248,7 @@ mtbdd_enum_first(MTBDD dd, MTBDD variables, uint8_t *arr, mtbdd_enum_filter_cb f
         variables = mtbdd_gethigh(variables);
 
         // check if MTBDD is on this variable
-        mtbddnode_t n = GETNODE(dd);
+        mtbddnode_t n = MTBDD_GETNODE(dd);
         if (mtbddnode_getvariable(n) != v) {
             *arr = 2;
             return mtbdd_enum_first(dd, variables, arr+1, filter_cb);
@@ -2191,7 +2288,7 @@ mtbdd_enum_next(MTBDD dd, MTBDD variables, uint8_t *arr, mtbdd_enum_filter_cb fi
 
         if (*arr == 0) {
             // previous was low
-            mtbddnode_t n = GETNODE(dd);
+            mtbddnode_t n = MTBDD_GETNODE(dd);
             MTBDD res = mtbdd_enum_next(node_getlow(dd, n), variables, arr+1, filter_cb);
             if (res != mtbdd_false) {
                 return res;
@@ -2207,7 +2304,7 @@ mtbdd_enum_next(MTBDD dd, MTBDD variables, uint8_t *arr, mtbdd_enum_filter_cb fi
             }
         } else if (*arr == 1) {
             // previous was high
-            mtbddnode_t n = GETNODE(dd);
+            mtbddnode_t n = MTBDD_GETNODE(dd);
             return mtbdd_enum_next(node_gethigh(dd, n), variables, arr+1, filter_cb);
         } else {
             // previous was either
@@ -2222,7 +2319,7 @@ mtbdd_enum_next(MTBDD dd, MTBDD variables, uint8_t *arr, mtbdd_enum_filter_cb fi
 static void
 mtbdd_unmark_rec(MTBDD mtbdd)
 {
-    mtbddnode_t n = GETNODE(mtbdd);
+    mtbddnode_t n = MTBDD_GETNODE(mtbdd);
     if (!mtbddnode_getmark(n)) return;
     mtbddnode_setmark(n, 0);
     if (mtbddnode_isleaf(n)) return;
@@ -2237,12 +2334,20 @@ mtbdd_unmark_rec(MTBDD mtbdd)
 static size_t
 mtbdd_leafcount_mark(MTBDD mtbdd)
 {
-    if (mtbdd == mtbdd_true) return 0; // do not count true/false leaf
-    if (mtbdd == mtbdd_false) return 0; // do not count true/false leaf
-    mtbddnode_t n = GETNODE(mtbdd);
-    if (mtbddnode_getmark(n)) return 0;
+    if (mtbdd == mtbdd_true) { // do not count true/false leaf
+		return 0;
+	}
+    if (mtbdd == mtbdd_false) { // do not count true/false leaf
+		return 0;
+	}
+    mtbddnode_t n = MTBDD_GETNODE(mtbdd);
+    if (mtbddnode_getmark(n)) {
+		return 0;
+	}
     mtbddnode_setmark(n, 1);
-    if (mtbddnode_isleaf(n)) return 1; // count leaf as 1
+    if (mtbddnode_isleaf(n)) { // count leaf as 1
+		return 1;
+	}
     return mtbdd_leafcount_mark(mtbddnode_getlow(n)) + mtbdd_leafcount_mark(mtbddnode_gethigh(n));
 }
 
@@ -2263,7 +2368,7 @@ mtbdd_nodecount_mark(MTBDD mtbdd)
 {
     if (mtbdd == mtbdd_true) return 0; // do not count true/false leaf
     if (mtbdd == mtbdd_false) return 0; // do not count true/false leaf
-    mtbddnode_t n = GETNODE(mtbdd);
+    mtbddnode_t n = MTBDD_GETNODE(mtbdd);
     if (mtbddnode_getmark(n)) return 0;
     mtbddnode_setmark(n, 1);
     if (mtbddnode_isleaf(n)) return 1; // count leaf as 1
@@ -2294,7 +2399,7 @@ TASK_2(int, mtbdd_test_isvalid_rec, MTBDD, dd, uint32_t, parent_var)
     if (marked == 0) return 0;
 
     // check if leaf
-    mtbddnode_t n = GETNODE(dd);
+    mtbddnode_t n = MTBDD_GETNODE(dd);
     if (mtbddnode_isleaf(n)) return 1; // we're fine
 
     // check variable order
@@ -2334,7 +2439,7 @@ TASK_IMPL_1(int, mtbdd_test_isvalid, MTBDD, dd)
     if (marked == 0) return 0;
 
     // check if leaf
-    mtbddnode_t n = GETNODE(dd);
+    mtbddnode_t n = MTBDD_GETNODE(dd);
     if (mtbddnode_isleaf(n)) return 1; // we're fine
 
     // check recursively
@@ -2352,7 +2457,7 @@ TASK_IMPL_1(int, mtbdd_test_isvalid, MTBDD, dd)
 static void
 mtbdd_fprintdot_rec(FILE *out, MTBDD mtbdd, print_terminal_label_cb cb)
 {
-    mtbddnode_t n = GETNODE(mtbdd); // also works for mtbdd_false
+    mtbddnode_t n = MTBDD_GETNODE(mtbdd); // also works for mtbdd_false
     if (mtbddnode_getmark(n)) return;
     mtbddnode_setmark(n, 1);
 
@@ -2372,6 +2477,12 @@ mtbdd_fprintdot_rec(FILE *out, MTBDD mtbdd, print_terminal_label_cb cb)
         case 2:
             fprintf(out, "%u/%u", (uint32_t)(value>>32), (uint32_t)value);
             break;
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		case SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID:
+			fprintf(out, "srf::");
+			print_storm_rational_function_to_file((storm_rational_function_ptr)value, out);
+			break;
+#endif
         default:
             cb(out, type, value);
             break;
@@ -2416,7 +2527,7 @@ int
 mtbdd_map_contains(MTBDDMAP map, uint32_t key)
 {
     while (!mtbdd_map_isempty(map)) {
-        mtbddnode_t n = GETNODE(map);
+        mtbddnode_t n = MTBDD_GETNODE(map);
         uint32_t k = mtbddnode_getvariable(n);
         if (k == key) return 1;
         if (k > key) return 0;
@@ -2450,7 +2561,7 @@ mtbdd_map_add(MTBDDMAP map, uint32_t key, MTBDD value)
 {
     if (mtbdd_map_isempty(map)) return mtbdd_makenode(key, mtbdd_map_empty(), value);
 
-    mtbddnode_t n = GETNODE(map);
+    mtbddnode_t n = MTBDD_GETNODE(map);
     uint32_t k = mtbddnode_getvariable(n);
 
     if (k < key) {
@@ -2474,8 +2585,8 @@ mtbdd_map_addall(MTBDDMAP map1, MTBDDMAP map2)
     if (mtbdd_map_isempty(map1)) return map2;
     if (mtbdd_map_isempty(map2)) return map1;
 
-    mtbddnode_t n1 = GETNODE(map1);
-    mtbddnode_t n2 = GETNODE(map2);
+    mtbddnode_t n1 = MTBDD_GETNODE(map1);
+    mtbddnode_t n2 = MTBDD_GETNODE(map2);
     uint32_t k1 = mtbddnode_getvariable(n1);
     uint32_t k2 = mtbddnode_getvariable(n2);
 
@@ -2502,7 +2613,7 @@ mtbdd_map_remove(MTBDDMAP map, uint32_t key)
 {
     if (mtbdd_map_isempty(map)) return map;
 
-    mtbddnode_t n = GETNODE(map);
+    mtbddnode_t n = MTBDD_GETNODE(map);
     uint32_t k = mtbddnode_getvariable(n);
 
     if (k < key) {
@@ -2524,8 +2635,8 @@ mtbdd_map_removeall(MTBDDMAP map, MTBDD variables)
     if (mtbdd_map_isempty(map)) return map;
     if (variables == mtbdd_true) return map;
 
-    mtbddnode_t n1 = GETNODE(map);
-    mtbddnode_t n2 = GETNODE(variables);
+    mtbddnode_t n1 = MTBDD_GETNODE(map);
+    mtbddnode_t n2 = MTBDD_GETNODE(variables);
     uint32_t k1 = mtbddnode_getvariable(n1);
     uint32_t k2 = mtbddnode_getvariable(n2);
 
diff --git a/resources/3rdparty/sylvan/src/sylvan_mtbdd.h b/resources/3rdparty/sylvan/src/sylvan_mtbdd.h
index 1a7de3f57..60d484f50 100644
--- a/resources/3rdparty/sylvan/src/sylvan_mtbdd.h
+++ b/resources/3rdparty/sylvan/src/sylvan_mtbdd.h
@@ -307,7 +307,7 @@ TASK_DECL_3(MTBDD, mtbdd_abstract_op_max, MTBDD, MTBDD, int);
  *  must be a Boolean MTBDD (or standard BDD).
  */
 TASK_DECL_3(MTBDD, mtbdd_ite, MTBDD, MTBDD, MTBDD);
-#define mtbdd_ite(f, g, h) CALL(mtbdd_ite, f, g, h);
+#define mtbdd_ite(f, g, h) CALL(mtbdd_ite, f, g, h)
 
 /**
  * Multiply  and , and abstract variables  using summation.
diff --git a/resources/3rdparty/sylvan/src/sylvan_mtbdd_int.h b/resources/3rdparty/sylvan/src/sylvan_mtbdd_int.h
index 940250b9a..aff9821bb 100644
--- a/resources/3rdparty/sylvan/src/sylvan_mtbdd_int.h
+++ b/resources/3rdparty/sylvan/src/sylvan_mtbdd_int.h
@@ -28,7 +28,7 @@ typedef struct __attribute__((packed)) mtbddnode {
     uint64_t a, b;
 } * mtbddnode_t; // 16 bytes
 
-#define GETNODE(mtbdd) ((mtbddnode_t)llmsset_index_to_ptr(nodes, mtbdd&0x000000ffffffffff))
+#define MTBDD_GETNODE(mtbdd) ((mtbddnode_t)llmsset_index_to_ptr(nodes, mtbdd&0x000000ffffffffff))
 
 /**
  * Complement handling macros
diff --git a/resources/3rdparty/sylvan/src/sylvan_mtbdd_storm.c b/resources/3rdparty/sylvan/src/sylvan_mtbdd_storm.c
index dab4860c0..2a45a913d 100644
--- a/resources/3rdparty/sylvan/src/sylvan_mtbdd_storm.c
+++ b/resources/3rdparty/sylvan/src/sylvan_mtbdd_storm.c
@@ -1,3 +1,5 @@
+#include 
+
 /**
  * Generate SHA2 structural hashes.
  * Hashes are independent of location.
@@ -11,7 +13,7 @@ mtbdd_sha2_rec(MTBDD mtbdd, SHA256_CTX *ctx)
         return;
     }
     
-    mtbddnode_t node = GETNODE(mtbdd);
+    mtbddnode_t node = MTBDD_GETNODE(mtbdd);
     if (mtbddnode_isleaf(node)) {
         uint64_t val = mtbddnode_getvalue(node);
         SHA256_Update(ctx, (void*)&val, sizeof(uint64_t));
@@ -48,8 +50,8 @@ TASK_IMPL_2(MTBDD, mtbdd_op_divide, MTBDD*, pa, MTBDD*, pb)
     
     // Do not handle Boolean MTBDDs...
     
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
     
     if (mtbddnode_isleaf(na) && mtbddnode_isleaf(nb)) {
         uint64_t val_a = mtbddnode_getvalue(na);
@@ -97,6 +99,12 @@ TASK_IMPL_2(MTBDD, mtbdd_op_divide, MTBDD*, pa, MTBDD*, pb)
             MTBDD result = mtbdd_fraction(nom_a, denom_a);
             return result;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID && mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+			printf("ERROR mtbdd_op_divide type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID");
+			assert(0);
+		}
+#endif
     }
     
     return mtbdd_invalid;
@@ -114,8 +122,8 @@ TASK_IMPL_2(MTBDD, mtbdd_op_equals, MTBDD*, pa, MTBDD*, pb)
     if (a == mtbdd_false && b == mtbdd_false) return mtbdd_true;
     if (a == mtbdd_true && b == mtbdd_true) return mtbdd_true;
     
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
     
     if (mtbddnode_isleaf(na) && mtbddnode_isleaf(nb)) {
         uint64_t val_a = mtbddnode_getvalue(na);
@@ -140,6 +148,12 @@ TASK_IMPL_2(MTBDD, mtbdd_op_equals, MTBDD*, pa, MTBDD*, pb)
             if (nom_a == nom_b && denom_a == denom_b) return mtbdd_true;
             return mtbdd_false;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID && mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+			printf("ERROR mtbdd_op_equals type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID");
+			assert(0);
+		}
+#endif
     }
     
     if (a < b) {
@@ -162,8 +176,8 @@ TASK_IMPL_2(MTBDD, mtbdd_op_less, MTBDD*, pa, MTBDD*, pb)
     if (a == mtbdd_false && b == mtbdd_false) return mtbdd_true;
     if (a == mtbdd_true && b == mtbdd_true) return mtbdd_true;
     
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
     
     if (mtbddnode_isleaf(na) && mtbddnode_isleaf(nb)) {
         uint64_t val_a = mtbddnode_getvalue(na);
@@ -187,13 +201,19 @@ TASK_IMPL_2(MTBDD, mtbdd_op_less, MTBDD*, pa, MTBDD*, pb)
             uint64_t denom_b = val_b&0xffffffff;
             return nom_a * denom_b < nom_b * denom_a ? mtbdd_true : mtbdd_false;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID && mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+			printf("ERROR mtbdd_op_less type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID");
+			assert(0);
+		}
+#endif
     }
     
     return mtbdd_invalid;
 }
 
 /**
- * Binary operation Equals (for MTBDDs of same type)
+ * Binary operation Less or Equals (for MTBDDs of same type)
  * Only for MTBDDs where either all leaves are Boolean, or Integer, or Double.
  * For Integer/Double MTBDD, if either operand is mtbdd_false (not defined),
  * then the result is mtbdd_false (i.e. not defined).
@@ -204,8 +224,8 @@ TASK_IMPL_2(MTBDD, mtbdd_op_less_or_equal, MTBDD*, pa, MTBDD*, pb)
     if (a == mtbdd_false && b == mtbdd_false) return mtbdd_true;
     if (a == mtbdd_true && b == mtbdd_true) return mtbdd_true;
     
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
     
     if (mtbddnode_isleaf(na) && mtbddnode_isleaf(nb)) {
         uint64_t val_a = mtbddnode_getvalue(na);
@@ -230,6 +250,61 @@ TASK_IMPL_2(MTBDD, mtbdd_op_less_or_equal, MTBDD*, pa, MTBDD*, pb)
             nom_b *= denom_a;
             return nom_a <= nom_b ? mtbdd_true : mtbdd_false;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID && mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+			printf("ERROR mtbdd_op_less_or_equal type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID");
+			assert(0);
+		}
+#endif
+    }
+    
+    return mtbdd_invalid;
+}
+
+/**
+ * Binary operation Greater or Equals (for MTBDDs of same type)
+ * Only for MTBDDs where either all leaves are Boolean, or Integer, or Double.
+ * For Integer/Double MTBDD, if either operand is mtbdd_false (not defined),
+ * then the result is mtbdd_false (i.e. not defined).
+ */
+TASK_IMPL_2(MTBDD, mtbdd_op_greater_or_equal, MTBDD*, pa, MTBDD*, pb)
+{
+    MTBDD a = *pa, b = *pb;
+    if (a == mtbdd_false && b == mtbdd_false) return mtbdd_true;
+    if (a == mtbdd_true && b == mtbdd_true) return mtbdd_true;
+    
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
+    
+    if (mtbddnode_isleaf(na) && mtbddnode_isleaf(nb)) {
+        uint64_t val_a = mtbddnode_getvalue(na);
+        uint64_t val_b = mtbddnode_getvalue(nb);
+        if (mtbddnode_gettype(na) == 0 && mtbddnode_gettype(nb) == 0) {
+            int64_t va = *(int64_t*)(&val_a);
+            int64_t vb = *(int64_t*)(&val_b);
+            return va >= vb ? mtbdd_true : mtbdd_false;
+        } else if (mtbddnode_gettype(na) == 1 && mtbddnode_gettype(nb) == 1) {
+            // both double
+            double vval_a = *(double*)&val_a;
+            double vval_b = *(double*)&val_b;
+            if (vval_a >= vval_b) return mtbdd_true;
+            return mtbdd_false;
+        } else if (mtbddnode_gettype(na) == 2 && mtbddnode_gettype(nb) == 2) {
+            // both fraction
+            uint64_t nom_a = val_a>>32;
+            uint64_t nom_b = val_b>>32;
+            uint64_t denom_a = val_a&0xffffffff;
+            uint64_t denom_b = val_b&0xffffffff;
+            nom_a *= denom_b;
+            nom_b *= denom_a;
+            return nom_a >= nom_b ? mtbdd_true : mtbdd_false;
+        }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID && mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+			printf("ERROR mtbdd_op_greater_or_equal type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID");
+			assert(0);
+		}
+#endif
     }
     
     return mtbdd_invalid;
@@ -245,8 +320,8 @@ TASK_IMPL_2(MTBDD, mtbdd_op_pow, MTBDD*, pa, MTBDD*, pb)
 {
     MTBDD a = *pa, b = *pb;
     
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
     
     if (mtbddnode_isleaf(na) && mtbddnode_isleaf(nb)) {
         uint64_t val_a = mtbddnode_getvalue(na);
@@ -261,6 +336,12 @@ TASK_IMPL_2(MTBDD, mtbdd_op_pow, MTBDD*, pa, MTBDD*, pb)
         } else if (mtbddnode_gettype(na) == 2 && mtbddnode_gettype(nb) == 2) {
             assert(0);
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID && mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+			printf("ERROR mtbdd_op_pow type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID");
+			assert(0);
+		}
+#endif
     }
     
     return mtbdd_invalid;
@@ -276,8 +357,8 @@ TASK_IMPL_2(MTBDD, mtbdd_op_mod, MTBDD*, pa, MTBDD*, pb)
 {
     MTBDD a = *pa, b = *pb;
     
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
     
     if (mtbddnode_isleaf(na) && mtbddnode_isleaf(nb)) {
         uint64_t val_a = mtbddnode_getvalue(na);
@@ -292,6 +373,12 @@ TASK_IMPL_2(MTBDD, mtbdd_op_mod, MTBDD*, pa, MTBDD*, pb)
         } else if (mtbddnode_gettype(na) == 2 && mtbddnode_gettype(nb) == 2) {
             assert(0);
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID && mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+			printf("ERROR mtbdd_op_mod type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID");
+			assert(0);
+		}
+#endif
     }
     
     return mtbdd_invalid;
@@ -307,8 +394,8 @@ TASK_IMPL_2(MTBDD, mtbdd_op_logxy, MTBDD*, pa, MTBDD*, pb)
 {
     MTBDD a = *pa, b = *pb;
     
-    mtbddnode_t na = GETNODE(a);
-    mtbddnode_t nb = GETNODE(b);
+    mtbddnode_t na = MTBDD_GETNODE(a);
+    mtbddnode_t nb = MTBDD_GETNODE(b);
     
     if (mtbddnode_isleaf(na) && mtbddnode_isleaf(nb)) {
         uint64_t val_a = mtbddnode_getvalue(na);
@@ -323,6 +410,12 @@ TASK_IMPL_2(MTBDD, mtbdd_op_logxy, MTBDD*, pa, MTBDD*, pb)
         } else if (mtbddnode_gettype(na) == 2 && mtbddnode_gettype(nb) == 2) {
             assert(0);
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID && mtbddnode_gettype(nb) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+			printf("ERROR mtbdd_op_logxy type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID");
+			assert(0);
+		}
+#endif
     }
     
     return mtbdd_invalid;
@@ -335,7 +428,7 @@ TASK_IMPL_2(MTBDD, mtbdd_op_not_zero, MTBDD, a, size_t, v)
     if (a == mtbdd_true) return mtbdd_true;
     
     // a != constant
-    mtbddnode_t na = GETNODE(a);
+    mtbddnode_t na = MTBDD_GETNODE(a);
     
     if (mtbddnode_isleaf(na)) {
         if (mtbddnode_gettype(na) == 0) {
@@ -345,6 +438,11 @@ TASK_IMPL_2(MTBDD, mtbdd_op_not_zero, MTBDD, a, size_t, v)
         } else if (mtbddnode_gettype(na) == 2) {
             return mtbdd_getnumer(a) != 0 ? mtbdd_true : mtbdd_false;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+			return storm_rational_function_is_zero((storm_rational_function_ptr)mtbdd_getvalue(a)) == 0 ? mtbdd_true : mtbdd_false;
+		}
+#endif
     }
     
     // Ugly hack to get rid of the error "unused variable v" (because there is no version of uapply without a parameter).
@@ -365,7 +463,7 @@ TASK_IMPL_2(MTBDD, mtbdd_op_floor, MTBDD, a, size_t, v)
     if (a == mtbdd_true) return mtbdd_true;
     
     // a != constant
-    mtbddnode_t na = GETNODE(a);
+    mtbddnode_t na = MTBDD_GETNODE(a);
     
     if (mtbddnode_isleaf(na)) {
         if (mtbddnode_gettype(na) == 0) {
@@ -377,6 +475,12 @@ TASK_IMPL_2(MTBDD, mtbdd_op_floor, MTBDD, a, size_t, v)
             MTBDD result = mtbdd_fraction(mtbdd_getnumer(a) / mtbdd_getdenom(a), 1);
             return result;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+			printf("ERROR mtbdd_op_floor type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID");
+			assert(0);
+		}
+#endif
     }
     
     // Ugly hack to get rid of the error "unused variable v" (because there is no version of uapply without a parameter).
@@ -397,7 +501,7 @@ TASK_IMPL_2(MTBDD, mtbdd_op_ceil, MTBDD, a, size_t, v)
     if (a == mtbdd_true) return mtbdd_true;
     
     // a != constant
-    mtbddnode_t na = GETNODE(a);
+    mtbddnode_t na = MTBDD_GETNODE(a);
     
     if (mtbddnode_isleaf(na)) {
         if (mtbddnode_gettype(na) == 0) {
@@ -409,6 +513,12 @@ TASK_IMPL_2(MTBDD, mtbdd_op_ceil, MTBDD, a, size_t, v)
             MTBDD result = mtbdd_fraction(mtbdd_getnumer(a) / mtbdd_getdenom(a) + 1, 1);
             return result;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+			printf("ERROR mtbdd_op_ceil type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID");
+			assert(0);
+		}
+#endif
     }
 
     // Ugly hack to get rid of the error "unused variable v" (because there is no version of uapply without a parameter).
@@ -464,7 +574,7 @@ TASK_IMPL_2(double, mtbdd_non_zero_count, MTBDD, dd, size_t, nvars)
     /* Trivial cases */
     if (dd == mtbdd_false) return 0.0;
 
-    mtbddnode_t na = GETNODE(dd);
+    mtbddnode_t na = MTBDD_GETNODE(dd);
     
     if (mtbdd_isleaf(dd)) {
         if (mtbddnode_gettype(na) == 0) {
@@ -474,6 +584,11 @@ TASK_IMPL_2(double, mtbdd_non_zero_count, MTBDD, dd, size_t, nvars)
         } else if (mtbddnode_gettype(na) == 2) {
             return mtbdd_getnumer(dd) != 0 ? powl(2.0L, nvars) : 0.0;
         }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if (mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+			return storm_rational_function_is_zero((storm_rational_function_ptr)mtbdd_getvalue(dd)) == 0 ? powl(2.0L, nvars) : 0.0;
+		}
+#endif
     }
     
     /* Perhaps execute garbage collection */
@@ -506,9 +621,398 @@ int mtbdd_iszero(MTBDD dd) {
     } else if (mtbdd_gettype(dd) == 2) {
         return mtbdd_getnumer(dd) == 0;
     }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+	else if (mtbdd_gettype(dd) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID) {
+		return storm_rational_function_is_zero((storm_rational_function_ptr)mtbdd_getvalue(dd)) == 1 ? 1 : 0;
+	}
+#endif
     return 0;
 }
 
 int mtbdd_isnonzero(MTBDD dd) {
     return mtbdd_iszero(dd) ? 0 : 1;
-}
\ No newline at end of file
+}
+
+MTBDD
+mtbdd_ithvar(uint32_t level) {
+    return mtbdd_makenode(level, mtbdd_false, mtbdd_true);
+}
+
+TASK_IMPL_2(MTBDD, mtbdd_op_complement, MTBDD, a, size_t, k)
+{
+    // if a is false, then it is a partial function. Keep partial!
+    if (a == mtbdd_false) return mtbdd_false;
+
+    // a != constant
+    mtbddnode_t na = MTBDD_GETNODE(a);
+
+    if (mtbddnode_isleaf(na)) {
+        if (mtbddnode_gettype(na) == 0) {
+            int64_t v = mtbdd_getint64(a);
+			if (v == 0) {
+				return mtbdd_int64(1);
+			} else {
+				return mtbdd_int64(0);
+			}            
+        } else if (mtbddnode_gettype(na) == 1) {
+            double d = mtbdd_getdouble(a);
+			if (d == 0.0) {
+				return mtbdd_double(1.0);
+			} else {
+				return mtbdd_double(0.0);
+			}  
+        } else if (mtbddnode_gettype(na) == 2) {
+            printf("ERROR: mtbdd_op_complement type FRACTION.\n");
+			assert(0);
+        }
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+		else if ((mtbddnode_gettype(na) == SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID)) {
+			printf("ERROR: mtbdd_op_complement type SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID.\n");
+			assert(0);
+		}
+#endif
+    }
+
+    return mtbdd_invalid;
+    (void)k; // unused variable
+}
+
+TASK_IMPL_3(BDD, mtbdd_minExistsRepresentative, MTBDD, a, BDD, variables, BDDVAR, prev_level) {
+	/* Maybe perform garbage collection */
+    sylvan_gc_test();
+
+	if (sylvan_set_isempty(variables)) {
+		return sylvan_true;
+	}
+
+	/* Cube is guaranteed to be a cube at this point. */
+    if (mtbdd_isleaf(a)) {
+		BDD _v = sylvan_set_next(variables);
+		BDD res = CALL(mtbdd_minExistsRepresentative, a, _v, prev_level);
+		if (res == sylvan_invalid) {
+			return sylvan_invalid;
+		}
+		sylvan_ref(res);
+
+		BDD res1 = sylvan_not(sylvan_ite(sylvan_ithvar(bddnode_getvariable(BDD_GETNODE(variables))), sylvan_true, sylvan_not(res)));
+		if (res1 == sylvan_invalid) {
+			sylvan_deref(res);
+			return sylvan_invalid;
+		}
+		sylvan_deref(res);
+		return res1;
+    }
+	
+	mtbddnode_t na = MTBDD_GETNODE(a);
+	uint32_t va = mtbddnode_getvariable(na);
+	bddnode_t nv = BDD_GETNODE(variables);
+	BDDVAR vv = bddnode_getvariable(nv);
+
+    /* Abstract a variable that does not appear in a. */
+    if (va > vv) {
+		BDD _v = sylvan_set_next(variables);
+        BDD res = CALL(mtbdd_minExistsRepresentative, a, _v, va);
+        if (res == sylvan_invalid) {
+            return sylvan_invalid;
+        }
+        
+        // Fill in the missing variables to make representative unique.
+        sylvan_ref(res);
+        BDD res1 = sylvan_ite(sylvan_ithvar(vv), sylvan_false, res);
+        if (res1 == sylvan_invalid) {
+            sylvan_deref(res);
+            return sylvan_invalid;
+        }
+        sylvan_deref(res);
+       	return res1;
+    }
+    
+	/* TODO: Caching here. */
+    /*if ((res = cuddCacheLookup2(manager, Cudd_addMinAbstractRepresentative, f, cube)) != NULL) {
+        return(res);
+    }*/
+    
+    
+    MTBDD E = mtbdd_getlow(a);
+    MTBDD T = mtbdd_gethigh(a);
+    
+    /* If the two indices are the same, so are their levels. */
+    if (va == vv) {
+		BDD _v = sylvan_set_next(variables);
+        BDD res1 = CALL(mtbdd_minExistsRepresentative, E, _v, va);
+        if (res1 == sylvan_invalid) {
+            return sylvan_invalid;
+        }
+        sylvan_ref(res1);
+        
+        BDD res2 = CALL(mtbdd_minExistsRepresentative, T, _v, va);
+        if (res2 == sylvan_invalid) {
+            sylvan_deref(res1);
+            return sylvan_invalid;
+        }
+        sylvan_ref(res2);
+        
+        MTBDD left = mtbdd_abstract_min(E, _v);
+        if (left == mtbdd_invalid) {
+            sylvan_deref(res1);
+			sylvan_deref(res2);
+            return sylvan_invalid;
+        }
+        mtbdd_ref(left);
+		
+        MTBDD right = mtbdd_abstract_min(T, _v);
+        if (right == mtbdd_invalid) {
+            sylvan_deref(res1);
+			sylvan_deref(res2);
+			mtbdd_deref(left);
+            return sylvan_invalid;
+        }
+        mtbdd_ref(right);
+        
+        BDD tmp = mtbdd_less_or_equal_as_bdd(left, right);
+        if (tmp == sylvan_invalid) {
+            sylvan_deref(res1);
+			sylvan_deref(res2);
+			mtbdd_deref(left);
+			mtbdd_deref(right);
+            return sylvan_invalid;
+        }
+        sylvan_ref(tmp);
+        
+        mtbdd_deref(left);
+		mtbdd_deref(right);
+        
+        BDD res1Inf = sylvan_ite(tmp, res1, sylvan_false);
+        if (res1Inf == sylvan_invalid) {
+            sylvan_deref(res1);
+			sylvan_deref(res2);
+			sylvan_deref(tmp);
+            return sylvan_invalid;
+        }
+        sylvan_ref(res1Inf);
+        sylvan_deref(res1);
+
+        BDD res2Inf = sylvan_ite(tmp, sylvan_false, res2);
+        if (res2Inf == sylvan_invalid) {
+            sylvan_deref(res2);
+            sylvan_deref(res1Inf);
+            sylvan_deref(tmp);
+            return sylvan_invalid;
+        }
+        sylvan_ref(res2Inf);
+        sylvan_deref(res2);
+        sylvan_deref(tmp);
+
+        BDD res = (res1Inf == res2Inf) ? sylvan_ite(sylvan_ithvar(va), sylvan_false, res1Inf) : sylvan_ite(sylvan_ithvar(va), res2Inf, res1Inf);
+
+        if (res == sylvan_invalid) {
+            sylvan_deref(res1Inf);
+            sylvan_deref(res2Inf);
+            return sylvan_invalid;
+        }
+        sylvan_ref(res);
+        sylvan_deref(res1Inf);
+        sylvan_deref(res2Inf);
+        
+		/* TODO: Caching here. */
+		//cuddCacheInsert2(manager, Cudd_addMinAbstractRepresentative, f, cube, res);
+		
+        sylvan_deref(res);
+        return res;
+    }
+    else { /* if (va < vv) */
+		BDD res1 = CALL(mtbdd_minExistsRepresentative, E, variables, va);
+        if (res1 == sylvan_invalid) {
+			return sylvan_invalid;
+		}
+        sylvan_ref(res1);
+        BDD res2 = CALL(mtbdd_minExistsRepresentative, T, variables, va);
+        if (res2 == sylvan_invalid) {
+            sylvan_deref(res1);
+            return sylvan_invalid;
+        }
+        sylvan_ref(res2);
+
+        BDD res = (res1 == res2) ? res1 : sylvan_ite(sylvan_ithvar(va), res2, res1);
+        if (res == sylvan_invalid) {
+            sylvan_deref(res1);
+            sylvan_deref(res2);
+            return sylvan_invalid;
+        }
+        sylvan_deref(res1);
+        sylvan_deref(res2);
+		/* TODO: Caching here. */
+        //cuddCacheInsert2(manager, Cudd_addMinAbstractRepresentative, f, cube, res);
+        return res;
+    }
+}
+
+TASK_IMPL_3(BDD, mtbdd_maxExistsRepresentative, MTBDD, a, MTBDD, variables, uint32_t, prev_level) {
+	/* Maybe perform garbage collection */
+    sylvan_gc_test();
+
+	if (sylvan_set_isempty(variables)) {
+		return sylvan_true;
+	}
+
+	/* Cube is guaranteed to be a cube at this point. */
+    if (mtbdd_isleaf(a)) {
+		BDD _v = sylvan_set_next(variables);
+		BDD res = CALL(mtbdd_maxExistsRepresentative, a, _v, prev_level);
+		if (res == sylvan_invalid) {
+			return sylvan_invalid;
+		}
+		sylvan_ref(res);
+
+		BDD res1 = sylvan_not(sylvan_ite(sylvan_ithvar(bddnode_getvariable(BDD_GETNODE(variables))), sylvan_true, sylvan_not(res)));
+		if (res1 == sylvan_invalid) {
+			sylvan_deref(res);
+			return sylvan_invalid;
+		}
+		sylvan_deref(res);
+		return res1;
+    }
+	
+	mtbddnode_t na = MTBDD_GETNODE(a);
+	uint32_t va = mtbddnode_getvariable(na);
+	bddnode_t nv = BDD_GETNODE(variables);
+	BDDVAR vv = bddnode_getvariable(nv);
+
+    /* Abstract a variable that does not appear in a. */
+    if (va > vv) {
+		BDD _v = sylvan_set_next(variables);
+        BDD res = CALL(mtbdd_maxExistsRepresentative, a, _v, va);
+        if (res == sylvan_invalid) {
+            return sylvan_invalid;
+        }
+        
+        // Fill in the missing variables to make representative unique.
+        sylvan_ref(res);
+        BDD res1 = sylvan_ite(sylvan_ithvar(vv), sylvan_false, res);
+        if (res1 == sylvan_invalid) {
+            sylvan_deref(res);
+            return sylvan_invalid;
+        }
+        sylvan_deref(res);
+       	return res1;
+    }
+    
+	/* TODO: Caching here. */
+    /*if ((res = cuddCacheLookup2(manager, Cudd_addMinAbstractRepresentative, f, cube)) != NULL) {
+        return(res);
+    }*/
+    
+    
+    MTBDD E = mtbdd_getlow(a);
+    MTBDD T = mtbdd_gethigh(a);
+    
+    /* If the two indices are the same, so are their levels. */
+    if (va == vv) {
+		BDD _v = sylvan_set_next(variables);
+        BDD res1 = CALL(mtbdd_maxExistsRepresentative, E, _v, va);
+        if (res1 == sylvan_invalid) {
+            return sylvan_invalid;
+        }
+        sylvan_ref(res1);
+        
+        BDD res2 = CALL(mtbdd_maxExistsRepresentative, T, _v, va);
+        if (res2 == sylvan_invalid) {
+            sylvan_deref(res1);
+            return sylvan_invalid;
+        }
+        sylvan_ref(res2);
+        
+        MTBDD left = mtbdd_abstract_max(E, _v);
+        if (left == mtbdd_invalid) {
+            sylvan_deref(res1);
+			sylvan_deref(res2);
+            return sylvan_invalid;
+        }
+        mtbdd_ref(left);
+		
+        MTBDD right = mtbdd_abstract_max(T, _v);
+        if (right == mtbdd_invalid) {
+            sylvan_deref(res1);
+			sylvan_deref(res2);
+			mtbdd_deref(left);
+            return sylvan_invalid;
+        }
+        mtbdd_ref(right);
+        
+        BDD tmp = mtbdd_greater_or_equal_as_bdd(left, right);
+        if (tmp == sylvan_invalid) {
+            sylvan_deref(res1);
+			sylvan_deref(res2);
+			mtbdd_deref(left);
+			mtbdd_deref(right);
+            return sylvan_invalid;
+        }
+        sylvan_ref(tmp);
+        
+        mtbdd_deref(left);
+		mtbdd_deref(right);
+        
+        BDD res1Inf = sylvan_ite(tmp, res1, sylvan_false);
+        if (res1Inf == sylvan_invalid) {
+            sylvan_deref(res1);
+			sylvan_deref(res2);
+			sylvan_deref(tmp);
+            return sylvan_invalid;
+        }
+        sylvan_ref(res1Inf);
+        sylvan_deref(res1);
+
+        BDD res2Inf = sylvan_ite(tmp, sylvan_false, res2);
+        if (res2Inf == sylvan_invalid) {
+            sylvan_deref(res2);
+            sylvan_deref(res1Inf);
+            sylvan_deref(tmp);
+            return sylvan_invalid;
+        }
+        sylvan_ref(res2Inf);
+        sylvan_deref(res2);
+        sylvan_deref(tmp);
+
+        BDD res = (res1Inf == res2Inf) ? sylvan_ite(sylvan_ithvar(va), sylvan_false, res1Inf) : sylvan_ite(sylvan_ithvar(va), res2Inf, res1Inf);
+
+        if (res == sylvan_invalid) {
+            sylvan_deref(res1Inf);
+            sylvan_deref(res2Inf);
+            return sylvan_invalid;
+        }
+        sylvan_ref(res);
+        sylvan_deref(res1Inf);
+        sylvan_deref(res2Inf);
+        
+		/* TODO: Caching here. */
+		//cuddCacheInsert2(manager, Cudd_addMinAbstractRepresentative, f, cube, res);
+		
+        sylvan_deref(res);
+        return res;
+    }
+    else { /* if (va < vv) */
+		BDD res1 = CALL(mtbdd_maxExistsRepresentative, E, variables, va);
+        if (res1 == sylvan_invalid) {
+			return sylvan_invalid;
+		}
+        sylvan_ref(res1);
+        BDD res2 = CALL(mtbdd_maxExistsRepresentative, T, variables, va);
+        if (res2 == sylvan_invalid) {
+            sylvan_deref(res1);
+            return sylvan_invalid;
+        }
+        sylvan_ref(res2);
+
+        BDD res = (res1 == res2) ? res1 : sylvan_ite(sylvan_ithvar(va), res2, res1);
+        if (res == sylvan_invalid) {
+            sylvan_deref(res1);
+            sylvan_deref(res2);
+            return sylvan_invalid;
+        }
+        sylvan_deref(res1);
+        sylvan_deref(res2);
+		/* TODO: Caching here. */
+        //cuddCacheInsert2(manager, Cudd_addMinAbstractRepresentative, f, cube, res);
+        return res;
+    }	
+}
diff --git a/resources/3rdparty/sylvan/src/sylvan_mtbdd_storm.h b/resources/3rdparty/sylvan/src/sylvan_mtbdd_storm.h
index 38fa6668b..8be736c26 100644
--- a/resources/3rdparty/sylvan/src/sylvan_mtbdd_storm.h
+++ b/resources/3rdparty/sylvan/src/sylvan_mtbdd_storm.h
@@ -6,7 +6,7 @@ void mtbdd_getsha(MTBDD mtbdd, char *target); // target must be at least 65 byte
  * If either operand is mtbdd_false (not defined),
  * then the result is mtbdd_false (i.e. not defined).
  */
-TASK_DECL_2(MTBDD, mtbdd_op_divide, MTBDD*, MTBDD*);
+TASK_DECL_2(MTBDD, mtbdd_op_divide, MTBDD*, MTBDD*)
 #define mtbdd_divide(a, b) mtbdd_apply(a, b, TASK(mtbdd_op_divide))
 
 /**
@@ -15,7 +15,7 @@ TASK_DECL_2(MTBDD, mtbdd_op_divide, MTBDD*, MTBDD*);
  * For Integer/Double MTBDD, if either operand is mtbdd_false (not defined),
  * then the result is the other operand.
  */
-TASK_DECL_2(MTBDD, mtbdd_op_equals, MTBDD*, MTBDD*);
+TASK_DECL_2(MTBDD, mtbdd_op_equals, MTBDD*, MTBDD*)
 #define mtbdd_equals(a, b) mtbdd_apply(a, b, TASK(mtbdd_op_equals))
 
 /**
@@ -24,25 +24,34 @@ TASK_DECL_2(MTBDD, mtbdd_op_equals, MTBDD*, MTBDD*);
  * For Integer/Double MTBDD, if either operand is mtbdd_false (not defined),
  * then the result is the other operand.
  */
-TASK_DECL_2(MTBDD, mtbdd_op_less, MTBDD*, MTBDD*);
+TASK_DECL_2(MTBDD, mtbdd_op_less, MTBDD*, MTBDD*)
 #define mtbdd_less_as_bdd(a, b) mtbdd_apply(a, b, TASK(mtbdd_op_less))
 
 /**
- * Binary operation Less (for MTBDDs of same type)
+ * Binary operation Less or Equal (for MTBDDs of same type)
  * Only for MTBDDs where either all leaves are Boolean, or Integer, or Double.
  * For Integer/Double MTBDD, if either operand is mtbdd_false (not defined),
  * then the result is the other operand.
  */
-TASK_DECL_2(MTBDD, mtbdd_op_less_or_equal, MTBDD*, MTBDD*);
+TASK_DECL_2(MTBDD, mtbdd_op_less_or_equal, MTBDD*, MTBDD*)
 #define mtbdd_less_or_equal_as_bdd(a, b) mtbdd_apply(a, b, TASK(mtbdd_op_less_or_equal))
 
+/**
+ * Binary operation Greater or Equal (for MTBDDs of same type)
+ * Only for MTBDDs where either all leaves are Boolean, or Integer, or Double.
+ * For Integer/Double MTBDD, if either operand is mtbdd_false (not defined),
+ * then the result is the other operand.
+ */
+TASK_DECL_2(MTBDD, mtbdd_op_greater_or_equal, MTBDD*, MTBDD*)
+#define mtbdd_greater_or_equal_as_bdd(a, b) mtbdd_apply(a, b, TASK(mtbdd_op_greater_or_equal))
+
 /**
  * Binary operation Pow (for MTBDDs of same type)
  * Only for MTBDDs where either all leaves are Integer, Double or a Fraction.
  * For Integer/Double MTBDD, if either operand is mtbdd_false (not defined),
  * then the result is the other operand.
  */
-TASK_DECL_2(MTBDD, mtbdd_op_pow, MTBDD*, MTBDD*);
+TASK_DECL_2(MTBDD, mtbdd_op_pow, MTBDD*, MTBDD*)
 #define mtbdd_pow(a, b) mtbdd_apply(a, b, TASK(mtbdd_op_pow))
 
 /**
@@ -51,7 +60,7 @@ TASK_DECL_2(MTBDD, mtbdd_op_pow, MTBDD*, MTBDD*);
  * For Integer/Double MTBDD, if either operand is mtbdd_false (not defined),
  * then the result is the other operand.
  */
-TASK_DECL_2(MTBDD, mtbdd_op_mod, MTBDD*, MTBDD*);
+TASK_DECL_2(MTBDD, mtbdd_op_mod, MTBDD*, MTBDD*)
 #define mtbdd_mod(a, b) mtbdd_apply(a, b, TASK(mtbdd_op_mod))
 
 /**
@@ -60,7 +69,7 @@ TASK_DECL_2(MTBDD, mtbdd_op_mod, MTBDD*, MTBDD*);
  * For Integer/Double MTBDD, if either operand is mtbdd_false (not defined),
  * then the result is the other operand.
  */
-TASK_DECL_2(MTBDD, mtbdd_op_logxy, MTBDD*, MTBDD*);
+TASK_DECL_2(MTBDD, mtbdd_op_logxy, MTBDD*, MTBDD*)
 #define mtbdd_logxy(a, b) mtbdd_apply(a, b, TASK(mtbdd_op_logxy))
 
 /**
@@ -71,14 +80,14 @@ TASK_DECL_1(MTBDD, mtbdd_not_zero, MTBDD)
 #define mtbdd_not_zero(dd) CALL(mtbdd_not_zero, dd)
 
 /**
- * Monad that floors all values Double and Fraction values.
+ * Monad that floors all Double and Fraction values.
  */
 TASK_DECL_2(MTBDD, mtbdd_op_floor, MTBDD, size_t)
 TASK_DECL_1(MTBDD, mtbdd_floor, MTBDD)
 #define mtbdd_floor(dd) CALL(mtbdd_floor, dd)
 
 /**
- * Monad that ceils all values Double and Fraction values.
+ * Monad that ceils all Double and Fraction values.
  */
 TASK_DECL_2(MTBDD, mtbdd_op_ceil, MTBDD, size_t)
 TASK_DECL_1(MTBDD, mtbdd_ceil, MTBDD)
@@ -101,7 +110,7 @@ TASK_DECL_1(MTBDD, mtbdd_bool_to_int64, MTBDD)
 /**
  * Count the number of assignments (minterms) leading to a non-zero
  */
-TASK_DECL_2(double, mtbdd_non_zero_count, MTBDD, size_t);
+TASK_DECL_2(double, mtbdd_non_zero_count, MTBDD, size_t)
 #define mtbdd_non_zero_count(dd, nvars) CALL(mtbdd_non_zero_count, dd, nvars)
 
 // Checks whether the given MTBDD (does represents a zero leaf.
@@ -109,3 +118,34 @@ int mtbdd_iszero(MTBDD);
 int mtbdd_isnonzero(MTBDD);
 
 #define mtbdd_regular(dd) (dd & ~mtbdd_complement)
+
+#define GETNODE_BDD(bdd) ((bddnode_t)llmsset_index_to_ptr(nodes, bdd&0x000000ffffffffff))
+#define mtbdd_set_next(set) (mtbdd_gethigh(set))
+#define mtbdd_set_isempty(set) (set == mtbdd_true)
+
+/* Create a MTBDD representing just  or the negation of  */
+MTBDD mtbdd_ithvar(uint32_t var);
+
+/**
+ * Unary operation Complement.
+ * Supported domains: Integer, Real
+ */
+TASK_DECL_2(MTBDD, mtbdd_op_complement, MTBDD, size_t);
+
+/**
+ * Compute the complement of a.
+ */
+#define mtbdd_get_complement(a) mtbdd_uapply(a, TASK(mtbdd_op_complement), 0)
+
+/**
+ * Just like mtbdd_abstract_min, but instead of abstracting the variables in the given cube, picks a unique representative that realizes the minimal function value.
+ */
+TASK_DECL_3(BDD, mtbdd_minExistsRepresentative, MTBDD, MTBDD, uint32_t);
+#define mtbdd_minExistsRepresentative(a, vars) (CALL(mtbdd_minExistsRepresentative, a, vars, 0))
+
+/**
+ * Just like mtbdd_abstract_max but instead of abstracting the variables in the given cube, picks a unique representative that realizes the maximal function value.
+ */
+TASK_DECL_3(BDD, mtbdd_maxExistsRepresentative, MTBDD, MTBDD, uint32_t);
+#define mtbdd_maxExistsRepresentative(a, vars) (CALL(mtbdd_maxExistsRepresentative, a, vars, 0))
+
diff --git a/resources/3rdparty/sylvan/src/sylvan_obj.cpp b/resources/3rdparty/sylvan/src/sylvan_obj.cpp
index a573c7a49..b9d0c77f2 100644
--- a/resources/3rdparty/sylvan/src/sylvan_obj.cpp
+++ b/resources/3rdparty/sylvan/src/sylvan_obj.cpp
@@ -15,6 +15,7 @@
  */
 
 #include 
+#include 
 
 using namespace sylvan;
 
@@ -604,6 +605,15 @@ Mtbdd::doubleTerminal(double value)
     return mtbdd_double(value);
 }
 
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+Mtbdd
+Mtbdd::stormRationalFunctionTerminal(storm::RationalFunction const& value)
+{
+	storm_rational_function_ptr ptr = (storm_rational_function_ptr)(&value);
+    return mtbdd_storm_rational_function(ptr);
+}
+#endif
+
 Mtbdd
 Mtbdd::fractionTerminal(int64_t nominator, uint64_t denominator)
 {
@@ -1028,6 +1038,7 @@ void
 Sylvan::initMtbdd()
 {
     sylvan_init_mtbdd();
+	sylvan_storm_rational_function_init();
 }
 
 void
diff --git a/resources/3rdparty/sylvan/src/sylvan_obj.hpp b/resources/3rdparty/sylvan/src/sylvan_obj.hpp
index e7f77f6ca..a63cf01c2 100644
--- a/resources/3rdparty/sylvan/src/sylvan_obj.hpp
+++ b/resources/3rdparty/sylvan/src/sylvan_obj.hpp
@@ -23,6 +23,8 @@
 #include 
 #include 
 
+#include "storm/adapters/CarlAdapter.h"
+
 namespace sylvan {
 
 class BddSet;
@@ -542,6 +544,13 @@ public:
      */
     static Mtbdd doubleTerminal(double value);
 
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+	/**
+     * @brief Creates a Mtbdd leaf representing the rational function value 
+     */
+    static Mtbdd stormRationalFunctionTerminal(storm::RationalFunction const& value);
+#endif
+	
     /**
      * @brief Creates a Mtbdd leaf representing the fraction value /
      * Internally, Sylvan uses 32-bit values and reports overflows to stderr.
diff --git a/resources/3rdparty/sylvan/src/sylvan_obj_bdd_storm.hpp b/resources/3rdparty/sylvan/src/sylvan_obj_bdd_storm.hpp
index 393ce988c..afcc027e6 100644
--- a/resources/3rdparty/sylvan/src/sylvan_obj_bdd_storm.hpp
+++ b/resources/3rdparty/sylvan/src/sylvan_obj_bdd_storm.hpp
@@ -1,3 +1,7 @@
     Mtbdd toDoubleMtbdd() const;
     Mtbdd toInt64Mtbdd() const;
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+	Mtbdd toStormRationalFunctionMtbdd() const;
+#endif
     Mtbdd Ite(Mtbdd const& thenDd, Mtbdd const& elseDd) const;
+	Bdd ExistAbstractRepresentative(const BddSet& cube) const;
diff --git a/resources/3rdparty/sylvan/src/sylvan_obj_mtbdd_storm.hpp b/resources/3rdparty/sylvan/src/sylvan_obj_mtbdd_storm.hpp
index 26e5ea4be..cb272dbbb 100644
--- a/resources/3rdparty/sylvan/src/sylvan_obj_mtbdd_storm.hpp
+++ b/resources/3rdparty/sylvan/src/sylvan_obj_mtbdd_storm.hpp
@@ -8,6 +8,44 @@
      */
     Mtbdd Divide(const Mtbdd &other) const;
     
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+	/**
+     * @brief Computes f + g for Rational Functions
+     */
+    Mtbdd PlusRF(const Mtbdd &other) const;
+
+    /**
+     * @brief Computes f * g for Rational Functions
+     */
+    Mtbdd TimesRF(const Mtbdd &other) const;
+	
+	/**
+     * @brief Computes f - g for Rational Functions
+     */
+    Mtbdd MinusRF(const Mtbdd &other) const;
+
+    /**
+     * @brief Computes f / g for Rational Functions
+     */
+    Mtbdd DivideRF(const Mtbdd &other) const;
+	
+	Mtbdd AbstractPlusRF(const BddSet &variables) const;
+	
+	Mtbdd ReplaceLeavesRF(void* context) const;
+	
+	Mtbdd ToDoubleRF() const;
+#endif
+	
+	/**
+     * @brief Computes abstraction by minimum
+     */
+    Bdd AbstractMinRepresentative(const BddSet &variables) const;
+
+    /**
+     * @brief Computes abstraction by maximum
+     */
+    Bdd AbstractMaxRepresentative(const BddSet &variables) const;
+	
     Bdd NotZero() const;
     
     Bdd Equals(const Mtbdd& other) const;
diff --git a/resources/3rdparty/sylvan/src/sylvan_obj_storm.cpp b/resources/3rdparty/sylvan/src/sylvan_obj_storm.cpp
index 27706dcdd..bead06e8a 100644
--- a/resources/3rdparty/sylvan/src/sylvan_obj_storm.cpp
+++ b/resources/3rdparty/sylvan/src/sylvan_obj_storm.cpp
@@ -1,3 +1,9 @@
+Bdd
+Bdd::ExistAbstractRepresentative(const BddSet& cube) const {
+	LACE_ME;
+    return sylvan_existsRepresentative(bdd, cube.set.bdd);
+}
+
 Mtbdd
 Bdd::toDoubleMtbdd() const {
     LACE_ME;
@@ -10,6 +16,60 @@ Bdd::toInt64Mtbdd() const {
     return mtbdd_bool_to_int64(bdd);
 }
 
+#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL)
+Mtbdd
+Bdd::toStormRationalFunctionMtbdd() const {
+    LACE_ME;
+    return mtbdd_bool_to_storm_rational_function(bdd);
+}
+
+Mtbdd 
+Mtbdd::ToDoubleRF() const {
+    LACE_ME;
+    return sylvan_storm_rational_function_to_double(mtbdd);
+}
+
+Mtbdd
+Mtbdd::PlusRF(const Mtbdd &other) const
+{
+    LACE_ME;
+    return sylvan_storm_rational_function_plus(mtbdd, other.mtbdd);
+}
+
+
+Mtbdd
+Mtbdd::TimesRF(const Mtbdd &other) const
+{
+    LACE_ME;
+    return sylvan_storm_rational_function_times(mtbdd, other.mtbdd);
+}
+
+Mtbdd
+Mtbdd::MinusRF(const Mtbdd &other) const
+{
+    LACE_ME;
+    return sylvan_storm_rational_function_minus(mtbdd, other.mtbdd);
+}
+
+Mtbdd
+Mtbdd::DivideRF(const Mtbdd &other) const
+{
+    LACE_ME;
+    return sylvan_storm_rational_function_divide(mtbdd, other.mtbdd);
+}
+
+Mtbdd Mtbdd::AbstractPlusRF(const BddSet &variables) const {
+	LACE_ME;
+    return sylvan_storm_rational_function_abstract_plus(mtbdd, variables.set.bdd);
+}
+
+Mtbdd Mtbdd::ReplaceLeavesRF(void* context) const {
+	LACE_ME;
+    return sylvan_storm_rational_function_replace_leaves(mtbdd, (size_t)context);
+}
+
+#endif
+
 Mtbdd
 Bdd::Ite(Mtbdd const& thenDd, Mtbdd const& elseDd) const {
     LACE_ME;
@@ -139,3 +199,16 @@ Mtbdd::GetShaHash() const {
     return std::string(buf);
 }
 
+Bdd
+Mtbdd::AbstractMinRepresentative(const BddSet &variables) const
+{
+    LACE_ME;
+    return mtbdd_minExistsRepresentative(mtbdd, variables.set.bdd);
+}
+
+Bdd
+Mtbdd::AbstractMaxRepresentative(const BddSet &variables) const
+{
+    LACE_ME;
+    return mtbdd_maxExistsRepresentative(mtbdd, variables.set.bdd);
+}
diff --git a/resources/3rdparty/sylvan/src/sylvan_storm_rational_function.c b/resources/3rdparty/sylvan/src/sylvan_storm_rational_function.c
new file mode 100644
index 000000000..1453449d9
--- /dev/null
+++ b/resources/3rdparty/sylvan/src/sylvan_storm_rational_function.c
@@ -0,0 +1,541 @@
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#undef SYLVAN_STORM_RATIONAL_FUNCTION_DEBUG
+
+#ifdef SYLVAN_STORM_RATIONAL_FUNCTION_DEBUG
+int depth = 0;
+
+#define LOG_I(funcName) do { for (int i = 0; i < depth; ++i) { printf(" "); } ++depth; printf("Entering function " funcName "\n"); } while (0 != 0);
+#define LOG_O(funcName) do { --depth; for (int i = 0; i < depth; ++i) { printf(" "); } printf("Leaving function " funcName "\n"); } while (0 != 0);
+#else
+#define LOG_I(funcName)
+#define LOG_O(funcName)
+#endif
+
+/**
+ * helper function for hash
+ */
+#ifndef rotl64
+//static inline uint64_t
+//rotl64(uint64_t x, int8_t r)
+//{
+//    return ((x<>(64-r)));
+//}
+#endif
+
+static uint64_t
+sylvan_storm_rational_function_hash(const uint64_t v, const uint64_t seed)
+{
+	LOG_I("i-hash")
+    /* Hash the storm::RationalFunction in pointer v */
+    
+	storm_rational_function_ptr x = (storm_rational_function_ptr)v;
+
+	uint64_t hash = storm_rational_function_hash(x, seed);
+
+#ifdef SYLVAN_STORM_RATIONAL_FUNCTION_DEBUG
+	printf("Hashing ptr %p with contents ", x);
+	print_storm_rational_function(x);
+	printf(" with seed %zu, hash = %zu\n", seed, hash);
+#endif
+
+	LOG_O("i-hash")
+	return hash;
+}
+
+static int
+sylvan_storm_rational_function_equals(const uint64_t left, const uint64_t right)
+{
+	LOG_I("i-equals")
+    /* This function is called by the unique table when comparing a new
+       leaf with an existing leaf */
+	storm_rational_function_ptr a = (storm_rational_function_ptr)(size_t)left;
+	storm_rational_function_ptr b = (storm_rational_function_ptr)(size_t)right;
+
+    /* Just compare x and y */
+	int result = storm_rational_function_equals(a, b);
+	
+	LOG_O("i-equals")
+    return result;
+}
+
+static void
+sylvan_storm_rational_function_create(uint64_t *val)
+{
+	LOG_I("i-create")
+	
+#ifdef SYLVAN_STORM_RATIONAL_FUNCTION_DEBUG
+	void* tmp = (void*)*val;
+	printf("sylvan_storm_rational_function_create(ptr = %p, value = ", tmp);
+	print_storm_rational_function(*((storm_rational_function_ptr*)(size_t)val));
+	printf(")\n");
+#endif
+	
+    /* This function is called by the unique table when a leaf does not yet exist.
+       We make a copy, which will be stored in the hash table. */
+	storm_rational_function_ptr* x = (storm_rational_function_ptr*)(size_t)val;
+	storm_rational_function_init(x);
+	
+#ifdef SYLVAN_STORM_RATIONAL_FUNCTION_DEBUG
+	tmp = (void*)*val;
+	printf("sylvan_storm_rational_function_create_2(ptr = %p)\n", tmp);
+#endif
+	
+	LOG_O("i-create")
+}
+
+static void
+sylvan_storm_rational_function_destroy(uint64_t val)
+{
+	LOG_I("i-destroy")
+    /* This function is called by the unique table
+       when a leaf is removed during garbage collection. */
+	storm_rational_function_ptr x = (storm_rational_function_ptr)(size_t)val;
+	storm_rational_function_destroy(x);
+	LOG_O("i-destroy")
+}
+
+static uint32_t sylvan_storm_rational_function_type;
+static uint64_t CACHE_STORM_RATIONAL_FUNCTION_AND_EXISTS;
+
+/**
+ * Initialize storm::RationalFunction custom leaves
+ */
+void
+sylvan_storm_rational_function_init()
+{
+    /* Register custom leaf 3 */
+    sylvan_storm_rational_function_type = mtbdd_register_custom_leaf(sylvan_storm_rational_function_hash, sylvan_storm_rational_function_equals, sylvan_storm_rational_function_create, sylvan_storm_rational_function_destroy);
+	
+	if (SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID != sylvan_storm_rational_function_type) {
+		printf("ERROR - ERROR - ERROR\nThe Sylvan Type ID is NOT correct.\nIt was assumed to be %u, but it is actually %u!\nYou NEED to fix this by changing the macro \"SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID\" and recompiling StoRM!\n\n", SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID, sylvan_storm_rational_function_type);
+		assert(0);
+	}	
+	
+	CACHE_STORM_RATIONAL_FUNCTION_AND_EXISTS = cache_next_opid();
+}
+
+uint32_t sylvan_storm_rational_function_get_type() {
+	return sylvan_storm_rational_function_type;
+}
+
+/**
+ * Create storm::RationalFunction leaf
+ */
+MTBDD
+mtbdd_storm_rational_function(storm_rational_function_ptr val)
+{
+	LOG_I("i-mtbdd_")
+	uint64_t terminalValue = (uint64_t)val;
+	
+#ifdef SYLVAN_STORM_RATIONAL_FUNCTION_DEBUG
+	printf("mtbdd_storm_rational_function(ptr = %p, value = ", val);
+	print_storm_rational_function(val);
+	printf(")\n");
+#endif
+	
+	MTBDD result = mtbdd_makeleaf(sylvan_storm_rational_function_type, terminalValue);
+	
+	LOG_O("i-mtbdd_")
+	return result;
+}
+
+/**
+ * Converts a BDD to a MTBDD with storm::RationalFunction leaves
+ */
+TASK_IMPL_2(MTBDD, mtbdd_op_bool_to_storm_rational_function, MTBDD, a, size_t, v)
+{
+	LOG_I("task_impl_2 to_srf")
+	if (a == mtbdd_false) {
+		MTBDD result = mtbdd_storm_rational_function(storm_rational_function_get_zero());
+		LOG_O("task_impl_2 to_srf - ZERO")
+		return result;
+	}
+	if (a == mtbdd_true) {
+		MTBDD result = mtbdd_storm_rational_function(storm_rational_function_get_one());
+		LOG_O("task_impl_2 to_srf - ONE")
+		return result;
+	}
+    
+    // Ugly hack to get rid of the error "unused variable v" (because there is no version of uapply without a parameter).
+    (void)v;
+	
+    LOG_O("task_impl_2 to_srf - INVALID")
+    return mtbdd_invalid;
+}
+
+TASK_IMPL_1(MTBDD, mtbdd_bool_to_storm_rational_function, MTBDD, dd)
+{
+    return mtbdd_uapply(dd, TASK(mtbdd_op_bool_to_storm_rational_function), 0);
+}
+
+/**
+ * Operation "plus" for two storm::RationalFunction MTBDDs
+ * Interpret partial function as "0"
+ */
+TASK_IMPL_2(MTBDD, sylvan_storm_rational_function_op_plus, MTBDD*, pa, MTBDD*, pb)
+{
+	LOG_I("task_impl_2 op_plus")
+    MTBDD a = *pa, b = *pb;
+
+    /* Check for partial functions */
+    if (a == mtbdd_false) return b;
+    if (b == mtbdd_false) return a;
+
+    /* If both leaves, compute plus */
+    if (mtbdd_isleaf(a) && mtbdd_isleaf(b)) {
+		storm_rational_function_ptr ma = (storm_rational_function_ptr)mtbdd_getvalue(a);
+		storm_rational_function_ptr mb = (storm_rational_function_ptr)mtbdd_getvalue(b);
+
+		storm_rational_function_ptr mres = storm_rational_function_plus(ma, mb);
+        MTBDD res = mtbdd_storm_rational_function(mres);
+        
+		storm_rational_function_destroy(mres);
+
+        return res;
+    }
+
+    /* Commutative, so swap a,b for better cache performance */
+    if (a < b) {
+        *pa = b;
+        *pb = a;
+    }
+
+    return mtbdd_invalid;
+}
+
+/**
+ * Operation "minus" for two storm::RationalFunction MTBDDs
+ * Interpret partial function as "0"
+ */
+TASK_IMPL_2(MTBDD, sylvan_storm_rational_function_op_minus, MTBDD*, pa, MTBDD*, pb)
+{
+    LOG_I("task_impl_2 op_minus")
+	MTBDD a = *pa, b = *pb;
+
+    /* Check for partial functions */
+    if (a == mtbdd_false) return sylvan_storm_rational_function_neg(b);
+    if (b == mtbdd_false) return a;
+
+    /* If both leaves, compute plus */
+    if (mtbdd_isleaf(a) && mtbdd_isleaf(b)) {
+		storm_rational_function_ptr ma = (storm_rational_function_ptr)mtbdd_getvalue(a);
+		storm_rational_function_ptr mb = (storm_rational_function_ptr)mtbdd_getvalue(b);
+
+		storm_rational_function_ptr mres = storm_rational_function_minus(ma, mb);
+		MTBDD res = mtbdd_storm_rational_function(mres);
+
+		storm_rational_function_destroy(mres);
+
+        return res;
+    }
+
+    return mtbdd_invalid;
+}
+
+/**
+ * Operation "times" for two storm::RationalFunction MTBDDs.
+ * One of the parameters can be a BDD, then it is interpreted as a filter.
+ * For partial functions, domain is intersection
+ */
+TASK_IMPL_2(MTBDD, sylvan_storm_rational_function_op_times, MTBDD*, pa, MTBDD*, pb)
+{
+	LOG_I("task_impl_2 op_times")
+    MTBDD a = *pa, b = *pb;
+
+    /* Check for partial functions and for Boolean (filter) */
+    if (a == mtbdd_false || b == mtbdd_false) return mtbdd_false;
+
+    /* If one of Boolean, interpret as filter */
+    if (a == mtbdd_true) return b;
+    if (b == mtbdd_true) return a;
+
+    /* Handle multiplication of leaves */
+    if (mtbdd_isleaf(a) && mtbdd_isleaf(b)) {
+		storm_rational_function_ptr ma = (storm_rational_function_ptr)mtbdd_getvalue(a);
+		storm_rational_function_ptr mb = (storm_rational_function_ptr)mtbdd_getvalue(b);
+
+		storm_rational_function_ptr mres = storm_rational_function_times(ma, mb);		
+		MTBDD res = mtbdd_storm_rational_function(mres);
+
+		storm_rational_function_destroy(mres);
+
+        return res;
+    }
+
+    /* Commutative, so make "a" the lowest for better cache performance */
+    if (a < b) {
+        *pa = b;
+        *pb = a;
+    }
+
+    return mtbdd_invalid;
+}
+
+/**
+ * Operation "divide" for two storm::RationalFunction MTBDDs.
+ * For partial functions, domain is intersection
+ */
+TASK_IMPL_2(MTBDD, sylvan_storm_rational_function_op_divide, MTBDD*, pa, MTBDD*, pb)
+{
+	LOG_I("task_impl_2 op_divide")
+    MTBDD a = *pa, b = *pb;
+
+    /* Check for partial functions */
+    if (a == mtbdd_false || b == mtbdd_false) return mtbdd_false;
+
+    /* Handle division of leaves */
+    if (mtbdd_isleaf(a) && mtbdd_isleaf(b)) {
+		storm_rational_function_ptr ma = (storm_rational_function_ptr)mtbdd_getvalue(a);
+		storm_rational_function_ptr mb = (storm_rational_function_ptr)mtbdd_getvalue(b);
+
+		storm_rational_function_ptr mres = storm_rational_function_divide(ma, mb);
+		MTBDD res = mtbdd_storm_rational_function(mres);
+
+		storm_rational_function_destroy(mres);
+
+        return res;
+    }
+
+    return mtbdd_invalid;
+}
+
+/**
+ * The abstraction operators are called in either of two ways:
+ * - with k=0, then just calculate "a op b"
+ * - with k<>0, then just calculate "a := a op a", k times
+ */
+
+TASK_IMPL_3(MTBDD, sylvan_storm_rational_function_abstract_op_plus, MTBDD, a, MTBDD, b, int, k)
+{
+	LOG_I("task_impl_3 abstract_op_plus")
+    if (k==0) {
+        return mtbdd_apply(a, b, TASK(sylvan_storm_rational_function_op_plus));
+    } else {
+        MTBDD res = a;
+        for (int i=0; i and , and abstract variables  using summation.
+ * This is similar to the "and_exists" operation in BDDs.
+ */
+TASK_IMPL_3(MTBDD, sylvan_storm_rational_function_and_exists, MTBDD, a, MTBDD, b, MTBDD, v)
+{
+    /* Check terminal cases */
+
+    /* If v == true, then  is an empty set */
+    if (v == mtbdd_true) return mtbdd_apply(a, b, TASK(sylvan_storm_rational_function_op_times));
+
+    /* Try the times operator on a and b */
+    MTBDD result = CALL(sylvan_storm_rational_function_op_times, &a, &b);
+    if (result != mtbdd_invalid) {
+        /* Times operator successful, store reference (for garbage collection) */
+        mtbdd_refs_push(result);
+        /* ... and perform abstraction */
+        result = mtbdd_abstract(result, v, TASK(sylvan_storm_rational_function_abstract_op_plus));
+        mtbdd_refs_pop(1);
+        /* Note that the operation cache is used in mtbdd_abstract */
+        return result;
+    }
+
+    /* Maybe perform garbage collection */
+    sylvan_gc_test();
+
+    /* Check cache. Note that we do this now, since the times operator might swap a and b (commutative) */
+    if (cache_get3(CACHE_STORM_RATIONAL_FUNCTION_AND_EXISTS, a, b, v, &result)) return result;
+
+    /* Now, v is not a constant, and either a or b is not a constant */
+
+    /* Get top variable */
+    int la = mtbdd_isleaf(a);
+    int lb = mtbdd_isleaf(b);
+    mtbddnode_t na = la ? 0 : MTBDD_GETNODE(a);
+    mtbddnode_t nb = lb ? 0 : MTBDD_GETNODE(b);
+    uint32_t va = la ? 0xffffffff : mtbddnode_getvariable(na);
+    uint32_t vb = lb ? 0xffffffff : mtbddnode_getvariable(nb);
+    uint32_t var = va < vb ? va : vb;
+
+    mtbddnode_t nv = MTBDD_GETNODE(v);
+    uint32_t vv = mtbddnode_getvariable(nv);
+
+    if (vv < var) {
+        /* Recursive, then abstract result */
+        result = CALL(sylvan_storm_rational_function_and_exists, a, b, node_gethigh(v, nv));
+        mtbdd_refs_push(result);
+        result = mtbdd_apply(result, result, TASK(sylvan_storm_rational_function_op_plus));
+        mtbdd_refs_pop(1);
+    } else {
+        /* Get cofactors */
+        MTBDD alow, ahigh, blow, bhigh;
+        alow  = (!la && va == var) ? node_getlow(a, na)  : a;
+        ahigh = (!la && va == var) ? node_gethigh(a, na) : a;
+        blow  = (!lb && vb == var) ? node_getlow(b, nb)  : b;
+        bhigh = (!lb && vb == var) ? node_gethigh(b, nb) : b;
+
+        if (vv == var) {
+            /* Recursive, then abstract result */
+            mtbdd_refs_spawn(SPAWN(sylvan_storm_rational_function_and_exists, ahigh, bhigh, node_gethigh(v, nv)));
+            MTBDD low = mtbdd_refs_push(CALL(sylvan_storm_rational_function_and_exists, alow, blow, node_gethigh(v, nv)));
+            MTBDD high = mtbdd_refs_push(mtbdd_refs_sync(SYNC(sylvan_storm_rational_function_and_exists)));
+            result = CALL(mtbdd_apply, low, high, TASK(sylvan_storm_rational_function_op_plus));
+            mtbdd_refs_pop(2);
+        } else /* vv > v */ {
+            /* Recursive, then create node */
+            mtbdd_refs_spawn(SPAWN(sylvan_storm_rational_function_and_exists, ahigh, bhigh, v));
+            MTBDD low = mtbdd_refs_push(CALL(sylvan_storm_rational_function_and_exists, alow, blow, v));
+            MTBDD high = mtbdd_refs_sync(SYNC(sylvan_storm_rational_function_and_exists));
+            mtbdd_refs_pop(1);
+            result = mtbdd_makenode(var, low, high);
+        }
+    }
+
+    /* Store in cache */
+    cache_put3(CACHE_STORM_RATIONAL_FUNCTION_AND_EXISTS, a, b, v, result);
+    return result;
+}
+
+/**
+ * Apply a unary operation  to 
. + * Callback is consulted after the cache, thus the application to a terminal is cached. + */ +TASK_DECL_3(MTBDD, mtbdd_uapply_nocache, MTBDD, mtbdd_uapply_op, size_t); +#define mtbdd_uapply_nocache(dd, op, param) CALL(mtbdd_uapply_nocache, dd, op, param) + +/** + * Functionality regarding the replacement of leaves in MTBDDs. + */ + +/** + * Operation "replace" for one storm::RationalFunction MTBDD + */ +TASK_DECL_2(MTBDD, sylvan_storm_rational_function_op_replace_leaves, MTBDD, size_t) + +/** + * Compute the MTBDD that arises from a after calling the mtbddLeaveReplacementFunction on each leaf. + */ +#define sylvan_storm_rational_function_replace_leaves(a, ctx) mtbdd_uapply_nocache(a, TASK(sylvan_storm_rational_function_op_replace_leaves), ctx) + +/** + * Takes a storm::RationalFunction MTBDD and transforms it into a double MTBDD + */ +TASK_DECL_2(MTBDD, sylvan_storm_rational_function_op_to_double, MTBDD, size_t) + +/** + * Compute the MTBDD that arises from a after calling the mtbddLeaveReplacementFunction on each leaf. + */ +#define sylvan_storm_rational_function_to_double(a) mtbdd_uapply_nocache(a, TASK(sylvan_storm_rational_function_op_to_double), 0) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // SYLVAN_HAVE_CARL + +#endif // SYLVAN_STORM_RATIONAL_FUNCTION_H diff --git a/resources/cmake/find_modules/FindHwloc.cmake b/resources/cmake/find_modules/FindHwloc.cmake index 1db759375..b0027dd89 100644 --- a/resources/cmake/find_modules/FindHwloc.cmake +++ b/resources/cmake/find_modules/FindHwloc.cmake @@ -19,7 +19,6 @@ if (NOT HWLOC_PREFIX AND NOT $ENV{HWLOC_BASE} STREQUAL "") set(HWLOC_PREFIX $ENV{HWLOC_BASE}) endif() -message(STATUS "Searching for hwloc library in path " ${HWLOC_PREFIX}) find_library( HWLOC_LIBRARIES @@ -50,6 +49,4 @@ if (HWLOC_FOUND) if (NOT $ENV{HWLOC_LIB} STREQUAL "") # set(HWLOC_LIBRARIES "$ENV{HWLOC_LIB}") endif() - message(STATUS "hwloc includes: " ${HWLOC_INCLUDE_DIRS}) - message(STATUS "hwloc libraries: " ${HWLOC_LIBRARIES}) endif() \ No newline at end of file diff --git a/resources/cmake/find_modules/FindXerces.cmake b/resources/cmake/find_modules/FindXerces.cmake deleted file mode 100644 index f16483769..000000000 --- a/resources/cmake/find_modules/FindXerces.cmake +++ /dev/null @@ -1,96 +0,0 @@ -# From https://code.google.com/p/libcitygml/source/browse/trunk/CMakeModules/FindXerces.cmake?r=95 -# - Try to find Xerces-C -# Once done this will define -# -# XERCESC_FOUND - system has Xerces-C -# XERCESC_INCLUDE - the Xerces-C include directory -# XERCESC_LIBRARY - Link these to use Xerces-C -# XERCESC_VERSION - Xerces-C found version - -IF (XERCESC_INCLUDE AND XERCESC_LIBRARY) - # in cache already - SET(XERCESC_FIND_QUIETLY TRUE) -ENDIF (XERCESC_INCLUDE AND XERCESC_LIBRARY) - - -FIND_PATH(XERCESC_INCLUDE NAMES xercesc/util/XercesVersion.hpp - PATHS - $ENV{XERCESC_INCLUDE_DIR} - ${XERCESC_INCLUDE_DIR} - /usr/local/include - /usr/include -) - -IF (XERCESC_STATIC) - FIND_LIBRARY(XERCESC_LIBRARIES NAMES xerces-c_static_3 xerces-c-3.1 xerces-c - PATHS - $ENV{XERCESC_LIBRARY_DIR} - ${XERCESC_LIBRARY_DIR} - /usr/lib - /usr/local/lib - ) - FIND_LIBRARY(XERCESC_LIBRARIES_DEBUG NAMES xerces-c_static_3D xerces-c-3.1D - PATHS - $ENV{XERCESC_LIBRARY_DIR} - ${XERCESC_LIBRARY_DIR} - /usr/lib - /usr/local/lib - ) - ADD_DEFINITIONS( -DXERCES_STATIC_LIBRARY ) -ELSE (XERCESC_STATIC) - FIND_LIBRARY(XERCESC_LIBRARY NAMES xerces-c_3 - PATHS - $ENV{XERCESC_LIBRARY_DIR} - ${XERCESC_LIBRARY_DIR} - ) - FIND_LIBRARY(XERCESC_LIBRARIES_DEBUG NAMES xerces-c_3D - PATHS - $ENV{XERCESC_LIBRARY_DIR} - ${XERCESC_LIBRARY_DIR} - ) -ENDIF (XERCESC_STATIC) - -IF (XERCESC_INCLUDE AND XERCESC_LIBRARIES) - SET(XERCESC_FOUND TRUE) -ELSE (XERCESC_INCLUDE AND XERCESC_LIBRARIES) - SET(XERCESC_FOUND FALSE) -ENDIF (XERCESC_INCLUDE AND XERCESC_LIBRARIES) - -IF(XERCESC_FOUND) - - FIND_PATH(XERCESC_XVERHPPPATH NAMES XercesVersion.hpp PATHS - ${XERCESC_INCLUDE} - PATH_SUFFIXES xercesc/util) - - IF ( ${XERCESC_XVERHPPPATH} STREQUAL XERCESC_XVERHPPPATH-NOTFOUND ) - SET(XERCES_VERSION "0") - ELSE( ${XERCESC_XVERHPPPATH} STREQUAL XERCESC_XVERHPPPATH-NOTFOUND ) - FILE(READ ${XERCESC_XVERHPPPATH}/XercesVersion.hpp XVERHPP) - - STRING(REGEX MATCHALL "\n *#define XERCES_VERSION_MAJOR +[0-9]+" XVERMAJ - ${XVERHPP}) - STRING(REGEX MATCH "\n *#define XERCES_VERSION_MINOR +[0-9]+" XVERMIN - ${XVERHPP}) - STRING(REGEX MATCH "\n *#define XERCES_VERSION_REVISION +[0-9]+" XVERREV - ${XVERHPP}) - - STRING(REGEX REPLACE "\n *#define XERCES_VERSION_MAJOR +" "" - XVERMAJ ${XVERMAJ}) - STRING(REGEX REPLACE "\n *#define XERCES_VERSION_MINOR +" "" - XVERMIN ${XVERMIN}) - STRING(REGEX REPLACE "\n *#define XERCES_VERSION_REVISION +" "" - XVERREV ${XVERREV}) - - SET(XERCESC_VERSION ${XVERMAJ}.${XVERMIN}.${XVERREV}) - - ENDIF ( ${XERCESC_XVERHPPPATH} STREQUAL XERCESC_XVERHPPPATH-NOTFOUND ) - - IF(NOT XERCESC_FIND_QUIETLY) - MESSAGE(STATUS "Found Xerces-C: ${XERCESC_LIBRARY}") - MESSAGE(STATUS " : ${XERCESC_INCLUDE}") - MESSAGE(STATUS " Version: ${XERCESC_VERSION}") - ENDIF(NOT XERCESC_FIND_QUIETLY) -ENDIF(XERCESC_FOUND) - - -MARK_AS_ADVANCED(XERCESC_INCLUDE XERCESC_LIBRARIES) diff --git a/resources/examples/testfiles/ma/jobscheduler.ma b/resources/examples/testfiles/ma/jobscheduler.ma new file mode 100644 index 000000000..152383eaf --- /dev/null +++ b/resources/examples/testfiles/ma/jobscheduler.ma @@ -0,0 +1,44 @@ + +// Stochastic Job Scheduling, based on [] +// Encoding by Junges & Quatmann +// RWTH Aachen University +// Please cite Quatmann et al: Multi-objective Model Checking of Markov Automata +ma + +const double x_j1 = 1.0; +const double x_j2 = 2.0; +const double x_j3 = 3.0; +formula is_running = r_j1 + r_j2 + r_j3 > 0; +formula num_finished = f_j1 + f_j2 + f_j3; +module main + r_j1 : [0..1]; + r_j2 : [0..1]; + r_j3 : [0..1]; + f_j1 : [0..1]; + f_j2 : [0..1]; + f_j3 : [0..1]; + <> (r_j1 = 1) -> x_j1 : (r_j1' = 0) & (r_j2' = 0) & (r_j3' = 0) & (f_j1' = 1); + <> (r_j2 = 1) -> x_j2 : (r_j1' = 0) & (r_j2' = 0) & (r_j3' = 0) & (f_j2' = 1); + <> (r_j3 = 1) -> x_j3 : (r_j1' = 0) & (r_j2' = 0) & (r_j3' = 0) & (f_j3' = 1); + [] (!is_running) & (num_finished = 2) & (f_j1 = 0) -> 1: (r_j1' = 1); + [] (!is_running) & (num_finished = 2) & (f_j2 = 0) -> 1: (r_j2' = 1); + [] (!is_running) & (num_finished = 2) & (f_j3 = 0) -> 1: (r_j3' = 1); + [] (!is_running) & (num_finished <= 1) & (f_j1 = 0) & (f_j2 = 0) -> 1: (r_j1' = 1) & (r_j2' = 1); + [] (!is_running) & (num_finished <= 1) & (f_j1 = 0) & (f_j3 = 0) -> 1: (r_j1' = 1) & (r_j3' = 1); + [] (!is_running) & (num_finished <= 1) & (f_j2 = 0) & (f_j3 = 0) -> 1: (r_j2' = 1) & (r_j3' = 1); +endmodule +init + r_j1 = 0 & + r_j2 = 0 & + r_j3 = 0 & + f_j1 = 0 & + f_j2 = 0 & + f_j3 = 0 +endinit +label "all_jobs_finished" = num_finished=3; +label "half_of_jobs_finished" = num_finished=2; +label "one_job_finished" = num_finished=1; +label "slowest_before_fastest" = f_j1=1 & f_j3=0; +rewards "avg_waiting_time" + true : (3-num_finished)/3; +endrewards diff --git a/resources/examples/testfiles/ma/server.ma b/resources/examples/testfiles/ma/server.ma new file mode 100644 index 000000000..d82c32474 --- /dev/null +++ b/resources/examples/testfiles/ma/server.ma @@ -0,0 +1,34 @@ + +ma + +const double rateProcessing = 2; +const double rateA = 1; +const double rateB = 1; + +module server + + s : [0..5]; // current state: + // 0: wait for request + // 1: received request from A + // 2: received request from B + // 3: starting to process request of B + // 4: processing request + // 5: error + + + + <> s=0 -> rateA : (s'=1) + rateB : (s'=2); + [alpha] s=1 -> 1 : (s'=4); + [alpha] s=2 -> 1 : (s'=3); + [beta] s=2 -> 0.5 : (s'=0) + 0.5 : (s'=3); + [] s=3 -> 1 : (s'=4); + <> s=4 -> rateProcessing : (s'=0) + (rateA+rateB) : (s'=5); + <> s=5 -> 1 : true; + +endmodule + + +label "error" = (s=5); +label "processB" = (s=3); + + diff --git a/resources/examples/testfiles/mdp/multiobj_consensus2_3_2.nm b/resources/examples/testfiles/mdp/multiobj_consensus2_3_2.nm new file mode 100644 index 000000000..f8fff18da --- /dev/null +++ b/resources/examples/testfiles/mdp/multiobj_consensus2_3_2.nm @@ -0,0 +1,88 @@ +// model of randomised consensus + +mdp + +const int N = 2; // num processes +const int MAX = 3; // num rounds (R) +const int K = 2; // Parameter for coins + +// need to turn these into local copies later so the reading phase is complete? +formula leaders_agree1 = (p1=1 | r1 (p1'=1) & (r1'=1); + [] s1=0 & r1=0 -> (p1'=2) & (r1'=1); + + // read registers (currently does nothing because read vs from other processes + [] s1=0 & r1>0 & r1<=MAX -> (s1'=1); + // maxke a decision + [] s1=1 & decide1 -> (s1'=4) & (p1'=1); + [] s1=1 & decide2 -> (s1'=4) & (p1'=2); + [] s1=1 & r1 (s1'=0) & (p1'=1) & (r1'=r1+1); + [] s1=1 & r1 (s1'=0) & (p1'=2) & (r1'=r1+1); + [] s1=1 & r1 (s1'=2) & (p1'=0); + [] s1=1 & r1=MAX & !(decide1 | decide2) -> (s1'=5); // run out of rounds so error + // enter the coin procotol for the current round + [coin1_s1_start] s1=2 & r1=1 -> (s1'=3); + [coin2_s1_start] s1=2 & r1=2 -> (s1'=3); + // get response from the coin protocol + [coin1_s1_p1] s1=3 & r1=1 -> (s1'=0) & (p1'=1) & (r1'=r1+1); + [coin1_s1_p2] s1=3 & r1=1 -> (s1'=0) & (p1'=2) & (r1'=r1+1); + [coin2_s1_p1] s1=3 & r1=2 -> (s1'=0) & (p1'=1) & (r1'=r1+1); + [coin2_s1_p2] s1=3 & r1=2 -> (s1'=0) & (p1'=2) & (r1'=r1+1); + // done so loop + [done] s1>=4 -> true; + +endmodule + +module process2 = process1[ s1=s2, + p1=p2,p2=p1, + r1=r2,r2=r1, + coin1_s1_start=coin1_s2_start,coin2_s1_start=coin2_s2_start, + coin1_s1_p1=coin1_s2_p1,coin2_s1_p1=coin2_s2_p1, + coin1_s1_p2=coin1_s2_p2,coin2_s1_p2=coin2_s2_p2 ] +endmodule + +module coin1_error + + c1 : [0..1]; // 1 is the error state + v1 : [0..2]; // value of the coin returned the first time + + // first returned value (any processes) + [coin1_s1_p1] v1=0 -> (v1'=1); + [coin1_s2_p1] v1=0 -> (v1'=1); + [coin1_s1_p2] v1=0 -> (v1'=2); + [coin1_s2_p2] v1=0 -> (v1'=2); + // later values returned + [coin1_s1_p1] v1=1 -> true; // good behaviour + [coin1_s2_p1] v1=1 -> true; // good behaviour + [coin1_s1_p2] v1=2 -> true; // good behaviour + [coin1_s2_p2] v1=2 -> true; // good behaviour + [coin1_s1_p1] v1=2 -> (c1'=1); // error + [coin1_s2_p1] v1=2 -> (c1'=1); // error + [coin1_s1_p2] v1=1 -> (c1'=1); // error + [coin1_s2_p2] v1=1 -> (c1'=1); // error + +endmodule + +// coins 2 and 3 are of no use as there are not enough rounds afterwards to decide + +// Labels +label "one_proc_err" = (s1=5 | s2=5); +label "one_coin_ok" = (c1=0); diff --git a/resources/examples/testfiles/mdp/multiobj_dpm100.nm b/resources/examples/testfiles/mdp/multiobj_dpm100.nm new file mode 100644 index 000000000..2d8a4544c --- /dev/null +++ b/resources/examples/testfiles/mdp/multiobj_dpm100.nm @@ -0,0 +1,160 @@ +// power manager example +mdp + +const int QMAX =2; // max queue size + +// to model the pm making a choice and then a move being made we need +// two clock ticks for each transition +// first the pm decides tick1 and then the system moves tick2 + +module timer + + c : [0..1]; + + [tick1] c=0 -> (c'=1); + [tick2] c=1 -> (c'=0); + +endmodule + +//------------------------------------------------------------------------- + +// POWER MANAGER +module PM + + pm : [0..4] init 4; + // 0 - go to active + // 1 - go to idle + // 2 - go to idlelp + // 3 - go to stby + // 4 - go to sleep + + [tick1] true -> (pm'=0); + [tick1] true -> (pm'=1); + [tick1] true -> (pm'=2); + [tick1] true -> (pm'=3); + [tick1] true -> (pm'=4); + +endmodule + + +//------------------------------------------------------------------------- + +// SERVICE REQUESTER +module SR + + sr : [0..1] init 0; + // 0 idle + // 1 1req + + [tick2] sr=0 -> 0.898: (sr'=0) + 0.102: (sr'=1); + [tick2] sr=1 -> 0.454: (sr'=0) + 0.546: (sr'=1); + +endmodule + +//------------------------------------------------------------------------- + +// SERVICE PROVIDER + +module SP + + sp : [0..10] init 9; + // 0 active + // 1 idle + // 2 active_idlelp + // 3 idlelp + // 4 idlelp_active + // 5 active_stby + // 6 stby + // 7 stby_active + // 8 active_sleep + // 9 sleep + // 10 sleep_active + + // states where PM has no control (transient states) + [tick2] sp=2 -> 0.75 : (sp'=2) + 0.25 : (sp'=3); // active_idlelp + [tick2] sp=4 -> 0.25 : (sp'=0) + 0.75 : (sp'=4); // idlelp_active + [tick2] sp=5 -> 0.995 : (sp'=5) + 0.005 : (sp'=6); // active_stby + [tick2] sp=7 -> 0.005 : (sp'=0) + 0.995 : (sp'=7); // stby_active + [tick2] sp=8 -> 0.9983 : (sp'=8) + 0.0017 : (sp'=9); // active_sleep + [tick2] sp=10 -> 0.0017 : (sp'=0) + 0.9983 : (sp'=10); // sleep_active + + // states where PM has control + // goto_active + [tick2] sp=0 & pm=0 -> (sp'=0); // active + [tick2] sp=1 & pm=0 -> (sp'=0); // idle + [tick2] sp=3 & pm=0 -> (sp'=4); // idlelp + [tick2] sp=6 & pm=0 -> (sp'=7); // stby + [tick2] sp=9 & pm=0 -> (sp'=10); // sleep + // goto_idle + [tick2] sp=0 & pm=1 -> (sp'=1); // active + [tick2] sp=1 & pm=1 -> (sp'=1); // idle + [tick2] sp=3 & pm=1 -> (sp'=3); // idlelp + [tick2] sp=6 & pm=1 -> (sp'=6); // stby + [tick2] sp=9 & pm=1 -> (sp'=9); // sleep + // goto_idlelp + [tick2] sp=0 & pm=2 -> (sp'=2); // active + [tick2] sp=1 & pm=2 -> (sp'=2); // idle + [tick2] sp=3 & pm=2 -> (sp'=3); // idlelp + [tick2] sp=6 & pm=2 -> (sp'=6); // stby + [tick2] sp=9 & pm=2 -> (sp'=9); // sleep + // goto_stby + [tick2] sp=0 & pm=3 -> (sp'=5); // active + [tick2] sp=1 & pm=3 -> (sp'=5); // idle + [tick2] sp=3 & pm=3 -> (sp'=5); // idlelp + [tick2] sp=6 & pm=3 -> (sp'=6); // stby + [tick2] sp=9 & pm=3 -> (sp'=9); // sleep + // goto_sleep + [tick2] sp=0 & pm=4 -> (sp'=8); // active + [tick2] sp=1 & pm=4 -> (sp'=8); // idle + [tick2] sp=3 & pm=4 -> (sp'=8); // idlelp + [tick2] sp=6 & pm=4 -> (sp'=8); // stby + [tick2] sp=9 & pm=4 -> (sp'=9); // sleep + +endmodule + + +//------------------------------------------------------------------------- + +// SQ +module SQ + + q : [0..QMAX] init 0; + + // serve if busy + [tick2] sr=0 & sp=0 -> (q'=max(q-1,0)); + [tick2] sr=1 & sp=0 -> (q'=q); + + // otherwise do nothing + [tick2] sr=0 & sp>0 -> (q'=q); + [tick2] sr=1 & sp>0 -> (q'=min(q+1,QMAX)); + +endmodule + +//------------------------------------------------------------------------- +//rewards "time" +// [tick2] bat=1 : 1; +//endrewards + +rewards "power" + [tick2] sp=0 & c=1 : 2.5; + [tick2] sp=1 & c=1 : 1.5; + [tick2] sp=2 & c=1 : 2.5; + [tick2] sp=3 & c=1 : 0.8; + [tick2] sp=4 & c=1 : 2.5; + [tick2] sp=5 & c=1 : 2.5; + [tick2] sp=6 & c=1 : 0.3; + [tick2] sp=7 & c=1 : 2.5; + [tick2] sp=8 & c=1 : 2.5; + [tick2] sp=9 & c=1 : 0.1; + [tick2] sp=10 & c=1 : 2.5; +endrewards + +// is an instantaneous property but I suppose we can look at average size +// i.e. divide by the expected number of time steps +rewards "queue" + [tick2] c=1 : q; +endrewards + +rewards "lost" + [tick2] sr=1 & sp>0 & q=2 : 1; +endrewards diff --git a/resources/examples/testfiles/mdp/multiobj_scheduler05.nm b/resources/examples/testfiles/mdp/multiobj_scheduler05.nm new file mode 100644 index 000000000..f10f491f3 --- /dev/null +++ b/resources/examples/testfiles/mdp/multiobj_scheduler05.nm @@ -0,0 +1,95 @@ +mdp + +label "tasks_complete" = (task6=3); + +const int K=5; + +module scheduler + + task1 : [0..3]; + task2 : [0..3]; + task3 : [0..3]; + task4 : [0..3]; + task5 : [0..3]; + task6 : [0..3]; + + [p1_add] task1=0 -> (task1'=1); + [p2_add] task1=0 -> (task1'=2); + [p1_mult] task2=0 -> (task2'=1); + [p2_mult] task2=0 -> (task2'=2); + [p1_mult] task3=0&task1=3 -> (task3'=1); + [p2_mult] task3=0&task1=3 -> (task3'=2); + [p1_add] task4=0&task1=3&task2=3 -> (task4'=1); + [p2_add] task4=0&task1=3&task2=3 -> (task4'=2); + [p1_mult] task5=0&task3=3 -> (task5'=1); + [p2_mult] task5=0&task3=3 -> (task5'=2); + [p1_add] task6=0&task4=3&task5=3 -> (task6'=1); + [p2_add] task6=0&task4=3&task5=3 -> (task6'=2); + [p1_done] task1=1 -> (task1'=3); + [p1_done] task2=1 -> (task2'=3); + [p1_done] task3=1 -> (task3'=3); + [p1_done] task4=1 -> (task4'=3); + [p1_done] task5=1 -> (task5'=3); + [p1_done] task6=1 -> (task6'=3); + [p2_done] task1=2 -> (task1'=3); + [p2_done] task2=2 -> (task2'=3); + [p2_done] task3=2 -> (task3'=3); + [p2_done] task4=2 -> (task4'=3); + [p2_done] task5=2 -> (task5'=3); + [p2_done] task6=2 -> (task6'=3); + [time] true -> 1.0 : true; + +endmodule + +module P1 + + p1 : [0..3]; + c1 : [0..2]; + x1 : [0..4*K+1]; + + [p1_add] (p1=0) -> (p1'=1) & (x1'=0); + [] (p1=1)&(x1=1*K)&(c1=0) -> 1/3 : (p1'=3) & (x1'=0) & (c1'=0) + 2/3 : (c1'=1) & (x1'=0); + [] (p1=1)&(x1=1*K)&(c1=1) -> 1/2 : (p1'=3) & (x1'=0) & (c1'=0) + 1/2 : (c1'=2) & (x1'=0); + [p1_done] (p1=1)&(x1=1*K)&(c1=2) -> (p1'=0) & (x1'=0) & (c1'=0); + [p1_mult] (p1=0) -> (p1'=2) & (x1'=0); + [] (p1=2)&(x1=2*K)&(c1=0) -> 1/3 : (p1'=3) & (x1'=0) & (c1'=0) + 2/3 : (c1'=1) & (x1'=0); + [] (p1=2)&(x1=1*K)&(c1=1) -> 1/2 : (p1'=3) & (x1'=0) & (c1'=0) + 1/2 : (c1'=2) & (x1'=0); + [p1_done] (p1=2)&(x1=1*K)&(c1=2) -> (p1'=0) & (x1'=0) & (c1'=0); + [p1_done] (p1=3) -> (p1'=0); + [time] (p1=1=>x1+1<=1*K)&((p1=2&c1=0)=>x1+1<=2*K)&((p1=2&c1>0)=>x1+1<=1*K)&(p1=3=>x1+1<=0) -> 1.0 : (x1'=min(x1+1,4*K+1)); + +endmodule + +module P2 + + p2 : [0..3]; + c2 : [0..2]; + x2 : [0..6*K+1]; + + [p2_add] (p2=0) -> (p2'=1) & (x2'=0); + [] (p2=1)&(x2=4*K)&(c2=0) -> 1/3 : (p2'=3) & (x2'=0) & (c2'=0) + 2/3 : (c2'=1) & (x2'=0); + [] (p2=1)&(x2=1)&(c2=1) -> 1/2 : (p2'=3) & (x2'=0) & (c2'=0) + 1/2 : (c2'=2) & (x2'=0); + [p2_done] (p2=1)&(x2=1)&(c2=2) -> (p2'=0) & (x2'=0) & (c2'=0); + [p2_mult] (p2=0) -> (p2'=2) & (x2'=0); + [] (p2=2)&(x2=6*K)&(c2=0) -> 1/3 : (p2'=3) & (x2'=0) & (c2'=0) + 2/3 : (c2'=1) & (x2'=0); + [] (p2=2)&(x2=1)&(c2=1) -> 1/2 : (p2'=3) & (x2'=0) & (c2'=0) + 1/2 : (c2'=2) & (x2'=0); + [p2_done] (p2=2)&(x2=1)&(c2=2) -> (p2'=0) & (x2'=0) & (c2'=0); + [p2_done] (p2=3) -> (p2'=0); + [time] ((p2=1&c2=0)=>x2+1<=4*K)&((p2=1&c2>0)=>x2+1<=1)&((p2=2&c2=0)=>x2+1<=6*K)&((p2=2&c2>0)=>x2+1<=1)&(p2=3=>x2+1<=0) -> 1.0 : (x2'=min(x2+1,6*K+1)); + +endmodule + +rewards "time" + + [time] true : 1/K; + +endrewards + +rewards "energy" + + [time] p1=0 : 10/(1000*K); + [time] p1>0 : 90/(1000*K); + [time] p2=0 : 20/(1000*K); + [time] p2>0 : 30/(1000*K); + +endrewards diff --git a/resources/examples/testfiles/mdp/multiobj_team3.nm b/resources/examples/testfiles/mdp/multiobj_team3.nm new file mode 100644 index 000000000..58a7108b1 --- /dev/null +++ b/resources/examples/testfiles/mdp/multiobj_team3.nm @@ -0,0 +1,292 @@ +mdp + +// parameters +const int n_resources = 3; +const int n_tasks = 2; +const int n_sensors = 3; + + +// sensor resources +const int resource1=1; +const int resource2=2; +const int resource3=3; + +// network configuration +const int e12=1; +const int e13=1; + +const int e21=e12; +const int e23=1; + +const int e31=e13; +const int e32=e23; + + + + +// agent is committed to some team +formula committed = (m1_t1+m1_t2) > 0; + +// formulae to compute team sizes +formula team_size_t1 = m1_t1+m2_t1+m3_t1; +formula team_size_t2 = m1_t2+m2_t2+m3_t2; + +// formulae to check whether the agent can join the team +formula can_join_t1 = e12*m2_t1 + e13*m3_t1 > 0; +formula can_join_t2 = e12*m2_t2 + e13*m3_t2 > 0; + +// formulae to check whether agent has the resource required by the task +formula has_resource_t1 = ( (t1_r1=1&resource1=1) | (t1_r2=1&resource1=2) | (t1_r3=1&resource1=3) ); +formula has_resource_t2 = ( (t2_r1=1&resource1=1) | (t2_r2=1&resource1=2) | (t2_r3=1&resource1=3) ); + +// formulae to check whether the resource of an agent has been already filled in the team +formula resource_filled_t1 = (m2_t1=1 & resource1=resource2) | (m3_t1=1 & resource1=resource3); +formula resource_filled_t2 = (m2_t2=1 & resource1=resource2) | (m3_t2=1 & resource1=resource3); + +// formula to compute team initiation probability (assuming each agent has at least one connection) +formula IP = (e12*(1-((m2_t1+m2_t2)=0?0:1))+e13*(1-((m3_t1+m3_t2)=0?0:1))) / (e12+e13); + + +module controller // schedules the algorithm + + // algorithm status + status : [0..6]; + + // task resource indicator variables + t1_r1 : [0..1]; + t1_r2 : [0..1]; + t1_r3 : [0..1]; + + t2_r1 : [0..1]; + t2_r2 : [0..1]; + t2_r3 : [0..1]; + + // schedule placeholders + turn1 : [0..n_sensors]; + turn2 : [0..n_sensors]; + turn3 : [0..n_sensors]; + + // selecting schedule uniformly at random + [] status=0 -> 1/6 : (turn1'=1) & (turn2'=2) & (turn3'=3) & (status'=1) + + 1/6 : (turn1'=1) & (turn2'=3) & (turn3'=2) & (status'=1) + + 1/6 : (turn1'=2) & (turn2'=1) & (turn3'=3) & (status'=1) + + 1/6 : (turn1'=2) & (turn2'=3) & (turn3'=1) & (status'=1) + + 1/6 : (turn1'=3) & (turn2'=1) & (turn3'=2) & (status'=1) + + 1/6 : (turn1'=3) & (turn2'=2) & (turn3'=1) & (status'=1); + + + // initialising non-empty tasks uniformly at random + [] status=1 -> 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) + + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2); + + // executing the schedule + + // 1st round + [str1] status=2 & turn1=1 -> (status'=2); + [fin1] status=2 & turn1=1 -> (status'=3); + [str2] status=2 & turn1=2 -> (status'=2); + [fin2] status=2 & turn1=2 -> (status'=3); + [str3] status=2 & turn1=3 -> (status'=2); + [fin3] status=2 & turn1=3 -> (status'=3); + + // 2nd round + [str1] status=3 & turn2=1 -> (status'=3); + [fin1] status=3 & turn2=1 -> (status'=4); + [str2] status=3 & turn2=2 -> (status'=3); + [fin2] status=3 & turn2=2 -> (status'=4); + [str3] status=3 & turn2=3 -> (status'=3); + [fin3] status=3 & turn2=3 -> (status'=4); + + // 3rd round + [str1] status=4 & turn3=1 -> (status'=4); + [fin1] status=4 & turn3=1 -> (status'=5); + [str2] status=4 & turn3=2 -> (status'=4); + [fin2] status=4 & turn3=2 -> (status'=5); + [str3] status=4 & turn3=3 -> (status'=4); + [fin3] status=4 & turn3=3 -> (status'=5); + + [] status=5 -> (status'=6); + + [] status=6 -> true; + +endmodule + +module sensor1 + + state1 : [0..1]; + + // team membership indicators + m1_t1 : [0..1]; + m1_t2 : [0..1]; + + // starting turn, selecting order of tasks + [str1] state1=0 -> (state1'=1); + + // if there is no team and has required skill - initiating the team + [] state1=1 & !committed & team_size_t1=0 & has_resource_t1 -> (m1_t1'=1); + [] state1=1 & !committed & team_size_t2=0 & has_resource_t2 -> (m1_t2'=1); + + // if team already exists and one of the neighbours is in it - joining the team + [] state1=1 & !committed & team_size_t1>0 & can_join_t1 & has_resource_t1 & !resource_filled_t1 -> (m1_t1'=1); + [] state1=1 & !committed & team_size_t2>0 & can_join_t2 & has_resource_t2 & !resource_filled_t2 -> (m1_t2'=1); + + [fin1] state1>0 -> (state1'=0); + +endmodule + +module sensor2 = sensor1 +[ + state1=state2, + + str1=str2, + fin1=fin2, + + m1_t1=m2_t1, + m1_t2=m2_t2, + + m2_t1=m1_t1, + m2_t2=m1_t2, + + resource1=resource2, + resource2=resource1, + + e12=e21, + e13=e23, + e14=e24, + e15=e25, + + e21=e12, + e23=e13, + e24=e14, + e25=e15 +] +endmodule + +module sensor3 = sensor1 +[ + state1=state3, + + str1=str3, + fin1=fin3, + + m1_t1=m3_t1, + m1_t2=m3_t2, + m3_t1=m1_t1, + m3_t2=m1_t2, + + resource1=resource3, + resource3=resource1, + + e12=e32, + e13=e31, + e14=e34, + e15=e35, + + e31=e13, + e32=e12, + e34=e14, + e35=e15 +] +endmodule + + + + +// labels and formulae for property specification +formula finished = (status=5); +label "end" = (status=6); + + +formula task1_completed = finished + & ((t1_r1=1)=>((m1_t1=1&resource1=1)|(m2_t1=1&resource2=1)|(m3_t1=1&resource3=1))) + & ((t1_r2=1)=>((m1_t1=1&resource1=2)|(m2_t1=1&resource2=2)|(m3_t1=1&resource3=2))) + & ((t1_r3=1)=>((m1_t1=1&resource1=3)|(m2_t1=1&resource2=3)|(m3_t1=1&resource3=3))); + +formula task2_completed = finished + & ((t2_r1=1)=>((m1_t2=1&resource1=1)|(m2_t2=1&resource2=1)|(m3_t2=1&resource3=1))) + & ((t2_r2=1)=>((m1_t2=1&resource1=2)|(m2_t2=1&resource2=2)|(m3_t2=1&resource3=2))) + & ((t2_r3=1)=>((m1_t2=1&resource1=3)|(m2_t2=1&resource2=3)|(m3_t2=1&resource3=3))); + + + +formula agent1_joins_successful_team = (task1_completed & m1_t1=1) | (task2_completed & m1_t2=1); +formula agent1_joins_successful_team_of_1 = (task1_completed & m1_t1=1 & team_size_t1=1) | (task2_completed & m1_t2=1 & team_size_t2=1); +formula agent1_joins_successful_team_of_2 = (task1_completed & m1_t1=1 & team_size_t1=2) | (task2_completed & m1_t2=1 & team_size_t2=2); +formula agent1_joins_successful_team_of_3 = (task1_completed & m1_t1=1 & team_size_t1=3) | (task2_completed & m1_t2=1 & team_size_t2=3); + +formula agent2_joins_successful_team = (task1_completed & m2_t1=1) | (task2_completed & m2_t2=1); +formula agent2_joins_successful_team_of_1 = (task1_completed & m2_t1=1 & team_size_t1=1) | (task2_completed & m2_t2=1 & team_size_t2=1); +formula agent2_joins_successful_team_of_2 = (task1_completed & m2_t1=1 & team_size_t1=2) | (task2_completed & m2_t2=1 & team_size_t2=2); +formula agent2_joins_successful_team_of_3 = (task1_completed & m2_t1=1 & team_size_t1=3) | (task2_completed & m2_t2=1 & team_size_t2=3); + +formula agent3_joins_successful_team = (task1_completed & m3_t1=1) | (task2_completed & m3_t2=1); +formula agent3_joins_successful_team_of_1 = (task1_completed & m3_t1=1 & team_size_t1=1) | (task2_completed & m3_t2=1 & team_size_t2=1); +formula agent3_joins_successful_team_of_2 = (task1_completed & m3_t1=1 & team_size_t1=2) | (task2_completed & m3_t2=1 & team_size_t2=2); +formula agent3_joins_successful_team_of_3 = (task1_completed & m3_t1=1 & team_size_t1=3) | (task2_completed & m3_t2=1 & team_size_t2=3); + + +label "task1_compl" = task1_completed; +label "task2_compl" = task2_completed; + +// rewards +rewards "w_1_total" + [] agent1_joins_successful_team : 1; + [] agent2_joins_successful_team : 1; + [] agent3_joins_successful_team : 1; +endrewards + +rewards "w_2_total" + [] task1_completed : 1; + [] task2_completed : 1; +endrewards + + + + diff --git a/resources/examples/testfiles/mdp/multiobj_zeroconf4.nm b/resources/examples/testfiles/mdp/multiobj_zeroconf4.nm new file mode 100644 index 000000000..1ea3f3848 --- /dev/null +++ b/resources/examples/testfiles/mdp/multiobj_zeroconf4.nm @@ -0,0 +1,153 @@ +// IPv4: PTA model with digitial clocks +// multi-objective model of the host +// gxn/dxp 28/09/09 + +mdp + +//------------------------------------------------------------- +// VARIABLES +const int N=20; // number of abstract hosts +const int K=4; // number of probes to send + +// PROBABILITIES +const double old = N/65024; // probability pick an ip address being used +//const double old = 0.5; // probability pick an ip address being used +const double new = (1-old); // probability pick a new ip address + +// TIMING CONSTANTS +const int CONSEC = 2; // time interval between sending consecutive probles +const int TRANSTIME = 1; // upper bound on transmission time delay +const int LONGWAIT = 60; // minimum time delay after a high number of address collisions +const int DEFEND = 10; + +const int TIME_MAX_X = 60; // max value of clock x +const int TIME_MAX_Y = 10; // max value of clock y +const int TIME_MAX_Z = 1; // max value of clock z + +// OTHER CONSTANTS +const int MAXCOLL = 10; // maximum number of collisions before long wait +const int M=1; // time between sending and receiving a message + + +//------------------------------------------------------------- +// CONCRETE HOST +module host0 + + x : [0..TIME_MAX_X]; // first clock of the host + y : [0..TIME_MAX_Y]; // second clock of the host + + coll : [0..MAXCOLL]; // number of address collisions + probes : [0..K]; // counter (number of probes sent) + mess : [0..1]; // need to send a message or not + defend : [0..1]; // defend (if =1, try to defend IP address) + + ip : [1..2]; // ip address (1 - in use & 2 - fresh) + + l : [0..4] init 1; // location + // 0 : RECONFIGURE + // 1 : RANDOM + // 2 : WAITSP + // 3 : WAITSG + // 4 : USE + + // RECONFIGURE + [reset] l=0 -> (l'=1); + + // RANDOM (choose IP address) + [rec0] (l=1) -> true; // get message (ignore since have no ip address) + [rec1] (l=1) -> true; // get message (ignore since have no ip address) + // small number of collisions (choose straight away) + [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) + + 1/3*old : (l'=2) & (ip'=1) & (x'=1) + + 1/3*old : (l'=2) & (ip'=1) & (x'=2) + + 1/3*new : (l'=2) & (ip'=2) & (x'=0) + + 1/3*new : (l'=2) & (ip'=2) & (x'=1) + + 1/3*new : (l'=2) & (ip'=2) & (x'=2); + // large number of collisions: (wait for LONGWAIT) + [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); + [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) + + 1/3*old : (l'=2) & (ip'=1) & (x'=1) + + 1/3*old : (l'=2) & (ip'=1) & (x'=2) + + 1/3*new : (l'=2) & (ip'=2) & (x'=0) + + 1/3*new : (l'=2) & (ip'=2) & (x'=1) + + 1/3*new : (l'=2) & (ip'=2) & (x'=2); + + // WAITSP + // let time pass + [time] l=2 & x<2 -> (x'=min(x+1,2)); + // send probe + [send1] l=2 & ip=1 & x=2 & probes (x'=0) & (probes'=probes+1); + [send2] l=2 & ip=2 & x=2 & probes (x'=0) & (probes'=probes+1); + // sent K probes and waited 2 seconds + [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); + // get message and ip does not match: ignore + [rec0] l=2 & ip!=0 -> (l'=l); + [rec1] l=2 & ip!=1 -> (l'=l); + // get a message with matching ip: reconfigure + [rec1] l=2 & ip=1 -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); + + // WAITSG (sends two gratuitious arp probes) + // time passage + [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); + [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); + + // receive message and same ip: defend + [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); + // receive message and same ip: defer + [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); + // receive message and different ip + [rec0] l=3 & mess=0 & ip!=0 -> (l'=l); + [rec1] l=3 & mess=0 & ip!=1 -> (l'=l); + + + // send probe reply or message for defence + [send1] l=3 & ip=1 & mess=1 -> (mess'=0); + [send2] l=3 & ip=2 & mess=1 -> (mess'=0); + // send first gratuitous arp message + [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); + [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); + // send second gratuitous arp message (move to use) + [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); + [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); + + // USE (only interested in reaching this state so do not need to add anything here) + [] l=4 -> true; + +endmodule + +//------------------------------------------------------------- +// error automaton for the environment assumption +// do not get a reply when K probes are sent + +module env_error4 + + env : [0..1]; // 0 active and 1 done + k : [0..4]; // counts the number of messages sent + c1 : [0..M+1]; // time since first message + c2 : [0..M+1]; // time since second message + c3 : [0..M+1]; // time since third message + c4 : [0..M+1]; // time since fourth message + error : [0..1]; + + // message with new ip address arrives so done + [send2] error=0 & env=0 -> (env'=1); + // message with old ip address arrives so count + [send1] error=0 & env=0 -> (k'=min(k+1,K)); + // time passgae so update relevant clocks + [time] error=0 & env=0 & k=0 -> true; + [time] error=0 & env=0 & k=1 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)); + [time] error=0 & env=0 & k=2 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)); + [time] error=0 & env=0 & k=3 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)); + [time] error=0 & env=0 & k=4 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)); + // all clocks reached their bound so an error + [time] error=0 & env=0 & min(c1,c2,c3,c4)=M -> (error'=1); + // send a reply (then done) + [rec1] error=0 & env=0 & k>0 & min(c1,c2,c3,c4)<=M -> (env'=1); + // finished so any action can be performed + [time] error=1 | env=1 -> true; + [send1] error=1 | env=1 -> true; + [send2] error=1 | env=1 -> true; + [send2] error=1 | env=1 -> true; + [rec1] error=1 | env=1 -> true; + +endmodule diff --git a/resources/examples/testfiles/mdp/multiobjective1.nm b/resources/examples/testfiles/mdp/multiobjective1.nm deleted file mode 100644 index 1db60ec50..000000000 --- a/resources/examples/testfiles/mdp/multiobjective1.nm +++ /dev/null @@ -1,20 +0,0 @@ - -mdp - -module module1 - - // local state - s : [0..2] init 0; - - [A] s=0 -> 0.6 : (s'=1) + 0.4 : (s'=2); - [B] s=0 -> 0.3 : (s'=0) + 0.7 : (s'=1); - [C] s=0 -> 0.2 : (s'=0) + 0.8 : (s'=2); - [D] s=1 -> 0.25 : (s'=0) + 0.75 : (s'=2); - [] s=2 -> 1 : (s'=s); -endmodule - -rewards "rew" - [A] true : 10; - [D] true : 4; -endrewards - diff --git a/resources/examples/testfiles/mdp/multiobjective2.nm b/resources/examples/testfiles/mdp/multiobjective2.nm deleted file mode 100644 index 3df5018f5..000000000 --- a/resources/examples/testfiles/mdp/multiobjective2.nm +++ /dev/null @@ -1,20 +0,0 @@ - -mdp - -module module1 - - s : [0..2] init 0; - - [A] s=0 -> 1 : (s'=1); - [B] s=0 -> 1 : (s'=2); - [C] s=1 -> 1 : true; - [D] s=1 -> 1 : (s'=2); - [E] s=2 -> 1 : true; -endmodule - -rewards "rew" - [A] true : 10; - [C] true : 3; - [E] true : 1; -endrewards - diff --git a/resources/examples/testfiles/mdp/wlan0-2-4.nm b/resources/examples/testfiles/mdp/wlan0-2-4.nm new file mode 100644 index 000000000..136be18c5 --- /dev/null +++ b/resources/examples/testfiles/mdp/wlan0-2-4.nm @@ -0,0 +1,114 @@ +mdp +const int COL = 2; +const int ASLOTTIME = 1; +const int DIFS = 3; +const int VULN = 1; +const int TRANS_TIME_MAX = 4; +const int TRANS_TIME_MIN = 4; +const int ACK_TO = 6; +const int ACK = 4; +const int SIFS = 1; +const int TIME_MAX = ((max(6, 4)) + 1); +const int MAX_BACKOFF = 0; + + +formula busy = ((c1 > 0) | (c2 > 0)); +formula free = ((c1 = 0) & (c2 = 0)); + +module medium + col: [0..2] init 0; + c1: [0..2] init 0; + c2: [0..2] init 0; + [send1] ((c1 = 0) & (c2 = 0)) -> 1 : (c1' = 1); + [send2] ((c2 = 0) & (c1 = 0)) -> 1 : (c2' = 1); + [send1] ((c1 = 0) & (c2 > 0)) -> 1 : (col' = (min((col + 1), 2))) & (c1' = 2) & (c2' = 2); + [send2] ((c2 = 0) & (c1 > 0)) -> 1 : (col' = (min((col + 1), 2))) & (c1' = 2) & (c2' = 2); + [finish1] (c1 > 0) -> 1 : (c1' = 0); + [finish2] (c2 > 0) -> 1 : (c2' = 0); +endmodule + +module station1 + x1: [0..((max(6, 4)) + 1)] init 0; + s1: [1..12] init 1; + slot1: [0..1] init 0; + backoff1: [0..15] init 0; + bc1: [0..1] init 0; + [time] (((s1 = 1) & (x1 < 3)) & ((c1 = 0) & (c2 = 0))) -> 1 : (x1' = (min((x1 + 1), 7))); + [] ((s1 = 1) & ((x1 = 3) | (x1 = 2))) -> 1 : (x1' = 0) & (s1' = 8); + [] ((s1 = 1) & ((c1 > 0) | (c2 > 0))) -> 1 : (x1' = 0) & (s1' = 2); + [time] ((s1 = 2) & ((c1 > 0) | (c2 > 0))) -> 1 : (s1' = 2); + [] ((s1 = 2) & ((c1 = 0) & (c2 = 0))) -> 1 : (s1' = 3); + [time] (((s1 = 3) & (x1 < 3)) & ((c1 = 0) & (c2 = 0))) -> 1 : (x1' = (min((x1 + 1), 7))); + [] ((s1 = 3) & ((c1 > 0) | (c2 > 0))) -> 1 : (x1' = 0) & (s1' = 2); + [] (((s1 = 3) & ((x1 = 3) | (x1 = 2))) & (bc1 = 0)) -> 1 : (x1' = 0) & (s1' = 4) & (slot1' = 0) & (bc1' = (min((bc1 + 1), 0))); + [] (s1 = 4) -> (1 / 16) : (s1' = 5) & (backoff1' = 0) + (1 / 16) : (s1' = 5) & (backoff1' = 1) + (1 / 16) : (s1' = 5) & (backoff1' = 2) + (1 / 16) : (s1' = 5) & (backoff1' = 3) + (1 / 16) : (s1' = 5) & (backoff1' = 4) + (1 / 16) : (s1' = 5) & (backoff1' = 5) + (1 / 16) : (s1' = 5) & (backoff1' = 6) + (1 / 16) : (s1' = 5) & (backoff1' = 7) + (1 / 16) : (s1' = 5) & (backoff1' = 8) + (1 / 16) : (s1' = 5) & (backoff1' = 9) + (1 / 16) : (s1' = 5) & (backoff1' = 10) + (1 / 16) : (s1' = 5) & (backoff1' = 11) + (1 / 16) : (s1' = 5) & (backoff1' = 12) + (1 / 16) : (s1' = 5) & (backoff1' = 13) + (1 / 16) : (s1' = 5) & (backoff1' = 14) + (1 / 16) : (s1' = 5) & (backoff1' = 15); + [time] (((s1 = 5) & (x1 < 1)) & ((c1 = 0) & (c2 = 0))) -> 1 : (x1' = (min((x1 + 1), 7))); + [] (((s1 = 5) & (x1 = 1)) & (backoff1 > 0)) -> 1 : (x1' = 0) & (s1' = 5) & (backoff1' = (backoff1 - 1)); + [] ((((s1 = 5) & (x1 = 1)) & (backoff1 = 0)) & (slot1 > 0)) -> 1 : (x1' = 0) & (s1' = 5) & (slot1' = (slot1 - 1)) & (backoff1' = 15); + [] ((((s1 = 5) & (x1 = 1)) & (backoff1 = 0)) & (slot1 = 0)) -> 1 : (x1' = 0) & (s1' = 8); + [] ((s1 = 5) & ((c1 > 0) | (c2 > 0))) -> 1 : (x1' = 0) & (s1' = 6); + [time] ((s1 = 6) & ((c1 > 0) | (c2 > 0))) -> 1 : (s1' = 6); + [] ((s1 = 6) & ((c1 = 0) & (c2 = 0))) -> 1 : (s1' = 7); + [time] (((s1 = 7) & (x1 < 3)) & ((c1 = 0) & (c2 = 0))) -> 1 : (x1' = (min((x1 + 1), 7))); + [] ((s1 = 7) & ((x1 = 3) | (x1 = 2))) -> 1 : (x1' = 0) & (s1' = 5); + [] ((s1 = 7) & ((c1 > 0) | (c2 > 0))) -> 1 : (x1' = 0) & (s1' = 6); + [time] ((s1 = 8) & (x1 < 1)) -> 1 : (x1' = (min((x1 + 1), 7))); + [send1] ((s1 = 8) & ((x1 = 1) | (x1 = 0))) -> 1 : (x1' = 0) & (s1' = 9); + [time] ((s1 = 9) & (x1 < 4)) -> 1 : (x1' = (min((x1 + 1), 7))); + [finish1] (((s1 = 9) & (x1 >= 4)) & (c1 = 1)) -> 1 : (x1' = 0) & (s1' = 10); + [finish1] (((s1 = 9) & (x1 >= 4)) & (c1 = 2)) -> 1 : (x1' = 0) & (s1' = 11); + [] ((((s1 = 10) & (c1 = 0)) & (x1 = 0)) & ((c1 > 0) | (c2 > 0))) -> 1 : (s1' = 2); + [time] ((((s1 = 10) & (c1 = 0)) & (x1 = 0)) & ((c1 = 0) & (c2 = 0))) -> 1 : (x1' = (min((x1 + 1), 7))); + [send1] (((s1 = 10) & (c1 = 0)) & ((x1 = 1) | ((x1 = 0) & ((c1 = 0) & (c2 = 0))))) -> 1 : (x1' = 0) & (s1' = 10); + [time] (((s1 = 10) & (c1 = 1)) & (x1 < 4)) -> 1 : (x1' = (min((x1 + 1), 7))); + [finish1] (((s1 = 10) & (c1 = 1)) & ((x1 = 4) | (x1 = 3))) -> 1 : (x1' = 0) & (s1' = 12) & (bc1' = 0); + [] (((s1 = 11) & (x1 = 0)) & ((c1 > 0) | (c2 > 0))) -> 1 : (s1' = 2); + [time] (((s1 = 11) & (x1 = 0)) & ((c1 = 0) & (c2 = 0))) -> 1 : (x1' = (min((x1 + 1), 7))); + [time] (((s1 = 11) & (x1 > 0)) & (x1 < 6)) -> 1 : (x1' = (min((x1 + 1), 7))); + [] ((s1 = 11) & (x1 = 6)) -> 1 : (x1' = 0) & (s1' = 3); + [time] (s1 = 12) -> 1 : (s1' = 12); +endmodule + +module station2 + x2: [0..((max(6, 4)) + 1)] init 0; + s2: [1..12] init 1; + slot2: [0..1] init 0; + backoff2: [0..15] init 0; + bc2: [0..1] init 0; + [time] (((s2 = 1) & (x2 < 3)) & ((c2 = 0) & (c1 = 0))) -> 1 : (x2' = (min((x2 + 1), 7))); + [] ((s2 = 1) & ((x2 = 3) | (x2 = 2))) -> 1 : (x2' = 0) & (s2' = 8); + [] ((s2 = 1) & ((c2 > 0) | (c1 > 0))) -> 1 : (x2' = 0) & (s2' = 2); + [time] ((s2 = 2) & ((c2 > 0) | (c1 > 0))) -> 1 : (s2' = 2); + [] ((s2 = 2) & ((c2 = 0) & (c1 = 0))) -> 1 : (s2' = 3); + [time] (((s2 = 3) & (x2 < 3)) & ((c2 = 0) & (c1 = 0))) -> 1 : (x2' = (min((x2 + 1), 7))); + [] ((s2 = 3) & ((c2 > 0) | (c1 > 0))) -> 1 : (x2' = 0) & (s2' = 2); + [] (((s2 = 3) & ((x2 = 3) | (x2 = 2))) & (bc2 = 0)) -> 1 : (x2' = 0) & (s2' = 4) & (slot2' = 0) & (bc2' = (min((bc2 + 1), 0))); + [] (s2 = 4) -> (1 / 16) : (s2' = 5) & (backoff2' = 0) + (1 / 16) : (s2' = 5) & (backoff2' = 1) + (1 / 16) : (s2' = 5) & (backoff2' = 2) + (1 / 16) : (s2' = 5) & (backoff2' = 3) + (1 / 16) : (s2' = 5) & (backoff2' = 4) + (1 / 16) : (s2' = 5) & (backoff2' = 5) + (1 / 16) : (s2' = 5) & (backoff2' = 6) + (1 / 16) : (s2' = 5) & (backoff2' = 7) + (1 / 16) : (s2' = 5) & (backoff2' = 8) + (1 / 16) : (s2' = 5) & (backoff2' = 9) + (1 / 16) : (s2' = 5) & (backoff2' = 10) + (1 / 16) : (s2' = 5) & (backoff2' = 11) + (1 / 16) : (s2' = 5) & (backoff2' = 12) + (1 / 16) : (s2' = 5) & (backoff2' = 13) + (1 / 16) : (s2' = 5) & (backoff2' = 14) + (1 / 16) : (s2' = 5) & (backoff2' = 15); + [time] (((s2 = 5) & (x2 < 1)) & ((c2 = 0) & (c1 = 0))) -> 1 : (x2' = (min((x2 + 1), 7))); + [] (((s2 = 5) & (x2 = 1)) & (backoff2 > 0)) -> 1 : (x2' = 0) & (s2' = 5) & (backoff2' = (backoff2 - 1)); + [] ((((s2 = 5) & (x2 = 1)) & (backoff2 = 0)) & (slot2 > 0)) -> 1 : (x2' = 0) & (s2' = 5) & (slot2' = (slot2 - 1)) & (backoff2' = 15); + [] ((((s2 = 5) & (x2 = 1)) & (backoff2 = 0)) & (slot2 = 0)) -> 1 : (x2' = 0) & (s2' = 8); + [] ((s2 = 5) & ((c2 > 0) | (c1 > 0))) -> 1 : (x2' = 0) & (s2' = 6); + [time] ((s2 = 6) & ((c2 > 0) | (c1 > 0))) -> 1 : (s2' = 6); + [] ((s2 = 6) & ((c2 = 0) & (c1 = 0))) -> 1 : (s2' = 7); + [time] (((s2 = 7) & (x2 < 3)) & ((c2 = 0) & (c1 = 0))) -> 1 : (x2' = (min((x2 + 1), 7))); + [] ((s2 = 7) & ((x2 = 3) | (x2 = 2))) -> 1 : (x2' = 0) & (s2' = 5); + [] ((s2 = 7) & ((c2 > 0) | (c1 > 0))) -> 1 : (x2' = 0) & (s2' = 6); + [time] ((s2 = 8) & (x2 < 1)) -> 1 : (x2' = (min((x2 + 1), 7))); + [send2] ((s2 = 8) & ((x2 = 1) | (x2 = 0))) -> 1 : (x2' = 0) & (s2' = 9); + [time] ((s2 = 9) & (x2 < 4)) -> 1 : (x2' = (min((x2 + 1), 7))); + [finish2] (((s2 = 9) & (x2 >= 4)) & (c2 = 1)) -> 1 : (x2' = 0) & (s2' = 10); + [finish2] (((s2 = 9) & (x2 >= 4)) & (c2 = 2)) -> 1 : (x2' = 0) & (s2' = 11); + [] ((((s2 = 10) & (c2 = 0)) & (x2 = 0)) & ((c2 > 0) | (c1 > 0))) -> 1 : (s2' = 2); + [time] ((((s2 = 10) & (c2 = 0)) & (x2 = 0)) & ((c2 = 0) & (c1 = 0))) -> 1 : (x2' = (min((x2 + 1), 7))); + [send2] (((s2 = 10) & (c2 = 0)) & ((x2 = 1) | ((x2 = 0) & ((c2 = 0) & (c1 = 0))))) -> 1 : (x2' = 0) & (s2' = 10); + [time] (((s2 = 10) & (c2 = 1)) & (x2 < 4)) -> 1 : (x2' = (min((x2 + 1), 7))); + [finish2] (((s2 = 10) & (c2 = 1)) & ((x2 = 4) | (x2 = 3))) -> 1 : (x2' = 0) & (s2' = 12) & (bc2' = 0); + [] (((s2 = 11) & (x2 = 0)) & ((c2 > 0) | (c1 > 0))) -> 1 : (s2' = 2); + [time] (((s2 = 11) & (x2 = 0)) & ((c2 = 0) & (c1 = 0))) -> 1 : (x2' = (min((x2 + 1), 7))); + [time] (((s2 = 11) & (x2 > 0)) & (x2 < 6)) -> 1 : (x2' = (min((x2 + 1), 7))); + [] ((s2 = 11) & (x2 = 6)) -> 1 : (x2' = 0) & (s2' = 3); + [time] (s2 = 12) -> 1 : (s2' = 12); +endmodule + +label "twoCollisions" = (col = 2); \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a3056d870..bd0f67e7f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,7 @@ +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + add_subdirectory(storm) add_subdirectory(storm-pgcl) add_subdirectory(storm-pgcl-cli) diff --git a/src/storm-dft-cli/storm-dyftee.cpp b/src/storm-dft-cli/storm-dyftee.cpp index 78e411df8..3ec3b0ac0 100644 --- a/src/storm-dft-cli/storm-dyftee.cpp +++ b/src/storm-dft-cli/storm-dyftee.cpp @@ -13,6 +13,7 @@ #include "storm/settings/modules/MinMaxEquationSolverSettings.h" #include "storm/settings/modules/NativeEquationSolverSettings.h" #include "storm/settings/modules/EliminationSettings.h" +#include "storm/settings/modules/ResourceSettings.h" #include "storm-dft/parser/DFTGalileoParser.h" #include "storm-dft/parser/DFTJsonParser.h" @@ -47,7 +48,7 @@ void analyzeDFT(std::string filename, std::string property, bool symred, bool al storm::parser::DFTGalileoParser parser; storm::storage::DFT dft = parser.parseDFT(filename); - std::vector> formulas = storm::parseFormulasForExplicit(property); + std::vector> formulas = storm::extractFormulasFromProperties(storm::parsePropertiesForExplicit(property)); STORM_LOG_ASSERT(formulas.size() == 1, "Wrong number of formulas."); storm::modelchecker::DFTModelChecker modelChecker; @@ -98,6 +99,7 @@ void initializeSettings() { //storm::settings::addModule(); //storm::settings::addModule(); storm::settings::addModule(); + storm::settings::addModule(); // For translation into JANI via GSPN. storm::settings::addModule(); @@ -164,7 +166,7 @@ int main(const int argc, const char** argv) { storm::expressions::Expression targetExpression = exprManager->integer(1) == topfailedVar.getExpressionVariable().getExpression(); auto evtlFormula = std::make_shared(targetExpression); - auto tbFormula = std::make_shared(std::make_shared(true), evtlFormula, 0.0, 10.0); + auto tbFormula = std::make_shared(std::make_shared(true), evtlFormula, storm::logic::TimeBound(false, exprManager->integer(0)), storm::logic::TimeBound(false, exprManager->integer(10)), storm::logic::TimeBoundType::Time); auto tbUntil = std::make_shared(tbFormula); auto evFormula = std::make_shared(evtlFormula, storm::logic::FormulaContext::Time); @@ -258,7 +260,9 @@ int main(const int argc, const char** argv) { return 0; } catch (storm::exceptions::BaseException const& exception) { STORM_LOG_ERROR("An exception caused StoRM-DyFTeE to terminate. The message of the exception is: " << exception.what()); + return 1; } catch (std::exception const& exception) { STORM_LOG_ERROR("An unexpected exception occurred and caused StoRM-DyFTeE to terminate. The message of this exception is: " << exception.what()); + return 2; } } diff --git a/src/storm-dft/modelchecker/dft/DFTModelChecker.cpp b/src/storm-dft/modelchecker/dft/DFTModelChecker.cpp index 2de46e599..8ca775432 100644 --- a/src/storm-dft/modelchecker/dft/DFTModelChecker.cpp +++ b/src/storm-dft/modelchecker/dft/DFTModelChecker.cpp @@ -20,13 +20,8 @@ namespace storm { template void DFTModelChecker::check(storm::storage::DFT const& origDft, std::shared_ptr const& formula, bool symred, bool allowModularisation, bool enableDC, double approximationError) { // Initialize - this->explorationTime = std::chrono::duration::zero(); - this->buildingTime = std::chrono::duration::zero(); - this->bisimulationTime = std::chrono::duration::zero(); - this->modelCheckingTime = std::chrono::duration::zero(); - this->totalTime = std::chrono::duration::zero(); this->approximationError = approximationError; - totalStart = std::chrono::high_resolution_clock::now(); + totalTimer.start(); // Optimizing DFT storm::storage::DFT dft = origDft.optimize(); @@ -44,7 +39,7 @@ namespace storm { checkResult = result->asExplicitQuantitativeCheckResult().getValueMap().begin()->second; } - this->totalTime = std::chrono::high_resolution_clock::now() - totalStart; + totalTimer.stop(); } template @@ -191,7 +186,7 @@ namespace storm { std::shared_ptr> composedModel; for (auto const ft : dfts) { STORM_LOG_INFO("Building Model via parallel composition..."); - std::chrono::high_resolution_clock::time_point checkingStart = std::chrono::high_resolution_clock::now(); + explorationTimer.start(); // Find symmetries std::map>> emptySymmetry; @@ -212,7 +207,7 @@ namespace storm { //model->printModelInformationToStream(std::cout); STORM_LOG_INFO("No. states (Explored): " << model->getNumberOfStates()); STORM_LOG_INFO("No. transitions (Explored): " << model->getNumberOfTransitions()); - explorationTime += std::chrono::high_resolution_clock::now() - checkingStart; + explorationTimer.stop(); STORM_LOG_THROW(model->isOfType(storm::models::ModelType::Ctmc), storm::exceptions::NotSupportedException, "Parallel composition only applicable for CTMCs"); std::shared_ptr> ctmc = model->template as>(); @@ -227,10 +222,10 @@ namespace storm { } // Apply bisimulation - std::chrono::high_resolution_clock::time_point bisimulationStart = std::chrono::high_resolution_clock::now(); + bisimulationTimer.start(); composedModel = storm::performDeterministicSparseBisimulationMinimization>(composedModel, {formula}, storm::storage::BisimulationType::Weak)->template as>(); std::chrono::high_resolution_clock::time_point bisimulationEnd = std::chrono::high_resolution_clock::now(); - bisimulationTime += bisimulationEnd - bisimulationStart; + bisimulationTimer.stop(); STORM_LOG_INFO("No. states (Composed): " << composedModel->getNumberOfStates()); STORM_LOG_INFO("No. transitions (Composed): " << composedModel->getNumberOfTransitions()); @@ -247,7 +242,7 @@ namespace storm { // If we are here, no composition was possible STORM_LOG_ASSERT(!modularisationPossible, "Modularisation should not be possible."); - std::chrono::high_resolution_clock::time_point checkingStart = std::chrono::high_resolution_clock::now(); + explorationTimer.start(); // Find symmetries std::map>> emptySymmetry; storm::storage::DFTIndependentSymmetries symmetries(emptySymmetry); @@ -268,7 +263,7 @@ namespace storm { //model->printModelInformationToStream(std::cout); STORM_LOG_INFO("No. states (Explored): " << model->getNumberOfStates()); STORM_LOG_INFO("No. transitions (Explored): " << model->getNumberOfTransitions()); - explorationTime += std::chrono::high_resolution_clock::now() - checkingStart; + explorationTimer.stop(); STORM_LOG_THROW(model->isOfType(storm::models::ModelType::Ctmc), storm::exceptions::NotSupportedException, "Parallel composition only applicable for CTMCs"); return model->template as>(); @@ -276,7 +271,7 @@ namespace storm { template typename DFTModelChecker::dft_result DFTModelChecker::checkDFT(storm::storage::DFT const& dft, std::shared_ptr const& formula, bool symred, bool enableDC, double approximationError) { - std::chrono::high_resolution_clock::time_point checkingStart = std::chrono::high_resolution_clock::now(); + explorationTimer.start(); // Find symmetries std::map>> emptySymmetry; @@ -302,12 +297,14 @@ namespace storm { size_t iteration = 0; do { // Iteratively build finer models - std::chrono::high_resolution_clock::time_point explorationStart = std::chrono::high_resolution_clock::now(); + if (iteration > 0) { + explorationTimer.start(); + } STORM_LOG_INFO("Building model..."); // TODO Matthias refine model using existing model and MC results builder.buildModel(labeloptions, iteration, approximationError); - std::chrono::high_resolution_clock::time_point explorationEnd = std::chrono::high_resolution_clock::now(); - explorationTime += explorationEnd - explorationStart; + explorationTimer.stop(); + buildingTimer.start(); // TODO Matthias: possible to do bisimulation on approximated model and not on concrete one? @@ -317,7 +314,7 @@ namespace storm { // We only output the info from the lower bound as the info for the upper bound is the same STORM_LOG_INFO("No. states: " << model->getNumberOfStates()); STORM_LOG_INFO("No. transitions: " << model->getNumberOfTransitions()); - buildingTime += std::chrono::high_resolution_clock::now() - explorationEnd; + buildingTimer.stop(); // Check lower bound std::unique_ptr result = checkModel(model, formula); @@ -328,9 +325,9 @@ namespace storm { // Build model for upper bound STORM_LOG_INFO("Getting model for upper bound..."); - explorationEnd = std::chrono::high_resolution_clock::now(); + buildingTimer.start(); model = builder.getModelApproximation(probabilityFormula ? true : false); - buildingTime += std::chrono::high_resolution_clock::now() - explorationEnd; + buildingTimer.stop(); // Check upper bound result = checkModel(model, formula); result->filter(storm::modelchecker::ExplicitQualitativeCheckResult(model->getInitialStates())); @@ -340,8 +337,9 @@ namespace storm { ++iteration; STORM_LOG_INFO("Result after iteration " << iteration << ": (" << std::setprecision(10) << approxResult.first << ", " << approxResult.second << ")"); - totalTime = std::chrono::high_resolution_clock::now() - totalStart; + totalTimer.stop(); printTimings(); + totalTimer.start(); STORM_LOG_THROW(!storm::utility::isInfinity(approxResult.first) && !storm::utility::isInfinity(approxResult.second), storm::exceptions::NotSupportedException, "Approximation does not work if result might be infinity."); } while (!isApproximationSufficient(approxResult.first, approxResult.second, approximationError, probabilityFormula)); @@ -365,7 +363,7 @@ namespace storm { //model->printModelInformationToStream(std::cout); STORM_LOG_INFO("No. states (Explored): " << model->getNumberOfStates()); STORM_LOG_INFO("No. transitions (Explored): " << model->getNumberOfTransitions()); - explorationTime += std::chrono::high_resolution_clock::now() - checkingStart; + explorationTimer.stop(); // Model checking std::unique_ptr result = checkModel(model, formula); @@ -377,22 +375,22 @@ namespace storm { template std::unique_ptr DFTModelChecker::checkModel(std::shared_ptr>& model, std::shared_ptr const& formula) { // Bisimulation - std::chrono::high_resolution_clock::time_point bisimulationStart = std::chrono::high_resolution_clock::now(); + bisimulationTimer.start(); if (model->isOfType(storm::models::ModelType::Ctmc) && storm::settings::getModule().isBisimulationSet()) { STORM_LOG_INFO("Bisimulation..."); model = storm::performDeterministicSparseBisimulationMinimization>(model->template as>(), {formula}, storm::storage::BisimulationType::Weak)->template as>(); STORM_LOG_INFO("No. states (Bisimulation): " << model->getNumberOfStates()); STORM_LOG_INFO("No. transitions (Bisimulation): " << model->getNumberOfTransitions()); } - std::chrono::high_resolution_clock::time_point bisimulationEnd = std::chrono::high_resolution_clock::now(); - bisimulationTime += bisimulationEnd - bisimulationStart; + bisimulationTimer.stop(); + modelCheckingTimer.start(); // Check the model STORM_LOG_INFO("Model checking..."); std::unique_ptr result(storm::verifySparseModel(model, formula)); STORM_LOG_INFO("Model checking done."); STORM_LOG_ASSERT(result, "Result does not exist."); - modelCheckingTime += std::chrono::high_resolution_clock::now() - bisimulationEnd; + modelCheckingTimer.stop(); return result; } @@ -414,11 +412,11 @@ namespace storm { template void DFTModelChecker::printTimings(std::ostream& os) { os << "Times:" << std::endl; - os << "Exploration:\t" << explorationTime.count() << std::endl; - os << "Building:\t" << buildingTime.count() << std::endl; - os << "Bisimulation:\t" << bisimulationTime.count() << std::endl; - os << "Modelchecking:\t" << modelCheckingTime.count() << std::endl; - os << "Total:\t\t" << totalTime.count() << std::endl; + os << "Exploration:\t" << explorationTimer.getTimeInSeconds() << "s" << std::endl; + os << "Building:\t" << buildingTimer.getTimeInSeconds() << "s" << std::endl; + os << "Bisimulation:\t" << bisimulationTimer.getTimeInSeconds() << "s" << std::endl; + os << "Modelchecking:\t" << modelCheckingTimer.getTimeInSeconds() << "s" << std::endl; + os << "Total:\t\t" << totalTimer.getTimeInSeconds() << "s" << std::endl; } template diff --git a/src/storm-dft/modelchecker/dft/DFTModelChecker.h b/src/storm-dft/modelchecker/dft/DFTModelChecker.h index 7cee7b0e4..c714999a8 100644 --- a/src/storm-dft/modelchecker/dft/DFTModelChecker.h +++ b/src/storm-dft/modelchecker/dft/DFTModelChecker.h @@ -3,11 +3,10 @@ #include "storm/logic/Formula.h" #include "storm/modelchecker/results/CheckResult.h" #include "storm/utility/storm.h" // TODO this should not be included here. +#include "storm/utility/Stopwatch.h" #include "storm-dft/storage/dft/DFT.h" -#include - namespace storm { namespace modelchecker { @@ -57,12 +56,11 @@ namespace storm { private: // Timing values - std::chrono::duration buildingTime = std::chrono::duration::zero(); - std::chrono::duration explorationTime = std::chrono::duration::zero(); - std::chrono::duration bisimulationTime = std::chrono::duration::zero(); - std::chrono::duration modelCheckingTime = std::chrono::duration::zero(); - std::chrono::duration totalTime = std::chrono::duration::zero(); - std::chrono::high_resolution_clock::time_point totalStart; + storm::utility::Stopwatch buildingTimer; + storm::utility::Stopwatch explorationTimer; + storm::utility::Stopwatch bisimulationTimer; + storm::utility::Stopwatch modelCheckingTimer; + storm::utility::Stopwatch totalTimer; // Model checking result dft_result checkResult; @@ -137,4 +135,4 @@ namespace storm { }; } -} \ No newline at end of file +} diff --git a/src/storm-dft/settings/modules/DFTSettings.cpp b/src/storm-dft/settings/modules/DFTSettings.cpp index 6af1d9678..8b62833a1 100644 --- a/src/storm-dft/settings/modules/DFTSettings.cpp +++ b/src/storm-dft/settings/modules/DFTSettings.cpp @@ -8,6 +8,7 @@ #include "storm/settings/Argument.h" #include "storm/exceptions/InvalidSettingsException.h" +#include "storm/exceptions/IllegalArgumentValueException.h" namespace storm { namespace settings { @@ -39,17 +40,17 @@ namespace storm { DFTSettings::DFTSettings() : ModuleSettings(moduleName) { this->addOption(storm::settings::OptionBuilder(moduleName, dftFileOptionName, false, "Parses the model given in the Galileo format.").setShortName(dftFileOptionShortName) - .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the file from which to read the DFT model.").addValidationFunctionString(storm::settings::ArgumentValidators::existingReadableFileValidator()).build()).build()); + .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the file from which to read the DFT model.").addValidatorString(ArgumentValidatorFactory::createExistingFileValidator()).build()).build()); this->addOption(storm::settings::OptionBuilder(moduleName, dftJsonFileOptionName, false, "Parses the model given in the Cytoscape JSON format.").setShortName(dftJsonFileOptionShortName) - .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the JSON file from which to read the DFT model.").addValidationFunctionString(storm::settings::ArgumentValidators::existingReadableFileValidator()).build()).build()); + .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the JSON file from which to read the DFT model.").addValidatorString(ArgumentValidatorFactory::createExistingFileValidator()).build()).build()); this->addOption(storm::settings::OptionBuilder(moduleName, symmetryReductionOptionName, false, "Exploit symmetric structure of model.").setShortName(symmetryReductionOptionShortName).build()); this->addOption(storm::settings::OptionBuilder(moduleName, modularisationOptionName, false, "Use modularisation (not applicable for expected time).").build()); this->addOption(storm::settings::OptionBuilder(moduleName, disableDCOptionName, false, "Disable Dont Care propagation.").build()); - this->addOption(storm::settings::OptionBuilder(moduleName, approximationErrorOptionName, false, "Approximation error allowed.").setShortName(approximationErrorOptionShortName).addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("error", "The relative approximation error to use.").addValidationFunctionDouble(storm::settings::ArgumentValidators::doubleGreaterValidatorIncluding(0.0)).build()).build()); - this->addOption(storm::settings::OptionBuilder(moduleName, approximationHeuristicOptionName, false, "Set the heuristic used for approximation.").addArgument(storm::settings::ArgumentBuilder::createStringArgument("heuristic", "Sets which heuristic is used for approximation. Must be in {depth, probability}. Default is").setDefaultValueString("depth").addValidationFunctionString(storm::settings::ArgumentValidators::stringInListValidator({"depth", "rateratio"})).build()).build()); + this->addOption(storm::settings::OptionBuilder(moduleName, approximationErrorOptionName, false, "Approximation error allowed.").setShortName(approximationErrorOptionShortName).addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("error", "The relative approximation error to use.").addValidatorDouble(ArgumentValidatorFactory::createDoubleGreaterEqualValidator(0.0)).build()).build()); + this->addOption(storm::settings::OptionBuilder(moduleName, approximationHeuristicOptionName, false, "Set the heuristic used for approximation.").addArgument(storm::settings::ArgumentBuilder::createStringArgument("heuristic", "Sets which heuristic is used for approximation. Must be in {depth, probability}. Default is").setDefaultValueString("depth").addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator({"depth", "rateratio"})).build()).build()); this->addOption(storm::settings::OptionBuilder(moduleName, propExpectedTimeOptionName, false, "Compute expected time of system failure.").setShortName(propExpectedTimeOptionShortName).build()); this->addOption(storm::settings::OptionBuilder(moduleName, propProbabilityOptionName, false, "Compute probability of system failure.").build()); - this->addOption(storm::settings::OptionBuilder(moduleName, propTimeBoundOptionName, false, "Compute probability of system failure up to given timebound.").addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("time", "The timebound to use.").addValidationFunctionDouble(storm::settings::ArgumentValidators::doubleGreaterValidatorExcluding(0.0)).build()).build()); + this->addOption(storm::settings::OptionBuilder(moduleName, propTimeBoundOptionName, false, "Compute probability of system failure up to given timebound.").addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("time", "The timebound to use.").addValidatorDouble(ArgumentValidatorFactory::createDoubleGreaterValidator(0.0)).build()).build()); this->addOption(storm::settings::OptionBuilder(moduleName, minValueOptionName, false, "Compute minimal value in case of non-determinism.").build()); this->addOption(storm::settings::OptionBuilder(moduleName, maxValueOptionName, false, "Compute maximal value in case of non-determinism.").build()); #ifdef STORM_HAVE_Z3 diff --git a/src/storm-dft/storage/dft/DFT.h b/src/storm-dft/storage/dft/DFT.h index 4c904ec5c..1304bbfa9 100644 --- a/src/storm-dft/storage/dft/DFT.h +++ b/src/storm-dft/storage/dft/DFT.h @@ -270,10 +270,6 @@ namespace storm { } DFTLayoutInfo const& getElementLayoutInfo(size_t id) const { - if(mLayoutInfo.count(id) == 0) { - STORM_LOG_WARN("Layout info for element with id " << id << " not found"); - return DFTLayoutInfo(); - } return mLayoutInfo.at(id); } diff --git a/src/storm-dft/storage/dft/DFTBuilder.cpp b/src/storm-dft/storage/dft/DFTBuilder.cpp index 70df810cf..974ffac8a 100644 --- a/src/storm-dft/storage/dft/DFTBuilder.cpp +++ b/src/storm-dft/storage/dft/DFTBuilder.cpp @@ -97,6 +97,9 @@ namespace storm { for (auto& elem : mElements) { if(mLayoutInfo.count(elem.first) > 0) { dft.setElementLayoutInfo(elem.second->id(), mLayoutInfo.at(elem.first)); + } else { + // Set default layout + dft.setElementLayoutInfo(elem.second->id(), storm::storage::DFTLayoutInfo()); } } diff --git a/src/storm-dft/storage/dft/DFTLayoutInfo.h b/src/storm-dft/storage/dft/DFTLayoutInfo.h index c61de0f6d..6312835dc 100644 --- a/src/storm-dft/storage/dft/DFTLayoutInfo.h +++ b/src/storm-dft/storage/dft/DFTLayoutInfo.h @@ -3,13 +3,14 @@ namespace storm { namespace storage { struct DFTLayoutInfo { - DFTLayoutInfo() {}; + DFTLayoutInfo() : x(20.0), y(20.0) { + }; DFTLayoutInfo(double x, double y) : x(x), y(y) {}; // x location - double x = 0.0; + double x; // y location - double y = 0.0; + double y; }; } } diff --git a/src/storm-gspn-cli/storm-gspn.cpp b/src/storm-gspn-cli/storm-gspn.cpp index 17b45222d..fdf2594fc 100644 --- a/src/storm-gspn-cli/storm-gspn.cpp +++ b/src/storm-gspn-cli/storm-gspn.cpp @@ -3,6 +3,7 @@ #include "storm-gspn/storage/gspn/GSPN.h" #include "storm-gspn/storage/gspn/GspnBuilder.h" #include "storm-gspn/builder/JaniGSPNBuilder.h" +#include "storm-gspn/storm-gspn.h" #include "storm/exceptions/BaseException.h" #include "storm/exceptions/WrongFormatException.h" @@ -30,6 +31,7 @@ #include "storm/settings/modules/CoreSettings.h" #include "storm/settings/modules/DebugSettings.h" #include "storm/settings/modules/JaniExportSettings.h" +#include "storm/settings/modules/ResourceSettings.h" /*! * Initialize the settings manager. @@ -44,6 +46,7 @@ void initializeSettings() { storm::settings::addModule(); storm::settings::addModule(); storm::settings::addModule(); + storm::settings::addModule(); } @@ -65,11 +68,6 @@ std::unordered_map parseCapacitiesList(std::string const& } -void handleJani(storm::gspn::GSPN const& gspn) { - - storm::jani::JsonExporter::toFile(*model, {}, storm::settings::getModule().getJaniFilename()); - delete model; -} int main(const int argc, const char **argv) { try { @@ -98,19 +96,16 @@ int main(const int argc, const char **argv) { auto capacities = parseCapacitiesList(storm::settings::getModule().getCapacitiesFilename()); gspn->setCapacities(capacities); } - - - if(storm::settings::getModule().isWriteToDotSet()) { - std::ofstream file; - file.open(storm::settings::getModule().getWriteToDotFilename()); - gspn->writeDotToStream(file); - } + + storm::handleGSPNExportSettings(*gspn); if(storm::settings::getModule().isJaniFileSet()) { - handleJani(*gspn); + storm::jani::Model* model = storm::buildJani(*gspn); + storm::exportJaniModel(*model, {}, storm::settings::getModule().getJaniFilename()); + delete model; } - - + + delete gspn; return 0; // @@ -142,7 +137,9 @@ int main(const int argc, const char **argv) { return 0; } catch (storm::exceptions::BaseException const& exception) { STORM_LOG_ERROR("An exception caused StoRM to terminate. The message of the exception is: " << exception.what()); + return 1; } catch (std::exception const& exception) { STORM_LOG_ERROR("An unexpected exception occurred and caused StoRM to terminate. The message of this exception is: " << exception.what()); + return 2; } } diff --git a/src/storm-gspn/adapters/XercesAdapter.h b/src/storm-gspn/adapters/XercesAdapter.h index d6fc4ea65..0a39c8f2e 100644 --- a/src/storm-gspn/adapters/XercesAdapter.h +++ b/src/storm-gspn/adapters/XercesAdapter.h @@ -1,7 +1,7 @@ #pragma once #include "storm-config.h" -#ifdef USE_XERCES +#ifdef STORM_HAVE_XERCES #include #include diff --git a/src/storm-gspn/builder/JaniGSPNBuilder.cpp b/src/storm-gspn/builder/JaniGSPNBuilder.cpp index 061e9bd67..386d2b0a2 100644 --- a/src/storm-gspn/builder/JaniGSPNBuilder.cpp +++ b/src/storm-gspn/builder/JaniGSPNBuilder.cpp @@ -1 +1,150 @@ #include "JaniGSPNBuilder.h" + +namespace storm { + namespace builder { + + storm::jani::Model* JaniGSPNBuilder::build(std::string const& automatonName) { + storm::jani::Model* model = new storm::jani::Model(gspn.getName(), storm::jani::ModelType::MA, janiVersion, expressionManager); + storm::jani::Automaton mainAutomaton(automatonName, expressionManager->declareIntegerVariable("loc")); + addVariables(model); + uint64_t locId = addLocation(mainAutomaton); + addEdges(mainAutomaton, locId); + model->addAutomaton(mainAutomaton); + model->setStandardSystemComposition(); + return model; + } + + void JaniGSPNBuilder::addVariables(storm::jani::Model* model) { + for (auto const& place : gspn.getPlaces()) { + storm::jani::Variable* janiVar = nullptr; + if (!place.hasRestrictedCapacity()) { + // Effectively no capacity limit known + janiVar = new storm::jani::UnboundedIntegerVariable(place.getName(), expressionManager->declareIntegerVariable(place.getName()), expressionManager->integer(place.getNumberOfInitialTokens())); + } else { + assert(place.hasRestrictedCapacity()); + janiVar = new storm::jani::BoundedIntegerVariable(place.getName(), expressionManager->declareIntegerVariable(place.getName()), expressionManager->integer(place.getNumberOfInitialTokens()), expressionManager->integer(0), expressionManager->integer(place.getCapacity())); + } + assert(janiVar != nullptr); + assert(vars.count(place.getID()) == 0); + vars[place.getID()] = &model->addVariable(*janiVar); + delete janiVar; + } + } + + uint64_t JaniGSPNBuilder::addLocation(storm::jani::Automaton& automaton) { + uint64_t janiLoc = automaton.addLocation(storm::jani::Location("loc")); + automaton.addInitialLocation("loc"); + return janiLoc; + } + + void JaniGSPNBuilder::addEdges(storm::jani::Automaton& automaton, uint64_t locId) { + + uint64_t lastPriority = -1; + storm::expressions::Expression lastPriorityGuard = expressionManager->boolean(false); + storm::expressions::Expression priorityGuard = expressionManager->boolean(true); + + for (auto const& partition : gspn.getPartitions()) { + storm::expressions::Expression guard = expressionManager->boolean(false); + + assert(lastPriority >= partition.priority); + if (lastPriority > partition.priority) { + priorityGuard = priorityGuard && !lastPriorityGuard; + lastPriority = partition.priority; + } else { + assert(lastPriority == partition.priority); + } + + // Compute enabled weight expression. + storm::expressions::Expression totalWeight = expressionManager->rational(0.0); + for (auto const& transId : partition.transitions) { + auto const& trans = gspn.getImmediateTransitions()[transId]; + if (trans.noWeightAttached()) { + continue; + } + storm::expressions::Expression destguard = expressionManager->boolean(true); + for (auto const& inPlaceEntry : trans.getInputPlaces()) { + destguard = destguard && (vars[inPlaceEntry.first]->getExpressionVariable() >= inPlaceEntry.second); + } + for (auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) { + destguard = destguard && (vars[inhibPlaceEntry.first]->getExpressionVariable() < inhibPlaceEntry.second); + } + totalWeight = totalWeight + storm::expressions::ite(destguard, expressionManager->rational(trans.getWeight()), expressionManager->rational(0.0)); + + } + totalWeight = totalWeight.simplify(); + + + std::vector oas; + std::vector probabilities; + std::vector destinationLocations; + for (auto const& transId : partition.transitions) { + auto const& trans = gspn.getImmediateTransitions()[transId]; + if (trans.noWeightAttached()) { + std::cout << "ERROR -- no weights attached at transition" << std::endl; + continue; + } + storm::expressions::Expression destguard = expressionManager->boolean(true); + std::vector assignments; + for (auto const& inPlaceEntry : trans.getInputPlaces()) { + destguard = destguard && (vars[inPlaceEntry.first]->getExpressionVariable() >= inPlaceEntry.second); + if (trans.getOutputPlaces().count(inPlaceEntry.first) == 0) { + assignments.emplace_back( *vars[inPlaceEntry.first], (vars[inPlaceEntry.first])->getExpressionVariable() - inPlaceEntry.second); + } + } + for (auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) { + destguard = destguard && (vars[inhibPlaceEntry.first]->getExpressionVariable() < inhibPlaceEntry.second); + } + for (auto const& outputPlaceEntry : trans.getOutputPlaces()) { + if (trans.getInputPlaces().count(outputPlaceEntry.first) == 0) { + assignments.emplace_back( *vars[outputPlaceEntry.first], (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second ); + } else { + assignments.emplace_back( *vars[outputPlaceEntry.first], (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second - trans.getInputPlaces().at(outputPlaceEntry.first)); + } + } + destguard = destguard.simplify(); + guard = guard || destguard; + + oas.emplace_back(assignments); + destinationLocations.emplace_back(locId); + probabilities.emplace_back(storm::expressions::ite(destguard, (expressionManager->rational(trans.getWeight()) / totalWeight), expressionManager->rational(0.0))); + } + + std::shared_ptr templateEdge = automaton.createTemplateEdge((priorityGuard && guard).simplify()); + for (auto const& oa : oas) { + templateEdge->addDestination(storm::jani::TemplateEdgeDestination(oa)); + } + storm::jani::Edge e(locId, storm::jani::Model::SILENT_ACTION_INDEX, boost::none, templateEdge, destinationLocations, probabilities); + automaton.addEdge(e); + lastPriorityGuard = lastPriorityGuard || guard; + + } + for (auto const& trans : gspn.getTimedTransitions()) { + storm::expressions::Expression guard = expressionManager->boolean(true); + + std::vector assignments; + for (auto const& inPlaceEntry : trans.getInputPlaces()) { + guard = guard && (vars[inPlaceEntry.first]->getExpressionVariable() >= inPlaceEntry.second); + if (trans.getOutputPlaces().count(inPlaceEntry.first) == 0) { + assignments.emplace_back( *vars[inPlaceEntry.first], (vars[inPlaceEntry.first])->getExpressionVariable() - inPlaceEntry.second); + } + } + for (auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) { + guard = guard && (vars[inhibPlaceEntry.first]->getExpressionVariable() < inhibPlaceEntry.second); + } + for (auto const& outputPlaceEntry : trans.getOutputPlaces()) { + if (trans.getInputPlaces().count(outputPlaceEntry.first) == 0) { + assignments.emplace_back( *vars[outputPlaceEntry.first], (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second ); + } else { + assignments.emplace_back( *vars[outputPlaceEntry.first], (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second - trans.getInputPlaces().at(outputPlaceEntry.first)); + } + } + + std::shared_ptr templateEdge = automaton.createTemplateEdge(guard); + templateEdge->addDestination(assignments); + storm::jani::Edge e(locId, storm::jani::Model::SILENT_ACTION_INDEX, expressionManager->rational(trans.getRate()), templateEdge, {locId}, {expressionManager->integer(1)}); + automaton.addEdge(e); + + } + } + } +} \ No newline at end of file diff --git a/src/storm-gspn/builder/JaniGSPNBuilder.h b/src/storm-gspn/builder/JaniGSPNBuilder.h index 196d29562..791989009 100644 --- a/src/storm-gspn/builder/JaniGSPNBuilder.h +++ b/src/storm-gspn/builder/JaniGSPNBuilder.h @@ -8,156 +8,32 @@ namespace storm { namespace builder { class JaniGSPNBuilder { public: - JaniGSPNBuilder(storm::gspn::GSPN const& gspn, std::shared_ptr const& expManager) : gspn(gspn), expressionManager(expManager) { + JaniGSPNBuilder(storm::gspn::GSPN const& gspn, std::shared_ptr const& expManager) + : gspn(gspn), expressionManager(expManager) { } virtual ~JaniGSPNBuilder() { - + // Intentionally left empty. } - storm::jani::Model* build() { - storm::jani::Model* model = new storm::jani::Model(gspn.getName(), storm::jani::ModelType::MA, janiVersion, expressionManager); - storm::jani::Automaton mainAutomaton("immediate"); - addVariables(model); - uint64_t locId = addLocation(mainAutomaton); - addEdges(mainAutomaton, locId); - model->addAutomaton(mainAutomaton); - model->setStandardSystemComposition(); - return model; - } + storm::jani::Model* build(std::string const& automatonName = "gspn_automaton"); storm::jani::Variable const& getPlaceVariable(uint64_t placeId) { return *vars.at(placeId); } - - void addVariables(storm::jani::Model* model) { - for (auto const& place : gspn.getPlaces()) { - storm::jani::Variable* janiVar = nullptr; - if (!place.hasRestrictedCapacity()) { - // Effectively no capacity limit known - janiVar = new storm::jani::UnboundedIntegerVariable(place.getName(), expressionManager->declareIntegerVariable(place.getName()), expressionManager->integer(place.getNumberOfInitialTokens())); - } else { - assert(place.hasRestrictedCapacity()); - janiVar = new storm::jani::BoundedIntegerVariable(place.getName(), expressionManager->declareIntegerVariable(place.getName()), expressionManager->integer(place.getNumberOfInitialTokens()), expressionManager->integer(0), expressionManager->integer(place.getCapacity())); - } - assert(janiVar != nullptr); - assert(vars.count(place.getID()) == 0); - vars[place.getID()] = &model->addVariable(*janiVar); - delete janiVar; - } - } - - uint64_t addLocation(storm::jani::Automaton& automaton) { - uint64_t janiLoc = automaton.addLocation(storm::jani::Location("loc")); - automaton.addInitialLocation("loc"); - return janiLoc; - } - - void addEdges(storm::jani::Automaton& automaton, uint64_t locId) { - - uint64_t lastPriority = -1; - storm::expressions::Expression lastPriorityGuard = expressionManager->boolean(false); - storm::expressions::Expression priorityGuard = expressionManager->boolean(true); - // TODO here there is something to fix if we add transition partitions. - - for (auto const& partition : gspn.getPartitions()) { - storm::expressions::Expression guard = expressionManager->boolean(false); - std::vector weightedDestinations; - - assert(lastPriority >= partition.priority); - if (lastPriority > partition.priority) { - priorityGuard = priorityGuard && !lastPriorityGuard; - lastPriority = partition.priority; - } else { - assert(lastPriority == partition.priority); - } - - // Compute enabled weight expression. - storm::expressions::Expression totalWeight = expressionManager->rational(0.0); - for (auto const& transId : partition.transitions) { - auto const& trans = gspn.getImmediateTransitions()[transId]; - if (trans.noWeightAttached()) { - continue; - } - storm::expressions::Expression destguard = expressionManager->boolean(true); - for (auto const& inPlaceEntry : trans.getInputPlaces()) { - destguard = destguard && (vars[inPlaceEntry.first]->getExpressionVariable() >= inPlaceEntry.second); - } - for (auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) { - destguard = destguard && (vars[inhibPlaceEntry.first]->getExpressionVariable() < inhibPlaceEntry.second); - } - totalWeight = totalWeight + storm::expressions::ite(destguard, expressionManager->rational(trans.getWeight()), expressionManager->rational(0.0)); - - } - totalWeight = totalWeight.simplify(); - - - for (auto const& transId : partition.transitions) { - auto const& trans = gspn.getImmediateTransitions()[transId]; - if (trans.noWeightAttached()) { - std::cout << "ERROR -- no weights attached at transition" << std::endl; - continue; - } - storm::expressions::Expression destguard = expressionManager->boolean(true); - std::vector assignments; - for (auto const& inPlaceEntry : trans.getInputPlaces()) { - destguard = destguard && (vars[inPlaceEntry.first]->getExpressionVariable() >= inPlaceEntry.second); - if (trans.getOutputPlaces().count(inPlaceEntry.first) == 0) { - assignments.emplace_back( *vars[inPlaceEntry.first], (vars[inPlaceEntry.first])->getExpressionVariable() - inPlaceEntry.second); - } - } - for (auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) { - destguard = destguard && (vars[inhibPlaceEntry.first]->getExpressionVariable() < inhibPlaceEntry.second); - } - for (auto const& outputPlaceEntry : trans.getOutputPlaces()) { - if (trans.getInputPlaces().count(outputPlaceEntry.first) == 0) { - assignments.emplace_back( *vars[outputPlaceEntry.first], (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second ); - } else { - assignments.emplace_back( *vars[outputPlaceEntry.first], (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second - trans.getInputPlaces().at(outputPlaceEntry.first)); - } - } - destguard = destguard.simplify(); - guard = guard || destguard; - storm::jani::OrderedAssignments oa(assignments); - storm::jani::EdgeDestination dest(locId, storm::expressions::ite(destguard, (expressionManager->rational(trans.getWeight()) / totalWeight), expressionManager->rational(0.0)), oa); - weightedDestinations.push_back(dest); - } - storm::jani::Edge e(locId, storm::jani::Model::SILENT_ACTION_INDEX, boost::none, (priorityGuard && guard).simplify(), weightedDestinations); - automaton.addEdge(e); - lastPriorityGuard = lastPriorityGuard || guard; - - } - for (auto const& trans : gspn.getTimedTransitions()) { - storm::expressions::Expression guard = expressionManager->boolean(true); - - std::vector assignments; - for (auto const& inPlaceEntry : trans.getInputPlaces()) { - guard = guard && (vars[inPlaceEntry.first]->getExpressionVariable() >= inPlaceEntry.second); - if (trans.getOutputPlaces().count(inPlaceEntry.first) == 0) { - assignments.emplace_back( *vars[inPlaceEntry.first], (vars[inPlaceEntry.first])->getExpressionVariable() - inPlaceEntry.second); - } - } - for (auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) { - guard = guard && (vars[inhibPlaceEntry.first]->getExpressionVariable() < inhibPlaceEntry.second); - } - for (auto const& outputPlaceEntry : trans.getOutputPlaces()) { - if (trans.getInputPlaces().count(outputPlaceEntry.first) == 0) { - assignments.emplace_back( *vars[outputPlaceEntry.first], (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second ); - } else { - assignments.emplace_back( *vars[outputPlaceEntry.first], (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second - trans.getInputPlaces().at(outputPlaceEntry.first)); - } - } - storm::jani::OrderedAssignments oa(assignments); - storm::jani::EdgeDestination dest(locId, expressionManager->integer(1), oa); - storm::jani::Edge e(locId, storm::jani::Model::SILENT_ACTION_INDEX, expressionManager->rational(trans.getRate()), guard, {dest}); - automaton.addEdge(e); - - } - } + private: + + + void addVariables(storm::jani::Model* model); + + uint64_t addLocation(storm::jani::Automaton& automaton); + + void addEdges(storm::jani::Automaton& automaton, uint64_t locId); + const uint64_t janiVersion = 1; storm::gspn::GSPN const& gspn; std::map vars; diff --git a/src/storm-gspn/parser/GreatSpnEditorProjectParser.cpp b/src/storm-gspn/parser/GreatSpnEditorProjectParser.cpp index ce19a50a9..826124f25 100644 --- a/src/storm-gspn/parser/GreatSpnEditorProjectParser.cpp +++ b/src/storm-gspn/parser/GreatSpnEditorProjectParser.cpp @@ -1,9 +1,9 @@ #include "GreatSpnEditorProjectParser.h" -#ifdef USE_XERCES +#ifdef STORM_HAVE_XERCES #include -#include "storm/adapters/XercesAdapter.h" +#include "storm-gspn/adapters/XercesAdapter.h" #include "storm/exceptions/UnexpectedException.h" #include "storm/exceptions/WrongFormatException.h" @@ -13,8 +13,8 @@ namespace storm { namespace parser { storm::gspn::GSPN* GreatSpnEditorProjectParser::parse(xercesc::DOMElement const* elementRoot) { if (storm::adapters::XMLtoString(elementRoot->getTagName()) == "project") { - GreatSpnEditorProjectParser p; - return p.parse(elementRoot); + traverseProjectElement(elementRoot); + return builder.buildGspn(); } else { // If the top-level node is not a "pnml" or "" node, then throw an exception. STORM_LOG_THROW(false, storm::exceptions::UnexpectedException, "Failed to identify the root element.\n"); @@ -311,11 +311,11 @@ namespace storm { if (kind.compare("INPUT") == 0) { - builder.addInputArc(head, tail, mult); + builder.addInputArc(tail, head, mult); } else if (kind.compare("INHIBITOR") == 0) { - builder.addInhibitionArc(head, tail, mult); + builder.addInhibitionArc(tail, head, mult); } else if (kind.compare("OUTPUT") == 0) { - builder.addOutputArc(head, tail, mult); + builder.addOutputArc(tail, head, mult); } else { // TODO error! } diff --git a/src/storm-gspn/parser/GreatSpnEditorProjectParser.h b/src/storm-gspn/parser/GreatSpnEditorProjectParser.h index f594aa993..7c0f5e713 100644 --- a/src/storm-gspn/parser/GreatSpnEditorProjectParser.h +++ b/src/storm-gspn/parser/GreatSpnEditorProjectParser.h @@ -1,15 +1,15 @@ #pragma once #include "storm-config.h" -#ifdef USE_XERCES +#ifdef STORM_HAVE_XERCES #include #include #include -#include "storm/storage/gspn/GSPN.h" +#include "storm-gspn/storage/gspn/GSPN.h" -#include "storm/storage/gspn/GspnBuilder.h" +#include "storm-gspn/storage/gspn/GspnBuilder.h" namespace storm { namespace parser { diff --git a/src/storm-gspn/parser/GspnParser.cpp b/src/storm-gspn/parser/GspnParser.cpp index dfb3575d3..b92b6f006 100644 --- a/src/storm-gspn/parser/GspnParser.cpp +++ b/src/storm-gspn/parser/GspnParser.cpp @@ -13,7 +13,7 @@ namespace storm { namespace parser { storm::gspn::GSPN* GspnParser::parse(std::string const& filename) { -#ifdef USE_XERCES +#ifdef STORM_HAVE_XERCES // initialize xercesc try { xercesc::XMLPlatformUtils::Initialize(); diff --git a/src/storm-gspn/parser/PnmlParser.cpp b/src/storm-gspn/parser/PnmlParser.cpp index 4869405eb..3dfd9e2a6 100644 --- a/src/storm-gspn/parser/PnmlParser.cpp +++ b/src/storm-gspn/parser/PnmlParser.cpp @@ -1,9 +1,9 @@ #include "storm-gspn/parser/PnmlParser.h" -#ifdef USE_XERCES +#ifdef STORM_HAVE_XERCES #include -#include "storm/adapters/XercesAdapter.h" +#include "storm-gspn/adapters/XercesAdapter.h" #include "storm/exceptions/UnexpectedException.h" #include "storm/exceptions/WrongFormatException.h" @@ -283,7 +283,7 @@ namespace storm { STORM_PRINT_AND_LOG("unknown multiplicity (node=arc): " + id + "\n"); } - STORM_LOG_THROW(false, storm::exceptions::UnexpectedException, "No arc type specified for arc '" + id + "'"); + if (type.second == "normal") { builder.addNormalArc(source.second, target.second, multiplicity.second); } else if (type.second == "inhibition") { diff --git a/src/storm-gspn/parser/PnmlParser.h b/src/storm-gspn/parser/PnmlParser.h index 8bf5592ae..e4b459eb2 100644 --- a/src/storm-gspn/parser/PnmlParser.h +++ b/src/storm-gspn/parser/PnmlParser.h @@ -1,14 +1,14 @@ #pragma once #include "storm-config.h" -#ifdef USE_XERCES +#ifdef STORM_HAVE_XERCES #include #include #include -#include "storm/storage/gspn/GSPN.h" +#include "storm-gspn/storage/gspn/GSPN.h" -#include "storm/storage/gspn/GspnBuilder.h" +#include "storm-gspn/storage/gspn/GspnBuilder.h" namespace storm { namespace parser { diff --git a/src/storm-gspn/storage/gspn/GspnBuilder.cpp b/src/storm-gspn/storage/gspn/GspnBuilder.cpp index e0bbd76fd..a727ebebf 100644 --- a/src/storm-gspn/storage/gspn/GspnBuilder.cpp +++ b/src/storm-gspn/storage/gspn/GspnBuilder.cpp @@ -21,6 +21,7 @@ namespace storm { place.setNumberOfInitialTokens(initialTokens); place.setName(name); places.push_back(place); + placeNames.emplace(name, newId); return newId; } @@ -60,6 +61,8 @@ namespace storm { } immediateTransitions.push_back(trans); + + transitionNames.emplace(name, newId); return newId; } @@ -72,6 +75,8 @@ namespace storm { trans.setRate(rate); trans.setID(newId); timedTransitions.push_back(trans); + + transitionNames.emplace(name, newId); return newId; } diff --git a/src/storm-gspn/storm-gspn.h b/src/storm-gspn/storm-gspn.h index 63b0746f1..095b82aca 100644 --- a/src/storm-gspn/storm-gspn.h +++ b/src/storm-gspn/storm-gspn.h @@ -5,6 +5,7 @@ #include "storm-gspn/builder/JaniGSPNBuilder.h" #include "storm-gspn/storage/gspn/GSPN.h" +#include "storm/settings/SettingsManager.h" #include "storm/settings/modules/GSPNExportSettings.h" namespace storm { diff --git a/src/storm-pgcl-cli/storm-pgcl.cpp b/src/storm-pgcl-cli/storm-pgcl.cpp index bf5dc1c1e..37accc430 100644 --- a/src/storm-pgcl-cli/storm-pgcl.cpp +++ b/src/storm-pgcl-cli/storm-pgcl.cpp @@ -14,6 +14,7 @@ #include "storm/exceptions/FileIoException.h" #include "storm/settings/modules/GeneralSettings.h" +#include "storm/settings/modules/ResourceSettings.h" #include "storm/settings/modules/PGCLSettings.h" #include "storm/settings/modules/CoreSettings.h" #include "storm/settings/modules/DebugSettings.h" @@ -28,6 +29,7 @@ void initializeSettings() { // Register all known settings modules. storm::settings::addModule(); + storm::settings::addModule(); storm::settings::addModule(); storm::settings::addModule(); storm::settings::addModule(); @@ -76,13 +78,16 @@ int main(const int argc, const char** argv) { programGraphToDotFile(*progGraph); } if (storm::settings::getModule().isToJaniSet()) { - storm::builder::JaniProgramGraphBuilder builder(*progGraph); + storm::builder::JaniProgramGraphBuilderSetting settings; + // To disable reward detection, uncomment the following line + // TODO add a setting for this. + // settings.filterRewardVariables = false; + storm::builder::JaniProgramGraphBuilder builder(*progGraph, settings); if (storm::settings::getModule().isProgramVariableRestrictionSet()) { // TODO More fine grained control storm::storage::IntegerInterval restr = storm::storage::parseIntegerInterval(storm::settings::getModule().getProgramVariableRestrictions()); builder.restrictAllVariables(restr); } - builder.restrictAllVariables(0, 120); storm::jani::Model* model = builder.build(); delete progGraph; handleJani(*model); @@ -90,13 +95,11 @@ int main(const int argc, const char** argv) { } else { } - - - - }catch (storm::exceptions::BaseException const& exception) { STORM_LOG_ERROR("An exception caused StoRM-PGCL to terminate. The message of the exception is: " << exception.what()); + return 1; } catch (std::exception const& exception) { STORM_LOG_ERROR("An unexpected exception occurred and caused StoRM-PGCL to terminate. The message of this exception is: " << exception.what()); + return 2; } } diff --git a/src/storm-pgcl/builder/JaniProgramGraphBuilder.cpp b/src/storm-pgcl/builder/JaniProgramGraphBuilder.cpp index 736dcad21..4741fc374 100644 --- a/src/storm-pgcl/builder/JaniProgramGraphBuilder.cpp +++ b/src/storm-pgcl/builder/JaniProgramGraphBuilder.cpp @@ -63,23 +63,24 @@ namespace storm { return storm::jani::OrderedAssignments(vec); } - std::vector JaniProgramGraphBuilder::buildProbabilisticDestinations(storm::jani::Automaton& automaton, storm::ppg::ProgramEdge const& edge ) { + std::vector> JaniProgramGraphBuilder::buildProbabilisticDestinations(storm::jani::Automaton& automaton, storm::ppg::ProgramEdge const& edge, storm::jani::TemplateEdge& templateEdge) { storm::ppg::ProbabilisticProgramAction const& act = static_cast(edge.getAction()); - std::vector vec; - for(auto const& assign : act ) { - storm::jani::Assignment assignment(automaton.getVariables().getVariable(act.getVariableName()), expManager->integer(assign.value) ,0); - vec.emplace_back(janiLocId.at(edge.getTargetId()), assign.probability, assignment); + std::vector> vec; + for(auto const& assign : act) { + storm::jani::Assignment assignment(automaton.getVariables().getVariable(act.getVariableName()), expManager->integer(assign.value), 0); + templateEdge.addDestination(storm::jani::TemplateEdgeDestination(storm::jani::OrderedAssignments(assignment))); + vec.emplace_back(janiLocId.at(edge.getTargetId()), assign.probability); } return vec; } - std::vector JaniProgramGraphBuilder::buildDestinations(storm::jani::Automaton& automaton, storm::ppg::ProgramEdge const& edge ) { + std::vector> JaniProgramGraphBuilder::buildDestinations(storm::jani::Automaton& automaton, storm::ppg::ProgramEdge const& edge, storm::jani::TemplateEdge& templateEdge) { if (edge.getAction().isProbabilistic()) { - return buildProbabilisticDestinations(automaton, edge); + return buildProbabilisticDestinations(automaton, edge, templateEdge); } else { storm::jani::OrderedAssignments oa = buildOrderedAssignments(automaton, static_cast(edge.getAction())); - storm::jani::EdgeDestination dest(janiLocId.at(edge.getTargetId()), expManager->rational(1.0), oa); - return {dest}; + templateEdge.addDestination(storm::jani::TemplateEdgeDestination(oa)); + return {std::make_pair(janiLocId.at(edge.getTargetId()), expManager->rational(1.0))}; } } @@ -88,7 +89,7 @@ namespace storm { return in.simplify(); } - std::pair, storm::expressions::Expression> JaniProgramGraphBuilder::addVariableChecks(storm::ppg::ProgramEdge const& edge) { + std::pair, storm::expressions::Expression> JaniProgramGraphBuilder::addVariableChecks(storm::jani::Automaton& automaton, storm::ppg::ProgramEdge const& edge) { std::vector edges; storm::expressions::Expression newGuard; newGuard = expManager->boolean(true); @@ -116,8 +117,10 @@ namespace storm { // TODO currently only fully bounded restrictions are supported; assert(userVariableRestrictions.at(assignment.first).hasLeftBound() && userVariableRestrictions.at(assignment.first).hasRightBound()); storm::expressions::Expression newCondition = simplifyExpression(edge.getCondition() && (assignment.second > bound.getRightBound().get() || assignment.second < bound.getLeftBound().get())); - storm::jani::EdgeDestination dest(varOutOfBoundsLocations.at(assignment.first), expManager->rational(1.0), storm::jani::OrderedAssignments()); - storm::jani::Edge e(janiLocId.at(edge.getSourceId()), storm::jani::Model::SILENT_ACTION_INDEX, boost::none, newCondition, {dest}); + + std::shared_ptr templateEdge = automaton.createTemplateEdge(newCondition); + templateEdge->addDestination(storm::jani::TemplateEdgeDestination()); + storm::jani::Edge e(janiLocId.at(edge.getSourceId()), storm::jani::Model::SILENT_ACTION_INDEX, boost::none, templateEdge, {varOutOfBoundsLocations.at(assignment.first)}, {expManager->rational(1.0)}); edges.push_back(e); newGuard = newGuard && assignment.second <= bound.getRightBound().get() && assignment.second >= bound.getLeftBound().get(); } @@ -133,17 +136,20 @@ namespace storm { for(auto it = programGraph.locationBegin(); it != programGraph.locationEnd(); ++it) { ppg::ProgramLocation const& loc = it->second; if (loc.nrOutgoingEdgeGroups() == 0) { - storm::jani::OrderedAssignments oa; - storm::jani::EdgeDestination dest(janiLocId.at(loc.id()), expManager->integer(1), oa); - storm::jani::Edge e(janiLocId.at(loc.id()), storm::jani::Model::SILENT_ACTION_INDEX, boost::none, expManager->boolean(true), {dest}); + std::shared_ptr templateEdge = automaton.createTemplateEdge(expManager->boolean(true)); + templateEdge->addDestination(storm::jani::TemplateEdgeDestination()); + storm::jani::Edge e(janiLocId.at(loc.id()), storm::jani::Model::SILENT_ACTION_INDEX, boost::none, templateEdge, {janiLocId.at(loc.id())}, {expManager->rational(1.0)}); automaton.addEdge(e); } else if (loc.nrOutgoingEdgeGroups() == 1) { for(auto const& edge : **(loc.begin())) { - std::pair, storm::expressions::Expression> checks = addVariableChecks(*edge); + std::pair, storm::expressions::Expression> checks = addVariableChecks(automaton, *edge); for(auto const& check : checks.first) { automaton.addEdge(check); } - storm::jani::Edge e(janiLocId.at(loc.id()), storm::jani::Model::SILENT_ACTION_INDEX, boost::none, simplifyExpression(edge->getCondition() && checks.second), buildDestinations(automaton, *edge)); + std::shared_ptr templateEdge = automaton.createTemplateEdge(simplifyExpression(edge->getCondition() && checks.second)); + std::vector> destinationLocationsAndProbabilities = buildDestinations(automaton, *edge, *templateEdge); + + storm::jani::Edge e(janiLocId.at(loc.id()), storm::jani::Model::SILENT_ACTION_INDEX, boost::none, templateEdge, destinationLocationsAndProbabilities); automaton.addEdge(e); } } else { @@ -152,15 +158,20 @@ namespace storm { { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Combi of nondeterminism and probabilistic choices within a loc not supported yet"); } else { - std::vector destinations; + std::shared_ptr templateEdge = automaton.createTemplateEdge(expManager->boolean(true)); + + std::vector destinationProbabilities; + std::vector destinationLocations; for(auto const& eg : loc) { // TODO add assignments assert(eg->nrEdges() < 2); // Otherwise, non-determinism occurs. assert(eg->nrEdges() > 0); // Empty edge groups should not occur in input. - uint64_t target = janiLocId.at((*eg->begin())->getTargetId()); - destinations.emplace_back(target, eg->getProbability()); + destinationLocations.push_back(janiLocId.at((*eg->begin())->getTargetId())); + destinationProbabilities.push_back(eg->getProbability()); + templateEdge->addDestination(storm::jani::TemplateEdgeDestination()); } - storm::jani::Edge e(janiLocId.at(it->second.id()), storm::jani::Model::SILENT_ACTION_INDEX, boost::none, expManager->boolean(true), destinations); + + storm::jani::Edge e(janiLocId.at(it->second.id()), storm::jani::Model::SILENT_ACTION_INDEX, boost::none, templateEdge, destinationLocations, destinationProbabilities); automaton.addEdge(e); } } diff --git a/src/storm-pgcl/builder/JaniProgramGraphBuilder.h b/src/storm-pgcl/builder/JaniProgramGraphBuilder.h index 34b5dd5d7..ad5feb8a4 100644 --- a/src/storm-pgcl/builder/JaniProgramGraphBuilder.h +++ b/src/storm-pgcl/builder/JaniProgramGraphBuilder.h @@ -19,15 +19,21 @@ namespace storm { }; struct JaniProgramGraphBuilderSetting { + /// Method how to obtain domain for the variables; currently only unrestricted is supported JaniProgramGraphVariableDomainMethod variableDomainMethod = JaniProgramGraphVariableDomainMethod::Unrestricted; + /// If this is true, reward variables will be given special treatment, effectively removing them from the state space. + /// Disable in order to obtain full state space. + bool filterRewardVariables = true; }; class JaniProgramGraphBuilder { public: static unsigned janiVersion; - JaniProgramGraphBuilder(storm::ppg::ProgramGraph const& pg) : programGraph(pg) { - rewards = programGraph.rewardVariables(); + JaniProgramGraphBuilder(storm::ppg::ProgramGraph const& pg, JaniProgramGraphBuilderSetting const& pgbs = JaniProgramGraphBuilderSetting()) : programGraph(pg), pgbs(pgbs) { + if (pgbs.filterRewardVariables) { + rewards = programGraph.rewardVariables(); + } constants = programGraph.constants(); auto boundedVars = programGraph.constantAssigned(); for(auto const& v : boundedVars) { @@ -41,10 +47,6 @@ namespace storm { } } - //void addVariableRestriction(storm::expressions::Variable const& var, storm::IntegerInterval const& interval ) { - - //} - void restrictAllVariables(int64_t from, int64_t to) { restrictAllVariables(storm::storage::IntegerInterval(from, to)); @@ -67,7 +69,7 @@ namespace storm { storm::jani::Model* build(std::string const& name = "program_graph") { expManager = programGraph.getExpressionManager(); storm::jani::Model* model = new storm::jani::Model(name, storm::jani::ModelType::MDP, janiVersion, expManager); - storm::jani::Automaton mainAutomaton("main"); + storm::jani::Automaton mainAutomaton("main", expManager->declareIntegerVariable("pc")); addProcedureVariables(*model, mainAutomaton); janiLocId = addProcedureLocations(*model, mainAutomaton); addVariableOoBLocations(mainAutomaton); @@ -88,13 +90,13 @@ namespace storm { storm::jani::OrderedAssignments buildOrderedAssignments(storm::jani::Automaton& automaton, storm::ppg::DeterministicProgramAction const& act) ; void addEdges(storm::jani::Automaton& automaton); - std::vector buildDestinations(storm::jani::Automaton& automaton, storm::ppg::ProgramEdge const& edge ); + std::vector> buildDestinations(storm::jani::Automaton& automaton, storm::ppg::ProgramEdge const& edge, storm::jani::TemplateEdge& templateEdge); /** * Helper for probabilistic assignments */ - std::vector buildProbabilisticDestinations(storm::jani::Automaton& automaton, storm::ppg::ProgramEdge const& edge ); + std::vector> buildProbabilisticDestinations(storm::jani::Automaton& automaton, storm::ppg::ProgramEdge const& edge, storm::jani::TemplateEdge& templateEdge); - std::pair, storm::expressions::Expression> addVariableChecks(storm::ppg::ProgramEdge const& edge); + std::pair, storm::expressions::Expression> addVariableChecks(storm::jani::Automaton& automaton, storm::ppg::ProgramEdge const& edge); bool isUserRestrictedVariable(storm::ppg::ProgramVariableIdentifier i) const { return userVariableRestrictions.count(i) == 1 && !isRewardVariable(i); @@ -167,7 +169,7 @@ namespace storm { /// Restrictions on variables (provided by users) std::map userVariableRestrictions; - /// Locations for variables that would have gone ot o + /// Locations for variables that would have gone out of bounds std::map varOutOfBoundsLocations; std::map janiLocId; std::map variables; @@ -176,6 +178,8 @@ namespace storm { std::shared_ptr expManager; /// The program graph to be translated storm::ppg::ProgramGraph const& programGraph; + /// Settings + JaniProgramGraphBuilderSetting pgbs; }; diff --git a/src/storm/CMakeLists.txt b/src/storm/CMakeLists.txt index 4fba35749..d9135dcb9 100644 --- a/src/storm/CMakeLists.txt +++ b/src/storm/CMakeLists.txt @@ -28,6 +28,9 @@ if (ADDITIONAL_LINK_DIRS) link_directories(${ADDITIONAL_LINK_DIRS}) endif(ADDITIONAL_LINK_DIRS) +# Disable Debug compiler flags for PrismParser to lessen memory consumption during compilation +SET_SOURCE_FILES_PROPERTIES(${PROJECT_SOURCE_DIR}/src/storm/parser/PrismParser.cpp PROPERTIES COMPILE_FLAGS -g0) + ############################################################################### ## ## Binary creation (All link_directories() calls must be made before this point.) @@ -48,7 +51,6 @@ add_executable(storm-main ${STORM_MAIN_SOURCES} ${STORM_MAIN_HEADERS}) target_link_libraries(storm-main storm) set_target_properties(storm-main PROPERTIES OUTPUT_NAME "storm") - # Install storm headers to include directory. foreach(HEADER ${STORM_LIB_HEADERS}) string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/src/?" "" RELATIVE_HEADER_PATH ${HEADER}) @@ -66,3 +68,5 @@ add_custom_target(copy_storm_headers DEPENDS ${STORM_OUTPUT_HEADERS} ${STORM_LIB add_dependencies(storm copy_storm_headers) add_dependencies(storm copy_resources_headers) +# install command +install(TARGETS storm-main storm RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL) \ No newline at end of file diff --git a/src/storm/abstraction/AbstractionInformation.cpp b/src/storm/abstraction/AbstractionInformation.cpp new file mode 100644 index 000000000..c74cb60cb --- /dev/null +++ b/src/storm/abstraction/AbstractionInformation.cpp @@ -0,0 +1,551 @@ +#include "storm/abstraction/AbstractionInformation.h" + +#include "storm/storage/BitVector.h" + +#include "storm/storage/dd/DdManager.h" + +#include "storm/utility/macros.h" +#include "storm/exceptions/InvalidOperationException.h" + +#include "storm/storage/expressions/Expression.h" +#include "storm/storage/expressions/ExpressionManager.h" + +namespace storm { + namespace abstraction { + + template + AbstractionInformation::AbstractionInformation(storm::expressions::ExpressionManager& expressionManager, std::set const& abstractedVariables, std::unique_ptr&& smtSolver, std::shared_ptr> ddManager) : expressionManager(expressionManager), equivalenceChecker(std::move(smtSolver)), abstractedVariables(abstractedVariables), ddManager(ddManager), allPredicateIdentities(ddManager->getBddOne()), allLocationIdentities(ddManager->getBddOne()), expressionToBddMap() { + // Intentionally left empty. + } + + template + void AbstractionInformation::addExpressionVariable(storm::expressions::Variable const& variable) { + abstractedVariables.insert(variable); + } + + template + void AbstractionInformation::addExpressionVariable(storm::expressions::Variable const& variable, storm::expressions::Expression const& constraint) { + addExpressionVariable(variable); + addConstraint(constraint); + } + + template + void AbstractionInformation::addConstraint(storm::expressions::Expression const& constraint) { + constraints.push_back(constraint); + } + + template + uint_fast64_t AbstractionInformation::getOrAddPredicate(storm::expressions::Expression const& predicate) { + // Check if we already have an equivalent predicate. + for (uint64_t index = 0; index < predicates.size(); ++index) { + auto const& oldPredicate = predicates[index]; + if (equivalenceChecker.areEquivalent(oldPredicate, predicate)) { + expressionToBddMap[predicate] = expressionToBddMap.at(oldPredicate); + return index; + } + } + + std::size_t predicateIndex = predicates.size(); + predicateToIndexMap[predicate] = predicateIndex; + + // Add the new predicate to the list of known predicates. + predicates.push_back(predicate); + + // Add DD variables for the new predicate. + std::stringstream stream; + stream << predicate; + std::pair newMetaVariable = ddManager->addMetaVariable(stream.str()); + + predicateDdVariables.push_back(newMetaVariable); + extendedPredicateDdVariables.push_back(newMetaVariable); + predicateBdds.emplace_back(ddManager->getEncoding(newMetaVariable.first, 1), ddManager->getEncoding(newMetaVariable.second, 1)); + predicateIdentities.push_back(ddManager->getEncoding(newMetaVariable.first, 1).iff(ddManager->getEncoding(newMetaVariable.second, 1))); + allPredicateIdentities &= predicateIdentities.back(); + sourceVariables.insert(newMetaVariable.first); + successorVariables.insert(newMetaVariable.second); + sourcePredicateVariables.insert(newMetaVariable.first); + successorPredicateVariables.insert(newMetaVariable.second); + orderedSourcePredicateVariables.push_back(newMetaVariable.first); + orderedSuccessorPredicateVariables.push_back(newMetaVariable.second); + ddVariableIndexToPredicateIndexMap[predicateIdentities.back().getIndex()] = predicateIndex; + expressionToBddMap[predicate] = predicateBdds[predicateIndex].first && !bottomStateBdds.first; + + return predicateIndex; + } + + template + std::vector AbstractionInformation::addPredicates(std::vector const& predicates) { + std::vector predicateIndices; + for (auto const& predicate : predicates) { + predicateIndices.push_back(this->getOrAddPredicate(predicate)); + } + return predicateIndices; + } + + template + std::vector const& AbstractionInformation::getConstraints() const { + return constraints; + } + + template + storm::expressions::ExpressionManager& AbstractionInformation::getExpressionManager() { + return expressionManager.get(); + } + + template + storm::expressions::ExpressionManager const& AbstractionInformation::getExpressionManager() const { + return expressionManager.get(); + } + + template + storm::dd::DdManager& AbstractionInformation::getDdManager() { + return *ddManager; + } + + template + storm::dd::DdManager const& AbstractionInformation::getDdManager() const { + return *ddManager; + } + + template + std::shared_ptr> AbstractionInformation::getDdManagerAsSharedPointer() { + return ddManager; + } + + template + std::shared_ptr const> AbstractionInformation::getDdManagerAsSharedPointer() const { + return ddManager; + } + + template + std::vector const& AbstractionInformation::getPredicates() const { + return predicates; + } + + template + std::vector AbstractionInformation::getPredicates(storm::storage::BitVector const& predicateValuation) const { + STORM_LOG_ASSERT(predicateValuation.size() == this->getNumberOfPredicates(), "Size of predicate valuation does not match number of predicates."); + + std::vector result; + for (uint64_t index = 0; index < this->getNumberOfPredicates(); ++index) { + if (predicateValuation[index]) { + result.push_back(this->getPredicateByIndex(index)); + } else { + result.push_back(!this->getPredicateByIndex(index)); + } + } + + return result; + } + + template + storm::expressions::Expression const& AbstractionInformation::getPredicateByIndex(uint_fast64_t index) const { + return predicates[index]; + } + + template + storm::dd::Bdd AbstractionInformation::getPredicateSourceVariable(storm::expressions::Expression const& predicate) const { + auto indexIt = predicateToIndexMap.find(predicate); + STORM_LOG_THROW(indexIt != predicateToIndexMap.end(), storm::exceptions::InvalidOperationException, "Cannot retrieve BDD for unknown predicate."); + return predicateBdds[indexIt->second].first; + } + + template + bool AbstractionInformation::hasPredicate(storm::expressions::Expression const& predicate) const { + return predicateToIndexMap.find(predicate) != predicateToIndexMap.end(); + } + + template + std::size_t AbstractionInformation::getNumberOfPredicates() const { + return predicates.size(); + } + + template + std::set const& AbstractionInformation::getAbstractedVariables() const { + return abstractedVariables; + } + + template + void AbstractionInformation::createEncodingVariables(uint64_t player1VariableCount, uint64_t player2VariableCount, uint64_t auxVariableCount) { + STORM_LOG_THROW(player1Variables.empty() && player2Variables.empty() && auxVariables.empty(), storm::exceptions::InvalidOperationException, "Variables have already been created."); + + for (uint64_t index = 0; index < player1VariableCount; ++index) { + storm::expressions::Variable newVariable = ddManager->addMetaVariable("pl1." + std::to_string(index)).first; + player1Variables.push_back(newVariable); + player1VariableBdds.push_back(ddManager->getEncoding(newVariable, 1)); + } + STORM_LOG_DEBUG("Created " << player1VariableCount << " player 1 variables."); + + for (uint64_t index = 0; index < player2VariableCount; ++index) { + storm::expressions::Variable newVariable = ddManager->addMetaVariable("pl2." + std::to_string(index)).first; + player2Variables.push_back(newVariable); + player2VariableBdds.push_back(ddManager->getEncoding(newVariable, 1)); + } + STORM_LOG_DEBUG("Created " << player2VariableCount << " player 2 variables."); + + for (uint64_t index = 0; index < auxVariableCount; ++index) { + storm::expressions::Variable newVariable = ddManager->addMetaVariable("aux_" + std::to_string(index)).first; + auxVariables.push_back(newVariable); + auxVariableBdds.push_back(ddManager->getEncoding(newVariable, 1)); + } + STORM_LOG_DEBUG("Created " << auxVariableCount << " auxiliary variables."); + + bottomStateVariables = ddManager->addMetaVariable("bot"); + bottomStateBdds = std::make_pair(ddManager->getEncoding(bottomStateVariables.first, 1), ddManager->getEncoding(bottomStateVariables.second, 1)); + extendedPredicateDdVariables.push_back(bottomStateVariables); + } + + template + storm::dd::Bdd AbstractionInformation::encodePlayer1Choice(uint_fast64_t index, uint_fast64_t end) const { + return encodeChoice(index, 0, end, player1VariableBdds); + } + + template + uint_fast64_t AbstractionInformation::decodePlayer1Choice(storm::expressions::Valuation const& valuation, uint_fast64_t end) const { + return decodeChoice(valuation, 0, end, player1Variables); + } + + template + storm::dd::Bdd AbstractionInformation::encodePlayer2Choice(uint_fast64_t index, uint_fast64_t start, uint_fast64_t end) const { + return encodeChoice(index, start, end, player2VariableBdds); + } + + template + uint_fast64_t AbstractionInformation::decodePlayer2Choice(storm::expressions::Valuation const& valuation, uint_fast64_t end) const { + return decodeChoice(valuation, 0, end, player2Variables); + } + + template + storm::dd::Bdd AbstractionInformation::encodeAux(uint_fast64_t index, uint_fast64_t start, uint_fast64_t end) const { + return encodeChoice(index, start, end, auxVariableBdds); + } + + template + uint_fast64_t AbstractionInformation::decodeAux(storm::expressions::Valuation const& valuation, uint_fast64_t start, uint_fast64_t end) const { + return decodeChoice(valuation, start, end, auxVariables); + } + + template + std::vector const& AbstractionInformation::getPlayer1Variables() const { + return player1Variables; + } + + template + std::set AbstractionInformation::getPlayer1VariableSet(uint_fast64_t count) const { + return std::set(player1Variables.begin(), player1Variables.begin() + count); + } + + template + std::vector const& AbstractionInformation::getPlayer2Variables() const { + return player2Variables; + } + + template + std::set AbstractionInformation::getPlayer2VariableSet(uint_fast64_t count) const { + return std::set(player2Variables.begin(), player2Variables.begin() + count); + } + + template + std::vector const& AbstractionInformation::getAuxVariables() const { + return auxVariables; + } + + template + storm::expressions::Variable const& AbstractionInformation::getAuxVariable(uint_fast64_t index) const { + return auxVariables[index]; + } + + template + std::set AbstractionInformation::getAuxVariableSet(uint_fast64_t start, uint_fast64_t end) const { + return std::set(auxVariables.begin() + start, auxVariables.begin() + end); + } + + template + std::set const& AbstractionInformation::getSourceVariables() const { + return sourceVariables; + } + + template + std::set const& AbstractionInformation::getSuccessorVariables() const { + return successorVariables; + } + + template + std::set const& AbstractionInformation::getSourcePredicateVariables() const { + return sourcePredicateVariables; + } + + template + std::set const& AbstractionInformation::getSuccessorPredicateVariables() const { + return successorPredicateVariables; + } + + template + std::vector const& AbstractionInformation::getOrderedSourcePredicateVariables() const { + return orderedSourcePredicateVariables; + } + + template + std::vector const& AbstractionInformation::getOrderedSuccessorPredicateVariables() const { + return orderedSuccessorPredicateVariables; + } + + template + storm::dd::Bdd const& AbstractionInformation::getAllPredicateIdentities() const { + return allPredicateIdentities; + } + template + storm::dd::Bdd const& AbstractionInformation::getAllLocationIdentities() const { + return allLocationIdentities; + } + + template + std::size_t AbstractionInformation::getPlayer1VariableCount() const { + return player1Variables.size(); + } + + template + std::size_t AbstractionInformation::getPlayer2VariableCount() const { + return player2Variables.size(); + } + + template + std::size_t AbstractionInformation::getAuxVariableCount() const { + return auxVariables.size(); + } + + template + std::map> const& AbstractionInformation::getPredicateToBddMap() const { + return expressionToBddMap; + } + + template + std::vector> const& AbstractionInformation::getSourceSuccessorVariablePairs() const { + return predicateDdVariables; + } + + template + std::vector> const& AbstractionInformation::getExtendedSourceSuccessorVariablePairs() const { + return extendedPredicateDdVariables; + } + + template + storm::expressions::Variable const& AbstractionInformation::getBottomStateVariable(bool source) const { + if (source) { + return bottomStateVariables.first; + } else { + return bottomStateVariables.second; + } + } + + template + storm::dd::Bdd AbstractionInformation::getBottomStateBdd(bool source, bool negated) const { + if (source) { + if (negated) { + return !bottomStateBdds.first; + } else { + return bottomStateBdds.first; + } + } else { + if (negated) { + return !bottomStateBdds.second; + } else { + return bottomStateBdds.second; + } + } + } + + template + storm::dd::Bdd const& AbstractionInformation::encodePredicateAsSource(uint_fast64_t predicateIndex) const { + return predicateBdds[predicateIndex].first; + } + + template + storm::dd::Bdd const& AbstractionInformation::encodePredicateAsSuccessor(uint_fast64_t predicateIndex) const { + return predicateBdds[predicateIndex].second; + } + + template + storm::dd::Bdd const& AbstractionInformation::getPredicateIdentity(uint_fast64_t predicateIndex) const { + return predicateIdentities[predicateIndex]; + } + + template + storm::expressions::Expression const& AbstractionInformation::getPredicateForDdVariableIndex(uint_fast64_t ddVariableIndex) const { + auto indexIt = ddVariableIndexToPredicateIndexMap.find(ddVariableIndex); + STORM_LOG_THROW(indexIt != ddVariableIndexToPredicateIndexMap.end(), storm::exceptions::InvalidOperationException, "Unknown DD variable index."); + return predicates[indexIt->second]; + } + + template + std::vector> AbstractionInformation::declareNewVariables(std::vector> const& oldPredicates, std::set const& newPredicates) const { + std::vector> result; + + auto oldIt = oldPredicates.begin(); + auto oldIte = oldPredicates.end(); + auto newIt = newPredicates.begin(); + auto newIte = newPredicates.end(); + + for (; newIt != newIte; ++newIt) { + if (oldIt == oldIte || oldIt->second != *newIt) { + result.push_back(std::make_pair(expressionManager.get().declareFreshBooleanVariable(), *newIt)); + } else { + ++oldIt; + } + } + + return result; + } + + template + storm::dd::Bdd AbstractionInformation::encodeChoice(uint_fast64_t index, uint_fast64_t start, uint_fast64_t end, std::vector> const& variables) const { + storm::dd::Bdd result = ddManager->getBddOne(); + for (uint_fast64_t bitIndex = end; bitIndex > start; --bitIndex) { + if ((index & 1) != 0) { + result &= variables[bitIndex - 1]; + } else { + result &= !variables[bitIndex - 1]; + } + index >>= 1; + } + STORM_LOG_ASSERT(!result.isZero(), "BDD encoding must not be zero."); + return result; + } + + template + uint_fast64_t AbstractionInformation::decodeChoice(storm::expressions::Valuation const& valuation, uint_fast64_t start, uint_fast64_t end, std::vector const& variables) const { + uint_fast64_t result = 0; + for (uint_fast64_t variableIndex = start; variableIndex < end; ++variableIndex) { + result <<= 1; + if (valuation.getBooleanValue(variables[variableIndex])) { + result |= 1; + } + } + return result; + } + + template + storm::storage::BitVector AbstractionInformation::decodeState(storm::dd::Bdd const& state) const { + STORM_LOG_ASSERT(state.getNonZeroCount() == 1, "Wrong number of non-zero entries."); + + storm::storage::BitVector statePredicates(this->getNumberOfPredicates()); + + storm::dd::Add add = state.template toAdd(); + auto it = add.begin(); + auto stateValuePair = *it; + for (uint_fast64_t index = 0; index < this->getOrderedSourcePredicateVariables().size(); ++index) { + auto const& successorVariable = this->getOrderedSourcePredicateVariables()[index]; + if (stateValuePair.first.getBooleanValue(successorVariable)) { + statePredicates.set(index); + } + } + + return statePredicates; + } + + template + template + std::map> AbstractionInformation::decodeChoiceToUpdateSuccessorMapping(storm::dd::Bdd const& choice) const { + std::map> result; + + storm::dd::Add lowerChoiceAsAdd = choice.template toAdd(); + for (auto const& successorValuePair : lowerChoiceAsAdd) { + uint_fast64_t updateIndex = this->decodeAux(successorValuePair.first, 0, this->getAuxVariableCount()); + + storm::storage::BitVector successor(this->getNumberOfPredicates()); + for (uint_fast64_t index = 0; index < this->getOrderedSuccessorPredicateVariables().size(); ++index) { + auto const& successorVariable = this->getOrderedSuccessorPredicateVariables()[index]; + if (successorValuePair.first.getBooleanValue(successorVariable)) { + successor.set(index); + } + } + + result[updateIndex] = std::make_pair(successor, successorValuePair.second); + } + return result; + } + + template + std::tuple AbstractionInformation::decodeStatePlayer1ChoiceAndUpdate(storm::dd::Bdd const& stateChoiceAndUpdate) const { + STORM_LOG_ASSERT(stateChoiceAndUpdate.getNonZeroCount() == 1, "Wrong number of non-zero entries."); + + storm::storage::BitVector statePredicates(this->getNumberOfPredicates()); + + storm::dd::Add add = stateChoiceAndUpdate.template toAdd(); + auto it = add.begin(); + auto stateValuePair = *it; + uint64_t choiceIndex = this->decodePlayer1Choice(stateValuePair.first, this->getPlayer1VariableCount()); + uint64_t updateIndex = this->decodeAux(stateValuePair.first, 0, this->getAuxVariableCount()); + for (uint_fast64_t index = 0; index < this->getOrderedSourcePredicateVariables().size(); ++index) { + auto const& successorVariable = this->getOrderedSourcePredicateVariables()[index]; + + if (stateValuePair.first.getBooleanValue(successorVariable)) { + statePredicates.set(index); + } + } + + return std::make_tuple(statePredicates, choiceIndex, updateIndex); + } + + template + std::pair, uint64_t> AbstractionInformation::addLocationVariables(storm::expressions::Variable const& locationExpressionVariable, uint64_t highestLocationIndex) { + auto newMetaVariable = ddManager->addMetaVariable("loc_" + std::to_string(locationVariablePairs.size()), 0, highestLocationIndex); + + locationExpressionVariables.insert(locationExpressionVariable); + locationExpressionToDdVariableMap.emplace(locationExpressionVariable, newMetaVariable); + locationVariablePairs.emplace_back(newMetaVariable); + allSourceLocationVariables.insert(newMetaVariable.first); + sourceVariables.insert(newMetaVariable.first); + allSuccessorLocationVariables.insert(newMetaVariable.second); + successorVariables.insert(newMetaVariable.second); + extendedPredicateDdVariables.emplace_back(newMetaVariable); + allLocationIdentities &= ddManager->template getIdentity(newMetaVariable.first).equals(ddManager->template getIdentity(newMetaVariable.second)) && ddManager->getRange(newMetaVariable.first) && ddManager->getRange(newMetaVariable.second); + return std::make_pair(locationVariablePairs.back(), locationVariablePairs.size() - 1); + } + + template + storm::expressions::Variable AbstractionInformation::getLocationVariable(uint64_t locationVariableIndex, bool source) const { + if (source) { + return locationVariablePairs[locationVariableIndex].first; + } else { + return locationVariablePairs[locationVariableIndex].second; + } + } + + template + std::set const& AbstractionInformation::getSourceLocationVariables() const { + return allSourceLocationVariables; + } + + template + std::set const& AbstractionInformation::getSuccessorLocationVariables() const { + return allSuccessorLocationVariables; + } + + template + storm::expressions::Variable const& AbstractionInformation::getDdLocationVariable(storm::expressions::Variable const& locationExpressionVariable, bool source) { + auto const& metaVariablePair = locationExpressionToDdVariableMap.at(locationExpressionVariable); + if (source) { + return metaVariablePair.first; + } else { + return metaVariablePair.second; + } + } + + template + std::set const& AbstractionInformation::getLocationExpressionVariables() const { + return locationExpressionVariables; + } + + template + storm::dd::Bdd AbstractionInformation::encodeLocation(storm::expressions::Variable const& locationVariable, uint64_t locationIndex) const { + return this->getDdManager().getEncoding(locationVariable, locationIndex); + } + + template class AbstractionInformation; + template class AbstractionInformation; + + template std::map> AbstractionInformation::decodeChoiceToUpdateSuccessorMapping(storm::dd::Bdd const& choice) const; + template std::map> AbstractionInformation::decodeChoiceToUpdateSuccessorMapping(storm::dd::Bdd const& choice) const; + } +} diff --git a/src/storm/abstraction/AbstractionInformation.h b/src/storm/abstraction/AbstractionInformation.h new file mode 100644 index 000000000..093342993 --- /dev/null +++ b/src/storm/abstraction/AbstractionInformation.h @@ -0,0 +1,640 @@ +#pragma once + +#include +#include +#include +#include + +#include "storm/storage/dd/DdType.h" + +#include "storm/storage/dd/Bdd.h" + +#include "storm/solver/SmtSolver.h" + +#include "storm/storage/expressions/EquivalenceChecker.h" + +namespace storm { + namespace expressions { + class ExpressionManager; + class Expression; + class Variable; + } + + namespace dd { + template + class DdManager; + } + + namespace abstraction { + + template + class AbstractionInformation { + public: + /*! + * Creates a new abstraction information object. + * + * @param expressionManager The manager responsible for all variables and expressions during the abstraction process. + * @param abstractedVariables All expression variables that can appear in predicates known to this object. + * @param smtSolver An SMT solver that is used to detect equivalent predicates. + * @param ddManager The manager responsible for the DDs. + */ + AbstractionInformation(storm::expressions::ExpressionManager& expressionManager, std::set const& abstractedVariables, std::unique_ptr&& smtSolver, std::shared_ptr> ddManager = std::make_shared>()); + + /*! + * Adds the given variable. + * + * @param variable The variable to add. + */ + void addExpressionVariable(storm::expressions::Variable const& variable); + + /*! + * Adds the given variable whose range is restricted. + * + * @param variable The variable to add. + * @param constraint An expression characterizing the legal values of the variable. + */ + void addExpressionVariable(storm::expressions::Variable const& variable, storm::expressions::Expression const& constraint); + + /*! + * Adds an expression that constrains the legal variable values. + * + * @param constraint The constraint. + */ + void addConstraint(storm::expressions::Expression const& constraint); + + /*! + * Retrieves a list of expressions that constrain the valid variable values. + * + * @return The constraint expressions. + */ + std::vector const& getConstraints() const; + + /*! + * Gets the index of a predicate that is equivalent to the provided one. If none exists, the predicate is + * added. + * + * @param predicate The predicate to add. + * @return The index of the newly added predicate in the global list of predicates. + */ + uint_fast64_t getOrAddPredicate(storm::expressions::Expression const& predicate); + + /*! + * Adds the given predicates. + * + * @param predicates The predicates to add. + * @return A list of indices corresponding to the new predicates. + */ + std::vector addPredicates(std::vector const& predicates); + + /*! + * Retrieves the expression manager. + * + * @return The manager. + */ + storm::expressions::ExpressionManager& getExpressionManager(); + + /*! + * Retrieves the expression manager. + * + * @return The manager. + */ + storm::expressions::ExpressionManager const& getExpressionManager() const; + + /*! + * Retrieves the DD manager. + * + * @return The manager. + */ + storm::dd::DdManager& getDdManager(); + + /*! + * Retrieves the DD manager. + * + * @return The manager. + */ + storm::dd::DdManager const& getDdManager() const; + + /*! + * Retrieves the shared pointer to the DD manager. + * + * @return The shared pointer to the DD manager. + */ + std::shared_ptr> getDdManagerAsSharedPointer(); + + /*! + * Retrieves the shared pointer to the DD manager. + * + * @return The shared pointer to the DD manager. + */ + std::shared_ptr const> getDdManagerAsSharedPointer() const; + + /*! + * Retrieves all currently known predicates. + * + * @return The list of known predicates. + */ + std::vector const& getPredicates() const; + + /*! + * Retrieves a list of expression that corresponds to the given predicate valuation. + */ + std::vector getPredicates(storm::storage::BitVector const& predicateValuation) const; + + /*! + * Retrieves the predicate with the given index. + * + * @param index The index of the predicate. + */ + storm::expressions::Expression const& getPredicateByIndex(uint_fast64_t index) const; + + /*! + * Retrieves the source variable associated with the given predicate. Note that the given predicate must be + * known to this abstraction information. + * + * @param predicate The predicate for which to retrieve the source variable. + */ + storm::dd::Bdd getPredicateSourceVariable(storm::expressions::Expression const& predicate) const; + + /*! + * Determines whether the given predicate is in the set of known predicates. + * + * @param predicate The predicate for which to query membership. + */ + bool hasPredicate(storm::expressions::Expression const& predicate) const; + + /*! + * Retrieves the number of predicates. + * + * @return The number of predicates. + */ + std::size_t getNumberOfPredicates() const; + + /*! + * Retrieves all currently known variables. + * + * @return The set of known variables. + */ + std::set const& getAbstractedVariables() const; + + /*! + * Creates the given number of variables used to encode the choices of player 1/2 and auxiliary information. + * + * @param player1VariableCount The number of variables to use for encoding player 1 choices. + * @param player2VariableCount The number of variables to use for encoding player 2 choices. + * @param auxVariableCount The number of variables to use for encoding auxiliary information. + */ + void createEncodingVariables(uint64_t player1VariableCount, uint64_t player2VariableCount, uint64_t auxVariableCount); + + /*! + * Encodes the given index using the indicated player 1 variables. + * + * @param index The index to encode. + * @param end The index of the variable past the end of the range that is used to encode the index. + * @return The index encoded as a BDD. + */ + storm::dd::Bdd encodePlayer1Choice(uint_fast64_t index, uint_fast64_t end) const; + + /*! + * Decodes the player 1 choice in the given valuation. + * + * @param valuation The valuation to decode. + * @param end The index of the variable past the end of the range that is used to encode the index. + * @return The decoded player 1 choice. + */ + uint_fast64_t decodePlayer1Choice(storm::expressions::Valuation const& valuation, uint_fast64_t end) const; + + /*! + * Encodes the given index using the indicated player 2 variables. + * + * @param index The index to encode. + * @param start The index of the first variable of the range that is used to encode the index. + * @param end The index of the variable past the end of the range that is used to encode the index. + * @return The index encoded as a BDD. + */ + storm::dd::Bdd encodePlayer2Choice(uint_fast64_t index, uint_fast64_t start, uint_fast64_t end) const; + + /*! + * Decodes the player 2 choice in the given valuation. + * + * @param valuation The valuation to decode. + * @param end The index of the variable past the end of the range that is used to encode the index. + * @return The decoded player 2 choice. + */ + uint_fast64_t decodePlayer2Choice(storm::expressions::Valuation const& valuation, uint_fast64_t end) const; + + /*! + * Encodes the given index using the indicated auxiliary variables. + * + * @param index The index to encode. + * @param start The index of the first variable of the range that is used to encode the index. + * @param end The index of the variable past the end of the range that is used to encode the index. + * @return The index encoded as a BDD. + */ + storm::dd::Bdd encodeAux(uint_fast64_t index, uint_fast64_t start, uint_fast64_t end) const; + + /*! + * Decodes the auxiliary index in the given valuation. + * + * @param valuation The valuation to decode. + * @param start The index of the first variable of the range that is used to encode the index. + * @param end The index of the variable past the end of the range that is used to encode the index. + * @return The decoded auxiliary index. + */ + uint_fast64_t decodeAux(storm::expressions::Valuation const& valuation, uint_fast64_t start, uint_fast64_t end) const; + + /*! + * Retrieves the meta variables associated with the player 1 choices. + * + * @return The meta variables associated with the player 1 choices. + */ + std::vector const& getPlayer1Variables() const; + + /*! + * Retrieves the set of player 1 variables. + * + * @param count The number of player 1 variables to include. + * @return The set of player 1 variables. + */ + std::set getPlayer1VariableSet(uint_fast64_t count) const; + + /*! + * Retrieves the number of player 1 variables. + * + * @return The number of player 1 variables. + */ + std::size_t getPlayer1VariableCount() const; + + /*! + * Retrieves the meta variables associated with the player 2 choices. + * + * @return The meta variables associated with the player 2 choices. + */ + std::vector const& getPlayer2Variables() const; + + /*! + * Retrieves the number of player 2 variables. + * + * @return The number of player 2 variables. + */ + std::size_t getPlayer2VariableCount() const; + + /*! + * Retrieves the set of player 2 variables. + * + * @param count The number of player 2 variables to include. + * @return The set of player 2 variables. + */ + std::set getPlayer2VariableSet(uint_fast64_t count) const; + + /*! + * Retrieves the meta variables associated with auxiliary information. + * + * @return The meta variables associated with auxiliary information. + */ + std::vector const& getAuxVariables() const; + + /*! + * Retrieves the auxiliary variable with the given index. + * + * @param index The index of the auxiliary variable to retrieve. + * @return The auxiliary variable with the given index. + */ + storm::expressions::Variable const& getAuxVariable(uint_fast64_t index) const; + + /*! + * Retrieves the requested set of auxiliary variables. + * + * @param start The index of the first auxiliary variable to include. + * @param end The index of the auxiliary variable past the end of the range to include. + * @return The set of auxiliary variables. + */ + std::set getAuxVariableSet(uint_fast64_t start, uint_fast64_t end) const; + + /*! + * Retrieves the number of auxiliary variables. + * + * @return The number of auxiliary variables. + */ + std::size_t getAuxVariableCount() const; + + /*! + * Retrieves the set of source meta variables. + * + * @return All source meta variables. + */ + std::set const& getSourceVariables() const; + + /*! + * Retrieves the set of successor meta variables. + * + * @return All successor meta variables. + */ + std::set const& getSuccessorVariables() const; + + /*! + * Retrieves the set of source predicate meta variables. + * + * @return All source predicate meta variables. + */ + std::set const& getSourcePredicateVariables() const; + + /*! + * Retrieves the set of successor predicate meta variables. + * + * @return All successor predicate meta variables. + */ + std::set const& getSuccessorPredicateVariables() const; + + /*! + * Retrieves a BDD representing the identities of all predicates. + * + * @return All predicate identities. + */ + storm::dd::Bdd const& getAllPredicateIdentities() const; + + /*! + * Retrieves a BDD representing the identities of all location variables. + * + * @return All location identities. + */ + storm::dd::Bdd const& getAllLocationIdentities() const; + + /*! + * Retrieves a mapping of the known predicates to the BDDs that represent the corresponding states. + * + * @return A mapping from predicates to their representing BDDs. + */ + std::map> const& getPredicateToBddMap() const; + + /*! + * Retrieves the meta variables pairs for all predicates. + * + * @return The meta variable pairs for all predicates. + */ + std::vector> const& getSourceSuccessorVariablePairs() const; + + /*! + * Retrieves the meta variables pairs for all predicates together with the meta variables marking the bottom states. + * + * @return The meta variable pairs for all predicates and bottom states. + */ + std::vector> const& getExtendedSourceSuccessorVariablePairs() const; + + /*! + * Retrieves the meta variable marking the bottom states. + * + * @param source A flag indicating whether the source or successor meta variable is to be returned. + * @return The meta variable marking the bottom states. + */ + storm::expressions::Variable const& getBottomStateVariable(bool source) const; + + /*! + * Retrieves the BDD that can be used to mark the bottom states. + * + * @param source A flag indicating whether the source or successor BDD is to be returned. + * @param negated A flag indicating whether the BDD should encode the bottom states or the non-bottom states. + * @return The BDD that can be used to mark bottom states. + */ + storm::dd::Bdd getBottomStateBdd(bool source, bool negated) const; + + /*! + * Retrieves the BDD for the predicate with the given index over the source variables. + * + * @param predicateIndex The index of the predicate. + * @return The encoding the predicate over the source variables. + */ + storm::dd::Bdd const& encodePredicateAsSource(uint_fast64_t predicateIndex) const; + + /*! + * Retrieves the BDD for the predicate with the given index over the successor variables. + * + * @param predicateIndex The index of the predicate. + * @return The encoding the predicate over the successor variables. + */ + storm::dd::Bdd const& encodePredicateAsSuccessor(uint_fast64_t predicateIndex) const; + + /*! + * Retrieves a BDD representing the identity for the predicate with the given index. + * + * @param predicateIndex The index of the predicate. + * @return The identity for the predicate. + */ + storm::dd::Bdd const& getPredicateIdentity(uint_fast64_t predicateIndex) const; + + /*! + * Retrieves the predicate associated with the given DD variable index. + * + * @param ddVariableIndex The DD variable index for which to retrieve the predicate. + * @return The predicate associated with the given DD variable index. + */ + storm::expressions::Expression const& getPredicateForDdVariableIndex(uint_fast64_t ddVariableIndex) const; + + /*! + * Declares new variables for the missing predicates. + * + * @param oldPredicates The old predicates. + * @param newPredicates The new predicates. + * @return A list of the missing variables together with the predicate index they represent. + */ + std::vector> declareNewVariables(std::vector> const& oldPredicates, std::set const& newPredicates) const; + + /*! + * Decodes the given state (given as a BDD over the source variables) into a a bit vector indicating the + * truth values of the predicates in the state. + */ + storm::storage::BitVector decodeState(storm::dd::Bdd const& state) const; + + /*! + * Decodes the choice in the form of a BDD over the destination variables. + */ + template + std::map> decodeChoiceToUpdateSuccessorMapping(storm::dd::Bdd const& choice) const; + + /*! + * Decodes the given BDD (over source, player 1 and aux variables) into a bit vector indicating the truth + * values of the predicates in the state and the choice/update indices. + */ + std::tuple decodeStatePlayer1ChoiceAndUpdate(storm::dd::Bdd const& stateChoiceAndUpdate) const; + + /*! + * Adds a location variable of appropriate range and returns the pair of meta variables. + */ + std::pair, uint64_t> addLocationVariables(storm::expressions::Variable const& locationExpressionVariable, uint64_t highestLocationIndex); + + /*! + * Retrieves the location variable with the given index as either source or successor. + */ + storm::expressions::Variable getLocationVariable(uint64_t locationVariableIndex, bool source) const; + + /*! + * Retrieves the source location variables. + */ + std::set const& getSourceLocationVariables() const; + + /*! + * Retrieves the source location variables. + */ + std::set const& getSuccessorLocationVariables() const; + + /*! + * Retrieves the DD variable for the given location expression variable. + */ + storm::expressions::Variable const& getDdLocationVariable(storm::expressions::Variable const& locationExpressionVariable, bool source); + + /*! + * Retrieves the source location variables. + */ + std::set const& getLocationExpressionVariables() const; + + /*! + * Encodes the given location index as either source or successor. + */ + storm::dd::Bdd encodeLocation(storm::expressions::Variable const& locationVariable, uint64_t locationIndex) const; + + protected: + /*! + * Retrieves the ordered collection of source predicate meta variables. + * + * @return All source meta variables. + */ + std::vector const& getOrderedSourcePredicateVariables() const; + + /*! + * Retrieves the ordered collection of successor predicate meta variables. + * + * @return All successor meta variables. + */ + std::vector const& getOrderedSuccessorPredicateVariables() const; + + /*! + * Encodes the given index with the given number of variables from the given variables. + * + * @param index The index to encode. + * @param start The index of the first variable to use for the encoding. + * @param end The index of the variable past the end of the range to use for the encoding. + * @param variables The BDDs of the variables to use to encode the index. + * @return The BDD encoding the index. + */ + storm::dd::Bdd encodeChoice(uint_fast64_t index, uint_fast64_t start, uint_fast64_t end, std::vector> const& variables) const; + + /*! + * Decodes the index encoded in the valuation using the given variables. + * + * @param valuation The valuation to decode. + * @param start The index of the first variable to use for the encoding. + * @param end The index of the variable past the end of the range to use for the encoding. + * @param variables The variables used to encode the index. + * @return The encoded index. + */ + uint_fast64_t decodeChoice(storm::expressions::Valuation const& valuation, uint_fast64_t start, uint_fast64_t end, std::vector const& variables) const; + + // The expression related data. + + /// The manager responsible for the expressions of the program and the SMT solvers. + std::reference_wrapper expressionManager; + + /// A mapping from predicates to their indices in the predicate list. + std::unordered_map predicateToIndexMap; + + /// An object that can detect equivalence of predicates. + storm::expressions::EquivalenceChecker equivalenceChecker; + + /// The current set of predicates used in the abstraction. + std::vector predicates; + + /// The set of all abstracted variables. + std::set abstractedVariables; + + /// The expressions characterizing legal variable values. + std::vector constraints; + + // The DD-related data. + + /// The manager responsible for the DDs. + std::shared_ptr> ddManager; + + /// The DD variables corresponding to the predicates. + std::vector> predicateDdVariables; + + /// The DD variables corresponding to the predicates together with the DD variables marking the bottom states. + std::vector> extendedPredicateDdVariables; + + /// The set of all source variables. + std::set sourceVariables; + + /// The set of all successor variables. + std::set successorVariables; + + /// The set of all source predicate variables. + std::set sourcePredicateVariables; + + /// The set of all successor predicate variables. + std::set successorPredicateVariables; + + /// An ordered collection of the source variables. + std::vector orderedSourcePredicateVariables; + + /// An ordered collection of the successor variables. + std::vector orderedSuccessorPredicateVariables; + + /// The BDDs corresponding to the predicates. + std::vector, storm::dd::Bdd>> predicateBdds; + + /// The BDDs representing the predicate identities (i.e. source and successor variable have the same truth value). + std::vector> predicateIdentities; + + /// A BDD that represents the identity of all predicate variables. + storm::dd::Bdd allPredicateIdentities; + + /// A BDD that represents the identity of all location variables. + storm::dd::Bdd allLocationIdentities; + + /// A meta variable pair that marks bottom states. + std::pair bottomStateVariables; + + /// The BDDs associated with the bottom state variable pair. + std::pair, storm::dd::Bdd> bottomStateBdds; + + /// A mapping from DD variable indices to the predicate index they represent. + std::unordered_map ddVariableIndexToPredicateIndexMap; + + /// Variables that encode the choices of player 1. + std::vector player1Variables; + + /// The BDDs associated with the meta variables of player 1. + std::vector> player1VariableBdds; + + /// Variables that encode the choices of player 2. + std::vector player2Variables; + + /// The BDDs associated with the meta variables of player 2. + std::vector> player2VariableBdds; + + /// Variables that can be used to encode auxiliary information. + std::vector auxVariables; + + /// The BDDs associated with the meta variables encoding auxiliary information. + std::vector> auxVariableBdds; + + /// A mapping from expressions to the corresponding BDDs. + std::map> expressionToBddMap; + + /// The location variable pairs (source/successor). + std::vector> locationVariablePairs; + + /// A mapping from location expression variables to their source/successor counterparts. + std::map> locationExpressionToDdVariableMap; + + /// The set of all location expression variables. + std::set locationExpressionVariables; + + // All source location variables. + std::set allSourceLocationVariables; + + // All successor location variables. + std::set allSuccessorLocationVariables; + + }; + + } +} diff --git a/src/storm/abstraction/BottomStateResult.cpp b/src/storm/abstraction/BottomStateResult.cpp new file mode 100644 index 000000000..a5f9576af --- /dev/null +++ b/src/storm/abstraction/BottomStateResult.cpp @@ -0,0 +1,14 @@ +#include "storm/abstraction/BottomStateResult.h" + +namespace storm { + namespace abstraction { + + template + BottomStateResult::BottomStateResult(storm::dd::Bdd const& states, storm::dd::Bdd const& transitions) : states(states), transitions(transitions) { + // Intentionally left empty. + } + + template class BottomStateResult; + template class BottomStateResult; + } +} diff --git a/src/storm/abstraction/BottomStateResult.h b/src/storm/abstraction/BottomStateResult.h new file mode 100644 index 000000000..e5b158c14 --- /dev/null +++ b/src/storm/abstraction/BottomStateResult.h @@ -0,0 +1,19 @@ +#pragma once + +#include "storm/storage/dd/DdType.h" +#include "storm/storage/dd/Bdd.h" + +namespace storm { + namespace abstraction { + + template + struct BottomStateResult { + public: + BottomStateResult(storm::dd::Bdd const& states, storm::dd::Bdd const& transitions); + + storm::dd::Bdd states; + storm::dd::Bdd transitions; + }; + + } +} diff --git a/src/storm/abstraction/ExpressionTranslator.cpp b/src/storm/abstraction/ExpressionTranslator.cpp new file mode 100644 index 000000000..fe2d28f97 --- /dev/null +++ b/src/storm/abstraction/ExpressionTranslator.cpp @@ -0,0 +1,198 @@ +#include "storm/abstraction/ExpressionTranslator.h" + +#include "storm/abstraction/AbstractionInformation.h" + +#include "storm/storage/dd/DdManager.h" +#include "storm/storage/dd/Bdd.h" + +#include "storm/storage/expressions/Expression.h" + +#include "storm/utility/macros.h" +#include "storm/exceptions/NotSupportedException.h" + +namespace storm { + namespace abstraction { + + using namespace storm::expressions; + + template + ExpressionTranslator::ExpressionTranslator(AbstractionInformation& abstractionInformation, std::unique_ptr&& smtSolver) : abstractionInformation(abstractionInformation), equivalenceChecker(std::move(smtSolver)), locationVariables(abstractionInformation.getLocationExpressionVariables()), abstractedVariables(abstractionInformation.getAbstractedVariables()) { + // Intentionally left empty. + } + + template + storm::dd::Bdd ExpressionTranslator::translate(storm::expressions::Expression const& expression) { + return boost::any_cast>(expression.accept(*this, boost::none)); + } + + template + boost::any ExpressionTranslator::visit(IfThenElseExpression const&, boost::any const&) { + STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Expressions of this kind are currently not supported by the abstraction expression translator."); + } + + template + boost::any ExpressionTranslator::visit(BinaryBooleanFunctionExpression const& expression, boost::any const& data) { + // Check whether the expression is either fully contained in the location variables fragment or the abstracted + // variables fragment. + std::set variablesInExpression; + expression.gatherVariables(variablesInExpression); + + std::set tmp; + std::set_intersection(variablesInExpression.begin(), variablesInExpression.end(), locationVariables.begin(), locationVariables.end(), std::inserter(tmp, tmp.begin())); + bool hasLocationVariables = !tmp.empty(); + + tmp.clear(); + std::set_intersection(variablesInExpression.begin(), variablesInExpression.end(), abstractedVariables.begin(), abstractedVariables.end(), std::inserter(tmp, tmp.begin())); + bool hasAbstractedVariables = !tmp.empty(); + + STORM_LOG_THROW(hasLocationVariables || hasAbstractedVariables, storm::exceptions::NotSupportedException, "Expressions without variables are currently not supported by the abstraction expression translator."); + + if (hasAbstractedVariables && !hasLocationVariables) { + for (uint64_t predicateIndex = 0; predicateIndex < abstractionInformation.get().getNumberOfPredicates(); ++predicateIndex) { + if (equivalenceChecker.areEquivalent(abstractionInformation.get().getPredicateByIndex(predicateIndex), expression.toExpression())) { + return abstractionInformation.get().encodePredicateAsSource(predicateIndex); + } + } + + // At this point, none of the predicates was found to be equivalent, so we split the expression. + } + + storm::dd::Bdd left = boost::any_cast>(expression.getFirstOperand()->accept(*this, data)); + storm::dd::Bdd right = boost::any_cast>(expression.getSecondOperand()->accept(*this, data)); + switch (expression.getOperatorType()) { + case BinaryBooleanFunctionExpression::OperatorType::And: return left && right; + case BinaryBooleanFunctionExpression::OperatorType::Or: return left || right; + case BinaryBooleanFunctionExpression::OperatorType::Xor: return left.exclusiveOr(right); + case BinaryBooleanFunctionExpression::OperatorType::Implies: return !left || right; + case BinaryBooleanFunctionExpression::OperatorType::Iff: return (left && right) || (!left && !right); + } + return boost::any(); + } + + template + boost::any ExpressionTranslator::visit(BinaryNumericalFunctionExpression const&, boost::any const&) { + STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Expressions of this kind are currently not supported by the abstraction expression translator."); + } + + template + boost::any ExpressionTranslator::visit(BinaryRelationExpression const& expression, boost::any const& data) { + // Check whether the expression is either fully contained in the location variables fragment or the abstracted + // variables fragment. + std::set variablesInExpression; + expression.gatherVariables(variablesInExpression); + + std::set tmp; + std::set_intersection(variablesInExpression.begin(), variablesInExpression.end(), locationVariables.begin(), locationVariables.end(), std::inserter(tmp, tmp.begin())); + bool hasLocationVariables = !tmp.empty(); + + tmp.clear(); + std::set_intersection(variablesInExpression.begin(), variablesInExpression.end(), abstractedVariables.begin(), abstractedVariables.end(), std::inserter(tmp, tmp.begin())); + bool hasAbstractedVariables = !tmp.empty(); + + STORM_LOG_THROW(hasLocationVariables || hasAbstractedVariables, storm::exceptions::NotSupportedException, "Expressions without variables are currently not supported by the abstraction expression translator."); + STORM_LOG_THROW(!hasLocationVariables || !hasAbstractedVariables, storm::exceptions::NotSupportedException, "Expressions with two types (location variables and abstracted variables) of variables are currently not supported by the abstraction expression translator."); + + if (hasLocationVariables) { + storm::dd::Add left = boost::any_cast>(expression.getFirstOperand()->accept(*this, data)); + storm::dd::Add right = boost::any_cast>(expression.getSecondOperand()->accept(*this, data)); + + switch (expression.getRelationType()) { + case BinaryRelationExpression::RelationType::Equal: return left.equals(right); + case BinaryRelationExpression::RelationType::NotEqual: return left.notEquals(right); + case BinaryRelationExpression::RelationType::Less: return left.less(right); + case BinaryRelationExpression::RelationType::LessOrEqual: return left.lessOrEqual(right); + case BinaryRelationExpression::RelationType::Greater: return left.greater(right); + case BinaryRelationExpression::RelationType::GreaterOrEqual: return left.greaterOrEqual(right); + } + } else { + for (uint64_t predicateIndex = 0; predicateIndex < abstractionInformation.get().getNumberOfPredicates(); ++predicateIndex) { + if (equivalenceChecker.areEquivalent(abstractionInformation.get().getPredicateByIndex(predicateIndex), expression.toExpression())) { + return abstractionInformation.get().encodePredicateAsSource(predicateIndex); + } + } + + // At this point, none of the predicates was found to be equivalent, but there is no need to split as the subexpressions are not valid predicates. + + STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Expressions of this kind are currently not supported by the abstraction expression translator."); + } + return boost::any(); + } + + template + boost::any ExpressionTranslator::visit(VariableExpression const& expression, boost::any const&) { + if (abstractedVariables.find(expression.getVariable()) != abstractedVariables.end()) { + for (uint64_t predicateIndex = 0; predicateIndex < abstractionInformation.get().getNumberOfPredicates(); ++predicateIndex) { + if (equivalenceChecker.areEquivalent(abstractionInformation.get().getPredicateByIndex(predicateIndex), expression.toExpression())) { + return abstractionInformation.get().encodePredicateAsSource(predicateIndex); + } + } + + STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Expressions of this kind are currently not supported by the abstraction expression translator."); + } else { + return abstractionInformation.get().getDdManager().template getIdentity(abstractionInformation.get().getDdLocationVariable(expression.getVariable(), true)); + } + } + + template + boost::any ExpressionTranslator::visit(UnaryBooleanFunctionExpression const& expression, boost::any const& data) { + // Check whether the expression is either fully contained in the location variables fragment or the abstracted + // variables fragment. + std::set variablesInExpression; + expression.gatherVariables(variablesInExpression); + + std::set tmp; + std::set_intersection(variablesInExpression.begin(), variablesInExpression.end(), locationVariables.begin(), locationVariables.end(), std::inserter(tmp, tmp.begin())); + bool hasLocationVariables = !tmp.empty(); + + tmp.clear(); + std::set_intersection(variablesInExpression.begin(), variablesInExpression.end(), abstractedVariables.begin(), abstractedVariables.end(), std::inserter(tmp, tmp.begin())); + bool hasAbstractedVariables = !tmp.empty(); + + STORM_LOG_THROW(hasLocationVariables || hasAbstractedVariables, storm::exceptions::NotSupportedException, "Expressions without variables are currently not supported by the abstraction expression translator."); + + if (hasAbstractedVariables && !hasLocationVariables) { + for (uint64_t predicateIndex = 0; predicateIndex < abstractionInformation.get().getNumberOfPredicates(); ++predicateIndex) { + if (equivalenceChecker.areEquivalent(abstractionInformation.get().getPredicateByIndex(predicateIndex), expression.toExpression())) { + return abstractionInformation.get().encodePredicateAsSource(predicateIndex); + } + } + + // At this point, none of the predicates was found to be equivalent, so we split the expression. + } + + storm::dd::Bdd sub = boost::any_cast>(expression.getOperand()->accept(*this, data)); + switch (expression.getOperatorType()) { + case UnaryBooleanFunctionExpression::OperatorType::Not: return !sub; + } + return boost::any(); + } + + template + boost::any ExpressionTranslator::visit(UnaryNumericalFunctionExpression const&, boost::any const&) { + STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Expressions of this kind are currently not supported by the abstraction expression translator."); + } + + template + boost::any ExpressionTranslator::visit(BooleanLiteralExpression const& expression, boost::any const&) { + if (expression.isTrue()) { + return abstractionInformation.get().getDdManager().getBddOne(); + } else { + return abstractionInformation.get().getDdManager().getBddZero(); + } + } + + template + boost::any ExpressionTranslator::visit(IntegerLiteralExpression const& expression, boost::any const&) { + return abstractionInformation.get().getDdManager().template getConstant(expression.getValue()); + } + + template + boost::any ExpressionTranslator::visit(RationalLiteralExpression const&, boost::any const&) { + STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Expressions of this kind are currently not supported by the abstraction expression translator."); + } + + template class ExpressionTranslator; + template class ExpressionTranslator; + + } +} diff --git a/src/storm/abstraction/ExpressionTranslator.h b/src/storm/abstraction/ExpressionTranslator.h new file mode 100644 index 000000000..3516e5a34 --- /dev/null +++ b/src/storm/abstraction/ExpressionTranslator.h @@ -0,0 +1,53 @@ +#pragma once + +#include + +#include "storm/storage/dd/DdType.h" +#include "storm/storage/expressions/ExpressionVisitor.h" +#include "storm/storage/expressions/EquivalenceChecker.h" + +#include "storm/solver/SmtSolver.h" + +namespace storm { + namespace dd { + template + class Bdd; + } + + namespace expressions { + class Expression; + } + + namespace abstraction { + + template + class AbstractionInformation; + + template + class ExpressionTranslator : public storm::expressions::ExpressionVisitor { + public: + ExpressionTranslator(AbstractionInformation& abstractionInformation, std::unique_ptr&& smtSolver); + + storm::dd::Bdd translate(storm::expressions::Expression const& expression); + + virtual boost::any visit(storm::expressions::IfThenElseExpression const& expression, boost::any const& data); + virtual boost::any visit(storm::expressions::BinaryBooleanFunctionExpression const& expression, boost::any const& data); + virtual boost::any visit(storm::expressions::BinaryNumericalFunctionExpression const& expression, boost::any const& data); + virtual boost::any visit(storm::expressions::BinaryRelationExpression const& expression, boost::any const& data); + virtual boost::any visit(storm::expressions::VariableExpression const& expression, boost::any const& data); + virtual boost::any visit(storm::expressions::UnaryBooleanFunctionExpression const& expression, boost::any const& data); + virtual boost::any visit(storm::expressions::UnaryNumericalFunctionExpression const& expression, boost::any const& data); + virtual boost::any visit(storm::expressions::BooleanLiteralExpression const& expression, boost::any const& data); + virtual boost::any visit(storm::expressions::IntegerLiteralExpression const& expression, boost::any const& data); + virtual boost::any visit(storm::expressions::RationalLiteralExpression const& expression, boost::any const& data); + + private: + std::reference_wrapper> abstractionInformation; + storm::expressions::EquivalenceChecker equivalenceChecker; + + std::set locationVariables; + std::set abstractedVariables; + }; + + } +} diff --git a/src/storm/abstraction/GameBddResult.cpp b/src/storm/abstraction/GameBddResult.cpp new file mode 100644 index 000000000..87aaeaee8 --- /dev/null +++ b/src/storm/abstraction/GameBddResult.cpp @@ -0,0 +1,20 @@ +#include "storm/abstraction/GameBddResult.h" + +namespace storm { + namespace abstraction { + + template + GameBddResult::GameBddResult() : bdd(), numberOfPlayer2Variables(0) { + // Intentionally left empty. + } + + template + GameBddResult::GameBddResult(storm::dd::Bdd const& gameBdd, uint_fast64_t numberOfPlayer2Variables) : bdd(gameBdd), numberOfPlayer2Variables(numberOfPlayer2Variables) { + // Intentionally left empty. + } + + template class GameBddResult; + template class GameBddResult; + + } +} diff --git a/src/storm/abstraction/GameBddResult.h b/src/storm/abstraction/GameBddResult.h new file mode 100644 index 000000000..84ecbcd80 --- /dev/null +++ b/src/storm/abstraction/GameBddResult.h @@ -0,0 +1,18 @@ +#pragma once + +#include "storm/storage/dd/Bdd.h" + +namespace storm { + namespace abstraction { + + template + struct GameBddResult { + GameBddResult(); + GameBddResult(storm::dd::Bdd const& gameBdd, uint_fast64_t numberOfPlayer2Variables); + + storm::dd::Bdd bdd; + uint_fast64_t numberOfPlayer2Variables; + }; + + } +} diff --git a/src/storm/abstraction/LocalExpressionInformation.cpp b/src/storm/abstraction/LocalExpressionInformation.cpp new file mode 100644 index 000000000..6d6231a1e --- /dev/null +++ b/src/storm/abstraction/LocalExpressionInformation.cpp @@ -0,0 +1,232 @@ +#include "storm/abstraction/LocalExpressionInformation.h" + +#include "storm/abstraction/AbstractionInformation.h" + +#include + +#include "storm/utility/macros.h" + +namespace storm { + namespace abstraction { + + template + LocalExpressionInformation::LocalExpressionInformation(AbstractionInformation const& abstractionInformation) : relevantVariables(abstractionInformation.getAbstractedVariables()), expressionBlocks(relevantVariables.size()), abstractionInformation(abstractionInformation) { + // Assign each variable to a new block. + uint_fast64_t currentBlock = 0; + variableBlocks.resize(relevantVariables.size()); + for (auto const& variable : relevantVariables) { + this->variableToBlockMapping[variable] = currentBlock; + this->variableToExpressionsMapping[variable] = std::set(); + variableBlocks[currentBlock].insert(variable); + ++currentBlock; + } + } + + template + std::map LocalExpressionInformation::addExpression(uint_fast64_t globalExpressionIndex) { + storm::expressions::Expression const& expression = abstractionInformation.get().getPredicateByIndex(globalExpressionIndex); + + // Register the expression for all variables that appear in it. + std::set expressionVariables = expression.getVariables(); + for (auto const& variable : expressionVariables) { + variableToExpressionsMapping[variable].insert(globalExpressionIndex); + } + + // Add the expression to the block of the first variable. When relating the variables, the blocks will + // get merged (if necessary). + STORM_LOG_ASSERT(!expressionVariables.empty(), "Found no variables in expression."); + expressionBlocks[getBlockIndexOfVariable(*expressionVariables.begin())].insert(globalExpressionIndex); + + // Add expression and relate all the appearing variables. + return this->relate(expressionVariables); + } + + template + bool LocalExpressionInformation::areRelated(storm::expressions::Variable const& firstVariable, storm::expressions::Variable const& secondVariable) { + return getBlockIndexOfVariable(firstVariable) == getBlockIndexOfVariable(secondVariable); + } + + template + std::map LocalExpressionInformation::relate(storm::expressions::Variable const& firstVariable, storm::expressions::Variable const& secondVariable) { + return this->relate({firstVariable, secondVariable}); + } + + template + std::map LocalExpressionInformation::relate(std::set const& variables) { + // Determine all blocks that need to be merged. + std::set blocksToMerge; + for (auto const& variable : variables) { + blocksToMerge.insert(getBlockIndexOfVariable(variable)); + } + + STORM_LOG_ASSERT(variables.empty() || !blocksToMerge.empty(), "Found no blocks to merge."); + + // If we found a single block only, there is nothing to do. + if (blocksToMerge.size() <= 1) { + std::map identity; + for (uint64_t i = 0; i < getNumberOfBlocks(); ++i) { + identity.emplace_hint(identity.end(), i, i); + } + return identity; + } + + return this->mergeBlocks(blocksToMerge); + } + + template + std::map LocalExpressionInformation::mergeBlocks(std::set const& blocksToMerge) { + std::map oldToNewIndices; + + // Merge all blocks into the block to keep. + std::vector> newVariableBlocks; + std::vector> newExpressionBlocks; + + std::set::const_iterator blocksToMergeIt = blocksToMerge.begin(); + std::set::const_iterator blocksToMergeIte = blocksToMerge.end(); + + // Determine which block to keep (to merge the other blocks into). + uint_fast64_t blockToKeep = *blocksToMergeIt; + ++blocksToMergeIt; + + for (uint_fast64_t blockIndex = 0; blockIndex < variableBlocks.size(); ++blockIndex) { + // If the block is the next one to merge into the block to keep, do so now. + if (blocksToMergeIt != blocksToMergeIte && *blocksToMergeIt == blockIndex && blockIndex != blockToKeep) { + // Adjust the mapping for all variables of the old block. + for (auto const& variable : variableBlocks[blockIndex]) { + variableToBlockMapping[variable] = blockToKeep; + } + oldToNewIndices[blockIndex] = blockToKeep; + + newVariableBlocks[blockToKeep].insert(variableBlocks[blockIndex].begin(), variableBlocks[blockIndex].end()); + newExpressionBlocks[blockToKeep].insert(expressionBlocks[blockIndex].begin(), expressionBlocks[blockIndex].end()); + ++blocksToMergeIt; + } else { + // Otherwise just move the current block to the new partition. + oldToNewIndices[blockIndex] = newVariableBlocks.size(); + + // Adjust the mapping for all variables of the old block. + for (auto const& variable : variableBlocks[blockIndex]) { + variableToBlockMapping[variable] = newVariableBlocks.size(); + } + + newVariableBlocks.emplace_back(std::move(variableBlocks[blockIndex])); + newExpressionBlocks.emplace_back(std::move(expressionBlocks[blockIndex])); + } + } + + variableBlocks = std::move(newVariableBlocks); + expressionBlocks = std::move(newExpressionBlocks); + + return oldToNewIndices; + } + + template + std::set const& LocalExpressionInformation::getBlockOfVariable(storm::expressions::Variable const& variable) const { + return variableBlocks[getBlockIndexOfVariable(variable)]; + } + + template + uint_fast64_t LocalExpressionInformation::getNumberOfBlocks() const { + return this->variableBlocks.size(); + } + + template + std::set const& LocalExpressionInformation::getVariableBlockWithIndex(uint_fast64_t blockIndex) const { + return this->variableBlocks[blockIndex]; + } + + template + uint_fast64_t LocalExpressionInformation::getBlockIndexOfVariable(storm::expressions::Variable const& variable) const { + STORM_LOG_ASSERT(this->relevantVariables.find(variable) != this->relevantVariables.end(), "Illegal variable '" << variable.getName() << "' for partition."); + return this->variableToBlockMapping.find(variable)->second; + } + + template + std::set LocalExpressionInformation::getBlockIndicesOfVariables(std::set const& variables) const { + std::set result; + for (auto const& variable : variables) { + result.insert(getBlockIndexOfVariable(variable)); + } + return result; + } + + template + std::set const& LocalExpressionInformation::getRelatedExpressions(storm::expressions::Variable const& variable) const { + return this->expressionBlocks[getBlockIndexOfVariable(variable)]; + } + + template + std::set LocalExpressionInformation::getRelatedExpressions(std::set const& variables) const { + // Start by determining the indices of all expression blocks that are related to any of the variables. + std::set relatedExpressionBlockIndices; + for (auto const& variable : variables) { + relatedExpressionBlockIndices.insert(getBlockIndexOfVariable(variable)); + } + + // Then join the expressions of these blocks and return the result. + std::set result; + for (auto const& blockIndex : relatedExpressionBlockIndices) { + result.insert(expressionBlocks[blockIndex].begin(), expressionBlocks[blockIndex].end()); + } + return result; + } + + template + std::set const& LocalExpressionInformation::getExpressionsUsingVariable(storm::expressions::Variable const& variable) const { + STORM_LOG_ASSERT(this->relevantVariables.find(variable) != this->relevantVariables.end(), "Illegal variable '" << variable.getName() << "' for partition."); + return this->variableToExpressionsMapping.find(variable)->second; + } + + template + std::set LocalExpressionInformation::getExpressionsUsingVariables(std::set const& variables) const { + std::set result; + + for (auto const& variable : variables) { + STORM_LOG_ASSERT(this->relevantVariables.find(variable) != this->relevantVariables.end(), "Illegal variable '" << variable.getName() << "' for partition."); + auto it = this->variableToExpressionsMapping.find(variable); + result.insert(it->second.begin(), it->second.end()); + } + + return result; + } + + template + std::set const& LocalExpressionInformation::getExpressionBlock(uint64_t index) const { + return expressionBlocks[index]; + } + + template + std::ostream& operator<<(std::ostream& out, LocalExpressionInformation const& partition) { + std::vector blocks; + for (uint_fast64_t index = 0; index < partition.variableBlocks.size(); ++index) { + auto const& variableBlock = partition.variableBlocks[index]; + auto const& expressionBlock = partition.expressionBlocks[index]; + + std::vector variablesInBlock; + for (auto const& variable : variableBlock) { + variablesInBlock.push_back(variable.getName()); + } + + std::vector expressionsInBlock; + for (auto const& expressionIndex : expressionBlock) { + std::stringstream stream; + stream << partition.abstractionInformation.get().getPredicateByIndex(expressionIndex); + expressionsInBlock.push_back(stream.str()); + } + + blocks.push_back("<[" + boost::algorithm::join(variablesInBlock, ", ") + "], [" + boost::algorithm::join(expressionsInBlock, ", ") + "]>"); + } + + out << "{"; + out << boost::join(blocks, ", "); + out << "}"; + return out; + } + + template class LocalExpressionInformation; + template class LocalExpressionInformation; + + template std::ostream& operator<<(std::ostream& out, LocalExpressionInformation const& partition); + template std::ostream& operator<<(std::ostream& out, LocalExpressionInformation const& partition); + } +} diff --git a/src/storm/abstraction/LocalExpressionInformation.h b/src/storm/abstraction/LocalExpressionInformation.h new file mode 100644 index 000000000..52827f8de --- /dev/null +++ b/src/storm/abstraction/LocalExpressionInformation.h @@ -0,0 +1,176 @@ +#pragma once + +#include +#include +#include +#include + +#include "storm/storage/expressions/Variable.h" +#include "storm/storage/expressions/Expression.h" + +#include "storm/storage/dd/DdType.h" + +namespace storm { + namespace abstraction { + + template + class AbstractionInformation; + + template + class LocalExpressionInformation { + public: + /*! + * Constructs a new variable partition. + * + * @param abstractionInformation The object storing global information about the abstraction. + */ + LocalExpressionInformation(AbstractionInformation const& abstractionInformation); + + /*! + * Adds the expression and therefore indirectly may cause blocks of variables to be merged. + * + * @param globalExpressionIndex The global index of the expression. + * @return A mapping from old block indices to the new ones (after possible merges). + */ + std::map addExpression(uint_fast64_t globalExpressionIndex); + + /*! + * Retrieves whether the two given variables are in the same block of the partition. + * + * @param firstVariable The first variable. + * @param secondVariable The second variable. + * @return True iff the two variables are in the same block. + */ + bool areRelated(storm::expressions::Variable const& firstVariable, storm::expressions::Variable const& secondVariable); + + /*! + * Places the given variables in the same block of the partition and performs the implied merges. + * + * @param firstVariable The first variable. + * @param secondVariable The second variable. + * @return A mapping from old block indices to the new ones (after possible merges). + */ + std::map relate(storm::expressions::Variable const& firstVariable, storm::expressions::Variable const& secondVariable); + + /*! + * Places the given variables in the same block of the partition and performs the implied merges. + * + * @param variables The variables to relate. + * @return A mapping from old block indices to the new ones (after possible merges). + */ + std::map relate(std::set const& variables); + + /*! + * Retrieves the block of related variables of the given variable. + * + * @param variable The variable whose block to retrieve. + * @return The block of the variable. + */ + std::set const& getBlockOfVariable(storm::expressions::Variable const& variable) const; + + /*! + * Retrieves the block index of the given variable. + * + * @param variable The variable for which to retrieve the block. + * @return The block index of the given variable. + */ + uint_fast64_t getBlockIndexOfVariable(storm::expressions::Variable const& variable) const; + + /*! + * Retrieves the block indices of the given variables. + * + * @param variables The variables for which to retrieve the blocks. + * @return The block indices of the given variables. + */ + std::set getBlockIndicesOfVariables(std::set const& variables) const; + + /*! + * Retrieves the number of blocks of the variable partition. + * + * @return The number of blocks in this partition. + */ + uint_fast64_t getNumberOfBlocks() const; + + /*! + * Retrieves the block with the given index. + * + * @param blockIndex The index of the block to retrieve. + * @return The block with the given index. + */ + std::set const& getVariableBlockWithIndex(uint_fast64_t blockIndex) const; + + /*! + * Retrieves the indices of the expressions related to the given variable. + * + * @param variable The variable for which to retrieve the related expressions. + * @return The related expressions. + */ + std::set const& getRelatedExpressions(storm::expressions::Variable const& variable) const; + + /*! + * Retrieves the indices of the expressions related to any of the given variables. + * + * @param variables The variables for which to retrieve the related expressions. + * @return The related expressions. + */ + std::set getRelatedExpressions(std::set const& variables) const; + + /*! + * Retrieves the indices of the expressions in which the given variable appears. + * + * @param variable The variable for which to retrieve the expressions. + * @return The indices of all expressions using the given variable. + */ + std::set const& getExpressionsUsingVariable(storm::expressions::Variable const& variable) const; + + /*! + * Retrieves the indices of the expressions in which the given variables appear. + * + * @param variables The variables for which to retrieve the expressions. + * @return The indices of all expressions using the given variables. + */ + std::set getExpressionsUsingVariables(std::set const& variables) const; + + /*! + * Retrieves the expression block with the given index. + * + * @return The requested expression block. + */ + std::set const& getExpressionBlock(uint64_t index) const; + + template + friend std::ostream& operator<<(std::ostream& out, LocalExpressionInformation const& partition); + + private: + /*! + * Merges the blocks with the given indices. + * + * @param blocksToMerge The indices of the blocks to merge. + * @return A mapping from old block indices to the new ones (after possible merges). + */ + std::map mergeBlocks(std::set const& blocksToMerge); + + // The set of variables relevant for this partition. + std::set relevantVariables; + + // A mapping from variables to their blocks. + std::unordered_map variableToBlockMapping; + + // The variable blocks of the partition. + std::vector> variableBlocks; + + // The expression blocks of the partition. + std::vector> expressionBlocks; + + // A mapping from variables to the indices of all expressions they appear in. + std::unordered_map> variableToExpressionsMapping; + + // The object storing the abstraction information. + std::reference_wrapper const> abstractionInformation; + }; + + template + std::ostream& operator<<(std::ostream& out, LocalExpressionInformation const& partition); + + } +} diff --git a/src/storm/abstraction/MenuGame.cpp b/src/storm/abstraction/MenuGame.cpp new file mode 100644 index 000000000..799003820 --- /dev/null +++ b/src/storm/abstraction/MenuGame.cpp @@ -0,0 +1,90 @@ +#include "storm/abstraction/MenuGame.h" + +#include "storm/exceptions/InvalidOperationException.h" +#include "storm/exceptions/InvalidArgumentException.h" + +#include "storm/storage/dd/Bdd.h" +#include "storm/storage/dd/Add.h" +#include "storm/storage/dd/DdManager.h" + +#include "storm/models/symbolic/StandardRewardModel.h" + +#include "storm-config.h" +#include "storm/adapters/CarlAdapter.h" + +namespace storm { + namespace abstraction { + + template + MenuGame::MenuGame(std::shared_ptr> manager, + storm::dd::Bdd reachableStates, + storm::dd::Bdd initialStates, + storm::dd::Bdd deadlockStates, + storm::dd::Add transitionMatrix, + storm::dd::Bdd bottomStates, + std::set const& rowVariables, + std::set const& columnVariables, + std::vector> const& rowColumnMetaVariablePairs, + std::set const& player1Variables, + std::set const& player2Variables, + std::set const& allNondeterminismVariables, + std::set const& probabilisticBranchingVariables, + std::map> const& expressionToBddMap) : storm::models::symbolic::StochasticTwoPlayerGame(manager, reachableStates, initialStates, deadlockStates, transitionMatrix.sumAbstract(probabilisticBranchingVariables), rowVariables, nullptr, columnVariables, nullptr, rowColumnMetaVariablePairs, player1Variables, player2Variables, allNondeterminismVariables), extendedTransitionMatrix(transitionMatrix), probabilisticBranchingVariables(probabilisticBranchingVariables), expressionToBddMap(expressionToBddMap), bottomStates(bottomStates) { + // Intentionally left empty. + } + + template + storm::dd::Bdd MenuGame::getStates(std::string const&) const { + STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Menu games do not provide labels."); + } + + template + storm::dd::Bdd MenuGame::getStates(storm::expressions::Expression const& expression) const { + return this->getStates(expression, false); + } + + template + storm::dd::Bdd MenuGame::getStates(storm::expressions::Expression const& expression, bool negated) const { + if (expression.isTrue()) { + return this->getReachableStates(); + } else if (expression.isFalse()) { + return this->getManager().getBddZero(); + } + + auto it = expressionToBddMap.find(expression); + STORM_LOG_THROW(it != expressionToBddMap.end(), storm::exceptions::InvalidArgumentException, "The given expression was not used in the abstraction process and can therefore not be retrieved."); + if (negated) { + return !it->second && this->getReachableStates(); + } else { + return it->second && this->getReachableStates(); + } + } + + template + storm::dd::Bdd MenuGame::getBottomStates() const { + return bottomStates; + } + + template + storm::dd::Add const& MenuGame::getExtendedTransitionMatrix() const { + return extendedTransitionMatrix; + } + + template + std::set const& MenuGame::getProbabilisticBranchingVariables() const { + return probabilisticBranchingVariables; + } + + template + bool MenuGame::hasLabel(std::string const&) const { + return false; + } + + template class MenuGame; + template class MenuGame; +#ifdef STORM_HAVE_CARL + template class MenuGame; +#endif + } +} + diff --git a/src/storm/abstraction/MenuGame.h b/src/storm/abstraction/MenuGame.h new file mode 100644 index 000000000..2cc45ba25 --- /dev/null +++ b/src/storm/abstraction/MenuGame.h @@ -0,0 +1,120 @@ +#pragma once + +#include + +#include "storm/models/symbolic/StochasticTwoPlayerGame.h" + +#include "storm/utility/OsDetection.h" + +namespace storm { + namespace abstraction { + + /*! + * This class represents a discrete-time stochastic two-player game. + */ + template + class MenuGame : public storm::models::symbolic::StochasticTwoPlayerGame { + public: + typedef typename storm::models::symbolic::StochasticTwoPlayerGame::RewardModelType RewardModelType; + + MenuGame(MenuGame const& other) = default; + MenuGame& operator=(MenuGame const& other) = default; + MenuGame(MenuGame&& other) = default; + MenuGame& operator=(MenuGame&& other) = default; + + /*! + * Constructs a model from the given data. + * + * @param manager The manager responsible for the decision diagrams. + * @param reachableStates The reachable states of the model. + * @param initialStates The initial states of the model. + * @param deadlockStates The deadlock states of the model. + * @param transitionMatrix The matrix representing the transitions in the model. + * @param bottomStates The bottom states of the model. + * @param rowVariables The set of row meta variables used in the DDs. + * @param columVariables The set of column meta variables used in the DDs. + * @param rowColumnMetaVariablePairs All pairs of row/column meta variables. + * @param player1Variables The meta variables used to encode the nondeterministic choices of player 1. + * @param player2Variables The meta variables used to encode the nondeterministic choices of player 2. + * @param allNondeterminismVariables The meta variables used to encode the nondeterminism in the model. + * @param probabilisticBranchingVariables The variables used to encode probabilistic branching. + * @param expressionToBddMap A mapping from expressions (used) in the abstraction to the BDDs encoding + * them. + */ + MenuGame(std::shared_ptr> manager, + storm::dd::Bdd reachableStates, + storm::dd::Bdd initialStates, + storm::dd::Bdd deadlockStates, + storm::dd::Add transitionMatrix, + storm::dd::Bdd bottomStates, + std::set const& rowVariables, + std::set const& columnVariables, + std::vector> const& rowColumnMetaVariablePairs, + std::set const& player1Variables, + std::set const& player2Variables, + std::set const& allNondeterminismVariables, + std::set const& probabilisticBranchingVariables, + std::map> const& expressionToBddMap); + + virtual storm::dd::Bdd getStates(std::string const& label) const override; + + /*! + * Returns the set of states satisfying the given expression (that must be of boolean type). Note that + * for menu games, the given expression must be a predicate that was used to build the abstract game. + * + * @param expression The expression that needs to hold in the states. + * @return The set of states satisfying the given expression. + */ + virtual storm::dd::Bdd getStates(storm::expressions::Expression const& expression) const override; + + /*! + * Returns the set of states satisfying the given expression (that must be of boolean type). Note that + * for menu games, the given expression must be a predicate that was used to build the abstract game. + * + * @param expression The expression that needs to hold in the states. + * @param negated If set to true, the result is the set of states not satisfying the expression. + * @return The set of states labeled satisfying the given expression. + */ + storm::dd::Bdd getStates(storm::expressions::Expression const& expression, bool negated) const; + + /*! + * Retrieves the bottom states of the model. + * + * @return The bottom states of the model. + */ + storm::dd::Bdd getBottomStates() const; + + /*! + * Retrieves the transition matrix extended by variables that encode additional information for the + * probabilistic branching. + * + * @reutrn Th extended transition matrix. + */ + storm::dd::Add const& getExtendedTransitionMatrix() const; + + /*! + * Retrieves the variables used to encode additional information for the probabilistic branching in the + * extended transition matrix. + * + * @return The probabilistic branching variables. + */ + std::set const& getProbabilisticBranchingVariables() const; + + virtual bool hasLabel(std::string const& label) const override; + + private: + // The transition relation extended byt the probabilistic branching variables. + storm::dd::Add extendedTransitionMatrix; + + // The meta variables used to probabilistic branching. + std::set probabilisticBranchingVariables; + + // A mapping from expressions that were used in the abstraction process to the the BDDs representing them. + std::map> expressionToBddMap; + + // The bottom states of the model. + storm::dd::Bdd bottomStates; + }; + + } +} diff --git a/src/storm/abstraction/MenuGameAbstractor.cpp b/src/storm/abstraction/MenuGameAbstractor.cpp new file mode 100644 index 000000000..164802c2b --- /dev/null +++ b/src/storm/abstraction/MenuGameAbstractor.cpp @@ -0,0 +1,142 @@ +#include "storm/abstraction/MenuGameAbstractor.h" + +#include "storm/abstraction/AbstractionInformation.h" + +#include "storm/models/symbolic/StandardRewardModel.h" + +#include "storm/storage/dd/Add.h" +#include "storm/storage/dd/Bdd.h" +#include "storm/utility/dd.h" + +#include "storm-config.h" +#include "storm/adapters/CarlAdapter.h" + +namespace storm { + namespace abstraction { + + template + std::string getStateName(std::pair const& stateValue, std::set const& locationVariables, std::set const& predicateVariables, storm::expressions::Variable const& bottomVariable) { + std::stringstream stateName; + + if (!locationVariables.empty()) { + stateName << "loc"; + } + + for (auto const& variable : locationVariables) { + stateName << stateValue.first.getIntegerValue(variable); + } + + if (!locationVariables.empty() && !predicateVariables.empty()) { + stateName << "_"; + } + + for (auto const& variable : predicateVariables) { + if (stateValue.first.getBooleanValue(variable)) { + stateName << "1"; + } else { + stateName << "0"; + } + } + + if (stateValue.first.getBooleanValue(bottomVariable)) { + stateName << "bot"; + } + return stateName.str(); + } + + template + void MenuGameAbstractor::exportToDot(storm::abstraction::MenuGame const& currentGame, std::string const& filename, storm::dd::Bdd const& highlightStatesBdd, storm::dd::Bdd const& filter) const { + + std::ofstream out(filename); + AbstractionInformation const& abstractionInformation = this->getAbstractionInformation(); + + storm::dd::Add filteredTransitions = filter.template toAdd() * currentGame.getTransitionMatrix(); + storm::dd::Bdd filteredTransitionsBdd = filteredTransitions.toBdd().existsAbstract(currentGame.getNondeterminismVariables()); + storm::dd::Bdd filteredReachableStates = storm::utility::dd::computeReachableStates(currentGame.getInitialStates(), filteredTransitionsBdd, currentGame.getRowVariables(), currentGame.getColumnVariables()); + filteredTransitions *= filteredReachableStates.template toAdd(); + + // Determine all initial states so we can color them blue. + std::unordered_set initialStates; + storm::dd::Add initialStatesAsAdd = currentGame.getInitialStates().template toAdd(); + for (auto stateValue : initialStatesAsAdd) { + initialStates.insert(getStateName(stateValue, abstractionInformation.getSourceLocationVariables(), abstractionInformation.getSourcePredicateVariables(), abstractionInformation.getBottomStateVariable(true))); + } + + // Determine all highlight states so we can color them red. + std::unordered_set highlightStates; + storm::dd::Add highlightStatesAdd = highlightStatesBdd.template toAdd(); + for (auto stateValue : highlightStatesAdd) { + highlightStates.insert(getStateName(stateValue, abstractionInformation.getSourceLocationVariables(), abstractionInformation.getSourcePredicateVariables(), abstractionInformation.getBottomStateVariable(true))); + } + + out << "digraph game {" << std::endl; + + // Create the player 1 nodes. + storm::dd::Add statesAsAdd = filteredReachableStates.template toAdd(); + for (auto stateValue : statesAsAdd) { + out << "\tpl1_"; + std::string stateName = getStateName(stateValue, abstractionInformation.getSourceLocationVariables(), abstractionInformation.getSourcePredicateVariables(), abstractionInformation.getBottomStateVariable(true)); + out << stateName; + out << " [ label=\""; + if (stateValue.first.getBooleanValue(abstractionInformation.getBottomStateVariable(true))) { + out << "*\", margin=0, width=0, height=0, shape=\"none\""; + } else { + out << stateName << "\", margin=0, width=0, height=0, shape=\"oval\""; + } + bool isInitial = initialStates.find(stateName) != initialStates.end(); + bool isHighlight = highlightStates.find(stateName) != highlightStates.end(); + if (isInitial && isHighlight) { + out << ", style=\"filled\", fillcolor=\"yellow\""; + } else if (isInitial) { + out << ", style=\"filled\", fillcolor=\"blue\""; + } else if (isHighlight) { + out << ", style=\"filled\", fillcolor=\"red\""; + } + out << " ];" << std::endl; + } + + // Create the nodes of the second player. + storm::dd::Add player2States = filteredTransitions.toBdd().existsAbstract(currentGame.getColumnVariables()).existsAbstract(currentGame.getPlayer2Variables()).template toAdd(); + for (auto stateValue : player2States) { + out << "\tpl2_"; + std::string stateName = getStateName(stateValue, abstractionInformation.getSourceLocationVariables(), abstractionInformation.getSourcePredicateVariables(), abstractionInformation.getBottomStateVariable(true)); + uint_fast64_t index = abstractionInformation.decodePlayer1Choice(stateValue.first, abstractionInformation.getPlayer1VariableCount()); + out << stateName << "_" << index; + out << " [ shape=\"square\", width=0, height=0, margin=0, label=\"" << index << "\" ];" << std::endl; + out << "\tpl1_" << stateName << " -> " << "pl2_" << stateName << "_" << index << " [ label=\"" << index << "\" ];" << std::endl; + } + + // Create the nodes of the probabilistic player. + storm::dd::Add playerPStates = filteredTransitions.toBdd().existsAbstract(currentGame.getColumnVariables()).template toAdd(); + for (auto stateValue : playerPStates) { + out << "\tplp_"; + std::stringstream stateNameStream; + stateNameStream << getStateName(stateValue, abstractionInformation.getSourceLocationVariables(), abstractionInformation.getSourcePredicateVariables(), abstractionInformation.getBottomStateVariable(true)); + uint_fast64_t index = abstractionInformation.decodePlayer1Choice(stateValue.first, abstractionInformation.getPlayer1VariableCount()); + stateNameStream << "_" << index; + std::string stateName = stateNameStream.str(); + index = abstractionInformation.decodePlayer2Choice(stateValue.first, currentGame.getPlayer2Variables().size()); + out << stateName << "_" << index; + out << " [ shape=\"point\", label=\"\" ];" << std::endl; + out << "\tpl2_" << stateName << " -> " << "plp_" << stateName << "_" << index << " [ label=\"" << index << "\" ];" << std::endl; + } + + for (auto stateValue : filteredTransitions) { + std::string sourceStateName = getStateName(stateValue, abstractionInformation.getSourceLocationVariables(), abstractionInformation.getSourcePredicateVariables(), abstractionInformation.getBottomStateVariable(true)); + std::string successorStateName = getStateName(stateValue, abstractionInformation.getSuccessorLocationVariables(), abstractionInformation.getSuccessorPredicateVariables(), abstractionInformation.getBottomStateVariable(false)); + uint_fast64_t pl1Index = abstractionInformation.decodePlayer1Choice(stateValue.first, abstractionInformation.getPlayer1VariableCount()); + uint_fast64_t pl2Index = abstractionInformation.decodePlayer2Choice(stateValue.first, currentGame.getPlayer2Variables().size()); + out << "\tplp_" << sourceStateName << "_" << pl1Index << "_" << pl2Index << " -> pl1_" << successorStateName << " [ label=\"" << stateValue.second << "\"];" << std::endl; + } + + out << "}" << std::endl; + } + + template class MenuGameAbstractor; + template class MenuGameAbstractor; + +#ifdef STORM_HAVE_CARL + template class MenuGameAbstractor; +#endif + } +} diff --git a/src/storm/abstraction/MenuGameAbstractor.h b/src/storm/abstraction/MenuGameAbstractor.h new file mode 100644 index 000000000..283559470 --- /dev/null +++ b/src/storm/abstraction/MenuGameAbstractor.h @@ -0,0 +1,54 @@ +#pragma once + +#include +#include + +#include "storm/storage/dd/DdType.h" + +#include "storm/abstraction/MenuGame.h" +#include "storm/abstraction/RefinementCommand.h" + +#include "storm/storage/expressions/Expression.h" + +namespace storm { + namespace dd { + template + class Bdd; + } + + namespace abstraction { + + template + class AbstractionInformation; + + template + class MenuGameAbstractor { + public: + /// Retrieves the abstraction. + virtual MenuGame abstract() = 0; + + /// Retrieves information about the abstraction. + virtual AbstractionInformation const& getAbstractionInformation() const = 0; + virtual storm::expressions::Expression const& getGuard(uint64_t player1Choice) const = 0; + virtual std::pair getPlayer1ChoiceRange() const = 0; + virtual std::map getVariableUpdates(uint64_t player1Choice, uint64_t auxiliaryChoice) const = 0; + virtual storm::expressions::Expression getInitialExpression() const = 0; + + /*! + * Retrieves a BDD that characterizes the states corresponding to the given expression. For this to work, + * appropriate predicates must have been used to refine the abstraction, otherwise this will fail. + */ + virtual storm::dd::Bdd getStates(storm::expressions::Expression const& expression) = 0; + + /// Methods to refine the abstraction. + virtual void refine(RefinementCommand const& command) = 0; + + /// Exports a representation of the current abstraction state in the dot format. + virtual void exportToDot(std::string const& filename, storm::dd::Bdd const& highlightStatesBdd, storm::dd::Bdd const& filter) const = 0; + + protected: + void exportToDot(storm::abstraction::MenuGame const& currentGame, std::string const& filename, storm::dd::Bdd const& highlightStatesBdd, storm::dd::Bdd const& filter) const; + }; + + } +} diff --git a/src/storm/abstraction/MenuGameRefiner.cpp b/src/storm/abstraction/MenuGameRefiner.cpp new file mode 100644 index 000000000..75555bdcd --- /dev/null +++ b/src/storm/abstraction/MenuGameRefiner.cpp @@ -0,0 +1,735 @@ +#include "storm/abstraction/MenuGameRefiner.h" + +#include "storm/abstraction/AbstractionInformation.h" +#include "storm/abstraction/MenuGameAbstractor.h" + +#include "storm/storage/dd/DdManager.h" +#include "storm/utility/dd.h" +#include "storm/utility/solver.h" + +#include "storm/solver/MathsatSmtSolver.h" + +#include "storm/models/symbolic/StandardRewardModel.h" + +#include "storm/exceptions/InvalidStateException.h" + +#include "storm/settings/SettingsManager.h" + +#include "storm-config.h" +#include "storm/adapters/CarlAdapter.h" + +namespace storm { + namespace abstraction { + + using storm::settings::modules::AbstractionSettings; + + RefinementPredicates::RefinementPredicates(Source const& source, std::vector const& predicates) : source(source), predicates(predicates) { + // Intentionally left empty. + } + + RefinementPredicates::Source RefinementPredicates::getSource() const { + return source; + } + + std::vector const& RefinementPredicates::getPredicates() const { + return predicates; + } + + void RefinementPredicates::addPredicates(std::vector const& newPredicates) { + this->predicates.insert(this->predicates.end(), newPredicates.begin(), newPredicates.end()); + } + + template + MostProbablePathsResult::MostProbablePathsResult(storm::dd::Add const& maxProbabilities, storm::dd::Bdd const& spanningTree) : maxProbabilities(maxProbabilities), spanningTree(spanningTree) { + // Intentionally left empty. + } + + template + struct PivotStateCandidatesResult { + storm::dd::Bdd reachableTransitionsMin; + storm::dd::Bdd reachableTransitionsMax; + storm::dd::Bdd pivotStates; + }; + + template + PivotStateResult::PivotStateResult(storm::dd::Bdd const& pivotState, storm::OptimizationDirection fromDirection, boost::optional> const& mostProbablePathsResult) : pivotState(pivotState), fromDirection(fromDirection), mostProbablePathsResult(mostProbablePathsResult) { + // Intentionally left empty. + } + + template + MenuGameRefiner::MenuGameRefiner(MenuGameAbstractor& abstractor, std::unique_ptr&& smtSolver) : abstractor(abstractor), useInterpolation(storm::settings::getModule().isUseInterpolationSet()), splitAll(false), splitPredicates(false), addedAllGuardsFlag(false), pivotSelectionHeuristic(storm::settings::getModule().getPivotSelectionHeuristic()), splitter(), equivalenceChecker(std::move(smtSolver)) { + + AbstractionSettings::SplitMode splitMode = storm::settings::getModule().getSplitMode(); + splitAll = splitMode == AbstractionSettings::SplitMode::All; + splitPredicates = splitMode == AbstractionSettings::SplitMode::NonGuard; + + if (storm::settings::getModule().isAddAllGuardsSet()) { + std::vector guards; + + std::pair player1Choices = this->abstractor.get().getPlayer1ChoiceRange(); + for (uint64_t index = player1Choices.first; index < player1Choices.second; ++index) { + storm::expressions::Expression guard = this->abstractor.get().getGuard(index); + if (!guard.isTrue() && !guard.isFalse()) { + guards.push_back(guard); + } + } + performRefinement(createGlobalRefinement(preprocessPredicates(guards, RefinementPredicates::Source::InitialGuard))); + + addedAllGuardsFlag = true; + } + } + + template + void MenuGameRefiner::refine(std::vector const& predicates) const { + performRefinement(createGlobalRefinement(preprocessPredicates(predicates, RefinementPredicates::Source::Manual))); + } + + template + MostProbablePathsResult getMostProbablePathSpanningTree(storm::abstraction::MenuGame const& game, storm::dd::Bdd const& transitionFilter) { + storm::dd::Add maxProbabilities = game.getInitialStates().template toAdd(); + + storm::dd::Bdd border = game.getInitialStates(); + storm::dd::Bdd spanningTree = game.getManager().getBddZero(); + + storm::dd::Add transitionMatrix = ((transitionFilter && game.getExtendedTransitionMatrix().maxAbstractRepresentative(game.getProbabilisticBranchingVariables())).template toAdd() * game.getExtendedTransitionMatrix()).sumAbstract(game.getPlayer2Variables()); + + std::set variablesToAbstract(game.getRowVariables()); + variablesToAbstract.insert(game.getPlayer1Variables().begin(), game.getPlayer1Variables().end()); + variablesToAbstract.insert(game.getProbabilisticBranchingVariables().begin(), game.getProbabilisticBranchingVariables().end()); + while (!border.isZero()) { + // Determine the new maximal probabilities to all states. + storm::dd::Add tmp = border.template toAdd() * transitionMatrix * maxProbabilities; + storm::dd::Bdd newMaxProbabilityChoices = tmp.maxAbstractRepresentative(variablesToAbstract); + storm::dd::Add newMaxProbabilities = tmp.maxAbstract(variablesToAbstract).swapVariables(game.getRowColumnMetaVariablePairs()); + + // Determine the probability values for which states strictly increased. + storm::dd::Bdd updateStates = newMaxProbabilities.greater(maxProbabilities); + maxProbabilities = updateStates.ite(newMaxProbabilities, maxProbabilities); + + // Delete all edges in the spanning tree that lead to states that need to be updated. + spanningTree &= ((!updateStates).swapVariables(game.getRowColumnMetaVariablePairs())); + + // Add all edges that achieve the new maximal value to the spanning tree. + spanningTree |= updateStates.swapVariables(game.getRowColumnMetaVariablePairs()) && newMaxProbabilityChoices; + + // Continue exploration from states that have been updated. + border = updateStates; + } + + return MostProbablePathsResult(maxProbabilities, spanningTree); + } + + template + PivotStateResult pickPivotState(AbstractionSettings::PivotSelectionHeuristic const& heuristic, storm::abstraction::MenuGame const& game, PivotStateCandidatesResult const& pivotStateCandidateResult, boost::optional> const& qualitativeResult, boost::optional> const& quantitativeResult) { + + // Get easy access to strategies. + storm::dd::Bdd minPlayer1Strategy; + storm::dd::Bdd minPlayer2Strategy; + storm::dd::Bdd maxPlayer1Strategy; + storm::dd::Bdd maxPlayer2Strategy; + if (qualitativeResult) { + minPlayer1Strategy = qualitativeResult.get().prob0Min.getPlayer1Strategy(); + minPlayer2Strategy = qualitativeResult.get().prob0Min.getPlayer2Strategy(); + maxPlayer1Strategy = qualitativeResult.get().prob1Max.getPlayer1Strategy(); + maxPlayer2Strategy = qualitativeResult.get().prob1Max.getPlayer2Strategy(); + } else if (quantitativeResult) { + minPlayer1Strategy = quantitativeResult.get().min.player1Strategy; + minPlayer2Strategy = quantitativeResult.get().min.player2Strategy; + maxPlayer1Strategy = quantitativeResult.get().max.player1Strategy; + maxPlayer2Strategy = quantitativeResult.get().max.player2Strategy; + } else { + STORM_LOG_ASSERT(false, "Either qualitative or quantitative result is required."); + } + + storm::dd::Bdd pivotStates = pivotStateCandidateResult.pivotStates; + + if (heuristic == AbstractionSettings::PivotSelectionHeuristic::NearestMaximalDeviation) { + // Set up used variables. + storm::dd::Bdd initialStates = game.getInitialStates(); + std::set const& rowVariables = game.getRowVariables(); + std::set const& columnVariables = game.getColumnVariables(); + storm::dd::Bdd transitionsMin = pivotStateCandidateResult.reachableTransitionsMin; + storm::dd::Bdd transitionsMax = pivotStateCandidateResult.reachableTransitionsMax; + storm::dd::Bdd frontierMin = initialStates; + storm::dd::Bdd frontierMax = initialStates; + storm::dd::Bdd frontierPivotStates = frontierMin && pivotStates; + + // Check whether we have pivot states on the very first level. + uint64_t level = 0; + bool foundPivotState = !frontierPivotStates.isZero(); + if (foundPivotState) { + STORM_LOG_TRACE("Picked pivot state from " << frontierPivotStates.getNonZeroCount() << " candidates on level " << level << ", " << pivotStates.getNonZeroCount() << " candidates in total."); + return PivotStateResult(frontierPivotStates.existsAbstractRepresentative(rowVariables), storm::OptimizationDirection::Minimize); + } else { + // Otherwise, we perform a simulatenous BFS in the sense that we make one step in both the min and max + // transitions and check for pivot states we encounter. + while (!foundPivotState) { + frontierMin = frontierMin.relationalProduct(transitionsMin, rowVariables, columnVariables); + frontierMax = frontierMax.relationalProduct(transitionsMax, rowVariables, columnVariables); + ++level; + + storm::dd::Bdd frontierMinPivotStates = frontierMin && pivotStates; + storm::dd::Bdd frontierMaxPivotStates = frontierMax && pivotStates; + uint64_t numberOfPivotStateCandidatesOnLevel = frontierMinPivotStates.getNonZeroCount() + frontierMaxPivotStates.getNonZeroCount(); + + if (!frontierMinPivotStates.isZero() || !frontierMaxPivotStates.isZero()) { + if (quantitativeResult) { + storm::dd::Add frontierMinPivotStatesAdd = frontierMinPivotStates.template toAdd(); + storm::dd::Add frontierMaxPivotStatesAdd = frontierMaxPivotStates.template toAdd(); + + storm::dd::Add diffMin = frontierMinPivotStatesAdd * quantitativeResult.get().max.values - frontierMinPivotStatesAdd * quantitativeResult.get().min.values; + storm::dd::Add diffMax = frontierMaxPivotStatesAdd * quantitativeResult.get().max.values - frontierMaxPivotStatesAdd * quantitativeResult.get().min.values; + + ValueType diffValue; + storm::OptimizationDirection direction; + if (diffMin.getMax() >= diffMax.getMax()) { + direction = storm::OptimizationDirection::Minimize; + diffValue = diffMin.getMax(); + } else { + direction = storm::OptimizationDirection::Maximize; + diffValue = diffMax.getMax(); + } + + STORM_LOG_TRACE("Picked pivot state with difference " << diffValue << " from " << numberOfPivotStateCandidatesOnLevel << " candidates on level " << level << ", " << pivotStates.getNonZeroCount() << " candidates in total."); + return PivotStateResult(direction == storm::OptimizationDirection::Minimize ? diffMin.maxAbstractRepresentative(rowVariables) : diffMax.maxAbstractRepresentative(rowVariables), direction); + } else { + STORM_LOG_TRACE("Picked pivot state from " << numberOfPivotStateCandidatesOnLevel << " candidates on level " << level << ", " << pivotStates.getNonZeroCount() << " candidates in total."); + + storm::OptimizationDirection direction; + if (!frontierMinPivotStates.isZero()) { + direction = storm::OptimizationDirection::Minimize; + } else { + direction = storm::OptimizationDirection::Maximize; + } + + return PivotStateResult(direction == storm::OptimizationDirection::Minimize ? frontierMinPivotStates.existsAbstractRepresentative(rowVariables) : frontierMaxPivotStates.existsAbstractRepresentative(rowVariables), direction); + } + } + } + } + } else { + // Compute the most probable paths to the reachable states and the corresponding spanning trees. + MostProbablePathsResult minMostProbablePathsResult = getMostProbablePathSpanningTree(game, minPlayer1Strategy && minPlayer2Strategy); + MostProbablePathsResult maxMostProbablePathsResult = getMostProbablePathSpanningTree(game, maxPlayer1Strategy && maxPlayer2Strategy); + storm::dd::Bdd selectedPivotState; + + storm::dd::Add score = pivotStates.template toAdd() * minMostProbablePathsResult.maxProbabilities.maximum(maxMostProbablePathsResult.maxProbabilities); + + if (heuristic == AbstractionSettings::PivotSelectionHeuristic::MaxWeightedDeviation && quantitativeResult) { + score = score * (quantitativeResult.get().max.values - quantitativeResult.get().min.values); + } + selectedPivotState = score.maxAbstractRepresentative(game.getRowVariables()); + STORM_LOG_TRACE("Selected pivot state with score " << score.getMax() << "."); + + storm::OptimizationDirection fromDirection = storm::OptimizationDirection::Minimize; + storm::dd::Add selectedPivotStateAsAdd = selectedPivotState.template toAdd(); + if ((selectedPivotStateAsAdd * maxMostProbablePathsResult.maxProbabilities).getMax() > (selectedPivotStateAsAdd * minMostProbablePathsResult.maxProbabilities).getMax()) { + fromDirection = storm::OptimizationDirection::Maximize; + } + + return PivotStateResult(selectedPivotState, fromDirection, fromDirection == storm::OptimizationDirection::Minimize ? minMostProbablePathsResult : maxMostProbablePathsResult); + } + + STORM_LOG_ASSERT(false, "This point must not be reached, because then no pivot state could be found."); + return PivotStateResult(storm::dd::Bdd(), storm::OptimizationDirection::Minimize); + } + + template + RefinementPredicates MenuGameRefiner::derivePredicatesFromDifferingChoices(storm::dd::Bdd const& player1Choice, storm::dd::Bdd const& lowerChoice, storm::dd::Bdd const& upperChoice) const { + // Prepare result. + storm::expressions::Expression newPredicate; + bool fromGuard = false; + + // Get abstraction informatin for easier access. + AbstractionInformation const& abstractionInformation = abstractor.get().getAbstractionInformation(); + + // Decode the index of the command chosen by player 1. + storm::dd::Add player1ChoiceAsAdd = player1Choice.template toAdd(); + auto pl1It = player1ChoiceAsAdd.begin(); + uint_fast64_t player1Index = abstractionInformation.decodePlayer1Choice((*pl1It).first, abstractionInformation.getPlayer1VariableCount()); + + // Check whether there are bottom states in the game and whether one of the choices actually picks the + // bottom state as the successor. + bool buttomStateSuccessor = !((abstractionInformation.getBottomStateBdd(false, false) && lowerChoice) || (abstractionInformation.getBottomStateBdd(false, false) && upperChoice)).isZero(); + + // If one of the choices picks the bottom state, the new predicate is based on the guard of the appropriate + // command (that is the player 1 choice). + if (buttomStateSuccessor) { + STORM_LOG_TRACE("One of the successors is a bottom state, taking a guard as a new predicate."); + newPredicate = abstractor.get().getGuard(player1Index); + fromGuard = true; + STORM_LOG_DEBUG("Derived new predicate (based on guard): " << newPredicate); + } else { + STORM_LOG_TRACE("No bottom state successor. Deriving a new predicate using weakest precondition."); + + // Decode both choices to explicit mappings. + std::map> lowerChoiceUpdateToSuccessorMapping = abstractionInformation.template decodeChoiceToUpdateSuccessorMapping(lowerChoice); + std::map> upperChoiceUpdateToSuccessorMapping = abstractionInformation.template decodeChoiceToUpdateSuccessorMapping(upperChoice); + STORM_LOG_ASSERT(lowerChoiceUpdateToSuccessorMapping.size() == upperChoiceUpdateToSuccessorMapping.size(), "Mismatching sizes after decode (" << lowerChoiceUpdateToSuccessorMapping.size() << " vs. " << upperChoiceUpdateToSuccessorMapping.size() << ")."); + + // First, sort updates according to probability mass. + std::vector> updateIndicesAndMasses; + for (auto const& entry : lowerChoiceUpdateToSuccessorMapping) { + updateIndicesAndMasses.emplace_back(entry.first, entry.second.second); + } + std::sort(updateIndicesAndMasses.begin(), updateIndicesAndMasses.end(), [] (std::pair const& a, std::pair const& b) { return a.second > b.second; }); + + // Now find the update with the highest probability mass among all deviating updates. More specifically, + // we determine the set of predicate indices for which there is a deviation. + std::set deviationPredicates; + uint64_t orderedUpdateIndex = 0; + std::vector possibleRefinementPredicates; + for (; orderedUpdateIndex < updateIndicesAndMasses.size(); ++orderedUpdateIndex) { + storm::storage::BitVector const& lower = lowerChoiceUpdateToSuccessorMapping.at(updateIndicesAndMasses[orderedUpdateIndex].first).first; + storm::storage::BitVector const& upper = upperChoiceUpdateToSuccessorMapping.at(updateIndicesAndMasses[orderedUpdateIndex].first).first; + + bool deviates = lower != upper; + if (deviates) { + std::map variableUpdates = abstractor.get().getVariableUpdates(player1Index, updateIndicesAndMasses[orderedUpdateIndex].first); + + for (uint64_t predicateIndex = 0; predicateIndex < lower.size(); ++predicateIndex) { + if (lower[predicateIndex] != upper[predicateIndex]) { + possibleRefinementPredicates.push_back(abstractionInformation.getPredicateByIndex(predicateIndex).substitute(variableUpdates).simplify()); + } + } + ++orderedUpdateIndex; + break; + } + } + + STORM_LOG_ASSERT(!possibleRefinementPredicates.empty(), "Expected refinement predicates."); + + // Since we can choose any of the deviation predicates to perform the split, we go through the remaining + // updates and build all deviation predicates. We can then check whether any of the possible refinement + // predicates also eliminates another deviation. + std::vector otherRefinementPredicates; + for (; orderedUpdateIndex < updateIndicesAndMasses.size(); ++orderedUpdateIndex) { + storm::storage::BitVector const& lower = lowerChoiceUpdateToSuccessorMapping.at(updateIndicesAndMasses[orderedUpdateIndex].first).first; + storm::storage::BitVector const& upper = upperChoiceUpdateToSuccessorMapping.at(updateIndicesAndMasses[orderedUpdateIndex].first).first; + + bool deviates = lower != upper; + if (deviates) { + std::map newVariableUpdates = abstractor.get().getVariableUpdates(player1Index, updateIndicesAndMasses[orderedUpdateIndex].first); + for (uint64_t predicateIndex = 0; predicateIndex < lower.size(); ++predicateIndex) { + if (lower[predicateIndex] != upper[predicateIndex]) { + otherRefinementPredicates.push_back(abstractionInformation.getPredicateByIndex(predicateIndex).substitute(newVariableUpdates).simplify()); + } + } + } + } + + // Finally, go through the refinement predicates and see how many deviations they cover. + std::vector refinementPredicateIndexToCount(possibleRefinementPredicates.size(), 0); + for (uint64_t index = 0; index < possibleRefinementPredicates.size(); ++index) { + refinementPredicateIndexToCount[index] = 1; + } + for (auto const& otherPredicate : otherRefinementPredicates) { + for (uint64_t index = 0; index < possibleRefinementPredicates.size(); ++index) { + if (equivalenceChecker.areEquivalent(otherPredicate, possibleRefinementPredicates[index])) { + ++refinementPredicateIndexToCount[index]; + } + } + } + + // Find predicate that covers the most deviations. + uint64_t chosenPredicateIndex = 0; + for (uint64_t index = 0; index < possibleRefinementPredicates.size(); ++index) { + if (refinementPredicateIndexToCount[index] > refinementPredicateIndexToCount[chosenPredicateIndex]) { + chosenPredicateIndex = index; + } + } + newPredicate = possibleRefinementPredicates[chosenPredicateIndex]; + + STORM_LOG_ASSERT(newPredicate.isInitialized(), "Could not derive new predicate as there is no deviation."); + STORM_LOG_DEBUG("Derived new predicate (based on weakest-precondition): " << newPredicate << ", (equivalent to " << (refinementPredicateIndexToCount[chosenPredicateIndex] - 1) << " other refinement predicates)"); + } + + return RefinementPredicates(fromGuard ? RefinementPredicates::Source::Guard : RefinementPredicates::Source::WeakestPrecondition, {newPredicate}); + } + + template + PivotStateCandidatesResult computePivotStates(storm::abstraction::MenuGame const& game, storm::dd::Bdd const& transitionMatrixBdd, storm::dd::Bdd const& minPlayer1Strategy, storm::dd::Bdd const& minPlayer2Strategy, storm::dd::Bdd const& maxPlayer1Strategy, storm::dd::Bdd const& maxPlayer2Strategy) { + + PivotStateCandidatesResult result; + + // Build the fragment of transitions that is reachable by either the min or the max strategies. + result.reachableTransitionsMin = (transitionMatrixBdd && minPlayer1Strategy && minPlayer2Strategy).existsAbstract(game.getNondeterminismVariables()); + result.reachableTransitionsMax = (transitionMatrixBdd && maxPlayer1Strategy && maxPlayer2Strategy).existsAbstract(game.getNondeterminismVariables()); + + // Start with all reachable states as potential pivot states. + result.pivotStates = storm::utility::dd::computeReachableStates(game.getInitialStates(), result.reachableTransitionsMin, game.getRowVariables(), game.getColumnVariables()) || + storm::utility::dd::computeReachableStates(game.getInitialStates(), result.reachableTransitionsMax, game.getRowVariables(), game.getColumnVariables()); + + // Then constrain these states by the requirement that for either the lower or upper player 1 choice the player 2 choices must be different and + // that the difference is not because of a missing strategy in either case. + + // Start with constructing the player 2 states that have a min and a max strategy. + storm::dd::Bdd constraint = minPlayer2Strategy.existsAbstract(game.getPlayer2Variables()) && maxPlayer2Strategy.existsAbstract(game.getPlayer2Variables()); + + // Now construct all player 2 choices that actually exist and differ in the min and max case. + constraint &= minPlayer2Strategy.exclusiveOr(maxPlayer2Strategy); + + // Then restrict the pivot states by requiring existing and different player 2 choices. + result.pivotStates &= ((minPlayer1Strategy || maxPlayer1Strategy) && constraint).existsAbstract(game.getNondeterminismVariables()); + + return result; + } + + template + RefinementPredicates MenuGameRefiner::derivePredicatesFromPivotState(storm::abstraction::MenuGame const& game, storm::dd::Bdd const& pivotState, storm::dd::Bdd const& minPlayer1Strategy, storm::dd::Bdd const& minPlayer2Strategy, storm::dd::Bdd const& maxPlayer1Strategy, storm::dd::Bdd const& maxPlayer2Strategy) const { + // Compute the lower and the upper choice for the pivot state. + std::set variablesToAbstract = game.getNondeterminismVariables(); + variablesToAbstract.insert(game.getRowVariables().begin(), game.getRowVariables().end()); + + bool player1ChoicesDifferent = !(pivotState && minPlayer1Strategy).exclusiveOr(pivotState && maxPlayer1Strategy).isZero(); + + boost::optional predicates; + + // Derive predicates from lower choice. + storm::dd::Bdd lowerChoice = pivotState && game.getExtendedTransitionMatrix().toBdd() && minPlayer1Strategy; + storm::dd::Bdd lowerChoice1 = (lowerChoice && minPlayer2Strategy).existsAbstract(variablesToAbstract); + storm::dd::Bdd lowerChoice2 = (lowerChoice && maxPlayer2Strategy).existsAbstract(variablesToAbstract); + + bool lowerChoicesDifferent = !lowerChoice1.exclusiveOr(lowerChoice2).isZero(); + if (lowerChoicesDifferent) { + STORM_LOG_TRACE("Deriving predicate based on lower choice."); + predicates = derivePredicatesFromDifferingChoices((pivotState && minPlayer1Strategy).existsAbstract(game.getRowVariables()), lowerChoice1, lowerChoice2); + } + + if (predicates && (!player1ChoicesDifferent || predicates.get().getSource() == RefinementPredicates::Source::Guard)) { + return predicates.get(); + } else { + boost::optional additionalPredicates; + + storm::dd::Bdd upperChoice = pivotState && game.getExtendedTransitionMatrix().toBdd() && maxPlayer1Strategy; + storm::dd::Bdd upperChoice1 = (upperChoice && minPlayer2Strategy).existsAbstract(variablesToAbstract); + storm::dd::Bdd upperChoice2 = (upperChoice && maxPlayer2Strategy).existsAbstract(variablesToAbstract); + + bool upperChoicesDifferent = !upperChoice1.exclusiveOr(upperChoice2).isZero(); + if (upperChoicesDifferent) { + STORM_LOG_TRACE("Deriving predicate based on upper choice."); + additionalPredicates = derivePredicatesFromDifferingChoices((pivotState && maxPlayer1Strategy).existsAbstract(game.getRowVariables()), upperChoice1, upperChoice2); + } + + if (additionalPredicates) { + if (additionalPredicates.get().getSource() == RefinementPredicates::Source::Guard) { + return additionalPredicates.get(); + } else { + predicates.get().addPredicates(additionalPredicates.get().getPredicates()); + } + } + } + + STORM_LOG_THROW(static_cast(predicates), storm::exceptions::InvalidStateException, "Could not derive predicates for refinement."); + + return predicates.get(); + } + + template + std::pair>, std::map> MenuGameRefiner::buildTrace(storm::expressions::ExpressionManager& expressionManager, storm::abstraction::MenuGame const& game, storm::dd::Bdd const& spanningTree, storm::dd::Bdd const& pivotState) const { + std::vector> predicates; + + // Prepare some variables. + AbstractionInformation const& abstractionInformation = abstractor.get().getAbstractionInformation(); + std::set variablesToAbstract(game.getColumnVariables()); + variablesToAbstract.insert(game.getPlayer1Variables().begin(), game.getPlayer1Variables().end()); + variablesToAbstract.insert(game.getProbabilisticBranchingVariables().begin(), game.getProbabilisticBranchingVariables().end()); + + storm::expressions::Expression initialExpression = abstractor.get().getInitialExpression(); + + std::set oldVariables = initialExpression.getVariables(); + for (auto const& predicate : abstractionInformation.getPredicates()) { + std::set usedVariables = predicate.getVariables(); + oldVariables.insert(usedVariables.begin(), usedVariables.end()); + } + + std::map oldToNewVariables; + for (auto const& variable : oldVariables) { + oldToNewVariables[variable] = expressionManager.getVariable(variable.getName()); + } + std::map lastSubstitution; + for (auto const& variable : oldToNewVariables) { + lastSubstitution[variable.second] = variable.second; + } + std::map stepVariableToCopiedVariableMap; + + // Start with the target state part of the trace. + storm::storage::BitVector decodedTargetState = abstractionInformation.decodeState(pivotState); + predicates.emplace_back(abstractionInformation.getPredicates(decodedTargetState)); + for (auto& predicate : predicates.back()) { + predicate = predicate.changeManager(expressionManager); + } + + // Perform a backward search for an initial state. + storm::dd::Bdd currentState = pivotState; + while ((currentState && game.getInitialStates()).isZero()) { + storm::dd::Bdd predecessorTransition = currentState.swapVariables(game.getRowColumnMetaVariablePairs()) && spanningTree; + std::tuple decodedPredecessor = abstractionInformation.decodeStatePlayer1ChoiceAndUpdate(predecessorTransition); + + // Create a new copy of each variable to use for this step. + std::map substitution; + for (auto const& variablePair : oldToNewVariables) { + storm::expressions::Variable variableCopy = expressionManager.declareVariableCopy(variablePair.second); + substitution[variablePair.second] = variableCopy; + stepVariableToCopiedVariableMap[variableCopy] = variablePair.second; + } + + // Retrieve the variable updates that the predecessor needs to perform to get to the current state. + auto variableUpdates = abstractor.get().getVariableUpdates(std::get<1>(decodedPredecessor), std::get<2>(decodedPredecessor)); + for (auto const& update : variableUpdates) { + storm::expressions::Variable newVariable = oldToNewVariables.at(update.first); + if (update.second.hasBooleanType()) { + predicates.back().push_back(storm::expressions::iff(lastSubstitution.at(oldToNewVariables.at(update.first)), update.second.changeManager(expressionManager).substitute(substitution))); + } else { + predicates.back().push_back(lastSubstitution.at(oldToNewVariables.at(update.first)) == update.second.changeManager(expressionManager).substitute(substitution)); + } + } + + // Add the guard of the choice. + predicates.back().push_back(abstractor.get().getGuard(std::get<1>(decodedPredecessor)).changeManager(expressionManager).substitute(substitution)); + + // Retrieve the predicate valuation in the predecessor. + predicates.emplace_back(abstractionInformation.getPredicates(std::get<0>(decodedPredecessor))); + for (auto& predicate : predicates.back()) { + predicate = predicate.changeManager(expressionManager).substitute(substitution); + } + + // Move backwards one step. + lastSubstitution = std::move(substitution); + currentState = predecessorTransition.existsAbstract(variablesToAbstract); + } + + predicates.back().push_back(initialExpression.changeManager(expressionManager).substitute(lastSubstitution)); + return std::make_pair(predicates, stepVariableToCopiedVariableMap); + } + + template + boost::optional MenuGameRefiner::derivePredicatesFromInterpolation(storm::abstraction::MenuGame const& game, PivotStateResult const& pivotStateResult, storm::dd::Bdd const& minPlayer1Strategy, storm::dd::Bdd const& minPlayer2Strategy, storm::dd::Bdd const& maxPlayer1Strategy, storm::dd::Bdd const& maxPlayer2Strategy) const { + + AbstractionInformation const& abstractionInformation = abstractor.get().getAbstractionInformation(); + + // Compute the most probable path from any initial state to the pivot state. + MostProbablePathsResult mostProbablePathsResult; + if (!pivotStateResult.mostProbablePathsResult) { + mostProbablePathsResult = getMostProbablePathSpanningTree(game, pivotStateResult.fromDirection == storm::OptimizationDirection::Minimize ? minPlayer1Strategy && minPlayer2Strategy : maxPlayer1Strategy && maxPlayer2Strategy); + } else { + mostProbablePathsResult = pivotStateResult.mostProbablePathsResult.get(); + } + + // Create a new expression manager that we can use for the interpolation. + std::shared_ptr interpolationManager = abstractionInformation.getExpressionManager().clone(); + + // Build the trace of the most probable path in terms of which predicates hold in each step. + std::pair>, std::map> traceAndVariableSubstitution = buildTrace(*interpolationManager, game, mostProbablePathsResult.spanningTree, pivotStateResult.pivotState); + auto const& trace = traceAndVariableSubstitution.first; + auto const& variableSubstitution = traceAndVariableSubstitution.second; + + // Create solver and interpolation groups. + storm::solver::MathsatSmtSolver interpolatingSolver(*interpolationManager, storm::solver::MathsatSmtSolver::Options(true, false, true)); + uint64_t stepCounter = 0; + auto traceIt = trace.rbegin(); + auto traceIte = trace.rend(); + for (; traceIt != traceIte; ++traceIt) { + auto const& step = *traceIt; + interpolatingSolver.push(); + + interpolatingSolver.setInterpolationGroup(stepCounter); + for (auto const& predicate : step) { + interpolatingSolver.add(predicate); + } + ++stepCounter; + + storm::solver::SmtSolver::CheckResult result = interpolatingSolver.check(); + // If the result already became unsatisfiable + if (result == storm::solver::SmtSolver::CheckResult::Unsat) { + STORM_LOG_TRACE("Trace formula became unsatisfiable after step " << (stepCounter - 1) << "."); + break; + } + } + + // Now encode the trace as an SMT problem. + storm::solver::SmtSolver::CheckResult result = interpolatingSolver.check(); + if (result == storm::solver::SmtSolver::CheckResult::Unsat) { + STORM_LOG_TRACE("Trace formula is unsatisfiable. Starting interpolation."); + + std::vector interpolants; + std::vector prefix; + for (uint64_t step = 0; step + 1 < stepCounter; ++step) { + prefix.push_back(step); + storm::expressions::Expression interpolant = interpolatingSolver.getInterpolant(prefix).substitute(variableSubstitution).changeManager(abstractionInformation.getExpressionManager()); + if (!interpolant.isTrue() && !interpolant.isFalse()) { + STORM_LOG_DEBUG("Derived new predicate (based on interpolation): " << interpolant); + interpolants.push_back(interpolant); + } + } + return boost::make_optional(RefinementPredicates(RefinementPredicates::Source::Interpolation, interpolants)); + } else { + STORM_LOG_TRACE("Trace formula is satisfiable, not using interpolation."); + } + + return boost::none; + } + + template + bool MenuGameRefiner::refine(storm::abstraction::MenuGame const& game, storm::dd::Bdd const& transitionMatrixBdd, QualitativeResultMinMax const& qualitativeResult) const { + STORM_LOG_TRACE("Trying refinement after qualitative check."); + // Get all relevant strategies. + storm::dd::Bdd minPlayer1Strategy = qualitativeResult.prob0Min.getPlayer1Strategy(); + storm::dd::Bdd minPlayer2Strategy = qualitativeResult.prob0Min.getPlayer2Strategy(); + storm::dd::Bdd maxPlayer1Strategy = qualitativeResult.prob1Max.getPlayer1Strategy(); + storm::dd::Bdd maxPlayer2Strategy = qualitativeResult.prob1Max.getPlayer2Strategy(); + + // Redirect all player 1 choices of the min strategy to that of the max strategy if this leads to a player 2 + // state that is also a prob 0 state. + minPlayer1Strategy = (maxPlayer1Strategy && qualitativeResult.prob0Min.getPlayer2States()).existsAbstract(game.getPlayer1Variables()).ite(maxPlayer1Strategy, minPlayer1Strategy); + + // Compute all reached pivot states. + PivotStateCandidatesResult pivotStateCandidatesResult = computePivotStates(game, transitionMatrixBdd, minPlayer1Strategy, minPlayer2Strategy, maxPlayer1Strategy, maxPlayer2Strategy); + + // We can only refine in case we have a reachable player 1 state with a player 2 successor (under either + // player 1's min or max strategy) such that from this player 2 state, both prob0 min and prob1 max define + // strategies and they differ. Hence, it is possible that we arrive at a point where no suitable pivot state + // is found. In this case, we abort the qualitative refinement here. + if (pivotStateCandidatesResult.pivotStates.isZero()) { + return false; + } + STORM_LOG_ASSERT(!pivotStateCandidatesResult.pivotStates.isZero(), "Unable to proceed without pivot state candidates."); + + // Now that we have the pivot state candidates, we need to pick one. + PivotStateResult pivotStateResult = pickPivotState(pivotSelectionHeuristic, game, pivotStateCandidatesResult, qualitativeResult, boost::none); + + boost::optional predicates; + if (useInterpolation) { + predicates = derivePredicatesFromInterpolation(game, pivotStateResult, minPlayer1Strategy, minPlayer2Strategy, maxPlayer1Strategy, maxPlayer2Strategy); + } + if (predicates) { + STORM_LOG_TRACE("Obtained predicates by interpolation."); + } else { + predicates = derivePredicatesFromPivotState(game, pivotStateResult.pivotState, minPlayer1Strategy, minPlayer2Strategy, maxPlayer1Strategy, maxPlayer2Strategy); + } + STORM_LOG_THROW(static_cast(predicates), storm::exceptions::InvalidStateException, "Predicates needed to continue."); + + // Derive predicate based on the selected pivot state. + std::vector preparedPredicates = preprocessPredicates(predicates.get().getPredicates(), predicates.get().getSource()); + performRefinement(createGlobalRefinement(preparedPredicates)); + return true; + } + + template + bool MenuGameRefiner::refine(storm::abstraction::MenuGame const& game, storm::dd::Bdd const& transitionMatrixBdd, QuantitativeResultMinMax const& quantitativeResult) const { + STORM_LOG_TRACE("Refining after quantitative check."); + // Get all relevant strategies. + storm::dd::Bdd minPlayer1Strategy = quantitativeResult.min.player1Strategy; + storm::dd::Bdd minPlayer2Strategy = quantitativeResult.min.player2Strategy; + storm::dd::Bdd maxPlayer1Strategy = quantitativeResult.max.player1Strategy; + storm::dd::Bdd maxPlayer2Strategy = quantitativeResult.max.player2Strategy; + + // Compute all reached pivot states. + PivotStateCandidatesResult pivotStateCandidatesResult = computePivotStates(game, transitionMatrixBdd, minPlayer1Strategy, minPlayer2Strategy, maxPlayer1Strategy, maxPlayer2Strategy); + + STORM_LOG_ASSERT(!pivotStateCandidatesResult.pivotStates.isZero(), "Unable to refine without pivot state candidates."); + + // Now that we have the pivot state candidates, we need to pick one. + PivotStateResult pivotStateResult = pickPivotState(pivotSelectionHeuristic, game, pivotStateCandidatesResult, boost::none, quantitativeResult); + + boost::optional predicates; + if (useInterpolation) { + predicates = derivePredicatesFromInterpolation(game, pivotStateResult, minPlayer1Strategy, minPlayer2Strategy, maxPlayer1Strategy, maxPlayer2Strategy); + } + if (predicates) { + STORM_LOG_TRACE("Obtained predicates by interpolation."); + } else { + predicates = derivePredicatesFromPivotState(game, pivotStateResult.pivotState, minPlayer1Strategy, minPlayer2Strategy, maxPlayer1Strategy, maxPlayer2Strategy); + } + STORM_LOG_THROW(static_cast(predicates), storm::exceptions::InvalidStateException, "Predicates needed to continue."); + + std::vector preparedPredicates = preprocessPredicates(predicates.get().getPredicates(), predicates.get().getSource()); + performRefinement(createGlobalRefinement(preparedPredicates)); + return true; + } + + template + std::vector MenuGameRefiner::preprocessPredicates(std::vector const& predicates, RefinementPredicates::Source const& source) const { + bool split = source == RefinementPredicates::Source::WeakestPrecondition && splitPredicates; + split |= source == RefinementPredicates::Source::Interpolation && splitPredicates; + split |= splitAll; + + if (split) { + AbstractionInformation const& abstractionInformation = abstractor.get().getAbstractionInformation(); + std::vector cleanedAtoms; + + for (auto const& predicate : predicates) { + + // Split the predicates. + std::vector atoms = splitter.split(predicate); + + // Check which of the atoms are redundant in the sense that they are equivalent to a predicate we already have. + for (auto const& atom : atoms) { + // Check whether the newly found atom is equivalent to an atom we already have in the predicate + // set or in the set that is to be added. + bool addAtom = true; + for (auto const& oldPredicate : abstractionInformation.getPredicates()) { + if (equivalenceChecker.areEquivalent(atom, oldPredicate)) { + addAtom = false; + break; + } + } + for (auto const& addedAtom : cleanedAtoms) { + if (equivalenceChecker.areEquivalent(addedAtom, atom)) { + addAtom = false; + break; + } + } + + if (addAtom) { + cleanedAtoms.push_back(atom); + } + } + } + + return cleanedAtoms; + } else { + // If no splitting of the predicates is required, just forward the refinement request to the abstractor. + } + + return predicates; + } + + template + std::vector MenuGameRefiner::createGlobalRefinement(std::vector const& predicates) const { + std::vector commands; + commands.emplace_back(predicates); + return commands; + } + + template + void MenuGameRefiner::performRefinement(std::vector const& refinementCommands) const { + for (auto const& command : refinementCommands) { + STORM_LOG_TRACE("Refining with " << command.getPredicates().size() << " predicates."); + for (auto const& predicate : command.getPredicates()) { + STORM_LOG_TRACE(predicate); + } + abstractor.get().refine(command); + } + + STORM_LOG_TRACE("Current set of predicates:"); + for (auto const& predicate : abstractor.get().getAbstractionInformation().getPredicates()) { + STORM_LOG_TRACE(predicate); + } + } + + template + bool MenuGameRefiner::addedAllGuards() const { + return addedAllGuardsFlag; + } + + template class MenuGameRefiner; + template class MenuGameRefiner; + +#ifdef STORM_HAVE_CARL + // Currently, this instantiation does not work. + // template class MenuGameRefiner; +#endif + + } +} diff --git a/src/storm/abstraction/MenuGameRefiner.h b/src/storm/abstraction/MenuGameRefiner.h new file mode 100644 index 000000000..d5681ff2f --- /dev/null +++ b/src/storm/abstraction/MenuGameRefiner.h @@ -0,0 +1,147 @@ +#pragma once + +#include +#include +#include + +#include + +#include "storm/abstraction/RefinementCommand.h" +#include "storm/abstraction/QualitativeResultMinMax.h" +#include "storm/abstraction/QuantitativeResultMinMax.h" + +#include "storm/storage/expressions/Expression.h" +#include "storm/storage/expressions/FullPredicateSplitter.h" +#include "storm/storage/expressions/EquivalenceChecker.h" + +#include "storm/storage/dd/DdType.h" + +#include "storm/settings/modules/AbstractionSettings.h" + +#include "storm/utility/solver.h" + +namespace storm { + namespace abstraction { + + template + class MenuGameAbstractor; + + template + class MenuGame; + + class RefinementPredicates { + public: + enum class Source { + WeakestPrecondition, InitialGuard, Guard, Interpolation, Manual + }; + + RefinementPredicates() = default; + RefinementPredicates(Source const& source, std::vector const& predicates); + + Source getSource() const; + std::vector const& getPredicates() const; + void addPredicates(std::vector const& newPredicates); + + private: + Source source; + std::vector predicates; + }; + + template + struct MostProbablePathsResult { + MostProbablePathsResult() = default; + MostProbablePathsResult(storm::dd::Add const& maxProbabilities, storm::dd::Bdd const& spanningTree); + + storm::dd::Add maxProbabilities; + storm::dd::Bdd spanningTree; + }; + + template + struct PivotStateResult { + PivotStateResult(storm::dd::Bdd const& pivotState, storm::OptimizationDirection fromDirection, boost::optional> const& mostProbablePathsResult = boost::none); + + storm::dd::Bdd pivotState; + storm::OptimizationDirection fromDirection; + boost::optional> mostProbablePathsResult; + }; + + template + class MenuGameRefiner { + public: + /*! + * Creates a refiner for the provided abstractor. + */ + MenuGameRefiner(MenuGameAbstractor& abstractor, std::unique_ptr&& smtSolver); + + /*! + * Refines the abstractor with the given predicates. + * + * @param predicates The predicates to use for refinement. + */ + void refine(std::vector const& predicates) const; + + /*! + * Refines the abstractor based on the qualitative result by trying to derive suitable predicates. + * + * @param True if predicates for refinement could be derived, false otherwise. + */ + bool refine(storm::abstraction::MenuGame const& game, storm::dd::Bdd const& transitionMatrixBdd, QualitativeResultMinMax const& qualitativeResult) const; + + /*! + * Refines the abstractor based on the quantitative result by trying to derive suitable predicates. + * + * @param True if predicates for refinement could be derived, false otherwise. + */ + bool refine(storm::abstraction::MenuGame const& game, storm::dd::Bdd const& transitionMatrixBdd, QuantitativeResultMinMax const& quantitativeResult) const; + + /*! + * Retrieves whether all guards were added. + */ + bool addedAllGuards() const; + + private: + RefinementPredicates derivePredicatesFromDifferingChoices(storm::dd::Bdd const& player1Choice, storm::dd::Bdd const& lowerChoice, storm::dd::Bdd const& upperChoice) const; + RefinementPredicates derivePredicatesFromPivotState(storm::abstraction::MenuGame const& game, storm::dd::Bdd const& pivotState, storm::dd::Bdd const& minPlayer1Strategy, storm::dd::Bdd const& minPlayer2Strategy, storm::dd::Bdd const& maxPlayer1Strategy, storm::dd::Bdd const& maxPlayer2Strategy) const; + + /*! + * Preprocesses the predicates. + */ + std::vector preprocessPredicates(std::vector const& predicates, RefinementPredicates::Source const& source) const; + + /*! + * Creates a set of refinement commands that amounts to splitting all player 1 choices with the given set of predicates. + */ + std::vector createGlobalRefinement(std::vector const& predicates) const; + + boost::optional derivePredicatesFromInterpolation(storm::abstraction::MenuGame const& game, PivotStateResult const& pivotStateResult, storm::dd::Bdd const& minPlayer1Strategy, storm::dd::Bdd const& minPlayer2Strategy, storm::dd::Bdd const& maxPlayer1Strategy, storm::dd::Bdd const& maxPlayer2Strategy) const; + std::pair>, std::map> buildTrace(storm::expressions::ExpressionManager& expressionManager, storm::abstraction::MenuGame const& game, storm::dd::Bdd const& spanningTree, storm::dd::Bdd const& pivotState) const; + + void performRefinement(std::vector const& refinementCommands) const; + + /// The underlying abstractor to refine. + std::reference_wrapper> abstractor; + + /// A flag indicating whether interpolation shall be used to rule out spurious pivot blocks. + bool useInterpolation; + + /// A flag indicating whether all predicates shall be split before using them for refinement. + bool splitAll; + + /// A flag indicating whether predicates derived from weakest preconditions shall be split before using them for refinement. + bool splitPredicates; + + /// A flag indicating whether all guards have been used to refine the abstraction. + bool addedAllGuardsFlag; + + /// The heuristic to use for pivot block selection. + storm::settings::modules::AbstractionSettings::PivotSelectionHeuristic pivotSelectionHeuristic; + + /// An object that can be used for splitting predicates. + mutable storm::expressions::FullPredicateSplitter splitter; + + /// An object that can be used to determine whether predicates are equivalent. + mutable storm::expressions::EquivalenceChecker equivalenceChecker; + }; + + } +} diff --git a/src/storm/abstraction/QualitativeResult.h b/src/storm/abstraction/QualitativeResult.h new file mode 100644 index 000000000..66386e72a --- /dev/null +++ b/src/storm/abstraction/QualitativeResult.h @@ -0,0 +1,12 @@ +#pragma once + +#include "storm/utility/graph.h" + +namespace storm { + namespace abstraction { + + template + using QualitativeResult = storm::utility::graph::GameProb01Result; + + } +} diff --git a/src/storm/abstraction/QualitativeResultMinMax.h b/src/storm/abstraction/QualitativeResultMinMax.h new file mode 100644 index 000000000..b013c8acb --- /dev/null +++ b/src/storm/abstraction/QualitativeResultMinMax.h @@ -0,0 +1,22 @@ +#pragma once + +#include "storm/storage/dd/DdType.h" + +#include "storm/utility/graph.h" + +namespace storm { + namespace abstraction { + + template + struct QualitativeResultMinMax { + public: + QualitativeResultMinMax() = default; + + storm::utility::graph::GameProb01Result prob0Min; + storm::utility::graph::GameProb01Result prob1Min; + storm::utility::graph::GameProb01Result prob0Max; + storm::utility::graph::GameProb01Result prob1Max; + }; + + } +} diff --git a/src/storm/abstraction/QuantitativeResult.h b/src/storm/abstraction/QuantitativeResult.h new file mode 100644 index 000000000..f2975067a --- /dev/null +++ b/src/storm/abstraction/QuantitativeResult.h @@ -0,0 +1,25 @@ +#pragma once + +#include "storm/storage/dd/DdType.h" +#include "storm/storage/dd/Add.h" +#include "storm/storage/dd/Bdd.h" + +namespace storm { + namespace abstraction { + + template + struct QuantitativeResult { + QuantitativeResult() = default; + + QuantitativeResult(std::pair initialStatesRange, storm::dd::Add const& values, storm::dd::Bdd const& player1Strategy, storm::dd::Bdd const& player2Strategy) : initialStatesRange(initialStatesRange), values(values), player1Strategy(player1Strategy), player2Strategy(player2Strategy) { + // Intentionally left empty. + } + + std::pair initialStatesRange; + storm::dd::Add values; + storm::dd::Bdd player1Strategy; + storm::dd::Bdd player2Strategy; + }; + + } +} diff --git a/src/storm/abstraction/QuantitativeResultMinMax.h b/src/storm/abstraction/QuantitativeResultMinMax.h new file mode 100644 index 000000000..f0bdab86d --- /dev/null +++ b/src/storm/abstraction/QuantitativeResultMinMax.h @@ -0,0 +1,21 @@ +#pragma once + +#include "storm/abstraction/QuantitativeResult.h" + +namespace storm { + namespace abstraction { + + template + struct QuantitativeResultMinMax { + QuantitativeResultMinMax() = default; + + QuantitativeResultMinMax(QuantitativeResult const& min, QuantitativeResult const& max) : min(min), max(max) { + // Intentionally left empty. + } + + QuantitativeResult min; + QuantitativeResult max; + }; + + } +} diff --git a/src/storm/abstraction/RefinementCommand.cpp b/src/storm/abstraction/RefinementCommand.cpp new file mode 100644 index 000000000..db83cbb18 --- /dev/null +++ b/src/storm/abstraction/RefinementCommand.cpp @@ -0,0 +1,27 @@ +#include "storm/abstraction/RefinementCommand.h" + +namespace storm { + namespace abstraction { + + RefinementCommand::RefinementCommand(uint64_t referencedPlayer1Choice, std::vector const& predicates) : referencedPlayer1Choice(referencedPlayer1Choice), predicates(predicates) { + // Intentionally left empty. + } + + RefinementCommand::RefinementCommand(std::vector const& predicates) : predicates(predicates) { + // Intentionally left empty. + } + + bool RefinementCommand::refersToPlayer1Choice() const { + return static_cast(referencedPlayer1Choice); + } + + uint64_t RefinementCommand::getReferencedPlayer1Choice() const { + return referencedPlayer1Choice.get(); + } + + std::vector const& RefinementCommand::getPredicates() const { + return predicates; + } + + } +} diff --git a/src/storm/abstraction/RefinementCommand.h b/src/storm/abstraction/RefinementCommand.h new file mode 100644 index 000000000..dae7b0f2c --- /dev/null +++ b/src/storm/abstraction/RefinementCommand.h @@ -0,0 +1,36 @@ +#pragma once + +#include +#include + +#include + +#include "storm/storage/expressions/Expression.h" + +namespace storm { + namespace abstraction { + + class RefinementCommand { + public: + /*! + * Creates a new refinement command for the given player 1 choice. + */ + RefinementCommand(uint64_t referencedPlayer1Choice, std::vector const& predicates); + + /*! + * Creates a new refinement command for all player 1 choices. + */ + RefinementCommand(std::vector const& predicates); + + /// Access to the details of this refinement commands. + bool refersToPlayer1Choice() const; + uint64_t getReferencedPlayer1Choice() const; + std::vector const& getPredicates() const; + + private: + boost::optional referencedPlayer1Choice; + std::vector predicates; + }; + + } +} diff --git a/src/storm/abstraction/StateSetAbstractor.cpp b/src/storm/abstraction/StateSetAbstractor.cpp new file mode 100644 index 000000000..986589294 --- /dev/null +++ b/src/storm/abstraction/StateSetAbstractor.cpp @@ -0,0 +1,160 @@ +#include "storm/abstraction/StateSetAbstractor.h" + +#include "storm/abstraction/AbstractionInformation.h" + +#include "storm/storage/dd/DdManager.h" + +#include "storm/utility/macros.h" +#include "storm/utility/solver.h" + +#include "storm-config.h" +#include "storm/adapters/CarlAdapter.h" + +namespace storm { + namespace abstraction { + + template + StateSetAbstractor::StateSetAbstractor(AbstractionInformation& abstractionInformation, std::vector const& statePredicates, std::shared_ptr const& smtSolverFactory) : smtSolver(smtSolverFactory->create(abstractionInformation.getExpressionManager())), abstractionInformation(abstractionInformation), localExpressionInformation(abstractionInformation), relevantPredicatesAndVariables(), concretePredicateVariables(), forceRecomputation(true), cachedBdd(abstractionInformation.getDdManager().getBddOne()), constraint(abstractionInformation.getDdManager().getBddOne()) { + + // Assert all state predicates. + for (auto const& predicate : statePredicates) { + smtSolver->add(predicate); + + // Extract the variables of the predicate, so we know which variables were used when abstracting. + std::set usedVariables = predicate.getVariables(); + concretePredicateVariables.insert(usedVariables.begin(), usedVariables.end()); + localExpressionInformation.relate(usedVariables); + } + } + + template + void StateSetAbstractor::addMissingPredicates(std::set const& newRelevantPredicateIndices) { + std::vector> newPredicateVariables = this->getAbstractionInformation().declareNewVariables(relevantPredicatesAndVariables, newRelevantPredicateIndices); + + for (auto const& element : newPredicateVariables) { + smtSolver->add(storm::expressions::iff(element.first, this->getAbstractionInformation().getPredicateByIndex(element.second))); + decisionVariables.push_back(element.first); + } + + relevantPredicatesAndVariables.insert(relevantPredicatesAndVariables.end(), newPredicateVariables.begin(), newPredicateVariables.end()); + std::sort(relevantPredicatesAndVariables.begin(), relevantPredicatesAndVariables.end(), [] (std::pair const& firstPair, std::pair const& secondPair) { return firstPair.second < secondPair.second; } ); + } + + template + void StateSetAbstractor::refine(std::vector const& newPredicates) { + // Make the partition aware of the new predicates, which may make more predicates relevant to the abstraction. + for (auto const& predicateIndex : newPredicates) { + localExpressionInformation.addExpression(predicateIndex); + } + + std::set newRelevantPredicateIndices = localExpressionInformation.getRelatedExpressions(concretePredicateVariables); + // Since the number of relevant predicates is monotonic, we can simply check for the size here. + STORM_LOG_ASSERT(newRelevantPredicateIndices.size() >= relevantPredicatesAndVariables.size(), "Illegal size of relevant predicates."); + if (newRelevantPredicateIndices.size() > relevantPredicatesAndVariables.size()) { + // Before adding the missing predicates, we need to remove the constraint BDD. + this->popConstraintBdd(); + + // If we need to recompute the BDD, we start by introducing decision variables and the corresponding + // constraints in the SMT problem. + addMissingPredicates(newRelevantPredicateIndices); + + // Then re-add the constraint BDD. + this->pushConstraintBdd(); + forceRecomputation = true; + } + } + + template + void StateSetAbstractor::constrain(storm::expressions::Expression const& constraint) { + smtSolver->add(constraint); + } + + template + void StateSetAbstractor::constrain(storm::dd::Bdd const& newConstraint) { + // If the constraint is different from the last one, we add it to the solver. + if (newConstraint != this->constraint) { + constraint = newConstraint; + this->pushConstraintBdd(); + } + } + + template + storm::dd::Bdd StateSetAbstractor::getStateBdd(storm::solver::SmtSolver::ModelReference const& model) const { + storm::dd::Bdd result = this->getAbstractionInformation().getDdManager().getBddOne(); + for (auto const& variableIndexPair : relevantPredicatesAndVariables) { + if (model.getBooleanValue(variableIndexPair.first)) { + result &= this->getAbstractionInformation().encodePredicateAsSource(variableIndexPair.second); + } else { + result &= !this->getAbstractionInformation().encodePredicateAsSource(variableIndexPair.second); + } + } + return result; + } + + template + void StateSetAbstractor::recomputeCachedBdd() { + STORM_LOG_TRACE("Recomputing BDD for state set abstraction."); + + storm::dd::Bdd result = this->getAbstractionInformation().getDdManager().getBddZero(); + smtSolver->allSat(decisionVariables, [&result,this] (storm::solver::SmtSolver::ModelReference const& model) { result |= getStateBdd(model); return true; } ); + + cachedBdd = result; + } + + template + void StateSetAbstractor::popConstraintBdd() { + // If the last constraint was not the constant one BDD, we need to pop the constraint from the solver. + if (this->constraint.isOne()) { + return; + } + smtSolver->pop(); + } + + template + void StateSetAbstractor::pushConstraintBdd() { + if (this->constraint.isOne()) { + return; + } + + // Create a new backtracking point before adding the constraint. + smtSolver->push(); + + // Create the constraint. + std::pair, std::unordered_map> result = constraint.toExpression(this->getAbstractionInformation().getExpressionManager()); + + // Then add the constraint. + for (auto const& expression : result.first) { + smtSolver->add(expression); + } + + // Finally associate the level variables with the predicates. + for (auto const& indexVariablePair : result.second) { + smtSolver->add(storm::expressions::iff(indexVariablePair.second, this->getAbstractionInformation().getPredicateForDdVariableIndex(indexVariablePair.first))); + } + } + + template + storm::dd::Bdd StateSetAbstractor::getAbstractStates() { + if (forceRecomputation) { + this->recomputeCachedBdd(); + } + return cachedBdd; + } + + template + AbstractionInformation& StateSetAbstractor::getAbstractionInformation() { + return abstractionInformation.get(); + } + + template + AbstractionInformation const& StateSetAbstractor::getAbstractionInformation() const { + return abstractionInformation.get(); + } + + template class StateSetAbstractor; + template class StateSetAbstractor; +#ifdef STORM_HAVE_CARL + template class StateSetAbstractor; +#endif + } +} diff --git a/src/storm/abstraction/StateSetAbstractor.h b/src/storm/abstraction/StateSetAbstractor.h new file mode 100644 index 000000000..96861e8b1 --- /dev/null +++ b/src/storm/abstraction/StateSetAbstractor.h @@ -0,0 +1,159 @@ +#pragma once + +#include +#include +#include + +#include "storm/utility/OsDetection.h" + +#include "storm/storage/dd/DdType.h" + +#include "storm/utility/solver.h" +#include "storm/solver/SmtSolver.h" + +#include "storm/abstraction/LocalExpressionInformation.h" + +namespace storm { + namespace utility { + namespace solver { + class SmtSolverFactory; + } + } + + namespace dd { + template + class Bdd; + + template + class Add; + } + + namespace abstraction { + template + class AbstractionInformation; + + template + class StateSetAbstractor { + public: + StateSetAbstractor(StateSetAbstractor const& other) = default; + StateSetAbstractor& operator=(StateSetAbstractor const& other) = default; + +#ifndef WINDOWS + StateSetAbstractor(StateSetAbstractor&& other) = default; + StateSetAbstractor& operator=(StateSetAbstractor&& other) = default; +#endif + + /*! + * Creates a state set abstractor. + * + * @param abstractionInformation An object storing information about the abstraction such as predicates and BDDs. + * @param statePredicates A set of predicates that have to hold in the concrete states this abstractor is + * supposed to abstract. + * @param smtSolverFactory A factory that can create new SMT solvers. + */ + StateSetAbstractor(AbstractionInformation& abstractionInformation, std::vector const& statePredicates, std::shared_ptr const& smtSolverFactory = std::make_shared()); + + /*! + * Refines the abstractor by making the given predicates new abstract predicates. + * + * @param newPredicateIndices The indices of the new predicates. + */ + void refine(std::vector const& newPredicateIndices); + + /*! + * Constrains the abstract states with the given expression. + * Note that all constaints must be added before the abstractor is used to retrieve the abstract states. + * + * @param constraint The constraint to add. + */ + void constrain(storm::expressions::Expression const& constraint); + + /*! + * Constraints the abstract states with the given BDD. + * + * @param newConstraint The BDD used as the constraint. + */ + void constrain(storm::dd::Bdd const& newConstraint); + + /*! + * Retrieves the set of abstract states matching all predicates added to this abstractor. + * + * @return The set of matching abstract states in the form of a BDD + */ + storm::dd::Bdd getAbstractStates(); + + private: + /*! + * Creates decision variables and the corresponding constraints for the missing predicates. + * + * @param newRelevantPredicateIndices The set of all relevant predicate indices. + */ + void addMissingPredicates(std::set const& newRelevantPredicateIndices); + + /*! + * Adds the current constraint BDD to the solver. + */ + void pushConstraintBdd(); + + /*! + * Removes the current constraint BDD (if any) from the solver. + */ + void popConstraintBdd(); + + /*! + * Recomputes the cached BDD. This needs to be triggered if any relevant predicates change. + */ + void recomputeCachedBdd(); + + /*! + * Translates the given model to a state DD. + * + * @param model The model to translate. + * @return The state encoded as a DD. + */ + storm::dd::Bdd getStateBdd(storm::solver::SmtSolver::ModelReference const& model) const; + + /*! + * Retrieves the abstraction information. + * + * @return The abstraction information. + */ + AbstractionInformation& getAbstractionInformation(); + + /*! + * Retrieves the abstraction information. + * + * @return The abstraction information. + */ + AbstractionInformation const& getAbstractionInformation() const; + + // The SMT solver used for abstracting the set of states. + std::unique_ptr smtSolver; + + // The abstraction-related information. + std::reference_wrapper> abstractionInformation; + + // The local expression-related information. + LocalExpressionInformation localExpressionInformation; + + // The set of relevant predicates and the corresponding decision variables. + std::vector> relevantPredicatesAndVariables; + + // The set of all variables appearing in the concrete predicates. + std::set concretePredicateVariables; + + // The set of all decision variables over which to perform the all-sat enumeration. + std::vector decisionVariables; + + // A flag indicating whether the cached BDD needs recomputation. + bool forceRecomputation; + + // The cached BDD representing the abstraction. This variable is written to in refinement steps (if work + // needed to be done). + storm::dd::Bdd cachedBdd; + + // This BDD currently constrains the search for solutions. + storm::dd::Bdd constraint; + }; + } +} diff --git a/src/storm/abstraction/ValidBlockAbstractor.cpp b/src/storm/abstraction/ValidBlockAbstractor.cpp new file mode 100644 index 000000000..dcfdcf20c --- /dev/null +++ b/src/storm/abstraction/ValidBlockAbstractor.cpp @@ -0,0 +1,136 @@ +#include "storm/abstraction/ValidBlockAbstractor.h" + +#include "storm/abstraction/AbstractionInformation.h" + +#include "storm/storage/dd/DdManager.h" + +#include "storm/utility/solver.h" + +namespace storm { + namespace abstraction { + + template + ValidBlockAbstractor::ValidBlockAbstractor(AbstractionInformation& abstractionInformation, std::shared_ptr const& smtSolverFactory) : abstractionInformation(abstractionInformation), localExpressionInformation(abstractionInformation), validBlocks(abstractionInformation.getDdManager().getBddOne()), checkForRecomputation(false) { + + uint64_t numberOfBlocks = localExpressionInformation.getNumberOfBlocks(); + validBlocksForPredicateBlocks.resize(numberOfBlocks, abstractionInformation.getDdManager().getBddOne()); + relevantVariablesAndPredicates.resize(numberOfBlocks); + decisionVariables.resize(numberOfBlocks); + + for (uint64_t i = 0; i < numberOfBlocks; ++i) { + smtSolvers.emplace_back(smtSolverFactory->create(abstractionInformation.getExpressionManager())); + for (auto const& constraint : abstractionInformation.getConstraints()) { + smtSolvers.back()->add(constraint); + } + } + } + + template + storm::dd::Bdd const& ValidBlockAbstractor::getValidBlocks() { + if (checkForRecomputation) { + recomputeValidBlocks(); + } + + return validBlocks; + } + + template + void ValidBlockAbstractor::refine(std::vector const& predicates) { + for (auto const& predicate : predicates) { + std::map mergeInformation = localExpressionInformation.addExpression(predicate); + + // Perform the remapping caused by merges. + for (auto const& blockRemapping : mergeInformation) { + if (blockRemapping.first == blockRemapping.second) { + continue; + } + + validBlocksForPredicateBlocks[blockRemapping.second] = validBlocksForPredicateBlocks[blockRemapping.first]; + smtSolvers[blockRemapping.second] = std::move(smtSolvers[blockRemapping.first]); + relevantVariablesAndPredicates[blockRemapping.second] = std::move(relevantVariablesAndPredicates[blockRemapping.first]); + decisionVariables[blockRemapping.second] = std::move(decisionVariables[blockRemapping.first]); + } + validBlocksForPredicateBlocks.resize(localExpressionInformation.getNumberOfBlocks()); + smtSolvers.resize(localExpressionInformation.getNumberOfBlocks()); + relevantVariablesAndPredicates.resize(localExpressionInformation.getNumberOfBlocks()); + decisionVariables.resize(localExpressionInformation.getNumberOfBlocks()); + } + checkForRecomputation = true; + } + + template + void ValidBlockAbstractor::recomputeValidBlocks() { + storm::dd::Bdd newValidBlocks = abstractionInformation.get().getDdManager().getBddOne(); + + for (uint64_t blockIndex = 0; blockIndex < localExpressionInformation.getNumberOfBlocks(); ++blockIndex) { + std::set const& predicateBlock = localExpressionInformation.getExpressionBlock(blockIndex); + + // If the size of the block changed, we need to add the appropriate variables and recompute the solution. + if (relevantVariablesAndPredicates[blockIndex].size() < predicateBlock.size()) { + recomputeValidBlockForPredicateBlock(blockIndex); + } + + newValidBlocks &= validBlocksForPredicateBlocks[blockIndex]; + } + + validBlocks = newValidBlocks; + } + + template + void ValidBlockAbstractor::recomputeValidBlockForPredicateBlock(uint64_t blockIndex) { + std::set const& predicateBlock = localExpressionInformation.getExpressionBlock(blockIndex); + + std::vector> newVariables = this->getAbstractionInformation().declareNewVariables(relevantVariablesAndPredicates[blockIndex], predicateBlock); + for (auto const& element : newVariables) { + smtSolvers[blockIndex]->add(storm::expressions::iff(element.first, this->getAbstractionInformation().getPredicateByIndex(element.second))); + decisionVariables[blockIndex].push_back(element.first); + } + + relevantVariablesAndPredicates[blockIndex].insert(relevantVariablesAndPredicates[blockIndex].end(), newVariables.begin(), newVariables.end()); + std::sort(relevantVariablesAndPredicates[blockIndex].begin(), relevantVariablesAndPredicates[blockIndex].end(), + [] (std::pair const& first, std::pair const& second) { + return first.second < second.second; + }); + + // Use all-sat to enumerate all valid blocks for this predicate block. + storm::dd::Bdd result = this->getAbstractionInformation().getDdManager().getBddZero(); + uint64_t numberOfSolutions = 0; + smtSolvers[blockIndex]->allSat(decisionVariables[blockIndex], [&result,this,&numberOfSolutions,blockIndex] (storm::solver::SmtSolver::ModelReference const& model) { + result |= getSourceStateBdd(model, blockIndex); + ++numberOfSolutions; + return true; + }); + + STORM_LOG_TRACE("Computed valid blocks for predicate block " << blockIndex << " (" << numberOfSolutions << " solutions enumerated)."); + + validBlocksForPredicateBlocks[blockIndex] = result; + } + + template + AbstractionInformation const& ValidBlockAbstractor::getAbstractionInformation() const { + return abstractionInformation.get(); + } + + template + storm::dd::Bdd ValidBlockAbstractor::getSourceStateBdd(storm::solver::SmtSolver::ModelReference const& model, uint64_t blockIndex) const { + storm::dd::Bdd result = this->getAbstractionInformation().getDdManager().getBddOne(); +// std::cout << "new model ----------------" << std::endl; + for (auto const& variableIndexPair : relevantVariablesAndPredicates[blockIndex]) { + if (model.getBooleanValue(variableIndexPair.first)) { +// std::cout << this->getAbstractionInformation().getPredicateByIndex(variableIndexPair.second) << " is true" << std::endl; + result &= this->getAbstractionInformation().encodePredicateAsSource(variableIndexPair.second); + } else { +// std::cout << this->getAbstractionInformation().getPredicateByIndex(variableIndexPair.second) << " is false" << std::endl; + result &= !this->getAbstractionInformation().encodePredicateAsSource(variableIndexPair.second); + } + } + + STORM_LOG_ASSERT(!result.isZero(), "Source must not be empty."); + return result; + } + + template class ValidBlockAbstractor; + template class ValidBlockAbstractor; + + } +} diff --git a/src/storm/abstraction/ValidBlockAbstractor.h b/src/storm/abstraction/ValidBlockAbstractor.h new file mode 100644 index 000000000..6e0b28ab4 --- /dev/null +++ b/src/storm/abstraction/ValidBlockAbstractor.h @@ -0,0 +1,88 @@ +#pragma once + +#include +#include +#include +#include + +#include "storm/storage/dd/DdType.h" +#include "storm/storage/dd/Bdd.h" + +#include "storm/abstraction/LocalExpressionInformation.h" + +#include "storm/solver/SmtSolver.h" + +namespace storm { + namespace utility { + namespace solver { + class SmtSolverFactory; + } + } + + namespace abstraction { + + template + class AbstractionInformation; + + template + class ValidBlockAbstractor { + public: + ValidBlockAbstractor(AbstractionInformation& abstractionInformation, std::shared_ptr const& smtSolverFactory); + + storm::dd::Bdd const& getValidBlocks(); + + void refine(std::vector const& predicates); + + private: + /*! + * Checks which parts of the valid blocks need to be recomputed. + */ + void recomputeValidBlocks(); + + /*! + * Recomputed the valid blocks for the given predicate block. + */ + void recomputeValidBlockForPredicateBlock(uint64_t blockIndex); + + /*! + * Retrieves the abstraction information object. + */ + AbstractionInformation const& getAbstractionInformation() const; + + /*! + * Translates the given model to a source state DD. + * + * @param model The model to translate. + * @param blockIndex The index of the block. + * @return The source state encoded as a DD. + */ + storm::dd::Bdd getSourceStateBdd(storm::solver::SmtSolver::ModelReference const& model, uint64_t blockIndex) const; + + /// The object storing the information about the abstraction (like predicates etc.) + std::reference_wrapper const> abstractionInformation; + + /// An object storing information about how predicates are related. + LocalExpressionInformation localExpressionInformation; + + /// The BDD storing all valid blocks; + storm::dd::Bdd validBlocks; + + /// A vector of SMT solvers that correspond to the predicate blocks in the local expression information. + std::vector> smtSolvers; + + /// A vector of relevant variables and predicates. Every inner vector corresponds to one block of the local + /// expression information. + std::vector>> relevantVariablesAndPredicates; + + /// The decision variables for each predicate block. + std::vector> decisionVariables; + + /// A vector of BDDs that store the valid blocks for the individual predicate blocks to be able to reuse them. + std::vector> validBlocksForPredicateBlocks; + + /// A flag that stores whether we need to possibly recompute the valid blocks (or parts). + bool checkForRecomputation; + }; + + } +} diff --git a/src/storm/abstraction/jani/AutomatonAbstractor.cpp b/src/storm/abstraction/jani/AutomatonAbstractor.cpp new file mode 100644 index 000000000..f22760db8 --- /dev/null +++ b/src/storm/abstraction/jani/AutomatonAbstractor.cpp @@ -0,0 +1,140 @@ +#include "storm/abstraction/jani/AutomatonAbstractor.h" + +#include "storm/abstraction/BottomStateResult.h" +#include "storm/abstraction/GameBddResult.h" +#include "storm/abstraction/AbstractionInformation.h" + +#include "storm/storage/dd/DdManager.h" +#include "storm/storage/dd/Add.h" + +#include "storm/storage/jani/Automaton.h" + +#include "storm/settings/SettingsManager.h" + +#include "storm-config.h" +#include "storm/adapters/CarlAdapter.h" + +#include "storm/utility/macros.h" + +namespace storm { + namespace abstraction { + namespace jani { + + using storm::settings::modules::AbstractionSettings; + + template + AutomatonAbstractor::AutomatonAbstractor(storm::jani::Automaton const& automaton, AbstractionInformation& abstractionInformation, std::shared_ptr const& smtSolverFactory, bool useDecomposition) : smtSolverFactory(smtSolverFactory), abstractionInformation(abstractionInformation), edges(), automaton(automaton) { + + // For each concrete command, we create an abstract counterpart. + uint64_t edgeId = 0; + for (auto const& edge : automaton.getEdges()) { + edges.emplace_back(edgeId, edge, abstractionInformation, smtSolverFactory, useDecomposition); + ++edgeId; + } + + if (automaton.getNumberOfLocations() > 1) { + locationVariables = abstractionInformation.addLocationVariables(automaton.getLocationExpressionVariable(), automaton.getNumberOfLocations() - 1).first; + } + } + + template + void AutomatonAbstractor::refine(std::vector const& predicates) { + for (uint_fast64_t index = 0; index < edges.size(); ++index) { + STORM_LOG_TRACE("Refining edge with index " << index << "."); + edges[index].refine(predicates); + } + } + + template + storm::expressions::Expression const& AutomatonAbstractor::getGuard(uint64_t player1Choice) const { + return edges[player1Choice].getGuard(); + } + + template + std::map AutomatonAbstractor::getVariableUpdates(uint64_t player1Choice, uint64_t auxiliaryChoice) const { + return edges[player1Choice].getVariableUpdates(auxiliaryChoice); + } + + template + GameBddResult AutomatonAbstractor::abstract() { + // First, we retrieve the abstractions of all commands. + std::vector> edgeDdsAndUsedOptionVariableCounts; + uint_fast64_t maximalNumberOfUsedOptionVariables = 0; + for (auto& edge : edges) { + edgeDdsAndUsedOptionVariableCounts.push_back(edge.abstract()); + maximalNumberOfUsedOptionVariables = std::max(maximalNumberOfUsedOptionVariables, edgeDdsAndUsedOptionVariableCounts.back().numberOfPlayer2Variables); + } + + // Then, we build the module BDD by adding the single command DDs. We need to make sure that all command + // DDs use the same amount DD variable encoding the choices of player 2. + storm::dd::Bdd result = this->getAbstractionInformation().getDdManager().getBddZero(); + for (auto const& edgeDd : edgeDdsAndUsedOptionVariableCounts) { + result |= edgeDd.bdd && this->getAbstractionInformation().encodePlayer2Choice(1, edgeDd.numberOfPlayer2Variables, maximalNumberOfUsedOptionVariables); + } + return GameBddResult(result, maximalNumberOfUsedOptionVariables); + } + + template + BottomStateResult AutomatonAbstractor::getBottomStateTransitions(storm::dd::Bdd const& reachableStates, uint_fast64_t numberOfPlayer2Variables) { + BottomStateResult result(this->getAbstractionInformation().getDdManager().getBddZero(), this->getAbstractionInformation().getDdManager().getBddZero()); + + for (auto& edge : edges) { + BottomStateResult commandBottomStateResult = edge.getBottomStateTransitions(reachableStates, numberOfPlayer2Variables, locationVariables); + result.states |= commandBottomStateResult.states; + result.transitions |= commandBottomStateResult.transitions; + } + + return result; + } + + template + storm::dd::Add AutomatonAbstractor::getEdgeDecoratorAdd() const { + storm::dd::Add result = this->getAbstractionInformation().getDdManager().template getAddZero(); + for (auto const& edge : edges) { + result += edge.getEdgeDecoratorAdd(locationVariables); + } + return result; + } + + template + storm::dd::Bdd AutomatonAbstractor::getInitialLocationsBdd() const { + if (automaton.get().getNumberOfLocations() == 1) { + return this->getAbstractionInformation().getDdManager().getBddOne(); + } + + std::set const& initialLocationIndices = automaton.get().getInitialLocationIndices(); + storm::dd::Bdd result = this->getAbstractionInformation().getDdManager().getBddZero(); + for (auto const& initialLocationIndex : initialLocationIndices) { + result |= this->getAbstractionInformation().encodeLocation(locationVariables.get().first, initialLocationIndex); + } + return result; + } + + template + std::vector> const& AutomatonAbstractor::getEdges() const { + return edges; + } + + template + std::vector>& AutomatonAbstractor::getEdges() { + return edges; + } + + template + std::size_t AutomatonAbstractor::getNumberOfEdges() const { + return edges.size(); + } + + template + AbstractionInformation const& AutomatonAbstractor::getAbstractionInformation() const { + return abstractionInformation.get(); + } + + template class AutomatonAbstractor; + template class AutomatonAbstractor; +#ifdef STORM_HAVE_CARL + template class AutomatonAbstractor; +#endif + } + } +} diff --git a/src/storm/abstraction/jani/AutomatonAbstractor.h b/src/storm/abstraction/jani/AutomatonAbstractor.h new file mode 100644 index 000000000..ac010a0d9 --- /dev/null +++ b/src/storm/abstraction/jani/AutomatonAbstractor.h @@ -0,0 +1,140 @@ +#pragma once + +#include "storm/storage/dd/DdType.h" + +#include "storm/abstraction/jani/EdgeAbstractor.h" + +#include "storm/settings/modules/AbstractionSettings.h" + +#include "storm/storage/expressions/Expression.h" + +#include "storm/utility/solver.h" + +namespace storm { + namespace jani { + // Forward-declare concrete automaton class. + class Automaton; + } + + namespace abstraction { + template + class AbstractionInformation; + + template + struct BottomStateResult; + + namespace jani { + template + class AutomatonAbstractor { + public: + /*! + * Constructs an abstract module from the given automaton. + * + * @param automaton The concrete automaton for which to build the abstraction. + * @param abstractionInformation An object holding information about the abstraction such as predicates and BDDs. + * @param smtSolverFactory A factory that is to be used for creating new SMT solvers. + * @param useDecomposition A flag indicating whether to use the decomposition during abstraction. + */ + AutomatonAbstractor(storm::jani::Automaton const& automaton, AbstractionInformation& abstractionInformation, std::shared_ptr const& smtSolverFactory, bool useDecomposition); + + AutomatonAbstractor(AutomatonAbstractor const&) = default; + AutomatonAbstractor& operator=(AutomatonAbstractor const&) = default; + AutomatonAbstractor(AutomatonAbstractor&&) = default; + AutomatonAbstractor& operator=(AutomatonAbstractor&&) = default; + + /*! + * Refines the abstract automaton with the given predicates. + * + * @param predicates The new predicate indices. + */ + void refine(std::vector const& predicates); + + /*! + * Retrieves the guard of the given player 1 choice. + * + * @param player1Choice The choice of player 1. + * @return The guard of the player 1 choice. + */ + storm::expressions::Expression const& getGuard(uint64_t player1Choice) const; + + /*! + * Retrieves a mapping from variables to expressions that define their updates wrt. to the given player + * 1 choice and auxiliary choice. + */ + std::map getVariableUpdates(uint64_t player1Choice, uint64_t auxiliaryChoice) const; + + /*! + * Computes the abstraction of the module wrt. to the current set of predicates. + * + * @return The abstraction of the module in the form of a BDD together with how many option variables were used. + */ + GameBddResult abstract(); + + /*! + * Retrieves the transitions to bottom states of this automaton. + * + * @param reachableStates A BDD representing the reachable states. + * @param numberOfPlayer2Variables The number of variables used to encode the choices of player 2. + * @return The bottom states and the necessary transitions. + */ + BottomStateResult getBottomStateTransitions(storm::dd::Bdd const& reachableStates, uint_fast64_t numberOfPlayer2Variables); + + /*! + * Retrieves an ADD that maps the encodings of edges, source/target locations and their updates to their probabilities. + * + * @return The edge decorator ADD. + */ + storm::dd::Add getEdgeDecoratorAdd() const; + + /*! + * Retrieves a BDD that encodes all initial locations of this abstract automaton. + */ + storm::dd::Bdd getInitialLocationsBdd() const; + + /*! + * Retrieves the abstract edges of this abstract automton. + * + * @return The abstract edges. + */ + std::vector> const& getEdges() const; + + /*! + * Retrieves the abstract edges of this abstract automaton. + * + * @return The abstract edges. + */ + std::vector>& getEdges(); + + /*! + * Retrieves the number of abstract edges of this abstract automaton. + * + * @param The number of edges. + */ + std::size_t getNumberOfEdges() const; + + private: + /*! + * Retrieves the abstraction information. + * + * @return The abstraction information. + */ + AbstractionInformation const& getAbstractionInformation() const; + + // A factory that can be used to create new SMT solvers. + std::shared_ptr smtSolverFactory; + + // The DD-related information. + std::reference_wrapper const> abstractionInformation; + + // The abstract edge of the abstract automaton. + std::vector> edges; + + // The concrete module this abstract automaton refers to. + std::reference_wrapper automaton; + + // If the automaton has more than one location, we need variables to encode that. + boost::optional> locationVariables; + }; + } + } +} diff --git a/src/storm/abstraction/jani/EdgeAbstractor.cpp b/src/storm/abstraction/jani/EdgeAbstractor.cpp new file mode 100644 index 000000000..980db0846 --- /dev/null +++ b/src/storm/abstraction/jani/EdgeAbstractor.cpp @@ -0,0 +1,705 @@ +#include "storm/abstraction/jani/EdgeAbstractor.h" + +#include + +#include + +#include "storm/abstraction/BottomStateResult.h" +#include "storm/abstraction/AbstractionInformation.h" + +#include "storm/storage/dd/DdManager.h" +#include "storm/storage/dd/Add.h" + +#include "storm/storage/jani/Edge.h" +#include "storm/storage/jani/EdgeDestination.h" + +#include "storm/utility/solver.h" +#include "storm/utility/macros.h" + +#include "storm-config.h" +#include "storm/adapters/CarlAdapter.h" + +namespace storm { + namespace abstraction { + namespace jani { + template + EdgeAbstractor::EdgeAbstractor(uint64_t edgeId, storm::jani::Edge const& edge, AbstractionInformation& abstractionInformation, std::shared_ptr const& smtSolverFactory, bool useDecomposition) : smtSolver(smtSolverFactory->create(abstractionInformation.getExpressionManager())), abstractionInformation(abstractionInformation), edgeId(edgeId), edge(edge), localExpressionInformation(abstractionInformation), evaluator(abstractionInformation.getExpressionManager()), relevantPredicatesAndVariables(), cachedDd(abstractionInformation.getDdManager().getBddZero(), 0), decisionVariables(), useDecomposition(useDecomposition), skipBottomStates(false), forceRecomputation(true), abstractGuard(abstractionInformation.getDdManager().getBddZero()), bottomStateAbstractor(abstractionInformation, {!edge.getGuard()}, smtSolverFactory) { + + // Make the second component of relevant predicates have the right size. + relevantPredicatesAndVariables.second.resize(edge.getNumberOfDestinations()); + + // Assert all constraints to enforce legal variable values. + for (auto const& constraint : abstractionInformation.getConstraints()) { + smtSolver->add(constraint); + bottomStateAbstractor.constrain(constraint); + } + + // Assert the guard of the command. + smtSolver->add(edge.getGuard()); + } + + template + void EdgeAbstractor::refine(std::vector const& predicates) { + // Add all predicates to the variable partition. + for (auto predicateIndex : predicates) { + localExpressionInformation.addExpression(predicateIndex); + } + + // Next, we check whether there is work to be done by recomputing the relevant predicates and checking + // whether they changed. + std::pair, std::vector>> newRelevantPredicates = this->computeRelevantPredicates(); + + // Check whether we need to recompute the abstraction. + bool relevantPredicatesChanged = this->relevantPredicatesChanged(newRelevantPredicates); + if (relevantPredicatesChanged) { + addMissingPredicates(newRelevantPredicates); + } + forceRecomputation |= relevantPredicatesChanged; + + // Refine bottom state abstractor. Note that this does not trigger a recomputation yet. + bottomStateAbstractor.refine(predicates); + } + + template + storm::expressions::Expression const& EdgeAbstractor::getGuard() const { + return edge.get().getGuard(); + } + + template + std::map EdgeAbstractor::getVariableUpdates(uint64_t auxiliaryChoice) const { + return edge.get().getDestination(auxiliaryChoice).getAsVariableToExpressionMap(); + } + + template + void EdgeAbstractor::recomputeCachedBdd() { + if (useDecomposition) { + recomputeCachedBddWithDecomposition(); + } else { + recomputeCachedBddWithoutDecomposition(); + } + } + + template + void EdgeAbstractor::recomputeCachedBddWithDecomposition() { + STORM_LOG_TRACE("Recomputing BDD for edge with id " << edgeId << " and guard " << edge.get().getGuard() << " using the decomposition."); + auto start = std::chrono::high_resolution_clock::now(); + + // compute a decomposition of the command + // * start with all relevant blocks: blocks of assignment variables and variables in the rhs of assignments + // * go through all assignments of all updates and merge relevant blocks that are related via an assignment + // * repeat this until nothing changes anymore + // * the resulting blocks are the decomposition + + // Start by constructing the relevant blocks. + std::set allRelevantBlocks; + std::map variableToBlockIndex; + for (auto const& destination : edge.get().getDestinations()) { + for (auto const& assignment : destination.getOrderedAssignments().getAllAssignments()) { + allRelevantBlocks.insert(localExpressionInformation.getBlockIndexOfVariable(assignment.getExpressionVariable())); + + auto rhsVariableBlocks = localExpressionInformation.getBlockIndicesOfVariables(assignment.getAssignedExpression().getVariables()); + allRelevantBlocks.insert(rhsVariableBlocks.begin(), rhsVariableBlocks.end()); + } + } + STORM_LOG_TRACE("Found " << allRelevantBlocks.size() << " relevant block(s)."); + + // Create a block partition. + std::vector> relevantBlockPartition; + std::map variableToLocalBlockIndex; + uint64_t index = 0; + for (auto const& blockIndex : allRelevantBlocks) { + relevantBlockPartition.emplace_back(std::set({blockIndex})); + for (auto const& variable : localExpressionInformation.getVariableBlockWithIndex(blockIndex)) { + variableToLocalBlockIndex[variable] = index; + } + ++index; + } + + // Merge all blocks that are related via the right-hand side of assignments. + for (auto const& destination : edge.get().getDestinations()) { + for (auto const& assignment : destination.getOrderedAssignments().getAllAssignments()) { + std::set rhsVariables = assignment.getAssignedExpression().getVariables(); + + if (!rhsVariables.empty()) { + uint64_t blockToKeep = variableToLocalBlockIndex.at(*rhsVariables.begin()); + for (auto const& variable : rhsVariables) { + uint64_t block = variableToLocalBlockIndex.at(variable); + if (block != blockToKeep) { + for (auto const& blockIndex : relevantBlockPartition[block]) { + for (auto const& variable : localExpressionInformation.getVariableBlockWithIndex(blockIndex)) { + variableToLocalBlockIndex[variable] = blockToKeep; + } + } + relevantBlockPartition[blockToKeep].insert(relevantBlockPartition[block].begin(), relevantBlockPartition[block].end()); + relevantBlockPartition[block].clear(); + } + } + } + } + } + + // Proceed by relating the blocks via assignment-variables and the expressions of their assigned expressions. + bool changed = false; + do { + changed = false; + for (auto const& destination : edge.get().getDestinations()) { + for (auto const& assignment : destination.getOrderedAssignments().getAllAssignments()) { + std::set rhsVariables = assignment.getAssignedExpression().getVariables(); + + if (!rhsVariables.empty()) { + storm::expressions::Variable const& representativeVariable = *rhsVariables.begin(); + uint64_t representativeBlock = variableToLocalBlockIndex.at(representativeVariable); + uint64_t assignmentVariableBlock = variableToLocalBlockIndex.at(assignment.getExpressionVariable()); + + // If the blocks are different, we merge them now + if (assignmentVariableBlock != representativeBlock) { + changed = true; + + for (auto const& blockIndex : relevantBlockPartition[assignmentVariableBlock]) { + for (auto const& variable : localExpressionInformation.getVariableBlockWithIndex(blockIndex)) { + variableToLocalBlockIndex[variable] = representativeBlock; + } + } + relevantBlockPartition[representativeBlock].insert(relevantBlockPartition[assignmentVariableBlock].begin(), relevantBlockPartition[assignmentVariableBlock].end()); + relevantBlockPartition[assignmentVariableBlock].clear(); + + } + } + } + } + } while (changed); + + // Now remove all blocks that are empty and obtain the partition. + std::vector> cleanedRelevantBlockPartition; + for (auto& element : relevantBlockPartition) { + if (!element.empty()) { + cleanedRelevantBlockPartition.emplace_back(std::move(element)); + } + } + relevantBlockPartition = std::move(cleanedRelevantBlockPartition); + + // if the decomposition has size 1, use the plain technique from before + if (relevantBlockPartition.size() == 1) { + STORM_LOG_TRACE("Relevant block partition size is one, falling back to regular computation."); + recomputeCachedBddWithoutDecomposition(); + } else { + std::set variablesContainedInGuard = edge.get().getGuard().getVariables(); + + // Check whether we need to enumerate the guard. This is the case if the blocks related by the guard + // are not contained within a single block of our decomposition. + bool enumerateAbstractGuard = true; + std::set guardBlocks = localExpressionInformation.getBlockIndicesOfVariables(variablesContainedInGuard); + for (auto const& block : relevantBlockPartition) { + bool allContained = true; + for (auto const& guardBlock : guardBlocks) { + if (block.find(guardBlock) == block.end()) { + allContained = false; + break; + } + } + if (allContained) { + enumerateAbstractGuard = false; + } + } + + uint64_t numberOfSolutions = 0; + + if (enumerateAbstractGuard) { + // otherwise, enumerate the abstract guard so we do this only once + std::set relatedGuardPredicates = localExpressionInformation.getRelatedExpressions(variablesContainedInGuard); + std::vector guardDecisionVariables; + std::vector> guardVariablesAndPredicates; + for (auto const& element : relevantPredicatesAndVariables.first) { + if (relatedGuardPredicates.find(element.second) != relatedGuardPredicates.end()) { + guardDecisionVariables.push_back(element.first); + guardVariablesAndPredicates.push_back(element); + } + } + abstractGuard = this->getAbstractionInformation().getDdManager().getBddZero(); + smtSolver->allSat(guardDecisionVariables, [this,&guardVariablesAndPredicates,&numberOfSolutions] (storm::solver::SmtSolver::ModelReference const& model) { + abstractGuard |= getSourceStateBdd(model, guardVariablesAndPredicates); + ++numberOfSolutions; + return true; + }); + STORM_LOG_TRACE("Enumerated " << numberOfSolutions << " for abstract guard."); + + // now that we have the abstract guard, we can add it as an assertion to the solver before enumerating + // the other solutions. + + // Create a new backtracking point before adding the guard. + smtSolver->push(); + + // Create the guard constraint. + std::pair, std::unordered_map> result = abstractGuard.toExpression(this->getAbstractionInformation().getExpressionManager()); + + // Then add it to the solver. + for (auto const& expression : result.first) { + smtSolver->add(expression); + } + + // Finally associate the level variables with the predicates. + for (auto const& indexVariablePair : result.second) { + smtSolver->add(storm::expressions::iff(indexVariablePair.second, this->getAbstractionInformation().getPredicateForDdVariableIndex(indexVariablePair.first))); + } + } + + // then enumerate the solutions for each of the blocks of the decomposition + uint64_t usedNondeterminismVariables = 0; + uint64_t blockCounter = 0; + std::vector> blockBdds; + for (auto const& block : relevantBlockPartition) { + std::set relevantPredicates; + for (auto const& innerBlock : block) { + relevantPredicates.insert(localExpressionInformation.getExpressionBlock(innerBlock).begin(), localExpressionInformation.getExpressionBlock(innerBlock).end()); + } + + std::vector transitionDecisionVariables; + std::vector> sourceVariablesAndPredicates; + for (auto const& element : relevantPredicatesAndVariables.first) { + if (relevantPredicates.find(element.second) != relevantPredicates.end()) { + transitionDecisionVariables.push_back(element.first); + sourceVariablesAndPredicates.push_back(element); + } + } + + std::vector>> destinationVariablesAndPredicates; + for (uint64_t destinationIndex = 0; destinationIndex < edge.get().getNumberOfDestinations(); ++destinationIndex) { + destinationVariablesAndPredicates.emplace_back(); + for (auto const& assignment : edge.get().getDestination(destinationIndex).getOrderedAssignments().getAllAssignments()) { + uint64_t assignmentVariableBlockIndex = localExpressionInformation.getBlockIndexOfVariable(assignment.getExpressionVariable()); + std::set const& assignmentVariableBlock = localExpressionInformation.getExpressionBlock(assignmentVariableBlockIndex); + if (block.find(assignmentVariableBlockIndex) != block.end()) { + for (auto const& element : relevantPredicatesAndVariables.second[destinationIndex]) { + if (assignmentVariableBlock.find(element.second) != assignmentVariableBlock.end()) { + destinationVariablesAndPredicates.back().push_back(element); + transitionDecisionVariables.push_back(element.first); + } + } + } + } + } + + std::unordered_map, std::vector>> sourceToDistributionsMap; + numberOfSolutions = 0; + smtSolver->allSat(transitionDecisionVariables, [&sourceToDistributionsMap,this,&numberOfSolutions,&sourceVariablesAndPredicates,&destinationVariablesAndPredicates] (storm::solver::SmtSolver::ModelReference const& model) { + sourceToDistributionsMap[getSourceStateBdd(model, sourceVariablesAndPredicates)].push_back(getDistributionBdd(model, destinationVariablesAndPredicates)); + ++numberOfSolutions; + return true; + }); + STORM_LOG_TRACE("Enumerated " << numberOfSolutions << " solutions for block " << blockCounter << "."); + numberOfSolutions = 0; + + // Now we search for the maximal number of choices of player 2 to determine how many DD variables we + // need to encode the nondeterminism. + uint_fast64_t maximalNumberOfChoices = 0; + for (auto const& sourceDistributionsPair : sourceToDistributionsMap) { + maximalNumberOfChoices = std::max(maximalNumberOfChoices, static_cast(sourceDistributionsPair.second.size())); + } + + // We now compute how many variables we need to encode the choices. We add one to the maximal number of + // choices to account for a possible transition to a bottom state. + uint_fast64_t numberOfVariablesNeeded = static_cast(std::ceil(std::log2(maximalNumberOfChoices + 1))); + + // Finally, build overall result. + storm::dd::Bdd resultBdd = this->getAbstractionInformation().getDdManager().getBddZero(); + + uint_fast64_t sourceStateIndex = 0; + for (auto const& sourceDistributionsPair : sourceToDistributionsMap) { + STORM_LOG_ASSERT(!sourceDistributionsPair.first.isZero(), "The source BDD must not be empty."); + STORM_LOG_ASSERT(!sourceDistributionsPair.second.empty(), "The distributions must not be empty."); + // We start with the distribution index of 1, becase 0 is reserved for a potential bottom choice. + uint_fast64_t distributionIndex = 1; + storm::dd::Bdd allDistributions = this->getAbstractionInformation().getDdManager().getBddZero(); + for (auto const& distribution : sourceDistributionsPair.second) { + allDistributions |= distribution && this->getAbstractionInformation().encodePlayer2Choice(distributionIndex, usedNondeterminismVariables, usedNondeterminismVariables + numberOfVariablesNeeded); + ++distributionIndex; + STORM_LOG_ASSERT(!allDistributions.isZero(), "The BDD must not be empty."); + } + resultBdd |= sourceDistributionsPair.first && allDistributions; + ++sourceStateIndex; + STORM_LOG_ASSERT(!resultBdd.isZero(), "The BDD must not be empty."); + } + usedNondeterminismVariables += numberOfVariablesNeeded; + + blockBdds.push_back(resultBdd); + ++blockCounter; + } + + if (enumerateAbstractGuard) { + smtSolver->pop(); + } + + // multiply the results + storm::dd::Bdd resultBdd = getAbstractionInformation().getDdManager().getBddOne(); + for (auto const& blockBdd : blockBdds) { + resultBdd &= blockBdd; + } + + // if we did not explicitly enumerate the guard, we can construct it from the result BDD. + if (!enumerateAbstractGuard) { + std::set allVariables(this->getAbstractionInformation().getSuccessorVariables()); + auto player2Variables = this->getAbstractionInformation().getPlayer2VariableSet(usedNondeterminismVariables); + allVariables.insert(player2Variables.begin(), player2Variables.end()); + auto auxVariables = this->getAbstractionInformation().getAuxVariableSet(0, this->getAbstractionInformation().getAuxVariableCount()); + allVariables.insert(auxVariables.begin(), auxVariables.end()); + + std::set variablesToAbstract; + std::set_intersection(allVariables.begin(), allVariables.end(), resultBdd.getContainedMetaVariables().begin(), resultBdd.getContainedMetaVariables().end(), std::inserter(variablesToAbstract, variablesToAbstract.begin())); + + abstractGuard = resultBdd.existsAbstract(variablesToAbstract); + } else { + // Multiply the abstract guard as it can contain predicates that are not mentioned in the blocks. + resultBdd &= abstractGuard; + } + + // multiply with missing identities + resultBdd &= computeMissingIdentities(); + + // cache and return result + resultBdd &= this->getAbstractionInformation().encodePlayer1Choice(edgeId, this->getAbstractionInformation().getPlayer1VariableCount()); + + // Cache the result. + cachedDd = GameBddResult(resultBdd, usedNondeterminismVariables); + + auto end = std::chrono::high_resolution_clock::now(); + STORM_LOG_TRACE("Enumerated " << numberOfSolutions << " solutions in " << std::chrono::duration_cast(end - start).count() << "ms."); + forceRecomputation = false; + } + } + + template + void EdgeAbstractor::recomputeCachedBddWithoutDecomposition() { + STORM_LOG_TRACE("Recomputing BDD for edge with id " << edgeId << " and guard " << edge.get().getGuard()); + auto start = std::chrono::high_resolution_clock::now(); + + // Create a mapping from source state DDs to their distributions. + std::unordered_map, std::vector>> sourceToDistributionsMap; + uint64_t numberOfSolutions = 0; + smtSolver->allSat(decisionVariables, [&sourceToDistributionsMap,this,&numberOfSolutions] (storm::solver::SmtSolver::ModelReference const& model) { + sourceToDistributionsMap[getSourceStateBdd(model, relevantPredicatesAndVariables.first)].push_back(getDistributionBdd(model, relevantPredicatesAndVariables.second)); + ++numberOfSolutions; + return true; + }); + + // Now we search for the maximal number of choices of player 2 to determine how many DD variables we + // need to encode the nondeterminism. + uint_fast64_t maximalNumberOfChoices = 0; + for (auto const& sourceDistributionsPair : sourceToDistributionsMap) { + maximalNumberOfChoices = std::max(maximalNumberOfChoices, static_cast(sourceDistributionsPair.second.size())); + } + + // We now compute how many variables we need to encode the choices. We add one to the maximal number of + // choices to account for a possible transition to a bottom state. + uint_fast64_t numberOfVariablesNeeded = static_cast(std::ceil(std::log2(maximalNumberOfChoices + 1))); + + // Finally, build overall result. + storm::dd::Bdd resultBdd = this->getAbstractionInformation().getDdManager().getBddZero(); + if (!skipBottomStates) { + abstractGuard = this->getAbstractionInformation().getDdManager().getBddZero(); + } + uint_fast64_t sourceStateIndex = 0; + for (auto const& sourceDistributionsPair : sourceToDistributionsMap) { + if (!skipBottomStates) { + abstractGuard |= sourceDistributionsPair.first; + } + + STORM_LOG_ASSERT(!sourceDistributionsPair.first.isZero(), "The source BDD must not be empty."); + STORM_LOG_ASSERT(!sourceDistributionsPair.second.empty(), "The distributions must not be empty."); + // We start with the distribution index of 1, becase 0 is reserved for a potential bottom choice. + uint_fast64_t distributionIndex = 1; + storm::dd::Bdd allDistributions = this->getAbstractionInformation().getDdManager().getBddZero(); + for (auto const& distribution : sourceDistributionsPair.second) { + allDistributions |= distribution && this->getAbstractionInformation().encodePlayer2Choice(distributionIndex, 0, numberOfVariablesNeeded); + ++distributionIndex; + STORM_LOG_ASSERT(!allDistributions.isZero(), "The BDD must not be empty."); + } + resultBdd |= sourceDistributionsPair.first && allDistributions; + ++sourceStateIndex; + STORM_LOG_ASSERT(!resultBdd.isZero(), "The BDD must not be empty."); + } + + resultBdd &= computeMissingIdentities(); + resultBdd &= this->getAbstractionInformation().encodePlayer1Choice(edgeId, this->getAbstractionInformation().getPlayer1VariableCount()); + STORM_LOG_ASSERT(sourceToDistributionsMap.empty() || !resultBdd.isZero(), "The BDD must not be empty, if there were distributions."); + + // Cache the result. + cachedDd = GameBddResult(resultBdd, numberOfVariablesNeeded); + auto end = std::chrono::high_resolution_clock::now(); + + STORM_LOG_TRACE("Enumerated " << numberOfSolutions << " solutions in " << std::chrono::duration_cast(end - start).count() << "ms."); + forceRecomputation = false; + } + + template + std::pair, std::set> EdgeAbstractor::computeRelevantPredicates(storm::jani::OrderedAssignments const& assignments) const { + std::pair, std::set> result; + + std::set assignedVariables; + for (auto const& assignment : assignments.getAllAssignments()) { + // Also, variables appearing on the right-hand side of an assignment are relevant for source state. + auto const& rightHandSidePredicates = localExpressionInformation.getExpressionsUsingVariables(assignment.getAssignedExpression().getVariables()); + result.first.insert(rightHandSidePredicates.begin(), rightHandSidePredicates.end()); + + // Variables that are being assigned are relevant for the successor state. + storm::expressions::Variable const& assignedVariable = assignment.getExpressionVariable(); + auto const& leftHandSidePredicates = localExpressionInformation.getExpressionsUsingVariable(assignedVariable); + result.second.insert(leftHandSidePredicates.begin(), leftHandSidePredicates.end()); + + // Keep track of all assigned variables, so we can find the related predicates later. + assignedVariables.insert(assignedVariable); + } + + auto const& predicatesRelatedToAssignedVariable = localExpressionInformation.getRelatedExpressions(assignedVariables); + result.first.insert(predicatesRelatedToAssignedVariable.begin(), predicatesRelatedToAssignedVariable.end()); + + return result; + } + + template + std::pair, std::vector>> EdgeAbstractor::computeRelevantPredicates() const { + std::pair, std::vector>> result; + + // To start with, all predicates related to the guard are relevant source predicates. + result.first = localExpressionInformation.getExpressionsUsingVariables(edge.get().getGuard().getVariables()); + + // Then, we add the predicates that become relevant, because of some update. + for (auto const& destination : edge.get().getDestinations()) { + std::pair, std::set> relevantUpdatePredicates = computeRelevantPredicates(destination.getOrderedAssignments()); + result.first.insert(relevantUpdatePredicates.first.begin(), relevantUpdatePredicates.first.end()); + result.second.push_back(relevantUpdatePredicates.second); + } + + return result; + } + + template + bool EdgeAbstractor::relevantPredicatesChanged(std::pair, std::vector>> const& newRelevantPredicates) const { + if (newRelevantPredicates.first.size() > relevantPredicatesAndVariables.first.size()) { + return true; + } + + for (uint_fast64_t index = 0; index < edge.get().getNumberOfDestinations(); ++index) { + if (newRelevantPredicates.second[index].size() > relevantPredicatesAndVariables.second[index].size()) { + return true; + } + } + + return false; + } + + template + void EdgeAbstractor::addMissingPredicates(std::pair, std::vector>> const& newRelevantPredicates) { + // Determine and add new relevant source predicates. + std::vector> newSourceVariables = this->getAbstractionInformation().declareNewVariables(relevantPredicatesAndVariables.first, newRelevantPredicates.first); + for (auto const& element : newSourceVariables) { + allRelevantPredicates.insert(element.second); + smtSolver->add(storm::expressions::iff(element.first, this->getAbstractionInformation().getPredicateByIndex(element.second))); + decisionVariables.push_back(element.first); + } + + // Insert the new variables into the record of relevant source variables. + relevantPredicatesAndVariables.first.insert(relevantPredicatesAndVariables.first.end(), newSourceVariables.begin(), newSourceVariables.end()); + std::sort(relevantPredicatesAndVariables.first.begin(), relevantPredicatesAndVariables.first.end(), [] (std::pair const& first, std::pair const& second) { return first.second < second.second; } ); + + // Do the same for every update. + for (uint_fast64_t index = 0; index < edge.get().getNumberOfDestinations(); ++index) { + std::vector> newSuccessorVariables = this->getAbstractionInformation().declareNewVariables(relevantPredicatesAndVariables.second[index], newRelevantPredicates.second[index]); + for (auto const& element : newSuccessorVariables) { + allRelevantPredicates.insert(element.second); + smtSolver->add(storm::expressions::iff(element.first, this->getAbstractionInformation().getPredicateByIndex(element.second).substitute(edge.get().getDestination(index).getAsVariableToExpressionMap()))); + decisionVariables.push_back(element.first); + } + + relevantPredicatesAndVariables.second[index].insert(relevantPredicatesAndVariables.second[index].end(), newSuccessorVariables.begin(), newSuccessorVariables.end()); + std::sort(relevantPredicatesAndVariables.second[index].begin(), relevantPredicatesAndVariables.second[index].end(), [] (std::pair const& first, std::pair const& second) { return first.second < second.second; } ); + } + } + + template + storm::dd::Bdd EdgeAbstractor::getSourceStateBdd(storm::solver::SmtSolver::ModelReference const& model, std::vector> const& variablePredicates) const { + storm::dd::Bdd result = this->getAbstractionInformation().getDdManager().getBddOne(); + for (auto const& variableIndexPair : variablePredicates) { + if (model.getBooleanValue(variableIndexPair.first)) { + result &= this->getAbstractionInformation().encodePredicateAsSource(variableIndexPair.second); + } else { + result &= !this->getAbstractionInformation().encodePredicateAsSource(variableIndexPair.second); + } + } + + STORM_LOG_ASSERT(!result.isZero(), "Source must not be empty."); + return result; + } + + template + storm::dd::Bdd EdgeAbstractor::getDistributionBdd(storm::solver::SmtSolver::ModelReference const& model, std::vector>> const& variablePredicates) const { + storm::dd::Bdd result = this->getAbstractionInformation().getDdManager().getBddZero(); + + for (uint_fast64_t destinationIndex = 0; destinationIndex < edge.get().getNumberOfDestinations(); ++destinationIndex) { + storm::dd::Bdd updateBdd = this->getAbstractionInformation().getDdManager().getBddOne(); + + // Translate block variables for this update into a successor block. + for (auto const& variableIndexPair : variablePredicates[destinationIndex]) { + if (model.getBooleanValue(variableIndexPair.first)) { + updateBdd &= this->getAbstractionInformation().encodePredicateAsSuccessor(variableIndexPair.second); + } else { + updateBdd &= !this->getAbstractionInformation().encodePredicateAsSuccessor(variableIndexPair.second); + } + updateBdd &= this->getAbstractionInformation().encodeAux(destinationIndex, 0, this->getAbstractionInformation().getAuxVariableCount()); + } + + result |= updateBdd; + } + + STORM_LOG_ASSERT(!result.isZero(), "Distribution must not be empty."); + return result; + } + + template + storm::dd::Bdd EdgeAbstractor::computeMissingIdentities() const { + storm::dd::Bdd identities = computeMissingGlobalIdentities(); + identities &= computeMissingUpdateIdentities(); + return identities; + } + + template + storm::dd::Bdd EdgeAbstractor::computeMissingUpdateIdentities() const { + storm::dd::Bdd result = this->getAbstractionInformation().getDdManager().getBddZero(); + + for (uint_fast64_t updateIndex = 0; updateIndex < edge.get().getNumberOfDestinations(); ++updateIndex) { + // Compute the identities that are missing for this update. + auto updateRelevantIt = relevantPredicatesAndVariables.second[updateIndex].begin(); + auto updateRelevantIte = relevantPredicatesAndVariables.second[updateIndex].end(); + + storm::dd::Bdd updateIdentity = this->getAbstractionInformation().getDdManager().getBddOne(); + auto sourceRelevantIt = relevantPredicatesAndVariables.first.begin(); + auto sourceRelevantIte = relevantPredicatesAndVariables.first.end(); + + // Go through all relevant source predicates. This is guaranteed to be a superset of the set of + // relevant successor predicates for any update. + for (; sourceRelevantIt != sourceRelevantIte; ++sourceRelevantIt) { + // If the predicates do not match, there is a predicate missing, so we need to add its identity. + if (updateRelevantIt == updateRelevantIte || sourceRelevantIt->second != updateRelevantIt->second) { + updateIdentity &= this->getAbstractionInformation().getPredicateIdentity(sourceRelevantIt->second); + } else { + ++updateRelevantIt; + } + } + + result |= updateIdentity && this->getAbstractionInformation().encodeAux(updateIndex, 0, this->getAbstractionInformation().getAuxVariableCount()); + } + return result; + } + + template + storm::dd::Bdd EdgeAbstractor::computeMissingGlobalIdentities() const { + storm::dd::Bdd result = this->getAbstractionInformation().getDdManager().getBddOne(); + + auto relevantIt = relevantPredicatesAndVariables.first.begin(); + auto relevantIte = relevantPredicatesAndVariables.first.end(); + + for (uint_fast64_t predicateIndex = 0; predicateIndex < this->getAbstractionInformation().getNumberOfPredicates(); ++predicateIndex) { + if (relevantIt == relevantIte || relevantIt->second != predicateIndex) { + result &= this->getAbstractionInformation().getPredicateIdentity(predicateIndex); + } else { + ++relevantIt; + } + } + + return result; + } + + template + GameBddResult EdgeAbstractor::abstract() { + if (forceRecomputation) { + this->recomputeCachedBdd(); + } else { + cachedDd.bdd &= computeMissingGlobalIdentities(); + } + + return cachedDd; + } + + template + BottomStateResult EdgeAbstractor::getBottomStateTransitions(storm::dd::Bdd const& reachableStates, uint_fast64_t numberOfPlayer2Variables, boost::optional> const& locationVariables) { + // Compute the reachable states that have this edge enabled. + storm::dd::Bdd reachableStatesWithEdge = (reachableStates && abstractGuard && this->getAbstractionInformation().encodeLocation(locationVariables.get().first, edge.get().getSourceLocationIndex())).existsAbstract(this->getAbstractionInformation().getSourceLocationVariables()); + + STORM_LOG_TRACE("Computing bottom state transitions of edge with guard " << edge.get().getGuard()); + BottomStateResult result(this->getAbstractionInformation().getDdManager().getBddZero(), this->getAbstractionInformation().getDdManager().getBddZero()); + + // If the guard of this edge is a predicate, there are not bottom states/transitions. + if (skipBottomStates) { + STORM_LOG_TRACE("Skipping bottom state computation for this edge."); + return result; + } + + // Use the state abstractor to compute the set of abstract states that has this edge enabled but still + // has a transition to a bottom state. + bottomStateAbstractor.constrain(reachableStatesWithEdge); + result.states = bottomStateAbstractor.getAbstractStates() && reachableStatesWithEdge && this->getAbstractionInformation().encodeLocation(locationVariables.get().first, edge.get().getSourceLocationIndex()); + + // If the result is empty one time, we can skip the bottom state computation from now on. + if (result.states.isZero()) { + skipBottomStates = true; + } + + // Now equip all these states with an actual transition to a bottom state. + result.transitions = result.states && this->getAbstractionInformation().getAllPredicateIdentities() && this->getAbstractionInformation().getBottomStateBdd(false, false); + + // Mark the states as bottom states and add source location information. + result.states &= this->getAbstractionInformation().getBottomStateBdd(true, false); + + // Add the edge encoding. + result.transitions &= this->getAbstractionInformation().encodePlayer1Choice(edgeId, this->getAbstractionInformation().getPlayer1VariableCount()) && this->getAbstractionInformation().encodePlayer2Choice(0, 0,numberOfPlayer2Variables) && this->getAbstractionInformation().encodeAux(0, 0, this->getAbstractionInformation().getAuxVariableCount()); + + // Add the location identity to the transitions. + result.transitions &= this->getAbstractionInformation().getAllLocationIdentities(); + + return result; + } + + template + storm::dd::Add EdgeAbstractor::getEdgeDecoratorAdd(boost::optional> const& locationVariables) const { + storm::dd::Add result = this->getAbstractionInformation().getDdManager().template getAddZero(); + for (uint_fast64_t destinationIndex = 0; destinationIndex < edge.get().getNumberOfDestinations(); ++destinationIndex) { + storm::dd::Add tmp = this->getAbstractionInformation().encodeAux(destinationIndex, 0, this->getAbstractionInformation().getAuxVariableCount()).template toAdd() * this->getAbstractionInformation().getDdManager().getConstant(evaluator.asRational(edge.get().getDestination(destinationIndex).getProbability())); + if (locationVariables) { + tmp *= this->getAbstractionInformation().encodeLocation(locationVariables.get().second, edge.get().getDestination(destinationIndex).getLocationIndex()).template toAdd(); + } + result += tmp; + } + + storm::dd::Add tmp = this->getAbstractionInformation().getDdManager().template getAddOne(); + if (locationVariables) { + tmp *= this->getAbstractionInformation().encodeLocation(locationVariables.get().first, edge.get().getSourceLocationIndex()).template toAdd(); + } + tmp *= this->getAbstractionInformation().encodePlayer1Choice(edgeId, this->getAbstractionInformation().getPlayer1VariableCount()).template toAdd(); + + result *= tmp; + + return result; + } + + template + storm::jani::Edge const& EdgeAbstractor::getConcreteEdge() const { + return edge.get(); + } + + template + AbstractionInformation const& EdgeAbstractor::getAbstractionInformation() const { + return abstractionInformation.get(); + } + + template + AbstractionInformation& EdgeAbstractor::getAbstractionInformation() { + return abstractionInformation.get(); + } + + template class EdgeAbstractor; + template class EdgeAbstractor; +#ifdef STORM_HAVE_CARL + template class EdgeAbstractor; +#endif + } + } +} diff --git a/src/storm/abstraction/jani/EdgeAbstractor.h b/src/storm/abstraction/jani/EdgeAbstractor.h new file mode 100644 index 000000000..674805666 --- /dev/null +++ b/src/storm/abstraction/jani/EdgeAbstractor.h @@ -0,0 +1,266 @@ +#pragma once + +#include +#include +#include +#include + +#include "storm/abstraction/LocalExpressionInformation.h" +#include "storm/abstraction/StateSetAbstractor.h" +#include "storm/abstraction/GameBddResult.h" + +#include "storm/storage/expressions/ExpressionEvaluator.h" + +#include "storm/storage/dd/DdType.h" +#include "storm/storage/expressions/Expression.h" + +#include "storm/solver/SmtSolver.h" + +namespace storm { + namespace utility { + namespace solver { + class SmtSolverFactory; + } + } + + namespace dd { + template + class Bdd; + + template + class Add; + } + + namespace jani { + // Forward-declare concrete edge and assignment classes. + class Edge; + class Assignment; + class OrderedAssignments; + } + + namespace abstraction { + template + class AbstractionInformation; + + template + class BottomStateResult; + + namespace jani { + template + class EdgeAbstractor { + public: + /*! + * Constructs an abstract edge from the given command and the initial predicates. + * + * @param edgeId The ID to assign to the edge. + * @param edge The concrete edge for which to build the abstraction. + * @param abstractionInformation An object holding information about the abstraction such as predicates and BDDs. + * @param smtSolverFactory A factory that is to be used for creating new SMT solvers. + * @param useDecomposition A flag indicating whether to use an edge decomposition during abstraction. + */ + EdgeAbstractor(uint64_t edgeId, storm::jani::Edge const& edge, AbstractionInformation& abstractionInformation, std::shared_ptr const& smtSolverFactory, bool useDecomposition); + + /*! + * Refines the abstract edge with the given predicates. + * + * @param predicates The new predicates. + */ + void refine(std::vector const& predicates); + + /*! + * Retrieves the guard of this edge. + */ + storm::expressions::Expression const& getGuard() const; + + /*! + * Retrieves a mapping from variables to expressions that define their updates wrt. to the given + * auxiliary choice. + */ + std::map getVariableUpdates(uint64_t auxiliaryChoice) const; + + /*! + * Computes the abstraction of the edge wrt. to the current set of predicates. + * + * @return The abstraction of the edge in the form of a BDD together with the number of DD variables + * used to encode the choices of player 2. + */ + GameBddResult abstract(); + + /*! + * Retrieves the transitions to bottom states of this edge. + * + * @param reachableStates A BDD representing the reachable states. + * @param numberOfPlayer2Variables The number of variables used to encode the choices of player 2. + * @return The bottom state transitions in the form of a BDD. + */ + BottomStateResult getBottomStateTransitions(storm::dd::Bdd const& reachableStates, uint_fast64_t numberOfPlayer2Variables, boost::optional> const& locationVariables); + + /*! + * Retrieves an ADD that maps the encoding of the edge, source/target locations and its updates to their probabilities. + * + * @param locationVariables If provided, the location variables are used to encode the source/destination locations of the edge + * and its destinations. + * @return The decorator ADD. + */ + storm::dd::Add getEdgeDecoratorAdd(boost::optional> const& locationVariables) const; + + /*! + * Retrieves the concrete edge that is abstracted by this abstract edge. + * + * @return The concrete edge. + */ + storm::jani::Edge const& getConcreteEdge() const; + + private: + /*! + * Determines the relevant predicates for source as well as successor states wrt. to the given assignments + * (that, for example, form an update). + * + * @param assignments The assignments that are to be considered. + * @return A pair whose first component represents the relevant source predicates and whose second + * component represents the relevant successor state predicates. + */ + std::pair, std::set> computeRelevantPredicates(storm::jani::OrderedAssignments const& assignments) const; + + /*! + * Determines the relevant predicates for source as well as successor states. + * + * @return A pair whose first component represents the relevant source predicates and whose second + * component represents the relevant successor state predicates. + */ + std::pair, std::vector>> computeRelevantPredicates() const; + + /*! + * Checks whether the relevant predicates changed. + * + * @param newRelevantPredicates The new relevant predicates. + */ + bool relevantPredicatesChanged(std::pair, std::vector>> const& newRelevantPredicates) const; + + /*! + * Takes the new relevant predicates and creates the appropriate variables and assertions for the ones + * that are currently missing. + * + * @param newRelevantPredicates The new relevant predicates. + */ + void addMissingPredicates(std::pair, std::vector>> const& newRelevantPredicates); + + /*! + * Translates the given model to a source state DD. + * + * @param model The model to translate. + * @return The source state encoded as a DD. + */ + storm::dd::Bdd getSourceStateBdd(storm::solver::SmtSolver::ModelReference const& model, std::vector> const& variablePredicates) const; + + /*! + * Translates the given model to a distribution over successor states. + * + * @param model The model to translate. + * @return The source state encoded as a DD. + */ + storm::dd::Bdd getDistributionBdd(storm::solver::SmtSolver::ModelReference const& model, std::vector>> const& variablePredicates) const; + + /*! + * Recomputes the cached BDD. This needs to be triggered if any relevant predicates change. + */ + void recomputeCachedBdd(); + + /*! + * Recomputes the cached BDD without the decomposition\. + */ + void recomputeCachedBddWithoutDecomposition(); + + /*! + * Recomputes the cached BDD using the decomposition. + */ + void recomputeCachedBddWithDecomposition(); + + /*! + * Computes the missing state identities. + * + * @return A BDD that represents the all missing state identities. + */ + storm::dd::Bdd computeMissingIdentities() const; + + /*! + * Computes the missing state identities for the updates. + * + * @return A BDD that represents the state identities for predicates that are irrelevant for the + * successor states. + */ + storm::dd::Bdd computeMissingUpdateIdentities() const; + + /*! + * Retrieves the abstraction information object. + * + * @return The abstraction information object. + */ + AbstractionInformation const& getAbstractionInformation() const; + + /*! + * Retrieves the abstraction information object. + * + * @return The abstraction information object. + */ + AbstractionInformation& getAbstractionInformation(); + + /*! + * Computes the globally missing state identities. + * + * @return A BDD that represents the global state identities for predicates that are irrelevant for the + * source and successor states. + */ + storm::dd::Bdd computeMissingGlobalIdentities() const; + + // An SMT responsible for this abstract command. + std::unique_ptr smtSolver; + + // The abstraction-related information. + std::reference_wrapper> abstractionInformation; + + // The ID of the edge. + uint64_t edgeId; + + // The concrete edge this abstract command refers to. + std::reference_wrapper edge; + + // The local expression-related information. + LocalExpressionInformation localExpressionInformation; + + // The evaluator used to translate the probability expressions. + storm::expressions::ExpressionEvaluator evaluator; + + // The currently relevant source/successor predicates and the corresponding variables. + std::pair>, std::vector>>> relevantPredicatesAndVariables; + + // The set of all relevant predicates. + std::set allRelevantPredicates; + + // The most recent result of a call to computeDd. If nothing has changed regarding the relevant + // predicates, this result may be reused. + GameBddResult cachedDd; + + // All relevant decision variables over which to perform AllSat. + std::vector decisionVariables; + + // A flag indicating whether to use the decomposition when abstracting. + bool useDecomposition; + + // A flag indicating whether the computation of bottom states can be skipped (for example, if the bottom + // states become empty at some point). + bool skipBottomStates; + + // A flag remembering whether we need to force recomputation of the BDD. + bool forceRecomputation; + + // The abstract guard of the edge. This is only used if the guard is not a predicate, because it can + // then be used to constrain the bottom state abstractor. + storm::dd::Bdd abstractGuard; + + // A state-set abstractor used to determine the bottom states if not all guards were added. + StateSetAbstractor bottomStateAbstractor; + }; + } + } +} diff --git a/src/storm/abstraction/jani/JaniMenuGameAbstractor.cpp b/src/storm/abstraction/jani/JaniMenuGameAbstractor.cpp new file mode 100644 index 000000000..1b162d3bb --- /dev/null +++ b/src/storm/abstraction/jani/JaniMenuGameAbstractor.cpp @@ -0,0 +1,217 @@ +#include "storm/abstraction/jani/JaniMenuGameAbstractor.h" + +#include "storm/abstraction/BottomStateResult.h" +#include "storm/abstraction/GameBddResult.h" +#include "storm/abstraction/ExpressionTranslator.h" + +#include "storm/storage/BitVector.h" + +#include "storm/storage/jani/Model.h" + +#include "storm/storage/dd/DdManager.h" +#include "storm/storage/dd/Add.h" + +#include "storm/models/symbolic/StandardRewardModel.h" + +#include "storm/settings/SettingsManager.h" + +#include "storm/utility/dd.h" +#include "storm/utility/macros.h" +#include "storm/utility/solver.h" +#include "storm/exceptions/WrongFormatException.h" +#include "storm/exceptions/InvalidArgumentException.h" +#include "storm/exceptions/NotSupportedException.h" + +#include "storm-config.h" +#include "storm/adapters/CarlAdapter.h" + +namespace storm { + namespace abstraction { + namespace jani { + + using storm::settings::modules::AbstractionSettings; + + template + JaniMenuGameAbstractor::JaniMenuGameAbstractor(storm::jani::Model const& model, std::shared_ptr const& smtSolverFactory) : model(model), smtSolverFactory(smtSolverFactory), abstractionInformation(model.getManager(), model.getAllExpressionVariables(), smtSolverFactory->create(model.getManager())), automata(), initialStateAbstractor(abstractionInformation, {model.getInitialStatesExpression()}, this->smtSolverFactory), validBlockAbstractor(abstractionInformation, smtSolverFactory), currentGame(nullptr), refinementPerformed(true) { + + // Check whether the model is linear as the abstraction requires this. + STORM_LOG_THROW(model.isLinear(), storm::exceptions::WrongFormatException, "Cannot create abstract model from non-linear model."); + + // For now, we assume that there is a single module. If the program has more than one module, it needs + // to be flattened before the procedure. + STORM_LOG_THROW(model.getNumberOfAutomata() == 1, storm::exceptions::WrongFormatException, "Cannot create abstract model from program containing more than one automaton."); + + // Add all variables range expressions to the information object. + for (auto const& range : this->model.get().getAllRangeExpressions()) { + abstractionInformation.addConstraint(range); + initialStateAbstractor.constrain(range); + } + + uint_fast64_t totalNumberOfCommands = 0; + uint_fast64_t maximalUpdateCount = 0; + std::vector allGuards; + for (auto const& automaton : model.getAutomata()) { + for (auto const& edge : automaton.getEdges()) { + maximalUpdateCount = std::max(maximalUpdateCount, static_cast(edge.getNumberOfDestinations())); + } + + totalNumberOfCommands += automaton.getNumberOfEdges(); + } + + // NOTE: currently we assume that 100 player 2 variables suffice, which corresponds to 2^100 possible + // choices. If for some reason this should not be enough, we could grow this vector dynamically, but + // odds are that it's impossible to treat such models in any event. + abstractionInformation.createEncodingVariables(static_cast(std::ceil(std::log2(totalNumberOfCommands))), 100, static_cast(std::ceil(std::log2(maximalUpdateCount)))); + + // For each module of the concrete program, we create an abstract counterpart. + bool useDecomposition = storm::settings::getModule().isUseDecompositionSet(); + for (auto const& automaton : model.getAutomata()) { + automata.emplace_back(automaton, abstractionInformation, this->smtSolverFactory, useDecomposition); + } + + // Retrieve global BDDs/ADDs so we can multiply them in the abstraction process. + initialLocationsBdd = automata.front().getInitialLocationsBdd(); + edgeDecoratorAdd = automata.front().getEdgeDecoratorAdd(); + } + + template + void JaniMenuGameAbstractor::refine(RefinementCommand const& command) { + // Add the predicates to the global list of predicates and gather their indices. + std::vector predicateIndices; + for (auto const& predicate : command.getPredicates()) { + STORM_LOG_THROW(predicate.hasBooleanType(), storm::exceptions::InvalidArgumentException, "Expecting a predicate of type bool."); + predicateIndices.push_back(abstractionInformation.getOrAddPredicate(predicate)); + } + + // Refine all abstract automata. + for (auto& automaton : automata) { + automaton.refine(predicateIndices); + } + + // Refine initial state abstractor. + initialStateAbstractor.refine(predicateIndices); + + // Refine the valid blocks. + validBlockAbstractor.refine(predicateIndices); + + refinementPerformed |= !command.getPredicates().empty(); + } + + template + MenuGame JaniMenuGameAbstractor::abstract() { + if (refinementPerformed) { + currentGame = buildGame(); + refinementPerformed = true; + } + return *currentGame; + } + + template + AbstractionInformation const& JaniMenuGameAbstractor::getAbstractionInformation() const { + return abstractionInformation; + } + + template + storm::expressions::Expression const& JaniMenuGameAbstractor::getGuard(uint64_t player1Choice) const { + return automata.front().getGuard(player1Choice); + } + + template + std::map JaniMenuGameAbstractor::getVariableUpdates(uint64_t player1Choice, uint64_t auxiliaryChoice) const { + return automata.front().getVariableUpdates(player1Choice, auxiliaryChoice); + } + + template + std::pair JaniMenuGameAbstractor::getPlayer1ChoiceRange() const { + return std::make_pair(0, automata.front().getNumberOfEdges()); + } + + template + storm::expressions::Expression JaniMenuGameAbstractor::getInitialExpression() const { + return model.get().getInitialStatesExpression({model.get().getAutomaton(0)}); + } + + template + storm::dd::Bdd JaniMenuGameAbstractor::getStates(storm::expressions::Expression const& expression) { + storm::abstraction::ExpressionTranslator translator(abstractionInformation, smtSolverFactory->create(abstractionInformation.getExpressionManager())); + return translator.translate(expression); + } + + template + std::unique_ptr> JaniMenuGameAbstractor::buildGame() { + // As long as there is only one module, we only build its game representation. + GameBddResult game = automata.front().abstract(); + + // Add the locations to the transitions. + game.bdd &= edgeDecoratorAdd.notZero(); + + // Construct a set of all unnecessary variables, so we can abstract from it. + std::set variablesToAbstract(abstractionInformation.getPlayer1VariableSet(abstractionInformation.getPlayer1VariableCount())); + auto player2Variables = abstractionInformation.getPlayer2VariableSet(game.numberOfPlayer2Variables); + variablesToAbstract.insert(player2Variables.begin(), player2Variables.end()); + auto auxVariables = abstractionInformation.getAuxVariableSet(0, abstractionInformation.getAuxVariableCount()); + variablesToAbstract.insert(auxVariables.begin(), auxVariables.end()); + + // Do a reachability analysis on the raw transition relation. + storm::dd::Bdd transitionRelation = game.bdd.existsAbstract(variablesToAbstract); + storm::dd::Bdd initialStates = initialLocationsBdd && initialStateAbstractor.getAbstractStates(); + initialStates.addMetaVariables(abstractionInformation.getSourcePredicateVariables()); + storm::dd::Bdd reachableStates = storm::utility::dd::computeReachableStates(initialStates, transitionRelation, abstractionInformation.getSourceVariables(), abstractionInformation.getSuccessorVariables()); + + // Find the deadlock states in the model. Note that this does not find the 'deadlocks' in bottom states, + // as the bottom states are not contained in the reachable states. + storm::dd::Bdd deadlockStates = transitionRelation.existsAbstract(abstractionInformation.getSuccessorVariables()); + deadlockStates = reachableStates && !deadlockStates; + + // If there are deadlock states, we fix them now. + storm::dd::Add deadlockTransitions = abstractionInformation.getDdManager().template getAddZero(); + if (!deadlockStates.isZero()) { + deadlockTransitions = (deadlockStates && abstractionInformation.getAllPredicateIdentities() && abstractionInformation.getAllLocationIdentities() && abstractionInformation.encodePlayer1Choice(0, abstractionInformation.getPlayer1VariableCount()) && abstractionInformation.encodePlayer2Choice(0, 0, game.numberOfPlayer2Variables) && abstractionInformation.encodeAux(0, 0, abstractionInformation.getAuxVariableCount())).template toAdd(); + } + + // Compute bottom states and the appropriate transitions if necessary. + BottomStateResult bottomStateResult(abstractionInformation.getDdManager().getBddZero(), abstractionInformation.getDdManager().getBddZero()); + bottomStateResult = automata.front().getBottomStateTransitions(reachableStates, game.numberOfPlayer2Variables); + bool hasBottomStates = !bottomStateResult.states.isZero(); + + // Construct the transition matrix by cutting away the transitions of unreachable states. + storm::dd::Add transitionMatrix = (game.bdd && reachableStates).template toAdd(); + transitionMatrix *= edgeDecoratorAdd; + transitionMatrix += deadlockTransitions; + + // Extend the current game information with the 'non-bottom' tag before potentially adding bottom state transitions. + transitionMatrix *= (abstractionInformation.getBottomStateBdd(true, true) && abstractionInformation.getBottomStateBdd(false, true)).template toAdd(); + reachableStates &= abstractionInformation.getBottomStateBdd(true, true); + initialStates &= abstractionInformation.getBottomStateBdd(true, true); + + // If there are bottom transitions, exnted the transition matrix and reachable states now. + if (hasBottomStates) { + transitionMatrix += bottomStateResult.transitions.template toAdd(); + reachableStates |= bottomStateResult.states; + } + + std::set allNondeterminismVariables = player2Variables; + allNondeterminismVariables.insert(abstractionInformation.getPlayer1Variables().begin(), abstractionInformation.getPlayer1Variables().end()); + + std::set allSourceVariables(abstractionInformation.getSourceVariables()); + allSourceVariables.insert(abstractionInformation.getBottomStateVariable(true)); + std::set allSuccessorVariables(abstractionInformation.getSuccessorVariables()); + allSuccessorVariables.insert(abstractionInformation.getBottomStateVariable(false)); + + return std::make_unique>(abstractionInformation.getDdManagerAsSharedPointer(), reachableStates, initialStates, abstractionInformation.getDdManager().getBddZero(), transitionMatrix, bottomStateResult.states, allSourceVariables, allSuccessorVariables, abstractionInformation.getExtendedSourceSuccessorVariablePairs(), std::set(abstractionInformation.getPlayer1Variables().begin(), abstractionInformation.getPlayer1Variables().end()), player2Variables, allNondeterminismVariables, auxVariables, abstractionInformation.getPredicateToBddMap()); + } + + template + void JaniMenuGameAbstractor::exportToDot(std::string const& filename, storm::dd::Bdd const& highlightStates, storm::dd::Bdd const& filter) const { + this->exportToDot(*currentGame, filename, highlightStates, filter); + } + + // Explicitly instantiate the class. + template class JaniMenuGameAbstractor; + template class JaniMenuGameAbstractor; +#ifdef STORM_HAVE_CARL + template class JaniMenuGameAbstractor; +#endif + } + } +} diff --git a/src/storm/abstraction/jani/JaniMenuGameAbstractor.h b/src/storm/abstraction/jani/JaniMenuGameAbstractor.h new file mode 100644 index 000000000..3a478fcb0 --- /dev/null +++ b/src/storm/abstraction/jani/JaniMenuGameAbstractor.h @@ -0,0 +1,163 @@ +#pragma once + +#include "storm/storage/dd/DdType.h" + +#include "storm/abstraction/MenuGameAbstractor.h" +#include "storm/abstraction/MenuGame.h" +#include "storm/abstraction/RefinementCommand.h" +#include "storm/abstraction/ValidBlockAbstractor.h" +#include "storm/abstraction/AbstractionInformation.h" +#include "storm/abstraction/jani/AutomatonAbstractor.h" + +#include "storm/storage/dd/Add.h" + +#include "storm/storage/expressions/Expression.h" + +#include "storm/settings/modules/AbstractionSettings.h" + +namespace storm { + namespace utility { + namespace solver { + class SmtSolverFactory; + } + } + + namespace models { + namespace symbolic { + template + class StochasticTwoPlayerGame; + } + } + + namespace jani { + // Forward-declare concrete Model class. + class Model; + } + + namespace abstraction { + namespace jani { + + template + class JaniMenuGameAbstractor : public MenuGameAbstractor { + public: + /*! + * Constructs an abstractor for the given model. + * + * @param model The concrete model for which to build the abstraction. + * @param smtSolverFactory A factory that is to be used for creating new SMT solvers. + */ + JaniMenuGameAbstractor(storm::jani::Model const& model, std::shared_ptr const& smtSolverFactory); + + JaniMenuGameAbstractor(JaniMenuGameAbstractor const&) = default; + JaniMenuGameAbstractor& operator=(JaniMenuGameAbstractor const&) = default; + JaniMenuGameAbstractor(JaniMenuGameAbstractor&&) = default; + JaniMenuGameAbstractor& operator=(JaniMenuGameAbstractor&&) = default; + + /*! + * Uses the current set of predicates to derive the abstract menu game in the form of an ADD. + * + * @return The abstract stochastic two player game. + */ + MenuGame abstract() override; + + /*! + * Retrieves information about the abstraction. + * + * @return The abstraction information object. + */ + AbstractionInformation const& getAbstractionInformation() const override; + + /*! + * Retrieves the guard predicate of the given player 1 choice. + * + * @param player1Choice The choice for which to retrieve the guard. + * @return The guard of the player 1 choice. + */ + storm::expressions::Expression const& getGuard(uint64_t player1Choice) const override; + + /*! + * Retrieves a mapping from variables to expressions that define their updates wrt. to the given player + * 1 choice and auxiliary choice. + */ + std::map getVariableUpdates(uint64_t player1Choice, uint64_t auxiliaryChoice) const override; + + /*! + * Retrieves the range of player 1 choices. + */ + std::pair getPlayer1ChoiceRange() const override; + + /*! + * Retrieves the expression that characterizes the initial states. + */ + storm::expressions::Expression getInitialExpression() const override; + + storm::dd::Bdd getStates(storm::expressions::Expression const& expression) override; + + /*! + * Performs the given refinement command. + * + * @param command The command to perform. + */ + virtual void refine(RefinementCommand const& command) override; + + /*! + * Exports the current state of the abstraction in the dot format to the given file. + * + * @param filename The name of the file to which to write the dot output. + * @param highlightStates A BDD characterizing states that will be highlighted. + * @param filter A filter that is applied to select which part of the game to export. + */ + void exportToDot(std::string const& filename, storm::dd::Bdd const& highlightStates, storm::dd::Bdd const& filter) const override; + + protected: + using MenuGameAbstractor::exportToDot; + + private: + /*! + * Builds the stochastic game representing the abstraction of the program. + * + * @return The stochastic game. + */ + std::unique_ptr> buildGame(); + + /*! + * Decodes the given choice over the auxiliary and successor variables to a mapping from update indices + * to bit vectors representing the successors under these updates. + * + * @param choice The choice to decode. + */ + std::map decodeChoiceToUpdateSuccessorMapping(storm::dd::Bdd const& choice) const; + + // The concrete model this abstractor refers to. + std::reference_wrapper model; + + // A factory that can be used to create new SMT solvers. + std::shared_ptr smtSolverFactory; + + // An object containing all information about the abstraction like predicates and the corresponding DDs. + AbstractionInformation abstractionInformation; + + // The abstract modules of the abstract program. + std::vector> automata; + + // A state-set abstractor used to determine the initial states of the abstraction. + StateSetAbstractor initialStateAbstractor; + + // An object that is used to compute the valid blocks. + ValidBlockAbstractor validBlockAbstractor; + + // A BDD characterizing the initial locations of the abstracted automata. + storm::dd::Bdd initialLocationsBdd; + + // An ADD characterizing the probabilities and source/target locations of edges and their updates. + storm::dd::Add edgeDecoratorAdd; + + // The current game-based abstraction. + std::unique_ptr> currentGame; + + // A flag storing whether a refinement was performed. + bool refinementPerformed; + }; + } + } +} diff --git a/src/storm/abstraction/prism/CommandAbstractor.cpp b/src/storm/abstraction/prism/CommandAbstractor.cpp new file mode 100644 index 000000000..cf116afcd --- /dev/null +++ b/src/storm/abstraction/prism/CommandAbstractor.cpp @@ -0,0 +1,689 @@ +#include "storm/abstraction/prism/CommandAbstractor.h" + +#include + +#include + +#include "storm/abstraction/AbstractionInformation.h" +#include "storm/abstraction/BottomStateResult.h" + +#include "storm/storage/dd/DdManager.h" +#include "storm/storage/dd/Add.h" + +#include "storm/storage/prism/Command.h" +#include "storm/storage/prism/Update.h" + +#include "storm/utility/solver.h" +#include "storm/utility/macros.h" + +#include "storm-config.h" +#include "storm/adapters/CarlAdapter.h" + +namespace storm { + namespace abstraction { + namespace prism { + template + CommandAbstractor::CommandAbstractor(storm::prism::Command const& command, AbstractionInformation& abstractionInformation, std::shared_ptr const& smtSolverFactory, bool useDecomposition) : smtSolver(smtSolverFactory->create(abstractionInformation.getExpressionManager())), abstractionInformation(abstractionInformation), command(command), localExpressionInformation(abstractionInformation), evaluator(abstractionInformation.getExpressionManager()), relevantPredicatesAndVariables(), cachedDd(abstractionInformation.getDdManager().getBddZero(), 0), decisionVariables(), useDecomposition(useDecomposition), skipBottomStates(false), forceRecomputation(true), abstractGuard(abstractionInformation.getDdManager().getBddZero()), bottomStateAbstractor(abstractionInformation, {!command.getGuardExpression()}, smtSolverFactory) { + + // Make the second component of relevant predicates have the right size. + relevantPredicatesAndVariables.second.resize(command.getNumberOfUpdates()); + + // Assert all constraints to enforce legal variable values. + for (auto const& constraint : abstractionInformation.getConstraints()) { + smtSolver->add(constraint); + bottomStateAbstractor.constrain(constraint); + } + + // Assert the guard of the command. + smtSolver->add(command.getGuardExpression()); + } + + template + void CommandAbstractor::refine(std::vector const& predicates) { + // Add all predicates to the variable partition. + for (auto predicateIndex : predicates) { + localExpressionInformation.addExpression(predicateIndex); + } + + // Next, we check whether there is work to be done by recomputing the relevant predicates and checking + // whether they changed. + std::pair, std::vector>> newRelevantPredicates = this->computeRelevantPredicates(); + + // Check whether we need to recompute the abstraction. + bool relevantPredicatesChanged = this->relevantPredicatesChanged(newRelevantPredicates); + if (relevantPredicatesChanged) { + addMissingPredicates(newRelevantPredicates); + } + forceRecomputation |= relevantPredicatesChanged; + + // Refine bottom state abstractor. Note that this does not trigger a recomputation yet. + bottomStateAbstractor.refine(predicates); + } + + template + storm::expressions::Expression const& CommandAbstractor::getGuard() const { + return command.get().getGuardExpression(); + } + + template + std::map CommandAbstractor::getVariableUpdates(uint64_t auxiliaryChoice) const { + return command.get().getUpdate(auxiliaryChoice).getAsVariableToExpressionMap(); + } + + template + void CommandAbstractor::recomputeCachedBdd() { + if (useDecomposition) { + recomputeCachedBddWithDecomposition(); + } else { + recomputeCachedBddWithoutDecomposition(); + } + } + + template + void CommandAbstractor::recomputeCachedBddWithDecomposition() { + STORM_LOG_TRACE("Recomputing BDD for command " << command.get() << " using the decomposition."); + auto start = std::chrono::high_resolution_clock::now(); + + // compute a decomposition of the command + // * start with all relevant blocks: blocks of assignment variables and variables in the rhs of assignments + // * go through all assignments of all updates and merge relevant blocks that are related via an assignment + // * repeat this until nothing changes anymore + // * the resulting blocks are the decomposition + + // Start by constructing the relevant blocks. + std::set allRelevantBlocks; + std::map variableToBlockIndex; + for (auto const& update : command.get().getUpdates()) { + for (auto const& assignment : update.getAssignments()) { + allRelevantBlocks.insert(localExpressionInformation.getBlockIndexOfVariable(assignment.getVariable())); + + auto rhsVariableBlocks = localExpressionInformation.getBlockIndicesOfVariables(assignment.getExpression().getVariables()); + allRelevantBlocks.insert(rhsVariableBlocks.begin(), rhsVariableBlocks.end()); + } + } + STORM_LOG_TRACE("Found " << allRelevantBlocks.size() << " relevant block(s)."); + + // Create a block partition. + std::vector> relevantBlockPartition; + std::map variableToLocalBlockIndex; + uint64_t index = 0; + for (auto const& blockIndex : allRelevantBlocks) { + relevantBlockPartition.emplace_back(std::set({blockIndex})); + for (auto const& variable : localExpressionInformation.getVariableBlockWithIndex(blockIndex)) { + variableToLocalBlockIndex[variable] = index; + } + ++index; + } + + // Merge all blocks that are related via the right-hand side of assignments. + for (auto const& update : command.get().getUpdates()) { + for (auto const& assignment : update.getAssignments()) { + std::set rhsVariables = assignment.getExpression().getVariables(); + + if (!rhsVariables.empty()) { + uint64_t blockToKeep = variableToLocalBlockIndex.at(*rhsVariables.begin()); + for (auto const& variable : rhsVariables) { + uint64_t block = variableToLocalBlockIndex.at(variable); + if (block != blockToKeep) { + for (auto const& blockIndex : relevantBlockPartition[block]) { + for (auto const& variable : localExpressionInformation.getVariableBlockWithIndex(blockIndex)) { + variableToLocalBlockIndex[variable] = blockToKeep; + } + } + relevantBlockPartition[blockToKeep].insert(relevantBlockPartition[block].begin(), relevantBlockPartition[block].end()); + relevantBlockPartition[block].clear(); + } + } + } + } + } + + // Proceed by relating the blocks via assignment-variables and the expressions of their assigned expressions. + bool changed = false; + do { + changed = false; + for (auto const& update : command.get().getUpdates()) { + for (auto const& assignment : update.getAssignments()) { + std::set rhsVariables = assignment.getExpression().getVariables(); + + if (!rhsVariables.empty()) { + storm::expressions::Variable const& representativeVariable = *rhsVariables.begin(); + uint64_t representativeBlock = variableToLocalBlockIndex.at(representativeVariable); + uint64_t assignmentVariableBlock = variableToLocalBlockIndex.at(assignment.getVariable()); + + // If the blocks are different, we merge them now + if (assignmentVariableBlock != representativeBlock) { + changed = true; + + for (auto const& blockIndex : relevantBlockPartition[assignmentVariableBlock]) { + for (auto const& variable : localExpressionInformation.getVariableBlockWithIndex(blockIndex)) { + variableToLocalBlockIndex[variable] = representativeBlock; + } + } + relevantBlockPartition[representativeBlock].insert(relevantBlockPartition[assignmentVariableBlock].begin(), relevantBlockPartition[assignmentVariableBlock].end()); + relevantBlockPartition[assignmentVariableBlock].clear(); + + } + } + } + } + } while (changed); + + // Now remove all blocks that are empty and obtain the partition. + std::vector> cleanedRelevantBlockPartition; + for (auto& element : relevantBlockPartition) { + if (!element.empty()) { + cleanedRelevantBlockPartition.emplace_back(std::move(element)); + } + } + relevantBlockPartition = std::move(cleanedRelevantBlockPartition); + + // if the decomposition has size 1, use the plain technique from before + if (relevantBlockPartition.size() == 1) { + STORM_LOG_TRACE("Relevant block partition size is one, falling back to regular computation."); + recomputeCachedBddWithoutDecomposition(); + } else { + std::set variablesContainedInGuard = command.get().getGuardExpression().getVariables(); + + // Check whether we need to enumerate the guard. This is the case if the blocks related by the guard + // are not contained within a single block of our decomposition. + bool enumerateAbstractGuard = true; + std::set guardBlocks = localExpressionInformation.getBlockIndicesOfVariables(variablesContainedInGuard); + for (auto const& block : relevantBlockPartition) { + bool allContained = true; + for (auto const& guardBlock : guardBlocks) { + if (block.find(guardBlock) == block.end()) { + allContained = false; + break; + } + } + if (allContained) { + enumerateAbstractGuard = false; + } + } + + uint64_t numberOfSolutions = 0; + + if (enumerateAbstractGuard) { + // otherwise, enumerate the abstract guard so we do this only once + std::set relatedGuardPredicates = localExpressionInformation.getRelatedExpressions(variablesContainedInGuard); + std::vector guardDecisionVariables; + std::vector> guardVariablesAndPredicates; + for (auto const& element : relevantPredicatesAndVariables.first) { + if (relatedGuardPredicates.find(element.second) != relatedGuardPredicates.end()) { + guardDecisionVariables.push_back(element.first); + guardVariablesAndPredicates.push_back(element); + } + } + abstractGuard = this->getAbstractionInformation().getDdManager().getBddZero(); + smtSolver->allSat(guardDecisionVariables, [this,&guardVariablesAndPredicates,&numberOfSolutions] (storm::solver::SmtSolver::ModelReference const& model) { + abstractGuard |= getSourceStateBdd(model, guardVariablesAndPredicates); + ++numberOfSolutions; + return true; + }); + STORM_LOG_TRACE("Enumerated " << numberOfSolutions << " for abstract guard."); + + // now that we have the abstract guard, we can add it as an assertion to the solver before enumerating + // the other solutions. + + // Create a new backtracking point before adding the guard. + smtSolver->push(); + + // Create the guard constraint. + std::pair, std::unordered_map> result = abstractGuard.toExpression(this->getAbstractionInformation().getExpressionManager()); + + // Then add it to the solver. + for (auto const& expression : result.first) { + smtSolver->add(expression); + } + + // Finally associate the level variables with the predicates. + for (auto const& indexVariablePair : result.second) { + smtSolver->add(storm::expressions::iff(indexVariablePair.second, this->getAbstractionInformation().getPredicateForDdVariableIndex(indexVariablePair.first))); + } + } + + // then enumerate the solutions for each of the blocks of the decomposition + uint64_t usedNondeterminismVariables = 0; + uint64_t blockCounter = 0; + std::vector> blockBdds; + for (auto const& block : relevantBlockPartition) { + std::set relevantPredicates; + for (auto const& innerBlock : block) { + relevantPredicates.insert(localExpressionInformation.getExpressionBlock(innerBlock).begin(), localExpressionInformation.getExpressionBlock(innerBlock).end()); + } + + std::vector transitionDecisionVariables; + std::vector> sourceVariablesAndPredicates; + for (auto const& element : relevantPredicatesAndVariables.first) { + if (relevantPredicates.find(element.second) != relevantPredicates.end()) { + transitionDecisionVariables.push_back(element.first); + sourceVariablesAndPredicates.push_back(element); + } + } + + std::vector>> destinationVariablesAndPredicates; + for (uint64_t updateIndex = 0; updateIndex < command.get().getNumberOfUpdates(); ++updateIndex) { + destinationVariablesAndPredicates.emplace_back(); + for (auto const& assignment : command.get().getUpdate(updateIndex).getAssignments()) { + uint64_t assignmentVariableBlockIndex = localExpressionInformation.getBlockIndexOfVariable(assignment.getVariable()); + std::set const& assignmentVariableBlock = localExpressionInformation.getExpressionBlock(assignmentVariableBlockIndex); + if (block.find(assignmentVariableBlockIndex) != block.end()) { + for (auto const& element : relevantPredicatesAndVariables.second[updateIndex]) { + if (assignmentVariableBlock.find(element.second) != assignmentVariableBlock.end()) { + destinationVariablesAndPredicates.back().push_back(element); + transitionDecisionVariables.push_back(element.first); + } + } + } + } + } + + std::unordered_map, std::vector>> sourceToDistributionsMap; + numberOfSolutions = 0; + smtSolver->allSat(transitionDecisionVariables, [&sourceToDistributionsMap,this,&numberOfSolutions,&sourceVariablesAndPredicates,&destinationVariablesAndPredicates] (storm::solver::SmtSolver::ModelReference const& model) { + sourceToDistributionsMap[getSourceStateBdd(model, sourceVariablesAndPredicates)].push_back(getDistributionBdd(model, destinationVariablesAndPredicates)); + ++numberOfSolutions; + return true; + }); + STORM_LOG_TRACE("Enumerated " << numberOfSolutions << " solutions for block " << blockCounter << "."); + numberOfSolutions = 0; + + // Now we search for the maximal number of choices of player 2 to determine how many DD variables we + // need to encode the nondeterminism. + uint_fast64_t maximalNumberOfChoices = 0; + for (auto const& sourceDistributionsPair : sourceToDistributionsMap) { + maximalNumberOfChoices = std::max(maximalNumberOfChoices, static_cast(sourceDistributionsPair.second.size())); + } + + // We now compute how many variables we need to encode the choices. We add one to the maximal number of + // choices to account for a possible transition to a bottom state. + uint_fast64_t numberOfVariablesNeeded = static_cast(std::ceil(std::log2(maximalNumberOfChoices + 1))); + + // Finally, build overall result. + storm::dd::Bdd resultBdd = this->getAbstractionInformation().getDdManager().getBddZero(); + + uint_fast64_t sourceStateIndex = 0; + for (auto const& sourceDistributionsPair : sourceToDistributionsMap) { + STORM_LOG_ASSERT(!sourceDistributionsPair.first.isZero(), "The source BDD must not be empty."); + STORM_LOG_ASSERT(!sourceDistributionsPair.second.empty(), "The distributions must not be empty."); + // We start with the distribution index of 1, becase 0 is reserved for a potential bottom choice. + uint_fast64_t distributionIndex = 1; + storm::dd::Bdd allDistributions = this->getAbstractionInformation().getDdManager().getBddZero(); + for (auto const& distribution : sourceDistributionsPair.second) { + allDistributions |= distribution && this->getAbstractionInformation().encodePlayer2Choice(distributionIndex, usedNondeterminismVariables, usedNondeterminismVariables + numberOfVariablesNeeded); + ++distributionIndex; + STORM_LOG_ASSERT(!allDistributions.isZero(), "The BDD must not be empty."); + } + resultBdd |= sourceDistributionsPair.first && allDistributions; + ++sourceStateIndex; + STORM_LOG_ASSERT(!resultBdd.isZero(), "The BDD must not be empty."); + } + usedNondeterminismVariables += numberOfVariablesNeeded; + + blockBdds.push_back(resultBdd); + ++blockCounter; + } + + if (enumerateAbstractGuard) { + smtSolver->pop(); + } + + // multiply the results + storm::dd::Bdd resultBdd = getAbstractionInformation().getDdManager().getBddOne(); + for (auto const& blockBdd : blockBdds) { + resultBdd &= blockBdd; + } + + // if we did not explicitly enumerate the guard, we can construct it from the result BDD. + if (!enumerateAbstractGuard) { + std::set allVariables(getAbstractionInformation().getSuccessorVariables()); + auto player2Variables = getAbstractionInformation().getPlayer2VariableSet(usedNondeterminismVariables); + allVariables.insert(player2Variables.begin(), player2Variables.end()); + auto auxVariables = getAbstractionInformation().getAuxVariableSet(0, getAbstractionInformation().getAuxVariableCount()); + allVariables.insert(auxVariables.begin(), auxVariables.end()); + + std::set variablesToAbstract; + std::set_intersection(allVariables.begin(), allVariables.end(), resultBdd.getContainedMetaVariables().begin(), resultBdd.getContainedMetaVariables().end(), std::inserter(variablesToAbstract, variablesToAbstract.begin())); + + abstractGuard = resultBdd.existsAbstract(variablesToAbstract); + } else { + // Multiply the abstract guard as it can contain predicates that are not mentioned in the blocks. + resultBdd &= abstractGuard; + } + + // multiply with missing identities + resultBdd &= computeMissingIdentities(); + + // cache and return result + resultBdd &= this->getAbstractionInformation().encodePlayer1Choice(command.get().getGlobalIndex(), this->getAbstractionInformation().getPlayer1VariableCount()); + + // Cache the result. + cachedDd = GameBddResult(resultBdd, usedNondeterminismVariables); + + auto end = std::chrono::high_resolution_clock::now(); + STORM_LOG_TRACE("Enumerated " << numberOfSolutions << " solutions in " << std::chrono::duration_cast(end - start).count() << "ms."); + forceRecomputation = false; + } + } + + template + void CommandAbstractor::recomputeCachedBddWithoutDecomposition() { + STORM_LOG_TRACE("Recomputing BDD for command " << command.get()); + auto start = std::chrono::high_resolution_clock::now(); + + // Create a mapping from source state DDs to their distributions. + std::unordered_map, std::vector>> sourceToDistributionsMap; + uint64_t numberOfSolutions = 0; + smtSolver->allSat(decisionVariables, [&sourceToDistributionsMap,this,&numberOfSolutions] (storm::solver::SmtSolver::ModelReference const& model) { + sourceToDistributionsMap[getSourceStateBdd(model, relevantPredicatesAndVariables.first)].push_back(getDistributionBdd(model, relevantPredicatesAndVariables.second)); + ++numberOfSolutions; + return true; + }); + + // Now we search for the maximal number of choices of player 2 to determine how many DD variables we + // need to encode the nondeterminism. + uint_fast64_t maximalNumberOfChoices = 0; + for (auto const& sourceDistributionsPair : sourceToDistributionsMap) { + maximalNumberOfChoices = std::max(maximalNumberOfChoices, static_cast(sourceDistributionsPair.second.size())); + } + + // We now compute how many variables we need to encode the choices. We add one to the maximal number of + // choices to account for a possible transition to a bottom state. + uint_fast64_t numberOfVariablesNeeded = static_cast(std::ceil(std::log2(maximalNumberOfChoices + 1))); + + // Finally, build overall result. + storm::dd::Bdd resultBdd = this->getAbstractionInformation().getDdManager().getBddZero(); + if (!skipBottomStates) { + abstractGuard = this->getAbstractionInformation().getDdManager().getBddZero(); + } + for (auto const& sourceDistributionsPair : sourceToDistributionsMap) { + if (!skipBottomStates) { + abstractGuard |= sourceDistributionsPair.first; + } + + STORM_LOG_ASSERT(!sourceDistributionsPair.first.isZero(), "The source BDD must not be empty."); + STORM_LOG_ASSERT(!sourceDistributionsPair.second.empty(), "The distributions must not be empty."); + // We start with the distribution index of 1, becase 0 is reserved for a potential bottom choice. + uint_fast64_t distributionIndex = 1; + storm::dd::Bdd allDistributions = this->getAbstractionInformation().getDdManager().getBddZero(); + for (auto const& distribution : sourceDistributionsPair.second) { + allDistributions |= distribution && this->getAbstractionInformation().encodePlayer2Choice(distributionIndex, 0, numberOfVariablesNeeded); + ++distributionIndex; + STORM_LOG_ASSERT(!allDistributions.isZero(), "The BDD must not be empty."); + } + resultBdd |= sourceDistributionsPair.first && allDistributions; + STORM_LOG_ASSERT(!resultBdd.isZero(), "The BDD must not be empty."); + } + + resultBdd &= computeMissingIdentities(); + resultBdd &= this->getAbstractionInformation().encodePlayer1Choice(command.get().getGlobalIndex(), this->getAbstractionInformation().getPlayer1VariableCount()); + STORM_LOG_ASSERT(sourceToDistributionsMap.empty() || !resultBdd.isZero(), "The BDD must not be empty, if there were distributions."); + + // Cache the result. + cachedDd = GameBddResult(resultBdd, numberOfVariablesNeeded); + auto end = std::chrono::high_resolution_clock::now(); + + STORM_LOG_TRACE("Enumerated " << numberOfSolutions << " solutions in " << std::chrono::duration_cast(end - start).count() << "ms."); + forceRecomputation = false; + } + + template + std::pair, std::set> CommandAbstractor::computeRelevantPredicates(std::vector const& assignments) const { + std::pair, std::set> result; + + std::set assignedVariables; + for (auto const& assignment : assignments) { + // Also, variables appearing on the right-hand side of an assignment are relevant for source state. + auto const& rightHandSidePredicates = localExpressionInformation.getRelatedExpressions(assignment.getExpression().getVariables()); + result.first.insert(rightHandSidePredicates.begin(), rightHandSidePredicates.end()); + + // Variables that are being assigned are relevant for the successor state. + storm::expressions::Variable const& assignedVariable = assignment.getVariable(); + auto const& leftHandSidePredicates = localExpressionInformation.getRelatedExpressions(assignedVariable); + result.second.insert(leftHandSidePredicates.begin(), leftHandSidePredicates.end()); + + // Keep track of all assigned variables, so we can find the related predicates later. + assignedVariables.insert(assignedVariable); + } + + auto const& predicatesRelatedToAssignedVariable = localExpressionInformation.getRelatedExpressions(assignedVariables); + result.first.insert(predicatesRelatedToAssignedVariable.begin(), predicatesRelatedToAssignedVariable.end()); + + return result; + } + + template + std::pair, std::vector>> CommandAbstractor::computeRelevantPredicates() const { + std::pair, std::vector>> result; + + // To start with, all predicates related to the guard are relevant source predicates. + result.first = localExpressionInformation.getRelatedExpressions(command.get().getGuardExpression().getVariables()); + + // Then, we add the predicates that become relevant, because of some update. + for (auto const& update : command.get().getUpdates()) { + std::pair, std::set> relevantUpdatePredicates = computeRelevantPredicates(update.getAssignments()); + result.first.insert(relevantUpdatePredicates.first.begin(), relevantUpdatePredicates.first.end()); + result.second.push_back(relevantUpdatePredicates.second); + } + + return result; + } + + template + bool CommandAbstractor::relevantPredicatesChanged(std::pair, std::vector>> const& newRelevantPredicates) const { + if (newRelevantPredicates.first.size() > relevantPredicatesAndVariables.first.size()) { + return true; + } + + for (uint_fast64_t index = 0; index < command.get().getNumberOfUpdates(); ++index) { + if (newRelevantPredicates.second[index].size() > relevantPredicatesAndVariables.second[index].size()) { + return true; + } + } + + return false; + } + + template + void CommandAbstractor::addMissingPredicates(std::pair, std::vector>> const& newRelevantPredicates) { + // Determine and add new relevant source predicates. + std::vector> newSourceVariables = this->getAbstractionInformation().declareNewVariables(relevantPredicatesAndVariables.first, newRelevantPredicates.first); + for (auto const& element : newSourceVariables) { + allRelevantPredicates.insert(element.second); + smtSolver->add(storm::expressions::iff(element.first, this->getAbstractionInformation().getPredicateByIndex(element.second))); + decisionVariables.push_back(element.first); + } + + // Insert the new variables into the record of relevant source variables. + relevantPredicatesAndVariables.first.insert(relevantPredicatesAndVariables.first.end(), newSourceVariables.begin(), newSourceVariables.end()); + std::sort(relevantPredicatesAndVariables.first.begin(), relevantPredicatesAndVariables.first.end(), [] (std::pair const& first, std::pair const& second) { return first.second < second.second; } ); + + // Do the same for every update. + for (uint_fast64_t index = 0; index < command.get().getNumberOfUpdates(); ++index) { + std::vector> newSuccessorVariables = this->getAbstractionInformation().declareNewVariables(relevantPredicatesAndVariables.second[index], newRelevantPredicates.second[index]); + for (auto const& element : newSuccessorVariables) { + allRelevantPredicates.insert(element.second); + smtSolver->add(storm::expressions::iff(element.first, this->getAbstractionInformation().getPredicateByIndex(element.second).substitute(command.get().getUpdate(index).getAsVariableToExpressionMap()))); + decisionVariables.push_back(element.first); + } + + relevantPredicatesAndVariables.second[index].insert(relevantPredicatesAndVariables.second[index].end(), newSuccessorVariables.begin(), newSuccessorVariables.end()); + std::sort(relevantPredicatesAndVariables.second[index].begin(), relevantPredicatesAndVariables.second[index].end(), [] (std::pair const& first, std::pair const& second) { return first.second < second.second; } ); + } + } + + template + storm::dd::Bdd CommandAbstractor::getSourceStateBdd(storm::solver::SmtSolver::ModelReference const& model, std::vector> const& variablePredicates) const { + storm::dd::Bdd result = this->getAbstractionInformation().getDdManager().getBddOne(); + for (auto const& variableIndexPair : variablePredicates) { + if (model.getBooleanValue(variableIndexPair.first)) { + result &= this->getAbstractionInformation().encodePredicateAsSource(variableIndexPair.second); + } else { + result &= !this->getAbstractionInformation().encodePredicateAsSource(variableIndexPair.second); + } + } + + STORM_LOG_ASSERT(!result.isZero(), "Source must not be empty."); + return result; + } + + template + storm::dd::Bdd CommandAbstractor::getDistributionBdd(storm::solver::SmtSolver::ModelReference const& model, std::vector>> const& variablePredicates) const { + storm::dd::Bdd result = this->getAbstractionInformation().getDdManager().getBddZero(); + + for (uint_fast64_t updateIndex = 0; updateIndex < command.get().getNumberOfUpdates(); ++updateIndex) { + storm::dd::Bdd updateBdd = this->getAbstractionInformation().getDdManager().getBddOne(); + + // Translate block variables for this update into a successor block. + for (auto const& variableIndexPair : variablePredicates[updateIndex]) { + if (model.getBooleanValue(variableIndexPair.first)) { + updateBdd &= this->getAbstractionInformation().encodePredicateAsSuccessor(variableIndexPair.second); + } else { + updateBdd &= !this->getAbstractionInformation().encodePredicateAsSuccessor(variableIndexPair.second); + } + updateBdd &= this->getAbstractionInformation().encodeAux(updateIndex, 0, this->getAbstractionInformation().getAuxVariableCount()); + } + + result |= updateBdd; + } + + STORM_LOG_ASSERT(!result.isZero(), "Distribution must not be empty."); + return result; + } + + template + storm::dd::Bdd CommandAbstractor::computeMissingIdentities() const { + storm::dd::Bdd identities = computeMissingGlobalIdentities(); + identities &= computeMissingUpdateIdentities(); + return identities; + } + + template + storm::dd::Bdd CommandAbstractor::computeMissingUpdateIdentities() const { + storm::dd::Bdd result = this->getAbstractionInformation().getDdManager().getBddZero(); + + for (uint_fast64_t updateIndex = 0; updateIndex < command.get().getNumberOfUpdates(); ++updateIndex) { + // Compute the identities that are missing for this update. + auto updateRelevantIt = relevantPredicatesAndVariables.second[updateIndex].begin(); + auto updateRelevantIte = relevantPredicatesAndVariables.second[updateIndex].end(); + + storm::dd::Bdd updateIdentity = this->getAbstractionInformation().getDdManager().getBddOne(); + auto sourceRelevantIt = relevantPredicatesAndVariables.first.begin(); + auto sourceRelevantIte = relevantPredicatesAndVariables.first.end(); + + // Go through all relevant source predicates. This is guaranteed to be a superset of the set of + // relevant successor predicates for any update. + for (; sourceRelevantIt != sourceRelevantIte; ++sourceRelevantIt) { + // If the predicates do not match, there is a predicate missing, so we need to add its identity. + if (updateRelevantIt == updateRelevantIte || sourceRelevantIt->second != updateRelevantIt->second) { + updateIdentity &= this->getAbstractionInformation().getPredicateIdentity(sourceRelevantIt->second); + } else { + ++updateRelevantIt; + } + } + + result |= updateIdentity && this->getAbstractionInformation().encodeAux(updateIndex, 0, this->getAbstractionInformation().getAuxVariableCount()); + } + return result; + } + + template + storm::dd::Bdd CommandAbstractor::computeMissingGlobalIdentities() const { + storm::dd::Bdd result = this->getAbstractionInformation().getDdManager().getBddOne(); + + auto relevantIt = relevantPredicatesAndVariables.first.begin(); + auto relevantIte = relevantPredicatesAndVariables.first.end(); + + for (uint_fast64_t predicateIndex = 0; predicateIndex < this->getAbstractionInformation().getNumberOfPredicates(); ++predicateIndex) { + if (relevantIt == relevantIte || relevantIt->second != predicateIndex) { + result &= this->getAbstractionInformation().getPredicateIdentity(predicateIndex); + } else { + ++relevantIt; + } + } + + return result; + } + + template + GameBddResult CommandAbstractor::abstract() { + if (forceRecomputation) { + this->recomputeCachedBdd(); + } else { + cachedDd.bdd &= computeMissingGlobalIdentities(); + } + + STORM_LOG_TRACE("Command produces " << cachedDd.bdd.getNonZeroCount() << " transitions."); + + return cachedDd; + } + + template + BottomStateResult CommandAbstractor::getBottomStateTransitions(storm::dd::Bdd const& reachableStates, uint_fast64_t numberOfPlayer2Variables) { + STORM_LOG_TRACE("Computing bottom state transitions of command " << command.get()); + BottomStateResult result(this->getAbstractionInformation().getDdManager().getBddZero(), this->getAbstractionInformation().getDdManager().getBddZero()); + + // If the guard of this command is a predicate, there are not bottom states/transitions. + if (skipBottomStates) { + STORM_LOG_TRACE("Skipping bottom state computation for this command."); + return result; + } + + storm::dd::Bdd reachableStatesWithCommand = reachableStates && abstractGuard; + + // Use the state abstractor to compute the set of abstract states that has this command enabled but + // still has a transition to a bottom state. + bottomStateAbstractor.constrain(reachableStatesWithCommand); + result.states = bottomStateAbstractor.getAbstractStates() && reachableStatesWithCommand; + + // If the result is empty one time, we can skip the bottom state computation from now on. + if (result.states.isZero()) { + skipBottomStates = true; + } + + // Now equip all these states with an actual transition to a bottom state. + result.transitions = result.states && this->getAbstractionInformation().getAllPredicateIdentities() && this->getAbstractionInformation().getBottomStateBdd(false, false); + + // Mark the states as bottom states. + result.states &= this->getAbstractionInformation().getBottomStateBdd(true, false); + + // Add the command encoding and the next free player 2 encoding. + result.transitions &= this->getAbstractionInformation().encodePlayer1Choice(command.get().getGlobalIndex(), this->getAbstractionInformation().getPlayer1VariableCount()) && this->getAbstractionInformation().encodePlayer2Choice(0, 0, numberOfPlayer2Variables) && this->getAbstractionInformation().encodeAux(0, 0, this->getAbstractionInformation().getAuxVariableCount()); + + return result; + } + + template + storm::dd::Add CommandAbstractor::getCommandUpdateProbabilitiesAdd() const { + storm::dd::Add result = this->getAbstractionInformation().getDdManager().template getAddZero(); + for (uint_fast64_t updateIndex = 0; updateIndex < command.get().getNumberOfUpdates(); ++updateIndex) { + result += this->getAbstractionInformation().encodeAux(updateIndex, 0, this->getAbstractionInformation().getAuxVariableCount()).template toAdd() * this->getAbstractionInformation().getDdManager().getConstant(evaluator.asRational(command.get().getUpdate(updateIndex).getLikelihoodExpression())); + } + result *= this->getAbstractionInformation().encodePlayer1Choice(command.get().getGlobalIndex(), this->getAbstractionInformation().getPlayer1VariableCount()).template toAdd(); + return result; + } + + template + storm::prism::Command const& CommandAbstractor::getConcreteCommand() const { + return command.get(); + } + + template + AbstractionInformation const& CommandAbstractor::getAbstractionInformation() const { + return abstractionInformation.get(); + } + + template + AbstractionInformation& CommandAbstractor::getAbstractionInformation() { + return abstractionInformation.get(); + } + + template class CommandAbstractor; + template class CommandAbstractor; +#ifdef STORM_HAVE_CARL + template class CommandAbstractor; +#endif + } + } +} diff --git a/src/storm/abstraction/prism/CommandAbstractor.h b/src/storm/abstraction/prism/CommandAbstractor.h new file mode 100644 index 000000000..e673de271 --- /dev/null +++ b/src/storm/abstraction/prism/CommandAbstractor.h @@ -0,0 +1,259 @@ +#pragma once + +#include +#include +#include +#include + +#include "storm/abstraction/LocalExpressionInformation.h" +#include "storm/abstraction/StateSetAbstractor.h" +#include "storm/abstraction/GameBddResult.h" + +#include "storm/storage/expressions/ExpressionEvaluator.h" + +#include "storm/storage/dd/DdType.h" +#include "storm/storage/expressions/Expression.h" + +#include "storm/solver/SmtSolver.h" + +namespace storm { + namespace utility { + namespace solver { + class SmtSolverFactory; + } + } + + namespace dd { + template + class Bdd; + + template + class Add; + } + + namespace prism { + // Forward-declare concrete command and assignment classes. + class Command; + class Assignment; + } + + namespace abstraction { + template + class AbstractionInformation; + + template + class BottomStateResult; + + namespace prism { + template + class CommandAbstractor { + public: + /*! + * Constructs an abstract command from the given command and the initial predicates. + * + * @param command The concrete command for which to build the abstraction. + * @param abstractionInformation An object holding information about the abstraction such as predicates and BDDs. + * @param smtSolverFactory A factory that is to be used for creating new SMT solvers. + * @param useDecomposition A flag indicating whether to use the decomposition during abstraction. + */ + CommandAbstractor(storm::prism::Command const& command, AbstractionInformation& abstractionInformation, std::shared_ptr const& smtSolverFactory, bool useDecomposition); + + /*! + * Refines the abstract command with the given predicates. + * + * @param predicates The new predicates. + */ + void refine(std::vector const& predicates); + + /*! + * Retrieves the guard of this command. + */ + storm::expressions::Expression const& getGuard() const; + + /*! + * Retrieves a mapping from variables to expressions that define their updates wrt. to the given + * auxiliary choice. + */ + std::map getVariableUpdates(uint64_t auxiliaryChoice) const; + + /*! + * Computes the abstraction of the command wrt. to the current set of predicates. + * + * @return The abstraction of the command in the form of a BDD together with the number of DD variables + * used to encode the choices of player 2. + */ + GameBddResult abstract(); + + /*! + * Retrieves the transitions to bottom states of this command. + * + * @param reachableStates A BDD representing the reachable states. + * @param numberOfPlayer2Variables The number of variables used to encode the choices of player 2. + * @return The bottom state transitions in the form of a BDD. + */ + BottomStateResult getBottomStateTransitions(storm::dd::Bdd const& reachableStates, uint_fast64_t numberOfPlayer2Variables); + + /*! + * Retrieves an ADD that maps the encoding of the command and its updates to their probabilities. + * + * @return The command-update probability ADD. + */ + storm::dd::Add getCommandUpdateProbabilitiesAdd() const; + + /*! + * Retrieves the concrete command that is abstracted by this abstract command. + * + * @return The concrete command. + */ + storm::prism::Command const& getConcreteCommand() const; + + private: + /*! + * Determines the relevant predicates for source as well as successor states wrt. to the given assignments + * (that, for example, form an update). + * + * @param assignments The assignments that are to be considered. + * @return A pair whose first component represents the relevant source predicates and whose second + * component represents the relevant successor state predicates. + */ + std::pair, std::set> computeRelevantPredicates(std::vector const& assignments) const; + + /*! + * Determines the relevant predicates for source as well as successor states. + * + * @return A pair whose first component represents the relevant source predicates and whose second + * component represents the relevant successor state predicates. + */ + std::pair, std::vector>> computeRelevantPredicates() const; + + /*! + * Checks whether the relevant predicates changed. + * + * @param newRelevantPredicates The new relevant predicates. + */ + bool relevantPredicatesChanged(std::pair, std::vector>> const& newRelevantPredicates) const; + + /*! + * Takes the new relevant predicates and creates the appropriate variables and assertions for the ones + * that are currently missing. + * + * @param newRelevantPredicates The new relevant predicates. + */ + void addMissingPredicates(std::pair, std::vector>> const& newRelevantPredicates); + + /*! + * Translates the given model to a source state DD. + * + * @param model The model to translate. + * @return The source state encoded as a DD. + */ + storm::dd::Bdd getSourceStateBdd(storm::solver::SmtSolver::ModelReference const& model, std::vector> const& variablePredicates) const; + + /*! + * Translates the given model to a distribution over successor states. + * + * @param model The model to translate. + * @return The source state encoded as a DD. + */ + storm::dd::Bdd getDistributionBdd(storm::solver::SmtSolver::ModelReference const& model, std::vector>> const& variablePredicates) const; + + /*! + * Recomputes the cached BDD. This needs to be triggered if any relevant predicates change. + */ + void recomputeCachedBdd(); + + /*! + * Recomputes the cached BDD without using the decomposition. + */ + void recomputeCachedBddWithoutDecomposition(); + + /*! + * Recomputes the cached BDD using th decomposition. + */ + void recomputeCachedBddWithDecomposition(); + + /*! + * Computes the missing state identities. + * + * @return A BDD that represents the all missing state identities. + */ + storm::dd::Bdd computeMissingIdentities() const; + + /*! + * Computes the missing state identities for the updates. + * + * @return A BDD that represents the state identities for predicates that are irrelevant for the + * successor states. + */ + storm::dd::Bdd computeMissingUpdateIdentities() const; + + /*! + * Retrieves the abstraction information object. + * + * @return The abstraction information object. + */ + AbstractionInformation const& getAbstractionInformation() const; + + /*! + * Retrieves the abstraction information object. + * + * @return The abstraction information object. + */ + AbstractionInformation& getAbstractionInformation(); + + /*! + * Computes the globally missing state identities. + * + * @return A BDD that represents the global state identities for predicates that are irrelevant for the + * source and successor states. + */ + storm::dd::Bdd computeMissingGlobalIdentities() const; + + // An SMT responsible for this abstract command. + std::unique_ptr smtSolver; + + // The abstraction-related information. + std::reference_wrapper> abstractionInformation; + + // The concrete command this abstract command refers to. + std::reference_wrapper command; + + // The local expression-related information. + LocalExpressionInformation localExpressionInformation; + + // The evaluator used to translate the probability expressions. + storm::expressions::ExpressionEvaluator evaluator; + + // The currently relevant source/successor predicates and the corresponding variables. + std::pair>, std::vector>>> relevantPredicatesAndVariables; + + // The set of all relevant predicates. + std::set allRelevantPredicates; + + // The most recent result of a call to computeDd. If nothing has changed regarding the relevant + // predicates, this result may be reused. + GameBddResult cachedDd; + + // All relevant decision variables over which to perform AllSat. + std::vector decisionVariables; + + // A flag indicating whether to use the decomposition when abstracting. + bool useDecomposition; + + // A flag indicating whether the guard of the command was added as a predicate. If this is true, there + // is no need to compute bottom states. + bool skipBottomStates; + + // A flag remembering whether we need to force recomputation of the BDD. + bool forceRecomputation; + + // The abstract guard of the command. This is only used if the guard is not a predicate, because it can + // then be used to constrain the bottom state abstractor. + storm::dd::Bdd abstractGuard; + + // A state-set abstractor used to determine the bottom states if not all guards were added. + StateSetAbstractor bottomStateAbstractor; + }; + } + } +} diff --git a/src/storm/abstraction/prism/ModuleAbstractor.cpp b/src/storm/abstraction/prism/ModuleAbstractor.cpp new file mode 100644 index 000000000..5670499ea --- /dev/null +++ b/src/storm/abstraction/prism/ModuleAbstractor.cpp @@ -0,0 +1,116 @@ +#include "storm/abstraction/prism/ModuleAbstractor.h" + +#include "storm/abstraction/AbstractionInformation.h" +#include "storm/abstraction/BottomStateResult.h" +#include "storm/abstraction/GameBddResult.h" + +#include "storm/storage/dd/DdManager.h" +#include "storm/storage/dd/Add.h" + +#include "storm/storage/prism/Module.h" + +#include "storm/settings/SettingsManager.h" + +#include "storm-config.h" +#include "storm/adapters/CarlAdapter.h" + +#include "storm/utility/macros.h" + +namespace storm { + namespace abstraction { + namespace prism { + + using storm::settings::modules::AbstractionSettings; + + template + ModuleAbstractor::ModuleAbstractor(storm::prism::Module const& module, AbstractionInformation& abstractionInformation, std::shared_ptr const& smtSolverFactory, bool useDecomposition) : smtSolverFactory(smtSolverFactory), abstractionInformation(abstractionInformation), commands(), module(module) { + + // For each concrete command, we create an abstract counterpart. + for (auto const& command : module.getCommands()) { + commands.emplace_back(command, abstractionInformation, smtSolverFactory, useDecomposition); + } + } + + template + void ModuleAbstractor::refine(std::vector const& predicates) { + for (uint_fast64_t index = 0; index < commands.size(); ++index) { + STORM_LOG_TRACE("Refining command with index " << index << "."); + CommandAbstractor& command = commands[index]; + command.refine(predicates); + } + } + + template + storm::expressions::Expression const& ModuleAbstractor::getGuard(uint64_t player1Choice) const { + return commands[player1Choice].getGuard(); + } + + template + std::map ModuleAbstractor::getVariableUpdates(uint64_t player1Choice, uint64_t auxiliaryChoice) const { + return commands[player1Choice].getVariableUpdates(auxiliaryChoice); + } + + template + GameBddResult ModuleAbstractor::abstract() { + // First, we retrieve the abstractions of all commands. + std::vector> commandDdsAndUsedOptionVariableCounts; + uint_fast64_t maximalNumberOfUsedOptionVariables = 0; + for (auto& command : commands) { + commandDdsAndUsedOptionVariableCounts.push_back(command.abstract()); + maximalNumberOfUsedOptionVariables = std::max(maximalNumberOfUsedOptionVariables, commandDdsAndUsedOptionVariableCounts.back().numberOfPlayer2Variables); + } + + // Then, we build the module BDD by adding the single command DDs. We need to make sure that all command + // DDs use the same amount DD variable encoding the choices of player 2. + storm::dd::Bdd result = this->getAbstractionInformation().getDdManager().getBddZero(); + for (auto const& commandDd : commandDdsAndUsedOptionVariableCounts) { + result |= commandDd.bdd && this->getAbstractionInformation().encodePlayer2Choice(1, commandDd.numberOfPlayer2Variables, maximalNumberOfUsedOptionVariables); + } + return GameBddResult(result, maximalNumberOfUsedOptionVariables); + } + + template + BottomStateResult ModuleAbstractor::getBottomStateTransitions(storm::dd::Bdd const& reachableStates, uint_fast64_t numberOfPlayer2Variables) { + BottomStateResult result(this->getAbstractionInformation().getDdManager().getBddZero(), this->getAbstractionInformation().getDdManager().getBddZero()); + + for (auto& command : commands) { + BottomStateResult commandBottomStateResult = command.getBottomStateTransitions(reachableStates, numberOfPlayer2Variables); + result.states |= commandBottomStateResult.states; + result.transitions |= commandBottomStateResult.transitions; + } + + return result; + } + + template + storm::dd::Add ModuleAbstractor::getCommandUpdateProbabilitiesAdd() const { + storm::dd::Add result = this->getAbstractionInformation().getDdManager().template getAddZero(); + for (auto const& command : commands) { + result += command.getCommandUpdateProbabilitiesAdd(); + } + return result; + } + + template + std::vector> const& ModuleAbstractor::getCommands() const { + return commands; + } + + template + std::vector>& ModuleAbstractor::getCommands() { + return commands; + } + + template + AbstractionInformation const& ModuleAbstractor::getAbstractionInformation() const { + return abstractionInformation.get(); + } + + template class ModuleAbstractor; + template class ModuleAbstractor; +#ifdef STORM_HAVE_CARL + template class ModuleAbstractor; +#endif + } + } +} diff --git a/src/storm/abstraction/prism/ModuleAbstractor.h b/src/storm/abstraction/prism/ModuleAbstractor.h new file mode 100644 index 000000000..3cfb21ca7 --- /dev/null +++ b/src/storm/abstraction/prism/ModuleAbstractor.h @@ -0,0 +1,128 @@ +#pragma once + +#include "storm/storage/dd/DdType.h" + +#include "storm/abstraction/prism/CommandAbstractor.h" + +#include "storm/settings/modules/AbstractionSettings.h" + +#include "storm/storage/expressions/Expression.h" + +#include "storm/utility/solver.h" + +namespace storm { + namespace prism { + // Forward-declare concrete module class. + class Module; + } + + namespace abstraction { + template + class AbstractionInformation; + + template + struct BottomStateResult; + + template + struct GameBddResult; + + namespace prism { + template + class ModuleAbstractor { + public: + /*! + * Constructs an abstract module from the given module. + * + * @param module The concrete module for which to build the abstraction. + * @param abstractionInformation An object holding information about the abstraction such as predicates and BDDs. + * @param smtSolverFactory A factory that is to be used for creating new SMT solvers. + * @param useDecomposition A flag that governs whether to use the decomposition in the abstraction. + */ + ModuleAbstractor(storm::prism::Module const& module, AbstractionInformation& abstractionInformation, std::shared_ptr const& smtSolverFactory, bool useDecomposition); + + ModuleAbstractor(ModuleAbstractor const&) = default; + ModuleAbstractor& operator=(ModuleAbstractor const&) = default; + ModuleAbstractor(ModuleAbstractor&&) = default; + ModuleAbstractor& operator=(ModuleAbstractor&&) = default; + + /*! + * Refines the abstract module with the given predicates. + * + * @param predicates The new predicate indices. + */ + void refine(std::vector const& predicates); + + /*! + * Retrieves the guard of the given player 1 choice. + * + * @param player1Choice The choice of player 1. + * @return The guard of the player 1 choice. + */ + storm::expressions::Expression const& getGuard(uint64_t player1Choice) const; + + /*! + * Retrieves a mapping from variables to expressions that define their updates wrt. to the given player + * 1 choice and auxiliary choice. + */ + std::map getVariableUpdates(uint64_t player1Choice, uint64_t auxiliaryChoice) const; + + /*! + * Computes the abstraction of the module wrt. to the current set of predicates. + * + * @return The abstraction of the module in the form of a BDD together with how many option variables were used. + */ + GameBddResult abstract(); + + /*! + * Retrieves the transitions to bottom states of this module. + * + * @param reachableStates A BDD representing the reachable states. + * @param numberOfPlayer2Variables The number of variables used to encode the choices of player 2. + * @return The bottom states and the necessary transitions. + */ + BottomStateResult getBottomStateTransitions(storm::dd::Bdd const& reachableStates, uint_fast64_t numberOfPlayer2Variables); + + /*! + * Retrieves an ADD that maps the encodings of commands and their updates to their probabilities. + * + * @return The command-update probability ADD. + */ + storm::dd::Add getCommandUpdateProbabilitiesAdd() const; + + /*! + * Retrieves the abstract commands of this abstract module. + * + * @return The abstract commands. + */ + std::vector> const& getCommands() const; + + /*! + * Retrieves the abstract commands of this abstract module. + * + * @return The abstract commands. + */ + std::vector>& getCommands(); + + private: + /*! + * Retrieves the abstraction information. + * + * @return The abstraction information. + */ + AbstractionInformation const& getAbstractionInformation() const; + + // A factory that can be used to create new SMT solvers. + std::shared_ptr smtSolverFactory; + + // The DD-related information. + std::reference_wrapper const> abstractionInformation; + + // The abstract commands of the abstract module. + std::vector> commands; + + // The concrete module this abstract module refers to. + std::reference_wrapper module; + }; + } + } +} diff --git a/src/storm/abstraction/prism/PrismMenuGameAbstractor.cpp b/src/storm/abstraction/prism/PrismMenuGameAbstractor.cpp new file mode 100644 index 000000000..e196c1510 --- /dev/null +++ b/src/storm/abstraction/prism/PrismMenuGameAbstractor.cpp @@ -0,0 +1,214 @@ +#include "storm/abstraction/prism/PrismMenuGameAbstractor.h" + +#include "storm/abstraction/BottomStateResult.h" +#include "storm/abstraction/GameBddResult.h" +#include "storm/abstraction/ExpressionTranslator.h" + +#include "storm/storage/BitVector.h" + +#include "storm/storage/prism/Program.h" + +#include "storm/storage/dd/DdManager.h" +#include "storm/storage/dd/Add.h" + +#include "storm/models/symbolic/StandardRewardModel.h" + +#include "storm/settings/SettingsManager.h" + +#include "storm/utility/dd.h" +#include "storm/utility/macros.h" +#include "storm/utility/solver.h" +#include "storm/exceptions/WrongFormatException.h" +#include "storm/exceptions/InvalidArgumentException.h" +#include "storm/exceptions/NotSupportedException.h" + +#include "storm-config.h" +#include "storm/adapters/CarlAdapter.h" + +namespace storm { + namespace abstraction { + namespace prism { + + using storm::settings::modules::AbstractionSettings; + + template + PrismMenuGameAbstractor::PrismMenuGameAbstractor(storm::prism::Program const& program, + std::shared_ptr const& smtSolverFactory) + : program(program), smtSolverFactory(smtSolverFactory), abstractionInformation(program.getManager(), program.getAllExpressionVariables(), smtSolverFactory->create(program.getManager())), modules(), initialStateAbstractor(abstractionInformation, {program.getInitialStatesExpression()}, this->smtSolverFactory), validBlockAbstractor(abstractionInformation, smtSolverFactory), currentGame(nullptr), refinementPerformed(false) { + + // For now, we assume that there is a single module. If the program has more than one module, it needs + // to be flattened before the procedure. + STORM_LOG_THROW(program.getNumberOfModules() == 1, storm::exceptions::WrongFormatException, "Cannot create abstract program from program containing too many modules."); + + // Add all variables range expressions to the information object. + for (auto const& range : this->program.get().getAllRangeExpressions()) { + abstractionInformation.addConstraint(range); + initialStateAbstractor.constrain(range); + } + + uint_fast64_t totalNumberOfCommands = 0; + uint_fast64_t maximalUpdateCount = 0; + std::vector allGuards; + for (auto const& module : program.getModules()) { + for (auto const& command : module.getCommands()) { + maximalUpdateCount = std::max(maximalUpdateCount, static_cast(command.getNumberOfUpdates())); + } + + totalNumberOfCommands += module.getNumberOfCommands(); + } + + // NOTE: currently we assume that 100 player 2 variables suffice, which corresponds to 2^100 possible + // choices. If for some reason this should not be enough, we could grow this vector dynamically, but + // odds are that it's impossible to treat such models in any event. + abstractionInformation.createEncodingVariables(static_cast(std::ceil(std::log2(totalNumberOfCommands))), 100, static_cast(std::ceil(std::log2(maximalUpdateCount)))); + + // For each module of the concrete program, we create an abstract counterpart. + bool useDecomposition = storm::settings::getModule().isUseDecompositionSet(); + for (auto const& module : program.getModules()) { + this->modules.emplace_back(module, abstractionInformation, this->smtSolverFactory, useDecomposition); + } + + // Retrieve the command-update probability ADD, so we can multiply it with the abstraction BDD later. + commandUpdateProbabilitiesAdd = modules.front().getCommandUpdateProbabilitiesAdd(); + } + + template + void PrismMenuGameAbstractor::refine(RefinementCommand const& command) { + // Add the predicates to the global list of predicates and gather their indices. + std::vector predicateIndices; + for (auto const& predicate : command.getPredicates()) { + STORM_LOG_THROW(predicate.hasBooleanType(), storm::exceptions::InvalidArgumentException, "Expecting a predicate of type bool."); + predicateIndices.push_back(abstractionInformation.getOrAddPredicate(predicate)); + } + + // Refine all abstract modules. + for (auto& module : modules) { + module.refine(predicateIndices); + } + + // Refine initial state abstractor. + initialStateAbstractor.refine(predicateIndices); + + // Refine the valid blocks. + validBlockAbstractor.refine(predicateIndices); + + refinementPerformed |= !command.getPredicates().empty(); + } + + template + MenuGame PrismMenuGameAbstractor::abstract() { + if (refinementPerformed) { + currentGame = buildGame(); + refinementPerformed = true; + } + return *currentGame; + } + + template + AbstractionInformation const& PrismMenuGameAbstractor::getAbstractionInformation() const { + return abstractionInformation; + } + + template + storm::expressions::Expression const& PrismMenuGameAbstractor::getGuard(uint64_t player1Choice) const { + return modules.front().getGuard(player1Choice); + } + + template + std::map PrismMenuGameAbstractor::getVariableUpdates(uint64_t player1Choice, uint64_t auxiliaryChoice) const { + return modules.front().getVariableUpdates(player1Choice, auxiliaryChoice); + } + + template + std::pair PrismMenuGameAbstractor::getPlayer1ChoiceRange() const { + return std::make_pair(0, modules.front().getCommands().size()); + } + + template + storm::expressions::Expression PrismMenuGameAbstractor::getInitialExpression() const { + return program.get().getInitialStatesExpression(); + } + + template + storm::dd::Bdd PrismMenuGameAbstractor::getStates(storm::expressions::Expression const& expression) { + storm::abstraction::ExpressionTranslator translator(abstractionInformation, smtSolverFactory->create(abstractionInformation.getExpressionManager())); + return translator.translate(expression); + } + + template + std::unique_ptr> PrismMenuGameAbstractor::buildGame() { + // As long as there is only one module, we only build its game representation. + GameBddResult game = modules.front().abstract(); + + // Construct a set of all unnecessary variables, so we can abstract from it. + std::set variablesToAbstract(abstractionInformation.getPlayer1VariableSet(abstractionInformation.getPlayer1VariableCount())); + auto player2Variables = abstractionInformation.getPlayer2VariableSet(game.numberOfPlayer2Variables); + variablesToAbstract.insert(player2Variables.begin(), player2Variables.end()); + auto auxVariables = abstractionInformation.getAuxVariableSet(0, abstractionInformation.getAuxVariableCount()); + variablesToAbstract.insert(auxVariables.begin(), auxVariables.end()); + + // Do a reachability analysis on the raw transition relation. + storm::dd::Bdd transitionRelation = game.bdd.existsAbstract(variablesToAbstract); + storm::dd::Bdd initialStates = initialStateAbstractor.getAbstractStates(); + initialStates.addMetaVariables(abstractionInformation.getSourcePredicateVariables()); + storm::dd::Bdd reachableStates = storm::utility::dd::computeReachableStates(initialStates, transitionRelation, abstractionInformation.getSourceVariables(), abstractionInformation.getSuccessorVariables()); + + // Find the deadlock states in the model. Note that this does not find the 'deadlocks' in bottom states, + // as the bottom states are not contained in the reachable states. + storm::dd::Bdd deadlockStates = transitionRelation.existsAbstract(abstractionInformation.getSuccessorVariables()); + deadlockStates = reachableStates && !deadlockStates; + + // If there are deadlock states, we fix them now. + storm::dd::Add deadlockTransitions = abstractionInformation.getDdManager().template getAddZero(); + if (!deadlockStates.isZero()) { + deadlockTransitions = (deadlockStates && abstractionInformation.getAllPredicateIdentities() && abstractionInformation.encodePlayer1Choice(0, abstractionInformation.getPlayer1VariableCount()) && abstractionInformation.encodePlayer2Choice(0, 0, game.numberOfPlayer2Variables) && abstractionInformation.encodeAux(0, 0, abstractionInformation.getAuxVariableCount())).template toAdd(); + } + + // Compute bottom states and the appropriate transitions if necessary. + BottomStateResult bottomStateResult(abstractionInformation.getDdManager().getBddZero(), abstractionInformation.getDdManager().getBddZero()); + bottomStateResult = modules.front().getBottomStateTransitions(reachableStates, game.numberOfPlayer2Variables); + bool hasBottomStates = !bottomStateResult.states.isZero(); + + // Construct the transition matrix by cutting away the transitions of unreachable states. + storm::dd::Add transitionMatrix = (game.bdd && reachableStates).template toAdd(); + transitionMatrix *= commandUpdateProbabilitiesAdd; + transitionMatrix += deadlockTransitions; + + // Extend the current game information with the 'non-bottom' tag before potentially adding bottom state transitions. + transitionMatrix *= (abstractionInformation.getBottomStateBdd(true, true) && abstractionInformation.getBottomStateBdd(false, true)).template toAdd(); + reachableStates &= abstractionInformation.getBottomStateBdd(true, true); + initialStates &= abstractionInformation.getBottomStateBdd(true, true); + + // If there are bottom transitions, exnted the transition matrix and reachable states now. + if (hasBottomStates) { + transitionMatrix += bottomStateResult.transitions.template toAdd(); + reachableStates |= bottomStateResult.states; + } + + std::set usedPlayer2Variables(abstractionInformation.getPlayer2Variables().begin(), abstractionInformation.getPlayer2Variables().begin() + game.numberOfPlayer2Variables); + + std::set allNondeterminismVariables = usedPlayer2Variables; + allNondeterminismVariables.insert(abstractionInformation.getPlayer1Variables().begin(), abstractionInformation.getPlayer1Variables().end()); + + std::set allSourceVariables(abstractionInformation.getSourceVariables()); + allSourceVariables.insert(abstractionInformation.getBottomStateVariable(true)); + std::set allSuccessorVariables(abstractionInformation.getSuccessorVariables()); + allSuccessorVariables.insert(abstractionInformation.getBottomStateVariable(false)); + + return std::make_unique>(abstractionInformation.getDdManagerAsSharedPointer(), reachableStates, initialStates, abstractionInformation.getDdManager().getBddZero(), transitionMatrix, bottomStateResult.states, allSourceVariables, allSuccessorVariables, abstractionInformation.getExtendedSourceSuccessorVariablePairs(), std::set(abstractionInformation.getPlayer1Variables().begin(), abstractionInformation.getPlayer1Variables().end()), usedPlayer2Variables, allNondeterminismVariables, auxVariables, abstractionInformation.getPredicateToBddMap()); + } + + template + void PrismMenuGameAbstractor::exportToDot(std::string const& filename, storm::dd::Bdd const& highlightStates, storm::dd::Bdd const& filter) const { + this->exportToDot(*currentGame, filename, highlightStates, filter); + } + + // Explicitly instantiate the class. + template class PrismMenuGameAbstractor; + template class PrismMenuGameAbstractor; +#ifdef STORM_HAVE_CARL + template class PrismMenuGameAbstractor; +#endif + } + } +} diff --git a/src/storm/abstraction/prism/PrismMenuGameAbstractor.h b/src/storm/abstraction/prism/PrismMenuGameAbstractor.h new file mode 100644 index 000000000..49dc8e9dc --- /dev/null +++ b/src/storm/abstraction/prism/PrismMenuGameAbstractor.h @@ -0,0 +1,160 @@ +#pragma once + +#include "storm/storage/dd/DdType.h" + +#include "storm/abstraction/MenuGameAbstractor.h" +#include "storm/abstraction/AbstractionInformation.h" +#include "storm/abstraction/MenuGame.h" +#include "storm/abstraction/RefinementCommand.h" +#include "storm/abstraction/ValidBlockAbstractor.h" +#include "storm/abstraction/prism/ModuleAbstractor.h" + +#include "storm/storage/dd/Add.h" + +#include "storm/storage/expressions/Expression.h" + +#include "storm/settings/modules/AbstractionSettings.h" + +namespace storm { + namespace utility { + namespace solver { + class SmtSolverFactory; + } + } + + namespace models { + namespace symbolic { + template + class StochasticTwoPlayerGame; + } + } + + namespace prism { + // Forward-declare concrete Program class. + class Program; + } + + namespace abstraction { + namespace prism { + + template + class PrismMenuGameAbstractor : public MenuGameAbstractor { + public: + /*! + * Constructs an abstractor for the given program. + * + * @param program The concrete program for which to build the abstraction. + * @param smtSolverFactory A factory that is to be used for creating new SMT solvers. + */ + PrismMenuGameAbstractor(storm::prism::Program const& program, std::shared_ptr const& smtSolverFactory); + + PrismMenuGameAbstractor(PrismMenuGameAbstractor const&) = default; + PrismMenuGameAbstractor& operator=(PrismMenuGameAbstractor const&) = default; + PrismMenuGameAbstractor(PrismMenuGameAbstractor&&) = default; + PrismMenuGameAbstractor& operator=(PrismMenuGameAbstractor&&) = default; + + /*! + * Uses the current set of predicates to derive the abstract menu game in the form of an ADD. + * + * @return The abstract stochastic two player game. + */ + MenuGame abstract() override; + + /*! + * Retrieves information about the abstraction. + * + * @return The abstraction information object. + */ + AbstractionInformation const& getAbstractionInformation() const override; + + /*! + * Retrieves the guard predicate of the given player 1 choice. + * + * @param player1Choice The choice for which to retrieve the guard. + * @return The guard of the player 1 choice. + */ + storm::expressions::Expression const& getGuard(uint64_t player1Choice) const override; + + /*! + * Retrieves a mapping from variables to expressions that define their updates wrt. to the given player + * 1 choice and auxiliary choice. + */ + std::map getVariableUpdates(uint64_t player1Choice, uint64_t auxiliaryChoice) const override; + + /*! + * Retrieves the range of player 1 choices. + */ + std::pair getPlayer1ChoiceRange() const override; + + /*! + * Retrieves the expression that characterizes the initial states. + */ + storm::expressions::Expression getInitialExpression() const override; + + storm::dd::Bdd getStates(storm::expressions::Expression const& expression) override; + + /*! + * Performs the given refinement command. + * + * @param command The command to perform. + */ + virtual void refine(RefinementCommand const& command) override; + + /*! + * Exports the current state of the abstraction in the dot format to the given file. + * + * @param filename The name of the file to which to write the dot output. + * @param highlightStates A BDD characterizing states that will be highlighted. + * @param filter A filter that is applied to select which part of the game to export. + */ + virtual void exportToDot(std::string const& filename, storm::dd::Bdd const& highlightStates, storm::dd::Bdd const& filter) const override; + + protected: + using MenuGameAbstractor::exportToDot; + + private: + /*! + * Builds the stochastic game representing the abstraction of the program. + * + * @return The stochastic game. + */ + std::unique_ptr> buildGame(); + + /*! + * Decodes the given choice over the auxiliary and successor variables to a mapping from update indices + * to bit vectors representing the successors under these updates. + * + * @param choice The choice to decode. + */ + std::map decodeChoiceToUpdateSuccessorMapping(storm::dd::Bdd const& choice) const; + + // The concrete program this abstract program refers to. + std::reference_wrapper program; + + // A factory that can be used to create new SMT solvers. + std::shared_ptr smtSolverFactory; + + // An object containing all information about the abstraction like predicates and the corresponding DDs. + AbstractionInformation abstractionInformation; + + // The abstract modules of the abstract program. + std::vector> modules; + + // A state-set abstractor used to determine the initial states of the abstraction. + StateSetAbstractor initialStateAbstractor; + + // An object that is used to compute the valid blocks. + ValidBlockAbstractor validBlockAbstractor; + + // An ADD characterizing the probabilities of commands and their updates. + storm::dd::Add commandUpdateProbabilitiesAdd; + + // The current game-based abstraction. + std::unique_ptr> currentGame; + + // A flag storing whether a refinement was performed. + bool refinementPerformed; + }; + } + } +} diff --git a/src/storm/adapters/AddExpressionAdapter.cpp b/src/storm/adapters/AddExpressionAdapter.cpp index 239b04125..b5731a3f3 100644 --- a/src/storm/adapters/AddExpressionAdapter.cpp +++ b/src/storm/adapters/AddExpressionAdapter.cpp @@ -8,6 +8,9 @@ #include "storm/storage/dd/Add.h" #include "storm/storage/dd/Bdd.h" +#include "storm-config.h" +#include "storm/adapters/CarlAdapter.h" + namespace storm { namespace adapters { @@ -139,7 +142,7 @@ namespace storm { } template - boost::any AddExpressionAdapter::visit(storm::expressions::VariableExpression const& expression, boost::any const& data) { + boost::any AddExpressionAdapter::visit(storm::expressions::VariableExpression const& expression, boost::any const&) { auto const& variablePair = variableMapping->find(expression.getVariable()); STORM_LOG_THROW(variablePair != variableMapping->end(), storm::exceptions::InvalidArgumentException, "Cannot translate the given expression, because it contains the variable '" << expression.getVariableName() << "' for which no DD counterpart is known."); if (expression.hasBooleanType()) { @@ -184,23 +187,25 @@ namespace storm { } template - boost::any AddExpressionAdapter::visit(storm::expressions::BooleanLiteralExpression const& expression, boost::any const& data) { + boost::any AddExpressionAdapter::visit(storm::expressions::BooleanLiteralExpression const& expression, boost::any const&) { return expression.getValue() ? ddManager->getBddOne() : ddManager->getBddZero(); } template - boost::any AddExpressionAdapter::visit(storm::expressions::IntegerLiteralExpression const& expression, boost::any const& data) { + boost::any AddExpressionAdapter::visit(storm::expressions::IntegerLiteralExpression const& expression, boost::any const&) { return ddManager->getConstant(static_cast(expression.getValue())); } template - boost::any AddExpressionAdapter::visit(storm::expressions::RationalLiteralExpression const& expression, boost::any const& data) { + boost::any AddExpressionAdapter::visit(storm::expressions::RationalLiteralExpression const& expression, boost::any const&) { return ddManager->getConstant(static_cast(expression.getValueAsDouble())); } // Explicitly instantiate the symbolic expression adapter template class AddExpressionAdapter; template class AddExpressionAdapter; - +#ifdef STORM_HAVE_CARL + template class AddExpressionAdapter; +#endif } // namespace adapters } // namespace storm diff --git a/src/storm/adapters/CarlAdapter.h b/src/storm/adapters/CarlAdapter.h index 29e46f109..d6360041e 100644 --- a/src/storm/adapters/CarlAdapter.h +++ b/src/storm/adapters/CarlAdapter.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace carl { // Define hash values for all polynomials and rational function. @@ -79,6 +80,7 @@ namespace storm { typedef carl::Variable RationalFunctionVariable; typedef carl::MultivariatePolynomial RawPolynomial; typedef carl::FactorizedPolynomial Polynomial; + typedef carl::Cache> RawPolynomialCache; typedef carl::Relation CompareRelation; typedef carl::RationalFunction RationalFunction; diff --git a/src/storm/adapters/EigenAdapter.cpp b/src/storm/adapters/EigenAdapter.cpp index b5a3ccbbf..499488217 100644 --- a/src/storm/adapters/EigenAdapter.cpp +++ b/src/storm/adapters/EigenAdapter.cpp @@ -4,9 +4,9 @@ namespace storm { namespace adapters { template - std::unique_ptr> EigenAdapter::toEigenSparseMatrix(storm::storage::SparseMatrix const& matrix) { + std::unique_ptr> EigenAdapter::toEigenSparseMatrix(storm::storage::SparseMatrix const& matrix) { // Build a list of triplets and let Eigen care about the insertion. - std::vector> triplets; + std::vector> triplets; triplets.reserve(matrix.getNonzeroEntryCount()); for (uint64_t row = 0; row < matrix.getRowCount(); ++row) { @@ -15,16 +15,16 @@ namespace storm { } } - std::unique_ptr> result = std::make_unique>(matrix.getRowCount(), matrix.getColumnCount()); + std::unique_ptr> result = std::make_unique>(matrix.getRowCount(), matrix.getColumnCount()); result->setFromTriplets(triplets.begin(), triplets.end()); return result; } - template std::unique_ptr> EigenAdapter::toEigenSparseMatrix(storm::storage::SparseMatrix const& matrix); + template std::unique_ptr> EigenAdapter::toEigenSparseMatrix(storm::storage::SparseMatrix const& matrix); #ifdef STORM_HAVE_CARL - template std::unique_ptr> EigenAdapter::toEigenSparseMatrix(storm::storage::SparseMatrix const& matrix); - template std::unique_ptr> EigenAdapter::toEigenSparseMatrix(storm::storage::SparseMatrix const& matrix); + template std::unique_ptr> EigenAdapter::toEigenSparseMatrix(storm::storage::SparseMatrix const& matrix); + template std::unique_ptr> EigenAdapter::toEigenSparseMatrix(storm::storage::SparseMatrix const& matrix); #endif } } diff --git a/src/storm/adapters/EigenAdapter.h b/src/storm/adapters/EigenAdapter.h index a205ebee4..6c5f8e7d5 100644 --- a/src/storm/adapters/EigenAdapter.h +++ b/src/storm/adapters/EigenAdapter.h @@ -16,7 +16,7 @@ namespace storm { * @return A pointer to a row-major sparse matrix in gmm++ format. */ template - static std::unique_ptr> toEigenSparseMatrix(storm::storage::SparseMatrix const& matrix); + static std::unique_ptr> toEigenSparseMatrix(storm::storage::SparseMatrix const& matrix); }; } diff --git a/src/storm/adapters/HyproAdapter.h b/src/storm/adapters/HyproAdapter.h index e13809c96..7537b63eb 100644 --- a/src/storm/adapters/HyproAdapter.h +++ b/src/storm/adapters/HyproAdapter.h @@ -12,7 +12,7 @@ #include #include "storm/adapters/CarlAdapter.h" -#include "storm/storage/geometry/HalfSpace.h" +#include "storm/storage/geometry/Halfspace.h" namespace storm { namespace adapters { diff --git a/src/storm/adapters/MathsatExpressionAdapter.h b/src/storm/adapters/MathsatExpressionAdapter.h index bded0ef41..63edcc371 100644 --- a/src/storm/adapters/MathsatExpressionAdapter.h +++ b/src/storm/adapters/MathsatExpressionAdapter.h @@ -58,12 +58,15 @@ namespace storm { */ msat_term translateExpression(storm::expressions::Expression const& expression) { msat_term result = boost::any_cast(expression.getBaseExpression().accept(*this, boost::none)); - STORM_LOG_THROW(!MSAT_ERROR_TERM(result), storm::exceptions::ExpressionEvaluationException, "Could not translate expression to MathSAT's format."); + if (MSAT_ERROR_TERM(result)) { + std::string errorMessage(msat_last_error_message(env)); + STORM_LOG_THROW(!MSAT_ERROR_TERM(result), storm::exceptions::ExpressionEvaluationException, "Could not translate expression to MathSAT's format. (Message: " << errorMessage << ")"); + } return result; } /*! - * Translates the given variable to an equivalent expression for Z3. + * Translates the given variable to an equivalent expression for MathSAT. * * @param variable The variable to translate. * @return An equivalent term for MathSAT. @@ -164,18 +167,24 @@ namespace storm { msat_term conditionResult = boost::any_cast(expression.getCondition()->accept(*this, data)); msat_term thenResult = boost::any_cast(expression.getThenExpression()->accept(*this, data)); msat_term elseResult = boost::any_cast(expression.getElseExpression()->accept(*this, data)); - return msat_make_term_ite(env, conditionResult, thenResult, elseResult); + + // MathSAT does not allow ite with boolean arguments, so we have to encode it ourselves. + if (expression.getThenExpression()->hasBooleanType() && expression.getElseExpression()->hasBooleanType()) { + return msat_make_and(env, msat_make_or(env, msat_make_not(env, conditionResult), thenResult), msat_make_or(env, conditionResult, elseResult)); + } else { + return msat_make_term_ite(env, conditionResult, thenResult, elseResult); + } } - virtual boost::any visit(storm::expressions::BooleanLiteralExpression const& expression, boost::any const& data) override { + virtual boost::any visit(storm::expressions::BooleanLiteralExpression const& expression, boost::any const&) override { return expression.getValue() ? msat_make_true(env) : msat_make_false(env); } - virtual boost::any visit(storm::expressions::RationalLiteralExpression const& expression, boost::any const& data) override { + virtual boost::any visit(storm::expressions::RationalLiteralExpression const& expression, boost::any const&) override { return msat_make_number(env, std::to_string(expression.getValueAsDouble()).c_str()); } - virtual boost::any visit(storm::expressions::IntegerLiteralExpression const& expression, boost::any const& data) override { + virtual boost::any visit(storm::expressions::IntegerLiteralExpression const& expression, boost::any const&) override { return msat_make_number(env, std::to_string(static_cast(expression.getValue())).c_str()); } @@ -209,7 +218,7 @@ namespace storm { } } - virtual boost::any visit(storm::expressions::VariableExpression const& expression, boost::any const& data) override { + virtual boost::any visit(storm::expressions::VariableExpression const& expression, boost::any const&) override { return translateExpression(expression.getVariable()); } diff --git a/src/storm/adapters/NumberAdapter.h b/src/storm/adapters/NumberAdapter.h index f300da9c7..55427841b 100644 --- a/src/storm/adapters/NumberAdapter.h +++ b/src/storm/adapters/NumberAdapter.h @@ -6,7 +6,7 @@ #include namespace storm { -#if defined STORM_HAVE_CLN && defined USE_CLN_NUMBERS +#if defined STORM_HAVE_CLN && defined STORM_USE_CLN_NUMBERS typedef cln::cl_RA RationalNumber; #else typedef mpq_class RationalNumber; diff --git a/src/storm/adapters/Smt2ExpressionAdapter.h b/src/storm/adapters/Smt2ExpressionAdapter.h index 7c5b6dce4..ad72269a6 100644 --- a/src/storm/adapters/Smt2ExpressionAdapter.h +++ b/src/storm/adapters/Smt2ExpressionAdapter.h @@ -24,7 +24,7 @@ namespace storm { * @param manager The manager that can be used to build expressions. * @param useReadableVarNames sets whether the expressions should use human readable names for the variables or the internal representation */ - Smt2ExpressionAdapter(storm::expressions::ExpressionManager& manager, bool useReadableVarNames) + Smt2ExpressionAdapter(storm::expressions::ExpressionManager&, bool useReadableVarNames) : useReadableVarNames(useReadableVarNames) { declaredVariables.emplace_back(std::set()); } diff --git a/src/storm/adapters/Z3ExpressionAdapter.cpp b/src/storm/adapters/Z3ExpressionAdapter.cpp index 77f3379ea..fa8e9721e 100644 --- a/src/storm/adapters/Z3ExpressionAdapter.cpp +++ b/src/storm/adapters/Z3ExpressionAdapter.cpp @@ -207,17 +207,17 @@ namespace storm { } } - boost::any Z3ExpressionAdapter::visit(storm::expressions::BooleanLiteralExpression const& expression, boost::any const& data) { + boost::any Z3ExpressionAdapter::visit(storm::expressions::BooleanLiteralExpression const& expression, boost::any const&) { return context.bool_val(expression.getValue()); } - boost::any Z3ExpressionAdapter::visit(storm::expressions::RationalLiteralExpression const& expression, boost::any const& data) { + boost::any Z3ExpressionAdapter::visit(storm::expressions::RationalLiteralExpression const& expression, boost::any const&) { std::stringstream fractionStream; fractionStream << expression.getValue(); return context.real_val(fractionStream.str().c_str()); } - boost::any Z3ExpressionAdapter::visit(storm::expressions::IntegerLiteralExpression const& expression, boost::any const& data) { + boost::any Z3ExpressionAdapter::visit(storm::expressions::IntegerLiteralExpression const& expression, boost::any const&) { return context.int_val(static_cast(expression.getValue())); } @@ -261,7 +261,7 @@ namespace storm { return z3::expr(context, Z3_mk_ite(context, conditionResult, thenResult, elseResult)); } - boost::any Z3ExpressionAdapter::visit(storm::expressions::VariableExpression const& expression, boost::any const& data) { + boost::any Z3ExpressionAdapter::visit(storm::expressions::VariableExpression const& expression, boost::any const&) { return this->translateExpression(expression.getVariable()); } diff --git a/src/storm/adapters/Z3ExpressionAdapter.h b/src/storm/adapters/Z3ExpressionAdapter.h index d42a2e01c..ddc6e185c 100644 --- a/src/storm/adapters/Z3ExpressionAdapter.h +++ b/src/storm/adapters/Z3ExpressionAdapter.h @@ -47,6 +47,7 @@ namespace storm { z3::expr translateExpression(storm::expressions::Variable const& variable); storm::expressions::Expression translateExpression(z3::expr const& expr); + /*! * Finds the counterpart to the given z3 variable declaration. * @@ -82,6 +83,7 @@ namespace storm { * @param variable The variable for which to create a Z3 counterpart. */ z3::expr createVariable(storm::expressions::Variable const& variable); + // The manager that can be used to build expressions. storm::expressions::ExpressionManager& manager; diff --git a/src/storm/builder/DdJaniModelBuilder.cpp b/src/storm/builder/DdJaniModelBuilder.cpp index 18cfee6da..33ee40758 100644 --- a/src/storm/builder/DdJaniModelBuilder.cpp +++ b/src/storm/builder/DdJaniModelBuilder.cpp @@ -51,9 +51,7 @@ namespace storm { template DdJaniModelBuilder::Options::Options(std::vector> const& formulas) : buildAllLabels(false), buildAllRewardModels(false), rewardModelsToBuild(), constantDefinitions(), terminalStates(), negatedTerminalStates() { - if (formulas.empty()) { - this->buildAllRewardModels = true; - } else { + if (!formulas.empty()) { for (auto const& formula : formulas) { this->preserveFormula(*formula); } @@ -121,12 +119,12 @@ namespace storm { bool DdJaniModelBuilder::Options::isBuildAllRewardModelsSet() const { return buildAllRewardModels; } - + template bool DdJaniModelBuilder::Options::isBuildAllLabelsSet() const { return buildAllLabels; } - + template void DdJaniModelBuilder::Options::addLabel(std::string const& labelName) { STORM_LOG_THROW(!buildAllLabels, storm::exceptions::InvalidSettingsException, "Cannot add label, because all labels are built anyway."); @@ -159,7 +157,6 @@ namespace storm { std::vector> rowColumnMetaVariablePairs; // A mapping from automata to the meta variables encoding their location. - std::map automatonToLocationVariableMap; std::map> automatonToLocationDdVariableMap; // A mapping from action indices to the meta variables used to encode these actions. @@ -223,7 +220,7 @@ namespace storm { return createVariables(); } - boost::any visit(storm::jani::AutomatonComposition const& composition, boost::any const& data) override { + boost::any visit(storm::jani::AutomatonComposition const& composition, boost::any const&) override { auto it = automata.find(composition.getAutomatonName()); STORM_LOG_THROW(it == automata.end(), storm::exceptions::InvalidArgumentException, "Cannot build symbolic model from JANI model whose system composition that refers to the automaton '" << composition.getAutomatonName() << "' multiple times."); automata.insert(it, composition.getAutomatonName()); @@ -232,7 +229,7 @@ namespace storm { boost::any visit(storm::jani::ParallelComposition const& composition, boost::any const& data) override { for (auto const& subcomposition : composition.getSubcompositions()) { - subcomposition->accept(*this, boost::none); + subcomposition->accept(*this, data); } return boost::none; } @@ -264,10 +261,11 @@ namespace storm { result.allNondeterminismVariables.insert(result.markovNondeterminismVariable); } - for (auto const& automaton : this->model.getAutomata()) { + for (auto const& automatonName : this->automata) { + storm::jani::Automaton const& automaton = this->model.getAutomaton(automatonName); + // Start by creating a meta variable for the location of the automaton. - storm::expressions::Variable locationExpressionVariable = model.getManager().declareFreshIntegerVariable(false, "loc"); - result.automatonToLocationVariableMap[automaton.getName()] = locationExpressionVariable; + storm::expressions::Variable locationExpressionVariable = automaton.getLocationExpressionVariable(); std::pair variablePair = result.manager->addMetaVariable("l_" + automaton.getName(), 0, automaton.getNumberOfLocations() - 1); result.automatonToLocationDdVariableMap[automaton.getName()] = variablePair; result.rowColumnMetaVariablePairs.push_back(variablePair); @@ -1785,10 +1783,16 @@ namespace storm { std::map buildLabelExpressions(storm::jani::Model const& model, CompositionVariables const& variables, typename DdJaniModelBuilder::Options const& options) { std::map result; + // Create a list of composed automata to restrict the labels to locations of these automata. + std::vector> composedAutomata; + for (auto const& entry : variables.automatonToIdentityMap) { + composedAutomata.emplace_back(model.getAutomaton(entry.first)); + } + for (auto const& variable : model.getGlobalVariables().getTransientVariables()) { if (variable.isBooleanVariable()) { if (options.buildAllLabels || options.labelNames.find(variable.getName()) != options.labelNames.end()) { - result[variable.getName()] = model.getLabelExpression(variable.asBooleanVariable(), variables.automatonToLocationVariableMap); + result[variable.getName()] = model.getLabelExpression(variable.asBooleanVariable(), composedAutomata); } } } diff --git a/src/storm/builder/DdJaniModelBuilder.h b/src/storm/builder/DdJaniModelBuilder.h index e2c574bff..aca9f5650 100644 --- a/src/storm/builder/DdJaniModelBuilder.h +++ b/src/storm/builder/DdJaniModelBuilder.h @@ -102,7 +102,7 @@ namespace storm { // model. If this is set, the outgoing transitions of these states are replaced with a self-loop. boost::optional negatedTerminalStates; }; - + /*! * Translates the given program into a symbolic model (i.e. one that stores the transition relation as a * decision diagram). diff --git a/src/storm/builder/DdPrismModelBuilder.cp b/src/storm/builder/DdPrismModelBuilder.cp new file mode 100644 index 000000000..26308f45b --- /dev/null +++ b/src/storm/builder/DdPrismModelBuilder.cp @@ -0,0 +1,1429 @@ +#include "storm/builder/DdPrismModelBuilder.h" + +#include + +#include "storm/models/symbolic/Dtmc.h" +#include "storm/models/symbolic/Ctmc.h" +#include "storm/models/symbolic/Mdp.h" +#include "storm/models/symbolic/StandardRewardModel.h" + +#include "storm/settings/SettingsManager.h" + +#include "storm/exceptions/InvalidStateException.h" +#include "storm/exceptions/NotSupportedException.h" +#include "storm/exceptions/InvalidArgumentException.h" + +#include "storm/utility/prism.h" +#include "storm/utility/math.h" +#include "storm/utility/dd.h" + +#include "storm/storage/dd/DdManager.h" +#include "storm/storage/prism/Program.h" +#include "storm/storage/prism/Compositions.h" +#include "storm/storage/dd/Add.h" +#include "storm/storage/dd/cudd/CuddAddIterator.h" +#include "storm/storage/dd/Bdd.h" + +#include "storm/settings/modules/CoreSettings.h" + +namespace storm { + namespace builder { + + template + class DdPrismModelBuilder::GenerationInformation { + public: + GenerationInformation(storm::prism::Program const& program) : program(program), manager(std::make_shared>()), rowMetaVariables(), variableToRowMetaVariableMap(std::make_shared>()), rowExpressionAdapter(std::make_shared>(manager, variableToRowMetaVariableMap)), columnMetaVariables(), variableToColumnMetaVariableMap((std::make_shared>())), columnExpressionAdapter(std::make_shared>(manager, variableToColumnMetaVariableMap)), rowColumnMetaVariablePairs(), nondeterminismMetaVariables(), variableToIdentityMap(), allGlobalVariables(), moduleToIdentityMap() { + // Initializes variables and identity DDs. + createMetaVariablesAndIdentities(); + } + + // The program that is currently translated. + storm::prism::Program const& program; + + // The manager used to build the decision diagrams. + std::shared_ptr> manager; + + // The meta variables for the row encoding. + std::set rowMetaVariables; + std::shared_ptr> variableToRowMetaVariableMap; + std::shared_ptr> rowExpressionAdapter; + + // The meta variables for the column encoding. + std::set columnMetaVariables; + std::shared_ptr> variableToColumnMetaVariableMap; + std::shared_ptr> columnExpressionAdapter; + + // All pairs of row/column meta variables. + std::vector> rowColumnMetaVariablePairs; + + // The meta variables used to encode the nondeterminism. + std::vector nondeterminismMetaVariables; + + // The meta variables used to encode the synchronization. + std::vector synchronizationMetaVariables; + + // A set of all variables used for encoding the nondeterminism (i.e. nondetermism + synchronization + // variables). This is handy to abstract from this variable set. + std::set allNondeterminismVariables; + + // As set of all variables used for encoding the synchronization. + std::set allSynchronizationMetaVariables; + + // DDs representing the identity for each variable. + std::map> variableToIdentityMap; + + // A set of all meta variables that correspond to global variables. + std::set allGlobalVariables; + + // DDs representing the identity for each module. + std::map> moduleToIdentityMap; + + // DDs representing the valid ranges of the variables of each module. + std::map> moduleToRangeMap; + + private: + /*! + * Creates the required meta variables and variable/module identities. + */ + void createMetaVariablesAndIdentities() { + // Add synchronization variables. + for (auto const& actionIndex : program.getSynchronizingActionIndices()) { + std::pair variablePair = manager->addMetaVariable(program.getActionName(actionIndex)); + synchronizationMetaVariables.push_back(variablePair.first); + allSynchronizationMetaVariables.insert(variablePair.first); + allNondeterminismVariables.insert(variablePair.first); + } + + // Add nondeterminism variables (number of modules + number of commands). + uint_fast64_t numberOfNondeterminismVariables = program.getModules().size(); + for (auto const& module : program.getModules()) { + numberOfNondeterminismVariables += module.getNumberOfCommands(); + } + for (uint_fast64_t i = 0; i < numberOfNondeterminismVariables; ++i) { + std::pair variablePair = manager->addMetaVariable("nondet" + std::to_string(i)); + nondeterminismMetaVariables.push_back(variablePair.first); + allNondeterminismVariables.insert(variablePair.first); + } + + // Create meta variables for global program variables. + for (storm::prism::IntegerVariable const& integerVariable : program.getGlobalIntegerVariables()) { + int_fast64_t low = integerVariable.getLowerBoundExpression().evaluateAsInt(); + int_fast64_t high = integerVariable.getUpperBoundExpression().evaluateAsInt(); + std::pair variablePair = manager->addMetaVariable(integerVariable.getName(), low, high); + + STORM_LOG_TRACE("Created meta variables for global integer variable: " << variablePair.first.getName() << "[" << variablePair.first.getIndex() << "] and " << variablePair.second.getName() << "[" << variablePair.second.getIndex() << "]"); + + rowMetaVariables.insert(variablePair.first); + variableToRowMetaVariableMap->emplace(integerVariable.getExpressionVariable(), variablePair.first); + + columnMetaVariables.insert(variablePair.second); + variableToColumnMetaVariableMap->emplace(integerVariable.getExpressionVariable(), variablePair.second); + + storm::dd::Add variableIdentity = manager->template getIdentity(variablePair.first).equals(manager->template getIdentity(variablePair.second)).template toAdd() * manager->getRange(variablePair.first).template toAdd() * manager->getRange(variablePair.second).template toAdd(); + variableToIdentityMap.emplace(integerVariable.getExpressionVariable(), variableIdentity); + rowColumnMetaVariablePairs.push_back(variablePair); + + allGlobalVariables.insert(integerVariable.getExpressionVariable()); + } + for (storm::prism::BooleanVariable const& booleanVariable : program.getGlobalBooleanVariables()) { + std::pair variablePair = manager->addMetaVariable(booleanVariable.getName()); + + STORM_LOG_TRACE("Created meta variables for global boolean variable: " << variablePair.first.getName() << "[" << variablePair.first.getIndex() << "] and " << variablePair.second.getName() << "[" << variablePair.second.getIndex() << "]"); + + rowMetaVariables.insert(variablePair.first); + variableToRowMetaVariableMap->emplace(booleanVariable.getExpressionVariable(), variablePair.first); + + columnMetaVariables.insert(variablePair.second); + variableToColumnMetaVariableMap->emplace(booleanVariable.getExpressionVariable(), variablePair.second); + + storm::dd::Add variableIdentity = manager->template getIdentity(variablePair.first).equals(manager->template getIdentity(variablePair.second)).template toAdd(); + variableToIdentityMap.emplace(booleanVariable.getExpressionVariable(), variableIdentity); + + rowColumnMetaVariablePairs.push_back(variablePair); + allGlobalVariables.insert(booleanVariable.getExpressionVariable()); + } + + // Create meta variables for each of the modules' variables. + for (storm::prism::Module const& module : program.getModules()) { + storm::dd::Bdd moduleIdentity = manager->getBddOne(); + storm::dd::Bdd moduleRange = manager->getBddOne(); + + for (storm::prism::IntegerVariable const& integerVariable : module.getIntegerVariables()) { + int_fast64_t low = integerVariable.getLowerBoundExpression().evaluateAsInt(); + int_fast64_t high = integerVariable.getUpperBoundExpression().evaluateAsInt(); + std::pair variablePair = manager->addMetaVariable(integerVariable.getName(), low, high); + STORM_LOG_TRACE("Created meta variables for integer variable: " << variablePair.first.getName() << "[" << variablePair.first.getIndex() << "] and " << variablePair.second.getName() << "[" << variablePair.second.getIndex() << "]"); + + rowMetaVariables.insert(variablePair.first); + variableToRowMetaVariableMap->emplace(integerVariable.getExpressionVariable(), variablePair.first); + + columnMetaVariables.insert(variablePair.second); + variableToColumnMetaVariableMap->emplace(integerVariable.getExpressionVariable(), variablePair.second); + + storm::dd::Bdd variableIdentity = manager->template getIdentity(variablePair.first).equals(manager->template getIdentity(variablePair.second)) && manager->getRange(variablePair.first) && manager->getRange(variablePair.second); + variableToIdentityMap.emplace(integerVariable.getExpressionVariable(), variableIdentity.template toAdd()); + moduleIdentity &= variableIdentity; + moduleRange &= manager->getRange(variablePair.first); + + rowColumnMetaVariablePairs.push_back(variablePair); + } + for (storm::prism::BooleanVariable const& booleanVariable : module.getBooleanVariables()) { + std::pair variablePair = manager->addMetaVariable(booleanVariable.getName()); + STORM_LOG_TRACE("Created meta variables for boolean variable: " << variablePair.first.getName() << "[" << variablePair.first.getIndex() << "] and " << variablePair.second.getName() << "[" << variablePair.second.getIndex() << "]"); + + rowMetaVariables.insert(variablePair.first); + variableToRowMetaVariableMap->emplace(booleanVariable.getExpressionVariable(), variablePair.first); + + columnMetaVariables.insert(variablePair.second); + variableToColumnMetaVariableMap->emplace(booleanVariable.getExpressionVariable(), variablePair.second); + + storm::dd::Bdd variableIdentity = manager->template getIdentity(variablePair.first).equals(manager->template getIdentity(variablePair.second)) && manager->getRange(variablePair.first) && manager->getRange(variablePair.second); + variableToIdentityMap.emplace(booleanVariable.getExpressionVariable(), variableIdentity.template toAdd()); + moduleIdentity &= variableIdentity; + moduleRange &= manager->getRange(variablePair.first); + + rowColumnMetaVariablePairs.push_back(variablePair); + } + moduleToIdentityMap[module.getName()] = moduleIdentity.template toAdd(); + moduleToRangeMap[module.getName()] = moduleRange.template toAdd(); + } + } + }; + + template + class ModuleComposer : public storm::prism::CompositionVisitor { + public: + ModuleComposer(typename DdPrismModelBuilder::GenerationInformation& generationInfo) : generationInfo(generationInfo) { + // Intentionally left empty. + } + + typename DdPrismModelBuilder::ModuleDecisionDiagram compose(storm::prism::Composition const& composition) { + return boost::any_cast::ModuleDecisionDiagram>(composition.accept(*this, newSynchronizingActionToOffsetMap())); + } + + std::map newSynchronizingActionToOffsetMap() const { + std::map result; + for (auto const& actionIndex : generationInfo.program.getSynchronizingActionIndices()) { + result[actionIndex] = 0; + } + return result; + } + + std::map updateSynchronizingActionToOffsetMap(typename DdPrismModelBuilder::ModuleDecisionDiagram const& sub, std::map const& oldMapping) const { + std::map result = oldMapping; + for (auto const& action : sub.synchronizingActionToDecisionDiagramMap) { + result[action.first] = action.second.numberOfUsedNondeterminismVariables; + } + return result; + } + + virtual boost::any visit(storm::prism::ModuleComposition const& composition, boost::any const& data) override { + STORM_LOG_TRACE("Translating module '" << composition.getModuleName() << "'."); + std::map const& synchronizingActionToOffsetMap = boost::any_cast const&>(data); + + typename DdPrismModelBuilder::ModuleDecisionDiagram result = DdPrismModelBuilder::createModuleDecisionDiagram(generationInfo, generationInfo.program.getModule(composition.getModuleName()), synchronizingActionToOffsetMap); + + return result; + } + + virtual boost::any visit(storm::prism::RenamingComposition const& composition, boost::any const& data) override { + // Create the mapping from action indices to action indices. + std::map renaming; + for (auto const& namePair : composition.getActionRenaming()) { + STORM_LOG_THROW(generationInfo.program.hasAction(namePair.first), storm::exceptions::InvalidArgumentException, "Composition refers to unknown action '" << namePair.first << "'."); + STORM_LOG_THROW(generationInfo.program.hasAction(namePair.second), storm::exceptions::InvalidArgumentException, "Composition refers to unknown action '" << namePair.second << "'."); + renaming.emplace(generationInfo.program.getActionIndex(namePair.first), generationInfo.program.getActionIndex(namePair.second)); + } + + // Prepare the new offset mapping. + std::map const& synchronizingActionToOffsetMap = boost::any_cast const&>(data); + std::map newSynchronizingActionToOffsetMap = synchronizingActionToOffsetMap; + for (auto const& indexPair : renaming) { + auto it = synchronizingActionToOffsetMap.find(indexPair.second); + STORM_LOG_THROW(it != synchronizingActionToOffsetMap.end(), storm::exceptions::InvalidArgumentException, "Invalid action index " << indexPair.second << "."); + newSynchronizingActionToOffsetMap[indexPair.first] = it->second; + } + + // Then, we translate the subcomposition. + typename DdPrismModelBuilder::ModuleDecisionDiagram sub = boost::any_cast::ModuleDecisionDiagram>(composition.getSubcomposition().accept(*this, newSynchronizingActionToOffsetMap)); + + // Perform the renaming and return result. + return rename(sub, renaming); + } + + virtual boost::any visit(storm::prism::HidingComposition const& composition, boost::any const& data) override { + // Create the mapping from action indices to action indices. + std::set actionIndicesToHide; + for (auto const& action : composition.getActionsToHide()) { + STORM_LOG_THROW(generationInfo.program.hasAction(action), storm::exceptions::InvalidArgumentException, "Composition refers to unknown action '" << action << "'."); + actionIndicesToHide.insert(generationInfo.program.getActionIndex(action)); + } + + // Prepare the new offset mapping. + std::map const& synchronizingActionToOffsetMap = boost::any_cast const&>(data); + std::map newSynchronizingActionToOffsetMap = synchronizingActionToOffsetMap; + for (auto const& index : actionIndicesToHide) { + newSynchronizingActionToOffsetMap[index] = 0; + } + + // Then, we translate the subcomposition. + typename DdPrismModelBuilder::ModuleDecisionDiagram sub = boost::any_cast::ModuleDecisionDiagram>(composition.getSubcomposition().accept(*this, newSynchronizingActionToOffsetMap)); + + // Perform the hiding and return result. + hide(sub, actionIndicesToHide); + return sub; + } + + virtual boost::any visit(storm::prism::SynchronizingParallelComposition const& composition, boost::any const& data) override { + // First, we translate the subcompositions. + typename DdPrismModelBuilder::ModuleDecisionDiagram left = boost::any_cast::ModuleDecisionDiagram>(composition.getLeftSubcomposition().accept(*this, data)); + + // Prepare the new offset mapping. + std::map const& synchronizingActionToOffsetMap = boost::any_cast const&>(data); + std::map newSynchronizingActionToOffsetMap = synchronizingActionToOffsetMap; + for (auto const& action : left.synchronizingActionToDecisionDiagramMap) { + newSynchronizingActionToOffsetMap[action.first] = action.second.numberOfUsedNondeterminismVariables; + } + + typename DdPrismModelBuilder::ModuleDecisionDiagram right = boost::any_cast::ModuleDecisionDiagram>(composition.getRightSubcomposition().accept(*this, newSynchronizingActionToOffsetMap)); + + // Then, determine the action indices on which we need to synchronize. + std::set leftSynchronizationActionIndices = left.getSynchronizingActionIndices(); + std::set rightSynchronizationActionIndices = right.getSynchronizingActionIndices(); + std::set synchronizationActionIndices; + std::set_intersection(leftSynchronizationActionIndices.begin(), leftSynchronizationActionIndices.end(), rightSynchronizationActionIndices.begin(), rightSynchronizationActionIndices.end(), std::inserter(synchronizationActionIndices, synchronizationActionIndices.begin())); + + // Finally, we compose the subcompositions to create the result. + composeInParallel(left, right, synchronizationActionIndices); + return left; + } + + virtual boost::any visit(storm::prism::InterleavingParallelComposition const& composition, boost::any const& data) override { + // First, we translate the subcompositions. + typename DdPrismModelBuilder::ModuleDecisionDiagram left = boost::any_cast::ModuleDecisionDiagram>(composition.getLeftSubcomposition().accept(*this, data)); + + typename DdPrismModelBuilder::ModuleDecisionDiagram right = boost::any_cast::ModuleDecisionDiagram>(composition.getRightSubcomposition().accept(*this, data)); + + // Finally, we compose the subcompositions to create the result. + composeInParallel(left, right, std::set()); + return left; + } + + virtual boost::any visit(storm::prism::RestrictedParallelComposition const& composition, boost::any const& data) override { + // Construct the synchronizing action indices from the synchronizing action names. + std::set synchronizingActionIndices; + for (auto const& action : composition.getSynchronizingActions()) { + synchronizingActionIndices.insert(generationInfo.program.getActionIndex(action)); + } + + // Then, we translate the subcompositions. + typename DdPrismModelBuilder::ModuleDecisionDiagram left = boost::any_cast::ModuleDecisionDiagram>(composition.getLeftSubcomposition().accept(*this, data)); + + // Prepare the new offset mapping. + std::map const& synchronizingActionToOffsetMap = boost::any_cast const&>(data); + std::map newSynchronizingActionToOffsetMap = synchronizingActionToOffsetMap; + for (auto const& actionIndex : synchronizingActionIndices) { + auto it = left.synchronizingActionToDecisionDiagramMap.find(actionIndex); + if (it != left.synchronizingActionToDecisionDiagramMap.end()) { + newSynchronizingActionToOffsetMap[actionIndex] = it->second.numberOfUsedNondeterminismVariables; + } + } + + typename DdPrismModelBuilder::ModuleDecisionDiagram right = boost::any_cast::ModuleDecisionDiagram>(composition.getRightSubcomposition().accept(*this, newSynchronizingActionToOffsetMap)); + + std::set leftSynchronizationActionIndices = left.getSynchronizingActionIndices(); + bool isContainedInLeft = std::includes(leftSynchronizationActionIndices.begin(), leftSynchronizationActionIndices.end(), synchronizingActionIndices.begin(), synchronizingActionIndices.end()); + STORM_LOG_WARN_COND(isContainedInLeft, "Left subcomposition of composition '" << composition << "' does not include all actions over which to synchronize."); + + std::set rightSynchronizationActionIndices = right.getSynchronizingActionIndices(); + bool isContainedInRight = std::includes(rightSynchronizationActionIndices.begin(), rightSynchronizationActionIndices.end(), synchronizingActionIndices.begin(), synchronizingActionIndices.end()); + STORM_LOG_WARN_COND(isContainedInRight, "Right subcomposition of composition '" << composition << "' does not include all actions over which to synchronize."); + + // Finally, we compose the subcompositions to create the result. + composeInParallel(left, right, synchronizingActionIndices); + return left; + } + + private: + /*! + * Hides the actions of the given module according to the given set. As a result, the module is modified in + * place. + */ + void hide(typename DdPrismModelBuilder::ModuleDecisionDiagram& sub, std::set const& actionIndicesToHide) const { + STORM_LOG_TRACE("Hiding actions."); + + for (auto const& actionIndex : actionIndicesToHide) { + auto it = sub.synchronizingActionToDecisionDiagramMap.find(actionIndex); + if (it != sub.synchronizingActionToDecisionDiagramMap.end()) { + sub.independentAction = DdPrismModelBuilder::combineUnsynchronizedActions(generationInfo, sub.independentAction, it->second); + sub.numberOfUsedNondeterminismVariables = std::max(sub.numberOfUsedNondeterminismVariables, sub.independentAction.numberOfUsedNondeterminismVariables); + sub.synchronizingActionToDecisionDiagramMap.erase(it); + } + } + } + + /*! + * Renames the actions of the given module according to the given renaming. + */ + typename DdPrismModelBuilder::ModuleDecisionDiagram rename(typename DdPrismModelBuilder::ModuleDecisionDiagram& sub, std::map const& renaming) const { + STORM_LOG_TRACE("Renaming actions."); + std::map::ActionDecisionDiagram> actionIndexToDdMap; + + // Go through all action DDs with a synchronizing label and rename them if they appear in the renaming. + for (auto& action : sub.synchronizingActionToDecisionDiagramMap) { + auto renamingIt = renaming.find(action.first); + if (renamingIt != renaming.end()) { + // If the action is to be renamed and an action with the target index already exists, we need + // to combine the action DDs. + auto itNewActions = actionIndexToDdMap.find(renamingIt->second); + if (itNewActions != actionIndexToDdMap.end()) { + actionIndexToDdMap[renamingIt->second] = DdPrismModelBuilder::combineUnsynchronizedActions(generationInfo, action.second, itNewActions->second); + + } else { + // In this case, we can simply copy the action over. + actionIndexToDdMap[renamingIt->second] = action.second; + } + } else { + // If the action is not to be renamed, we need to copy it over. However, if some other action + // was renamed to the very same action name before, we need to combine the transitions. + auto itNewActions = actionIndexToDdMap.find(action.first); + if (itNewActions != actionIndexToDdMap.end()) { + actionIndexToDdMap[action.first] = DdPrismModelBuilder::combineUnsynchronizedActions(generationInfo, action.second, itNewActions->second); + } else { + // In this case, we can simply copy the action over. + actionIndexToDdMap[action.first] = action.second; + } + } + } + + return typename DdPrismModelBuilder::ModuleDecisionDiagram(sub.independentAction, actionIndexToDdMap, sub.identity, sub.numberOfUsedNondeterminismVariables); + } + + /*! + * Composes the given modules while synchronizing over the provided action indices. As a result, the first + * module is modified in place and will contain the composition after a call to this method. + */ + void composeInParallel(typename DdPrismModelBuilder::ModuleDecisionDiagram& left, typename DdPrismModelBuilder::ModuleDecisionDiagram& right, std::set const& synchronizationActionIndices) const { + STORM_LOG_TRACE("Composing two modules."); + + // Combine the tau action. + uint_fast64_t numberOfUsedNondeterminismVariables = right.independentAction.numberOfUsedNondeterminismVariables; + left.independentAction = DdPrismModelBuilder::combineUnsynchronizedActions(generationInfo, left.independentAction, right.independentAction, left.identity, right.identity); + numberOfUsedNondeterminismVariables = std::max(numberOfUsedNondeterminismVariables, left.independentAction.numberOfUsedNondeterminismVariables); + + // Create an empty action for the case where one of the modules does not have a certain action. + typename DdPrismModelBuilder::ActionDecisionDiagram emptyAction(*generationInfo.manager); + + // Treat all non-tau actions of the left module. + for (auto& action : left.synchronizingActionToDecisionDiagramMap) { + // If we need to synchronize over this action index, we try to do so now. + if (synchronizationActionIndices.find(action.first) != synchronizationActionIndices.end()) { + // If we are to synchronize over an action that does not exist in the second module, the result + // is that the synchronization is the empty action. + if (!right.hasSynchronizingAction(action.first)) { + action.second = emptyAction; + } else { + // Otherwise, the actions of the modules are synchronized. + action.second = DdPrismModelBuilder::combineSynchronizingActions(action.second, right.synchronizingActionToDecisionDiagramMap[action.first]); + } + } else { + // If we don't synchronize over this action, we need to construct the interleaving. + + // If both modules contain the action, we need to mutually multiply the other identity. + if (right.hasSynchronizingAction(action.first)) { + action.second = DdPrismModelBuilder::combineUnsynchronizedActions(generationInfo, action.second, right.synchronizingActionToDecisionDiagramMap[action.first], left.identity, right.identity); + } else { + // If only the first module has this action, we need to use a dummy action decision diagram + // for the second module. + action.second = DdPrismModelBuilder::combineUnsynchronizedActions(generationInfo, action.second, emptyAction, left.identity, right.identity); + } + } + numberOfUsedNondeterminismVariables = std::max(numberOfUsedNondeterminismVariables, action.second.numberOfUsedNondeterminismVariables); + } + + // Treat all non-tau actions of the right module. + for (auto const& actionIndex : right.getSynchronizingActionIndices()) { + // Here, we only need to treat actions that the first module does not have, because we have handled + // this case earlier. + if (!left.hasSynchronizingAction(actionIndex)) { + if (synchronizationActionIndices.find(actionIndex) != synchronizationActionIndices.end()) { + // If we are to synchronize over this action that does not exist in the first module, the + // result is that the synchronization is the empty action. + left.synchronizingActionToDecisionDiagramMap[actionIndex] = emptyAction; + } else { + // If only the second module has this action, we need to use a dummy action decision diagram + // for the first module. + left.synchronizingActionToDecisionDiagramMap[actionIndex] = DdPrismModelBuilder::combineUnsynchronizedActions(generationInfo, emptyAction, right.synchronizingActionToDecisionDiagramMap[actionIndex], left.identity, right.identity); + } + } + numberOfUsedNondeterminismVariables = std::max(numberOfUsedNondeterminismVariables, left.synchronizingActionToDecisionDiagramMap[actionIndex].numberOfUsedNondeterminismVariables); + } + + // Combine identity matrices. + left.identity = left.identity * right.identity; + + // Keep track of the number of nondeterminism variables used. + left.numberOfUsedNondeterminismVariables = std::max(left.numberOfUsedNondeterminismVariables, numberOfUsedNondeterminismVariables); + } + + typename DdPrismModelBuilder::GenerationInformation& generationInfo; + }; + + template + DdPrismModelBuilder::Options::Options() : buildAllRewardModels(false), rewardModelsToBuild(), buildAllLabels(false), labelsToBuild(), terminalStates(), negatedTerminalStates() { + // Intentionally left empty. + } + + template + DdPrismModelBuilder::Options::Options(storm::logic::Formula const& formula) : buildAllRewardModels(false), rewardModelsToBuild(), buildAllLabels(false), labelsToBuild(std::set()), terminalStates(), negatedTerminalStates() { + this->preserveFormula(formula); + this->setTerminalStatesFromFormula(formula); + } + + template + DdPrismModelBuilder::Options::Options(std::vector> const& formulas) : buildAllRewardModels(false), rewardModelsToBuild(), buildAllLabels(false), labelsToBuild(), terminalStates(), negatedTerminalStates() { + if (formulas.empty()) { + this->buildAllRewardModels = true; + this->buildAllLabels = true; + } else { + for (auto const& formula : formulas) { + this->preserveFormula(*formula); + } + if (formulas.size() == 1) { + this->setTerminalStatesFromFormula(*formulas.front()); + } + } + } + + template + void DdPrismModelBuilder::Options::preserveFormula(storm::logic::Formula const& formula) { + // If we already had terminal states, we need to erase them. + if (terminalStates) { + terminalStates.reset(); + } + if (negatedTerminalStates) { + negatedTerminalStates.reset(); + } + + // If we are not required to build all reward models, we determine the reward models we need to build. + if (!buildAllRewardModels) { + std::set referencedRewardModels = formula.getReferencedRewardModels(); + rewardModelsToBuild.insert(referencedRewardModels.begin(), referencedRewardModels.end()); + } + + // Extract all the labels used in the formula. + std::vector> atomicLabelFormulas = formula.getAtomicLabelFormulas(); + for (auto const& formula : atomicLabelFormulas) { + if (!labelsToBuild) { + labelsToBuild = std::set(); + } + labelsToBuild.get().insert(formula.get()->getLabel()); + } + } + + template + void DdPrismModelBuilder::Options::setTerminalStatesFromFormula(storm::logic::Formula const& formula) { + if (formula.isAtomicExpressionFormula()) { + terminalStates = formula.asAtomicExpressionFormula().getExpression(); + } else if (formula.isAtomicLabelFormula()) { + terminalStates = formula.asAtomicLabelFormula().getLabel(); + } else if (formula.isEventuallyFormula()) { + storm::logic::Formula const& sub = formula.asEventuallyFormula().getSubformula(); + if (sub.isAtomicExpressionFormula() || sub.isAtomicLabelFormula()) { + this->setTerminalStatesFromFormula(sub); + } + } else if (formula.isUntilFormula()) { + storm::logic::Formula const& right = formula.asUntilFormula().getRightSubformula(); + if (right.isAtomicExpressionFormula() || right.isAtomicLabelFormula()) { + this->setTerminalStatesFromFormula(right); + } + storm::logic::Formula const& left = formula.asUntilFormula().getLeftSubformula(); + if (left.isAtomicExpressionFormula()) { + negatedTerminalStates = left.asAtomicExpressionFormula().getExpression(); + } else if (left.isAtomicLabelFormula()) { + negatedTerminalStates = left.asAtomicLabelFormula().getLabel(); + } + } else if (formula.isProbabilityOperatorFormula()) { + storm::logic::Formula const& sub = formula.asProbabilityOperatorFormula().getSubformula(); + if (sub.isEventuallyFormula() || sub.isUntilFormula()) { + this->setTerminalStatesFromFormula(sub); + } + } + } + + template + struct DdPrismModelBuilder::SystemResult { + SystemResult(storm::dd::Add const& allTransitionsDd, DdPrismModelBuilder::ModuleDecisionDiagram const& globalModule, storm::dd::Add const& stateActionDd) : allTransitionsDd(allTransitionsDd), globalModule(globalModule), stateActionDd(stateActionDd) { + // Intentionally left empty. + } + + storm::dd::Add allTransitionsDd; + typename DdPrismModelBuilder::ModuleDecisionDiagram globalModule; + storm::dd::Add stateActionDd; + }; + + template + typename DdPrismModelBuilder::UpdateDecisionDiagram DdPrismModelBuilder::createUpdateDecisionDiagram(GenerationInformation& generationInfo, storm::prism::Module const& module, storm::dd::Add const& guard, storm::prism::Update const& update) { + storm::dd::Add updateDd = generationInfo.manager->template getAddOne(); + + STORM_LOG_TRACE("Translating update " << update); + + // Iterate over all assignments (boolean and integer) and build the DD for it. + std::vector assignments = update.getAssignments(); + std::set assignedVariables; + for (auto const& assignment : assignments) { + // Record the variable as being written. + STORM_LOG_TRACE("Assigning to variable " << generationInfo.variableToRowMetaVariableMap->at(assignment.getVariable()).getName()); + assignedVariables.insert(assignment.getVariable()); + + // Translate the written variable. + auto const& primedMetaVariable = generationInfo.variableToColumnMetaVariableMap->at(assignment.getVariable()); + storm::dd::Add writtenVariable = generationInfo.manager->template getIdentity(primedMetaVariable); + + // Translate the expression that is being assigned. + storm::dd::Add updateExpression = generationInfo.rowExpressionAdapter->translateExpression(assignment.getExpression()); + + // Combine the update expression with the guard. + storm::dd::Add result = updateExpression * guard; + + // Combine the variable and the assigned expression. + storm::dd::Add tmp = result; + result = result.equals(writtenVariable).template toAdd(); + result *= guard; + + // Restrict the transitions to the range of the written variable. + result = result * generationInfo.manager->getRange(primedMetaVariable).template toAdd(); + + updateDd *= result; + } + + // Compute the set of assigned global variables. + std::set assignedGlobalVariables; + std::set_intersection(assignedVariables.begin(), assignedVariables.end(), generationInfo.allGlobalVariables.begin(), generationInfo.allGlobalVariables.end(), std::inserter(assignedGlobalVariables, assignedGlobalVariables.begin())); + + // All unassigned boolean variables need to keep their value. + for (storm::prism::BooleanVariable const& booleanVariable : module.getBooleanVariables()) { + if (assignedVariables.find(booleanVariable.getExpressionVariable()) == assignedVariables.end()) { + STORM_LOG_TRACE("Multiplying identity of variable " << booleanVariable.getName()); + updateDd *= generationInfo.variableToIdentityMap.at(booleanVariable.getExpressionVariable()); + } + } + + // All unassigned integer variables need to keep their value. + for (storm::prism::IntegerVariable const& integerVariable : module.getIntegerVariables()) { + if (assignedVariables.find(integerVariable.getExpressionVariable()) == assignedVariables.end()) { + STORM_LOG_TRACE("Multiplying identity of variable " << integerVariable.getName()); + updateDd *= generationInfo.variableToIdentityMap.at(integerVariable.getExpressionVariable()); + } + } + + return UpdateDecisionDiagram(updateDd, assignedGlobalVariables); + } + + template + typename DdPrismModelBuilder::ActionDecisionDiagram DdPrismModelBuilder::createCommandDecisionDiagram(GenerationInformation& generationInfo, storm::prism::Module const& module, storm::prism::Command const& command) { + STORM_LOG_TRACE("Translating guard " << command.getGuardExpression()); + storm::dd::Add guard = generationInfo.rowExpressionAdapter->translateExpression(command.getGuardExpression()) * generationInfo.moduleToRangeMap[module.getName()]; + STORM_LOG_WARN_COND(!guard.isZero(), "The guard '" << command.getGuardExpression() << "' is unsatisfiable."); + + if (!guard.isZero()) { + // Create the DDs representing the individual updates. + std::vector updateResults; + for (storm::prism::Update const& update : command.getUpdates()) { + updateResults.push_back(createUpdateDecisionDiagram(generationInfo, module, guard, update)); + + STORM_LOG_WARN_COND(!updateResults.back().updateDd.isZero(), "Update '" << update << "' does not have any effect."); + } + + // Start by gathering all variables that were written in at least one update. + std::set globalVariablesInSomeUpdate; + + // If the command is labeled, we have to analyze which portion of the global variables was written by + // any of the updates and make all update results equal w.r.t. this set. If the command is not labeled, + // we can already multiply the identities of all global variables. + if (command.isLabeled()) { + std::for_each(updateResults.begin(), updateResults.end(), [&globalVariablesInSomeUpdate] (UpdateDecisionDiagram const& update) { globalVariablesInSomeUpdate.insert(update.assignedGlobalVariables.begin(), update.assignedGlobalVariables.end()); } ); + } else { + globalVariablesInSomeUpdate = generationInfo.allGlobalVariables; + } + + // Then, multiply the missing identities. + for (auto& updateResult : updateResults) { + std::set missingIdentities; + std::set_difference(globalVariablesInSomeUpdate.begin(), globalVariablesInSomeUpdate.end(), updateResult.assignedGlobalVariables.begin(), updateResult.assignedGlobalVariables.end(), std::inserter(missingIdentities, missingIdentities.begin())); + + for (auto const& variable : missingIdentities) { + STORM_LOG_TRACE("Multiplying identity for variable " << variable.getName() << "[" << variable.getIndex() << "] to update."); + updateResult.updateDd *= generationInfo.variableToIdentityMap.at(variable); + } + } + + // Now combine the update DDs to the command DD. + storm::dd::Add commandDd = generationInfo.manager->template getAddZero(); + auto updateResultsIt = updateResults.begin(); + for (auto updateIt = command.getUpdates().begin(), updateIte = command.getUpdates().end(); updateIt != updateIte; ++updateIt, ++updateResultsIt) { + storm::dd::Add probabilityDd = generationInfo.rowExpressionAdapter->translateExpression(updateIt->getLikelihoodExpression()); + commandDd += updateResultsIt->updateDd * probabilityDd; + } + + return ActionDecisionDiagram(guard, guard * commandDd, globalVariablesInSomeUpdate); + } else { + return ActionDecisionDiagram(*generationInfo.manager); + } + } + + template + typename DdPrismModelBuilder::ActionDecisionDiagram DdPrismModelBuilder::createActionDecisionDiagram(GenerationInformation& generationInfo, storm::prism::Module const& module, uint_fast64_t synchronizationActionIndex, uint_fast64_t nondeterminismVariableOffset) { + std::vector commandDds; + for (storm::prism::Command const& command : module.getCommands()) { + + // Determine whether the command is relevant for the selected action. + bool relevant = (synchronizationActionIndex == 0 && !command.isLabeled()) || (synchronizationActionIndex && command.isLabeled() && command.getActionIndex() == synchronizationActionIndex); + + if (!relevant) { + continue; + } + + STORM_LOG_TRACE("Translating command " << command); + + // At this point, the command is known to be relevant for the action. + commandDds.push_back(createCommandDecisionDiagram(generationInfo, module, command)); + } + + ActionDecisionDiagram result(*generationInfo.manager); + if (!commandDds.empty()) { + switch (generationInfo.program.getModelType()){ + case storm::prism::Program::ModelType::DTMC: + case storm::prism::Program::ModelType::CTMC: + result = combineCommandsToActionMarkovChain(generationInfo, commandDds); + break; + case storm::prism::Program::ModelType::MDP: + result = combineCommandsToActionMDP(generationInfo, commandDds, nondeterminismVariableOffset); + break; + default: + STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "Cannot translate model of this type."); + } + } + + return result; + } + + template + std::set DdPrismModelBuilder::equalizeAssignedGlobalVariables(GenerationInformation const& generationInfo, ActionDecisionDiagram& action1, ActionDecisionDiagram& action2) { + // Start by gathering all variables that were written in at least one action DD. + std::set globalVariablesInActionDd; + std::set_union(action1.assignedGlobalVariables.begin(), action1.assignedGlobalVariables.end(), action2.assignedGlobalVariables.begin(), action2.assignedGlobalVariables.end(), std::inserter(globalVariablesInActionDd, globalVariablesInActionDd.begin())); + + std::set missingIdentitiesInAction1; + std::set_difference(globalVariablesInActionDd.begin(), globalVariablesInActionDd.end(), action1.assignedGlobalVariables.begin(), action1.assignedGlobalVariables.end(), std::inserter(missingIdentitiesInAction1, missingIdentitiesInAction1.begin())); + for (auto const& variable : missingIdentitiesInAction1) { + action1.transitionsDd *= generationInfo.variableToIdentityMap.at(variable); + } + + std::set missingIdentitiesInAction2; + std::set_difference(globalVariablesInActionDd.begin(), globalVariablesInActionDd.end(), action1.assignedGlobalVariables.begin(), action1.assignedGlobalVariables.end(), std::inserter(missingIdentitiesInAction2, missingIdentitiesInAction2.begin())); + for (auto const& variable : missingIdentitiesInAction2) { + action2.transitionsDd *= generationInfo.variableToIdentityMap.at(variable); + } + + return globalVariablesInActionDd; + } + + template + std::set DdPrismModelBuilder::equalizeAssignedGlobalVariables(GenerationInformation const& generationInfo, std::vector& actionDds) { + // Start by gathering all variables that were written in at least one action DD. + std::set globalVariablesInActionDd; + for (auto const& commandDd : actionDds) { + globalVariablesInActionDd.insert(commandDd.assignedGlobalVariables.begin(), commandDd.assignedGlobalVariables.end()); + } + + STORM_LOG_TRACE("Equalizing assigned global variables."); + + // Then multiply the transitions of each action with the missing identities. + for (auto& actionDd : actionDds) { + STORM_LOG_TRACE("Equalizing next action."); + std::set missingIdentities; + std::set_difference(globalVariablesInActionDd.begin(), globalVariablesInActionDd.end(), actionDd.assignedGlobalVariables.begin(), actionDd.assignedGlobalVariables.end(), std::inserter(missingIdentities, missingIdentities.begin())); + for (auto const& variable : missingIdentities) { + STORM_LOG_TRACE("Multiplying identity of variable " << variable.getName() << "."); + actionDd.transitionsDd *= generationInfo.variableToIdentityMap.at(variable); + } + } + return globalVariablesInActionDd; + } + + template + typename DdPrismModelBuilder::ActionDecisionDiagram DdPrismModelBuilder::combineCommandsToActionMarkovChain(GenerationInformation& generationInfo, std::vector& commandDds) { + storm::dd::Add allGuards = generationInfo.manager->template getAddZero(); + storm::dd::Add allCommands = generationInfo.manager->template getAddZero(); + storm::dd::Add temporary; + + // Make all command DDs assign to the same global variables. + std::set assignedGlobalVariables = equalizeAssignedGlobalVariables(generationInfo, commandDds); + + // Then combine the commands to the full action DD and multiply missing identities along the way. + for (auto& commandDd : commandDds) { + // Check for overlapping guards. + temporary = commandDd.guardDd * allGuards; + + // Issue a warning if there are overlapping guards in a non-CTMC model. + STORM_LOG_WARN_COND(temporary.isZero() || generationInfo.program.getModelType() == storm::prism::Program::ModelType::CTMC, "Guard of a command overlaps with previous guards."); + + allGuards += commandDd.guardDd; + allCommands += commandDd.transitionsDd; + } + + return ActionDecisionDiagram(allGuards, allCommands, assignedGlobalVariables); + } + + template + storm::dd::Add DdPrismModelBuilder::encodeChoice(GenerationInformation& generationInfo, uint_fast64_t nondeterminismVariableOffset, uint_fast64_t numberOfBinaryVariables, int_fast64_t value) { + storm::dd::Add result = generationInfo.manager->template getAddZero(); + + STORM_LOG_TRACE("Encoding " << value << " with " << numberOfBinaryVariables << " binary variable(s) starting from offset " << nondeterminismVariableOffset << "."); + + std::map metaVariableNameToValueMap; + for (uint_fast64_t i = nondeterminismVariableOffset; i < nondeterminismVariableOffset + numberOfBinaryVariables; ++i) { + if (value & (1ull << (numberOfBinaryVariables - i - 1))) { + metaVariableNameToValueMap.emplace(generationInfo.nondeterminismMetaVariables[i], 1); + } else { + metaVariableNameToValueMap.emplace(generationInfo.nondeterminismMetaVariables[i], 0); + } + } + + result.setValue(metaVariableNameToValueMap, ValueType(1)); + return result; + } + + template + typename DdPrismModelBuilder::ActionDecisionDiagram DdPrismModelBuilder::combineCommandsToActionMDP(GenerationInformation& generationInfo, std::vector& commandDds, uint_fast64_t nondeterminismVariableOffset) { + storm::dd::Bdd allGuards = generationInfo.manager->getBddZero(); + storm::dd::Add allCommands = generationInfo.manager->template getAddZero(); + + // Make all command DDs assign to the same global variables. + std::set assignedGlobalVariables = equalizeAssignedGlobalVariables(generationInfo, commandDds); + + // Sum all guards, so we can read off the maximal number of nondeterministic choices in any given state. + storm::dd::Add sumOfGuards = generationInfo.manager->template getAddZero(); + for (auto const& commandDd : commandDds) { + sumOfGuards += commandDd.guardDd; + allGuards |= commandDd.guardDd.toBdd(); + } + uint_fast64_t maxChoices = static_cast(sumOfGuards.getMax()); + + STORM_LOG_TRACE("Found " << maxChoices << " local choices."); + + // Depending on the maximal number of nondeterminstic choices, we need to use some variables to encode the nondeterminism. + if (maxChoices == 0) { + return ActionDecisionDiagram(*generationInfo.manager); + } else if (maxChoices == 1) { + // Sum up all commands. + for (auto const& commandDd : commandDds) { + allCommands += commandDd.transitionsDd; + } + return ActionDecisionDiagram(sumOfGuards, allCommands, assignedGlobalVariables); + } else { + // Calculate number of required variables to encode the nondeterminism. + uint_fast64_t numberOfBinaryVariables = static_cast(std::ceil(storm::utility::math::log2(maxChoices))); + + storm::dd::Bdd equalsNumberOfChoicesDd; + std::vector> choiceDds(maxChoices, generationInfo.manager->template getAddZero()); + std::vector> remainingDds(maxChoices, generationInfo.manager->getBddZero()); + + for (uint_fast64_t currentChoices = 1; currentChoices <= maxChoices; ++currentChoices) { + // Determine the set of states with exactly currentChoices choices. + equalsNumberOfChoicesDd = sumOfGuards.equals(generationInfo.manager->getConstant(ValueType(currentChoices))); + + // If there is no such state, continue with the next possible number of choices. + if (equalsNumberOfChoicesDd.isZero()) { + continue; + } + + // Reset the previously used intermediate storage. + for (uint_fast64_t j = 0; j < currentChoices; ++j) { + choiceDds[j] = generationInfo.manager->template getAddZero(); + remainingDds[j] = equalsNumberOfChoicesDd; + } + + for (std::size_t j = 0; j < commandDds.size(); ++j) { + // Check if command guard overlaps with equalsNumberOfChoicesDd. That is, there are states with exactly currentChoices + // choices such that one outgoing choice is given by the j-th command. + storm::dd::Bdd guardChoicesIntersection = commandDds[j].guardDd.toBdd() && equalsNumberOfChoicesDd; + + // If there is no such state, continue with the next command. + if (guardChoicesIntersection.isZero()) { + continue; + } + + // Split the nondeterministic choices. + for (uint_fast64_t k = 0; k < currentChoices; ++k) { + // Calculate the overlapping part of command guard and the remaining DD. + storm::dd::Bdd remainingGuardChoicesIntersection = guardChoicesIntersection && remainingDds[k]; + + // Check if we can add some overlapping parts to the current index. + if (!remainingGuardChoicesIntersection.isZero()) { + // Remove overlapping parts from the remaining DD. + remainingDds[k] = remainingDds[k] && !remainingGuardChoicesIntersection; + + // Combine the overlapping part of the guard with command updates and add it to the resulting DD. + choiceDds[k] += remainingGuardChoicesIntersection.template toAdd() * commandDds[j].transitionsDd; + } + + // Remove overlapping parts from the command guard DD + guardChoicesIntersection = guardChoicesIntersection && !remainingGuardChoicesIntersection; + + // If the guard DD has become equivalent to false, we can stop here. + if (guardChoicesIntersection.isZero()) { + break; + } + } + } + + // Add the meta variables that encode the nondeterminisim to the different choices. + for (uint_fast64_t j = 0; j < currentChoices; ++j) { + allCommands += encodeChoice(generationInfo, nondeterminismVariableOffset, numberOfBinaryVariables, j) * choiceDds[j]; + } + + // Delete currentChoices out of overlapping DD + sumOfGuards = sumOfGuards * (!equalsNumberOfChoicesDd).template toAdd(); + } + + return ActionDecisionDiagram(allGuards.template toAdd(), allCommands, assignedGlobalVariables, nondeterminismVariableOffset + numberOfBinaryVariables); + } + } + + template + typename DdPrismModelBuilder::ActionDecisionDiagram DdPrismModelBuilder::combineSynchronizingActions(ActionDecisionDiagram const& action1, ActionDecisionDiagram const& action2) { + std::set assignedGlobalVariables; + std::set_union(action1.assignedGlobalVariables.begin(), action1.assignedGlobalVariables.end(), action2.assignedGlobalVariables.begin(), action2.assignedGlobalVariables.end(), std::inserter(assignedGlobalVariables, assignedGlobalVariables.begin())); + return ActionDecisionDiagram(action1.guardDd * action2.guardDd, action1.transitionsDd * action2.transitionsDd, assignedGlobalVariables, std::max(action1.numberOfUsedNondeterminismVariables, action2.numberOfUsedNondeterminismVariables)); + } + + template + typename DdPrismModelBuilder::ActionDecisionDiagram DdPrismModelBuilder::combineUnsynchronizedActions(GenerationInformation const& generationInfo, ActionDecisionDiagram& action1, ActionDecisionDiagram& action2, storm::dd::Add const& identityDd1, storm::dd::Add const& identityDd2) { + + // First extend the action DDs by the other identities. + STORM_LOG_TRACE("Multiplying identities to combine unsynchronized actions."); + action1.transitionsDd = action1.transitionsDd * identityDd2; + action2.transitionsDd = action2.transitionsDd * identityDd1; + + // Then combine the extended action DDs. + return combineUnsynchronizedActions(generationInfo, action1, action2); + } + + template + typename DdPrismModelBuilder::ActionDecisionDiagram DdPrismModelBuilder::combineUnsynchronizedActions(GenerationInformation const& generationInfo, ActionDecisionDiagram& action1, ActionDecisionDiagram& action2) { + STORM_LOG_TRACE("Combining unsynchronized actions."); + + // Make both action DDs write to the same global variables. + std::set assignedGlobalVariables = equalizeAssignedGlobalVariables(generationInfo, action1, action2); + + if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::DTMC || generationInfo.program.getModelType() == storm::prism::Program::ModelType::CTMC) { + return ActionDecisionDiagram(action1.guardDd + action2.guardDd, action1.transitionsDd + action2.transitionsDd, assignedGlobalVariables, 0); + } else if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::MDP) { + if (action1.transitionsDd.isZero()) { + return ActionDecisionDiagram(action2.guardDd, action2.transitionsDd, assignedGlobalVariables, action2.numberOfUsedNondeterminismVariables); + } else if (action2.transitionsDd.isZero()) { + return ActionDecisionDiagram(action1.guardDd, action1.transitionsDd, assignedGlobalVariables, action1.numberOfUsedNondeterminismVariables); + } + + // Bring both choices to the same number of variables that encode the nondeterminism. + uint_fast64_t numberOfUsedNondeterminismVariables = std::max(action1.numberOfUsedNondeterminismVariables, action2.numberOfUsedNondeterminismVariables); + if (action1.numberOfUsedNondeterminismVariables > action2.numberOfUsedNondeterminismVariables) { + storm::dd::Add nondeterminismEncoding = generationInfo.manager->template getAddOne(); + + for (uint_fast64_t i = action2.numberOfUsedNondeterminismVariables; i < action1.numberOfUsedNondeterminismVariables; ++i) { + nondeterminismEncoding *= generationInfo.manager->getEncoding(generationInfo.nondeterminismMetaVariables[i], 0).template toAdd(); + } + action2.transitionsDd *= nondeterminismEncoding; + } else if (action2.numberOfUsedNondeterminismVariables > action1.numberOfUsedNondeterminismVariables) { + storm::dd::Add nondeterminismEncoding = generationInfo.manager->template getAddOne(); + + for (uint_fast64_t i = action1.numberOfUsedNondeterminismVariables; i < action2.numberOfUsedNondeterminismVariables; ++i) { + nondeterminismEncoding *= generationInfo.manager->getEncoding(generationInfo.nondeterminismMetaVariables[i], 0).template toAdd(); + } + action1.transitionsDd *= nondeterminismEncoding; + } + + // Add a new variable that resolves the nondeterminism between the two choices. + storm::dd::Add combinedTransitions = generationInfo.manager->getEncoding(generationInfo.nondeterminismMetaVariables[numberOfUsedNondeterminismVariables], 1).ite(action2.transitionsDd, action1.transitionsDd); + + return ActionDecisionDiagram((action1.guardDd.toBdd() || action2.guardDd.toBdd()).template toAdd(), combinedTransitions, assignedGlobalVariables, numberOfUsedNondeterminismVariables + 1); + } else { + STORM_LOG_THROW(false, storm::exceptions::InvalidStateException, "Illegal model type."); + } + } + + template + typename DdPrismModelBuilder::ModuleDecisionDiagram DdPrismModelBuilder::createModuleDecisionDiagram(GenerationInformation& generationInfo, storm::prism::Module const& module, std::map const& synchronizingActionToOffsetMap) { + // Start by creating the action DD for the independent action. + ActionDecisionDiagram independentActionDd = createActionDecisionDiagram(generationInfo, module, 0, 0); + uint_fast64_t numberOfUsedNondeterminismVariables = independentActionDd.numberOfUsedNondeterminismVariables; + + // Create module DD for all synchronizing actions of the module. + std::map actionIndexToDdMap; + for (auto const& actionIndex : module.getSynchronizingActionIndices()) { + STORM_LOG_TRACE("Creating DD for action '" << actionIndex << "'."); + ActionDecisionDiagram tmp = createActionDecisionDiagram(generationInfo, module, actionIndex, synchronizingActionToOffsetMap.at(actionIndex)); + numberOfUsedNondeterminismVariables = std::max(numberOfUsedNondeterminismVariables, tmp.numberOfUsedNondeterminismVariables); + actionIndexToDdMap.emplace(actionIndex, tmp); + } + + return ModuleDecisionDiagram(independentActionDd, actionIndexToDdMap, generationInfo.moduleToIdentityMap.at(module.getName()), numberOfUsedNondeterminismVariables); + } + + template + storm::dd::Add DdPrismModelBuilder::getSynchronizationDecisionDiagram(GenerationInformation& generationInfo, uint_fast64_t actionIndex) { + storm::dd::Add synchronization = generationInfo.manager->template getAddOne(); + if (actionIndex != 0) { + for (uint_fast64_t i = 0; i < generationInfo.synchronizationMetaVariables.size(); ++i) { + if ((actionIndex - 1) == i) { + synchronization *= generationInfo.manager->getEncoding(generationInfo.synchronizationMetaVariables[i], 1).template toAdd(); + } else { + synchronization *= generationInfo.manager->getEncoding(generationInfo.synchronizationMetaVariables[i], 0).template toAdd(); + } + } + } else { + for (uint_fast64_t i = 0; i < generationInfo.synchronizationMetaVariables.size(); ++i) { + synchronization *= generationInfo.manager->getEncoding(generationInfo.synchronizationMetaVariables[i], 0).template toAdd(); + } + } + return synchronization; + } + + template + storm::dd::Add DdPrismModelBuilder::createSystemFromModule(GenerationInformation& generationInfo, ModuleDecisionDiagram const& module) { + // If the model is an MDP, we need to encode the nondeterminism using additional variables. + if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::MDP) { + storm::dd::Add result = generationInfo.manager->template getAddZero(); + + // First, determine the highest number of nondeterminism variables that is used in any action and make + // all actions use the same amout of nondeterminism variables. + uint_fast64_t numberOfUsedNondeterminismVariables = module.numberOfUsedNondeterminismVariables; + + // Compute missing global variable identities in independent action. + std::set missingIdentities; + std::set_difference(generationInfo.allGlobalVariables.begin(), generationInfo.allGlobalVariables.end(), module.independentAction.assignedGlobalVariables.begin(), module.independentAction.assignedGlobalVariables.end(), std::inserter(missingIdentities, missingIdentities.begin())); + storm::dd::Add identityEncoding = generationInfo.manager->template getAddOne(); + for (auto const& variable : missingIdentities) { + STORM_LOG_TRACE("Multiplying identity of global variable " << variable.getName() << " to independent action."); + identityEncoding *= generationInfo.variableToIdentityMap.at(variable); + } + + // Add variables to independent action DD. + storm::dd::Add nondeterminismEncoding = generationInfo.manager->template getAddOne(); + for (uint_fast64_t i = module.independentAction.numberOfUsedNondeterminismVariables; i < numberOfUsedNondeterminismVariables; ++i) { + nondeterminismEncoding *= generationInfo.manager->getEncoding(generationInfo.nondeterminismMetaVariables[i], 0).template toAdd(); + } + result = identityEncoding * module.independentAction.transitionsDd * nondeterminismEncoding; + + // Add variables to synchronized action DDs. + std::map> synchronizingActionToDdMap; + for (auto const& synchronizingAction : module.synchronizingActionToDecisionDiagramMap) { + // Compute missing global variable identities in synchronizing actions. + missingIdentities = std::set(); + std::set_difference(generationInfo.allGlobalVariables.begin(), generationInfo.allGlobalVariables.end(), synchronizingAction.second.assignedGlobalVariables.begin(), synchronizingAction.second.assignedGlobalVariables.end(), std::inserter(missingIdentities, missingIdentities.begin())); + identityEncoding = generationInfo.manager->template getAddOne(); + for (auto const& variable : missingIdentities) { + STORM_LOG_TRACE("Multiplying identity of global variable " << variable.getName() << " to synchronizing action '" << synchronizingAction.first << "'."); + identityEncoding *= generationInfo.variableToIdentityMap.at(variable); + } + + nondeterminismEncoding = generationInfo.manager->template getAddOne(); + for (uint_fast64_t i = synchronizingAction.second.numberOfUsedNondeterminismVariables; i < numberOfUsedNondeterminismVariables; ++i) { + nondeterminismEncoding *= generationInfo.manager->getEncoding(generationInfo.nondeterminismMetaVariables[i], 0).template toAdd(); + } + synchronizingActionToDdMap.emplace(synchronizingAction.first, identityEncoding * synchronizingAction.second.transitionsDd * nondeterminismEncoding); + } + + // Add variables for synchronization. + result *= getSynchronizationDecisionDiagram(generationInfo); + + for (auto& synchronizingAction : synchronizingActionToDdMap) { + synchronizingAction.second *= getSynchronizationDecisionDiagram(generationInfo, synchronizingAction.first); + } + + // Now, we can simply add all synchronizing actions to the result. + for (auto const& synchronizingAction : synchronizingActionToDdMap) { + result += synchronizingAction.second; + } + + return result; + } else if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::DTMC || generationInfo.program.getModelType() == storm::prism::Program::ModelType::CTMC) { + // Simply add all actions, but make sure to include the missing global variable identities. + + // Compute missing global variable identities in independent action. + std::set missingIdentities; + std::set_difference(generationInfo.allGlobalVariables.begin(), generationInfo.allGlobalVariables.end(), module.independentAction.assignedGlobalVariables.begin(), module.independentAction.assignedGlobalVariables.end(), std::inserter(missingIdentities, missingIdentities.begin())); + storm::dd::Add identityEncoding = generationInfo.manager->template getAddOne(); + for (auto const& variable : missingIdentities) { + STORM_LOG_TRACE("Multiplying identity of global variable " << variable.getName() << " to independent action."); + identityEncoding *= generationInfo.variableToIdentityMap.at(variable); + } + + storm::dd::Add result = identityEncoding * module.independentAction.transitionsDd; + + for (auto const& synchronizingAction : module.synchronizingActionToDecisionDiagramMap) { + // Compute missing global variable identities in synchronizing actions. + missingIdentities = std::set(); + std::set_difference(generationInfo.allGlobalVariables.begin(), generationInfo.allGlobalVariables.end(), synchronizingAction.second.assignedGlobalVariables.begin(), synchronizingAction.second.assignedGlobalVariables.end(), std::inserter(missingIdentities, missingIdentities.begin())); + identityEncoding = generationInfo.manager->template getAddOne(); + for (auto const& variable : missingIdentities) { + STORM_LOG_TRACE("Multiplying identity of global variable " << variable.getName() << " to synchronizing action '" << synchronizingAction.first << "'."); + identityEncoding *= generationInfo.variableToIdentityMap.at(variable); + } + + result += identityEncoding * synchronizingAction.second.transitionsDd; + } + return result; + } else { + STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "Illegal model type."); + } + } + + template + typename DdPrismModelBuilder::SystemResult DdPrismModelBuilder::createSystemDecisionDiagram(GenerationInformation& generationInfo) { + ModuleComposer composer(generationInfo); + ModuleDecisionDiagram system = composer.compose(generationInfo.program.specifiesSystemComposition() ? generationInfo.program.getSystemCompositionConstruct().getSystemComposition() : *generationInfo.program.getDefaultSystemComposition()); + + storm::dd::Add result = createSystemFromModule(generationInfo, system); + + // Create an auxiliary DD that is used later during the construction of reward models. + STORM_LOG_TRACE("Counting: " << result.getNonZeroCount() << " // " << result.getNodeCount()); + storm::dd::Add stateActionDd = result.sumAbstract(generationInfo.columnMetaVariables); + + // For DTMCs, we normalize each row to 1 (to account for non-determinism). + if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::DTMC) { + result = result / stateActionDd; + } else if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::MDP) { + // For MDPs, we need to throw away the nondeterminism variables from the generation information that + // were never used. + for (uint_fast64_t index = system.numberOfUsedNondeterminismVariables; index < generationInfo.nondeterminismMetaVariables.size(); ++index) { + generationInfo.allNondeterminismVariables.erase(generationInfo.nondeterminismMetaVariables[index]); + } + generationInfo.nondeterminismMetaVariables.resize(system.numberOfUsedNondeterminismVariables); + } + + return SystemResult(result, system, stateActionDd); + } + + template + storm::models::symbolic::StandardRewardModel DdPrismModelBuilder::createRewardModelDecisionDiagrams(GenerationInformation& generationInfo, storm::prism::RewardModel const& rewardModel, ModuleDecisionDiagram const& globalModule, storm::dd::Add const& reachableStatesAdd, storm::dd::Add const& stateActionDd) { + + // Start by creating the state reward vector. + boost::optional> stateRewards; + if (rewardModel.hasStateRewards()) { + stateRewards = generationInfo.manager->template getAddZero(); + + for (auto const& stateReward : rewardModel.getStateRewards()) { + storm::dd::Add states = generationInfo.rowExpressionAdapter->translateExpression(stateReward.getStatePredicateExpression()); + storm::dd::Add rewards = generationInfo.rowExpressionAdapter->translateExpression(stateReward.getRewardValueExpression()); + + // Restrict the rewards to those states that satisfy the condition. + rewards = reachableStatesAdd * states * rewards; + + // Perform some sanity checks. + STORM_LOG_WARN_COND(rewards.getMin() >= 0, "The reward model assigns negative rewards to some states."); + STORM_LOG_WARN_COND(!rewards.isZero(), "The reward model does not assign any non-zero rewards."); + + // Add the rewards to the global state reward vector. + stateRewards.get() += rewards; + } + } + + // Next, build the state-action reward vector. + boost::optional> stateActionRewards; + if (rewardModel.hasStateActionRewards()) { + stateActionRewards = generationInfo.manager->template getAddZero(); + + for (auto const& stateActionReward : rewardModel.getStateActionRewards()) { + storm::dd::Add states = generationInfo.rowExpressionAdapter->translateExpression(stateActionReward.getStatePredicateExpression()); + storm::dd::Add rewards = generationInfo.rowExpressionAdapter->translateExpression(stateActionReward.getRewardValueExpression()); + storm::dd::Add synchronization = generationInfo.manager->template getAddOne(); + + if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::MDP) { + synchronization = getSynchronizationDecisionDiagram(generationInfo, stateActionReward.getActionIndex()); + } + ActionDecisionDiagram const& actionDd = stateActionReward.isLabeled() ? globalModule.synchronizingActionToDecisionDiagramMap.at(stateActionReward.getActionIndex()) : globalModule.independentAction; + states *= actionDd.guardDd * reachableStatesAdd; + storm::dd::Add stateActionRewardDd = synchronization * states * rewards; + + // If we are building the state-action rewards for an MDP, we need to make sure that the encoding + // of the nondeterminism is present in the reward vector, so we ne need to multiply it with the + // legal state-actions. + if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::MDP) { + stateActionRewardDd *= stateActionDd; + } else if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::CTMC) { + // For CTMCs, we need to multiply the entries with the exit rate of the corresponding action. + stateActionRewardDd *= actionDd.transitionsDd.sumAbstract(generationInfo.columnMetaVariables); + } + + // Perform some sanity checks. + STORM_LOG_WARN_COND(stateActionRewardDd.getMin() >= 0, "The reward model assigns negative rewards to some states."); + STORM_LOG_WARN_COND(!stateActionRewardDd.isZero(), "The reward model does not assign any non-zero rewards."); + + // Add the rewards to the global transition reward matrix. + stateActionRewards.get() += stateActionRewardDd; + } + + // Scale state-action rewards for DTMCs and CTMCs. + if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::DTMC || generationInfo.program.getModelType() == storm::prism::Program::ModelType::CTMC) { + stateActionRewards.get() /= stateActionDd; + } + } + + // Then build the transition reward matrix. + boost::optional> transitionRewards; + if (rewardModel.hasTransitionRewards()) { + transitionRewards = generationInfo.manager->template getAddZero(); + + for (auto const& transitionReward : rewardModel.getTransitionRewards()) { + storm::dd::Add sourceStates = generationInfo.rowExpressionAdapter->translateExpression(transitionReward.getSourceStatePredicateExpression()); + storm::dd::Add targetStates = generationInfo.rowExpressionAdapter->translateExpression(transitionReward.getTargetStatePredicateExpression()); + storm::dd::Add rewards = generationInfo.rowExpressionAdapter->translateExpression(transitionReward.getRewardValueExpression()); + + storm::dd::Add synchronization = generationInfo.manager->template getAddOne(); + + storm::dd::Add transitions; + if (transitionReward.isLabeled()) { + if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::MDP) { + synchronization = getSynchronizationDecisionDiagram(generationInfo, transitionReward.getActionIndex()); + } + transitions = globalModule.synchronizingActionToDecisionDiagramMap.at(transitionReward.getActionIndex()).transitionsDd; + } else { + if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::MDP) { + synchronization = getSynchronizationDecisionDiagram(generationInfo); + } + transitions = globalModule.independentAction.transitionsDd; + } + + storm::dd::Add transitionRewardDd = synchronization * sourceStates * targetStates * rewards; + if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::DTMC) { + // For DTMCs we need to keep the weighting for the scaling that follows. + transitionRewardDd = transitions * transitionRewardDd; + } else { + // For all other model types, we do not scale the rewards. + transitionRewardDd = transitions.notZero().template toAdd() * transitionRewardDd; + } + + // Perform some sanity checks. + STORM_LOG_WARN_COND(transitionRewardDd.getMin() >= 0, "The reward model assigns negative rewards to some states."); + STORM_LOG_WARN_COND(!transitionRewardDd.isZero(), "The reward model does not assign any non-zero rewards."); + + // Add the rewards to the global transition reward matrix. + transitionRewards.get() += transitionRewardDd; + } + + // Scale transition rewards for DTMCs. + if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::DTMC) { + transitionRewards.get() /= stateActionDd; + } + } + + return storm::models::symbolic::StandardRewardModel(stateRewards, stateActionRewards, transitionRewards); + } + + template + std::shared_ptr> DdPrismModelBuilder::build(storm::prism::Program const& program, Options const& options) { + if (program.hasUndefinedConstants()) { + std::vector> undefinedConstants = program.getUndefinedConstants(); + std::stringstream stream; + bool printComma = false; + for (auto const& constant : undefinedConstants) { + if (printComma) { + stream << ", "; + } else { + printComma = true; + } + stream << constant.get().getName() << " (" << constant.get().getType() << ")"; + } + stream << "."; + STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "Program still contains these undefined constants: " + stream.str()); + } + + STORM_LOG_TRACE("Building representation of program:" << std::endl << program << std::endl); + + // Start by initializing the structure used for storing all information needed during the model generation. + // In particular, this creates the meta variables used to encode the model. + GenerationInformation generationInfo(program); + + SystemResult system = createSystemDecisionDiagram(generationInfo); + storm::dd::Add transitionMatrix = system.allTransitionsDd; + + ModuleDecisionDiagram const& globalModule = system.globalModule; + storm::dd::Add stateActionDd = system.stateActionDd; + + // If we were asked to treat some states as terminal states, we cut away their transitions now. + storm::dd::Bdd terminalStatesBdd = generationInfo.manager->getBddZero(); + if (options.terminalStates || options.negatedTerminalStates) { + std::map constantsSubstitution = program.getConstantsSubstitution(); + + if (options.terminalStates) { + storm::expressions::Expression terminalExpression; + if (options.terminalStates.get().type() == typeid(storm::expressions::Expression)) { + terminalExpression = boost::get(options.terminalStates.get()); + } else { + std::string const& labelName = boost::get(options.terminalStates.get()); + if (program.hasLabel(labelName)) { + terminalExpression = program.getLabelExpression(labelName); + } else { + STORM_LOG_THROW(labelName == "init" || labelName == "deadlock", storm::exceptions::InvalidArgumentException, "Terminal states refer to illegal label '" << labelName << "'."); + } + } + + if (terminalExpression.isInitialized()) { + // If the expression refers to constants of the model, we need to substitute them. + terminalExpression = terminalExpression.substitute(constantsSubstitution); + + STORM_LOG_TRACE("Making the states satisfying " << terminalExpression << " terminal."); + terminalStatesBdd = generationInfo.rowExpressionAdapter->translateExpression(terminalExpression).toBdd(); + } + } + if (options.negatedTerminalStates) { + storm::expressions::Expression negatedTerminalExpression; + if (options.negatedTerminalStates.get().type() == typeid(storm::expressions::Expression)) { + negatedTerminalExpression = boost::get(options.negatedTerminalStates.get()); + } else { + std::string const& labelName = boost::get(options.negatedTerminalStates.get()); + if (program.hasLabel(labelName)) { + negatedTerminalExpression = program.getLabelExpression(labelName); + } else { + STORM_LOG_THROW(labelName == "init" || labelName == "deadlock", storm::exceptions::InvalidArgumentException, "Terminal states refer to illegal label '" << labelName << "'."); + } + } + + if (negatedTerminalExpression.isInitialized()) { + // If the expression refers to constants of the model, we need to substitute them. + negatedTerminalExpression = negatedTerminalExpression.substitute(constantsSubstitution); + + STORM_LOG_TRACE("Making the states *not* satisfying " << negatedTerminalExpression << " terminal."); + terminalStatesBdd |= !generationInfo.rowExpressionAdapter->translateExpression(negatedTerminalExpression).toBdd(); + } + } + + transitionMatrix *= (!terminalStatesBdd).template toAdd(); + } + + std::cout << "trans matrix has size " << transitionMatrix.getNodeCount() << std::endl; + + // Cut the transitions and rewards to the reachable fragment of the state space. + storm::dd::Bdd initialStates = createInitialStatesDecisionDiagram(generationInfo); + + storm::dd::Bdd transitionMatrixBdd = transitionMatrix.notZero(); + if (program.getModelType() == storm::prism::Program::ModelType::MDP) { + transitionMatrixBdd = transitionMatrixBdd.existsAbstract(generationInfo.allNondeterminismVariables); + } + + storm::dd::Bdd reachableStates = storm::utility::dd::computeReachableStates(initialStates, transitionMatrixBdd, generationInfo.rowMetaVariables, generationInfo.columnMetaVariables); + storm::dd::Add reachableStatesAdd = reachableStates.template toAdd(); + transitionMatrix *= reachableStatesAdd; + stateActionDd *= reachableStatesAdd; + + // Detect deadlocks and 1) fix them if requested 2) throw an error otherwise. + storm::dd::Bdd statesWithTransition = transitionMatrixBdd.existsAbstract(generationInfo.columnMetaVariables); + storm::dd::Bdd deadlockStates = reachableStates && !statesWithTransition; + + // If there are deadlocks, either fix them or raise an error. + if (!deadlockStates.isZero()) { + // If we need to fix deadlocks, we do so now. + if (!storm::settings::getModule().isDontFixDeadlocksSet()) { + STORM_LOG_INFO("Fixing deadlocks in " << deadlockStates.getNonZeroCount() << " states. The first three of these states are: "); + + storm::dd::Add deadlockStatesAdd = deadlockStates.template toAdd(); + uint_fast64_t count = 0; + for (auto it = deadlockStatesAdd.begin(), ite = deadlockStatesAdd.end(); it != ite && count < 3; ++it, ++count) { + STORM_LOG_INFO((*it).first.toPrettyString(generationInfo.rowMetaVariables) << std::endl); + } + + if (program.getModelType() == storm::prism::Program::ModelType::DTMC || program.getModelType() == storm::prism::Program::ModelType::CTMC) { + storm::dd::Add identity = globalModule.identity; + + // Make sure that global variables do not change along the introduced self-loops. + for (auto const& var : generationInfo.allGlobalVariables) { + identity *= generationInfo.variableToIdentityMap.at(var); + } + + // For DTMCs, we can simply add the identity of the global module for all deadlock states. + transitionMatrix += deadlockStatesAdd * identity; + } else if (program.getModelType() == storm::prism::Program::ModelType::MDP) { + // For MDPs, however, we need to select an action associated with the self-loop, if we do not + // want to attach a lot of self-loops to the deadlock states. + storm::dd::Add action = generationInfo.manager->template getAddOne(); + for (auto const& metaVariable : generationInfo.allNondeterminismVariables) { + action *= generationInfo.manager->template getIdentity(metaVariable); + } + // Make sure that global variables do not change along the introduced self-loops. + for (auto const& var : generationInfo.allGlobalVariables) { + action *= generationInfo.variableToIdentityMap.at(var); + } + transitionMatrix += deadlockStatesAdd * globalModule.identity * action; + } + } else { + STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "The model contains " << deadlockStates.getNonZeroCount() << " deadlock states. Please unset the option to not fix deadlocks, if you want to fix them automatically."); + } + } + + // Reduce the deadlock states by the states that we did simply not explore. + deadlockStates = deadlockStates && !terminalStatesBdd; + + // Now build the reward models. + std::vector> selectedRewardModels; + + // First, we make sure that all selected reward models actually exist. + for (auto const& rewardModelName : options.rewardModelsToBuild) { + STORM_LOG_THROW(rewardModelName.empty() || program.hasRewardModel(rewardModelName), storm::exceptions::InvalidArgumentException, "Model does not possess a reward model with the name '" << rewardModelName << "'."); + } + + for (auto const& rewardModel : program.getRewardModels()) { + if (options.buildAllRewardModels || options.rewardModelsToBuild.find(rewardModel.getName()) != options.rewardModelsToBuild.end()) { + std::cout << "build all? " << buildAllRewardModels << std::endl; + selectedRewardModels.push_back(rewardModel); + } + } + // If no reward model was selected until now and a referenced reward model appears to be unique, we build + // the only existing reward model (given that no explicit name was given for the referenced reward model). + if (selectedRewardModels.empty() && program.getNumberOfRewardModels() == 1 && options.rewardModelsToBuild.size() == 1 && *options.rewardModelsToBuild.begin() == "") { + selectedRewardModels.push_back(program.getRewardModel(0)); + } + + std::unordered_map> rewardModels; + for (auto const& rewardModel : selectedRewardModels) { + rewardModels.emplace(rewardModel.get().getName(), createRewardModelDecisionDiagrams(generationInfo, rewardModel.get(), globalModule, reachableStatesAdd, stateActionDd)); + } + + // Build the labels that can be accessed as a shortcut. + std::map labelToExpressionMapping; + for (auto const& label : program.getLabels()) { + labelToExpressionMapping.emplace(label.getName(), label.getStatePredicateExpression()); + } + + if (program.getModelType() == storm::prism::Program::ModelType::DTMC) { + return std::shared_ptr>(new storm::models::symbolic::Dtmc(generationInfo.manager, reachableStates, initialStates, deadlockStates, transitionMatrix, generationInfo.rowMetaVariables, generationInfo.rowExpressionAdapter, generationInfo.columnMetaVariables, generationInfo.columnExpressionAdapter, generationInfo.rowColumnMetaVariablePairs, labelToExpressionMapping, rewardModels)); + } else if (program.getModelType() == storm::prism::Program::ModelType::CTMC) { + return std::shared_ptr>(new storm::models::symbolic::Ctmc(generationInfo.manager, reachableStates, initialStates, deadlockStates, transitionMatrix, generationInfo.rowMetaVariables, generationInfo.rowExpressionAdapter, generationInfo.columnMetaVariables, generationInfo.columnExpressionAdapter, generationInfo.rowColumnMetaVariablePairs, labelToExpressionMapping, rewardModels)); + } else if (program.getModelType() == storm::prism::Program::ModelType::MDP) { + return std::shared_ptr>(new storm::models::symbolic::Mdp(generationInfo.manager, reachableStates, initialStates, deadlockStates, transitionMatrix, generationInfo.rowMetaVariables, generationInfo.rowExpressionAdapter, generationInfo.columnMetaVariables, generationInfo.columnExpressionAdapter, generationInfo.rowColumnMetaVariablePairs, generationInfo.allNondeterminismVariables, labelToExpressionMapping, rewardModels)); + } else { + STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "Invalid model type."); + } + } + + template + storm::dd::Bdd DdPrismModelBuilder::createInitialStatesDecisionDiagram(GenerationInformation& generationInfo) { + storm::dd::Bdd initialStates = generationInfo.rowExpressionAdapter->translateExpression(generationInfo.program.getInitialStatesExpression()).toBdd(); + + for (auto const& metaVariable : generationInfo.rowMetaVariables) { + initialStates &= generationInfo.manager->getRange(metaVariable); + } + + return initialStates; + } + + // Explicitly instantiate the symbolic model builder. + template class DdPrismModelBuilder; + template class DdPrismModelBuilder; + + } // namespace adapters +} // namespace storm + + diff --git a/src/storm/builder/DdPrismModelBuilder.cpp b/src/storm/builder/DdPrismModelBuilder.cpp index 099c0fba5..e2afeeae6 100644 --- a/src/storm/builder/DdPrismModelBuilder.cpp +++ b/src/storm/builder/DdPrismModelBuilder.cpp @@ -424,7 +424,7 @@ namespace storm { action.second = emptyAction; } else { // Otherwise, the actions of the modules are synchronized. - action.second = DdPrismModelBuilder::combineSynchronizingActions(generationInfo, action.second, right.synchronizingActionToDecisionDiagramMap[action.first]); + action.second = DdPrismModelBuilder::combineSynchronizingActions(action.second, right.synchronizingActionToDecisionDiagramMap[action.first]); } } else { // If we don't synchronize over this action, we need to construct the interleaving. @@ -470,7 +470,7 @@ namespace storm { }; template - DdPrismModelBuilder::Options::Options() : buildAllRewardModels(true), rewardModelsToBuild(), buildAllLabels(true), labelsToBuild(), terminalStates(), negatedTerminalStates() { + DdPrismModelBuilder::Options::Options() : buildAllRewardModels(false), rewardModelsToBuild(), buildAllLabels(false), labelsToBuild(), terminalStates(), negatedTerminalStates() { // Intentionally left empty. } @@ -482,16 +482,11 @@ namespace storm { template DdPrismModelBuilder::Options::Options(std::vector> const& formulas) : buildAllRewardModels(false), rewardModelsToBuild(), buildAllLabels(false), labelsToBuild(), terminalStates(), negatedTerminalStates() { - if (formulas.empty()) { - this->buildAllRewardModels = true; - this->buildAllLabels = true; - } else { - for (auto const& formula : formulas) { - this->preserveFormula(*formula); - } - if (formulas.size() == 1) { - this->setTerminalStatesFromFormula(*formulas.front()); - } + for (auto const& formula : formulas) { + this->preserveFormula(*formula); + } + if (formulas.size() == 1) { + this->setTerminalStatesFromFormula(*formulas.front()); } } @@ -553,13 +548,13 @@ namespace storm { template struct DdPrismModelBuilder::SystemResult { - SystemResult(storm::dd::Add const& allTransitionsDd, DdPrismModelBuilder::ModuleDecisionDiagram const& globalModule, storm::dd::Add const& stateActionDd) : allTransitionsDd(allTransitionsDd), globalModule(globalModule), stateActionDd(stateActionDd) { + SystemResult(storm::dd::Add const& allTransitionsDd, DdPrismModelBuilder::ModuleDecisionDiagram const& globalModule, boost::optional> const& stateActionDd) : allTransitionsDd(allTransitionsDd), globalModule(globalModule), stateActionDd(stateActionDd) { // Intentionally left empty. } storm::dd::Add allTransitionsDd; typename DdPrismModelBuilder::ModuleDecisionDiagram globalModule; - storm::dd::Add stateActionDd; + boost::optional> stateActionDd; }; template @@ -623,14 +618,14 @@ namespace storm { template typename DdPrismModelBuilder::ActionDecisionDiagram DdPrismModelBuilder::createCommandDecisionDiagram(GenerationInformation& generationInfo, storm::prism::Module const& module, storm::prism::Command const& command) { STORM_LOG_TRACE("Translating guard " << command.getGuardExpression()); - storm::dd::Add guard = generationInfo.rowExpressionAdapter->translateExpression(command.getGuardExpression()) * generationInfo.moduleToRangeMap[module.getName()]; + storm::dd::Bdd guard = generationInfo.rowExpressionAdapter->translateBooleanExpression(command.getGuardExpression()) && generationInfo.moduleToRangeMap[module.getName()].notZero(); STORM_LOG_WARN_COND(!guard.isZero(), "The guard '" << command.getGuardExpression() << "' is unsatisfiable."); if (!guard.isZero()) { // Create the DDs representing the individual updates. std::vector updateResults; for (storm::prism::Update const& update : command.getUpdates()) { - updateResults.push_back(createUpdateDecisionDiagram(generationInfo, module, guard, update)); + updateResults.push_back(createUpdateDecisionDiagram(generationInfo, module, guard.template toAdd(), update)); STORM_LOG_WARN_COND(!updateResults.back().updateDd.isZero(), "Update '" << update << "' does not have any effect."); } @@ -666,7 +661,7 @@ namespace storm { commandDd += updateResultsIt->updateDd * probabilityDd; } - return ActionDecisionDiagram(guard, guard * commandDd, globalVariablesInSomeUpdate); + return ActionDecisionDiagram(guard, guard.template toAdd() * commandDd, globalVariablesInSomeUpdate); } else { return ActionDecisionDiagram(*generationInfo.manager); } @@ -754,9 +749,9 @@ namespace storm { template typename DdPrismModelBuilder::ActionDecisionDiagram DdPrismModelBuilder::combineCommandsToActionMarkovChain(GenerationInformation& generationInfo, std::vector& commandDds) { - storm::dd::Add allGuards = generationInfo.manager->template getAddZero(); + storm::dd::Bdd allGuards = generationInfo.manager->getBddZero(); storm::dd::Add allCommands = generationInfo.manager->template getAddZero(); - storm::dd::Add temporary; + storm::dd::Bdd temporary; // Make all command DDs assign to the same global variables. std::set assignedGlobalVariables = equalizeAssignedGlobalVariables(generationInfo, commandDds); @@ -764,12 +759,12 @@ namespace storm { // Then combine the commands to the full action DD and multiply missing identities along the way. for (auto& commandDd : commandDds) { // Check for overlapping guards. - temporary = commandDd.guardDd * allGuards; + temporary = commandDd.guardDd && allGuards; // Issue a warning if there are overlapping guards in a non-CTMC model. STORM_LOG_WARN_COND(temporary.isZero() || generationInfo.program.getModelType() == storm::prism::Program::ModelType::CTMC, "Guard of a command overlaps with previous guards."); - allGuards += commandDd.guardDd; + allGuards |= commandDd.guardDd; allCommands += commandDd.transitionsDd; } @@ -806,8 +801,8 @@ namespace storm { // Sum all guards, so we can read off the maximal number of nondeterministic choices in any given state. storm::dd::Add sumOfGuards = generationInfo.manager->template getAddZero(); for (auto const& commandDd : commandDds) { - sumOfGuards += commandDd.guardDd; - allGuards |= commandDd.guardDd.toBdd(); + sumOfGuards += commandDd.guardDd.template toAdd(); + allGuards |= commandDd.guardDd; } uint_fast64_t maxChoices = static_cast(sumOfGuards.getMax()); @@ -821,7 +816,7 @@ namespace storm { for (auto const& commandDd : commandDds) { allCommands += commandDd.transitionsDd; } - return ActionDecisionDiagram(sumOfGuards, allCommands, assignedGlobalVariables); + return ActionDecisionDiagram(allGuards, allCommands, assignedGlobalVariables); } else { // Calculate number of required variables to encode the nondeterminism. uint_fast64_t numberOfBinaryVariables = static_cast(std::ceil(storm::utility::math::log2(maxChoices))); @@ -848,7 +843,7 @@ namespace storm { for (std::size_t j = 0; j < commandDds.size(); ++j) { // Check if command guard overlaps with equalsNumberOfChoicesDd. That is, there are states with exactly currentChoices // choices such that one outgoing choice is given by the j-th command. - storm::dd::Bdd guardChoicesIntersection = commandDds[j].guardDd.toBdd() && equalsNumberOfChoicesDd; + storm::dd::Bdd guardChoicesIntersection = commandDds[j].guardDd && equalsNumberOfChoicesDd; // If there is no such state, continue with the next command. if (guardChoicesIntersection.isZero()) { @@ -888,15 +883,15 @@ namespace storm { sumOfGuards = sumOfGuards * (!equalsNumberOfChoicesDd).template toAdd(); } - return ActionDecisionDiagram(allGuards.template toAdd(), allCommands, assignedGlobalVariables, nondeterminismVariableOffset + numberOfBinaryVariables); + return ActionDecisionDiagram(allGuards, allCommands, assignedGlobalVariables, nondeterminismVariableOffset + numberOfBinaryVariables); } } template - typename DdPrismModelBuilder::ActionDecisionDiagram DdPrismModelBuilder::combineSynchronizingActions(GenerationInformation const& generationInfo, ActionDecisionDiagram const& action1, ActionDecisionDiagram const& action2) { + typename DdPrismModelBuilder::ActionDecisionDiagram DdPrismModelBuilder::combineSynchronizingActions(ActionDecisionDiagram const& action1, ActionDecisionDiagram const& action2) { std::set assignedGlobalVariables; std::set_union(action1.assignedGlobalVariables.begin(), action1.assignedGlobalVariables.end(), action2.assignedGlobalVariables.begin(), action2.assignedGlobalVariables.end(), std::inserter(assignedGlobalVariables, assignedGlobalVariables.begin())); - return ActionDecisionDiagram(action1.guardDd * action2.guardDd, action1.transitionsDd * action2.transitionsDd, assignedGlobalVariables, std::max(action1.numberOfUsedNondeterminismVariables, action2.numberOfUsedNondeterminismVariables)); + return ActionDecisionDiagram(action1.guardDd && action2.guardDd, action1.transitionsDd * action2.transitionsDd, assignedGlobalVariables, std::max(action1.numberOfUsedNondeterminismVariables, action2.numberOfUsedNondeterminismVariables)); } template @@ -919,7 +914,7 @@ namespace storm { std::set assignedGlobalVariables = equalizeAssignedGlobalVariables(generationInfo, action1, action2); if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::DTMC || generationInfo.program.getModelType() == storm::prism::Program::ModelType::CTMC) { - return ActionDecisionDiagram(action1.guardDd + action2.guardDd, action1.transitionsDd + action2.transitionsDd, assignedGlobalVariables, 0); + return ActionDecisionDiagram(action1.guardDd || action2.guardDd, action1.transitionsDd + action2.transitionsDd, assignedGlobalVariables, 0); } else if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::MDP) { if (action1.transitionsDd.isZero()) { return ActionDecisionDiagram(action2.guardDd, action2.transitionsDd, assignedGlobalVariables, action2.numberOfUsedNondeterminismVariables); @@ -948,7 +943,7 @@ namespace storm { // Add a new variable that resolves the nondeterminism between the two choices. storm::dd::Add combinedTransitions = generationInfo.manager->getEncoding(generationInfo.nondeterminismMetaVariables[numberOfUsedNondeterminismVariables], 1).ite(action2.transitionsDd, action1.transitionsDd); - return ActionDecisionDiagram((action1.guardDd.toBdd() || action2.guardDd.toBdd()).template toAdd(), combinedTransitions, assignedGlobalVariables, numberOfUsedNondeterminismVariables + 1); + return ActionDecisionDiagram(action1.guardDd || action2.guardDd, combinedTransitions, assignedGlobalVariables, numberOfUsedNondeterminismVariables + 1); } else { STORM_LOG_THROW(false, storm::exceptions::InvalidStateException, "Illegal model type."); } @@ -1087,13 +1082,14 @@ namespace storm { ModuleDecisionDiagram system = composer.compose(generationInfo.program.specifiesSystemComposition() ? generationInfo.program.getSystemCompositionConstruct().getSystemComposition() : *generationInfo.program.getDefaultSystemComposition()); storm::dd::Add result = createSystemFromModule(generationInfo, system); - + // Create an auxiliary DD that is used later during the construction of reward models. - storm::dd::Add stateActionDd = result.sumAbstract(generationInfo.columnMetaVariables); + boost::optional> stateActionDd; // For DTMCs, we normalize each row to 1 (to account for non-determinism). if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::DTMC) { - result = result / stateActionDd; + stateActionDd = result.sumAbstract(generationInfo.columnMetaVariables); + result = result / stateActionDd.get(); } else if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::MDP) { // For MDPs, we need to throw away the nondeterminism variables from the generation information that // were never used. @@ -1107,7 +1103,16 @@ namespace storm { } template - storm::models::symbolic::StandardRewardModel DdPrismModelBuilder::createRewardModelDecisionDiagrams(GenerationInformation& generationInfo, storm::prism::RewardModel const& rewardModel, ModuleDecisionDiagram const& globalModule, storm::dd::Add const& transitionMatrix, storm::dd::Add const& reachableStatesAdd, storm::dd::Add const& stateActionDd) { + std::unordered_map> DdPrismModelBuilder::createRewardModelDecisionDiagrams(std::vector> const& selectedRewardModels, SystemResult& system, GenerationInformation& generationInfo, ModuleDecisionDiagram const& globalModule, storm::dd::Add const& reachableStatesAdd, storm::dd::Add const& transitionMatrix) { + std::unordered_map> rewardModels; + for (auto const& rewardModel : selectedRewardModels) { + rewardModels.emplace(rewardModel.get().getName(), createRewardModelDecisionDiagrams(generationInfo, rewardModel.get(), globalModule, reachableStatesAdd, transitionMatrix, system.stateActionDd)); + } + return rewardModels; + } + + template + storm::models::symbolic::StandardRewardModel DdPrismModelBuilder::createRewardModelDecisionDiagrams(GenerationInformation& generationInfo, storm::prism::RewardModel const& rewardModel, ModuleDecisionDiagram const& globalModule, storm::dd::Add const& reachableStatesAdd, storm::dd::Add const& transitionMatrix, boost::optional>& stateActionDd) { // Start by creating the state reward vector. boost::optional> stateRewards; @@ -1144,14 +1149,16 @@ namespace storm { synchronization = getSynchronizationDecisionDiagram(generationInfo, stateActionReward.getActionIndex()); } ActionDecisionDiagram const& actionDd = stateActionReward.isLabeled() ? globalModule.synchronizingActionToDecisionDiagramMap.at(stateActionReward.getActionIndex()) : globalModule.independentAction; - states *= actionDd.guardDd * reachableStatesAdd; + states *= actionDd.guardDd.template toAdd() * reachableStatesAdd; storm::dd::Add stateActionRewardDd = synchronization * states * rewards; - // If we are building the state-action rewards for an MDP, we need to make sure that the encoding - // of the nondeterminism is present in the reward vector, so we ne need to multiply it with the - // legal state-actions. + // If we are building the state-action rewards for an MDP, we need to make sure that the reward is + // only given on legal nondeterminism encodings, which is why we multiply with the state-action DD. if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::MDP) { - stateActionRewardDd *= stateActionDd; + if (!stateActionDd) { + stateActionDd = transitionMatrix.notZero().existsAbstract(generationInfo.columnMetaVariables).template toAdd(); + } + stateActionRewardDd *= stateActionDd.get(); } else if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::CTMC) { // For CTMCs, we need to multiply the entries with the exit rate of the corresponding action. stateActionRewardDd *= actionDd.transitionsDd.sumAbstract(generationInfo.columnMetaVariables); @@ -1167,7 +1174,11 @@ namespace storm { // Scale state-action rewards for DTMCs and CTMCs. if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::DTMC || generationInfo.program.getModelType() == storm::prism::Program::ModelType::CTMC) { - stateActionRewards.get() /= stateActionDd; + if (!stateActionDd) { + stateActionDd = transitionMatrix.sumAbstract(generationInfo.columnMetaVariables); + } + + stateActionRewards.get() /= stateActionDd.get(); } } @@ -1215,7 +1226,7 @@ namespace storm { // Scale transition rewards for DTMCs. if (generationInfo.program.getModelType() == storm::prism::Program::ModelType::DTMC) { - transitionRewards.get() /= stateActionDd; + transitionRewards.get() /= stateActionDd.get(); } } @@ -1240,7 +1251,7 @@ namespace storm { STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "Program still contains these undefined constants: " + stream.str()); } - STORM_LOG_DEBUG("Building representation of program:" << std::endl << program << std::endl); + STORM_LOG_TRACE("Building representation of program:" << std::endl << program << std::endl); // Start by initializing the structure used for storing all information needed during the model generation. // In particular, this creates the meta variables used to encode the model. @@ -1250,7 +1261,6 @@ namespace storm { storm::dd::Add transitionMatrix = system.allTransitionsDd; ModuleDecisionDiagram const& globalModule = system.globalModule; - storm::dd::Add stateActionDd = system.stateActionDd; // If we were asked to treat some states as terminal states, we cut away their transitions now. storm::dd::Bdd terminalStatesBdd = generationInfo.manager->getBddZero(); @@ -1314,7 +1324,9 @@ namespace storm { storm::dd::Bdd reachableStates = storm::utility::dd::computeReachableStates(initialStates, transitionMatrixBdd, generationInfo.rowMetaVariables, generationInfo.columnMetaVariables); storm::dd::Add reachableStatesAdd = reachableStates.template toAdd(); transitionMatrix *= reachableStatesAdd; - stateActionDd *= reachableStatesAdd; + if (system.stateActionDd) { + system.stateActionDd.get() *= reachableStatesAdd; + } // Detect deadlocks and 1) fix them if requested 2) throw an error otherwise. storm::dd::Bdd statesWithTransition = transitionMatrixBdd.existsAbstract(generationInfo.columnMetaVariables); @@ -1382,10 +1394,7 @@ namespace storm { selectedRewardModels.push_back(program.getRewardModel(0)); } - std::unordered_map> rewardModels; - for (auto const& rewardModel : selectedRewardModels) { - rewardModels.emplace(rewardModel.get().getName(), createRewardModelDecisionDiagrams(generationInfo, rewardModel.get(), globalModule, transitionMatrix, reachableStatesAdd, stateActionDd)); - } + std::unordered_map> rewardModels = createRewardModelDecisionDiagrams(selectedRewardModels, system, generationInfo, globalModule, reachableStatesAdd, transitionMatrix); // Build the labels that can be accessed as a shortcut. std::map labelToExpressionMapping; @@ -1396,7 +1405,7 @@ namespace storm { if (program.getModelType() == storm::prism::Program::ModelType::DTMC) { return std::shared_ptr>(new storm::models::symbolic::Dtmc(generationInfo.manager, reachableStates, initialStates, deadlockStates, transitionMatrix, generationInfo.rowMetaVariables, generationInfo.rowExpressionAdapter, generationInfo.columnMetaVariables, generationInfo.columnExpressionAdapter, generationInfo.rowColumnMetaVariablePairs, labelToExpressionMapping, rewardModels)); } else if (program.getModelType() == storm::prism::Program::ModelType::CTMC) { - return std::shared_ptr>(new storm::models::symbolic::Ctmc(generationInfo.manager, reachableStates, initialStates, deadlockStates, transitionMatrix, generationInfo.rowMetaVariables, generationInfo.rowExpressionAdapter, generationInfo.columnMetaVariables, generationInfo.columnExpressionAdapter, generationInfo.rowColumnMetaVariablePairs, labelToExpressionMapping, rewardModels)); + return std::shared_ptr>(new storm::models::symbolic::Ctmc(generationInfo.manager, reachableStates, initialStates, deadlockStates, transitionMatrix, system.stateActionDd, generationInfo.rowMetaVariables, generationInfo.rowExpressionAdapter, generationInfo.columnMetaVariables, generationInfo.columnExpressionAdapter, generationInfo.rowColumnMetaVariablePairs, labelToExpressionMapping, rewardModels)); } else if (program.getModelType() == storm::prism::Program::ModelType::MDP) { return std::shared_ptr>(new storm::models::symbolic::Mdp(generationInfo.manager, reachableStates, initialStates, deadlockStates, transitionMatrix, generationInfo.rowMetaVariables, generationInfo.rowExpressionAdapter, generationInfo.columnMetaVariables, generationInfo.columnExpressionAdapter, generationInfo.rowColumnMetaVariablePairs, generationInfo.allNondeterminismVariables, labelToExpressionMapping, rewardModels)); } else { diff --git a/src/storm/builder/DdPrismModelBuilder.h b/src/storm/builder/DdPrismModelBuilder.h index d60cbcaee..f3b7adc31 100644 --- a/src/storm/builder/DdPrismModelBuilder.h +++ b/src/storm/builder/DdPrismModelBuilder.h @@ -122,11 +122,11 @@ namespace storm { // Intentionally left empty. } - ActionDecisionDiagram(storm::dd::DdManager const& manager, std::set const& assignedGlobalVariables = std::set(), uint_fast64_t numberOfUsedNondeterminismVariables = 0) : guardDd(manager.template getAddZero()), transitionsDd(manager.template getAddZero()), numberOfUsedNondeterminismVariables(numberOfUsedNondeterminismVariables), assignedGlobalVariables(assignedGlobalVariables) { + ActionDecisionDiagram(storm::dd::DdManager const& manager, std::set const& assignedGlobalVariables = std::set(), uint_fast64_t numberOfUsedNondeterminismVariables = 0) : guardDd(manager.getBddZero()), transitionsDd(manager.template getAddZero()), numberOfUsedNondeterminismVariables(numberOfUsedNondeterminismVariables), assignedGlobalVariables(assignedGlobalVariables) { // Intentionally left empty. } - ActionDecisionDiagram(storm::dd::Add guardDd, storm::dd::Add transitionsDd, std::set const& assignedGlobalVariables = std::set(), uint_fast64_t numberOfUsedNondeterminismVariables = 0) : guardDd(guardDd), transitionsDd(transitionsDd), numberOfUsedNondeterminismVariables(numberOfUsedNondeterminismVariables), assignedGlobalVariables(assignedGlobalVariables) { + ActionDecisionDiagram(storm::dd::Bdd guardDd, storm::dd::Add transitionsDd, std::set const& assignedGlobalVariables = std::set(), uint_fast64_t numberOfUsedNondeterminismVariables = 0) : guardDd(guardDd), transitionsDd(transitionsDd), numberOfUsedNondeterminismVariables(numberOfUsedNondeterminismVariables), assignedGlobalVariables(assignedGlobalVariables) { // Intentionally left empty. } @@ -134,7 +134,7 @@ namespace storm { ActionDecisionDiagram& operator=(ActionDecisionDiagram const& other) = default; // The guard of the action. - storm::dd::Add guardDd; + storm::dd::Bdd guardDd; // The actual transitions (source and target states). storm::dd::Add transitionsDd; @@ -218,7 +218,7 @@ namespace storm { static ActionDecisionDiagram combineCommandsToActionMDP(GenerationInformation& generationInfo, std::vector& commandDds, uint_fast64_t nondeterminismVariableOffset); - static ActionDecisionDiagram combineSynchronizingActions(GenerationInformation const& generationInfo, ActionDecisionDiagram const& action1, ActionDecisionDiagram const& action2); + static ActionDecisionDiagram combineSynchronizingActions(ActionDecisionDiagram const& action1, ActionDecisionDiagram const& action2); static ActionDecisionDiagram combineUnsynchronizedActions(GenerationInformation const& generationInfo, ActionDecisionDiagram& action1, ActionDecisionDiagram& action2, storm::dd::Add const& identityDd1, storm::dd::Add const& identityDd2); @@ -230,7 +230,9 @@ namespace storm { static storm::dd::Add createSystemFromModule(GenerationInformation& generationInfo, ModuleDecisionDiagram const& module); - static storm::models::symbolic::StandardRewardModel createRewardModelDecisionDiagrams(GenerationInformation& generationInfo, storm::prism::RewardModel const& rewardModel, ModuleDecisionDiagram const& globalModule, storm::dd::Add const& transitionMatrix, storm::dd::Add const& reachableStatesAdd, storm::dd::Add const& stateActionDd); + static std::unordered_map> createRewardModelDecisionDiagrams(std::vector> const& selectedRewardModels, SystemResult& system, GenerationInformation& generationInfo, ModuleDecisionDiagram const& globalModule, storm::dd::Add const& reachableStatesAdd, storm::dd::Add const& transitionMatrix); + + static storm::models::symbolic::StandardRewardModel createRewardModelDecisionDiagrams(GenerationInformation& generationInfo, storm::prism::RewardModel const& rewardModel, ModuleDecisionDiagram const& globalModule, storm::dd::Add const& reachableStatesAdd, storm::dd::Add const& transitionMatrix, boost::optional>& stateActionDd); static SystemResult createSystemDecisionDiagram(GenerationInformation& generationInfo); diff --git a/src/storm/builder/RewardModelBuilder.cpp b/src/storm/builder/RewardModelBuilder.cpp index 0200207bc..75dece593 100644 --- a/src/storm/builder/RewardModelBuilder.cpp +++ b/src/storm/builder/RewardModelBuilder.cpp @@ -16,7 +16,7 @@ namespace storm { } template - storm::models::sparse::StandardRewardModel RewardModelBuilder::build(uint_fast64_t rowCount, uint_fast64_t columnCount, uint_fast64_t rowGroupCount) { + storm::models::sparse::StandardRewardModel RewardModelBuilder::build(uint_fast64_t rowCount, uint_fast64_t, uint_fast64_t rowGroupCount) { boost::optional> optionalStateRewardVector; if (hasStateRewards()) { stateRewardVector.resize(rowGroupCount); diff --git a/src/storm/builder/jit/ExplicitJitJaniModelBuilder.cpp b/src/storm/builder/jit/ExplicitJitJaniModelBuilder.cpp index bd0f1c89c..3c6789324 100644 --- a/src/storm/builder/jit/ExplicitJitJaniModelBuilder.cpp +++ b/src/storm/builder/jit/ExplicitJitJaniModelBuilder.cpp @@ -32,6 +32,8 @@ namespace storm { namespace builder { namespace jit { + static const std::string JIT_VARIABLE_EXTENSION = "_jit_"; + #ifdef LINUX static const std::string DYLIB_EXTENSION = ".so"; #endif @@ -50,7 +52,13 @@ namespace storm { if (settings.isCompilerSet()) { compiler = settings.getCompiler(); } else { - compiler = "c++"; + const char* cxxEnv = std::getenv("CXX"); + if (cxxEnv != nullptr) { + compiler = std::string(cxxEnv); + } + if (compiler.empty()) { + compiler = "c++"; + } } if (settings.isCompilerFlagsSet()) { compilerFlags = settings.getCompilerFlags(); @@ -97,11 +105,6 @@ namespace storm { } } - // Create location variables for all the automata that we put in parallel. - for (auto const& automaton : parallelAutomata) { - automatonToLocationVariable.emplace(automaton.get().getName(), this->model.getManager().declareFreshIntegerVariable(false, automaton.get().getName() + "_")); - } - // If the program still contains undefined constants and we are not in a parametric setting, assemble an appropriate error message. #ifdef STORM_HAVE_CARL if (!std::is_same::value && this->model.hasUndefinedConstants()) { @@ -923,19 +926,19 @@ namespace storm { if (hasLocationRewards) { cpptempl::data_map locationReward; - locationReward["variable"] = variable.getName(); + locationReward["variable"] = variable.getName() + JIT_VARIABLE_EXTENSION; locationRewards.push_back(locationReward); } if (hasEdgeRewards) { cpptempl::data_map edgeReward; - edgeReward["variable"] = variable.getName(); + edgeReward["variable"] = variable.getName() + JIT_VARIABLE_EXTENSION; edgeReward["index"] = asString(rewardModelIndex); edgeRewards.push_back(edgeReward); } if (hasDestinationRewards) { cpptempl::data_map destinationReward; destinationReward["index"] = asString(rewardModelIndex); - destinationReward["variable"] = variable.getName(); + destinationReward["variable"] = variable.getName() + JIT_VARIABLE_EXTENSION; destinationRewards.push_back(destinationReward); } ++rewardModelIndex; @@ -1514,7 +1517,7 @@ namespace storm { if (this->options.isBuildAllLabelsSet() || this->options.getLabelNames().find(variable.getName()) != this->options.getLabelNames().end()) { cpptempl::data_map label; label["name"] = variable.getName(); - label["predicate"] = expressionTranslator.translate(shiftVariablesWrtLowerBound(model.getLabelExpression(variable.asBooleanVariable(), automatonToLocationVariable)), storm::expressions::ToCppTranslationOptions(variablePrefixes, variableToName)); + label["predicate"] = expressionTranslator.translate(shiftVariablesWrtLowerBound(model.getLabelExpression(variable.asBooleanVariable(), parallelAutomata)), storm::expressions::ToCppTranslationOptions(variablePrefixes, variableToName, storm::expressions::ToCppTranslationMode::CastDouble)); labels.push_back(label); } } @@ -1523,7 +1526,7 @@ namespace storm { for (auto const& expression : this->options.getExpressionLabels()) { cpptempl::data_map label; label["name"] = expression.toString(); - label["predicate"] = expressionTranslator.translate(shiftVariablesWrtLowerBound(expression), storm::expressions::ToCppTranslationOptions(variablePrefixes, variableToName)); + label["predicate"] = expressionTranslator.translate(shiftVariablesWrtLowerBound(expression), storm::expressions::ToCppTranslationOptions(variablePrefixes, variableToName, storm::expressions::ToCppTranslationMode::CastDouble)); labels.push_back(label); } @@ -1542,8 +1545,8 @@ namespace storm { auto const& variable = variables.getVariable(labelOrExpression.getLabel()); STORM_LOG_THROW(variable.isBooleanVariable(), storm::exceptions::WrongFormatException, "Terminal label refers to non-boolean variable '" << variable.getName() << "."); STORM_LOG_THROW(variable.isTransient(), storm::exceptions::WrongFormatException, "Terminal label refers to non-transient variable '" << variable.getName() << "."); - auto labelExpression = model.getLabelExpression(variable.asBooleanVariable(), automatonToLocationVariable); - if (terminalEntry.second) { + auto labelExpression = model.getLabelExpression(variable.asBooleanVariable(), parallelAutomata); + if (!terminalEntry.second) { labelExpression = !labelExpression; } terminalExpressions.push_back(expressionTranslator.translate(shiftVariablesWrtLowerBound(labelExpression), storm::expressions::ToCppTranslationOptions(variablePrefixes, variableToName))); @@ -1577,7 +1580,7 @@ namespace storm { template std::string const& ExplicitJitJaniModelBuilder::registerVariable(storm::expressions::Variable const& variable, bool transient) { // Since the variable name might be illegal as a C++ identifier, we need to prepare it a bit. - variableToName[variable] = variable.getName() + "_jit_"; + variableToName[variable] = variable.getName() + JIT_VARIABLE_EXTENSION; if (transient) { transientVariables.insert(variable); variablePrefixes[variable] = "transientIn."; @@ -1590,7 +1593,7 @@ namespace storm { template storm::expressions::Variable const& ExplicitJitJaniModelBuilder::getLocationVariable(storm::jani::Automaton const& automaton) const { - return automatonToLocationVariable.at(automaton.getName()); + return automaton.getLocationExpressionVariable(); } template @@ -2347,7 +2350,7 @@ namespace storm { } void addStateBehaviour(IndexType const& stateId, StateBehaviour& behaviour) { - if (behaviour.empty()) { + if (behaviour.empty() && behaviour.isExpanded()) { deadlockStates.push_back(stateId); } @@ -2405,12 +2408,12 @@ namespace storm { } template> = carl::dummy> - RationalFunctionType convertVariableToPolynomial(carl::Variable const& variable, std::shared_ptr>> cache) { + RationalFunctionType convertVariableToPolynomial(carl::Variable const& variable, std::shared_ptr>>) { return RationalFunctionType(variable); } template - std::vector getParameters(storm::jani::Model const& model, std::shared_ptr>> cache) { + std::vector getParameters(storm::jani::Model const&, std::shared_ptr>>) { STORM_LOG_THROW(false, storm::exceptions::InvalidStateException, "This function must not be called for this type."); } diff --git a/src/storm/builder/jit/ExplicitJitJaniModelBuilder.h b/src/storm/builder/jit/ExplicitJitJaniModelBuilder.h index e3c4c0b94..062865459 100644 --- a/src/storm/builder/jit/ExplicitJitJaniModelBuilder.h +++ b/src/storm/builder/jit/ExplicitJitJaniModelBuilder.h @@ -161,7 +161,6 @@ namespace storm { // Members that store information about the model. They are used in the process of assembling the model // data that is used in the skeleton. std::unordered_map variableToName; - std::map automatonToLocationVariable; storm::expressions::ToCppVisitor expressionTranslator; std::map lowerBoundShiftSubstitution; std::map lowerBounds; diff --git a/src/storm/builder/jit/StateBehaviour.cpp b/src/storm/builder/jit/StateBehaviour.cpp index a14261e1f..40cf06895 100644 --- a/src/storm/builder/jit/StateBehaviour.cpp +++ b/src/storm/builder/jit/StateBehaviour.cpp @@ -73,13 +73,14 @@ namespace storm { if (modelType == storm::jani::ModelType::CTMC) { for (auto const& choice : choices) { ValueType massOfChoice = storm::utility::zero(); - for (auto const& entry : choices.front().getDistribution()) { + for (auto const& entry : choice.getDistribution()) { massOfChoice += entry.getValue(); } - + totalExitRate += massOfChoice; + auto outIt = newRewards.begin(); for (auto const& reward : choice.getRewards()) { - *outIt += reward * massOfChoice / totalExitRate; + *outIt += reward * massOfChoice; ++outIt; } } @@ -87,12 +88,16 @@ namespace storm { for (auto const& choice : choices) { auto outIt = newRewards.begin(); for (auto const& reward : choice.getRewards()) { - *outIt += reward / totalExitRate; + *outIt += reward; ++outIt; } } } + for (auto& entry : newRewards) { + entry /= totalExitRate; + } + choices.front().setRewards(std::move(newRewards)); } diff --git a/src/storm/cli/cli.cpp b/src/storm/cli/cli.cpp index cfa8c66d1..a8e02dd46 100644 --- a/src/storm/cli/cli.cpp +++ b/src/storm/cli/cli.cpp @@ -9,12 +9,13 @@ #include "storm/settings/modules/IOSettings.h" #include "storm/settings/modules/CoreSettings.h" #include "storm/exceptions/OptionParserException.h" +#include "storm/settings/modules/ResourceSettings.h" #include "storm/settings/modules/JaniExportSettings.h" +#include "storm/utility/resources.h" #include "storm/utility/storm-version.h" - // Includes for the linked libraries and versions header. #ifdef STORM_HAVE_INTELTBB # include "tbb/tbb_stddef.h" @@ -129,47 +130,23 @@ namespace storm { } void showTimeAndMemoryStatistics(uint64_t wallclockMilliseconds) { -#ifndef WINDOWS struct rusage ru; getrusage(RUSAGE_SELF, &ru); - std::cout << "Performance statistics:" << std::endl; - std::cout << " * peak memory usage: " << ru.ru_maxrss/1024/1024 << " mb" << std::endl; - std::cout << " * CPU time: " << ru.ru_utime.tv_sec << "." << std::setw(3) << std::setfill('0') << ru.ru_utime.tv_usec/1000 << " seconds" << std::endl; + std::cout << std::endl << "Performance statistics:" << std::endl; +#ifdef MACOS + // For Mac OS, this is returned in bytes. + uint64_t maximumResidentSizeInMegabytes = ru.ru_maxrss / 1024 / 1024; +#endif +#ifdef LINUX + // For Linux, this is returned in kilobytes. + uint64_t maximumResidentSizeInMegabytes = ru.ru_maxrss / 1024; +#endif + std::cout << " * peak memory usage: " << maximumResidentSizeInMegabytes << "MB" << std::endl; + std::cout << " * CPU time: " << ru.ru_utime.tv_sec << "." << std::setw(3) << std::setfill('0') << ru.ru_utime.tv_usec/1000 << "s" << std::endl; if (wallclockMilliseconds != 0) { - std::cout << " * wallclock time: " << (wallclockMilliseconds/1000) << "." << std::setw(3) << std::setfill('0') << (wallclockMilliseconds % 1000) << " seconds" << std::endl; + std::cout << " * wallclock time: " << (wallclockMilliseconds/1000) << "." << std::setw(3) << std::setfill('0') << (wallclockMilliseconds % 1000) << "s" << std::endl; } -#else - HANDLE hProcess = GetCurrentProcess (); - FILETIME ftCreation, ftExit, ftUser, ftKernel; - PROCESS_MEMORY_COUNTERS pmc; - if (GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc))) { - std::cout << "Memory Usage: " << std::endl; - std::cout << "\tPageFaultCount: " << pmc.PageFaultCount << std::endl; - std::cout << "\tPeakWorkingSetSize: " << pmc.PeakWorkingSetSize << std::endl; - std::cout << "\tWorkingSetSize: " << pmc.WorkingSetSize << std::endl; - std::cout << "\tQuotaPeakPagedPoolUsage: " << pmc.QuotaPeakPagedPoolUsage << std::endl; - std::cout << "\tQuotaPagedPoolUsage: " << pmc.QuotaPagedPoolUsage << std::endl; - std::cout << "\tQuotaPeakNonPagedPoolUsage: " << pmc.QuotaPeakNonPagedPoolUsage << std::endl; - std::cout << "\tQuotaNonPagedPoolUsage: " << pmc.QuotaNonPagedPoolUsage << std::endl; - std::cout << "\tPagefileUsage:" << pmc.PagefileUsage << std::endl; - std::cout << "\tPeakPagefileUsage: " << pmc.PeakPagefileUsage << std::endl; - } - - GetProcessTimes (hProcess, &ftCreation, &ftExit, &ftKernel, &ftUser); - - ULARGE_INTEGER uLargeInteger; - uLargeInteger.LowPart = ftKernel.dwLowDateTime; - uLargeInteger.HighPart = ftKernel.dwHighDateTime; - double kernelTime = static_cast(uLargeInteger.QuadPart) / 10000.0; // 100 ns Resolution to milliseconds - uLargeInteger.LowPart = ftUser.dwLowDateTime; - uLargeInteger.HighPart = ftUser.dwHighDateTime; - double userTime = static_cast(uLargeInteger.QuadPart) / 10000.0; - - std::cout << "CPU Time: " << std::endl; - std::cout << "\tKernel Time: " << std::setprecision(5) << kernelTime << "ms" << std::endl; - std::cout << "\tUser Time: " << std::setprecision(5) << userTime << "ms" << std::endl; -#endif } bool parseOptions(const int argc, const char* argv[]) { @@ -180,27 +157,35 @@ namespace storm { throw e; return false; } - - if (storm::settings::getModule().isHelpSet()) { + + storm::settings::modules::GeneralSettings const& general = storm::settings::getModule(); + storm::settings::modules::ResourceSettings const& resources = storm::settings::getModule(); + storm::settings::modules::DebugSettings const& debug = storm::settings::getModule(); + + if (general.isHelpSet()) { storm::settings::manager().printHelp(storm::settings::getModule().getHelpModuleName()); return false; } - - if (storm::settings::getModule().isVersionSet()) { + // If we were given a time limit, we put it in place now. + if (resources.isTimeoutSet()) { + storm::utility::resources::setCPULimit(resources.getTimeoutInSeconds()); + } + + if (general.isVersionSet()) { storm::settings::manager().printVersion(); return false; } - - if (storm::settings::getModule().isVerboseSet()) { + + if (general.isVerboseSet()) { storm::utility::setLogLevel(l3pp::LogLevel::INFO); } - if (storm::settings::getModule().isDebugSet()) { + if (debug.isDebugSet()) { storm::utility::setLogLevel(l3pp::LogLevel::DEBUG); } - if (storm::settings::getModule().isTraceSet()) { + if (debug.isTraceSet()) { storm::utility::setLogLevel(l3pp::LogLevel::TRACE); } - if (storm::settings::getModule().isLogfileSet()) { + if (debug.isLogfileSet()) { storm::utility::initializeFileLogging(); } return true; @@ -212,16 +197,35 @@ namespace storm { storm::utility::initializeFileLogging(); } + boost::optional> propertyFilter; + std::string propertyFilterString = storm::settings::getModule().getPropertyFilter(); + if (propertyFilterString != "all") { + propertyFilter = storm::parsePropertyFilter(storm::settings::getModule().getPropertyFilter()); + } + + auto coreSettings = storm::settings::getModule(); + auto generalSettings = storm::settings::getModule(); auto ioSettings = storm::settings::getModule(); if (ioSettings.isPrismOrJaniInputSet()) { storm::storage::SymbolicModelDescription model; std::vector properties; STORM_LOG_TRACE("Parsing symbolic input."); + boost::optional> labelRenaming; if (ioSettings.isPrismInputSet()) { model = storm::parseProgram(ioSettings.getPrismInputFilename()); - if (ioSettings.isPrismToJaniSet()) { - model = model.toJani(true); + + bool transformToJani = ioSettings.isPrismToJaniSet(); + bool transformToJaniForJit = coreSettings.getEngine() == storm::settings::modules::CoreSettings::Engine::Sparse && ioSettings.isJitSet(); + STORM_LOG_WARN_COND(transformToJani || !transformToJaniForJit, "The JIT-based model builder is only available for JANI models, automatically converting the PRISM input model."); + transformToJani |= transformToJaniForJit; + + if (transformToJani) { + auto modelAndRenaming = model.toJaniWithLabelRenaming(true); + if (!modelAndRenaming.second.empty()) { + labelRenaming = modelAndRenaming.second; + } + model = modelAndRenaming.first; } } else if (ioSettings.isJaniInputSet()) { auto input = storm::parseJaniModel(ioSettings.getJaniInputFilename()); @@ -235,22 +239,33 @@ namespace storm { } + // Get the string that assigns values to the unknown currently undefined constants in the model and formula. + std::string constantDefinitionString = ioSettings.getConstantDefinitionString(); + std::map constantDefinitions; + // Then proceed to parsing the properties (if given), since the model we are building may depend on the property. STORM_LOG_TRACE("Parsing properties."); - uint64_t i = 0; - if (storm::settings::getModule().isPropertySet()) { + if (generalSettings.isPropertySet()) { if (model.isJaniModel()) { - for(auto const& formula : storm::parseFormulasForJaniModel(storm::settings::getModule().getProperty(), model.asJaniModel())) { - properties.emplace_back(std::to_string(i), formula); - ++i; + properties = storm::parsePropertiesForJaniModel(generalSettings.getProperty(), model.asJaniModel(), propertyFilter); + + if (labelRenaming) { + std::vector amendedProperties; + for (auto const& property : properties) { + amendedProperties.emplace_back(property.substituteLabels(labelRenaming.get())); + } + properties = std::move(amendedProperties); } } else { - for(auto const& formula :storm::parseFormulasForPrismProgram(storm::settings::getModule().getProperty(), model.asPrismProgram())) { - properties.emplace_back(std::to_string(i), formula); - ++i; - } + properties = storm::parsePropertiesForPrismProgram(generalSettings.getProperty(), model.asPrismProgram(), propertyFilter); } + + constantDefinitions = model.parseConstantDefinitions(constantDefinitionString); + properties = substituteConstantsInProperties(properties, constantDefinitions); + } else { + constantDefinitions = model.parseConstantDefinitions(constantDefinitionString); } + model = model.preprocess(constantDefinitions); if (model.isJaniModel() && storm::settings::getModule().isJaniFileSet()) { exportJaniModel(model.asJaniModel(), properties, storm::settings::getModule().getJaniFilename()); @@ -260,18 +275,14 @@ namespace storm { return; } - // Get the string that assigns values to the unknown currently undefined constants in the model. - std::string constantDefinitionString = ioSettings.getConstantDefinitionString(); - model = model.preprocess(constantDefinitionString); - STORM_LOG_TRACE("Building and checking symbolic model."); - if (storm::settings::getModule().isParametricSet()) { + if (generalSettings.isParametricSet()) { #ifdef STORM_HAVE_CARL buildAndCheckSymbolicModel(model, properties, true); #else STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "No parameters are supported in this build."); #endif - } else if (storm::settings::getModule().isExactSet()) { + } else if (generalSettings.isExactSet()) { #ifdef STORM_HAVE_CARL buildAndCheckSymbolicModel(model, properties, true); #else @@ -280,19 +291,14 @@ namespace storm { } else { buildAndCheckSymbolicModel(model, properties, true); } - } else if (storm::settings::getModule().isExplicitSet()) { - STORM_LOG_THROW(storm::settings::getModule().getEngine() == storm::settings::modules::CoreSettings::Engine::Sparse, storm::exceptions::InvalidSettingsException, "Only the sparse engine supports explicit model input."); + } else if (ioSettings.isExplicitSet()) { + STORM_LOG_THROW(coreSettings.getEngine() == storm::settings::modules::CoreSettings::Engine::Sparse, storm::exceptions::InvalidSettingsException, "Only the sparse engine supports explicit model input."); // If the model is given in an explicit format, we parse the properties without allowing expressions // in formulas. std::vector properties; - if (storm::settings::getModule().isPropertySet()) { - uint64_t i = 0; - for(auto const& formula : storm::parseFormulasForExplicit(storm::settings::getModule().getProperty())) { - properties.emplace_back(std::to_string(i), formula); - ++i; - - } + if (generalSettings.isPropertySet()) { + properties = storm::parsePropertiesForExplicit(generalSettings.getProperty(), propertyFilter); } buildAndCheckExplicitModel(properties, true); diff --git a/src/storm/cli/entrypoints.h b/src/storm/cli/entrypoints.h index f5720c829..3d1a9397e 100644 --- a/src/storm/cli/entrypoints.h +++ b/src/storm/cli/entrypoints.h @@ -1,38 +1,41 @@ #ifndef STORM_ENTRYPOINTS_H_H #define STORM_ENTRYPOINTS_H_H +#include + #include "storm/utility/storm.h" #include "storm/storage/SymbolicModelDescription.h" #include "storm/utility/ExplicitExporter.h" +#include "storm/utility/Stopwatch.h" #include "storm/exceptions/NotImplementedException.h" #include "storm/exceptions/InvalidSettingsException.h" #include "storm/exceptions/UnexpectedException.h" +#include "storm/exceptions/InvalidTypeException.h" namespace storm { namespace cli { template void applyFilterFunctionAndOutput(std::unique_ptr const& result, storm::modelchecker::FilterType ft) { - - if(result->isQuantitative()) { - switch(ft) { + if (result->isQuantitative()) { + switch (ft) { case storm::modelchecker::FilterType::VALUES: - std::cout << *result << std::endl; - return; + STORM_PRINT_AND_LOG(*result); + break; case storm::modelchecker::FilterType::SUM: - std::cout << result->asQuantitativeCheckResult().sum(); - return; + STORM_PRINT_AND_LOG(result->asQuantitativeCheckResult().sum()); + break; case storm::modelchecker::FilterType::AVG: - std::cout << result->asQuantitativeCheckResult().average(); - return; + STORM_PRINT_AND_LOG(result->asQuantitativeCheckResult().average()); + break; case storm::modelchecker::FilterType::MIN: - std::cout << result->asQuantitativeCheckResult().getMin(); - return; + STORM_PRINT_AND_LOG(result->asQuantitativeCheckResult().getMin()); + break; case storm::modelchecker::FilterType::MAX: - std::cout << result->asQuantitativeCheckResult().getMax(); - return; + STORM_PRINT_AND_LOG(result->asQuantitativeCheckResult().getMax()); + break; case storm::modelchecker::FilterType::ARGMIN: case storm::modelchecker::FilterType::ARGMAX: STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Outputting states is not supported"); @@ -42,19 +45,19 @@ namespace storm { STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "FilterType only defined for qualitative results"); } } else { - switch(ft) { + switch (ft) { case storm::modelchecker::FilterType::VALUES: - std::cout << *result << std::endl; - return; + STORM_PRINT_AND_LOG(*result << std::endl); + break; case storm::modelchecker::FilterType::EXISTS: - std::cout << result->asQualitativeCheckResult().existsTrue(); - return; + STORM_PRINT_AND_LOG(result->asQualitativeCheckResult().existsTrue()); + break; case storm::modelchecker::FilterType::FORALL: - std::cout << result->asQualitativeCheckResult().forallTrue(); - return; + STORM_PRINT_AND_LOG(result->asQualitativeCheckResult().forallTrue()); + break; case storm::modelchecker::FilterType::COUNT: - std::cout << result->asQualitativeCheckResult().count(); - return; + STORM_PRINT_AND_LOG(result->asQualitativeCheckResult().count()); + break; case storm::modelchecker::FilterType::ARGMIN: case storm::modelchecker::FilterType::ARGMAX: @@ -65,23 +68,25 @@ namespace storm { case storm::modelchecker::FilterType::MAX: STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "FilterType only defined for quantitative results"); } - } + STORM_PRINT_AND_LOG(std::endl); } template void verifySparseModel(std::shared_ptr> model, std::vector const& properties, bool onlyInitialStatesRelevant = false) { for (auto const& property : properties) { - std::cout << std::endl << "Model checking property: " << property << " ..."; + STORM_PRINT_AND_LOG(std::endl << "Model checking property " << *property.getRawFormula() << " ..." << std::endl); + std::cout.flush(); + storm::utility::Stopwatch modelCheckingWatch(true); std::unique_ptr result(storm::verifySparseModel(model, property.getFilter().getFormula(), onlyInitialStatesRelevant)); + modelCheckingWatch.stop(); if (result) { - std::cout << " done." << std::endl; - std::cout << "Result (initial states): "; + STORM_PRINT_AND_LOG("Result (initial states): "); result->filter(storm::modelchecker::ExplicitQualitativeCheckResult(model->getInitialStates())); applyFilterFunctionAndOutput(result, property.getFilter().getFilterType()); - std::cout << std::endl; + STORM_PRINT_AND_LOG("Time for model checking: " << modelCheckingWatch << "." << std::endl); } else { - std::cout << " skipped, because the modelling formalism is currently unsupported." << std::endl; + STORM_PRINT_AND_LOG(" skipped, because the modelling formalism is currently unsupported." << std::endl); } } } @@ -92,16 +97,18 @@ namespace storm { for (auto const& property : properties) { STORM_LOG_THROW(model->getType() == storm::models::ModelType::Dtmc || model->getType() == storm::models::ModelType::Ctmc, storm::exceptions::InvalidSettingsException, "Currently parametric verification is only available for DTMCs and CTMCs."); - std::cout << std::endl << "Model checking property: " << property << " ..."; + STORM_PRINT_AND_LOG(std::endl << "Model checking property " << *property.getRawFormula() << " ..." << std::endl); + std::cout.flush(); + storm::utility::Stopwatch modelCheckingWatch(true); std::unique_ptr result(storm::verifySparseModel(model, property.getFilter().getFormula(), onlyInitialStatesRelevant)); + modelCheckingWatch.stop(); if (result) { - std::cout << " done." << std::endl; - std::cout << "Result (initial states): "; + STORM_PRINT_AND_LOG("Result (initial states): "); result->filter(storm::modelchecker::ExplicitQualitativeCheckResult(model->getInitialStates())); applyFilterFunctionAndOutput(result, property.getFilter().getFilterType()); - std::cout << std::endl; + STORM_PRINT_AND_LOG("Time for model checking: " << modelCheckingWatch << "." << std::endl); } else { - std::cout << " skipped, because the modelling formalism is currently unsupported." << std::endl; + STORM_PRINT_AND_LOG(" skipped, because the modelling formalism is currently unsupported." << std::endl); } if (storm::settings::getModule().exportResultToFile()) { @@ -112,8 +119,22 @@ namespace storm { #endif template - void verifySymbolicModelWithAbstractionRefinementEngine(storm::storage::SymbolicModelDescription const& model, std::vector const& formulas, bool onlyInitialStatesRelevant = false) { - STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Abstraction Refinement is not yet implemented."); + void verifySymbolicModelWithAbstractionRefinementEngine(storm::storage::SymbolicModelDescription const& model, std::vector const& properties, bool onlyInitialStatesRelevant = false) { + typedef double ValueType; + for (auto const& property : properties) { + STORM_PRINT_AND_LOG(std::endl << "Model checking property " << *property.getRawFormula() << " ..." << std::endl); + std::cout.flush(); + storm::utility::Stopwatch modelCheckingWatch(true); + std::unique_ptr result(storm::verifySymbolicModelWithAbstractionRefinementEngine(model, property.getFilter().getFormula(), onlyInitialStatesRelevant)); + modelCheckingWatch.stop(); + if (result) { + STORM_PRINT_AND_LOG("Result (initial states): "); + STORM_PRINT_AND_LOG(*result << std::endl); + STORM_PRINT_AND_LOG("Time for model checking: " << modelCheckingWatch << "." << std::endl); + } else { + STORM_PRINT_AND_LOG(" skipped, because the modelling formalism is currently unsupported." << std::endl); + } + } } template @@ -123,17 +144,22 @@ namespace storm { STORM_LOG_THROW(program.getModelType() == storm::prism::Program::ModelType::DTMC || program.getModelType() == storm::prism::Program::ModelType::MDP, storm::exceptions::InvalidSettingsException, "Currently exploration-based verification is only available for DTMCs and MDPs."); for (auto const& property : formulas) { - std::cout << std::endl << "Model checking property: " << property << " ..."; + STORM_PRINT_AND_LOG(std::endl << "Model checking property " << *property.getRawFormula() << " ..." << std::endl); + std::cout.flush(); bool formulaSupported = false; std::unique_ptr result; + storm::utility::Stopwatch modelCheckingWatch(false); + if (program.getModelType() == storm::prism::Program::ModelType::DTMC) { storm::modelchecker::SparseExplorationModelChecker> checker(program); storm::modelchecker::CheckTask task(*property.getFilter().getFormula(), onlyInitialStatesRelevant); formulaSupported = checker.canHandle(task); if (formulaSupported) { + modelCheckingWatch.start(); result = checker.check(task); + modelCheckingWatch.stop(); } } else if (program.getModelType() == storm::prism::Program::ModelType::MDP) { storm::modelchecker::SparseExplorationModelChecker> checker(program); @@ -141,23 +167,24 @@ namespace storm { formulaSupported = checker.canHandle(task); if (formulaSupported) { + modelCheckingWatch.start(); result = checker.check(task); + modelCheckingWatch.stop(); } } else { // Should be catched before. assert(false); } if (!formulaSupported) { - std::cout << " skipped, because the formula cannot be handled by the selected engine/method." << std::endl; + STORM_PRINT_AND_LOG(" skipped, because the formula cannot be handled by the selected engine/method." << std::endl); } if (result) { - std::cout << " done." << std::endl; - std::cout << "Result (initial states): "; + STORM_PRINT_AND_LOG("Result (initial states): "); applyFilterFunctionAndOutput(result, property.getFilter().getFilterType()); - std::cout << std::endl; + STORM_PRINT_AND_LOG("Time for model checking: " << modelCheckingWatch << "." << std::endl); } else { - std::cout << " skipped, because the modelling formalism is currently unsupported." << std::endl; + STORM_PRINT_AND_LOG(" skipped, because the modelling formalism is currently unsupported." << std::endl); } } } @@ -172,17 +199,20 @@ namespace storm { template void verifySymbolicModelWithHybridEngine(std::shared_ptr> model, std::vector const& formulas, bool onlyInitialStatesRelevant = false) { for (auto const& property : formulas) { - std::cout << std::endl << "Model checking property: " << property << " ..."; + STORM_PRINT_AND_LOG(std::endl << "Model checking property " << *property.getRawFormula() << " ..." << std::endl); + std::cout.flush(); + + storm::utility::Stopwatch modelCheckingWatch(true); std::unique_ptr result(storm::verifySymbolicModelWithHybridEngine(model, property.getFilter().getFormula(), onlyInitialStatesRelevant)); + modelCheckingWatch.stop(); if (result) { - std::cout << " done." << std::endl; - std::cout << "Result (initial states): "; + STORM_PRINT_AND_LOG("Result (initial states): "); result->filter(storm::modelchecker::SymbolicQualitativeCheckResult(model->getReachableStates(), model->getInitialStates())); applyFilterFunctionAndOutput(result, property.getFilter().getFilterType()); - std::cout << std::endl; + STORM_PRINT_AND_LOG("Time for model checking: " << modelCheckingWatch << "." << std::endl); } else { - std::cout << " skipped, because the modelling formalism is currently unsupported." << std::endl; + STORM_PRINT_AND_LOG(" skipped, because the modelling formalism is currently unsupported." << std::endl); } } } @@ -190,16 +220,19 @@ namespace storm { template void verifySymbolicModelWithDdEngine(std::shared_ptr> model, std::vector const& formulas, bool onlyInitialStatesRelevant = false) { for (auto const& property : formulas) { - std::cout << std::endl << "Model checking property: " << property << " ..."; + STORM_PRINT_AND_LOG(std::endl << "Model checking property " << *property.getRawFormula() << " ..." << std::endl); + std::cout.flush(); + + storm::utility::Stopwatch modelCheckingWatch(true); std::unique_ptr result(storm::verifySymbolicModelWithDdEngine(model, property.getFilter().getFormula(), onlyInitialStatesRelevant)); + modelCheckingWatch.stop(); if (result) { - std::cout << " done." << std::endl; - std::cout << "Result (initial states): "; + STORM_PRINT_AND_LOG("Result (initial states): "); result->filter(storm::modelchecker::SymbolicQualitativeCheckResult(model->getReachableStates(), model->getInitialStates())); applyFilterFunctionAndOutput(result, property.getFilter().getFilterType()); - std::cout << std::endl; + STORM_PRINT_AND_LOG("Time for model checking: " << modelCheckingWatch << "." << std::endl); } else { - std::cout << " skipped, because the modelling formalism is currently unsupported." << std::endl; + STORM_PRINT_AND_LOG(" skipped, because the modelling formalism is currently unsupported." << std::endl); } } } @@ -247,7 +280,10 @@ namespace storm { template void buildAndCheckSymbolicModelWithSymbolicEngine(bool hybrid, storm::storage::SymbolicModelDescription const& model, std::vector const& properties, bool onlyInitialStatesRelevant = false) { // Start by building the model. - auto markovModel = buildSymbolicModel(model, formulasInProperties(properties)); + storm::utility::Stopwatch modelBuildingWatch(true); + auto markovModel = buildSymbolicModel(model, extractFormulasFromProperties(properties)); + modelBuildingWatch.stop(); + STORM_PRINT_AND_LOG("Time for model construction: " << modelBuildingWatch << "." << std::endl << std::endl); // Print some information about the model. markovModel->printModelInformationToStream(std::cout); @@ -262,9 +298,12 @@ namespace storm { template void buildAndCheckSymbolicModelWithSparseEngine(storm::storage::SymbolicModelDescription const& model, std::vector const& properties, bool onlyInitialStatesRelevant = false) { - auto formulas = formulasInProperties(properties); + auto formulas = extractFormulasFromProperties(properties); // Start by building the model. + storm::utility::Stopwatch modelBuildingWatch(true); std::shared_ptr markovModel = buildSparseModel(model, formulas); + modelBuildingWatch.stop(); + STORM_PRINT_AND_LOG("Time for model construction: " << modelBuildingWatch << "." << std::endl << std::endl); STORM_LOG_THROW(markovModel, storm::exceptions::UnexpectedException, "The model was not successfully built."); @@ -295,6 +334,7 @@ namespace storm { template void buildAndCheckSymbolicModel(storm::storage::SymbolicModelDescription const& model, std::vector const& formulas, bool onlyInitialStatesRelevant = false) { if (storm::settings::getModule().getEngine() == storm::settings::modules::CoreSettings::Engine::AbstractionRefinement) { + STORM_LOG_THROW((std::is_same::value), storm::exceptions::InvalidTypeException, "The value type is not supported by abstraction refinement."); auto ddlib = storm::settings::getModule().getDdLibraryType(); if (ddlib == storm::dd::DdType::CUDD) { verifySymbolicModelWithAbstractionRefinementEngine(model, formulas, onlyInitialStatesRelevant); @@ -338,10 +378,14 @@ namespace storm { storm::settings::modules::IOSettings const& settings = storm::settings::getModule(); STORM_LOG_THROW(settings.isExplicitSet(), storm::exceptions::InvalidStateException, "Unable to build explicit model without model files."); + + storm::utility::Stopwatch modelBuildingWatch(true); std::shared_ptr model = buildExplicitModel(settings.getTransitionFilename(), settings.getLabelingFilename(), settings.isStateRewardsSet() ? boost::optional(settings.getStateRewardsFilename()) : boost::none, settings.isTransitionRewardsSet() ? boost::optional(settings.getTransitionRewardsFilename()) : boost::none, settings.isChoiceLabelingSet() ? boost::optional(settings.getChoiceLabelingFilename()) : boost::none); + modelBuildingWatch.stop(); + STORM_PRINT_AND_LOG("Time for model construction: " << modelBuildingWatch << "." << std::endl); // Preprocess the model if needed. - BRANCH_ON_MODELTYPE(model, model, ValueType, storm::dd::DdType::CUDD, preprocessModel, formulasInProperties(properties)); + BRANCH_ON_MODELTYPE(model, model, ValueType, storm::dd::DdType::CUDD, preprocessModel, extractFormulasFromProperties(properties)); // Print some information about the model. model->printModelInformationToStream(std::cout); diff --git a/src/storm/counterexamples/MILPMinimalLabelSetGenerator.h b/src/storm/counterexamples/MILPMinimalLabelSetGenerator.h index bcf18eb0e..537b844d6 100644 --- a/src/storm/counterexamples/MILPMinimalLabelSetGenerator.h +++ b/src/storm/counterexamples/MILPMinimalLabelSetGenerator.h @@ -94,7 +94,7 @@ namespace storm { */ static struct StateInformation determineRelevantAndProblematicStates(storm::models::sparse::Mdp const& labeledMdp, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates) { StateInformation result; - result.relevantStates = storm::utility::graph::performProbGreater0E(labeledMdp.getTransitionMatrix(), labeledMdp.getNondeterministicChoiceIndices(), labeledMdp.getBackwardTransitions(), phiStates, psiStates); + result.relevantStates = storm::utility::graph::performProbGreater0E(labeledMdp.getBackwardTransitions(), phiStates, psiStates); result.relevantStates &= ~psiStates; result.problematicStates = storm::utility::graph::performProb0E(labeledMdp.getTransitionMatrix(), labeledMdp.getNondeterministicChoiceIndices(), labeledMdp.getBackwardTransitions(), phiStates, psiStates); result.problematicStates &= result.relevantStates; @@ -262,11 +262,9 @@ namespace storm { * Creates the variable for the probability of the virtual initial state. * * @param solver The MILP solver. - * @param maximizeProbability If set to true, the objective function is constructed in a way that a - * label-minimal subsystem of maximal probability is computed. * @return The index of the variable for the probability of the virtual initial state. */ - static std::pair createVirtualInitialStateVariable(storm::solver::LpSolver& solver, bool maximizeProbability = false) { + static std::pair createVirtualInitialStateVariable(storm::solver::LpSolver& solver) { std::stringstream variableNameBuffer; variableNameBuffer << "pinit"; storm::expressions::Variable variable = solver.addBoundedContinuousVariable(variableNameBuffer.str(), 0, 1); @@ -415,13 +413,12 @@ namespace storm { * exceeds the given threshold. * * @param solver The MILP solver. - * @param labeledMdp The labeled MDP. * @param variableInformation A struct with information about the variables of the model. * @param probabilityThreshold The probability that the subsystem must exceed. * @param strictBound A flag indicating whether the threshold must be exceeded or only matched. * @return The total number of constraints that were created. */ - static uint_fast64_t assertProbabilityGreaterThanThreshold(storm::solver::LpSolver& solver, storm::models::sparse::Mdp const& labeledMdp, VariableInformation const& variableInformation, double probabilityThreshold, bool strictBound) { + static uint_fast64_t assertProbabilityGreaterThanThreshold(storm::solver::LpSolver& solver, VariableInformation const& variableInformation, double probabilityThreshold, bool strictBound) { storm::expressions::Expression constraint; if (strictBound) { constraint = variableInformation.virtualInitialStateVariable > solver.getConstant(probabilityThreshold); @@ -506,11 +503,10 @@ namespace storm { * * @param solver The MILP solver. * @param stateInformation The information about the states in the model. - * @param choiceInformation The information about the choices in the model. * @param variableInformation A struct with information about the variables of the model. * @return The total number of constraints that were created. */ - static uint_fast64_t assertZeroProbabilityWithoutChoice(storm::solver::LpSolver& solver, StateInformation const& stateInformation, ChoiceInformation const& choiceInformation, VariableInformation const& variableInformation) { + static uint_fast64_t assertZeroProbabilityWithoutChoice(storm::solver::LpSolver& solver, StateInformation const& stateInformation, VariableInformation const& variableInformation) { uint_fast64_t numberOfConstraintsCreated = 0; for (auto state : stateInformation.relevantStates) { storm::expressions::Expression constraint = variableInformation.stateToProbabilityVariableMap.at(state); @@ -624,13 +620,11 @@ namespace storm { * Asserts that labels that are on all paths from initial to target states are definitely taken. * * @param solver The MILP solver. - * @param labeledMdp The labeled MDP. - * @param psiStates A bit vector characterizing the psi states in the model. * @param choiceInformation The information about the choices in the model. * @param variableInformation A struct with information about the variables of the model. * @return The total number of constraints that were created. */ - static uint_fast64_t assertKnownLabels(storm::solver::LpSolver& solver, storm::models::sparse::Mdp const& labeledMdp, storm::storage::BitVector const& psiStates, ChoiceInformation const& choiceInformation, VariableInformation const& variableInformation) { + static uint_fast64_t assertKnownLabels(storm::solver::LpSolver& solver, ChoiceInformation const& choiceInformation, VariableInformation const& variableInformation) { uint_fast64_t numberOfConstraintsCreated = 0; for (auto label : choiceInformation.knownLabels) { @@ -815,7 +809,7 @@ namespace storm { */ static void buildConstraintSystem(storm::solver::LpSolver& solver, storm::models::sparse::Mdp const& labeledMdp, storm::storage::BitVector const& psiStates, StateInformation const& stateInformation, ChoiceInformation const& choiceInformation, VariableInformation const& variableInformation, double probabilityThreshold, bool strictBound, bool includeSchedulerCuts = false) { // Assert that the reachability probability in the subsystem exceeds the given threshold. - uint_fast64_t numberOfConstraints = assertProbabilityGreaterThanThreshold(solver, labeledMdp, variableInformation, probabilityThreshold, strictBound); + uint_fast64_t numberOfConstraints = assertProbabilityGreaterThanThreshold(solver, variableInformation, probabilityThreshold, strictBound); STORM_LOG_DEBUG("Asserted that reachability probability exceeds threshold."); // Add constraints that assert the policy takes at most one action in each state. @@ -828,7 +822,7 @@ namespace storm { // Add constraints that encode that the reachability probability from states which do not pick any action // is zero. - numberOfConstraints += assertZeroProbabilityWithoutChoice(solver, stateInformation, choiceInformation, variableInformation); + numberOfConstraints += assertZeroProbabilityWithoutChoice(solver, stateInformation, variableInformation); STORM_LOG_DEBUG("Asserted that reachability probability is zero if no choice is taken."); // Add constraints that encode the reachability probabilities for states. @@ -840,7 +834,7 @@ namespace storm { STORM_LOG_DEBUG("Asserted that unproblematic state reachable from problematic states."); // Add constraints that express that certain labels are already known to be taken. - numberOfConstraints += assertKnownLabels(solver, labeledMdp, psiStates, choiceInformation, variableInformation); + numberOfConstraints += assertKnownLabels(solver, choiceInformation, variableInformation); STORM_LOG_DEBUG("Asserted known labels are taken."); // If required, assert additional constraints that reduce the number of possible policies. @@ -923,7 +917,7 @@ namespace storm { } public: - static boost::container::flat_set getMinimalLabelSet(storm::logic::Formula const& pathFormula, storm::models::sparse::Mdp const& labeledMdp, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, double probabilityThreshold, bool strictBound, bool checkThresholdFeasible = false, bool includeSchedulerCuts = false) { + static boost::container::flat_set getMinimalLabelSet(storm::models::sparse::Mdp const& labeledMdp, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, double probabilityThreshold, bool strictBound, bool checkThresholdFeasible = false, bool includeSchedulerCuts = false) { // (0) Check whether the MDP is indeed labeled. if (!labeledMdp.hasChoiceLabeling()) { throw storm::exceptions::InvalidArgumentException() << "Minimal label set generation is impossible for unlabeled model."; @@ -1015,7 +1009,7 @@ namespace storm { // Delegate the actual computation work to the function of equal name. auto startTime = std::chrono::high_resolution_clock::now(); - boost::container::flat_set usedLabelSet = getMinimalLabelSet(probabilityOperator.getSubformula(), labeledMdp, phiStates, psiStates, threshold, strictBound, true, storm::settings::getModule().isUseSchedulerCutsSet()); + boost::container::flat_set usedLabelSet = getMinimalLabelSet(labeledMdp, phiStates, psiStates, threshold, strictBound, true, storm::settings::getModule().isUseSchedulerCutsSet()); auto endTime = std::chrono::high_resolution_clock::now(); std::cout << std::endl << "Computed minimal label set of size " << usedLabelSet.size() << " in " << std::chrono::duration_cast(endTime - startTime).count() << "ms." << std::endl; diff --git a/src/storm/counterexamples/SMTMinimalCommandSetGenerator.h b/src/storm/counterexamples/SMTMinimalCommandSetGenerator.h index ecc82ad25..e30aade7b 100644 --- a/src/storm/counterexamples/SMTMinimalCommandSetGenerator.h +++ b/src/storm/counterexamples/SMTMinimalCommandSetGenerator.h @@ -14,7 +14,7 @@ #include "storm/settings/modules/CoreSettings.h" #include "storm/utility/counterexamples.h" -#include "storm/utility/prism.h" +#include "storm/utility/cli.h" namespace storm { namespace counterexamples { @@ -95,7 +95,7 @@ namespace storm { // Compute all relevant states, i.e. states for which there exists a scheduler that has a non-zero // probabilitiy of satisfying phi until psi. storm::storage::SparseMatrix backwardTransitions = labeledMdp.getBackwardTransitions(); - relevancyInformation.relevantStates = storm::utility::graph::performProbGreater0E(labeledMdp.getTransitionMatrix(), labeledMdp.getNondeterministicChoiceIndices(), backwardTransitions, phiStates, psiStates); + relevancyInformation.relevantStates = storm::utility::graph::performProbGreater0E(backwardTransitions, phiStates, psiStates); relevancyInformation.relevantStates &= ~psiStates; STORM_LOG_DEBUG("Found " << relevancyInformation.relevantStates.getNumberOfSetBits() << " relevant states."); @@ -1410,7 +1410,7 @@ namespace storm { } storm::storage::BitVector unreachableRelevantStates = ~reachableStates & relevancyInformation.relevantStates; - storm::storage::BitVector statesThatCanReachTargetStates = storm::utility::graph::performProbGreater0E(subMdp.getTransitionMatrix(), subMdp.getNondeterministicChoiceIndices(), subMdp.getBackwardTransitions(), phiStates, psiStates); + storm::storage::BitVector statesThatCanReachTargetStates = storm::utility::graph::performProbGreater0E(subMdp.getBackwardTransitions(), phiStates, psiStates); boost::container::flat_set locallyRelevantLabels; std::set_difference(relevancyInformation.relevantLabels.begin(), relevancyInformation.relevantLabels.end(), commandSet.begin(), commandSet.end(), std::inserter(locallyRelevantLabels, locallyRelevantLabels.begin())); @@ -1530,7 +1530,7 @@ namespace storm { STORM_LOG_DEBUG("Successfully determined reachable state space."); storm::storage::BitVector unreachableRelevantStates = ~reachableStates & relevancyInformation.relevantStates; - storm::storage::BitVector statesThatCanReachTargetStates = storm::utility::graph::performProbGreater0E(subMdp.getTransitionMatrix(), subMdp.getNondeterministicChoiceIndices(), subMdp.getBackwardTransitions(), phiStates, psiStates); + storm::storage::BitVector statesThatCanReachTargetStates = storm::utility::graph::performProbGreater0E(subMdp.getBackwardTransitions(), phiStates, psiStates); boost::container::flat_set locallyRelevantLabels; std::set_difference(relevancyInformation.relevantLabels.begin(), relevancyInformation.relevantLabels.end(), commandSet.begin(), commandSet.end(), std::inserter(locallyRelevantLabels, locallyRelevantLabels.begin())); @@ -1593,7 +1593,7 @@ namespace storm { * @param checkThresholdFeasible If set, it is verified that the model can actually achieve/exceed the given probability value. If this check * is made and fails, an exception is thrown. */ - static boost::container::flat_set getMinimalCommandSet(storm::logic::Formula const& pathFormula, storm::prism::Program program, std::string const& constantDefinitionString, storm::models::sparse::Mdp const& labeledMdp, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, double probabilityThreshold, bool strictBound, bool checkThresholdFeasible = false, bool includeReachabilityEncoding = false) { + static boost::container::flat_set getMinimalCommandSet(storm::prism::Program program, std::string const& constantDefinitionString, storm::models::sparse::Mdp const& labeledMdp, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, double probabilityThreshold, bool strictBound, bool checkThresholdFeasible = false, bool includeReachabilityEncoding = false) { #ifdef STORM_HAVE_Z3 // Set up all clocks used for time measurement. auto totalClock = std::chrono::high_resolution_clock::now(); @@ -1612,7 +1612,7 @@ namespace storm { auto analysisClock = std::chrono::high_resolution_clock::now(); decltype(std::chrono::high_resolution_clock::now() - analysisClock) totalAnalysisTime(0); - std::map constantDefinitions = storm::utility::prism::parseConstantDefinitionString(program, constantDefinitionString); + std::map constantDefinitions = storm::utility::cli::parseConstantDefinitionString(program.getManager(), constantDefinitionString); storm::prism::Program preparedProgram = program.defineUndefinedConstants(constantDefinitions); preparedProgram = preparedProgram.substituteConstants(); @@ -1791,7 +1791,7 @@ namespace storm { // Delegate the actual computation work to the function of equal name. auto startTime = std::chrono::high_resolution_clock::now(); - auto labelSet = getMinimalCommandSet(probabilityOperator.getSubformula(), program, constantDefinitionString, labeledMdp, phiStates, psiStates, threshold, strictBound, true, storm::settings::getModule().isEncodeReachabilitySet()); + auto labelSet = getMinimalCommandSet(program, constantDefinitionString, labeledMdp, phiStates, psiStates, threshold, strictBound, true, storm::settings::getModule().isEncodeReachabilitySet()); auto endTime = std::chrono::high_resolution_clock::now(); std::cout << std::endl << "Computed minimal label set of size " << labelSet.size() << " in " << std::chrono::duration_cast(endTime - startTime).count() << "ms." << std::endl; diff --git a/src/storm/exceptions/InvalidModelException.h b/src/storm/exceptions/InvalidModelException.h new file mode 100644 index 000000000..fd6aaa444 --- /dev/null +++ b/src/storm/exceptions/InvalidModelException.h @@ -0,0 +1,13 @@ +#pragma once + +#include "storm/exceptions/BaseException.h" +#include "storm/exceptions/ExceptionMacros.h" + +namespace storm { + namespace exceptions { + + STORM_NEW_EXCEPTION(InvalidModelException) + + } // namespace exceptions +} // namespace storm + diff --git a/src/storm/generator/JaniNextStateGenerator.cpp b/src/storm/generator/JaniNextStateGenerator.cpp index 42372b291..b5a3d420b 100644 --- a/src/storm/generator/JaniNextStateGenerator.cpp +++ b/src/storm/generator/JaniNextStateGenerator.cpp @@ -9,6 +9,7 @@ #include "storm/utility/constants.h" #include "storm/utility/macros.h" #include "storm/utility/solver.h" +#include "storm/utility/combinatorics.h" #include "storm/exceptions/InvalidSettingsException.h" #include "storm/exceptions/WrongFormatException.h" #include "storm/exceptions/InvalidArgumentException.h" @@ -22,7 +23,7 @@ namespace storm { } template - JaniNextStateGenerator::JaniNextStateGenerator(storm::jani::Model const& model, NextStateGeneratorOptions const& options, bool flag) : NextStateGenerator(model.getExpressionManager(), options), model(model), rewardVariables(), hasStateActionRewards(false) { + JaniNextStateGenerator::JaniNextStateGenerator(storm::jani::Model const& model, NextStateGeneratorOptions const& options, bool) : NextStateGenerator(model.getExpressionManager(), options), model(model), rewardVariables(), hasStateActionRewards(false) { STORM_LOG_THROW(model.hasStandardComposition(), storm::exceptions::WrongFormatException, "The explicit next-state generator currently does not support custom system compositions."); STORM_LOG_THROW(!model.hasNonGlobalTransientVariable(), storm::exceptions::InvalidSettingsException, "The explicit next-state generator currently does not support automata-local transient variables."); STORM_LOG_THROW(!model.usesAssignmentLevels(), storm::exceptions::InvalidSettingsException, "The explicit next-state generator currently does not support assignment levels."); @@ -79,11 +80,9 @@ namespace storm { // If there are terminal states we need to handle, we now need to translate all labels to expressions. if (this->options.hasTerminalStates()) { - std::map locationVariables; - auto locationVariableIt = this->variableInformation.locationVariables.begin(); + std::vector> composedAutomata; for (auto const& automaton : this->model.getAutomata()) { - locationVariables[automaton.getName()] = locationVariableIt->variable; - ++locationVariableIt; + composedAutomata.emplace_back(automaton); } for (auto const& expressionOrLabelAndBool : this->options.getTerminalStates()) { @@ -99,7 +98,7 @@ namespace storm { STORM_LOG_THROW(variable.isBooleanVariable(), storm::exceptions::InvalidSettingsException, "Terminal states refer to non-boolean variable '" << expressionOrLabelAndBool.first.getLabel() << "'."); STORM_LOG_THROW(variable.isTransient(), storm::exceptions::InvalidSettingsException, "Terminal states refer to non-transient variable '" << expressionOrLabelAndBool.first.getLabel() << "'."); - this->terminalStates.push_back(std::make_pair(this->model.getLabelExpression(variable.asBooleanVariable(), locationVariables), expressionOrLabelAndBool.second)); + this->terminalStates.push_back(std::make_pair(this->model.getLabelExpression(variable.asBooleanVariable(), composedAutomata), expressionOrLabelAndBool.second)); } } } @@ -200,41 +199,18 @@ namespace storm { } // Gather iterators to the initial locations of all the automata. - std::vector::const_iterator> initialLocationsIterators; - uint64_t currentLocationVariable = 0; - for (auto const& automaton : this->model.getAutomata()) { - initialLocationsIterators.push_back(automaton.getInitialLocationIndices().cbegin()); - - // Initialize the locations to the first possible combination. - setLocation(initialState, this->variableInformation.locationVariables[currentLocationVariable], *initialLocationsIterators.back()); - ++currentLocationVariable; + std::vector::const_iterator> initialLocationsIts; + std::vector::const_iterator> initialLocationsItes; + for (auto const& automaton : allAutomata) { + initialLocationsIts.push_back(automaton.get().getInitialLocationIndices().cbegin()); + initialLocationsItes.push_back(automaton.get().getInitialLocationIndices().cend()); } - - // Now iterate through all combinations of initial locations. - while (true) { + storm::utility::combinatorics::forEach(initialLocationsIts, initialLocationsItes, [this,&initialState] (uint64_t index, uint64_t value) { setLocation(initialState, this->variableInformation.locationVariables[index], value); }, [&stateToIdCallback,&initialStateIndices,&initialState] () { // Register initial state. StateType id = stateToIdCallback(initialState); initialStateIndices.push_back(id); - - uint64_t index = 0; - for (; index < initialLocationsIterators.size(); ++index) { - ++initialLocationsIterators[index]; - if (initialLocationsIterators[index] == this->model.getAutomata()[index].getInitialLocationIndices().cend()) { - initialLocationsIterators[index] = this->model.getAutomata()[index].getInitialLocationIndices().cbegin(); - } else { - break; - } - } - - // If we are at the end, leave the loop. Otherwise, create the next initial state. - if (index == initialLocationsIterators.size()) { - break; - } else { - for (uint64_t j = 0; j <= index; ++j) { - setLocation(initialState, this->variableInformation.locationVariables[j], *initialLocationsIterators[j]); - } - } - } + return true; + }); // Block the current initial state to search for the next one. if (!blockingExpression.isInitialized()) { @@ -491,6 +467,9 @@ namespace storm { // If the new state was already found as a successor state, update the probability // and otherwise insert it. auto probability = stateProbabilityPair.second * this->evaluator->asRational(destination.getProbability()); + if (edge.hasRate()) { + probability *= this->evaluator->asRational(edge.getRate()); + } if (probability != storm::utility::zero()) { auto targetStateIt = newTargetStates->find(newTargetState); if (targetStateIt != newTargetStates->end()) { @@ -617,7 +596,7 @@ namespace storm { auto index = std::distance(enabledEdges.begin(), edgeSetIt); if (it != writtenGlobalVariables.end()) { - STORM_LOG_THROW(it->second == index, storm::exceptions::WrongFormatException, "Multiple writes to global variable '" << globalVariable.getName() << "' in synchronizing edges."); + STORM_LOG_THROW(it->second == static_cast(index), storm::exceptions::WrongFormatException, "Multiple writes to global variable '" << globalVariable.getName() << "' in synchronizing edges."); } else { writtenGlobalVariables.emplace(globalVariable, index); } @@ -640,11 +619,9 @@ namespace storm { storm::models::sparse::StateLabeling JaniNextStateGenerator::label(storm::storage::BitVectorHashMap const& states, std::vector const& initialStateIndices, std::vector const& deadlockStateIndices) { // Prepare a mapping from automata names to the location variables. - std::map locationVariables; - auto locationVariableIt = this->variableInformation.locationVariables.begin(); + std::vector> composedAutomata; for (auto const& automaton : model.getAutomata()) { - locationVariables[automaton.getName()] = locationVariableIt->variable; - ++locationVariableIt; + composedAutomata.emplace_back(automaton); } // As in JANI we can use transient boolean variable assignments in locations to identify states, we need to @@ -653,7 +630,7 @@ namespace storm { for (auto const& variable : model.getGlobalVariables().getTransientVariables()) { if (variable.isBooleanVariable()) { if (this->options.isBuildAllLabelsSet() || this->options.getLabelNames().find(variable.getName()) != this->options.getLabelNames().end()) { - transientVariableToExpressionMap[variable.getExpressionVariable()] = model.getLabelExpression(variable.asBooleanVariable(), locationVariables); + transientVariableToExpressionMap[variable.getExpressionVariable()] = model.getLabelExpression(variable.asBooleanVariable(), composedAutomata); } } } diff --git a/src/storm/generator/PrismNextStateGenerator.cpp b/src/storm/generator/PrismNextStateGenerator.cpp index d9c3b4293..b3061db61 100644 --- a/src/storm/generator/PrismNextStateGenerator.cpp +++ b/src/storm/generator/PrismNextStateGenerator.cpp @@ -22,7 +22,7 @@ namespace storm { } template - PrismNextStateGenerator::PrismNextStateGenerator(storm::prism::Program const& program, NextStateGeneratorOptions const& options, bool flag) : NextStateGenerator(program.getManager(), options), program(program), rewardModels() { + PrismNextStateGenerator::PrismNextStateGenerator(storm::prism::Program const& program, NextStateGeneratorOptions const& options, bool) : NextStateGenerator(program.getManager(), options), program(program), rewardModels() { STORM_LOG_TRACE("Creating next-state generator for PRISM program: " << program); STORM_LOG_THROW(!this->program.specifiesSystemComposition(), storm::exceptions::WrongFormatException, "The explicit next-state generator currently does not support custom system compositions."); @@ -256,13 +256,13 @@ namespace storm { for (auto const& stateActionReward : rewardModel.get().getStateActionRewards()) { for (auto const& choice : allChoices) { if (stateActionReward.getActionIndex() == choice.getActionIndex() && this->evaluator->asBool(stateActionReward.getStatePredicateExpression())) { - stateActionRewardValue += ValueType(this->evaluator->asRational(stateActionReward.getRewardValueExpression())) * choice.getTotalMass() / totalExitRate; + stateActionRewardValue += ValueType(this->evaluator->asRational(stateActionReward.getRewardValueExpression())) * choice.getTotalMass(); } } } } - globalChoice.addReward(stateActionRewardValue); + globalChoice.addReward(stateActionRewardValue / totalExitRate); } // Move the newly fused choice in place. diff --git a/src/storm/generator/VariableInformation.cpp b/src/storm/generator/VariableInformation.cpp index f81ea5c57..d904ae545 100644 --- a/src/storm/generator/VariableInformation.cpp +++ b/src/storm/generator/VariableInformation.cpp @@ -79,7 +79,7 @@ namespace storm { } for (auto const& automaton : model.getAutomata()) { uint_fast64_t bitwidth = static_cast(std::ceil(std::log2(automaton.getNumberOfLocations()))); - locationVariables.emplace_back(model.getManager().declareFreshIntegerVariable(false, "loc"), automaton.getNumberOfLocations() - 1, totalBitOffset, bitwidth); + locationVariables.emplace_back(automaton.getLocationExpressionVariable(), automaton.getNumberOfLocations() - 1, totalBitOffset, bitwidth); totalBitOffset += bitwidth; for (auto const& variable : automaton.getVariables().getBooleanVariables()) { diff --git a/src/storm/logic/BoundedUntilFormula.cpp b/src/storm/logic/BoundedUntilFormula.cpp index f75854d77..67ece142a 100644 --- a/src/storm/logic/BoundedUntilFormula.cpp +++ b/src/storm/logic/BoundedUntilFormula.cpp @@ -5,19 +5,13 @@ #include "storm/logic/FormulaVisitor.h" +#include "storm/exceptions/InvalidPropertyException.h" +#include "storm/exceptions/InvalidOperationException.h" + namespace storm { namespace logic { - BoundedUntilFormula::BoundedUntilFormula(std::shared_ptr const& leftSubformula, std::shared_ptr const& rightSubformula, double lowerBound, double upperBound) : BinaryPathFormula(leftSubformula, rightSubformula), bounds(std::make_pair(lowerBound, upperBound)) { - STORM_LOG_THROW(lowerBound >= 0 && upperBound >= 0, storm::exceptions::InvalidArgumentException, "Bounded until formula requires non-negative time bounds."); - STORM_LOG_THROW(lowerBound <= upperBound, storm::exceptions::InvalidArgumentException, "Lower bound of bounded until formula is required to be smaller than the upper bound."); - } - - BoundedUntilFormula::BoundedUntilFormula(std::shared_ptr const& leftSubformula, std::shared_ptr const& rightSubformula, uint_fast64_t upperBound) : BinaryPathFormula(leftSubformula, rightSubformula), bounds(upperBound) { - // Intentionally left empty. - } - - BoundedUntilFormula::BoundedUntilFormula(std::shared_ptr const& leftSubformula, std::shared_ptr const& rightSubformula, boost::variant> const& bounds) : BinaryPathFormula(leftSubformula, rightSubformula), bounds(bounds) { - // Intentionally left empty. + BoundedUntilFormula::BoundedUntilFormula(std::shared_ptr const& leftSubformula, std::shared_ptr const& rightSubformula, boost::optional const& lowerBound, boost::optional const& upperBound, TimeBoundType const& timeBoundType) : BinaryPathFormula(leftSubformula, rightSubformula), timeBoundType(timeBoundType), lowerBound(lowerBound), upperBound(upperBound) { + STORM_LOG_THROW(lowerBound || upperBound, storm::exceptions::InvalidArgumentException, "Bounded until formula requires at least one bound."); } bool BoundedUntilFormula::isBoundedUntilFormula() const { @@ -31,29 +25,123 @@ namespace storm { boost::any BoundedUntilFormula::accept(FormulaVisitor const& visitor, boost::any const& data) const { return visitor.visit(*this, data); } + + TimeBoundType const& BoundedUntilFormula::getTimeBoundType() const { + return timeBoundType; + } + + bool BoundedUntilFormula::isStepBounded() const { + return timeBoundType == TimeBoundType::Steps; + } + + bool BoundedUntilFormula::isTimeBounded() const { + return timeBoundType == TimeBoundType::Time; + } + + bool BoundedUntilFormula::isLowerBoundStrict() const { + return lowerBound.get().isStrict(); + } + + bool BoundedUntilFormula::hasLowerBound() const { + return static_cast(lowerBound); + } + + bool BoundedUntilFormula::hasIntegerLowerBound() const { + return lowerBound.get().getBound().hasIntegerType(); + } + + bool BoundedUntilFormula::isUpperBoundStrict() const { + return upperBound.get().isStrict(); + } + + bool BoundedUntilFormula::hasUpperBound() const { + return static_cast(upperBound); + } + + bool BoundedUntilFormula::hasIntegerUpperBound() const { + return upperBound.get().getBound().hasIntegerType(); + } - bool BoundedUntilFormula::hasDiscreteTimeBound() const { - return bounds.which() == 0; + storm::expressions::Expression const& BoundedUntilFormula::getLowerBound() const { + return lowerBound.get().getBound(); + } + + storm::expressions::Expression const& BoundedUntilFormula::getUpperBound() const { + return upperBound.get().getBound(); + } + + template <> + double BoundedUntilFormula::getLowerBound() const { + checkNoVariablesInBound(this->getLowerBound()); + double bound = this->getLowerBound().evaluateAsDouble(); + STORM_LOG_THROW(bound >= 0, storm::exceptions::InvalidPropertyException, "Time-bound must not evaluate to negative number."); + return bound; + } + + template <> + double BoundedUntilFormula::getUpperBound() const { + checkNoVariablesInBound(this->getUpperBound()); + double bound = this->getUpperBound().evaluateAsDouble(); + STORM_LOG_THROW(bound >= 0, storm::exceptions::InvalidPropertyException, "Time-bound must not evaluate to negative number."); + return bound; + } + + template <> + uint64_t BoundedUntilFormula::getLowerBound() const { + checkNoVariablesInBound(this->getLowerBound()); + int_fast64_t bound = this->getLowerBound().evaluateAsInt(); + STORM_LOG_THROW(bound >= 0, storm::exceptions::InvalidPropertyException, "Time-bound must not evaluate to negative number."); + return static_cast(bound); } - - std::pair const& BoundedUntilFormula::getIntervalBounds() const { - return boost::get>(bounds); + + template <> + uint64_t BoundedUntilFormula::getUpperBound() const { + checkNoVariablesInBound(this->getUpperBound()); + int_fast64_t bound = this->getUpperBound().evaluateAsInt(); + STORM_LOG_THROW(bound >= 0, storm::exceptions::InvalidPropertyException, "Time-bound must not evaluate to negative number."); + return static_cast(bound); } - uint_fast64_t BoundedUntilFormula::getDiscreteTimeBound() const { - return boost::get(bounds); + void BoundedUntilFormula::checkNoVariablesInBound(storm::expressions::Expression const& bound) { + STORM_LOG_THROW(!bound.containsVariables(), storm::exceptions::InvalidOperationException, "Cannot evaluate time-bound '" << bound << "' as it contains undefined constants."); } std::ostream& BoundedUntilFormula::writeToStream(std::ostream& out) const { this->getLeftSubformula().writeToStream(out); out << " U"; - if (!this->hasDiscreteTimeBound()) { - std::pair const& intervalBounds = getIntervalBounds(); - out << "[" << intervalBounds.first << "," << intervalBounds.second << "] "; + if (this->hasLowerBound()) { + if (this->hasUpperBound()) { + if (this->isLowerBoundStrict()) { + out << "("; + } else { + out << "["; + } + out << this->getLowerBound(); + out << ", "; + out << this->getUpperBound(); + if (this->isUpperBoundStrict()) { + out << ")"; + } else { + out << "]"; + } + } else { + if (this->isLowerBoundStrict()) { + out << ">"; + } else { + out << ">="; + } + out << getLowerBound(); + } } else { - out << "<=" << getDiscreteTimeBound() << " "; + if (this->isUpperBoundStrict()) { + out << "<"; + } else { + out << "<="; + } + out << this->getUpperBound(); } + out << " "; this->getRightSubformula().writeToStream(out); return out; diff --git a/src/storm/logic/BoundedUntilFormula.h b/src/storm/logic/BoundedUntilFormula.h index 97f0fdbae..862871796 100644 --- a/src/storm/logic/BoundedUntilFormula.h +++ b/src/storm/logic/BoundedUntilFormula.h @@ -1,17 +1,18 @@ #ifndef STORM_LOGIC_BOUNDEDUNTILFORMULA_H_ #define STORM_LOGIC_BOUNDEDUNTILFORMULA_H_ -#include +#include #include "storm/logic/BinaryPathFormula.h" +#include "storm/logic/TimeBound.h" +#include "storm/logic/TimeBoundType.h" + namespace storm { namespace logic { class BoundedUntilFormula : public BinaryPathFormula { public: - BoundedUntilFormula(std::shared_ptr const& leftSubformula, std::shared_ptr const& rightSubformula, double lowerBound, double upperBound); - BoundedUntilFormula(std::shared_ptr const& leftSubformula, std::shared_ptr const& rightSubformula, uint_fast64_t upperBound); - BoundedUntilFormula(std::shared_ptr const& leftSubformula, std::shared_ptr const& rightSubformula, boost::variant> const& bounds); + BoundedUntilFormula(std::shared_ptr const& leftSubformula, std::shared_ptr const& rightSubformula, boost::optional const& lowerBound, boost::optional const& upperBound, TimeBoundType const& timeBoundType = TimeBoundType::Time); virtual bool isBoundedUntilFormula() const override; @@ -19,15 +20,35 @@ namespace storm { virtual boost::any accept(FormulaVisitor const& visitor, boost::any const& data) const override; - bool hasDiscreteTimeBound() const; + TimeBoundType const& getTimeBoundType() const; + bool isStepBounded() const; + bool isTimeBounded() const; + + bool isLowerBoundStrict() const; + bool hasLowerBound() const; + bool hasIntegerLowerBound() const; + + bool isUpperBoundStrict() const; + bool hasUpperBound() const; + bool hasIntegerUpperBound() const; + + storm::expressions::Expression const& getLowerBound() const; + storm::expressions::Expression const& getUpperBound() const; - std::pair const& getIntervalBounds() const; - uint_fast64_t getDiscreteTimeBound() const; + template + ValueType getLowerBound() const; + + template + ValueType getUpperBound() const; virtual std::ostream& writeToStream(std::ostream& out) const override; private: - boost::variant> bounds; + static void checkNoVariablesInBound(storm::expressions::Expression const& bound); + + TimeBoundType timeBoundType; + boost::optional lowerBound; + boost::optional upperBound; }; } } diff --git a/src/storm/logic/CloneVisitor.cpp b/src/storm/logic/CloneVisitor.cpp index b3981e62a..e19d9477d 100644 --- a/src/storm/logic/CloneVisitor.cpp +++ b/src/storm/logic/CloneVisitor.cpp @@ -10,11 +10,11 @@ namespace storm { return boost::any_cast>(result); } - boost::any CloneVisitor::visit(AtomicExpressionFormula const& f, boost::any const& data) const { + boost::any CloneVisitor::visit(AtomicExpressionFormula const& f, boost::any const&) const { return std::static_pointer_cast(std::make_shared(f)); } - boost::any CloneVisitor::visit(AtomicLabelFormula const& f, boost::any const& data) const { + boost::any CloneVisitor::visit(AtomicLabelFormula const& f, boost::any const&) const { return std::static_pointer_cast(std::make_shared(f)); } @@ -24,18 +24,14 @@ namespace storm { return std::static_pointer_cast(std::make_shared(f.getOperator(), left, right)); } - boost::any CloneVisitor::visit(BooleanLiteralFormula const& f, boost::any const& data) const { + boost::any CloneVisitor::visit(BooleanLiteralFormula const& f, boost::any const&) const { return std::static_pointer_cast(std::make_shared(f)); } boost::any CloneVisitor::visit(BoundedUntilFormula const& f, boost::any const& data) const { std::shared_ptr left = boost::any_cast>(f.getLeftSubformula().accept(*this, data)); std::shared_ptr right = boost::any_cast>(f.getRightSubformula().accept(*this, data)); - if (f.hasDiscreteTimeBound()) { - return std::static_pointer_cast(std::make_shared(left, right, f.getDiscreteTimeBound())); - } else { - return std::static_pointer_cast(std::make_shared(left, right, f.getIntervalBounds())); - } + return std::static_pointer_cast(std::make_shared(f)); } boost::any CloneVisitor::visit(ConditionalFormula const& f, boost::any const& data) const { @@ -44,7 +40,7 @@ namespace storm { return std::static_pointer_cast(std::make_shared(subformula, conditionFormula, f.getContext())); } - boost::any CloneVisitor::visit(CumulativeRewardFormula const& f, boost::any const& data) const { + boost::any CloneVisitor::visit(CumulativeRewardFormula const& f, boost::any const&) const { return std::static_pointer_cast(std::make_shared(f)); } @@ -63,7 +59,7 @@ namespace storm { return std::static_pointer_cast(std::make_shared(subformula)); } - boost::any CloneVisitor::visit(InstantaneousRewardFormula const& f, boost::any const& data) const { + boost::any CloneVisitor::visit(InstantaneousRewardFormula const& f, boost::any const&) const { return std::static_pointer_cast(std::make_shared(f)); } @@ -72,7 +68,7 @@ namespace storm { return std::static_pointer_cast(std::make_shared(subformula, f.getOperatorInformation())); } - boost::any CloneVisitor::visit(LongRunAverageRewardFormula const& f, boost::any const& data) const { + boost::any CloneVisitor::visit(LongRunAverageRewardFormula const& f, boost::any const&) const { return std::static_pointer_cast(std::make_shared(f)); } @@ -99,7 +95,7 @@ namespace storm { return std::static_pointer_cast(std::make_shared(subformula, f.getOptionalRewardModelName(), f.getOperatorInformation())); } - boost::any CloneVisitor::visit(TotalRewardFormula const& f, boost::any const& data) const { + boost::any CloneVisitor::visit(TotalRewardFormula const&, boost::any const&) const { return std::static_pointer_cast(std::make_shared()); } diff --git a/src/storm/logic/CumulativeRewardFormula.cpp b/src/storm/logic/CumulativeRewardFormula.cpp index 6b74a3c0d..05bf0353b 100644 --- a/src/storm/logic/CumulativeRewardFormula.cpp +++ b/src/storm/logic/CumulativeRewardFormula.cpp @@ -2,16 +2,16 @@ #include "storm/logic/FormulaVisitor.h" +#include "storm/utility/macros.h" +#include "storm/exceptions/InvalidPropertyException.h" +#include "storm/exceptions/InvalidOperationException.h" + namespace storm { namespace logic { - CumulativeRewardFormula::CumulativeRewardFormula(uint_fast64_t timeBound) : timeBound(timeBound) { - // Intentionally left empty. - } - - CumulativeRewardFormula::CumulativeRewardFormula(double timeBound) : timeBound(timeBound) { + CumulativeRewardFormula::CumulativeRewardFormula(TimeBound const& bound, TimeBoundType const& timeBoundType) : timeBoundType(timeBoundType), bound(bound) { // Intentionally left empty. } - + bool CumulativeRewardFormula::isCumulativeRewardFormula() const { return true; } @@ -24,32 +24,52 @@ namespace storm { return visitor.visit(*this, data); } - bool CumulativeRewardFormula::hasDiscreteTimeBound() const { - return timeBound.which() == 0; + TimeBoundType const& CumulativeRewardFormula::getTimeBoundType() const { + return timeBoundType; + } + + bool CumulativeRewardFormula::isStepBounded() const { + return timeBoundType == TimeBoundType::Steps; + } + + bool CumulativeRewardFormula::isTimeBounded() const { + return timeBoundType == TimeBoundType::Time; + } + + bool CumulativeRewardFormula::isBoundStrict() const { + return bound.isStrict(); } - uint_fast64_t CumulativeRewardFormula::getDiscreteTimeBound() const { - return boost::get(timeBound); + bool CumulativeRewardFormula::hasIntegerBound() const { + return bound.getBound().hasIntegerType(); } - bool CumulativeRewardFormula::hasContinuousTimeBound() const { - return timeBound.which() == 1; + storm::expressions::Expression const& CumulativeRewardFormula::getBound() const { + return bound.getBound(); + } + + template <> + double CumulativeRewardFormula::getBound() const { + checkNoVariablesInBound(bound.getBound()); + double value = bound.getBound().evaluateAsDouble(); + STORM_LOG_THROW(value >= 0, storm::exceptions::InvalidPropertyException, "Time-bound must not evaluate to negative number."); + return value; + } + + template <> + uint64_t CumulativeRewardFormula::getBound() const { + checkNoVariablesInBound(bound.getBound()); + uint64_t value = bound.getBound().evaluateAsInt(); + STORM_LOG_THROW(value >= 0, storm::exceptions::InvalidPropertyException, "Time-bound must not evaluate to negative number."); + return value; } - double CumulativeRewardFormula::getContinuousTimeBound() const { - if (this->hasDiscreteTimeBound()) { - return this->getDiscreteTimeBound(); - } else { - return boost::get(timeBound); - } + void CumulativeRewardFormula::checkNoVariablesInBound(storm::expressions::Expression const& bound) { + STORM_LOG_THROW(!bound.containsVariables(), storm::exceptions::InvalidOperationException, "Cannot evaluate time-bound '" << bound << "' as it contains undefined constants."); } std::ostream& CumulativeRewardFormula::writeToStream(std::ostream& out) const { - if (this->hasDiscreteTimeBound()) { - out << "C<=" << this->getDiscreteTimeBound(); - } else { - out << "C<=" << this->getContinuousTimeBound(); - } + out << "C<=" << this->getBound(); return out; } } diff --git a/src/storm/logic/CumulativeRewardFormula.h b/src/storm/logic/CumulativeRewardFormula.h index 81871b79d..ad9d5e3c0 100644 --- a/src/storm/logic/CumulativeRewardFormula.h +++ b/src/storm/logic/CumulativeRewardFormula.h @@ -1,17 +1,16 @@ #ifndef STORM_LOGIC_CUMULATIVEREWARDFORMULA_H_ #define STORM_LOGIC_CUMULATIVEREWARDFORMULA_H_ -#include - #include "storm/logic/PathFormula.h" +#include "storm/logic/TimeBound.h" +#include "storm/logic/TimeBoundType.h" + namespace storm { namespace logic { class CumulativeRewardFormula : public PathFormula { public: - CumulativeRewardFormula(uint_fast64_t timeBound); - - CumulativeRewardFormula(double timeBound); + CumulativeRewardFormula(TimeBound const& bound, TimeBoundType const& timeBoundType = TimeBoundType::Time); virtual ~CumulativeRewardFormula() { // Intentionally left empty. @@ -24,16 +23,23 @@ namespace storm { virtual std::ostream& writeToStream(std::ostream& out) const override; - bool hasDiscreteTimeBound() const; + TimeBoundType const& getTimeBoundType() const; + bool isStepBounded() const; + bool isTimeBounded() const; - uint_fast64_t getDiscreteTimeBound() const; + bool isBoundStrict() const; + bool hasIntegerBound() const; - bool hasContinuousTimeBound() const; + storm::expressions::Expression const& getBound() const; - double getContinuousTimeBound() const; + template + ValueType getBound() const; private: - boost::variant timeBound; + static void checkNoVariablesInBound(storm::expressions::Expression const& bound); + + TimeBoundType timeBoundType; + TimeBound bound; }; } } diff --git a/src/storm/logic/Formula.cpp b/src/storm/logic/Formula.cpp index e253da4fb..9038a2307 100644 --- a/src/storm/logic/Formula.cpp +++ b/src/storm/logic/Formula.cpp @@ -443,6 +443,11 @@ namespace storm { return visitor.substitute(*this); } + std::shared_ptr Formula::substitute(std::map const& labelSubstitution) const { + LabelSubstitutionVisitor visitor(labelSubstitution); + return visitor.substitute(*this); + } + storm::expressions::Expression Formula::toExpression(storm::expressions::ExpressionManager const& manager, std::map const& labelToExpressionMapping) const { ToExpressionVisitor visitor; if (labelToExpressionMapping.empty()) { @@ -460,15 +465,15 @@ namespace storm { return this->shared_from_this(); } - void Formula::gatherAtomicExpressionFormulas(std::vector>& atomicExpressionFormulas) const { + void Formula::gatherAtomicExpressionFormulas(std::vector>&) const { return; } - void Formula::gatherAtomicLabelFormulas(std::vector>& atomicLabelFormulas) const { + void Formula::gatherAtomicLabelFormulas(std::vector>&) const { return; } - void Formula::gatherReferencedRewardModels(std::set& referencedRewardModels) const { + void Formula::gatherReferencedRewardModels(std::set&) const { return; } diff --git a/src/storm/logic/Formula.h b/src/storm/logic/Formula.h index 80f31203f..2ad5e9477 100644 --- a/src/storm/logic/Formula.h +++ b/src/storm/logic/Formula.h @@ -197,6 +197,7 @@ namespace storm { std::shared_ptr substitute(std::map const& substitution) const; std::shared_ptr substitute(std::map const& labelSubstitution) const; + std::shared_ptr substitute(std::map const& labelSubstitution) const; /*! * Takes the formula and converts it to an equivalent expression. The formula may contain atomic labels, but diff --git a/src/storm/logic/FormulaInformationVisitor.cpp b/src/storm/logic/FormulaInformationVisitor.cpp index ed0a461b1..319fbf2f8 100644 --- a/src/storm/logic/FormulaInformationVisitor.cpp +++ b/src/storm/logic/FormulaInformationVisitor.cpp @@ -9,88 +9,88 @@ namespace storm { return boost::any_cast(result); } - boost::any FormulaInformationVisitor::visit(AtomicExpressionFormula const& f, boost::any const& data) const { + boost::any FormulaInformationVisitor::visit(AtomicExpressionFormula const&, boost::any const&) const { return FormulaInformation(); } - boost::any FormulaInformationVisitor::visit(AtomicLabelFormula const& f, boost::any const& data) const { + boost::any FormulaInformationVisitor::visit(AtomicLabelFormula const&, boost::any const&) const { return FormulaInformation(); } - boost::any FormulaInformationVisitor::visit(BinaryBooleanStateFormula const& f, boost::any const& data) const { + boost::any FormulaInformationVisitor::visit(BinaryBooleanStateFormula const&, boost::any const&) const { return FormulaInformation(); } - boost::any FormulaInformationVisitor::visit(BooleanLiteralFormula const& f, boost::any const& data) const { + boost::any FormulaInformationVisitor::visit(BooleanLiteralFormula const&, boost::any const&) const { return FormulaInformation(); } boost::any FormulaInformationVisitor::visit(BoundedUntilFormula const& f, boost::any const& data) const { - return boost::any_cast(f.getLeftSubformula().accept(*this)).join(boost::any_cast(f.getRightSubformula().accept(*this))).setContainsBoundedUntilFormula(); + return boost::any_cast(f.getLeftSubformula().accept(*this, data)).join(boost::any_cast(f.getRightSubformula().accept(*this))).setContainsBoundedUntilFormula(); } boost::any FormulaInformationVisitor::visit(ConditionalFormula const& f, boost::any const& data) const { - return boost::any_cast(f.getSubformula().accept(*this)).join(boost::any_cast(f.getConditionFormula().accept(*this))); + return boost::any_cast(f.getSubformula().accept(*this, data)).join(boost::any_cast(f.getConditionFormula().accept(*this))); } - boost::any FormulaInformationVisitor::visit(CumulativeRewardFormula const& f, boost::any const& data) const { + boost::any FormulaInformationVisitor::visit(CumulativeRewardFormula const&, boost::any const&) const { return FormulaInformation(); } boost::any FormulaInformationVisitor::visit(EventuallyFormula const& f, boost::any const& data) const { - return f.getSubformula().accept(*this); + return f.getSubformula().accept(*this, data); } boost::any FormulaInformationVisitor::visit(TimeOperatorFormula const& f, boost::any const& data) const { - return f.getSubformula().accept(*this); + return f.getSubformula().accept(*this, data); } boost::any FormulaInformationVisitor::visit(GloballyFormula const& f, boost::any const& data) const { - return f.getSubformula().accept(*this); + return f.getSubformula().accept(*this, data); } - boost::any FormulaInformationVisitor::visit(InstantaneousRewardFormula const& f, boost::any const& data) const { + boost::any FormulaInformationVisitor::visit(InstantaneousRewardFormula const&, boost::any const&) const { return FormulaInformation(); } boost::any FormulaInformationVisitor::visit(LongRunAverageOperatorFormula const& f, boost::any const& data) const { - return f.getSubformula().accept(*this); + return f.getSubformula().accept(*this, data); } - boost::any FormulaInformationVisitor::visit(LongRunAverageRewardFormula const& f, boost::any const& data) const { + boost::any FormulaInformationVisitor::visit(LongRunAverageRewardFormula const&, boost::any const&) const { return FormulaInformation(); } boost::any FormulaInformationVisitor::visit(MultiObjectiveFormula const& f, boost::any const& data) const { FormulaInformation result; for(auto const& subF : f.getSubformulas()){ - result.join(boost::any_cast(subF->accept(*this))); + result.join(boost::any_cast(subF->accept(*this, data))); } return result; } boost::any FormulaInformationVisitor::visit(NextFormula const& f, boost::any const& data) const { - return boost::any_cast(f.getSubformula().accept(*this)).setContainsNextFormula(); + return boost::any_cast(f.getSubformula().accept(*this, data)).setContainsNextFormula(); } boost::any FormulaInformationVisitor::visit(ProbabilityOperatorFormula const& f, boost::any const& data) const { - return f.getSubformula().accept(*this); + return f.getSubformula().accept(*this, data); } boost::any FormulaInformationVisitor::visit(RewardOperatorFormula const& f, boost::any const& data) const { - return boost::any_cast(f.getSubformula().accept(*this)).setContainsRewardOperator(); + return boost::any_cast(f.getSubformula().accept(*this, data)).setContainsRewardOperator(); } - boost::any FormulaInformationVisitor::visit(TotalRewardFormula const& f, boost::any const& data) const { + boost::any FormulaInformationVisitor::visit(TotalRewardFormula const&, boost::any const&) const { return FormulaInformation(); } boost::any FormulaInformationVisitor::visit(UnaryBooleanStateFormula const& f, boost::any const& data) const { - return f.getSubformula().accept(*this); + return f.getSubformula().accept(*this, data); } boost::any FormulaInformationVisitor::visit(UntilFormula const& f, boost::any const& data) const { - return boost::any_cast(f.getLeftSubformula().accept(*this)).join(boost::any_cast(f.getRightSubformula().accept(*this))); + return boost::any_cast(f.getLeftSubformula().accept(*this, data)).join(boost::any_cast(f.getRightSubformula().accept(*this))); } } diff --git a/src/storm/logic/FragmentChecker.cpp b/src/storm/logic/FragmentChecker.cpp index 0b2b1a81b..c47b8ea5d 100644 --- a/src/storm/logic/FragmentChecker.cpp +++ b/src/storm/logic/FragmentChecker.cpp @@ -28,12 +28,12 @@ namespace storm { return result; } - boost::any FragmentChecker::visit(AtomicExpressionFormula const& f, boost::any const& data) const { + boost::any FragmentChecker::visit(AtomicExpressionFormula const&, boost::any const& data) const { InheritedInformation const& inherited = boost::any_cast(data); return inherited.getSpecification().areAtomicExpressionFormulasAllowed(); } - boost::any FragmentChecker::visit(AtomicLabelFormula const& f, boost::any const& data) const { + boost::any FragmentChecker::visit(AtomicLabelFormula const&, boost::any const& data) const { InheritedInformation const& inherited = boost::any_cast(data); return inherited.getSpecification().areAtomicLabelFormulasAllowed(); } @@ -46,7 +46,7 @@ namespace storm { return result; } - boost::any FragmentChecker::visit(BooleanLiteralFormula const& f, boost::any const& data) const { + boost::any FragmentChecker::visit(BooleanLiteralFormula const&, boost::any const& data) const { InheritedInformation const& inherited = boost::any_cast(data); return inherited.getSpecification().areBooleanLiteralFormulasAllowed(); } @@ -58,7 +58,7 @@ namespace storm { result = result && !f.getLeftSubformula().isPathFormula(); result = result && !f.getRightSubformula().isPathFormula(); } - if (f.hasDiscreteTimeBound()) { + if (f.isStepBounded()) { result = result && inherited.getSpecification().areStepBoundedUntilFormulasAllowed(); } else { result = result && inherited.getSpecification().areTimeBoundedUntilFormulasAllowed(); @@ -88,7 +88,7 @@ namespace storm { return result; } - boost::any FragmentChecker::visit(CumulativeRewardFormula const& f, boost::any const& data) const { + boost::any FragmentChecker::visit(CumulativeRewardFormula const&, boost::any const& data) const { InheritedInformation const& inherited = boost::any_cast(data); return inherited.getSpecification().areCumulativeRewardFormulasAllowed(); } @@ -137,7 +137,7 @@ namespace storm { return result; } - boost::any FragmentChecker::visit(InstantaneousRewardFormula const& f, boost::any const& data) const { + boost::any FragmentChecker::visit(InstantaneousRewardFormula const&, boost::any const& data) const { InheritedInformation const& inherited = boost::any_cast(data); return inherited.getSpecification().areInstantaneousRewardFormulasAllowed(); } @@ -154,7 +154,7 @@ namespace storm { return result; } - boost::any FragmentChecker::visit(LongRunAverageRewardFormula const& f, boost::any const& data) const { + boost::any FragmentChecker::visit(LongRunAverageRewardFormula const&, boost::any const& data) const { InheritedInformation const& inherited = boost::any_cast(data); return inherited.getSpecification().areLongRunAverageRewardFormulasAllowed(); } @@ -219,7 +219,7 @@ namespace storm { return result; } - boost::any FragmentChecker::visit(TotalRewardFormula const& f, boost::any const& data) const { + boost::any FragmentChecker::visit(TotalRewardFormula const&, boost::any const& data) const { InheritedInformation const& inherited = boost::any_cast(data); return inherited.getSpecification().areTotalRewardFormulasAllowed(); } diff --git a/src/storm/logic/FragmentSpecification.cpp b/src/storm/logic/FragmentSpecification.cpp index 4720c2e6b..0d4771552 100644 --- a/src/storm/logic/FragmentSpecification.cpp +++ b/src/storm/logic/FragmentSpecification.cpp @@ -39,6 +39,7 @@ namespace storm { pctl.setUntilFormulasAllowed(true); pctl.setBoundedUntilFormulasAllowed(true); pctl.setStepBoundedUntilFormulasAllowed(true); + pctl.setTimeBoundedUntilFormulasAllowed(true); return pctl; } @@ -97,6 +98,7 @@ namespace storm { multiObjective.setTotalRewardFormulasAllowed(true); multiObjective.setBoundedUntilFormulasAllowed(true); multiObjective.setStepBoundedUntilFormulasAllowed(true); + multiObjective.setTimeBoundedUntilFormulasAllowed(true); return multiObjective; } @@ -323,7 +325,6 @@ namespace storm { return *this; } - bool FragmentSpecification::areTotalRewardFormulasAllowed() const { return totalRewardFormula; } diff --git a/src/storm/logic/InstantaneousRewardFormula.cpp b/src/storm/logic/InstantaneousRewardFormula.cpp index d783fac79..f702ca578 100644 --- a/src/storm/logic/InstantaneousRewardFormula.cpp +++ b/src/storm/logic/InstantaneousRewardFormula.cpp @@ -2,16 +2,16 @@ #include "storm/logic/FormulaVisitor.h" +#include "storm/utility/macros.h" +#include "storm/exceptions/InvalidPropertyException.h" +#include "storm/exceptions/InvalidOperationException.h" + namespace storm { namespace logic { - InstantaneousRewardFormula::InstantaneousRewardFormula(uint_fast64_t timeBound) : timeBound(timeBound) { + InstantaneousRewardFormula::InstantaneousRewardFormula(storm::expressions::Expression const& bound, TimeBoundType const& timeBoundType) : timeBoundType(timeBoundType), bound(bound) { // Intentionally left empty. } - InstantaneousRewardFormula::InstantaneousRewardFormula(double timeBound) : timeBound(timeBound) { - // Intentionally left empty. - } - bool InstantaneousRewardFormula::isInstantaneousRewardFormula() const { return true; } @@ -24,32 +24,48 @@ namespace storm { return visitor.visit(*this, data); } - bool InstantaneousRewardFormula::hasDiscreteTimeBound() const { - return timeBound.which() == 0; + TimeBoundType const& InstantaneousRewardFormula::getTimeBoundType() const { + return timeBoundType; + } + + bool InstantaneousRewardFormula::isStepBounded() const { + return timeBoundType == TimeBoundType::Steps; + } + + bool InstantaneousRewardFormula::isTimeBounded() const { + return timeBoundType == TimeBoundType::Time; + } + + bool InstantaneousRewardFormula::hasIntegerBound() const { + return bound.hasIntegerType(); } - uint_fast64_t InstantaneousRewardFormula::getDiscreteTimeBound() const { - return boost::get(timeBound); + storm::expressions::Expression const& InstantaneousRewardFormula::getBound() const { + return bound; } - bool InstantaneousRewardFormula::hasContinuousTimeBound() const { - return timeBound.which() == 1; + template <> + double InstantaneousRewardFormula::getBound() const { + checkNoVariablesInBound(bound); + double value = bound.evaluateAsDouble(); + STORM_LOG_THROW(value >= 0, storm::exceptions::InvalidPropertyException, "Time-bound must not evaluate to negative number."); + return value; } - double InstantaneousRewardFormula::getContinuousTimeBound() const { - if (this->hasDiscreteTimeBound()) { - return this->getDiscreteTimeBound(); - } else { - return boost::get(timeBound); - } + template <> + uint64_t InstantaneousRewardFormula::getBound() const { + checkNoVariablesInBound(bound); + uint64_t value = bound.evaluateAsInt(); + STORM_LOG_THROW(value >= 0, storm::exceptions::InvalidPropertyException, "Time-bound must not evaluate to negative number."); + return value; } - + + void InstantaneousRewardFormula::checkNoVariablesInBound(storm::expressions::Expression const& bound) { + STORM_LOG_THROW(!bound.containsVariables(), storm::exceptions::InvalidOperationException, "Cannot evaluate time-instant '" << bound << "' as it contains undefined constants."); + } + std::ostream& InstantaneousRewardFormula::writeToStream(std::ostream& out) const { - if (this->hasDiscreteTimeBound()) { - out << "I=" << this->getDiscreteTimeBound(); - } else { - out << "I=" << this->getContinuousTimeBound(); - } + out << "I=" << this->getBound(); return out; } } diff --git a/src/storm/logic/InstantaneousRewardFormula.h b/src/storm/logic/InstantaneousRewardFormula.h index beecbfb17..ee9b5b28f 100644 --- a/src/storm/logic/InstantaneousRewardFormula.h +++ b/src/storm/logic/InstantaneousRewardFormula.h @@ -1,18 +1,17 @@ #ifndef STORM_LOGIC_INSTANTANEOUSREWARDFORMULA_H_ #define STORM_LOGIC_INSTANTANEOUSREWARDFORMULA_H_ -#include - #include "storm/logic/PathFormula.h" +#include "storm/logic/TimeBoundType.h" +#include "storm/storage/expressions/Expression.h" + namespace storm { namespace logic { class InstantaneousRewardFormula : public PathFormula { public: - InstantaneousRewardFormula(uint_fast64_t timeBound); - - InstantaneousRewardFormula(double timeBound); - + InstantaneousRewardFormula(storm::expressions::Expression const& bound, TimeBoundType const& timeBoundType = TimeBoundType::Time); + virtual ~InstantaneousRewardFormula() { // Intentionally left empty. } @@ -25,16 +24,22 @@ namespace storm { virtual std::ostream& writeToStream(std::ostream& out) const override; - bool hasDiscreteTimeBound() const; + TimeBoundType const& getTimeBoundType() const; + bool isStepBounded() const; + bool isTimeBounded() const; - uint_fast64_t getDiscreteTimeBound() const; - - bool hasContinuousTimeBound() const; + bool hasIntegerBound() const; + + storm::expressions::Expression const& getBound() const; + + template + ValueType getBound() const; - double getContinuousTimeBound() const; - private: - boost::variant timeBound; + static void checkNoVariablesInBound(storm::expressions::Expression const& bound); + + TimeBoundType timeBoundType; + storm::expressions::Expression bound; }; } } diff --git a/src/storm/logic/LabelSubstitutionVisitor.cpp b/src/storm/logic/LabelSubstitutionVisitor.cpp index 6a245aab8..1e17649a3 100644 --- a/src/storm/logic/LabelSubstitutionVisitor.cpp +++ b/src/storm/logic/LabelSubstitutionVisitor.cpp @@ -5,22 +5,35 @@ namespace storm { namespace logic { - LabelSubstitutionVisitor::LabelSubstitutionVisitor(std::map const& labelToExpressionMapping) : labelToExpressionMapping(labelToExpressionMapping) { + LabelSubstitutionVisitor::LabelSubstitutionVisitor(std::map const& labelToExpressionMapping) : labelToExpressionMapping(&labelToExpressionMapping), labelToLabelMapping(nullptr) { // Intentionally left empty. } + LabelSubstitutionVisitor::LabelSubstitutionVisitor(std::map const& labelToLabelMapping) : labelToExpressionMapping(nullptr), labelToLabelMapping(&labelToLabelMapping) { + // Intentionally left empty. + } + std::shared_ptr LabelSubstitutionVisitor::substitute(Formula const& f) const { boost::any result = f.accept(*this, boost::any()); return boost::any_cast>(result); } - boost::any LabelSubstitutionVisitor::visit(AtomicLabelFormula const& f, boost::any const& data) const { - auto it = labelToExpressionMapping.find(f.getLabel()); - if (it != labelToExpressionMapping.end()) { - return std::static_pointer_cast(std::make_shared(it->second)); + boost::any LabelSubstitutionVisitor::visit(AtomicLabelFormula const& f, boost::any const&) const { + if (labelToExpressionMapping) { + auto it = labelToExpressionMapping->find(f.getLabel()); + if (it != labelToExpressionMapping->end()) { + return std::static_pointer_cast(std::make_shared(it->second)); + } else { + return f.asSharedPointer(); + } } else { - return std::static_pointer_cast(std::make_shared(f)); + auto it = labelToLabelMapping->find(f.getLabel()); + if (it != labelToLabelMapping->end()) { + return std::static_pointer_cast(std::make_shared(it->second)); + } else { + return f.asSharedPointer(); + } } - } + } } } diff --git a/src/storm/logic/LabelSubstitutionVisitor.h b/src/storm/logic/LabelSubstitutionVisitor.h index 928380be5..cac04fa72 100644 --- a/src/storm/logic/LabelSubstitutionVisitor.h +++ b/src/storm/logic/LabelSubstitutionVisitor.h @@ -13,13 +13,15 @@ namespace storm { class LabelSubstitutionVisitor : public CloneVisitor { public: LabelSubstitutionVisitor(std::map const& labelToExpressionMapping); + LabelSubstitutionVisitor(std::map const& labelToLabelMapping); std::shared_ptr substitute(Formula const& f) const; virtual boost::any visit(AtomicLabelFormula const& f, boost::any const& data) const override; private: - std::map const& labelToExpressionMapping; + std::map const* labelToExpressionMapping; + std::map const* labelToLabelMapping; }; } diff --git a/src/storm/logic/OperatorFormula.cpp b/src/storm/logic/OperatorFormula.cpp index a0607aa7a..93b692e98 100644 --- a/src/storm/logic/OperatorFormula.cpp +++ b/src/storm/logic/OperatorFormula.cpp @@ -15,6 +15,7 @@ namespace storm { } ComparisonType OperatorFormula::getComparisonType() const { + STORM_LOG_ASSERT(operatorInformation.bound.is_initialized(), "Cannot get Formula comparison type (has no bound?)"); return operatorInformation.bound.get().comparisonType; } diff --git a/src/storm/logic/TimeBound.cpp b/src/storm/logic/TimeBound.cpp new file mode 100644 index 000000000..7ecd05aea --- /dev/null +++ b/src/storm/logic/TimeBound.cpp @@ -0,0 +1,19 @@ +#include "storm/logic/TimeBound.h" + +namespace storm { + namespace logic { + + TimeBound::TimeBound(bool strict, storm::expressions::Expression const& bound) : strict(strict), bound(bound) { + // Intentionally left empty. + } + + storm::expressions::Expression const& TimeBound::getBound() const { + return bound; + } + + bool TimeBound::isStrict() const { + return strict; + } + + } +} diff --git a/src/storm/logic/TimeBound.h b/src/storm/logic/TimeBound.h new file mode 100644 index 000000000..17a4c2b41 --- /dev/null +++ b/src/storm/logic/TimeBound.h @@ -0,0 +1,21 @@ +#pragma once + +#include "storm/storage/expressions/Expression.h" + +namespace storm { + namespace logic { + + class TimeBound { + public: + TimeBound(bool strict, storm::expressions::Expression const& bound); + + storm::expressions::Expression const& getBound() const; + bool isStrict() const; + + private: + bool strict; + storm::expressions::Expression bound; + }; + + } +} diff --git a/src/storm/logic/TimeBoundType.h b/src/storm/logic/TimeBoundType.h new file mode 100644 index 000000000..aef71b040 --- /dev/null +++ b/src/storm/logic/TimeBoundType.h @@ -0,0 +1,12 @@ +#pragma once + +namespace storm { + namespace logic { + + enum class TimeBoundType { + Steps, + Time + }; + + } +} diff --git a/src/storm/logic/ToExpressionVisitor.cpp b/src/storm/logic/ToExpressionVisitor.cpp index a223a45da..ddfe0ea6d 100644 --- a/src/storm/logic/ToExpressionVisitor.cpp +++ b/src/storm/logic/ToExpressionVisitor.cpp @@ -15,11 +15,11 @@ namespace storm { return boost::any_cast(result); } - boost::any ToExpressionVisitor::visit(AtomicExpressionFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(AtomicExpressionFormula const& f, boost::any const&) const { return f.getExpression(); } - boost::any ToExpressionVisitor::visit(AtomicLabelFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(AtomicLabelFormula const& f, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression, because the undefined atomic label '" << f.getLabel() << "' appears in the formula."); } @@ -34,6 +34,7 @@ namespace storm { return left || right; break; } + return boost::any(); } boost::any ToExpressionVisitor::visit(BooleanLiteralFormula const& f, boost::any const& data) const { @@ -46,59 +47,59 @@ namespace storm { return result; } - boost::any ToExpressionVisitor::visit(BoundedUntilFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(BoundedUntilFormula const&, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression from formula that contains illegal elements."); } - boost::any ToExpressionVisitor::visit(ConditionalFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(ConditionalFormula const&, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression from formula that contains illegal elements."); } - boost::any ToExpressionVisitor::visit(CumulativeRewardFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(CumulativeRewardFormula const&, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression from formula that contains illegal elements."); } - boost::any ToExpressionVisitor::visit(EventuallyFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(EventuallyFormula const&, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression from formula that contains illegal elements."); } - boost::any ToExpressionVisitor::visit(TimeOperatorFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(TimeOperatorFormula const&, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression from formula that contains illegal elements."); } - boost::any ToExpressionVisitor::visit(GloballyFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(GloballyFormula const&, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression from formula that contains illegal elements."); } - boost::any ToExpressionVisitor::visit(InstantaneousRewardFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(InstantaneousRewardFormula const&, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression from formula that contains illegal elements."); } - boost::any ToExpressionVisitor::visit(LongRunAverageOperatorFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(LongRunAverageOperatorFormula const&, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression from formula that contains illegal elements."); } - boost::any ToExpressionVisitor::visit(LongRunAverageRewardFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(LongRunAverageRewardFormula const&, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression from formula that contains illegal elements."); } - boost::any ToExpressionVisitor::visit(MultiObjectiveFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(MultiObjectiveFormula const&, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression from formula that contains illegal elements."); } - boost::any ToExpressionVisitor::visit(NextFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(NextFormula const&, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression from formula that contains illegal elements."); } - boost::any ToExpressionVisitor::visit(ProbabilityOperatorFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(ProbabilityOperatorFormula const&, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression from formula that contains illegal elements."); } - boost::any ToExpressionVisitor::visit(RewardOperatorFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(RewardOperatorFormula const&, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression from formula that contains illegal elements."); } - boost::any ToExpressionVisitor::visit(TotalRewardFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(TotalRewardFormula const&, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression from formula that contains illegal elements."); } @@ -109,9 +110,10 @@ namespace storm { return !subexpression; break; } + return boost::any(); } - boost::any ToExpressionVisitor::visit(UntilFormula const& f, boost::any const& data) const { + boost::any ToExpressionVisitor::visit(UntilFormula const&, boost::any const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot assemble expression from formula that contains illegal elements."); } diff --git a/src/storm/logic/VariableSubstitutionVisitor.cpp b/src/storm/logic/VariableSubstitutionVisitor.cpp index 8f0d09faf..e0fe0630d 100644 --- a/src/storm/logic/VariableSubstitutionVisitor.cpp +++ b/src/storm/logic/VariableSubstitutionVisitor.cpp @@ -14,7 +14,31 @@ namespace storm { return boost::any_cast>(result); } - boost::any VariableSubstitutionVisitor::visit(AtomicExpressionFormula const& f, boost::any const& data) const { + boost::any VariableSubstitutionVisitor::visit(BoundedUntilFormula const& f, boost::any const& data) const { + auto left = boost::any_cast>(f.getLeftSubformula().accept(*this, data)); + auto right = boost::any_cast>(f.getRightSubformula().accept(*this, data)); + + boost::optional lowerBound; + if (f.hasLowerBound()) { + lowerBound = TimeBound(f.isLowerBoundStrict(), f.getLowerBound().substitute(substitution)); + } + boost::optional upperBound; + if (f.hasUpperBound()) { + upperBound = TimeBound(f.isUpperBoundStrict(), f.getUpperBound().substitute(substitution)); + } + + return std::static_pointer_cast(std::make_shared(left, right, lowerBound, upperBound, f.getTimeBoundType())); + } + + boost::any VariableSubstitutionVisitor::visit(CumulativeRewardFormula const& f, boost::any const& data) const { + return std::static_pointer_cast(std::make_shared(storm::logic::TimeBound(f.isBoundStrict(), f.getBound().substitute(substitution)), f.getTimeBoundType())); + } + + boost::any VariableSubstitutionVisitor::visit(InstantaneousRewardFormula const& f, boost::any const& data) const { + return std::static_pointer_cast(std::make_shared(f.getBound().substitute(substitution), f.getTimeBoundType())); + } + + boost::any VariableSubstitutionVisitor::visit(AtomicExpressionFormula const& f, boost::any const&) const { return std::static_pointer_cast(std::make_shared(f.getExpression().substitute(substitution))); } } diff --git a/src/storm/logic/VariableSubstitutionVisitor.h b/src/storm/logic/VariableSubstitutionVisitor.h index 4e15980c0..4f5c19e06 100644 --- a/src/storm/logic/VariableSubstitutionVisitor.h +++ b/src/storm/logic/VariableSubstitutionVisitor.h @@ -16,6 +16,9 @@ namespace storm { std::shared_ptr substitute(Formula const& f) const; + virtual boost::any visit(BoundedUntilFormula const& f, boost::any const& data) const override; + virtual boost::any visit(CumulativeRewardFormula const& f, boost::any const& data) const override; + virtual boost::any visit(InstantaneousRewardFormula const& f, boost::any const& data) const override; virtual boost::any visit(AtomicExpressionFormula const& f, boost::any const& data) const override; private: diff --git a/src/storm/modelchecker/AbstractModelChecker.cpp b/src/storm/modelchecker/AbstractModelChecker.cpp index 0eba3911b..e564aa0f6 100644 --- a/src/storm/modelchecker/AbstractModelChecker.cpp +++ b/src/storm/modelchecker/AbstractModelChecker.cpp @@ -105,27 +105,27 @@ namespace storm { } template - std::unique_ptr AbstractModelChecker::computeConditionalRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr AbstractModelChecker::computeConditionalRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "This model checker does not support the formula: " << checkTask.getFormula() << "."); } template - std::unique_ptr AbstractModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr AbstractModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "This model checker does not support the formula: " << checkTask.getFormula() << "."); } template - std::unique_ptr AbstractModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr AbstractModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "This model checker does not support the formula: " << checkTask.getFormula() << "."); } template - std::unique_ptr AbstractModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr AbstractModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "This model checker does not support the formula: " << checkTask.getFormula() << "."); } template - std::unique_ptr AbstractModelChecker::computeLongRunAverageRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr AbstractModelChecker::computeLongRunAverageRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "This model checker does not support the formula: " << checkTask.getFormula() << "."); } @@ -144,7 +144,7 @@ namespace storm { } template - std::unique_ptr AbstractModelChecker::computeReachabilityTimes(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr AbstractModelChecker::computeReachabilityTimes(storm::logic::RewardMeasureType, CheckTask const& checkTask) { STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "This model checker does not support the formula: " << checkTask.getFormula() << "."); } diff --git a/src/storm/modelchecker/CheckTask.h b/src/storm/modelchecker/CheckTask.h index 2f817e3d1..435a25e45 100644 --- a/src/storm/modelchecker/CheckTask.h +++ b/src/storm/modelchecker/CheckTask.h @@ -160,7 +160,14 @@ namespace storm { storm::logic::Bound const& getBound() const { return bound.get(); } - + + /*! + * Retrieves the bound (if set). + */ + boost::optional> const& getOptionalBound() const { + return bound; + } + /*! * Retrieves whether the computation only needs to be performed qualitatively, because the values will only * be compared to 0/1. diff --git a/src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.cpp b/src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.cpp new file mode 100644 index 000000000..b1468d87a --- /dev/null +++ b/src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.cpp @@ -0,0 +1,626 @@ +#include "storm/modelchecker/abstraction/GameBasedMdpModelChecker.h" + +#include "storm/modelchecker/results/ExplicitQuantitativeCheckResult.h" +#include "storm/modelchecker/results/ExplicitQualitativeCheckResult.h" + +#include "storm/models/symbolic/StandardRewardModel.h" +#include "storm/models/symbolic/Dtmc.h" +#include "storm/models/symbolic/Mdp.h" + +#include "storm/storage/expressions/ExpressionManager.h" +#include "storm/storage/expressions/VariableSetPredicateSplitter.h" + +#include "storm/storage/dd/DdManager.h" + +#include "storm/abstraction/prism/PrismMenuGameAbstractor.h" +#include "storm/abstraction/jani/JaniMenuGameAbstractor.h" +#include "storm/abstraction/MenuGameRefiner.h" + +#include "storm/logic/FragmentSpecification.h" + +#include "storm/solver/SymbolicGameSolver.h" + +#include "storm/settings/SettingsManager.h" +#include "storm/settings/modules/CoreSettings.h" +#include "storm/settings/modules/AbstractionSettings.h" + +#include "storm/utility/solver.h" +#include "storm/utility/prism.h" +#include "storm/utility/macros.h" + +#include "storm/exceptions/NotSupportedException.h" +#include "storm/exceptions/InvalidPropertyException.h" +#include "storm/exceptions/InvalidModelException.h" + +#include "storm/modelchecker/results/CheckResult.h" + +namespace storm { + namespace modelchecker { + + using storm::abstraction::QuantitativeResult; + using storm::abstraction::QuantitativeResultMinMax; + + template + GameBasedMdpModelChecker::GameBasedMdpModelChecker(storm::storage::SymbolicModelDescription const& model, std::shared_ptr const& smtSolverFactory) : smtSolverFactory(smtSolverFactory), comparator(storm::settings::getModule().getPrecision()), reuseQualitativeResults(false), reuseQuantitativeResults(false) { + model.requireNoUndefinedConstants(); + if (model.isPrismProgram()) { + storm::prism::Program const& originalProgram = model.asPrismProgram(); + STORM_LOG_THROW(originalProgram.getModelType() == storm::prism::Program::ModelType::DTMC || originalProgram.getModelType() == storm::prism::Program::ModelType::MDP, storm::exceptions::NotSupportedException, "Currently only DTMCs/MDPs are supported by the game-based model checker."); + + // Flatten the modules if there is more than one. + if (originalProgram.getNumberOfModules() > 1) { + preprocessedModel = originalProgram.flattenModules(this->smtSolverFactory); + } else { + preprocessedModel = originalProgram; + } + + STORM_LOG_TRACE("Game-based model checker got program " << preprocessedModel.asPrismProgram()); + } else { + storm::jani::Model const& originalModel = model.asJaniModel(); + STORM_LOG_THROW(originalModel.getModelType() == storm::jani::ModelType::DTMC || originalModel.getModelType() == storm::jani::ModelType::MDP, storm::exceptions::NotSupportedException, "Currently only DTMCs/MDPs are supported by the game-based model checker."); + + // Flatten the parallel composition. + preprocessedModel = model.asJaniModel().flattenComposition(); + } + + storm::settings::modules::AbstractionSettings::ReuseMode reuseMode = storm::settings::getModule().getReuseMode(); + reuseQualitativeResults = reuseMode == storm::settings::modules::AbstractionSettings::ReuseMode::All || reuseMode == storm::settings::modules::AbstractionSettings::ReuseMode::Qualitative; + reuseQuantitativeResults = reuseMode == storm::settings::modules::AbstractionSettings::ReuseMode::All || reuseMode == storm::settings::modules::AbstractionSettings::ReuseMode::Quantitative; + } + + template + bool GameBasedMdpModelChecker::canHandle(CheckTask const& checkTask) const { + storm::logic::Formula const& formula = checkTask.getFormula(); + storm::logic::FragmentSpecification fragment = storm::logic::reachability(); + return formula.isInFragment(fragment) && checkTask.isOnlyInitialStatesRelevantSet(); + } + + template + std::unique_ptr GameBasedMdpModelChecker::computeUntilProbabilities(CheckTask const& checkTask) { + storm::logic::UntilFormula const& pathFormula = checkTask.getFormula(); + std::map labelToExpressionMapping; + if (preprocessedModel.isPrismProgram()) { + labelToExpressionMapping = preprocessedModel.asPrismProgram().getLabelToExpressionMapping(); + } else { + storm::jani::Model const& janiModel = preprocessedModel.asJaniModel(); + for (auto const& variable : janiModel.getGlobalVariables().getBooleanVariables()) { + if (variable.isTransient()) { + labelToExpressionMapping[variable.getName()] = janiModel.getLabelExpression(variable.asBooleanVariable()); + } + } + } + + storm::expressions::Expression constraintExpression = pathFormula.getLeftSubformula().toExpression(preprocessedModel.getManager(), labelToExpressionMapping); + storm::expressions::Expression targetStateExpression = pathFormula.getRightSubformula().toExpression(preprocessedModel.getManager(), labelToExpressionMapping); + + return performGameBasedAbstractionRefinement(checkTask.substituteFormula(pathFormula), constraintExpression, targetStateExpression); + } + + template + std::unique_ptr GameBasedMdpModelChecker::computeReachabilityProbabilities(CheckTask const& checkTask) { + storm::logic::EventuallyFormula const& pathFormula = checkTask.getFormula(); + std::map labelToExpressionMapping; + if (preprocessedModel.isPrismProgram()) { + labelToExpressionMapping = preprocessedModel.asPrismProgram().getLabelToExpressionMapping(); + } else { + storm::jani::Model const& janiModel = preprocessedModel.asJaniModel(); + for (auto const& variable : janiModel.getGlobalVariables().getBooleanVariables()) { + if (variable.isTransient()) { + labelToExpressionMapping[variable.getName()] = janiModel.getLabelExpression(variable.asBooleanVariable()); + } + } + } + + storm::expressions::Expression constraintExpression = preprocessedModel.getManager().boolean(true); + storm::expressions::Expression targetStateExpression = pathFormula.getSubformula().toExpression(preprocessedModel.getManager(), labelToExpressionMapping); + + return performGameBasedAbstractionRefinement(checkTask.substituteFormula(pathFormula), constraintExpression, targetStateExpression); + } + + template + std::unique_ptr checkForResultAfterQualitativeCheck(CheckTask const& checkTask, storm::OptimizationDirection player2Direction, storm::dd::Bdd const& initialStates, storm::dd::Bdd const& prob0, storm::dd::Bdd const& prob1) { + std::unique_ptr result; + + boost::optional> const& bound = checkTask.getOptionalBound(); + if (bound) { + // Despite having a bound, we create a quanitative result so that the next layer can perform the comparison. + + if (player2Direction == storm::OptimizationDirection::Minimize) { + if (storm::logic::isLowerBound(bound.get().comparisonType)) { + if ((prob1 && initialStates) == initialStates) { + result = std::make_unique>(storm::storage::sparse::state_type(0), storm::utility::one()); + } + } else { + if (!(prob1 && initialStates).isZero()) { + result = std::make_unique>(storm::storage::sparse::state_type(0), storm::utility::one()); + } + } + } else if (player2Direction == storm::OptimizationDirection::Maximize) { + if (!storm::logic::isLowerBound(bound.get().comparisonType)) { + if ((prob0 && initialStates) == initialStates) { + result = std::make_unique>(storm::storage::sparse::state_type(0), storm::utility::zero()); + } + } else { + if (!(prob0 && initialStates).isZero()) { + result = std::make_unique>(storm::storage::sparse::state_type(0), storm::utility::zero()); + } + } + } + } + + return result; + } + + template + std::unique_ptr checkForResultAfterQualitativeCheck(CheckTask const& checkTask, storm::dd::Bdd const& initialStates, QualitativeResultMinMax const& qualitativeResult) { + // Check whether we can already give the answer based on the current information. + std::unique_ptr result = checkForResultAfterQualitativeCheck(checkTask, storm::OptimizationDirection::Minimize, initialStates, qualitativeResult.prob0Min.getPlayer1States(), qualitativeResult.prob1Min.getPlayer1States()); + if (result) { + return result; + } + result = checkForResultAfterQualitativeCheck(checkTask, storm::OptimizationDirection::Maximize, initialStates, qualitativeResult.prob0Max.getPlayer1States(), qualitativeResult.prob1Max.getPlayer1States()); + if (result) { + return result; + } + return result; + } + + template + std::unique_ptr checkForResultAfterQuantitativeCheck(CheckTask const& checkTask, storm::OptimizationDirection const& player2Direction, std::pair const& initialValueRange) { + std::unique_ptr result; + + // If the minimum value exceeds an upper threshold or the maximum value is below a lower threshold, we can + // return the value because the property will definitely hold. Vice versa, if the minimum value exceeds an + // upper bound or the maximum value is below a lower bound, the property will definitely not hold and we can + // return the value. + boost::optional> const& bound = checkTask.getOptionalBound(); + if (!bound) { + return result; + } + + ValueType const& lowerValue = initialValueRange.first; + ValueType const& upperValue = initialValueRange.second; + + storm::logic::ComparisonType comparisonType = bound.get().comparisonType; + ValueType threshold = bound.get().threshold; + + if (storm::logic::isLowerBound(comparisonType)) { + if (player2Direction == storm::OptimizationDirection::Minimize) { + if ((storm::logic::isStrict(comparisonType) && lowerValue > threshold) + || (!storm::logic::isStrict(comparisonType) && lowerValue >= threshold)) { + result = std::make_unique>(storm::storage::sparse::state_type(0), lowerValue); + } + } else { + if ((storm::logic::isStrict(comparisonType) && upperValue <= threshold) + || (!storm::logic::isStrict(comparisonType) && upperValue < threshold)) { + result = std::make_unique>(storm::storage::sparse::state_type(0), upperValue); + } + } + } else { + if (player2Direction == storm::OptimizationDirection::Maximize) { + if ((storm::logic::isStrict(comparisonType) && upperValue < threshold) || + (!storm::logic::isStrict(comparisonType) && upperValue <= threshold)) { + result = std::make_unique>(storm::storage::sparse::state_type(0), upperValue); + } + } else { + if ((storm::logic::isStrict(comparisonType) && lowerValue >= threshold) || + (!storm::logic::isStrict(comparisonType) && lowerValue > threshold)) { + result = std::make_unique>(storm::storage::sparse::state_type(0), lowerValue); + } + } + } + + return result; + } + + template + std::unique_ptr checkForResultAfterQuantitativeCheck(ValueType const& minValue, ValueType const& maxValue, storm::utility::ConstantsComparator const& comparator) { + std::unique_ptr result; + + // If the lower and upper bounds are close enough, we can return the result. + if (comparator.isEqual(minValue, maxValue)) { + result = std::make_unique>(storm::storage::sparse::state_type(0), (minValue + maxValue) / ValueType(2)); + } + + return result; + } + + template + QuantitativeResult solveMaybeStates(storm::OptimizationDirection const& player1Direction, storm::OptimizationDirection const& player2Direction, storm::abstraction::MenuGame const& game, storm::dd::Bdd const& maybeStates, storm::dd::Bdd const& prob1States, boost::optional> const& startInfo = boost::none) { + + STORM_LOG_TRACE("Performing quantative solution step. Player 1: " << player1Direction << ", player 2: " << player2Direction << "."); + + // Compute the ingredients of the equation system. + storm::dd::Add maybeStatesAdd = maybeStates.template toAdd(); + storm::dd::Add submatrix = maybeStatesAdd * game.getTransitionMatrix(); + storm::dd::Add prob1StatesAsColumn = prob1States.template toAdd().swapVariables(game.getRowColumnMetaVariablePairs()); + storm::dd::Add subvector = submatrix * prob1StatesAsColumn; + subvector = subvector.sumAbstract(game.getColumnVariables()); + + // Cut away all columns targeting non-maybe states. + submatrix *= maybeStatesAdd.swapVariables(game.getRowColumnMetaVariablePairs()); + + // Cut the starting vector to the maybe states of this query. + storm::dd::Add startVector; + if (startInfo) { + startVector = startInfo.get().values * maybeStatesAdd; + } else { + startVector = game.getManager().template getAddZero(); + } + + // Create the solver and solve the equation system. + storm::utility::solver::SymbolicGameSolverFactory solverFactory; + std::unique_ptr> solver = solverFactory.create(submatrix, maybeStates, game.getIllegalPlayer1Mask(), game.getIllegalPlayer2Mask(), game.getRowVariables(), game.getColumnVariables(), game.getRowColumnMetaVariablePairs(), game.getPlayer1Variables(), game.getPlayer2Variables()); + solver->setGeneratePlayersStrategies(true); + auto values = solver->solveGame(player1Direction, player2Direction, startVector, subvector, startInfo ? boost::make_optional(startInfo.get().player1Strategy) : boost::none, startInfo ? boost::make_optional(startInfo.get().player2Strategy) : boost::none); + return QuantitativeResult(std::make_pair(storm::utility::zero(), storm::utility::one()), values, solver->getPlayer1Strategy(), solver->getPlayer2Strategy()); + } + + template + QuantitativeResult computeQuantitativeResult(storm::OptimizationDirection player1Direction, storm::OptimizationDirection player2Direction, storm::abstraction::MenuGame const& game, QualitativeResultMinMax const& qualitativeResult, storm::dd::Add const& initialStatesAdd, storm::dd::Bdd const& maybeStates, boost::optional> const& startInfo = boost::none) { + + bool min = player2Direction == storm::OptimizationDirection::Minimize; + QuantitativeResult result; + + // We fix the strategies. That is, we take the decisions of the strategies obtained in the qualitiative + // preprocessing if possible. + storm::dd::Bdd combinedPlayer1QualitativeStrategies; + storm::dd::Bdd combinedPlayer2QualitativeStrategies; + if (min) { + combinedPlayer1QualitativeStrategies = (qualitativeResult.prob0Min.getPlayer1Strategy() || qualitativeResult.prob1Min.getPlayer1Strategy()); + combinedPlayer2QualitativeStrategies = (qualitativeResult.prob0Min.getPlayer2Strategy() || qualitativeResult.prob1Min.getPlayer2Strategy()); + } else { + combinedPlayer1QualitativeStrategies = (qualitativeResult.prob0Max.getPlayer1Strategy() || qualitativeResult.prob1Max.getPlayer1Strategy()); + combinedPlayer2QualitativeStrategies = (qualitativeResult.prob0Max.getPlayer2Strategy() || qualitativeResult.prob1Max.getPlayer2Strategy()); + } + + result.player1Strategy = combinedPlayer1QualitativeStrategies; + result.player2Strategy = combinedPlayer2QualitativeStrategies; + result.values = game.getManager().template getAddZero(); + + auto start = std::chrono::high_resolution_clock::now(); + if (!maybeStates.isZero()) { + STORM_LOG_TRACE("Solving " << maybeStates.getNonZeroCount() << " maybe states."); + + // Solve the quantitative values of maybe states. + result = solveMaybeStates(player1Direction, player2Direction, game, maybeStates, min ? qualitativeResult.prob1Min.getPlayer1States() : qualitativeResult.prob1Max.getPlayer1States(), startInfo); + + // Cut the obtained strategies to the reachable states of the game. + result.player1Strategy &= game.getReachableStates(); + result.player2Strategy &= game.getReachableStates(); + + // Extend the values of the maybe states by the qualitative values. + result.values += min ? qualitativeResult.prob1Min.getPlayer1States().template toAdd() : qualitativeResult.prob1Max.getPlayer1States().template toAdd(); + } else { + STORM_LOG_TRACE("No maybe states."); + + // Extend the values of the maybe states by the qualitative values. + result.values += min ? qualitativeResult.prob1Min.getPlayer1States().template toAdd() : qualitativeResult.prob1Max.getPlayer1States().template toAdd(); + } + + // Construct an ADD holding the initial values of initial states and extract the bound on the initial states. + storm::dd::Add initialStateValueAdd = initialStatesAdd * result.values; + + ValueType maxValueOverInitialStates = initialStateValueAdd.getMax(); + initialStateValueAdd += (!game.getInitialStates()).template toAdd(); + ValueType minValueOverInitialStates = initialStateValueAdd.getMin(); + + result.initialStatesRange = std::make_pair(minValueOverInitialStates, maxValueOverInitialStates); + + result.player1Strategy = combinedPlayer1QualitativeStrategies.existsAbstract(game.getPlayer1Variables()).ite(combinedPlayer1QualitativeStrategies, result.player1Strategy); + result.player2Strategy = combinedPlayer2QualitativeStrategies.existsAbstract(game.getPlayer2Variables()).ite(combinedPlayer2QualitativeStrategies, result.player2Strategy); + + auto end = std::chrono::high_resolution_clock::now(); + STORM_LOG_TRACE("Obtained quantitative " << (min ? "lower" : "upper") << " bound " << (min ? result.initialStatesRange.first : result.initialStatesRange.second) << " in " << std::chrono::duration_cast(end - start).count() << "ms."); + + return result; + } + + template + std::unique_ptr GameBasedMdpModelChecker::performGameBasedAbstractionRefinement(CheckTask const& checkTask, storm::expressions::Expression const& constraintExpression, storm::expressions::Expression const& targetStateExpression) { + STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidPropertyException, "The game-based abstraction refinement model checker can only compute the result for the initial states."); + + // Optimization: do not compute both bounds if not necessary (e.g. if bound given and exceeded, etc.) + + // Set up initial predicates. + std::vector initialPredicates = getInitialPredicates(constraintExpression, targetStateExpression); + + // Derive the optimization direction for player 1 (assuming menu-game abstraction). + storm::OptimizationDirection player1Direction = getPlayer1Direction(checkTask); + + // Create the abstractor. + std::shared_ptr> abstractor; + if (preprocessedModel.isPrismProgram()) { + abstractor = std::make_shared>(preprocessedModel.asPrismProgram(), smtSolverFactory); + } else { + abstractor = std::make_shared>(preprocessedModel.asJaniModel(), smtSolverFactory); + } + + // Create a refiner that can be used to refine the abstraction when needed. + storm::abstraction::MenuGameRefiner refiner(*abstractor, smtSolverFactory->create(preprocessedModel.getManager())); + refiner.refine(initialPredicates); + + storm::dd::Bdd globalConstraintStates = abstractor->getStates(constraintExpression); + storm::dd::Bdd globalTargetStates = abstractor->getStates(targetStateExpression); + + // Enter the main-loop of abstraction refinement. + boost::optional> previousQualitativeResult = boost::none; + boost::optional> previousMinQuantitativeResult = boost::none; + for (uint_fast64_t iterations = 0; iterations < 10000; ++iterations) { + auto iterationStart = std::chrono::high_resolution_clock::now(); + STORM_LOG_TRACE("Starting iteration " << iterations << "."); + + // (1) build the abstraction. + auto abstractionStart = std::chrono::high_resolution_clock::now(); + storm::abstraction::MenuGame game = abstractor->abstract(); + auto abstractionEnd = std::chrono::high_resolution_clock::now(); + STORM_LOG_DEBUG("Abstraction in iteration " << iterations << " has " << game.getNumberOfStates() << " (player 1) states and " << game.getNumberOfTransitions() << " transitions (computed in " << std::chrono::duration_cast(abstractionEnd - abstractionStart).count() << "ms)."); + + // (2) Prepare transition matrix BDD and target state BDD for later use. + storm::dd::Bdd transitionMatrixBdd = game.getTransitionMatrix().toBdd(); + storm::dd::Bdd initialStates = game.getInitialStates(); + STORM_LOG_THROW(initialStates.getNonZeroCount() == 1 || checkTask.isBoundSet(), storm::exceptions::InvalidPropertyException, "Game-based abstraction refinement requires a bound on the formula for model with " << initialStates.getNonZeroCount() << " initial states."); + storm::dd::Bdd constraintStates = globalConstraintStates && game.getReachableStates(); + storm::dd::Bdd targetStates = globalTargetStates && game.getReachableStates(); + if (player1Direction == storm::OptimizationDirection::Minimize) { + targetStates |= game.getBottomStates(); + } + + // #ifdef LOCAL_DEBUG + // targetStates.template toAdd().exportToDot("target.dot"); + // abstractor->exportToDot("game" + std::to_string(iterations) + ".dot", targetStates, game.getManager().getBddOne()); + // game.getReachableStates().template toAdd().exportToDot("reach.dot"); + // #endif + + // (3) compute all states with probability 0/1 wrt. to the two different player 2 goals (min/max). + auto qualitativeStart = std::chrono::high_resolution_clock::now(); + QualitativeResultMinMax qualitativeResult = computeProb01States(previousQualitativeResult, game, player1Direction, transitionMatrixBdd, constraintStates, targetStates); + std::unique_ptr result = checkForResultAfterQualitativeCheck(checkTask, initialStates, qualitativeResult); + if (result) { + printStatistics(*abstractor, game); + return result; + } + previousQualitativeResult = qualitativeResult; + auto qualitativeEnd = std::chrono::high_resolution_clock::now(); + STORM_LOG_DEBUG("Qualitative computation completed in " << std::chrono::duration_cast(qualitativeEnd - qualitativeStart).count() << "ms."); + + // (4) compute the states for which we have to determine quantitative information. + storm::dd::Bdd maybeMin = !(qualitativeResult.prob0Min.getPlayer1States() || qualitativeResult.prob1Min.getPlayer1States()) && game.getReachableStates(); + storm::dd::Bdd maybeMax = !(qualitativeResult.prob0Max.getPlayer1States() || qualitativeResult.prob1Max.getPlayer1States()) && game.getReachableStates(); + + // (5) if the initial states are not maybe states, then we can refine at this point. + storm::dd::Bdd initialMaybeStates = (initialStates && maybeMin) || (initialStates && maybeMax); + bool qualitativeRefinement = false; + if (initialMaybeStates.isZero()) { + // In this case, we know the result for the initial states for both player 2 minimizing and maximizing. + STORM_LOG_TRACE("No initial state is a 'maybe' state."); + + STORM_LOG_DEBUG("Obtained qualitative bounds [0, 1] on the actual value for the initial states. Refining abstraction based on qualitative check."); + + // If we get here, the initial states were all identified as prob0/1 states, but the value (0 or 1) + // depends on whether player 2 is minimizing or maximizing. Therefore, we need to find a place to refine. + auto qualitativeRefinementStart = std::chrono::high_resolution_clock::now(); + qualitativeRefinement = refiner.refine(game, transitionMatrixBdd, qualitativeResult); + auto qualitativeRefinementEnd = std::chrono::high_resolution_clock::now(); + STORM_LOG_DEBUG("Qualitative refinement completed in " << std::chrono::duration_cast(qualitativeRefinementEnd - qualitativeRefinementStart).count() << "ms."); + } else if (initialMaybeStates == initialStates && checkTask.isQualitativeSet()) { + // If all initial states are 'maybe' states and the property we needed to check is a qualitative one, + // we can return the result here. + return std::make_unique>(storm::storage::sparse::state_type(0), ValueType(0.5)); + } + + // (6) if we arrived at this point and no refinement was made, we need to compute the quantitative solution. + if (!qualitativeRefinement) { + // At this point, we know that we cannot answer the query without further numeric computation. + + storm::dd::Add initialStatesAdd = initialStates.template toAdd(); + + STORM_LOG_TRACE("Starting numerical solution step."); + auto quantitativeStart = std::chrono::high_resolution_clock::now(); + + QuantitativeResultMinMax quantitativeResult; + + // (7) Solve the min values and check whether we can give the answer already. + quantitativeResult.min = computeQuantitativeResult(player1Direction, storm::OptimizationDirection::Minimize, game, qualitativeResult, initialStatesAdd, maybeMin, reuseQuantitativeResults ? previousMinQuantitativeResult : boost::none); + previousMinQuantitativeResult = quantitativeResult.min; + result = checkForResultAfterQuantitativeCheck(checkTask, storm::OptimizationDirection::Minimize, quantitativeResult.min.initialStatesRange); + if (result) { + printStatistics(*abstractor, game); + return result; + } + + // (8) Solve the max values and check whether we can give the answer already. + quantitativeResult.max = computeQuantitativeResult(player1Direction, storm::OptimizationDirection::Maximize, game, qualitativeResult, initialStatesAdd, maybeMax, boost::make_optional(quantitativeResult.min)); + result = checkForResultAfterQuantitativeCheck(checkTask, storm::OptimizationDirection::Maximize, quantitativeResult.max.initialStatesRange); + if (result) { + printStatistics(*abstractor, game); + return result; + } + + auto quantitativeEnd = std::chrono::high_resolution_clock::now(); + STORM_LOG_DEBUG("Obtained quantitative bounds [" << quantitativeResult.min.initialStatesRange.first << ", " << quantitativeResult.max.initialStatesRange.second << "] on the actual value for the initial states in " << std::chrono::duration_cast(quantitativeEnd - quantitativeStart).count() << "ms."); + + // (9) Check whether the lower and upper bounds are close enough to terminate with an answer. + result = checkForResultAfterQuantitativeCheck(quantitativeResult.min.initialStatesRange.first, quantitativeResult.max.initialStatesRange.second, comparator); + if (result) { + printStatistics(*abstractor, game); + return result; + } + + // Make sure that all strategies are still valid strategies. + STORM_LOG_ASSERT(quantitativeResult.min.player1Strategy.isZero() || quantitativeResult.min.player1Strategy.template toAdd().sumAbstract(game.getPlayer1Variables()).getMax() <= 1, "Player 1 strategy for min is illegal."); + STORM_LOG_ASSERT(quantitativeResult.max.player1Strategy.isZero() || quantitativeResult.max.player1Strategy.template toAdd().sumAbstract(game.getPlayer1Variables()).getMax() <= 1, "Player 1 strategy for max is illegal."); + STORM_LOG_ASSERT(quantitativeResult.min.player2Strategy.isZero() || quantitativeResult.min.player2Strategy.template toAdd().sumAbstract(game.getPlayer2Variables()).getMax() <= 1, "Player 2 strategy for min is illegal."); + STORM_LOG_ASSERT(quantitativeResult.max.player2Strategy.isZero() || quantitativeResult.max.player2Strategy.template toAdd().sumAbstract(game.getPlayer2Variables()).getMax() <= 1, "Player 2 strategy for max is illegal."); + + auto quantitativeRefinementStart = std::chrono::high_resolution_clock::now(); + // (10) If we arrived at this point, it means that we have all qualitative and quantitative + // information about the game, but we could not yet answer the query. In this case, we need to refine. + refiner.refine(game, transitionMatrixBdd, quantitativeResult); + auto quantitativeRefinementEnd = std::chrono::high_resolution_clock::now(); + STORM_LOG_DEBUG("Quantitative refinement completed in " << std::chrono::duration_cast(quantitativeRefinementEnd - quantitativeRefinementStart).count() << "ms."); + + } + auto iterationEnd = std::chrono::high_resolution_clock::now(); + STORM_LOG_DEBUG("Iteration " << iterations << " took " << std::chrono::duration_cast(iterationEnd - iterationStart).count() << "ms."); + } + + STORM_LOG_ASSERT(false, "This point must not be reached."); + return nullptr; + } + + template + std::vector GameBasedMdpModelChecker::getInitialPredicates(storm::expressions::Expression const& constraintExpression, storm::expressions::Expression const& targetStateExpression) { + std::vector initialPredicates; + if (preprocessedModel.isJaniModel()) { + storm::expressions::VariableSetPredicateSplitter splitter(preprocessedModel.asJaniModel().getAllLocationExpressionVariables()); + + std::vector splitExpressions = splitter.split(targetStateExpression); + initialPredicates.insert(initialPredicates.end(), splitExpressions.begin(), splitExpressions.end()); + + splitExpressions = splitter.split(constraintExpression); + initialPredicates.insert(initialPredicates.end(), splitExpressions.begin(), splitExpressions.end()); + } else { + if (!targetStateExpression.isTrue() && !targetStateExpression.isFalse()) { + initialPredicates.push_back(targetStateExpression); + } + if (!constraintExpression.isTrue() && !constraintExpression.isFalse()) { + initialPredicates.push_back(constraintExpression); + } + } + return initialPredicates; + } + + template + storm::OptimizationDirection GameBasedMdpModelChecker::getPlayer1Direction(CheckTask const& checkTask) { + if (preprocessedModel.getModelType() == storm::storage::SymbolicModelDescription::ModelType::DTMC) { + return storm::OptimizationDirection::Maximize; + } else if (checkTask.isOptimizationDirectionSet()) { + return checkTask.getOptimizationDirection(); + } else if (checkTask.isBoundSet() && preprocessedModel.getModelType() != storm::storage::SymbolicModelDescription::ModelType::DTMC) { + return storm::logic::isLowerBound(checkTask.getBoundComparisonType()) ? storm::OptimizationDirection::Minimize : storm::OptimizationDirection::Maximize; + } + STORM_LOG_THROW(false, storm::exceptions::InvalidPropertyException, "Could not derive player 1 optimization direction."); + return storm::OptimizationDirection::Maximize; + } + + template + bool checkQualitativeStrategies(bool prob0, QualitativeResult const& result, storm::dd::Bdd const& targetStates) { + if (prob0) { + STORM_LOG_ASSERT(result.hasPlayer1Strategy() && (result.getPlayer1States().isZero() || !result.getPlayer1Strategy().isZero()), "Unable to proceed without strategy."); + } else { + STORM_LOG_ASSERT(result.hasPlayer1Strategy() && ((result.getPlayer1States() && !targetStates).isZero() || !result.getPlayer1Strategy().isZero()), "Unable to proceed without strategy."); + } + + STORM_LOG_ASSERT(result.hasPlayer2Strategy() && (result.getPlayer2States().isZero() || !result.getPlayer2Strategy().isZero()), "Unable to proceed without strategy."); + + return true; + } + + template + bool checkQualitativeStrategies(QualitativeResultMinMax const& qualitativeResult, storm::dd::Bdd const& targetStates) { + bool result = true; + result &= checkQualitativeStrategies(true, qualitativeResult.prob0Min, targetStates); + result &= checkQualitativeStrategies(false, qualitativeResult.prob1Min, targetStates); + result &= checkQualitativeStrategies(true, qualitativeResult.prob0Max, targetStates); + result &= checkQualitativeStrategies(false, qualitativeResult.prob1Max, targetStates); + return result; + } + + template + QualitativeResultMinMax GameBasedMdpModelChecker::computeProb01States(boost::optional> const& previousQualitativeResult, storm::abstraction::MenuGame const& game, storm::OptimizationDirection player1Direction, storm::dd::Bdd const& transitionMatrixBdd, storm::dd::Bdd const& constraintStates, storm::dd::Bdd const& targetStates) { + + QualitativeResultMinMax result; + + if (reuseQualitativeResults) { + // Depending on the player 1 direction, we choose a different order of operations. + if (player1Direction == storm::OptimizationDirection::Minimize) { + // (1) min/min: compute prob0 using the game functions + result.prob0Min = storm::utility::graph::performProb0(game, transitionMatrixBdd, constraintStates, targetStates, player1Direction, storm::OptimizationDirection::Minimize, true, true); + + // (2) min/min: compute prob1 using the MDP functions + storm::dd::Bdd candidates = game.getReachableStates() && !result.prob0Min.player1States; + storm::dd::Bdd prob1MinMinMdp = storm::utility::graph::performProb1A(game, transitionMatrixBdd, previousQualitativeResult ? previousQualitativeResult.get().prob1Min.player1States : targetStates, candidates); + + // (3) min/min: compute prob1 using the game functions + result.prob1Min = storm::utility::graph::performProb1(game, transitionMatrixBdd, constraintStates, targetStates, player1Direction, storm::OptimizationDirection::Minimize, true, true, boost::make_optional(prob1MinMinMdp)); + + // (4) min/max: compute prob 0 using the game functions + result.prob0Max = storm::utility::graph::performProb0(game, transitionMatrixBdd, constraintStates, targetStates, player1Direction, storm::OptimizationDirection::Maximize, true, true); + + // (5) min/max: compute prob 1 using the game functions + // We know that only previous prob1 states can now be prob 1 states again, because the upper bound + // values can only decrease over iterations. + boost::optional> prob1Candidates; + if (previousQualitativeResult) { + prob1Candidates = previousQualitativeResult.get().prob1Max.player1States; + } + result.prob1Max = storm::utility::graph::performProb1(game, transitionMatrixBdd, constraintStates, targetStates, player1Direction, storm::OptimizationDirection::Maximize, true, true, prob1Candidates); + } else { + // (1) max/max: compute prob0 using the game functions + result.prob0Max = storm::utility::graph::performProb0(game, transitionMatrixBdd, constraintStates, targetStates, player1Direction, storm::OptimizationDirection::Maximize, true, true); + + // (2) max/max: compute prob1 using the MDP functions, reuse prob1 states of last iteration to constrain the candidate states. + storm::dd::Bdd candidates = game.getReachableStates() && !result.prob0Max.player1States; + if (previousQualitativeResult) { + candidates &= previousQualitativeResult.get().prob1Max.player1States; + } + storm::dd::Bdd prob1MaxMaxMdp = storm::utility::graph::performProb1E(game, transitionMatrixBdd, constraintStates, targetStates, candidates); + + // (3) max/max: compute prob1 using the game functions, reuse prob1 states from the MDP precomputation + result.prob1Max = storm::utility::graph::performProb1(game, transitionMatrixBdd, constraintStates, targetStates, player1Direction, storm::OptimizationDirection::Maximize, true, true, boost::make_optional(prob1MaxMaxMdp)); + + // (4) max/min: compute prob0 using the game functions + result.prob0Min = storm::utility::graph::performProb0(game, transitionMatrixBdd, constraintStates, targetStates, player1Direction, storm::OptimizationDirection::Minimize, true, true); + + // (5) max/min: compute prob1 using the game functions, use prob1 from max/max as the candidate set + result.prob1Min = storm::utility::graph::performProb1(game, transitionMatrixBdd, constraintStates, targetStates, player1Direction, storm::OptimizationDirection::Minimize, true, true, boost::make_optional(prob1MaxMaxMdp)); + } + } else { + result.prob0Min = storm::utility::graph::performProb0(game, transitionMatrixBdd, constraintStates, targetStates, player1Direction, storm::OptimizationDirection::Minimize, true, true); + result.prob1Min = storm::utility::graph::performProb1(game, transitionMatrixBdd, constraintStates, targetStates, player1Direction, storm::OptimizationDirection::Minimize, true, true); + result.prob0Max = storm::utility::graph::performProb0(game, transitionMatrixBdd, constraintStates, targetStates, player1Direction, storm::OptimizationDirection::Maximize, true, true); + result.prob1Max = storm::utility::graph::performProb1(game, transitionMatrixBdd, constraintStates, targetStates, player1Direction, storm::OptimizationDirection::Maximize, true, true); + } + + STORM_LOG_TRACE("Qualitative precomputation completed."); + STORM_LOG_TRACE("[" << player1Direction << ", " << storm::OptimizationDirection::Minimize << "]: " << result.prob0Min.player1States.getNonZeroCount() << " 'no', " << result.prob1Min.player1States.getNonZeroCount() << " 'yes'."); + STORM_LOG_TRACE("[" << player1Direction << ", " << storm::OptimizationDirection::Maximize << "]: " << result.prob0Max.player1States.getNonZeroCount() << " 'no', " << result.prob1Max.player1States.getNonZeroCount() << " 'yes'."); + + STORM_LOG_ASSERT(checkQualitativeStrategies(result, targetStates), "Qualitative strategies appear to be broken."); + return result; + } + + template + void GameBasedMdpModelChecker::printStatistics(storm::abstraction::MenuGameAbstractor const& abstractor, storm::abstraction::MenuGame const& game) const { + if (storm::settings::getModule().isShowStatisticsSet()) { + storm::abstraction::AbstractionInformation const& abstractionInformation = abstractor.getAbstractionInformation(); + + std::cout << std::endl; + std::cout << "Statistics:" << std::endl; + std::cout << " * player 1 states (final game): " << game.getReachableStates().getNonZeroCount() << std::endl; + std::cout << " * transitions (final game): " << game.getTransitionMatrix().getNonZeroCount() << std::endl; + std::cout << " * predicates used in abstraction: " << abstractionInformation.getNumberOfPredicates() << std::endl; + } + } + + template + storm::expressions::Expression GameBasedMdpModelChecker::getExpression(storm::logic::Formula const& formula) { + STORM_LOG_THROW(formula.isBooleanLiteralFormula() || formula.isAtomicExpressionFormula() || formula.isAtomicLabelFormula(), storm::exceptions::InvalidPropertyException, "The target states have to be given as label or an expression."); + storm::expressions::Expression result; + if (formula.isAtomicLabelFormula()) { + result = preprocessedModel.asPrismProgram().getLabelExpression(formula.asAtomicLabelFormula().getLabel()); + } else if (formula.isAtomicExpressionFormula()) { + result = formula.asAtomicExpressionFormula().getExpression(); + } else { + result = formula.asBooleanLiteralFormula().isTrueFormula() ? preprocessedModel.getManager().boolean(true) : preprocessedModel.getManager().boolean(false); + } + return result; + } + + template class GameBasedMdpModelChecker>; + template class GameBasedMdpModelChecker>; + template class GameBasedMdpModelChecker>; + template class GameBasedMdpModelChecker>; + } +} diff --git a/src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.h b/src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.h new file mode 100644 index 000000000..ae63f96df --- /dev/null +++ b/src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.h @@ -0,0 +1,102 @@ +#ifndef STORM_MODELCHECKER_GAMEBASEDMDPMODELCHECKER_H_ +#define STORM_MODELCHECKER_GAMEBASEDMDPMODELCHECKER_H_ + +#include "storm/modelchecker/AbstractModelChecker.h" + +#include "storm/storage/prism/Program.h" + +#include "storm/storage/dd/DdType.h" + +#include "storm/storage/SymbolicModelDescription.h" + +#include "storm/abstraction/QualitativeResult.h" +#include "storm/abstraction/QualitativeResultMinMax.h" + +#include "storm/logic/Bound.h" + +#include "storm/utility/ConstantsComparator.h" +#include "storm/utility/solver.h" +#include "storm/utility/graph.h" + +namespace storm { + namespace abstraction { + template + class MenuGame; + + template + class MenuGameAbstractor; + } + + namespace modelchecker { + + using storm::abstraction::QualitativeResult; + using storm::abstraction::QualitativeResultMinMax; + + template + class GameBasedMdpModelChecker : public AbstractModelChecker { + public: + typedef typename ModelType::ValueType ValueType; + + /*! + * Constructs a model checker whose underlying model is implicitly given by the provided program. All + * verification calls will be answererd with respect to this model. + * + * @param model The model description that (symbolically) specifies the model to check. + * @param smtSolverFactory A factory used to create SMT solver when necessary. + */ + explicit GameBasedMdpModelChecker(storm::storage::SymbolicModelDescription const& model, std::shared_ptr const& smtSolverFactory = std::make_shared()); + + /// Overridden methods from super class. + virtual bool canHandle(CheckTask const& checkTask) const override; + virtual std::unique_ptr computeUntilProbabilities(CheckTask const& checkTask) override; + virtual std::unique_ptr computeReachabilityProbabilities(CheckTask const& checkTask) override; + + private: + /*! + * Performs the core part of the abstraction-refinement loop. + */ + std::unique_ptr performGameBasedAbstractionRefinement(CheckTask const& checkTask, storm::expressions::Expression const& constraintExpression, storm::expressions::Expression const& targetStateExpression); + + /*! + * Retrieves the initial predicates for the abstraction. + */ + std::vector getInitialPredicates(storm::expressions::Expression const& constraintExpression, storm::expressions::Expression const& targetStateExpression); + + /*! + * Derives the optimization direction of player 1. + */ + storm::OptimizationDirection getPlayer1Direction(CheckTask const& checkTask); + + /*! + * Performs a qualitative check on the the given game to compute the (player 1) states that have probability + * 0 or 1, respectively, to reach a target state and only visiting constraint states before. + */ + QualitativeResultMinMax computeProb01States(boost::optional> const& previousQualitativeResult, storm::abstraction::MenuGame const& game, storm::OptimizationDirection player1Direction, storm::dd::Bdd const& transitionMatrixBdd, storm::dd::Bdd const& constraintStates, storm::dd::Bdd const& targetStates); + + void printStatistics(storm::abstraction::MenuGameAbstractor const& abstractor, storm::abstraction::MenuGame const& game) const; + + /* + * Retrieves the expression characterized by the formula. The formula needs to be propositional. + */ + storm::expressions::Expression getExpression(storm::logic::Formula const& formula); + + /// The preprocessed model that contains only one module/automaton and otherwhise corresponds to the semantics + /// of the original model description. + storm::storage::SymbolicModelDescription preprocessedModel; + + /// A factory that is used for creating SMT solvers when needed. + std::shared_ptr smtSolverFactory; + + /// A comparator that can be used for detecting convergence. + storm::utility::ConstantsComparator comparator; + + /// A flag indicating whether to reuse the qualitative results. + bool reuseQualitativeResults; + + /// A flag indicating whether to reuse the quantitative results. + bool reuseQuantitativeResults; + }; + } +} + +#endif /* STORM_MODELCHECKER_GAMEBASEDMDPMODELCHECKER_H_ */ diff --git a/src/storm/modelchecker/csl/HybridCtmcCslModelChecker.cpp b/src/storm/modelchecker/csl/HybridCtmcCslModelChecker.cpp index 62f789332..fc221147b 100644 --- a/src/storm/modelchecker/csl/HybridCtmcCslModelChecker.cpp +++ b/src/storm/modelchecker/csl/HybridCtmcCslModelChecker.cpp @@ -12,6 +12,8 @@ #include "storm/logic/FragmentSpecification.h" +#include "storm/exceptions/NotImplementedException.h" + namespace storm { namespace modelchecker { template @@ -27,7 +29,7 @@ namespace storm { template bool HybridCtmcCslModelChecker::canHandle(CheckTask const& checkTask) const { storm::logic::Formula const& formula = checkTask.getFormula(); - return formula.isInFragment(storm::logic::csrl().setGloballyFormulasAllowed(false).setLongRunAverageRewardFormulasAllowed(false).setLongRunAverageProbabilitiesAllowed(true)); + return formula.isInFragment(storm::logic::csrl().setGloballyFormulasAllowed(false).setLongRunAverageRewardFormulasAllowed(true).setLongRunAverageProbabilitiesAllowed(true)); } template @@ -52,7 +54,7 @@ namespace storm { template - std::unique_ptr HybridCtmcCslModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr HybridCtmcCslModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula(); std::unique_ptr subResultPointer = this->check(eventuallyFormula.getSubformula()); SymbolicQualitativeCheckResult const& subResult = subResultPointer->asSymbolicQualitativeCheckResult(); @@ -67,29 +69,36 @@ namespace storm { std::unique_ptr rightResultPointer = this->check(pathFormula.getRightSubformula()); SymbolicQualitativeCheckResult const& leftResult = leftResultPointer->asSymbolicQualitativeCheckResult(); SymbolicQualitativeCheckResult const& rightResult = rightResultPointer->asSymbolicQualitativeCheckResult(); + + STORM_LOG_THROW(!pathFormula.isStepBounded(), storm::exceptions::NotImplementedException, "Currently step-bounded properties on CTMCs are not supported."); double lowerBound = 0; double upperBound = 0; - if (!pathFormula.hasDiscreteTimeBound()) { - std::pair const& intervalBounds = pathFormula.getIntervalBounds(); - lowerBound = intervalBounds.first; - upperBound = intervalBounds.second; + if (pathFormula.hasLowerBound()) { + lowerBound = pathFormula.getLowerBound(); + } + if (pathFormula.hasUpperBound()) { + upperBound = pathFormula.getUpperBound(); } else { - upperBound = pathFormula.getDiscreteTimeBound(); + upperBound = storm::utility::infinity(); } return storm::modelchecker::helper::HybridCtmcCslHelper::computeBoundedUntilProbabilities(this->getModel(), this->getModel().getTransitionMatrix(), this->getModel().getExitRateVector(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), checkTask.isQualitativeSet(), lowerBound, upperBound, *linearEquationSolverFactory); } template - std::unique_ptr HybridCtmcCslModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr HybridCtmcCslModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::InstantaneousRewardFormula const& rewardPathFormula = checkTask.getFormula(); - return storm::modelchecker::helper::HybridCtmcCslHelper::computeInstantaneousRewards(this->getModel(), this->getModel().getTransitionMatrix(), this->getModel().getExitRateVector(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getContinuousTimeBound(), *linearEquationSolverFactory); + + STORM_LOG_THROW(!rewardPathFormula.isStepBounded(), storm::exceptions::NotImplementedException, "Currently step-bounded properties on CTMCs are not supported."); + return storm::modelchecker::helper::HybridCtmcCslHelper::computeInstantaneousRewards(this->getModel(), this->getModel().getTransitionMatrix(), this->getModel().getExitRateVector(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound(), *linearEquationSolverFactory); } template - std::unique_ptr HybridCtmcCslModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr HybridCtmcCslModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::CumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula(); - return storm::modelchecker::helper::HybridCtmcCslHelper::computeCumulativeRewards(this->getModel(), this->getModel().getTransitionMatrix(), this->getModel().getExitRateVector(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getContinuousTimeBound(), *linearEquationSolverFactory); + + STORM_LOG_THROW(!rewardPathFormula.isStepBounded(), storm::exceptions::NotImplementedException, "Currently step-bounded properties on CTMCs are not supported."); + return storm::modelchecker::helper::HybridCtmcCslHelper::computeCumulativeRewards(this->getModel(), this->getModel().getTransitionMatrix(), this->getModel().getExitRateVector(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound(), *linearEquationSolverFactory); } template @@ -98,7 +107,12 @@ namespace storm { std::unique_ptr subResultPointer = this->check(stateFormula); SymbolicQualitativeCheckResult const& subResult = subResultPointer->asSymbolicQualitativeCheckResult(); - return storm::modelchecker::helper::HybridCtmcCslHelper::computeLongRunAverageProbabilities(this->getModel(), this->getModel().getTransitionMatrix(), this->getModel().getExitRateVector(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), *linearEquationSolverFactory); + return storm::modelchecker::helper::HybridCtmcCslHelper::computeLongRunAverageProbabilities(this->getModel(), this->getModel().getTransitionMatrix(), this->getModel().getExitRateVector(), subResult.getTruthValuesVector(), *linearEquationSolverFactory); + } + + template + std::unique_ptr HybridCtmcCslModelChecker::computeLongRunAverageRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + return storm::modelchecker::helper::HybridCtmcCslHelper::computeLongRunAverageRewards(this->getModel(), this->getModel().getTransitionMatrix(), this->getModel().getExitRateVector(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), *linearEquationSolverFactory); } // Explicitly instantiate the model checker. diff --git a/src/storm/modelchecker/csl/HybridCtmcCslModelChecker.h b/src/storm/modelchecker/csl/HybridCtmcCslModelChecker.h index 24dbde9d2..202456f5b 100644 --- a/src/storm/modelchecker/csl/HybridCtmcCslModelChecker.h +++ b/src/storm/modelchecker/csl/HybridCtmcCslModelChecker.h @@ -24,10 +24,12 @@ namespace storm { virtual std::unique_ptr computeBoundedUntilProbabilities(CheckTask const& checkTask) override; virtual std::unique_ptr computeNextProbabilities(CheckTask const& checkTask) override; virtual std::unique_ptr computeUntilProbabilities(CheckTask const& checkTask) override; + virtual std::unique_ptr computeLongRunAverageProbabilities(CheckTask const& checkTask) override; + + virtual std::unique_ptr computeLongRunAverageRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; virtual std::unique_ptr computeInstantaneousRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; virtual std::unique_ptr computeCumulativeRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; virtual std::unique_ptr computeReachabilityRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; - virtual std::unique_ptr computeLongRunAverageProbabilities(CheckTask const& checkTask) override; private: // An object that is used for solving linear equations and performing matrix-vector multiplication. diff --git a/src/storm/modelchecker/csl/SparseCtmcCslModelChecker.cpp b/src/storm/modelchecker/csl/SparseCtmcCslModelChecker.cpp index e554e7997..4d6e9407f 100644 --- a/src/storm/modelchecker/csl/SparseCtmcCslModelChecker.cpp +++ b/src/storm/modelchecker/csl/SparseCtmcCslModelChecker.cpp @@ -42,14 +42,14 @@ namespace storm { template::SupportsExponential, int>::type> bool SparseCtmcCslModelChecker::canHandleImplementation(CheckTask const& checkTask) const { storm::logic::Formula const& formula = checkTask.getFormula(); - return formula.isInFragment(storm::logic::csrl().setGloballyFormulasAllowed(false).setLongRunAverageRewardFormulasAllowed(false).setLongRunAverageProbabilitiesAllowed(true).setTimeAllowed(true)); + return formula.isInFragment(storm::logic::csrl().setGloballyFormulasAllowed(false).setLongRunAverageRewardFormulasAllowed(true).setLongRunAverageProbabilitiesAllowed(true).setTimeAllowed(true)); } template template::SupportsExponential, int>::type> bool SparseCtmcCslModelChecker::canHandleImplementation(CheckTask const& checkTask) const { storm::logic::Formula const& formula = checkTask.getFormula(); - return formula.isInFragment(storm::logic::prctl().setGloballyFormulasAllowed(false).setLongRunAverageRewardFormulasAllowed(false).setLongRunAverageProbabilitiesAllowed(true).setTimeAllowed(true)); + return formula.isInFragment(storm::logic::prctl().setGloballyFormulasAllowed(false).setLongRunAverageRewardFormulasAllowed(true).setLongRunAverageProbabilitiesAllowed(true).setTimeAllowed(true)); } template @@ -59,16 +59,19 @@ namespace storm { std::unique_ptr rightResultPointer = this->check(pathFormula.getRightSubformula()); ExplicitQualitativeCheckResult const& leftResult = leftResultPointer->asExplicitQualitativeCheckResult();; ExplicitQualitativeCheckResult const& rightResult = rightResultPointer->asExplicitQualitativeCheckResult(); + + STORM_LOG_THROW(!pathFormula.isStepBounded(), storm::exceptions::NotImplementedException, "Currently step-bounded properties on CTMCs are not supported."); double lowerBound = 0; double upperBound = 0; - if (!pathFormula.hasDiscreteTimeBound()) { - std::pair const& intervalBounds = pathFormula.getIntervalBounds(); - lowerBound = intervalBounds.first; - upperBound = intervalBounds.second; + if (pathFormula.hasLowerBound()) { + lowerBound = pathFormula.getLowerBound(); + } + if (pathFormula.hasUpperBound()) { + upperBound = pathFormula.getUpperBound(); } else { - upperBound = pathFormula.getDiscreteTimeBound(); + upperBound = storm::utility::infinity(); } - + std::vector numericResult = storm::modelchecker::helper::SparseCtmcCslHelper::computeBoundedUntilProbabilities(this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), this->getModel().getExitRateVector(), checkTask.isQualitativeSet(), lowerBound, upperBound, *linearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(numericResult))); } @@ -94,21 +97,23 @@ namespace storm { } template - std::unique_ptr SparseCtmcCslModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SparseCtmcCslModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::InstantaneousRewardFormula const& rewardPathFormula = checkTask.getFormula(); - std::vector numericResult = storm::modelchecker::helper::SparseCtmcCslHelper::computeInstantaneousRewards(this->getModel().getTransitionMatrix(), this->getModel().getExitRateVector(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getContinuousTimeBound(), *linearEquationSolverFactory); + STORM_LOG_THROW(!rewardPathFormula.isStepBounded(), storm::exceptions::NotImplementedException, "Currently step-bounded properties on CTMCs are not supported."); + std::vector numericResult = storm::modelchecker::helper::SparseCtmcCslHelper::computeInstantaneousRewards(this->getModel().getTransitionMatrix(), this->getModel().getExitRateVector(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound(), *linearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(numericResult))); } template - std::unique_ptr SparseCtmcCslModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SparseCtmcCslModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::CumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula(); - std::vector numericResult = storm::modelchecker::helper::SparseCtmcCslHelper::computeCumulativeRewards(this->getModel().getTransitionMatrix(), this->getModel().getExitRateVector(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getContinuousTimeBound(), *linearEquationSolverFactory); + STORM_LOG_THROW(!rewardPathFormula.isStepBounded(), storm::exceptions::NotImplementedException, "Currently step-bounded properties on CTMCs are not supported."); + std::vector numericResult = storm::modelchecker::helper::SparseCtmcCslHelper::computeCumulativeRewards(this->getModel().getTransitionMatrix(), this->getModel().getExitRateVector(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound(), *linearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(numericResult))); } template - std::unique_ptr SparseCtmcCslModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SparseCtmcCslModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula(); std::unique_ptr subResultPointer = this->check(eventuallyFormula.getSubformula()); ExplicitQualitativeCheckResult const& subResult = subResultPointer->asExplicitQualitativeCheckResult(); @@ -124,17 +129,24 @@ namespace storm { ExplicitQualitativeCheckResult const& subResult = subResultPointer->asExplicitQualitativeCheckResult(); storm::storage::SparseMatrix probabilityMatrix = storm::modelchecker::helper::SparseCtmcCslHelper::computeProbabilityMatrix(this->getModel().getTransitionMatrix(), this->getModel().getExitRateVector()); - std::vector numericResult = storm::modelchecker::helper::SparseCtmcCslHelper::computeLongRunAverageProbabilities(probabilityMatrix, subResult.getTruthValuesVector(), &this->getModel().getExitRateVector(), checkTask.isQualitativeSet(), *linearEquationSolverFactory); + std::vector numericResult = storm::modelchecker::helper::SparseCtmcCslHelper::computeLongRunAverageProbabilities(probabilityMatrix, subResult.getTruthValuesVector(), &this->getModel().getExitRateVector(), *linearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(numericResult))); } template - std::unique_ptr SparseCtmcCslModelChecker::computeReachabilityTimes(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SparseCtmcCslModelChecker::computeLongRunAverageRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + storm::storage::SparseMatrix probabilityMatrix = storm::modelchecker::helper::SparseCtmcCslHelper::computeProbabilityMatrix(this->getModel().getTransitionMatrix(), this->getModel().getExitRateVector()); + std::vector numericResult = storm::modelchecker::helper::SparseCtmcCslHelper::computeLongRunAverageRewards(probabilityMatrix, checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), &this->getModel().getExitRateVector(), *linearEquationSolverFactory); + return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(numericResult))); + } + + template + std::unique_ptr SparseCtmcCslModelChecker::computeReachabilityTimes(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula(); std::unique_ptr subResultPointer = this->check(eventuallyFormula.getSubformula()); ExplicitQualitativeCheckResult& subResult = subResultPointer->asExplicitQualitativeCheckResult(); - std::vector numericResult = storm::modelchecker::helper::SparseCtmcCslHelper::computeReachabilityTimes(this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), this->getModel().getExitRateVector(), this->getModel().getInitialStates(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), *linearEquationSolverFactory); + std::vector numericResult = storm::modelchecker::helper::SparseCtmcCslHelper::computeReachabilityTimes(this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), this->getModel().getExitRateVector(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), *linearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(numericResult))); } diff --git a/src/storm/modelchecker/csl/SparseCtmcCslModelChecker.h b/src/storm/modelchecker/csl/SparseCtmcCslModelChecker.h index 830bfe135..f5ca5d6d3 100644 --- a/src/storm/modelchecker/csl/SparseCtmcCslModelChecker.h +++ b/src/storm/modelchecker/csl/SparseCtmcCslModelChecker.h @@ -26,11 +26,13 @@ namespace storm { virtual std::unique_ptr computeBoundedUntilProbabilities(CheckTask const& checkTask) override; virtual std::unique_ptr computeNextProbabilities(CheckTask const& checkTask) override; virtual std::unique_ptr computeUntilProbabilities(CheckTask const& checkTask) override; + virtual std::unique_ptr computeLongRunAverageProbabilities(CheckTask const& checkTask) override; + virtual std::unique_ptr computeReachabilityTimes(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; + + virtual std::unique_ptr computeLongRunAverageRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; virtual std::unique_ptr computeCumulativeRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; virtual std::unique_ptr computeInstantaneousRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; virtual std::unique_ptr computeReachabilityRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; - virtual std::unique_ptr computeLongRunAverageProbabilities(CheckTask const& checkTask) override; - virtual std::unique_ptr computeReachabilityTimes(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; private: template::SupportsExponential, int>::type = 0> diff --git a/src/storm/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.cpp b/src/storm/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.cpp index 16ccd6162..4aef07d8d 100644 --- a/src/storm/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.cpp +++ b/src/storm/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.cpp @@ -53,16 +53,19 @@ namespace storm { STORM_LOG_THROW(this->getModel().isClosed(), storm::exceptions::InvalidPropertyException, "Unable to compute time-bounded reachability probabilities in non-closed Markov automaton."); std::unique_ptr rightResultPointer = this->check(pathFormula.getRightSubformula()); ExplicitQualitativeCheckResult const& rightResult = rightResultPointer->asExplicitQualitativeCheckResult(); + + STORM_LOG_THROW(!pathFormula.isStepBounded(), storm::exceptions::NotImplementedException, "Currently step-bounded properties on MAs are not supported."); double lowerBound = 0; double upperBound = 0; - if (!pathFormula.hasDiscreteTimeBound()) { - std::pair const& intervalBounds = pathFormula.getIntervalBounds(); - lowerBound = intervalBounds.first; - upperBound = intervalBounds.second; + if (pathFormula.hasLowerBound()) { + lowerBound = pathFormula.getLowerBound(); + } + if (pathFormula.hasUpperBound()) { + upperBound = pathFormula.getUpperBound(); } else { - upperBound = pathFormula.getDiscreteTimeBound(); + upperBound = storm::utility::infinity(); } - + std::vector result = storm::modelchecker::helper::SparseMarkovAutomatonCslHelper::computeBoundedUntilProbabilities(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), this->getModel().getExitRates(), this->getModel().getMarkovianStates(), rightResult.getTruthValuesVector(), std::make_pair(lowerBound, upperBound), *minMaxLinearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(result))); } @@ -80,14 +83,14 @@ namespace storm { } template - std::unique_ptr SparseMarkovAutomatonCslModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SparseMarkovAutomatonCslModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula(); STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); STORM_LOG_THROW(this->getModel().isClosed(), storm::exceptions::InvalidPropertyException, "Unable to compute reachability rewards in non-closed Markov automaton."); std::unique_ptr subResultPointer = this->check(eventuallyFormula.getSubformula()); ExplicitQualitativeCheckResult const& subResult = subResultPointer->asExplicitQualitativeCheckResult(); - std::vector result = storm::modelchecker::helper::SparseMarkovAutomatonCslHelper::computeReachabilityRewards(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), this->getModel().getExitRates(), this->getModel().getMarkovianStates(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), *minMaxLinearEquationSolverFactory); + std::vector result = storm::modelchecker::helper::SparseMarkovAutomatonCslHelper::computeReachabilityRewards(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), this->getModel().getExitRates(), this->getModel().getMarkovianStates(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), subResult.getTruthValuesVector(), *minMaxLinearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(result))); } @@ -100,19 +103,19 @@ namespace storm { std::unique_ptr subResultPointer = this->check(stateFormula); ExplicitQualitativeCheckResult const& subResult = subResultPointer->asExplicitQualitativeCheckResult(); - std::vector result = storm::modelchecker::helper::SparseMarkovAutomatonCslHelper::computeLongRunAverageProbabilities(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), this->getModel().getExitRates(), this->getModel().getMarkovianStates(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), *minMaxLinearEquationSolverFactory); + std::vector result = storm::modelchecker::helper::SparseMarkovAutomatonCslHelper::computeLongRunAverageProbabilities(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), this->getModel().getExitRates(), this->getModel().getMarkovianStates(), subResult.getTruthValuesVector(), *minMaxLinearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(result))); } template - std::unique_ptr SparseMarkovAutomatonCslModelChecker::computeReachabilityTimes(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SparseMarkovAutomatonCslModelChecker::computeReachabilityTimes(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula(); STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); STORM_LOG_THROW(this->getModel().isClosed(), storm::exceptions::InvalidPropertyException, "Unable to compute expected times in non-closed Markov automaton."); std::unique_ptr subResultPointer = this->check(eventuallyFormula.getSubformula()); ExplicitQualitativeCheckResult& subResult = subResultPointer->asExplicitQualitativeCheckResult(); - std::vector result = storm::modelchecker::helper::SparseMarkovAutomatonCslHelper::computeTimes(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), this->getModel().getExitRates(), this->getModel().getMarkovianStates(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), *minMaxLinearEquationSolverFactory); + std::vector result = storm::modelchecker::helper::SparseMarkovAutomatonCslHelper::computeTimes(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), this->getModel().getExitRates(), this->getModel().getMarkovianStates(), subResult.getTruthValuesVector(), *minMaxLinearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(result))); } diff --git a/src/storm/modelchecker/csl/helper/HybridCtmcCslHelper.cpp b/src/storm/modelchecker/csl/helper/HybridCtmcCslHelper.cpp index 19d6755c7..592ecc460 100644 --- a/src/storm/modelchecker/csl/helper/HybridCtmcCslHelper.cpp +++ b/src/storm/modelchecker/csl/helper/HybridCtmcCslHelper.cpp @@ -28,17 +28,17 @@ namespace storm { template std::unique_ptr HybridCtmcCslHelper::computeReachabilityRewards(storm::models::symbolic::Ctmc const& model, storm::dd::Add const& rateMatrix, storm::dd::Add const& exitRateVector, RewardModelType const& rewardModel, storm::dd::Bdd const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { - return HybridDtmcPrctlHelper::computeReachabilityRewards(model, computeProbabilityMatrix(model, rateMatrix, exitRateVector), rewardModel.divideStateRewardVector(exitRateVector), targetStates, qualitative, linearEquationSolverFactory); + return HybridDtmcPrctlHelper::computeReachabilityRewards(model, computeProbabilityMatrix(rateMatrix, exitRateVector), rewardModel.divideStateRewardVector(exitRateVector), targetStates, qualitative, linearEquationSolverFactory); } template std::unique_ptr HybridCtmcCslHelper::computeNextProbabilities(storm::models::symbolic::Ctmc const& model, storm::dd::Add const& rateMatrix, storm::dd::Add const& exitRateVector, storm::dd::Bdd const& nextStates) { - return HybridDtmcPrctlHelper::computeNextProbabilities(model, computeProbabilityMatrix(model, rateMatrix, exitRateVector), nextStates); + return HybridDtmcPrctlHelper::computeNextProbabilities(model, computeProbabilityMatrix(rateMatrix, exitRateVector), nextStates); } template std::unique_ptr HybridCtmcCslHelper::computeUntilProbabilities(storm::models::symbolic::Ctmc const& model, storm::dd::Add const& rateMatrix, storm::dd::Add const& exitRateVector, storm::dd::Bdd const& phiStates, storm::dd::Bdd const& psiStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { - return HybridDtmcPrctlHelper::computeUntilProbabilities(model, computeProbabilityMatrix(model, rateMatrix, exitRateVector), phiStates, psiStates, qualitative, linearEquationSolverFactory); + return HybridDtmcPrctlHelper::computeUntilProbabilities(model, computeProbabilityMatrix(rateMatrix, exitRateVector), phiStates, psiStates, qualitative, linearEquationSolverFactory); } template @@ -224,7 +224,7 @@ namespace storm { STORM_LOG_THROW(rewardModel.hasStateRewards(), storm::exceptions::InvalidPropertyException, "Missing reward model for formula. Skipping formula."); // Create ODD for the translation. - storm::dd::Odd odd =model.getReachableStates().createOdd(); + storm::dd::Odd odd = model.getReachableStates().createOdd(); // Initialize result to state rewards of the model. std::vector result = rewardModel.getStateRewardVector().toVector(odd); @@ -267,17 +267,17 @@ namespace storm { storm::storage::SparseMatrix explicitUniformizedMatrix = uniformizedMatrix.toMatrix(odd, odd); // Then compute the state reward vector to use in the computation. - storm::dd::Add totalRewardVector = rewardModel.getTotalRewardVector(rateMatrix, model.getColumnVariables(), exitRateVector); + storm::dd::Add totalRewardVector = rewardModel.getTotalRewardVector(rateMatrix, model.getColumnVariables(), exitRateVector, false); std::vector explicitTotalRewardVector = totalRewardVector.toVector(odd); - + // Finally, compute the transient probabilities. std::vector result = storm::modelchecker::helper::SparseCtmcCslHelper::computeTransientProbabilities(explicitUniformizedMatrix, nullptr, timeBound, uniformizationRate, explicitTotalRewardVector, linearEquationSolverFactory); return std::unique_ptr(new HybridQuantitativeCheckResult(model.getReachableStates(), model.getManager().getBddZero(), model.getManager().template getAddZero(), model.getReachableStates(), std::move(odd), std::move(result))); } template - std::unique_ptr HybridCtmcCslHelper::computeLongRunAverageProbabilities(storm::models::symbolic::Ctmc const& model, storm::dd::Add const& rateMatrix, storm::dd::Add const& exitRateVector, storm::dd::Bdd const& psiStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { - storm::dd::Add probabilityMatrix = computeProbabilityMatrix(model, rateMatrix, exitRateVector); + std::unique_ptr HybridCtmcCslHelper::computeLongRunAverageProbabilities(storm::models::symbolic::Ctmc const& model, storm::dd::Add const& rateMatrix, storm::dd::Add const& exitRateVector, storm::dd::Bdd const& psiStates, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { + storm::dd::Add probabilityMatrix = computeProbabilityMatrix(rateMatrix, exitRateVector); // Create ODD for the translation. storm::dd::Odd odd = model.getReachableStates().createOdd(); @@ -285,11 +285,28 @@ namespace storm { storm::storage::SparseMatrix explicitProbabilityMatrix = probabilityMatrix.toMatrix(odd, odd); std::vector explicitExitRateVector = exitRateVector.toVector(odd); - std::vector result = storm::modelchecker::helper::SparseCtmcCslHelper::computeLongRunAverageProbabilities(explicitProbabilityMatrix, psiStates.toVector(odd), &explicitExitRateVector, qualitative, linearEquationSolverFactory); + std::vector result = storm::modelchecker::helper::SparseCtmcCslHelper::computeLongRunAverageProbabilities(explicitProbabilityMatrix, psiStates.toVector(odd), &explicitExitRateVector, linearEquationSolverFactory); return std::unique_ptr(new HybridQuantitativeCheckResult(model.getReachableStates(), model.getManager().getBddZero(), model.getManager().template getAddZero(), model.getReachableStates(), std::move(odd), std::move(result))); } + template + std::unique_ptr HybridCtmcCslHelper::computeLongRunAverageRewards(storm::models::symbolic::Ctmc const& model, storm::dd::Add const& rateMatrix, storm::dd::Add const& exitRateVector, RewardModelType const& rewardModel, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { + + STORM_LOG_THROW(!rewardModel.empty(), storm::exceptions::InvalidPropertyException, "Missing reward model for formula. Skipping formula."); + storm::dd::Add probabilityMatrix = computeProbabilityMatrix(rateMatrix, exitRateVector); + + // Create ODD for the translation. + storm::dd::Odd odd = model.getReachableStates().createOdd(); + + storm::storage::SparseMatrix explicitProbabilityMatrix = probabilityMatrix.toMatrix(odd, odd); + std::vector explicitExitRateVector = exitRateVector.toVector(odd); + + std::vector result = storm::modelchecker::helper::SparseCtmcCslHelper::computeLongRunAverageRewards(explicitProbabilityMatrix, rewardModel.getTotalRewardVector(probabilityMatrix, model.getColumnVariables(), exitRateVector, true).toVector(odd), &explicitExitRateVector, linearEquationSolverFactory); + + return std::unique_ptr(new HybridQuantitativeCheckResult(model.getReachableStates(), model.getManager().getBddZero(), model.getManager().template getAddZero(), model.getReachableStates(), std::move(odd), std::move(result))); + } + template storm::dd::Add HybridCtmcCslHelper::computeUniformizedMatrix(storm::models::symbolic::Ctmc const& model, storm::dd::Add const& transitionMatrix, storm::dd::Add const& exitRateVector, storm::dd::Bdd const& maybeStates, ValueType uniformizationRate) { STORM_LOG_DEBUG("Computing uniformized matrix using uniformization rate " << uniformizationRate << "."); @@ -309,7 +326,7 @@ namespace storm { } template - storm::dd::Add HybridCtmcCslHelper::computeProbabilityMatrix(storm::models::symbolic::Ctmc const& model, storm::dd::Add const& rateMatrix, storm::dd::Add const& exitRateVector) { + storm::dd::Add HybridCtmcCslHelper::computeProbabilityMatrix(storm::dd::Add const& rateMatrix, storm::dd::Add const& exitRateVector) { return rateMatrix / exitRateVector; } diff --git a/src/storm/modelchecker/csl/helper/HybridCtmcCslHelper.h b/src/storm/modelchecker/csl/helper/HybridCtmcCslHelper.h index d8bc0fc66..62eef6264 100644 --- a/src/storm/modelchecker/csl/helper/HybridCtmcCslHelper.h +++ b/src/storm/modelchecker/csl/helper/HybridCtmcCslHelper.h @@ -28,10 +28,12 @@ namespace storm { static std::unique_ptr computeReachabilityRewards(storm::models::symbolic::Ctmc const& model, storm::dd::Add const& rateMatrix, storm::dd::Add const& exitRateVector, RewardModelType const& rewardModel, storm::dd::Bdd const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); - static std::unique_ptr computeLongRunAverageProbabilities(storm::models::symbolic::Ctmc const& model, storm::dd::Add const& rateMatrix, storm::dd::Add const& exitRateVector, storm::dd::Bdd const& psiStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + static std::unique_ptr computeLongRunAverageProbabilities(storm::models::symbolic::Ctmc const& model, storm::dd::Add const& rateMatrix, storm::dd::Add const& exitRateVector, storm::dd::Bdd const& psiStates, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); static std::unique_ptr computeNextProbabilities(storm::models::symbolic::Ctmc const& model, storm::dd::Add const& rateMatrix, storm::dd::Add const& exitRateVector, storm::dd::Bdd const& nextStates); + static std::unique_ptr computeLongRunAverageRewards(storm::models::symbolic::Ctmc const& model, storm::dd::Add const& rateMatrix, storm::dd::Add const& exitRateVector, RewardModelType const& rewardModel, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + /*! * Converts the given rate-matrix into a time-abstract probability matrix. * @@ -40,12 +42,11 @@ namespace storm { * @param exitRateVector The exit rate vector of the model. * @return The probability matrix. */ - static storm::dd::Add computeProbabilityMatrix(storm::models::symbolic::Ctmc const& model, storm::dd::Add const& rateMatrix, storm::dd::Add const& exitRateVector); + static storm::dd::Add computeProbabilityMatrix(storm::dd::Add const& rateMatrix, storm::dd::Add const& exitRateVector); /*! * Computes the matrix representing the transitions of the uniformized CTMC. * - * @param model The symbolic model. * @param transitionMatrix The matrix to uniformize. * @param exitRateVector The exit rate vector. * @param maybeStates The states that need to be considered. diff --git a/src/storm/modelchecker/csl/helper/SparseCtmcCslHelper.cpp b/src/storm/modelchecker/csl/helper/SparseCtmcCslHelper.cpp index d616ac806..10995f9b7 100644 --- a/src/storm/modelchecker/csl/helper/SparseCtmcCslHelper.cpp +++ b/src/storm/modelchecker/csl/helper/SparseCtmcCslHelper.cpp @@ -192,7 +192,7 @@ namespace storm { } template ::SupportsExponential, int>::type> - std::vector SparseCtmcCslHelper::computeBoundedUntilProbabilities(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, std::vector const& exitRates, bool qualitative, double lowerBound, double upperBound, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { + std::vector SparseCtmcCslHelper::computeBoundedUntilProbabilities(storm::storage::SparseMatrix const&, storm::storage::SparseMatrix const&, storm::storage::BitVector const&, storm::storage::BitVector const&, std::vector const&, bool, double, double, storm::solver::LinearEquationSolverFactory const&) { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Computing bounded until probabilities is unsupported for this value type."); } @@ -208,7 +208,7 @@ namespace storm { template ::SupportsExponential, int>::type> std::vector SparseCtmcCslHelper::computeInstantaneousRewards(storm::storage::SparseMatrix const& rateMatrix, std::vector const& exitRateVector, RewardModelType const& rewardModel, double timeBound, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { - // Only compute the result if the model has a state-based reward this->getModel(). + // Only compute the result if the model has a state-based reward model. STORM_LOG_THROW(!rewardModel.empty(), storm::exceptions::InvalidPropertyException, "Missing reward model for formula. Skipping formula."); uint_fast64_t numberOfStates = rateMatrix.getRowCount(); @@ -233,13 +233,13 @@ namespace storm { } template ::SupportsExponential, int>::type> - std::vector SparseCtmcCslHelper::computeInstantaneousRewards(storm::storage::SparseMatrix const& rateMatrix, std::vector const& exitRateVector, RewardModelType const& rewardModel, double timeBound, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { + std::vector SparseCtmcCslHelper::computeInstantaneousRewards(storm::storage::SparseMatrix const&, std::vector const&, RewardModelType const&, double, storm::solver::LinearEquationSolverFactory const&) { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Computing instantaneous rewards is unsupported for this value type."); } template ::SupportsExponential, int>::type> std::vector SparseCtmcCslHelper::computeCumulativeRewards(storm::storage::SparseMatrix const& rateMatrix, std::vector const& exitRateVector, RewardModelType const& rewardModel, double timeBound, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { - // Only compute the result if the model has a state-based reward this->getModel(). + // Only compute the result if the model has a state-based reward model. STORM_LOG_THROW(!rewardModel.empty(), storm::exceptions::InvalidPropertyException, "Missing reward model for formula. Skipping formula."); uint_fast64_t numberOfStates = rateMatrix.getRowCount(); @@ -262,19 +262,19 @@ namespace storm { storm::storage::SparseMatrix uniformizedMatrix = computeUniformizedMatrix(rateMatrix, storm::storage::BitVector(numberOfStates, true), uniformizationRate, exitRateVector); // Compute the total state reward vector. - std::vector totalRewardVector = rewardModel.getTotalRewardVector(rateMatrix, exitRateVector); + std::vector totalRewardVector = rewardModel.getTotalRewardVector(rateMatrix, exitRateVector, false); // Finally, compute the transient probabilities. return computeTransientProbabilities(uniformizedMatrix, nullptr, timeBound, uniformizationRate, totalRewardVector, linearEquationSolverFactory); } template ::SupportsExponential, int>::type> - std::vector SparseCtmcCslHelper::computeCumulativeRewards(storm::storage::SparseMatrix const& rateMatrix, std::vector const& exitRateVector, RewardModelType const& rewardModel, double timeBound, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { + std::vector SparseCtmcCslHelper::computeCumulativeRewards(storm::storage::SparseMatrix const&, std::vector const&, RewardModelType const&, double, storm::solver::LinearEquationSolverFactory const&) { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Computing cumulative rewards is unsupported for this value type."); } template - std::vector SparseCtmcCslHelper::computeReachabilityTimes(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& initialStates, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { + std::vector SparseCtmcCslHelper::computeReachabilityTimes(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { // Compute expected time on CTMC by reduction to DTMC with rewards. storm::storage::SparseMatrix probabilityMatrix = computeProbabilityMatrix(rateMatrix, exitRateVector); @@ -293,7 +293,7 @@ namespace storm { return storm::modelchecker::helper::SparseDtmcPrctlHelper::computeReachabilityRewards(probabilityMatrix, backwardTransitions, totalRewardVector, targetStates, qualitative, linearEquationSolverFactory); } - template ::SupportsExponential, int>::type> + template std::vector SparseCtmcCslHelper::computeReachabilityRewards(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, RewardModelType const& rewardModel, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { STORM_LOG_THROW(!rewardModel.empty(), storm::exceptions::InvalidPropertyException, "Missing reward model for formula. Skipping formula."); @@ -324,13 +324,9 @@ namespace storm { return storm::modelchecker::helper::SparseDtmcPrctlHelper::computeReachabilityRewards(probabilityMatrix, backwardTransitions, totalRewardVector, targetStates, qualitative, linearEquationSolverFactory); } - template ::SupportsExponential, int>::type> - std::vector SparseCtmcCslHelper::computeReachabilityRewards(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, RewardModelType const& rewardModel, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { - STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Computing reachability rewards is unsupported for this value type."); - } - template - std::vector SparseCtmcCslHelper::computeLongRunAverageProbabilities(storm::storage::SparseMatrix const& probabilityMatrix, storm::storage::BitVector const& psiStates, std::vector const* exitRateVector, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { + std::vector SparseCtmcCslHelper::computeLongRunAverageProbabilities(storm::storage::SparseMatrix const& probabilityMatrix, storm::storage::BitVector const& psiStates, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { + // If there are no goal states, we avoid the computation and directly return zero. uint_fast64_t numberOfStates = probabilityMatrix.getRowCount(); if (psiStates.empty()) { @@ -342,7 +338,43 @@ namespace storm { return std::vector(numberOfStates, storm::utility::one()); } - // Start by decomposing the DTMC into its BSCCs. + ValueType zero = storm::utility::zero(); + ValueType one = storm::utility::one(); + + return computeLongRunAverages(probabilityMatrix, + [&zero, &one, &psiStates] (storm::storage::sparse::state_type const& state) -> ValueType { + if (psiStates.get(state)) { + return one; + } + return zero; + }, + exitRateVector, + linearEquationSolverFactory); + } + + template + std::vector SparseCtmcCslHelper::computeLongRunAverageRewards(storm::storage::SparseMatrix const& probabilityMatrix, RewardModelType const& rewardModel, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { + // Only compute the result if the model has a state-based reward model. + STORM_LOG_THROW(!rewardModel.empty(), storm::exceptions::InvalidPropertyException, "Missing reward model for formula. Skipping formula."); + + return computeLongRunAverageRewards(probabilityMatrix, rewardModel.getTotalRewardVector(probabilityMatrix, *exitRateVector, true), exitRateVector, linearEquationSolverFactory); + } + + template + std::vector SparseCtmcCslHelper::computeLongRunAverageRewards(storm::storage::SparseMatrix const& probabilityMatrix, std::vector const& stateRewardVector, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { + return computeLongRunAverages(probabilityMatrix, + [&stateRewardVector] (storm::storage::sparse::state_type const& state) -> ValueType { + return stateRewardVector[state]; + }, + exitRateVector, + linearEquationSolverFactory); + } + + template + std::vector SparseCtmcCslHelper::computeLongRunAverages(storm::storage::SparseMatrix const& probabilityMatrix, std::function const& valueGetter, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory){ + uint_fast64_t numberOfStates = probabilityMatrix.getRowCount(); + + // Start by decomposing the CTMC into its BSCCs. storm::storage::StronglyConnectedComponentDecomposition bsccDecomposition(probabilityMatrix, storm::storage::BitVector(probabilityMatrix.getRowCount(), true), false, true); STORM_LOG_DEBUG("Found " << bsccDecomposition.size() << " BSCCs."); @@ -448,7 +480,7 @@ namespace storm { storm::storage::StronglyConnectedComponent const& bscc = bsccDecomposition[bsccIndex]; for (auto const& state : bscc) { - bsccEquationSystemSolution[indexInStatesInBsccs[state]] = one / bscc.size(); + bsccEquationSystemSolution[indexInStatesInBsccs[state]] = one / bscc.size(); } } @@ -470,14 +502,13 @@ namespace storm { bsccEquationSystemSolution[indexInStatesInBsccs[*stateIter]] = (bsccEquationSystemSolution[indexInStatesInBsccs[*stateIter]] * (one / (*exitRateVector)[*stateIter])) / bsccTotalValue[stateToBsccIndexMap[indexInStatesInBsccs[*stateIter]]]; } } + // Calculate LRA Value for each BSCC from steady state distribution in BSCCs. for (uint_fast64_t bsccIndex = 0; bsccIndex < bsccDecomposition.size(); ++bsccIndex) { storm::storage::StronglyConnectedComponent const& bscc = bsccDecomposition[bsccIndex]; for (auto const& state : bscc) { - if (psiStates.get(state)) { - bsccLra[stateToBsccIndexMap[indexInStatesInBsccs[state]]] += bsccEquationSystemSolution[indexInStatesInBsccs[state]]; - } + bsccLra[stateToBsccIndexMap[indexInStatesInBsccs[state]]] += valueGetter(state) * bsccEquationSystemSolution[indexInStatesInBsccs[state]]; } } @@ -490,9 +521,7 @@ namespace storm { // At this point, all BSCCs are known to contain exactly one state, which is why we can set all values // directly (based on whether or not the contained state is a psi state). - if (psiStates.get(*bscc.begin())) { - bsccLra[bsccIndex] = storm::utility::one(); - } + bsccLra[bsccIndex] = valueGetter(*bscc.begin()); } for (uint_fast64_t bsccIndex = 0; bsccIndex < bsccDecomposition.size(); ++bsccIndex) { @@ -591,7 +620,7 @@ namespace storm { } // Use Fox-Glynn to get the truncation points and the weights. - std::tuple> foxGlynnResult = storm::utility::numerical::getFoxGlynnCutoff(lambda, 1e-300, 1e+300, storm::settings::getModule().getPrecision() / 8.0); + std::tuple> foxGlynnResult = storm::utility::numerical::getFoxGlynnCutoff(lambda, 1e+300, storm::settings::getModule().getPrecision() / 8.0); STORM_LOG_DEBUG("Fox-Glynn cutoff points: left=" << std::get<0>(foxGlynnResult) << ", right=" << std::get<1>(foxGlynnResult)); // Scale the weights so they add up to one. @@ -695,11 +724,13 @@ namespace storm { template std::vector SparseCtmcCslHelper::computeInstantaneousRewards(storm::storage::SparseMatrix const& rateMatrix, std::vector const& exitRateVector, storm::models::sparse::StandardRewardModel const& rewardModel, double timeBound, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); - template std::vector SparseCtmcCslHelper::computeReachabilityTimes(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& initialStates, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + template std::vector SparseCtmcCslHelper::computeReachabilityTimes(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); template std::vector SparseCtmcCslHelper::computeReachabilityRewards(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::models::sparse::StandardRewardModel const& rewardModel, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); - template std::vector SparseCtmcCslHelper::computeLongRunAverageProbabilities(storm::storage::SparseMatrix const& probabilityMatrix, storm::storage::BitVector const& psiStates, std::vector const* exitRateVector, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + template std::vector SparseCtmcCslHelper::computeLongRunAverageProbabilities(storm::storage::SparseMatrix const& probabilityMatrix, storm::storage::BitVector const& psiStates, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + template std::vector SparseCtmcCslHelper::computeLongRunAverageRewards(storm::storage::SparseMatrix const& probabilityMatrix, storm::models::sparse::StandardRewardModel const& rewardModel, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + template std::vector SparseCtmcCslHelper::computeLongRunAverageRewards(storm::storage::SparseMatrix const& probabilityMatrix, std::vector const& stateRewardVector, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); template std::vector SparseCtmcCslHelper::computeCumulativeRewards(storm::storage::SparseMatrix const& rateMatrix, std::vector const& exitRateVector, storm::models::sparse::StandardRewardModel const& rewardModel, double timeBound, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); @@ -720,14 +751,20 @@ namespace storm { template std::vector SparseCtmcCslHelper::computeInstantaneousRewards(storm::storage::SparseMatrix const& rateMatrix, std::vector const& exitRateVector, storm::models::sparse::StandardRewardModel const& rewardModel, double timeBound, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); template std::vector SparseCtmcCslHelper::computeInstantaneousRewards(storm::storage::SparseMatrix const& rateMatrix, std::vector const& exitRateVector, storm::models::sparse::StandardRewardModel const& rewardModel, double timeBound, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); - template std::vector SparseCtmcCslHelper::computeReachabilityTimes(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& initialStates, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); - template std::vector SparseCtmcCslHelper::computeReachabilityTimes(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& initialStates, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + template std::vector SparseCtmcCslHelper::computeReachabilityTimes(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + template std::vector SparseCtmcCslHelper::computeReachabilityTimes(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); template std::vector SparseCtmcCslHelper::computeReachabilityRewards(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::models::sparse::StandardRewardModel const& rewardModel, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); template std::vector SparseCtmcCslHelper::computeReachabilityRewards(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::models::sparse::StandardRewardModel const& rewardModel, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); - template std::vector SparseCtmcCslHelper::computeLongRunAverageProbabilities(storm::storage::SparseMatrix const& probabilityMatrix, storm::storage::BitVector const& psiStates, std::vector const* exitRateVector, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); - template std::vector SparseCtmcCslHelper::computeLongRunAverageProbabilities(storm::storage::SparseMatrix const& probabilityMatrix, storm::storage::BitVector const& psiStates, std::vector const* exitRateVector, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + template std::vector SparseCtmcCslHelper::computeLongRunAverageProbabilities(storm::storage::SparseMatrix const& probabilityMatrix, storm::storage::BitVector const& psiStates, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + template std::vector SparseCtmcCslHelper::computeLongRunAverageProbabilities(storm::storage::SparseMatrix const& probabilityMatrix, storm::storage::BitVector const& psiStates, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + + template std::vector SparseCtmcCslHelper::computeLongRunAverageRewards(storm::storage::SparseMatrix const& probabilityMatrix, storm::models::sparse::StandardRewardModel const& rewardModel, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + template std::vector SparseCtmcCslHelper::computeLongRunAverageRewards(storm::storage::SparseMatrix const& probabilityMatrix, storm::models::sparse::StandardRewardModel const& rewardModel, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + + template std::vector SparseCtmcCslHelper::computeLongRunAverageRewards(storm::storage::SparseMatrix const& probabilityMatrix, std::vector const& stateRewardVector, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + template std::vector SparseCtmcCslHelper::computeLongRunAverageRewards(storm::storage::SparseMatrix const& probabilityMatrix, std::vector const& stateRewardVector, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); template std::vector SparseCtmcCslHelper::computeCumulativeRewards(storm::storage::SparseMatrix const& rateMatrix, std::vector const& exitRateVector, storm::models::sparse::StandardRewardModel const& rewardModel, double timeBound, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); template std::vector SparseCtmcCslHelper::computeCumulativeRewards(storm::storage::SparseMatrix const& rateMatrix, std::vector const& exitRateVector, storm::models::sparse::StandardRewardModel const& rewardModel, double timeBound, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); diff --git a/src/storm/modelchecker/csl/helper/SparseCtmcCslHelper.h b/src/storm/modelchecker/csl/helper/SparseCtmcCslHelper.h index cfb56b375..78787b748 100644 --- a/src/storm/modelchecker/csl/helper/SparseCtmcCslHelper.h +++ b/src/storm/modelchecker/csl/helper/SparseCtmcCslHelper.h @@ -7,6 +7,8 @@ #include "storm/utility/NumberTraits.h" +#include "storm/storage/sparse/StateType.h" + namespace storm { namespace modelchecker { namespace helper { @@ -36,17 +38,20 @@ namespace storm { template ::SupportsExponential, int>::type = 0> static std::vector computeCumulativeRewards(storm::storage::SparseMatrix const& rateMatrix, std::vector const& exitRateVector, RewardModelType const& rewardModel, double timeBound, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); - template ::SupportsExponential, int>::type = 0> + template static std::vector computeReachabilityRewards(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, RewardModelType const& rewardModel, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); - template ::SupportsExponential, int>::type = 0> - static std::vector computeReachabilityRewards(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, RewardModelType const& rewardModel, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + template + static std::vector computeLongRunAverageProbabilities(storm::storage::SparseMatrix const& probabilityMatrix, storm::storage::BitVector const& psiStates, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + + template + static std::vector computeLongRunAverageRewards(storm::storage::SparseMatrix const& probabilityMatrix, RewardModelType const& rewardModel, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); template - static std::vector computeLongRunAverageProbabilities(storm::storage::SparseMatrix const& probabilityMatrix, storm::storage::BitVector const& psiStates, std::vector const* exitRateVector, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); - + static std::vector computeLongRunAverageRewards(storm::storage::SparseMatrix const& probabilityMatrix, std::vector const& stateRewardVector, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + template - static std::vector computeReachabilityTimes(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& initialStates, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); + static std::vector computeReachabilityTimes(storm::storage::SparseMatrix const& rateMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); /*! * Computes the matrix representing the transitions of the uniformized CTMC. @@ -96,6 +101,10 @@ namespace storm { */ template static storm::storage::SparseMatrix computeGeneratorMatrix(storm::storage::SparseMatrix const& rateMatrix, std::vector const& exitRates); + + private: + template + static std::vector computeLongRunAverages(storm::storage::SparseMatrix const& probabilityMatrix, std::function const& valueGetter, std::vector const* exitRateVector, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); }; } } diff --git a/src/storm/modelchecker/csl/helper/SparseMarkovAutomatonCslHelper.cpp b/src/storm/modelchecker/csl/helper/SparseMarkovAutomatonCslHelper.cpp index 14c5cef7b..a76916519 100644 --- a/src/storm/modelchecker/csl/helper/SparseMarkovAutomatonCslHelper.cpp +++ b/src/storm/modelchecker/csl/helper/SparseMarkovAutomatonCslHelper.cpp @@ -31,7 +31,7 @@ namespace storm { namespace helper { template - void SparseMarkovAutomatonCslHelper::computeBoundedReachabilityProbabilities(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, std::vector const& exitRates, storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& goalStates, storm::storage::BitVector const& markovianNonGoalStates, storm::storage::BitVector const& probabilisticNonGoalStates, std::vector& markovianNonGoalValues, std::vector& probabilisticNonGoalValues, ValueType delta, uint_fast64_t numberOfSteps, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory) { + void SparseMarkovAutomatonCslHelper::computeBoundedReachabilityProbabilities(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, std::vector const& exitRates, storm::storage::BitVector const& goalStates, storm::storage::BitVector const& markovianNonGoalStates, storm::storage::BitVector const& probabilisticNonGoalStates, std::vector& markovianNonGoalValues, std::vector& probabilisticNonGoalValues, ValueType delta, uint_fast64_t numberOfSteps, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory) { // Start by computing four sparse matrices: // * a matrix aMarkovian with all (discretized) transitions from Markovian non-goal states to all Markovian non-goal states. @@ -145,7 +145,7 @@ namespace storm { std::vector vProbabilistic(probabilisticNonGoalStates.getNumberOfSetBits()); std::vector vMarkovian(markovianNonGoalStates.getNumberOfSetBits()); - computeBoundedReachabilityProbabilities(dir, transitionMatrix, exitRateVector, markovianStates, psiStates, markovianNonGoalStates, probabilisticNonGoalStates, vMarkovian, vProbabilistic, delta, numberOfSteps, minMaxLinearEquationSolverFactory); + computeBoundedReachabilityProbabilities(dir, transitionMatrix, exitRateVector, psiStates, markovianNonGoalStates, probabilisticNonGoalStates, vMarkovian, vProbabilistic, delta, numberOfSteps, minMaxLinearEquationSolverFactory); // (4) If the lower bound of interval was non-zero, we need to take the current values as the starting values for a subsequent value iteration. if (lowerBound != storm::utility::zero()) { @@ -163,7 +163,7 @@ namespace storm { STORM_LOG_INFO("Performing " << numberOfSteps << " iterations (delta=" << delta << ") for interval [0, " << lowerBound << "]." << std::endl); // Compute the bounded reachability for interval [0, b-a]. - computeBoundedReachabilityProbabilities(dir, transitionMatrix, exitRateVector, markovianStates, storm::storage::BitVector(numberOfStates), markovianStates, ~markovianStates, vAllMarkovian, vAllProbabilistic, delta, numberOfSteps, minMaxLinearEquationSolverFactory); + computeBoundedReachabilityProbabilities(dir, transitionMatrix, exitRateVector, storm::storage::BitVector(numberOfStates), markovianStates, ~markovianStates, vAllMarkovian, vAllProbabilistic, delta, numberOfSteps, minMaxLinearEquationSolverFactory); // Create the result vector out of vAllProbabilistic and vAllMarkovian and return it. std::vector result(numberOfStates, storm::utility::zero()); @@ -189,12 +189,17 @@ namespace storm { template template - std::vector SparseMarkovAutomatonCslHelper::computeReachabilityRewards(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, RewardModelType const& rewardModel, storm::storage::BitVector const& psiStates, bool qualitative, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory) { - std::vector totalRewardVector = rewardModel.getTotalRewardVector(transitionMatrix.getRowCount(), transitionMatrix, storm::storage::BitVector(transitionMatrix.getRowGroupCount(), true)); - return computeExpectedRewards(dir, transitionMatrix, backwardTransitions, exitRateVector, markovianStates, psiStates, totalRewardVector, minMaxLinearEquationSolverFactory); + std::vector SparseMarkovAutomatonCslHelper::computeReachabilityRewards(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, RewardModelType const& rewardModel, storm::storage::BitVector const& psiStates, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory) { + std::vector stateRewardWeights(transitionMatrix.getRowGroupCount()); + for (auto const markovianState : markovianStates) { + stateRewardWeights[markovianState] = storm::utility::one() / exitRateVector[markovianState]; + } + std::vector totalRewardVector = rewardModel.getTotalActionRewardVector(transitionMatrix, stateRewardWeights); + return computeExpectedRewards(dir, transitionMatrix, backwardTransitions, psiStates, totalRewardVector, minMaxLinearEquationSolverFactory); } + template - std::vector SparseMarkovAutomatonCslHelper::computeLongRunAverageProbabilities(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& psiStates, bool qualitative, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory) { + std::vector SparseMarkovAutomatonCslHelper::computeLongRunAverageProbabilities(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& psiStates, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory) { uint_fast64_t numberOfStates = transitionMatrix.getRowGroupCount(); // If there are no goal states, we avoid the computation and directly return zero. @@ -203,7 +208,7 @@ namespace storm { } // Likewise, if all bits are set, we can avoid the computation and set. - if ((~psiStates).empty()) { + if (psiStates.full()) { return std::vector(numberOfStates, storm::utility::one()); } @@ -349,59 +354,78 @@ namespace storm { } template - std::vector SparseMarkovAutomatonCslHelper::computeTimes(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& psiStates, bool qualitative, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory) { - uint_fast64_t numberOfStates = transitionMatrix.getRowGroupCount(); - std::vector rewardValues(numberOfStates, storm::utility::zero()); - storm::utility::vector::setVectorValues(rewardValues, markovianStates, storm::utility::one()); - return computeExpectedRewards(dir, transitionMatrix, backwardTransitions, exitRateVector, markovianStates, psiStates, rewardValues, minMaxLinearEquationSolverFactory); + std::vector SparseMarkovAutomatonCslHelper::computeTimes(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& psiStates, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory) { + std::vector rewardValues(transitionMatrix.getRowCount(), storm::utility::zero()); + for (auto const markovianState : markovianStates) { + rewardValues[transitionMatrix.getRowGroupIndices()[markovianState]] = storm::utility::one() / exitRateVector[markovianState]; + } + return computeExpectedRewards(dir, transitionMatrix, backwardTransitions, psiStates, rewardValues, minMaxLinearEquationSolverFactory); } - - template - std::vector SparseMarkovAutomatonCslHelper::computeExpectedRewards(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& goalStates, std::vector const& stateRewards, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory) { + + template + std::vector + SparseMarkovAutomatonCslHelper::computeExpectedRewards(OptimizationDirection dir, + storm::storage::SparseMatrix const &transitionMatrix, + storm::storage::SparseMatrix const &backwardTransitions, + storm::storage::BitVector const &goalStates, + std::vector const &stateActionRewardVector, + storm::solver::MinMaxLinearEquationSolverFactory const &minMaxLinearEquationSolverFactory) { uint_fast64_t numberOfStates = transitionMatrix.getRowGroupCount(); - + // First, we need to check which states have infinite expected time (by definition). storm::storage::BitVector infinityStates; - if (dir ==OptimizationDirection::Minimize) { + if (dir == OptimizationDirection::Minimize) { // If we need to compute the minimum expected times, we have to set the values of those states to infinity that, under all schedulers, // reach a bottom SCC without a goal state. - + // So we start by computing all bottom SCCs without goal states. - storm::storage::StronglyConnectedComponentDecomposition sccDecomposition(transitionMatrix, ~goalStates, true, true); - + storm::storage::StronglyConnectedComponentDecomposition sccDecomposition(transitionMatrix, + ~goalStates, true, + true); + // Now form the union of all these SCCs. storm::storage::BitVector unionOfNonGoalBSccs(numberOfStates); - for (auto const& scc : sccDecomposition) { + for (auto const &scc : sccDecomposition) { for (auto state : scc) { unionOfNonGoalBSccs.set(state); } } - + // Finally, if this union is non-empty, compute the states such that all schedulers reach some state of the union. if (!unionOfNonGoalBSccs.empty()) { - infinityStates = storm::utility::graph::performProbGreater0A(transitionMatrix, transitionMatrix.getRowGroupIndices(), backwardTransitions, storm::storage::BitVector(numberOfStates, true), unionOfNonGoalBSccs); + infinityStates = storm::utility::graph::performProbGreater0A(transitionMatrix, + transitionMatrix.getRowGroupIndices(), + backwardTransitions, + storm::storage::BitVector( + numberOfStates, true), + unionOfNonGoalBSccs); } else { // Otherwise, we have no infinity states. infinityStates = storm::storage::BitVector(numberOfStates); } } else { // If we maximize the property, the expected time of a state is infinite, if an end-component without any goal state is reachable. - + // So we start by computing all MECs that have no goal state. - storm::storage::MaximalEndComponentDecomposition mecDecomposition(transitionMatrix, backwardTransitions, ~goalStates); - + storm::storage::MaximalEndComponentDecomposition mecDecomposition(transitionMatrix, + backwardTransitions, + ~goalStates); + // Now we form the union of all states in these end components. storm::storage::BitVector unionOfNonGoalMaximalEndComponents(numberOfStates); - for (auto const& mec : mecDecomposition) { - for (auto const& stateActionPair : mec) { + for (auto const &mec : mecDecomposition) { + for (auto const &stateActionPair : mec) { unionOfNonGoalMaximalEndComponents.set(stateActionPair.first); } } - + if (!unionOfNonGoalMaximalEndComponents.empty()) { // Now we need to check for which states there exists a scheduler that reaches one of the previously computed states. - infinityStates = storm::utility::graph::performProbGreater0E(transitionMatrix, transitionMatrix.getRowGroupIndices(), backwardTransitions, storm::storage::BitVector(numberOfStates, true), unionOfNonGoalMaximalEndComponents); + infinityStates = storm::utility::graph::performProbGreater0E(backwardTransitions, + storm::storage::BitVector( + numberOfStates, true), + unionOfNonGoalMaximalEndComponents); } else { // Otherwise, we have no infinity states. infinityStates = storm::storage::BitVector(numberOfStates); @@ -412,33 +436,31 @@ namespace storm { // Create resulting vector. std::vector result(numberOfStates); - + if (!maybeStates.empty()) { // Then, we can eliminate the rows and columns for all states whose values are already known. std::vector x(maybeStates.getNumberOfSetBits()); - storm::storage::SparseMatrix submatrix = transitionMatrix.getSubmatrix(true, maybeStates, maybeStates); - - // Now prepare the expected reward values for all states so they can be used as the right-hand side of the equation system. - std::vector rewardValues(stateRewards); - for (auto state : markovianStates) { - rewardValues[state] = rewardValues[state] / exitRateVector[state]; - } - + storm::storage::SparseMatrix submatrix = transitionMatrix.getSubmatrix(true, maybeStates, + maybeStates); + // Finally, prepare the actual right-hand side. std::vector b(submatrix.getRowCount()); - storm::utility::vector::selectVectorValuesRepeatedly(b, maybeStates, transitionMatrix.getRowGroupIndices(), rewardValues); - + storm::utility::vector::selectVectorValues(b, maybeStates, + transitionMatrix.getRowGroupIndices(), + stateActionRewardVector); + // Solve the corresponding system of equations. - std::unique_ptr> solver = minMaxLinearEquationSolverFactory.create(submatrix); + std::unique_ptr> solver = minMaxLinearEquationSolverFactory.create( + submatrix); solver->solveEquations(dir, x, b); - + // Set values of resulting vector according to previous result and return the result. storm::utility::vector::setVectorValues(result, maybeStates, x); } storm::utility::vector::setVectorValues(result, goalStates, storm::utility::zero()); storm::utility::vector::setVectorValues(result, infinityStates, storm::utility::infinity()); - + return result; } @@ -505,7 +527,7 @@ namespace storm { } template class SparseMarkovAutomatonCslHelper; - template std::vector SparseMarkovAutomatonCslHelper::computeReachabilityRewards(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, storm::models::sparse::StandardRewardModel const& rewardModel, storm::storage::BitVector const& psiStates, bool qualitative, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); + template std::vector SparseMarkovAutomatonCslHelper::computeReachabilityRewards(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, storm::models::sparse::StandardRewardModel const& rewardModel, storm::storage::BitVector const& psiStates, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); } } diff --git a/src/storm/modelchecker/csl/helper/SparseMarkovAutomatonCslHelper.h b/src/storm/modelchecker/csl/helper/SparseMarkovAutomatonCslHelper.h index 081ee7313..f0ab29ebc 100644 --- a/src/storm/modelchecker/csl/helper/SparseMarkovAutomatonCslHelper.h +++ b/src/storm/modelchecker/csl/helper/SparseMarkovAutomatonCslHelper.h @@ -19,20 +19,20 @@ namespace storm { static std::vector computeUntilProbabilities(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, bool qualitative, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); template - static std::vector computeReachabilityRewards(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, RewardModelType const& rewardModel, storm::storage::BitVector const& psiStates, bool qualitative, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); + static std::vector computeReachabilityRewards(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, RewardModelType const& rewardModel, storm::storage::BitVector const& psiStates, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); - static std::vector computeLongRunAverageProbabilities(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& psiStates, bool qualitative, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); + static std::vector computeLongRunAverageProbabilities(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& psiStates, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); - static std::vector computeTimes(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& psiStates, bool qualitative, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); + static std::vector computeTimes(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& psiStates, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); private: - static void computeBoundedReachabilityProbabilities(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, std::vector const& exitRates, storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& goalStates, storm::storage::BitVector const& markovianNonGoalStates, storm::storage::BitVector const& probabilisticNonGoalStates, std::vector& markovianNonGoalValues, std::vector& probabilisticNonGoalValues, ValueType delta, uint_fast64_t numberOfSteps, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); + static void computeBoundedReachabilityProbabilities(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, std::vector const& exitRates, storm::storage::BitVector const& goalStates, storm::storage::BitVector const& markovianNonGoalStates, storm::storage::BitVector const& probabilisticNonGoalStates, std::vector& markovianNonGoalValues, std::vector& probabilisticNonGoalValues, ValueType delta, uint_fast64_t numberOfSteps, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); /*! * Computes the long-run average value for the given maximal end component of a Markov automaton. * - * @param minimize Sets whether the long-run average is to be minimized or maximized. + * @param dir Sets whether the long-run average is to be minimized or maximized. * @param transitionMatrix The transition matrix of the underlying Markov automaton. * @param markovianStates A bit vector storing all markovian states. * @param exitRateVector A vector with exit rates for all states. Exit rates of probabilistic states are @@ -46,12 +46,9 @@ namespace storm { /*! * Computes the expected reward that is gained from each state before entering any of the goal states. * - * @param minimize Indicates whether minimal or maximal rewards are to be computed. + * @param dir Indicates whether minimal or maximal rewards are to be computed. * @param transitionMatrix The transition matrix of the underlying Markov automaton. * @param backwardTransitions The reversed transition relation of the underlying Markov automaton. - * @param exitRateVector A vector with exit rates for all states. Exit rates of probabilistic states are - * assumed to be zero. - * @param markovianStates A bit vector storing all markovian states. * @param goalStates The goal states that define until which point rewards are gained. * @param stateRewards A vector that defines the reward gained in each state. For probabilistic states, * this is an instantaneous reward that is fully gained and for Markovian states the actually gained @@ -59,7 +56,7 @@ namespace storm { * of the state. * @return A vector that contains the expected reward for each state of the model. */ - static std::vector computeExpectedRewards(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& exitRateVector, storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& goalStates, std::vector const& stateRewards, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); + static std::vector computeExpectedRewards(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& goalStates, std::vector const& stateRewards, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); }; } diff --git a/src/storm/modelchecker/exploration/SparseExplorationModelChecker.cpp b/src/storm/modelchecker/exploration/SparseExplorationModelChecker.cpp index 3fd18a49a..de099d655 100644 --- a/src/storm/modelchecker/exploration/SparseExplorationModelChecker.cpp +++ b/src/storm/modelchecker/exploration/SparseExplorationModelChecker.cpp @@ -440,7 +440,7 @@ namespace storm { // duplicate work is the following. Optimally, we would only do the MEC decomposition, because we need // it anyway. However, when only detecting (accepting) MECs, we do not infer which of the other states // (not contained in MECs) also have probability 0/1. - statesWithProbability0 = storm::utility::graph::performProb0A(relevantStatesMatrix, relevantStatesMatrix.getRowGroupIndices(), transposedMatrix, allStates, targetStates); + statesWithProbability0 = storm::utility::graph::performProb0A(transposedMatrix, allStates, targetStates); targetStates.set(sink, true); statesWithProbability1 = storm::utility::graph::performProb1E(relevantStatesMatrix, relevantStatesMatrix.getRowGroupIndices(), transposedMatrix, allStates, targetStates); diff --git a/src/storm/modelchecker/multiobjective/pcaa/SparseMaPcaaWeightVectorChecker.cpp b/src/storm/modelchecker/multiobjective/pcaa/SparseMaPcaaWeightVectorChecker.cpp index e39c5baba..1c4dd8420 100644 --- a/src/storm/modelchecker/multiobjective/pcaa/SparseMaPcaaWeightVectorChecker.cpp +++ b/src/storm/modelchecker/multiobjective/pcaa/SparseMaPcaaWeightVectorChecker.cpp @@ -5,7 +5,6 @@ #include "storm/adapters/CarlAdapter.h" #include "storm/models/sparse/MarkovAutomaton.h" #include "storm/models/sparse/StandardRewardModel.h" -#include "storm/transformer/EndComponentEliminator.h" #include "storm/utility/macros.h" #include "storm/utility/vector.h" diff --git a/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaParetoQuery.cpp b/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaParetoQuery.cpp index 7941757b2..639589592 100644 --- a/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaParetoQuery.cpp +++ b/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaParetoQuery.cpp @@ -7,7 +7,7 @@ #include "storm/modelchecker/results/ParetoCurveCheckResult.h" #include "storm/utility/constants.h" #include "storm/utility/vector.h" -#include "storm/settings//SettingsManager.h" +#include "storm/settings/SettingsManager.h" #include "storm/settings/modules/MultiObjectiveSettings.h" #include "storm/settings/modules/GeneralSettings.h" @@ -22,7 +22,10 @@ namespace storm { // Set the precision of the weight vector checker typename SparseModelType::ValueType weightedPrecision = storm::utility::convertNumber(storm::settings::getModule().getPrecision()); - weightedPrecision /= typename SparseModelType::ValueType(2); + weightedPrecision /= storm::utility::sqrt(storm::utility::convertNumber(this->objectives.size())); + // multiobjPrecision / sqrt(numObjectives) is the largest possible value for which termination is guaranteed. + // Lets be a little bit more precise to reduce the number of required iterations. + weightedPrecision *= storm::utility::convertNumber(0.9); this->weightVectorChecker->setWeightedPrecision(weightedPrecision); } @@ -35,9 +38,10 @@ namespace storm { // obtain the data for the checkresult std::vector> paretoOptimalPoints; - paretoOptimalPoints.reserve(this->refinementSteps.size()); - for(auto const& step : this->refinementSteps) { - paretoOptimalPoints.push_back(storm::utility::vector::convertNumericVector(this->transformPointToOriginalModel(step.lowerBoundPoint))); + std::vector vertices = this->underApproximation->getVertices(); + paretoOptimalPoints.reserve(vertices.size()); + for(auto const& vertex : vertices) { + paretoOptimalPoints.push_back(storm::utility::vector::convertNumericVector(this->transformPointToOriginalModel(vertex))); } return std::unique_ptr(new ParetoCurveCheckResult(this->originalModel.getInitialStates().getNextSetIndex(0), std::move(paretoOptimalPoints), diff --git a/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaPreprocessor.cpp b/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaPreprocessor.cpp index 45dcc5e36..125e12a1e 100644 --- a/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaPreprocessor.cpp +++ b/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaPreprocessor.cpp @@ -1,4 +1,4 @@ - #include "storm/modelchecker/multiobjective/pcaa/SparsePcaaPreprocessor.h" +#include "storm/modelchecker/multiobjective/pcaa/SparsePcaaPreprocessor.h" #include "storm/models/sparse/Mdp.h" #include "storm/models/sparse/MarkovAutomaton.h" @@ -32,7 +32,7 @@ namespace storm { PcaaObjective& currentObjective = result.objectives.back(); currentObjective.originalFormula = subFormula; if(currentObjective.originalFormula->isOperatorFormula()) { - preprocessFormula(currentObjective.originalFormula->asOperatorFormula(), result, currentObjective); + preprocessOperatorFormula(currentObjective.originalFormula->asOperatorFormula(), result, currentObjective); } else { STORM_LOG_THROW(false, storm::exceptions::InvalidPropertyException, "Could not preprocess the subformula " << *subFormula << " of " << originalFormula << " because it is not supported"); } @@ -93,7 +93,7 @@ namespace storm { } template - void SparsePcaaPreprocessor::preprocessFormula(storm::logic::OperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective) { + void SparsePcaaPreprocessor::preprocessOperatorFormula(storm::logic::OperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective) { // Get a unique name for the new reward model. currentObjective.rewardModelName = "objective" + std::to_string(result.objectives.size()); @@ -124,11 +124,11 @@ namespace storm { } if(formula.isProbabilityOperatorFormula()){ - preprocessFormula(formula.asProbabilityOperatorFormula(), result, currentObjective); + preprocessProbabilityOperatorFormula(formula.asProbabilityOperatorFormula(), result, currentObjective); } else if(formula.isRewardOperatorFormula()){ - preprocessFormula(formula.asRewardOperatorFormula(), result, currentObjective); + preprocessRewardOperatorFormula(formula.asRewardOperatorFormula(), result, currentObjective); } else if(formula.isTimeOperatorFormula()){ - preprocessFormula(formula.asTimeOperatorFormula(), result, currentObjective); + preprocessTimeOperatorFormula(formula.asTimeOperatorFormula(), result, currentObjective); } else { STORM_LOG_THROW(false, storm::exceptions::InvalidPropertyException, "Could not preprocess the objective " << formula << " because it is not supported"); } @@ -140,52 +140,52 @@ namespace storm { } template - void SparsePcaaPreprocessor::preprocessFormula(storm::logic::ProbabilityOperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective) { + void SparsePcaaPreprocessor::preprocessProbabilityOperatorFormula(storm::logic::ProbabilityOperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective) { if(formula.getSubformula().isUntilFormula()){ - preprocessFormula(formula.getSubformula().asUntilFormula(), result, currentObjective); + preprocessUntilFormula(formula.getSubformula().asUntilFormula(), result, currentObjective); } else if(formula.getSubformula().isBoundedUntilFormula()){ - preprocessFormula(formula.getSubformula().asBoundedUntilFormula(), result, currentObjective); + preprocessBoundedUntilFormula(formula.getSubformula().asBoundedUntilFormula(), result, currentObjective); } else if(formula.getSubformula().isGloballyFormula()){ - preprocessFormula(formula.getSubformula().asGloballyFormula(), result, currentObjective); + preprocessGloballyFormula(formula.getSubformula().asGloballyFormula(), result, currentObjective); } else if(formula.getSubformula().isEventuallyFormula()){ - preprocessFormula(formula.getSubformula().asEventuallyFormula(), result, currentObjective); + preprocessEventuallyFormula(formula.getSubformula().asEventuallyFormula(), result, currentObjective); } else { STORM_LOG_THROW(false, storm::exceptions::InvalidPropertyException, "The subformula of " << formula << " is not supported."); } } template - void SparsePcaaPreprocessor::preprocessFormula(storm::logic::RewardOperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective) { + void SparsePcaaPreprocessor::preprocessRewardOperatorFormula(storm::logic::RewardOperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective) { // Check if the reward model is uniquely specified STORM_LOG_THROW((formula.hasRewardModelName() && result.preprocessedModel.hasRewardModel(formula.getRewardModelName())) || result.preprocessedModel.hasUniqueRewardModel(), storm::exceptions::InvalidPropertyException, "The reward model is not unique and the formula " << formula << " does not specify a reward model."); if(formula.getSubformula().isEventuallyFormula()){ - preprocessFormula(formula.getSubformula().asEventuallyFormula(), result, currentObjective, formula.getOptionalRewardModelName()); + preprocessEventuallyFormula(formula.getSubformula().asEventuallyFormula(), result, currentObjective, formula.getOptionalRewardModelName()); } else if(formula.getSubformula().isCumulativeRewardFormula()) { - preprocessFormula(formula.getSubformula().asCumulativeRewardFormula(), result, currentObjective, formula.getOptionalRewardModelName()); + preprocessCumulativeRewardFormula(formula.getSubformula().asCumulativeRewardFormula(), result, currentObjective, formula.getOptionalRewardModelName()); } else if(formula.getSubformula().isTotalRewardFormula()) { - preprocessFormula(formula.getSubformula().asTotalRewardFormula(), result, currentObjective, formula.getOptionalRewardModelName()); + preprocessTotalRewardFormula(result, currentObjective, formula.getOptionalRewardModelName()); } else { STORM_LOG_THROW(false, storm::exceptions::InvalidPropertyException, "The subformula of " << formula << " is not supported."); } } template - void SparsePcaaPreprocessor::preprocessFormula(storm::logic::TimeOperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective) { + void SparsePcaaPreprocessor::preprocessTimeOperatorFormula(storm::logic::TimeOperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective) { // Time formulas are only supported for Markov automata STORM_LOG_THROW(result.originalModel.isOfType(storm::models::ModelType::MarkovAutomaton), storm::exceptions::InvalidPropertyException, "Time operator formulas are only supported for Markov automata."); if(formula.getSubformula().isEventuallyFormula()){ - preprocessFormula(formula.getSubformula().asEventuallyFormula(), result, currentObjective); + preprocessEventuallyFormula(formula.getSubformula().asEventuallyFormula(), result, currentObjective); } else { STORM_LOG_THROW(false, storm::exceptions::InvalidPropertyException, "The subformula of " << formula << " is not supported."); } } template - void SparsePcaaPreprocessor::preprocessFormula(storm::logic::UntilFormula const& formula, ReturnType& result, PcaaObjective& currentObjective) { + void SparsePcaaPreprocessor::preprocessUntilFormula(storm::logic::UntilFormula const& formula, ReturnType& result, PcaaObjective& currentObjective) { CheckTask phiTask(formula.getLeftSubformula()); CheckTask psiTask(formula.getRightSubformula()); storm::modelchecker::SparsePropositionalModelChecker mc(result.preprocessedModel); @@ -223,28 +223,36 @@ namespace storm { } template - void SparsePcaaPreprocessor::preprocessFormula(storm::logic::BoundedUntilFormula const& formula, ReturnType& result, PcaaObjective& currentObjective) { + void SparsePcaaPreprocessor::preprocessBoundedUntilFormula(storm::logic::BoundedUntilFormula const& formula, ReturnType& result, PcaaObjective& currentObjective) { + STORM_LOG_THROW(!result.originalModel.isOfType(storm::models::ModelType::MarkovAutomaton) || !formula.isStepBounded(), storm::exceptions::InvalidPropertyException, "Multi-objective model checking currently does not support step-bounded properties for Markov automata."); - if(formula.hasDiscreteTimeBound()) { - currentObjective.upperTimeBound = storm::utility::convertNumber(formula.getDiscreteTimeBound()); - } else { - if(result.originalModel.isOfType(storm::models::ModelType::Mdp)) { - STORM_LOG_THROW(formula.getIntervalBounds().first == std::round(formula.getIntervalBounds().first), storm::exceptions::InvalidPropertyException, "Expected a boundedUntilFormula with discrete lower time bound but got " << formula << "."); - STORM_LOG_THROW(formula.getIntervalBounds().second == std::round(formula.getIntervalBounds().second), storm::exceptions::InvalidPropertyException, "Expected a boundedUntilFormula with discrete upper time bound but got " << formula << "."); + if (formula.hasLowerBound()) { + STORM_LOG_THROW(!result.originalModel.isOfType(storm::models::ModelType::Mdp) || formula.hasIntegerLowerBound(), storm::exceptions::InvalidPropertyException, "Expected discrete lower time-bound in formula."); + // FIXME: really convert formula bound to value type? + if (formula.hasIntegerLowerBound()) { + currentObjective.lowerTimeBound = storm::utility::convertNumber(formula.getLowerBound()); } else { - STORM_LOG_THROW(result.originalModel.isOfType(storm::models::ModelType::MarkovAutomaton), storm::exceptions::InvalidPropertyException, "Got a boundedUntilFormula which can not be checked for the current model type."); - STORM_LOG_THROW(formula.getIntervalBounds().second > formula.getIntervalBounds().first, storm::exceptions::InvalidPropertyException, "Neither empty nor point intervalls are allowed but got " << formula << "."); + currentObjective.lowerTimeBound = storm::utility::convertNumber(formula.getLowerBound()); } - if(!storm::utility::isZero(formula.getIntervalBounds().first)) { - currentObjective.lowerTimeBound = storm::utility::convertNumber(formula.getIntervalBounds().first); + } + if (formula.hasUpperBound()) { + STORM_LOG_THROW(!result.originalModel.isOfType(storm::models::ModelType::Mdp) || formula.hasIntegerUpperBound(), storm::exceptions::InvalidPropertyException, "Expected discrete lower time-bound in formula."); + // FIXME: really convert formula bound to value type? + if (formula.hasIntegerUpperBound()) { + currentObjective.upperTimeBound = storm::utility::convertNumber(formula.getUpperBound()); + } else { + currentObjective.upperTimeBound = storm::utility::convertNumber(formula.getUpperBound()); } - currentObjective.upperTimeBound = storm::utility::convertNumber(formula.getIntervalBounds().second); + } else { + currentObjective.upperTimeBound = storm::utility::infinity(); } - preprocessFormula(storm::logic::UntilFormula(formula.getLeftSubformula().asSharedPointer(), formula.getRightSubformula().asSharedPointer()), result, currentObjective); + STORM_LOG_THROW(currentObjective.lowerTimeBound < currentObjective.upperTimeBound, storm::exceptions::InvalidPropertyException, "Empty or point time intervals are currently not supported by multi-objective model checking."); + + preprocessUntilFormula(storm::logic::UntilFormula(formula.getLeftSubformula().asSharedPointer(), formula.getRightSubformula().asSharedPointer()), result, currentObjective); } template - void SparsePcaaPreprocessor::preprocessFormula(storm::logic::GloballyFormula const& formula, ReturnType& result, PcaaObjective& currentObjective) { + void SparsePcaaPreprocessor::preprocessGloballyFormula(storm::logic::GloballyFormula const& formula, ReturnType& result, PcaaObjective& currentObjective) { // The formula will be transformed to an until formula for the complementary event. // If the original formula minimizes, the complementary one will maximize and vice versa. // Hence, the decision whether to consider positive or negative rewards flips. @@ -255,13 +263,13 @@ namespace storm { auto negatedSubformula = std::make_shared(storm::logic::UnaryBooleanStateFormula::OperatorType::Not, formula.getSubformula().asSharedPointer()); - preprocessFormula(storm::logic::UntilFormula(storm::logic::Formula::getTrueFormula(), negatedSubformula), result, currentObjective); + preprocessUntilFormula(storm::logic::UntilFormula(storm::logic::Formula::getTrueFormula(), negatedSubformula), result, currentObjective); } template - void SparsePcaaPreprocessor::preprocessFormula(storm::logic::EventuallyFormula const& formula, ReturnType& result, PcaaObjective& currentObjective, boost::optional const& optionalRewardModelName) { + void SparsePcaaPreprocessor::preprocessEventuallyFormula(storm::logic::EventuallyFormula const& formula, ReturnType& result, PcaaObjective& currentObjective, boost::optional const& optionalRewardModelName) { if(formula.isReachabilityProbabilityFormula()){ - preprocessFormula(storm::logic::UntilFormula(storm::logic::Formula::getTrueFormula(), formula.getSubformula().asSharedPointer()), result, currentObjective); + preprocessUntilFormula(storm::logic::UntilFormula(storm::logic::Formula::getTrueFormula(), formula.getSubformula().asSharedPointer()), result, currentObjective); return; } @@ -304,11 +312,11 @@ namespace storm { } template - void SparsePcaaPreprocessor::preprocessFormula(storm::logic::CumulativeRewardFormula const& formula, ReturnType& result, PcaaObjective& currentObjective, boost::optional const& optionalRewardModelName) { + void SparsePcaaPreprocessor::preprocessCumulativeRewardFormula(storm::logic::CumulativeRewardFormula const& formula, ReturnType& result, PcaaObjective& currentObjective, boost::optional const& optionalRewardModelName) { STORM_LOG_THROW(result.originalModel.isOfType(storm::models::ModelType::Mdp), storm::exceptions::InvalidPropertyException, "Cumulative reward formulas are not supported for the given model type."); - STORM_LOG_THROW(formula.hasDiscreteTimeBound(), storm::exceptions::InvalidPropertyException, "Expected a cumulativeRewardFormula with a discrete time bound but got " << formula << "."); - STORM_LOG_THROW(formula.getDiscreteTimeBound()>0, storm::exceptions::InvalidPropertyException, "Expected a cumulativeRewardFormula with a positive discrete time bound but got " << formula << "."); - currentObjective.upperTimeBound = storm::utility::convertNumber(formula.getDiscreteTimeBound()); + STORM_LOG_THROW(formula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Expected a cumulativeRewardFormula with a discrete time bound but got " << formula << "."); + // FIXME: really convert to value type? + currentObjective.upperTimeBound = storm::utility::convertNumber(formula.getBound()); RewardModelType objectiveRewards = result.preprocessedModel.getRewardModel(optionalRewardModelName ? optionalRewardModelName.get() : ""); objectiveRewards.reduceToStateBasedRewards(result.preprocessedModel.getTransitionMatrix(), false); @@ -324,7 +332,7 @@ namespace storm { } template - void SparsePcaaPreprocessor::preprocessFormula(storm::logic::TotalRewardFormula const& formula, ReturnType& result, PcaaObjective& currentObjective, boost::optional const& optionalRewardModelName) { + void SparsePcaaPreprocessor::preprocessTotalRewardFormula(ReturnType& result, PcaaObjective& currentObjective, boost::optional const& optionalRewardModelName) { RewardModelType objectiveRewards = result.preprocessedModel.getRewardModel(optionalRewardModelName ? optionalRewardModelName.get() : ""); objectiveRewards.reduceToStateBasedRewards(result.preprocessedModel.getTransitionMatrix(), false); if(!currentObjective.rewardsArePositive){ @@ -341,7 +349,7 @@ namespace storm { template void SparsePcaaPreprocessor::analyzeEndComponents(ReturnType& result, storm::storage::SparseMatrix const& backwardTransitions) { - + result.ecActions = storm::storage::BitVector(result.preprocessedModel.getNumberOfChoices(), false); std::vector ecs; auto mecDecomposition = storm::storage::MaximalEndComponentDecomposition(result.preprocessedModel.getTransitionMatrix(), backwardTransitions); diff --git a/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaPreprocessor.h b/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaPreprocessor.h index b5209d4ff..fb35fa9d1 100644 --- a/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaPreprocessor.h +++ b/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaPreprocessor.h @@ -50,16 +50,16 @@ namespace storm { * @param currentObjective the currently considered objective. The given formula should be a a (sub)formula of this objective * @param optionalRewardModelName the reward model name that is considered for the formula (if available) */ - static void preprocessFormula(storm::logic::OperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective); - static void preprocessFormula(storm::logic::ProbabilityOperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective); - static void preprocessFormula(storm::logic::RewardOperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective); - static void preprocessFormula(storm::logic::TimeOperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective); - static void preprocessFormula(storm::logic::UntilFormula const& formula, ReturnType& result, PcaaObjective& currentObjective); - static void preprocessFormula(storm::logic::BoundedUntilFormula const& formula, ReturnType& result, PcaaObjective& currentObjective); - static void preprocessFormula(storm::logic::GloballyFormula const& formula, ReturnType& result, PcaaObjective& currentObjective); - static void preprocessFormula(storm::logic::EventuallyFormula const& formula, ReturnType& result, PcaaObjective& currentObjective, boost::optional const& optionalRewardModelName = boost::none); - static void preprocessFormula(storm::logic::CumulativeRewardFormula const& formula, ReturnType& result, PcaaObjective& currentObjective, boost::optional const& optionalRewardModelName = boost::none); - static void preprocessFormula(storm::logic::TotalRewardFormula const& formula, ReturnType& result, PcaaObjective& currentObjective, boost::optional const& optionalRewardModelName = boost::none); + static void preprocessOperatorFormula(storm::logic::OperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective); + static void preprocessProbabilityOperatorFormula(storm::logic::ProbabilityOperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective); + static void preprocessRewardOperatorFormula(storm::logic::RewardOperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective); + static void preprocessTimeOperatorFormula(storm::logic::TimeOperatorFormula const& formula, ReturnType& result, PcaaObjective& currentObjective); + static void preprocessUntilFormula(storm::logic::UntilFormula const& formula, ReturnType& result, PcaaObjective& currentObjective); + static void preprocessBoundedUntilFormula(storm::logic::BoundedUntilFormula const& formula, ReturnType& result, PcaaObjective& currentObjective); + static void preprocessGloballyFormula(storm::logic::GloballyFormula const& formula, ReturnType& result, PcaaObjective& currentObjective); + static void preprocessEventuallyFormula(storm::logic::EventuallyFormula const& formula, ReturnType& result, PcaaObjective& currentObjective, boost::optional const& optionalRewardModelName = boost::none); + static void preprocessCumulativeRewardFormula(storm::logic::CumulativeRewardFormula const& formula, ReturnType& result, PcaaObjective& currentObjective, boost::optional const& optionalRewardModelName = boost::none); + static void preprocessTotalRewardFormula(ReturnType& result, PcaaObjective& currentObjective, boost::optional const& optionalRewardModelName = boost::none); // The total reward formula itself does not need to be provided as it is unique. /*! * Analyzes the end components of the preprocessed model. That is: diff --git a/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaWeightVectorChecker.cpp b/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaWeightVectorChecker.cpp index f3cb80ff5..8cd5245a9 100644 --- a/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaWeightVectorChecker.cpp +++ b/src/storm/modelchecker/multiobjective/pcaa/SparsePcaaWeightVectorChecker.cpp @@ -117,7 +117,7 @@ namespace storm { template void SparsePcaaWeightVectorChecker::unboundedWeightedPhase(std::vector const& weightedRewardVector) { - if(this->objectivesWithNoUpperTimeBound.empty()) { + if(this->objectivesWithNoUpperTimeBound.empty() || !storm::utility::vector::hasNonZeroEntry(weightedRewardVector)) { this->weightedResult = std::vector(model.getNumberOfStates(), storm::utility::zero()); this->scheduler = storm::storage::TotalScheduler(model.getNumberOfStates()); return; @@ -133,7 +133,7 @@ namespace storm { nonZeroRewardStates.set(state); } } - storm::storage::BitVector subsystemStates = storm::utility::graph::performProbGreater0E(model.getTransitionMatrix(), model.getTransitionMatrix().getRowGroupIndices(), model.getTransitionMatrix().transpose(true), storm::storage::BitVector(model.getNumberOfStates(), true), nonZeroRewardStates); + storm::storage::BitVector subsystemStates = storm::utility::graph::performProbGreater0E(model.getTransitionMatrix().transpose(true), storm::storage::BitVector(model.getNumberOfStates(), true), nonZeroRewardStates); // Remove neutral end components, i.e., ECs in which no reward is earned. auto ecEliminatorResult = storm::transformer::EndComponentEliminator::transform(model.getTransitionMatrix(), subsystemStates, ecActions & zeroRewardActions, possiblyRecurrentStates); diff --git a/src/storm/modelchecker/prctl/HybridDtmcPrctlModelChecker.cpp b/src/storm/modelchecker/prctl/HybridDtmcPrctlModelChecker.cpp index b84c6eb10..1936e60bd 100644 --- a/src/storm/modelchecker/prctl/HybridDtmcPrctlModelChecker.cpp +++ b/src/storm/modelchecker/prctl/HybridDtmcPrctlModelChecker.cpp @@ -38,7 +38,7 @@ namespace storm { template bool HybridDtmcPrctlModelChecker::canHandle(CheckTask const& checkTask) const { storm::logic::Formula const& formula = checkTask.getFormula(); - return formula.isInFragment(storm::logic::prctl().setLongRunAverageRewardFormulasAllowed(false).setLongRunAverageProbabilitiesAllowed(true)); + return formula.isInFragment(storm::logic::prctl().setLongRunAverageRewardFormulasAllowed(true).setLongRunAverageProbabilitiesAllowed(true)); } template @@ -70,30 +70,31 @@ namespace storm { template std::unique_ptr HybridDtmcPrctlModelChecker::computeBoundedUntilProbabilities(CheckTask const& checkTask) { storm::logic::BoundedUntilFormula const& pathFormula = checkTask.getFormula(); - STORM_LOG_THROW(pathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidArgumentException, "Formula needs to have a discrete time bound."); + STORM_LOG_THROW(!pathFormula.hasLowerBound() && pathFormula.hasUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have single upper time bound."); + STORM_LOG_THROW(pathFormula.hasIntegerUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have discrete upper time bound."); std::unique_ptr leftResultPointer = this->check(pathFormula.getLeftSubformula()); std::unique_ptr rightResultPointer = this->check(pathFormula.getRightSubformula()); SymbolicQualitativeCheckResult const& leftResult = leftResultPointer->asSymbolicQualitativeCheckResult(); SymbolicQualitativeCheckResult const& rightResult = rightResultPointer->asSymbolicQualitativeCheckResult(); - return storm::modelchecker::helper::HybridDtmcPrctlHelper::computeBoundedUntilProbabilities(this->getModel(), this->getModel().getTransitionMatrix(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), pathFormula.getDiscreteTimeBound(), *this->linearEquationSolverFactory); + return storm::modelchecker::helper::HybridDtmcPrctlHelper::computeBoundedUntilProbabilities(this->getModel(), this->getModel().getTransitionMatrix(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), pathFormula.getUpperBound() + (pathFormula.isUpperBoundStrict() ? 1ull : 0ull), *this->linearEquationSolverFactory); } template - std::unique_ptr HybridDtmcPrctlModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr HybridDtmcPrctlModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::CumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula(); - STORM_LOG_THROW(rewardPathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidArgumentException, "Formula needs to have a discrete time bound."); - return storm::modelchecker::helper::HybridDtmcPrctlHelper::computeCumulativeRewards(this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getDiscreteTimeBound(), *this->linearEquationSolverFactory); + STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + return storm::modelchecker::helper::HybridDtmcPrctlHelper::computeCumulativeRewards(this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound() + (rewardPathFormula.isBoundStrict() ? 1ull : 0ull), *this->linearEquationSolverFactory); } template - std::unique_ptr HybridDtmcPrctlModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr HybridDtmcPrctlModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::InstantaneousRewardFormula const& rewardPathFormula = checkTask.getFormula(); - STORM_LOG_THROW(rewardPathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidArgumentException, "Formula needs to have a discrete time bound."); - return storm::modelchecker::helper::HybridDtmcPrctlHelper::computeInstantaneousRewards(this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getDiscreteTimeBound(), *this->linearEquationSolverFactory); + STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + return storm::modelchecker::helper::HybridDtmcPrctlHelper::computeInstantaneousRewards(this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound(), *this->linearEquationSolverFactory); } template - std::unique_ptr HybridDtmcPrctlModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr HybridDtmcPrctlModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula(); std::unique_ptr subResultPointer = this->check(eventuallyFormula.getSubformula()); SymbolicQualitativeCheckResult const& subResult = subResultPointer->asSymbolicQualitativeCheckResult(); @@ -107,13 +108,12 @@ namespace storm { std::unique_ptr subResultPointer = this->check(stateFormula); SymbolicQualitativeCheckResult const& subResult = subResultPointer->asSymbolicQualitativeCheckResult(); - // Create ODD for the translation. - storm::dd::Odd odd = this->getModel().getReachableStates().createOdd(); - - storm::storage::SparseMatrix explicitProbabilityMatrix = this->getModel().getTransitionMatrix().toMatrix(odd, odd); - - std::vector result = storm::modelchecker::helper::SparseDtmcPrctlHelper::computeLongRunAverageProbabilities(explicitProbabilityMatrix, subResult.getTruthValuesVector().toVector(odd), checkTask.isQualitativeSet(), *this->linearEquationSolverFactory); - return std::unique_ptr(new HybridQuantitativeCheckResult(this->getModel().getReachableStates(), this->getModel().getManager().getBddZero(), this->getModel().getManager().template getAddZero(), this->getModel().getReachableStates(), std::move(odd), std::move(result))); + return storm::modelchecker::helper::HybridDtmcPrctlHelper::computeLongRunAverageProbabilities(this->getModel(), this->getModel().getTransitionMatrix(), subResult.getTruthValuesVector(), *this->linearEquationSolverFactory); + } + + template + std::unique_ptr HybridDtmcPrctlModelChecker::computeLongRunAverageRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + return storm::modelchecker::helper::HybridDtmcPrctlHelper::computeLongRunAverageRewards(this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), *this->linearEquationSolverFactory); } template class HybridDtmcPrctlModelChecker>; diff --git a/src/storm/modelchecker/prctl/HybridDtmcPrctlModelChecker.h b/src/storm/modelchecker/prctl/HybridDtmcPrctlModelChecker.h index 748bf422f..b54ed38ea 100644 --- a/src/storm/modelchecker/prctl/HybridDtmcPrctlModelChecker.h +++ b/src/storm/modelchecker/prctl/HybridDtmcPrctlModelChecker.h @@ -25,10 +25,12 @@ namespace storm { virtual std::unique_ptr computeNextProbabilities(CheckTask const& checkTask) override; virtual std::unique_ptr computeUntilProbabilities(CheckTask const& checkTask) override; virtual std::unique_ptr computeGloballyProbabilities(CheckTask const& checkTask) override; + virtual std::unique_ptr computeLongRunAverageProbabilities(CheckTask const& checkTask) override; + + virtual std::unique_ptr computeLongRunAverageRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; virtual std::unique_ptr computeCumulativeRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; virtual std::unique_ptr computeInstantaneousRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; virtual std::unique_ptr computeReachabilityRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; - virtual std::unique_ptr computeLongRunAverageProbabilities(CheckTask const& checkTask) override; private: // An object that is used for retrieving linear equation solvers. diff --git a/src/storm/modelchecker/prctl/HybridMdpPrctlModelChecker.cpp b/src/storm/modelchecker/prctl/HybridMdpPrctlModelChecker.cpp index cc324e1bf..56aed7679 100644 --- a/src/storm/modelchecker/prctl/HybridMdpPrctlModelChecker.cpp +++ b/src/storm/modelchecker/prctl/HybridMdpPrctlModelChecker.cpp @@ -68,32 +68,33 @@ namespace storm { std::unique_ptr HybridMdpPrctlModelChecker::computeBoundedUntilProbabilities(CheckTask const& checkTask) { storm::logic::BoundedUntilFormula const& pathFormula = checkTask.getFormula(); STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); - STORM_LOG_THROW(pathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + STORM_LOG_THROW(!pathFormula.hasLowerBound() && pathFormula.hasUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have single upper time bound."); + STORM_LOG_THROW(pathFormula.hasIntegerUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have discrete upper time bound."); std::unique_ptr leftResultPointer = this->check(pathFormula.getLeftSubformula()); std::unique_ptr rightResultPointer = this->check(pathFormula.getRightSubformula()); SymbolicQualitativeCheckResult const& leftResult = leftResultPointer->asSymbolicQualitativeCheckResult(); SymbolicQualitativeCheckResult const& rightResult = rightResultPointer->asSymbolicQualitativeCheckResult(); - return storm::modelchecker::helper::HybridMdpPrctlHelper::computeBoundedUntilProbabilities(checkTask.getOptimizationDirection(), this->getModel(), this->getModel().getTransitionMatrix(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), pathFormula.getDiscreteTimeBound(), *this->linearEquationSolverFactory); + return storm::modelchecker::helper::HybridMdpPrctlHelper::computeBoundedUntilProbabilities(checkTask.getOptimizationDirection(), this->getModel(), this->getModel().getTransitionMatrix(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), pathFormula.getUpperBound() + (pathFormula.isUpperBoundStrict() ? 1ull : 0ull), *this->linearEquationSolverFactory); } template - std::unique_ptr HybridMdpPrctlModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr HybridMdpPrctlModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::CumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula(); STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); - STORM_LOG_THROW(rewardPathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); - return storm::modelchecker::helper::HybridMdpPrctlHelper::computeCumulativeRewards(checkTask.getOptimizationDirection(), this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getDiscreteTimeBound(), *this->linearEquationSolverFactory); + STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + return storm::modelchecker::helper::HybridMdpPrctlHelper::computeCumulativeRewards(checkTask.getOptimizationDirection(), this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound() + (rewardPathFormula.isBoundStrict() ? 1ull : 0ll), *this->linearEquationSolverFactory); } template - std::unique_ptr HybridMdpPrctlModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr HybridMdpPrctlModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::InstantaneousRewardFormula const& rewardPathFormula = checkTask.getFormula(); STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); - STORM_LOG_THROW(rewardPathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); - return storm::modelchecker::helper::HybridMdpPrctlHelper::computeInstantaneousRewards(checkTask.getOptimizationDirection(), this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getDiscreteTimeBound(), *this->linearEquationSolverFactory); + STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + return storm::modelchecker::helper::HybridMdpPrctlHelper::computeInstantaneousRewards(checkTask.getOptimizationDirection(), this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound(), *this->linearEquationSolverFactory); } template - std::unique_ptr HybridMdpPrctlModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr HybridMdpPrctlModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula(); STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); std::unique_ptr subResultPointer = this->check(eventuallyFormula.getSubformula()); diff --git a/src/storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.cpp b/src/storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.cpp index dda0cd248..5bbf6cf23 100644 --- a/src/storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.cpp +++ b/src/storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.cpp @@ -36,18 +36,19 @@ namespace storm { template bool SparseDtmcPrctlModelChecker::canHandle(CheckTask const& checkTask) const { storm::logic::Formula const& formula = checkTask.getFormula(); - return formula.isInFragment(storm::logic::prctl().setLongRunAverageRewardFormulasAllowed(false).setLongRunAverageProbabilitiesAllowed(true).setConditionalProbabilityFormulasAllowed(true).setConditionalRewardFormulasAllowed(true).setOnlyEventuallyFormuluasInConditionalFormulasAllowed(true)); + return formula.isInFragment(storm::logic::prctl().setLongRunAverageRewardFormulasAllowed(true).setLongRunAverageProbabilitiesAllowed(true).setConditionalProbabilityFormulasAllowed(true).setConditionalRewardFormulasAllowed(true).setOnlyEventuallyFormuluasInConditionalFormulasAllowed(true)); } template std::unique_ptr SparseDtmcPrctlModelChecker::computeBoundedUntilProbabilities(CheckTask const& checkTask) { storm::logic::BoundedUntilFormula const& pathFormula = checkTask.getFormula(); - STORM_LOG_THROW(pathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + STORM_LOG_THROW(!pathFormula.hasLowerBound() && pathFormula.hasUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have single upper time bound."); + STORM_LOG_THROW(pathFormula.hasIntegerUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have discrete upper time bound."); std::unique_ptr leftResultPointer = this->check(pathFormula.getLeftSubformula()); std::unique_ptr rightResultPointer = this->check(pathFormula.getRightSubformula()); ExplicitQualitativeCheckResult const& leftResult = leftResultPointer->asExplicitQualitativeCheckResult(); ExplicitQualitativeCheckResult const& rightResult = rightResultPointer->asExplicitQualitativeCheckResult(); - std::vector numericResult = storm::modelchecker::helper::SparseDtmcPrctlHelper::computeBoundedUntilProbabilities(this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), pathFormula.getDiscreteTimeBound(), *linearEquationSolverFactory); + std::vector numericResult = storm::modelchecker::helper::SparseDtmcPrctlHelper::computeBoundedUntilProbabilities(this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), pathFormula.getUpperBound() + (pathFormula.isUpperBoundStrict() ? 1ull : 0ull), *linearEquationSolverFactory); std::unique_ptr result = std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(numericResult))); return result; } @@ -82,23 +83,23 @@ namespace storm { } template - std::unique_ptr SparseDtmcPrctlModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SparseDtmcPrctlModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::CumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula(); - STORM_LOG_THROW(rewardPathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); - std::vector numericResult = storm::modelchecker::helper::SparseDtmcPrctlHelper::computeCumulativeRewards(this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getDiscreteTimeBound(), *linearEquationSolverFactory); + STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + std::vector numericResult = storm::modelchecker::helper::SparseDtmcPrctlHelper::computeCumulativeRewards(this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound() + (rewardPathFormula.isBoundStrict() ? 1ull : 0ull), *linearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(numericResult))); } template - std::unique_ptr SparseDtmcPrctlModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SparseDtmcPrctlModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::InstantaneousRewardFormula const& rewardPathFormula = checkTask.getFormula(); - STORM_LOG_THROW(rewardPathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); - std::vector numericResult = storm::modelchecker::helper::SparseDtmcPrctlHelper::computeInstantaneousRewards(this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getDiscreteTimeBound(), *linearEquationSolverFactory); + STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + std::vector numericResult = storm::modelchecker::helper::SparseDtmcPrctlHelper::computeInstantaneousRewards(this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound(), *linearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(numericResult))); } template - std::unique_ptr SparseDtmcPrctlModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SparseDtmcPrctlModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula(); std::unique_ptr subResultPointer = this->check(eventuallyFormula.getSubformula()); ExplicitQualitativeCheckResult const& subResult = subResultPointer->asExplicitQualitativeCheckResult(); @@ -111,10 +112,17 @@ namespace storm { storm::logic::StateFormula const& stateFormula = checkTask.getFormula(); std::unique_ptr subResultPointer = this->check(stateFormula); ExplicitQualitativeCheckResult const& subResult = subResultPointer->asExplicitQualitativeCheckResult(); - std::vector numericResult = storm::modelchecker::helper::SparseCtmcCslHelper::computeLongRunAverageProbabilities(this->getModel().getTransitionMatrix(), subResult.getTruthValuesVector(), nullptr, checkTask.isQualitativeSet(), *linearEquationSolverFactory); + std::vector numericResult = storm::modelchecker::helper::SparseCtmcCslHelper::computeLongRunAverageProbabilities(this->getModel().getTransitionMatrix(), subResult.getTruthValuesVector(), nullptr, *linearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(numericResult))); } + template + std::unique_ptr SparseDtmcPrctlModelChecker::computeLongRunAverageRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::vector numericResult = storm::modelchecker::helper::SparseCtmcCslHelper::computeLongRunAverageRewards(this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), nullptr, *linearEquationSolverFactory); + return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(numericResult))); + + } + template std::unique_ptr SparseDtmcPrctlModelChecker::computeConditionalProbabilities(CheckTask const& checkTask) { storm::logic::ConditionalFormula const& conditionalFormula = checkTask.getFormula(); @@ -131,7 +139,7 @@ namespace storm { } template - std::unique_ptr SparseDtmcPrctlModelChecker::computeConditionalRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SparseDtmcPrctlModelChecker::computeConditionalRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::ConditionalFormula const& conditionalFormula = checkTask.getFormula(); STORM_LOG_THROW(conditionalFormula.getSubformula().isReachabilityRewardFormula(), storm::exceptions::InvalidPropertyException, "Illegal conditional probability formula."); STORM_LOG_THROW(conditionalFormula.getConditionFormula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException, "Illegal conditional probability formula."); diff --git a/src/storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.h b/src/storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.h index 2a6269a71..3b40cad37 100644 --- a/src/storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.h +++ b/src/storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.h @@ -31,6 +31,7 @@ namespace storm { virtual std::unique_ptr computeInstantaneousRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; virtual std::unique_ptr computeReachabilityRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; virtual std::unique_ptr computeConditionalRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; + virtual std::unique_ptr computeLongRunAverageRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) override; private: // An object that is used for retrieving linear equation solvers. diff --git a/src/storm/modelchecker/prctl/SparseMdpPrctlModelChecker.cpp b/src/storm/modelchecker/prctl/SparseMdpPrctlModelChecker.cpp index 2fd883812..2a7f6d725 100644 --- a/src/storm/modelchecker/prctl/SparseMdpPrctlModelChecker.cpp +++ b/src/storm/modelchecker/prctl/SparseMdpPrctlModelChecker.cpp @@ -26,7 +26,7 @@ #include "storm/storage/MaximalEndComponentDecomposition.h" -#include "storm/exceptions/InvalidArgumentException.h" +#include "storm/exceptions/InvalidPropertyException.h" namespace storm { namespace modelchecker { @@ -57,19 +57,21 @@ namespace storm { template std::unique_ptr SparseMdpPrctlModelChecker::computeBoundedUntilProbabilities(CheckTask const& checkTask) { storm::logic::BoundedUntilFormula const& pathFormula = checkTask.getFormula(); - STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidArgumentException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); + STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); + STORM_LOG_THROW(!pathFormula.hasLowerBound() && pathFormula.hasUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have single upper time bound."); + STORM_LOG_THROW(pathFormula.hasIntegerUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have discrete upper time bound."); std::unique_ptr leftResultPointer = this->check(pathFormula.getLeftSubformula()); std::unique_ptr rightResultPointer = this->check(pathFormula.getRightSubformula()); ExplicitQualitativeCheckResult const& leftResult = leftResultPointer->asExplicitQualitativeCheckResult(); ExplicitQualitativeCheckResult const& rightResult = rightResultPointer->asExplicitQualitativeCheckResult(); - std::vector numericResult = storm::modelchecker::helper::SparseMdpPrctlHelper::computeBoundedUntilProbabilities(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), pathFormula.getDiscreteTimeBound(), *minMaxLinearEquationSolverFactory); + std::vector numericResult = storm::modelchecker::helper::SparseMdpPrctlHelper::computeBoundedUntilProbabilities(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), pathFormula.getUpperBound() + (pathFormula.isUpperBoundStrict() ? 1ull : 0ull), *minMaxLinearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(numericResult))); } template std::unique_ptr SparseMdpPrctlModelChecker::computeNextProbabilities(CheckTask const& checkTask) { storm::logic::NextFormula const& pathFormula = checkTask.getFormula(); - STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidArgumentException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); + STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); std::unique_ptr subResultPointer = this->check(pathFormula.getSubformula()); ExplicitQualitativeCheckResult const& subResult = subResultPointer->asExplicitQualitativeCheckResult(); std::vector numericResult = storm::modelchecker::helper::SparseMdpPrctlHelper::computeNextProbabilities(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), subResult.getTruthValuesVector(), *minMaxLinearEquationSolverFactory); @@ -79,7 +81,7 @@ namespace storm { template std::unique_ptr SparseMdpPrctlModelChecker::computeUntilProbabilities(CheckTask const& checkTask) { storm::logic::UntilFormula const& pathFormula = checkTask.getFormula(); - STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidArgumentException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); + STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); std::unique_ptr leftResultPointer = this->check(pathFormula.getLeftSubformula()); std::unique_ptr rightResultPointer = this->check(pathFormula.getRightSubformula()); ExplicitQualitativeCheckResult const& leftResult = leftResultPointer->asExplicitQualitativeCheckResult(); @@ -95,7 +97,7 @@ namespace storm { template std::unique_ptr SparseMdpPrctlModelChecker::computeGloballyProbabilities(CheckTask const& checkTask) { storm::logic::GloballyFormula const& pathFormula = checkTask.getFormula(); - STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidArgumentException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); + STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); std::unique_ptr subResultPointer = this->check(pathFormula.getSubformula()); ExplicitQualitativeCheckResult const& subResult = subResultPointer->asExplicitQualitativeCheckResult(); auto ret = storm::modelchecker::helper::SparseMdpPrctlHelper::computeGloballyProbabilities(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), *minMaxLinearEquationSolverFactory); @@ -105,7 +107,7 @@ namespace storm { template std::unique_ptr SparseMdpPrctlModelChecker::computeConditionalProbabilities(CheckTask const& checkTask) { storm::logic::ConditionalFormula const& conditionalFormula = checkTask.getFormula(); - STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidArgumentException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); + STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); STORM_LOG_THROW(this->getModel().getInitialStates().getNumberOfSetBits() == 1, storm::exceptions::InvalidPropertyException, "Cannot compute conditional probabilities on MDPs with more than one initial state."); STORM_LOG_THROW(conditionalFormula.getSubformula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException, "Illegal conditional probability formula."); STORM_LOG_THROW(conditionalFormula.getConditionFormula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException, "Illegal conditional probability formula."); @@ -115,31 +117,31 @@ namespace storm { ExplicitQualitativeCheckResult const& leftResult = leftResultPointer->asExplicitQualitativeCheckResult(); ExplicitQualitativeCheckResult const& rightResult = rightResultPointer->asExplicitQualitativeCheckResult(); - return storm::modelchecker::helper::SparseMdpPrctlHelper::computeConditionalProbabilities(checkTask.getOptimizationDirection(), *this->getModel().getInitialStates().begin(), this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), checkTask.isQualitativeSet(), *minMaxLinearEquationSolverFactory); + return storm::modelchecker::helper::SparseMdpPrctlHelper::computeConditionalProbabilities(checkTask.getOptimizationDirection(), *this->getModel().getInitialStates().begin(), this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), *minMaxLinearEquationSolverFactory); } template - std::unique_ptr SparseMdpPrctlModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SparseMdpPrctlModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::CumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula(); - STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidArgumentException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); - STORM_LOG_THROW(rewardPathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidArgumentException, "Formula needs to have a discrete time bound."); - std::vector numericResult = storm::modelchecker::helper::SparseMdpPrctlHelper::computeCumulativeRewards(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getDiscreteTimeBound(), *minMaxLinearEquationSolverFactory); + STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); + STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + std::vector numericResult = storm::modelchecker::helper::SparseMdpPrctlHelper::computeCumulativeRewards(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound() + (rewardPathFormula.isBoundStrict() ? 1ull : 0ull), *minMaxLinearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(numericResult))); } template - std::unique_ptr SparseMdpPrctlModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SparseMdpPrctlModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::InstantaneousRewardFormula const& rewardPathFormula = checkTask.getFormula(); - STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidArgumentException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); - STORM_LOG_THROW(rewardPathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidArgumentException, "Formula needs to have a discrete time bound."); - std::vector numericResult = storm::modelchecker::helper::SparseMdpPrctlHelper::computeInstantaneousRewards(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getDiscreteTimeBound(), *minMaxLinearEquationSolverFactory); + STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); + STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + std::vector numericResult = storm::modelchecker::helper::SparseMdpPrctlHelper::computeInstantaneousRewards(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound(), *minMaxLinearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(numericResult))); } template - std::unique_ptr SparseMdpPrctlModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SparseMdpPrctlModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula(); - STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidArgumentException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); + STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); std::unique_ptr subResultPointer = this->check(eventuallyFormula.getSubformula()); ExplicitQualitativeCheckResult const& subResult = subResultPointer->asExplicitQualitativeCheckResult(); std::vector numericResult = storm::modelchecker::helper::SparseMdpPrctlHelper::computeReachabilityRewards(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), *minMaxLinearEquationSolverFactory); @@ -149,10 +151,10 @@ namespace storm { template std::unique_ptr SparseMdpPrctlModelChecker::computeLongRunAverageProbabilities(CheckTask const& checkTask) { storm::logic::StateFormula const& stateFormula = checkTask.getFormula(); - STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidArgumentException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); + STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); std::unique_ptr subResultPointer = this->check(stateFormula); ExplicitQualitativeCheckResult const& subResult = subResultPointer->asExplicitQualitativeCheckResult(); - std::vector numericResult = storm::modelchecker::helper::SparseMdpPrctlHelper::computeLongRunAverageProbabilities(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), *minMaxLinearEquationSolverFactory); + std::vector numericResult = storm::modelchecker::helper::SparseMdpPrctlHelper::computeLongRunAverageProbabilities(checkTask.getOptimizationDirection(), this->getModel().getTransitionMatrix(), this->getModel().getBackwardTransitions(), subResult.getTruthValuesVector(), *minMaxLinearEquationSolverFactory); return std::unique_ptr(new ExplicitQuantitativeCheckResult(std::move(numericResult))); } diff --git a/src/storm/modelchecker/prctl/SymbolicDtmcPrctlModelChecker.cpp b/src/storm/modelchecker/prctl/SymbolicDtmcPrctlModelChecker.cpp index 931ce3b89..c52307315 100644 --- a/src/storm/modelchecker/prctl/SymbolicDtmcPrctlModelChecker.cpp +++ b/src/storm/modelchecker/prctl/SymbolicDtmcPrctlModelChecker.cpp @@ -70,33 +70,34 @@ namespace storm { template std::unique_ptr SymbolicDtmcPrctlModelChecker::computeBoundedUntilProbabilities(CheckTask const& checkTask) { storm::logic::BoundedUntilFormula const& pathFormula = checkTask.getFormula(); - STORM_LOG_THROW(pathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + STORM_LOG_THROW(!pathFormula.hasLowerBound() && pathFormula.hasUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have single upper time bound."); + STORM_LOG_THROW(pathFormula.hasIntegerUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have discrete upper time bound."); std::unique_ptr leftResultPointer = this->check(pathFormula.getLeftSubformula()); std::unique_ptr rightResultPointer = this->check(pathFormula.getRightSubformula()); SymbolicQualitativeCheckResult const& leftResult = leftResultPointer->asSymbolicQualitativeCheckResult(); SymbolicQualitativeCheckResult const& rightResult = rightResultPointer->asSymbolicQualitativeCheckResult(); - storm::dd::Add numericResult = storm::modelchecker::helper::SymbolicDtmcPrctlHelper::computeBoundedUntilProbabilities(this->getModel(), this->getModel().getTransitionMatrix(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), pathFormula.getDiscreteTimeBound(), *this->linearEquationSolverFactory); + storm::dd::Add numericResult = storm::modelchecker::helper::SymbolicDtmcPrctlHelper::computeBoundedUntilProbabilities(this->getModel(), this->getModel().getTransitionMatrix(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), pathFormula.getUpperBound() + (pathFormula.isUpperBoundStrict() ? 1ull : 0ull), *this->linearEquationSolverFactory); return std::unique_ptr>(new SymbolicQuantitativeCheckResult(this->getModel().getReachableStates(), numericResult)); } template - std::unique_ptr SymbolicDtmcPrctlModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SymbolicDtmcPrctlModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::CumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula(); - STORM_LOG_THROW(rewardPathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); - storm::dd::Add numericResult = storm::modelchecker::helper::SymbolicDtmcPrctlHelper::computeCumulativeRewards(this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getDiscreteTimeBound(), *this->linearEquationSolverFactory); + STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + storm::dd::Add numericResult = storm::modelchecker::helper::SymbolicDtmcPrctlHelper::computeCumulativeRewards(this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound() + (rewardPathFormula.isBoundStrict() ? 1ull : 0ull), *this->linearEquationSolverFactory); return std::unique_ptr>(new SymbolicQuantitativeCheckResult(this->getModel().getReachableStates(), numericResult)); } template - std::unique_ptr SymbolicDtmcPrctlModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SymbolicDtmcPrctlModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::InstantaneousRewardFormula const& rewardPathFormula = checkTask.getFormula(); - STORM_LOG_THROW(rewardPathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); - storm::dd::Add numericResult = storm::modelchecker::helper::SymbolicDtmcPrctlHelper::computeInstantaneousRewards(this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getDiscreteTimeBound(), *this->linearEquationSolverFactory); + STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + storm::dd::Add numericResult = storm::modelchecker::helper::SymbolicDtmcPrctlHelper::computeInstantaneousRewards(this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound(), *this->linearEquationSolverFactory); return std::unique_ptr>(new SymbolicQuantitativeCheckResult(this->getModel().getReachableStates(), numericResult)); } template - std::unique_ptr SymbolicDtmcPrctlModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SymbolicDtmcPrctlModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula(); std::unique_ptr subResultPointer = this->check(eventuallyFormula.getSubformula()); SymbolicQualitativeCheckResult const& subResult = subResultPointer->asSymbolicQualitativeCheckResult(); diff --git a/src/storm/modelchecker/prctl/SymbolicMdpPrctlModelChecker.cpp b/src/storm/modelchecker/prctl/SymbolicMdpPrctlModelChecker.cpp index c901012fc..2ac26509a 100644 --- a/src/storm/modelchecker/prctl/SymbolicMdpPrctlModelChecker.cpp +++ b/src/storm/modelchecker/prctl/SymbolicMdpPrctlModelChecker.cpp @@ -70,32 +70,33 @@ namespace storm { std::unique_ptr SymbolicMdpPrctlModelChecker::computeBoundedUntilProbabilities(CheckTask const& checkTask) { storm::logic::BoundedUntilFormula const& pathFormula = checkTask.getFormula(); STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidArgumentException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); - STORM_LOG_THROW(pathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + STORM_LOG_THROW(!pathFormula.hasLowerBound() && pathFormula.hasUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have single upper time bound."); + STORM_LOG_THROW(pathFormula.hasIntegerUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have discrete upper time bound."); std::unique_ptr leftResultPointer = this->check(pathFormula.getLeftSubformula()); std::unique_ptr rightResultPointer = this->check(pathFormula.getRightSubformula()); SymbolicQualitativeCheckResult const& leftResult = leftResultPointer->asSymbolicQualitativeCheckResult(); SymbolicQualitativeCheckResult const& rightResult = rightResultPointer->asSymbolicQualitativeCheckResult(); - return storm::modelchecker::helper::SymbolicMdpPrctlHelper::computeBoundedUntilProbabilities(checkTask.getOptimizationDirection(), this->getModel(), this->getModel().getTransitionMatrix(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), pathFormula.getDiscreteTimeBound(), *this->linearEquationSolverFactory); + return storm::modelchecker::helper::SymbolicMdpPrctlHelper::computeBoundedUntilProbabilities(checkTask.getOptimizationDirection(), this->getModel(), this->getModel().getTransitionMatrix(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), pathFormula.getUpperBound() + (pathFormula.isUpperBoundStrict() ? 1ull : 0ull), *this->linearEquationSolverFactory); } template - std::unique_ptr SymbolicMdpPrctlModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SymbolicMdpPrctlModelChecker::computeCumulativeRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::CumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula(); STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidArgumentException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); - STORM_LOG_THROW(rewardPathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); - return storm::modelchecker::helper::SymbolicMdpPrctlHelper::computeCumulativeRewards(checkTask.getOptimizationDirection(), this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getDiscreteTimeBound(), *this->linearEquationSolverFactory); + STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + return storm::modelchecker::helper::SymbolicMdpPrctlHelper::computeCumulativeRewards(checkTask.getOptimizationDirection(), this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound() + (rewardPathFormula.isBoundStrict() ? 1ull : 0ull), *this->linearEquationSolverFactory); } template - std::unique_ptr SymbolicMdpPrctlModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SymbolicMdpPrctlModelChecker::computeInstantaneousRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::InstantaneousRewardFormula const& rewardPathFormula = checkTask.getFormula(); STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidArgumentException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); - STORM_LOG_THROW(rewardPathFormula.hasDiscreteTimeBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); - return storm::modelchecker::helper::SymbolicMdpPrctlHelper::computeInstantaneousRewards(checkTask.getOptimizationDirection(), this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getDiscreteTimeBound(), *this->linearEquationSolverFactory); + STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound."); + return storm::modelchecker::helper::SymbolicMdpPrctlHelper::computeInstantaneousRewards(checkTask.getOptimizationDirection(), this->getModel(), this->getModel().getTransitionMatrix(), checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""), rewardPathFormula.getBound(), *this->linearEquationSolverFactory); } template - std::unique_ptr SymbolicMdpPrctlModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SymbolicMdpPrctlModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula(); STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException, "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model."); std::unique_ptr subResultPointer = this->check(eventuallyFormula.getSubformula()); diff --git a/src/storm/modelchecker/prctl/helper/HybridDtmcPrctlHelper.cpp b/src/storm/modelchecker/prctl/helper/HybridDtmcPrctlHelper.cpp index d5e21fa67..af3bbc2cf 100644 --- a/src/storm/modelchecker/prctl/helper/HybridDtmcPrctlHelper.cpp +++ b/src/storm/modelchecker/prctl/helper/HybridDtmcPrctlHelper.cpp @@ -1,5 +1,6 @@ #include "storm/modelchecker/prctl/helper/HybridDtmcPrctlHelper.h" +#include "storm/modelchecker/prctl/helper/SparseDtmcPrctlHelper.h" #include "storm/solver/LinearEquationSolver.h" @@ -72,6 +73,7 @@ namespace storm { std::vector b = subvector.toVector(odd); std::unique_ptr> solver = linearEquationSolverFactory.create(std::move(explicitSubmatrix)); + solver->setBounds(storm::utility::zero(), storm::utility::one()); solver->solveEquations(x, b); // Return a hybrid check result that stores the numerical values explicitly. @@ -139,7 +141,6 @@ namespace storm { } } - template std::unique_ptr HybridDtmcPrctlHelper::computeInstantaneousRewards(storm::models::symbolic::Model const& model, storm::dd::Add const& transitionMatrix, RewardModelType const& rewardModel, uint_fast64_t stepBound, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { // Only compute the result if the model has at least one reward this->getModel(). @@ -237,6 +238,7 @@ namespace storm { // Now solve the resulting equation system. std::unique_ptr> solver = linearEquationSolverFactory.create(std::move(explicitSubmatrix)); + solver->setLowerBound(storm::utility::zero()); solver->solveEquations(x, b); // Return a hybrid check result that stores the numerical values explicitly. @@ -247,6 +249,26 @@ namespace storm { } } + template + std::unique_ptr HybridDtmcPrctlHelper::computeLongRunAverageProbabilities(storm::models::symbolic::Model const& model, storm::dd::Add const& transitionMatrix, storm::dd::Bdd const& targetStates, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { + // Create ODD for the translation. + storm::dd::Odd odd = model.getReachableStates().createOdd(); + storm::storage::SparseMatrix explicitProbabilityMatrix = model.getTransitionMatrix().toMatrix(odd, odd); + + std::vector result = storm::modelchecker::helper::SparseDtmcPrctlHelper::computeLongRunAverageProbabilities(explicitProbabilityMatrix, targetStates.toVector(odd), linearEquationSolverFactory); + return std::unique_ptr(new HybridQuantitativeCheckResult(model.getReachableStates(), model.getManager().getBddZero(), model.getManager().template getAddZero(), model.getReachableStates(), std::move(odd), std::move(result))); + } + + template + std::unique_ptr HybridDtmcPrctlHelper::computeLongRunAverageRewards(storm::models::symbolic::Model const& model, storm::dd::Add const& transitionMatrix, RewardModelType const& rewardModel, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { + // Create ODD for the translation. + storm::dd::Odd odd = model.getReachableStates().createOdd(); + storm::storage::SparseMatrix explicitProbabilityMatrix = model.getTransitionMatrix().toMatrix(odd, odd); + + std::vector result = storm::modelchecker::helper::SparseDtmcPrctlHelper::computeLongRunAverageRewards(explicitProbabilityMatrix, rewardModel.getTotalRewardVector(model.getTransitionMatrix(), model.getColumnVariables()).toVector(odd), linearEquationSolverFactory); + return std::unique_ptr(new HybridQuantitativeCheckResult(model.getReachableStates(), model.getManager().getBddZero(), model.getManager().template getAddZero(), model.getReachableStates(), std::move(odd), std::move(result))); + } + template class HybridDtmcPrctlHelper; template class HybridDtmcPrctlHelper; } diff --git a/src/storm/modelchecker/prctl/helper/HybridDtmcPrctlHelper.h b/src/storm/modelchecker/prctl/helper/HybridDtmcPrctlHelper.h index 5bec52909..e254c5912 100644 --- a/src/storm/modelchecker/prctl/helper/HybridDtmcPrctlHelper.h +++ b/src/storm/modelchecker/prctl/helper/HybridDtmcPrctlHelper.h @@ -33,6 +33,11 @@ namespace storm { static std::unique_ptr computeInstantaneousRewards(storm::models::symbolic::Model const& model, storm::dd::Add const& transitionMatrix, RewardModelType const& rewardModel, uint_fast64_t stepBound, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); static std::unique_ptr computeReachabilityRewards(storm::models::symbolic::Model const& model, storm::dd::Add const& transitionMatrix, RewardModelType const& rewardModel, storm::dd::Bdd const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + + static std::unique_ptr computeLongRunAverageProbabilities(storm::models::symbolic::Model const& model, storm::dd::Add const& transitionMatrix, storm::dd::Bdd const& targetStates, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + + static std::unique_ptr computeLongRunAverageRewards(storm::models::symbolic::Model const& model, storm::dd::Add const& transitionMatrix, RewardModelType const& rewardModel, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + }; } diff --git a/src/storm/modelchecker/prctl/helper/HybridMdpPrctlHelper.cpp b/src/storm/modelchecker/prctl/helper/HybridMdpPrctlHelper.cpp index cae24c70a..1caae1606 100644 --- a/src/storm/modelchecker/prctl/helper/HybridMdpPrctlHelper.cpp +++ b/src/storm/modelchecker/prctl/helper/HybridMdpPrctlHelper.cpp @@ -1,5 +1,7 @@ #include "storm/modelchecker/prctl/helper/HybridMdpPrctlHelper.h" +#include "storm/modelchecker/prctl/helper/SymbolicMdpPrctlHelper.h" + #include "storm/storage/dd/DdManager.h" #include "storm/storage/dd/Add.h" #include "storm/storage/dd/Bdd.h" @@ -95,8 +97,7 @@ namespace storm { template std::unique_ptr HybridMdpPrctlHelper::computeNextProbabilities(OptimizationDirection dir, storm::models::symbolic::NondeterministicModel const& model, storm::dd::Add const& transitionMatrix, storm::dd::Bdd const& nextStates) { - storm::dd::Add result = transitionMatrix * nextStates.swapVariables(model.getRowColumnMetaVariablePairs()).template toAdd(); - return std::unique_ptr(new storm::modelchecker::SymbolicQuantitativeCheckResult(model.getReachableStates(), result.sumAbstract(model.getColumnVariables()))); + return SymbolicMdpPrctlHelper::computeNextProbabilities(dir, model, transitionMatrix, nextStates); } template @@ -211,9 +212,10 @@ namespace storm { storm::dd::Bdd infinityStates; storm::dd::Bdd transitionMatrixBdd = transitionMatrix.notZero(); if (dir == OptimizationDirection::Minimize) { + STORM_LOG_WARN("Results of reward computation may be too low, because of zero-reward loops."); infinityStates = storm::utility::graph::performProb1E(model, transitionMatrixBdd, model.getReachableStates(), targetStates, storm::utility::graph::performProbGreater0E(model, transitionMatrixBdd, model.getReachableStates(), targetStates)); } else { - infinityStates = storm::utility::graph::performProb1A(model, transitionMatrixBdd, model.getReachableStates(), targetStates, storm::utility::graph::performProbGreater0A(model, transitionMatrixBdd, model.getReachableStates(), targetStates)); + infinityStates = storm::utility::graph::performProb1A(model, transitionMatrixBdd, targetStates, storm::utility::graph::performProbGreater0A(model, transitionMatrixBdd, model.getReachableStates(), targetStates)); } infinityStates = !infinityStates && model.getReachableStates(); storm::dd::Bdd maybeStates = (!targetStates && !infinityStates) && model.getReachableStates(); @@ -241,16 +243,21 @@ namespace storm { // Then compute the state reward vector to use in the computation. storm::dd::Add subvector = rewardModel.getTotalRewardVector(maybeStatesAdd, submatrix, model.getColumnVariables()); + if (!rewardModel.hasStateActionRewards() && !rewardModel.hasTransitionRewards()) { + // If the reward model neither has state-action nor transition rewards, we need to multiply + // it with the legal nondetermism encodings in each state. + subvector *= transitionMatrixBdd.existsAbstract(model.getColumnVariables()).template toAdd(); + } // Since we are cutting away target and infinity states, we need to account for this by giving // choices the value infinity that have some successor contained in the infinity states. storm::dd::Bdd choicesWithInfinitySuccessor = (maybeStates && transitionMatrixBdd && infinityStates.swapVariables(model.getRowColumnMetaVariablePairs())).existsAbstract(model.getColumnVariables()); subvector = choicesWithInfinitySuccessor.ite(model.getManager().template getInfinity(), subvector); - + // Before cutting the non-maybe columns, we need to compute the sizes of the row groups. - storm::dd::Add stateActionAdd = (submatrix.notZero().existsAbstract(model.getColumnVariables()) || subvector.notZero()).template toAdd(); + storm::dd::Add stateActionAdd = submatrix.notZero().existsAbstract(model.getColumnVariables()).template toAdd(); std::vector rowGroupSizes = stateActionAdd.sumAbstract(model.getNondeterminismVariables()).toVector(odd); - + // Finally cut away all columns targeting non-maybe states. submatrix *= maybeStatesAdd.swapVariables(model.getRowColumnMetaVariablePairs()); @@ -259,7 +266,7 @@ namespace storm { // Translate the symbolic matrix/vector to their explicit representations. std::pair, std::vector> explicitRepresentation = submatrix.toMatrixVector(subvector, std::move(rowGroupSizes), model.getNondeterminismVariables(), odd, odd); - + // Now solve the resulting equation system. std::unique_ptr> solver = linearEquationSolverFactory.create(std::move(explicitRepresentation.first)); solver->solveEquations(dir, x, explicitRepresentation.second); diff --git a/src/storm/modelchecker/prctl/helper/SparseDtmcPrctlHelper.cpp b/src/storm/modelchecker/prctl/helper/SparseDtmcPrctlHelper.cpp index 1e98585ae..f768a2428 100644 --- a/src/storm/modelchecker/prctl/helper/SparseDtmcPrctlHelper.cpp +++ b/src/storm/modelchecker/prctl/helper/SparseDtmcPrctlHelper.cpp @@ -88,13 +88,13 @@ namespace storm { storm::utility::vector::selectVectorValues(x, maybeStates, resultHint.get()); } - // Prepare the right-hand side of the equation system. For entry i this corresponds to // the accumulated probability of going from state i to some 'yes' state. std::vector b = transitionMatrix.getConstrainedRowSumVector(maybeStates, statesWithProbability1); // Now solve the created system of linear equations. std::unique_ptr> solver = linearEquationSolverFactory.create(std::move(submatrix)); + solver->setBounds(storm::utility::zero(), storm::utility::one()); solver->solveEquations(x, b); // Set values of resulting vector according to result. @@ -169,7 +169,7 @@ namespace storm { std::vector SparseDtmcPrctlHelper::computeReachabilityRewards(storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& totalStateRewardVector, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory, boost::optional> resultHint) { return computeReachabilityRewards(transitionMatrix, backwardTransitions, - [&] (uint_fast64_t numberOfRows, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::BitVector const& maybeStates) { + [&] (uint_fast64_t numberOfRows, storm::storage::SparseMatrix const&, storm::storage::BitVector const& maybeStates) { std::vector result(numberOfRows); storm::utility::vector::selectVectorValues(result, maybeStates, totalStateRewardVector); return result; @@ -218,6 +218,7 @@ namespace storm { // Now solve the resulting equation system. std::unique_ptr> solver = linearEquationSolverFactory.create(std::move(submatrix)); + solver->setLowerBound(storm::utility::zero()); solver->solveEquations(x, b); // Set values of resulting vector according to result. @@ -232,8 +233,18 @@ namespace storm { } template - std::vector SparseDtmcPrctlHelper::computeLongRunAverageProbabilities(storm::storage::SparseMatrix const& transitionMatrix, storm::storage::BitVector const& psiStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { - return SparseCtmcCslHelper::computeLongRunAverageProbabilities(transitionMatrix, psiStates, nullptr, qualitative, linearEquationSolverFactory); + std::vector SparseDtmcPrctlHelper::computeLongRunAverageProbabilities(storm::storage::SparseMatrix const& transitionMatrix, storm::storage::BitVector const& psiStates, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { + return SparseCtmcCslHelper::computeLongRunAverageProbabilities(transitionMatrix, psiStates, nullptr, linearEquationSolverFactory); + } + + template + std::vector SparseDtmcPrctlHelper::computeLongRunAverageRewards(storm::storage::SparseMatrix const& transitionMatrix, RewardModelType const& rewardModel, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { + return SparseCtmcCslHelper::computeLongRunAverageRewards(transitionMatrix, rewardModel, nullptr, linearEquationSolverFactory); + } + + template + std::vector SparseDtmcPrctlHelper::computeLongRunAverageRewards(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& stateRewards, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory) { + return SparseCtmcCslHelper::computeLongRunAverageRewards(transitionMatrix, stateRewards, nullptr, linearEquationSolverFactory); } template diff --git a/src/storm/modelchecker/prctl/helper/SparseDtmcPrctlHelper.h b/src/storm/modelchecker/prctl/helper/SparseDtmcPrctlHelper.h index e248de563..3c3b6974b 100644 --- a/src/storm/modelchecker/prctl/helper/SparseDtmcPrctlHelper.h +++ b/src/storm/modelchecker/prctl/helper/SparseDtmcPrctlHelper.h @@ -38,8 +38,12 @@ namespace storm { static std::vector computeReachabilityRewards(storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::vector const& totalStateRewardVector, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory, boost::optional> resultHint = boost::none); - static std::vector computeLongRunAverageProbabilities(storm::storage::SparseMatrix const& transitionMatrix, storm::storage::BitVector const& psiStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); - + static std::vector computeLongRunAverageProbabilities(storm::storage::SparseMatrix const& transitionMatrix, storm::storage::BitVector const& psiStates, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + + static std::vector computeLongRunAverageRewards(storm::storage::SparseMatrix const& transitionMatrix, RewardModelType const& rewardModel, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + + static std::vector computeLongRunAverageRewards(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& stateRewards, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); + static std::vector computeConditionalProbabilities(storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& targetStates, storm::storage::BitVector const& conditionStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); static std::vector computeConditionalRewards(storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, RewardModelType const& rewardModel, storm::storage::BitVector const& targetStates, storm::storage::BitVector const& conditionStates, bool qualitative, storm::solver::LinearEquationSolverFactory const& linearEquationSolverFactory); diff --git a/src/storm/modelchecker/prctl/helper/SparseMdpPrctlHelper.cpp b/src/storm/modelchecker/prctl/helper/SparseMdpPrctlHelper.cpp index ec6aeea6c..2db593ac9 100644 --- a/src/storm/modelchecker/prctl/helper/SparseMdpPrctlHelper.cpp +++ b/src/storm/modelchecker/prctl/helper/SparseMdpPrctlHelper.cpp @@ -35,7 +35,7 @@ namespace storm { if (dir == OptimizationDirection::Minimize) { maybeStates = storm::utility::graph::performProbGreater0A(transitionMatrix, transitionMatrix.getRowGroupIndices(), backwardTransitions, phiStates, psiStates, true, stepBound); } else { - maybeStates = storm::utility::graph::performProbGreater0E(transitionMatrix, transitionMatrix.getRowGroupIndices(), backwardTransitions, phiStates, psiStates, true, stepBound); + maybeStates = storm::utility::graph::performProbGreater0E(backwardTransitions, phiStates, psiStates, true, stepBound); } maybeStates &= ~psiStates; STORM_LOG_INFO("Found " << maybeStates.getNumberOfSetBits() << " 'maybe' states."); @@ -272,7 +272,7 @@ namespace storm { } template<> - std::vector SparseMdpPrctlHelper::computeReachabilityRewards(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::models::sparse::StandardRewardModel const& intervalRewardModel, bool lowerBoundOfIntervals, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory) { + std::vector SparseMdpPrctlHelper::computeReachabilityRewards(OptimizationDirection, storm::storage::SparseMatrix const&, storm::storage::SparseMatrix const&, storm::models::sparse::StandardRewardModel const&, bool, storm::storage::BitVector const&, bool, storm::solver::MinMaxLinearEquationSolverFactory const&) { STORM_LOG_THROW(false, storm::exceptions::IllegalFunctionCallException, "Computing reachability rewards is unsupported for this data type."); } #endif @@ -286,6 +286,7 @@ namespace storm { storm::storage::BitVector infinityStates; storm::storage::BitVector trueStates(transitionMatrix.getRowGroupCount(), true); if (dir == OptimizationDirection::Minimize) { + STORM_LOG_WARN("Results of reward computation may be too low, because of zero-reward loops."); infinityStates = storm::utility::graph::performProb1E(transitionMatrix, nondeterministicChoiceIndices, backwardTransitions, trueStates, targetStates); } else { infinityStates = storm::utility::graph::performProb1A(transitionMatrix, nondeterministicChoiceIndices, backwardTransitions, trueStates, targetStates); @@ -329,7 +330,7 @@ namespace storm { } } } - + // Create vector for results for maybe states. std::vector x(maybeStates.getNumberOfSetBits(), storm::utility::zero()); @@ -349,7 +350,7 @@ namespace storm { } template - std::vector SparseMdpPrctlHelper::computeLongRunAverageProbabilities(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& psiStates, bool qualitative, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory) { + std::vector SparseMdpPrctlHelper::computeLongRunAverageProbabilities(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& psiStates, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory) { // If there are no goal states, we avoid the computation and directly return zero. uint_fast64_t numberOfStates = transitionMatrix.getRowGroupCount(); if (psiStates.empty()) { @@ -543,7 +544,7 @@ namespace storm { } template - std::unique_ptr SparseMdpPrctlHelper::computeConditionalProbabilities(OptimizationDirection dir, storm::storage::sparse::state_type initialState, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& targetStates, storm::storage::BitVector const& conditionStates, bool qualitative, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory) { + std::unique_ptr SparseMdpPrctlHelper::computeConditionalProbabilities(OptimizationDirection dir, storm::storage::sparse::state_type initialState, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& targetStates, storm::storage::BitVector const& conditionStates, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory) { // For the max-case, we can simply take the given target states. For the min-case, however, we need to // find the MECs of non-target states and make them the new target states. diff --git a/src/storm/modelchecker/prctl/helper/SparseMdpPrctlHelper.h b/src/storm/modelchecker/prctl/helper/SparseMdpPrctlHelper.h index 3b1ac337d..efc80aa59 100644 --- a/src/storm/modelchecker/prctl/helper/SparseMdpPrctlHelper.h +++ b/src/storm/modelchecker/prctl/helper/SparseMdpPrctlHelper.h @@ -57,9 +57,9 @@ namespace storm { static std::vector computeReachabilityRewards(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::models::sparse::StandardRewardModel const& intervalRewardModel, bool lowerBoundOfIntervals, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); #endif - static std::vector computeLongRunAverageProbabilities(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& psiStates, bool qualitative, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); + static std::vector computeLongRunAverageProbabilities(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& psiStates, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); - static std::unique_ptr computeConditionalProbabilities(OptimizationDirection dir, storm::storage::sparse::state_type initialState, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& targetStates, storm::storage::BitVector const& conditionStates, bool qualitative, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); + static std::unique_ptr computeConditionalProbabilities(OptimizationDirection dir, storm::storage::sparse::state_type initialState, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& targetStates, storm::storage::BitVector const& conditionStates, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); private: static std::vector computeReachabilityRewardsHelper(OptimizationDirection dir, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::SparseMatrix const& backwardTransitions, std::function(uint_fast64_t, storm::storage::SparseMatrix const&, storm::storage::BitVector const&)> const& totalStateRewardVectorGetter, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::MinMaxLinearEquationSolverFactory const& minMaxLinearEquationSolverFactory); diff --git a/src/storm/modelchecker/prctl/helper/SymbolicDtmcPrctlHelper.cpp b/src/storm/modelchecker/prctl/helper/SymbolicDtmcPrctlHelper.cpp index eff8fdf1b..ac1815d43 100644 --- a/src/storm/modelchecker/prctl/helper/SymbolicDtmcPrctlHelper.cpp +++ b/src/storm/modelchecker/prctl/helper/SymbolicDtmcPrctlHelper.cpp @@ -58,7 +58,7 @@ namespace storm { // Solve the equation system. std::unique_ptr> solver = linearEquationSolverFactory.create(submatrix, maybeStates, model.getRowVariables(), model.getColumnVariables(), model.getRowColumnMetaVariablePairs()); - storm::dd::Add result = solver->solveEquations(model.getManager().getConstant(0.5) * maybeStatesAdd, subvector); + storm::dd::Add result = solver->solveEquations(model.getManager().getConstant(0.0), subvector); return statesWithProbability01.second.template toAdd() + result; } else { @@ -166,16 +166,16 @@ namespace storm { storm::dd::Add submatrix = transitionMatrix * maybeStatesAdd; // Then compute the state reward vector to use in the computation. - storm::dd::Add subvector = rewardModel.getTotalRewardVector(submatrix, model.getColumnVariables()); + storm::dd::Add subvector = rewardModel.getTotalRewardVector(maybeStatesAdd, submatrix, model.getColumnVariables()); // Finally cut away all columns targeting non-maybe states and convert the matrix into the matrix needed // for solving the equation system (i.e. compute (I-A)). submatrix *= maybeStatesAdd.swapVariables(model.getRowColumnMetaVariablePairs()); submatrix = (model.getRowColumnIdentity() * maybeStatesAdd) - submatrix; - + // Solve the equation system. std::unique_ptr> solver = linearEquationSolverFactory.create(submatrix, maybeStates, model.getRowVariables(), model.getColumnVariables(), model.getRowColumnMetaVariablePairs()); - storm::dd::Add result = solver->solveEquations(model.getManager().getConstant(0.5) * maybeStatesAdd, subvector); + storm::dd::Add result = solver->solveEquations(model.getManager().getConstant(0.0), subvector); return infinityStates.ite(model.getManager().getConstant(storm::utility::infinity()), result); } else { diff --git a/src/storm/modelchecker/prctl/helper/SymbolicMdpPrctlHelper.cpp b/src/storm/modelchecker/prctl/helper/SymbolicMdpPrctlHelper.cpp index 7ab762515..95277500b 100644 --- a/src/storm/modelchecker/prctl/helper/SymbolicMdpPrctlHelper.cpp +++ b/src/storm/modelchecker/prctl/helper/SymbolicMdpPrctlHelper.cpp @@ -84,8 +84,13 @@ namespace storm { template std::unique_ptr SymbolicMdpPrctlHelper::computeNextProbabilities(OptimizationDirection dir, storm::models::symbolic::NondeterministicModel const& model, storm::dd::Add const& transitionMatrix, storm::dd::Bdd const& nextStates) { - storm::dd::Add result = transitionMatrix * nextStates.swapVariables(model.getRowColumnMetaVariablePairs()).template toAdd(); - return std::unique_ptr(new SymbolicQuantitativeCheckResult(model.getReachableStates(), result.sumAbstract(model.getColumnVariables()))); + storm::dd::Add result = (transitionMatrix * nextStates.swapVariables(model.getRowColumnMetaVariablePairs()).template toAdd()).sumAbstract(model.getColumnVariables()); + if (dir == OptimizationDirection::Minimize) { + result = (result + model.getIllegalMask().template toAdd()).minAbstract(model.getNondeterminismVariables()); + } else { + result = result.maxAbstract(model.getNondeterminismVariables()); + } + return std::unique_ptr(new SymbolicQuantitativeCheckResult(model.getReachableStates(), result)); } template @@ -132,7 +137,7 @@ namespace storm { STORM_LOG_THROW(rewardModel.hasStateRewards(), storm::exceptions::InvalidPropertyException, "Missing reward model for formula. Skipping formula."); // Perform the matrix-vector multiplication. - std::unique_ptr> solver = linearEquationSolverFactory.create(model.getTransitionMatrix(), model.getReachableStates(), model.getIllegalMask(), model.getRowVariables(), model.getColumnVariables(), model.getNondeterminismVariables(), model.getRowColumnMetaVariablePairs()); + std::unique_ptr> solver = linearEquationSolverFactory.create(transitionMatrix, model.getReachableStates(), model.getIllegalMask(), model.getRowVariables(), model.getColumnVariables(), model.getNondeterminismVariables(), model.getRowColumnMetaVariablePairs()); storm::dd::Add result = solver->multiply(dir == OptimizationDirection::Minimize, rewardModel.getStateRewardVector(), nullptr, stepBound); return std::unique_ptr(new SymbolicQuantitativeCheckResult(model.getReachableStates(), result)); @@ -163,9 +168,10 @@ namespace storm { storm::dd::Bdd infinityStates; storm::dd::Bdd transitionMatrixBdd = transitionMatrix.notZero(); if (dir == OptimizationDirection::Minimize) { + STORM_LOG_WARN("Results of reward computation may be too low, because of zero-reward loops."); infinityStates = storm::utility::graph::performProb1E(model, transitionMatrixBdd, model.getReachableStates(), targetStates, storm::utility::graph::performProbGreater0E(model, transitionMatrixBdd, model.getReachableStates(), targetStates)); } else { - infinityStates = storm::utility::graph::performProb1A(model, transitionMatrixBdd, model.getReachableStates(), targetStates, storm::utility::graph::performProbGreater0A(model, transitionMatrixBdd, model.getReachableStates(), targetStates)); + infinityStates = storm::utility::graph::performProb1A(model, transitionMatrixBdd, targetStates, storm::utility::graph::performProbGreater0A(model, transitionMatrixBdd, model.getReachableStates(), targetStates)); } infinityStates = !infinityStates && model.getReachableStates(); diff --git a/src/storm/modelchecker/reachability/SparseDtmcEliminationModelChecker.cpp b/src/storm/modelchecker/reachability/SparseDtmcEliminationModelChecker.cpp index aca5be11c..010fe8b23 100644 --- a/src/storm/modelchecker/reachability/SparseDtmcEliminationModelChecker.cpp +++ b/src/storm/modelchecker/reachability/SparseDtmcEliminationModelChecker.cpp @@ -113,7 +113,7 @@ namespace storm { } template - std::unique_ptr SparseDtmcEliminationModelChecker::computeLongRunAverageRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SparseDtmcEliminationModelChecker::computeLongRunAverageRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { // Do some sanity checks to establish some required properties. RewardModelType const& rewardModel = this->getModel().getRewardModel(checkTask.isRewardModelSet() ? checkTask.getRewardModel() : ""); STORM_LOG_THROW(!rewardModel.empty(), storm::exceptions::IllegalArgumentException, "Input model does not have a reward model."); @@ -323,6 +323,9 @@ namespace storm { std::unique_ptr SparseDtmcEliminationModelChecker::computeBoundedUntilProbabilities(CheckTask const& checkTask) { storm::logic::BoundedUntilFormula const& pathFormula = checkTask.getFormula(); + STORM_LOG_THROW(!pathFormula.hasLowerBound() && pathFormula.hasUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have single upper time bound."); + STORM_LOG_THROW(pathFormula.hasIntegerUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have discrete upper time bound."); + // Retrieve the appropriate bitvectors by model checking the subformulas. std::unique_ptr leftResultPointer = this->check(pathFormula.getLeftSubformula()); std::unique_ptr rightResultPointer = this->check(pathFormula.getRightSubformula()); @@ -331,7 +334,7 @@ namespace storm { // Start by determining the states that have a non-zero probability of reaching the target states within the // time bound. - storm::storage::BitVector statesWithProbabilityGreater0 = storm::utility::graph::performProbGreater0(this->getModel().getBackwardTransitions(), phiStates, psiStates, true, pathFormula.getDiscreteTimeBound()); + storm::storage::BitVector statesWithProbabilityGreater0 = storm::utility::graph::performProbGreater0(this->getModel().getBackwardTransitions(), phiStates, psiStates, true, pathFormula.getUpperBound()); statesWithProbabilityGreater0 &= ~psiStates; // Determine whether we need to perform some further computation. @@ -350,7 +353,7 @@ namespace storm { std::vector result(transitionMatrix.getRowCount(), storm::utility::zero()); if (furtherComputationNeeded) { - uint_fast64_t timeBound = pathFormula.getDiscreteTimeBound(); + uint_fast64_t timeBound = pathFormula.getUpperBound(); if (checkTask.isOnlyInitialStatesRelevantSet()) { // Determine the set of states that is reachable from the initial state without jumping over a target state. @@ -476,7 +479,7 @@ namespace storm { storm::storage::SparseMatrix submatrix = probabilityMatrix.getSubmatrix(false, maybeStates, maybeStates); storm::storage::SparseMatrix submatrixTransposed = submatrix.transpose(); - std::vector subresult = computeReachabilityValues(submatrix, oneStepProbabilities, submatrixTransposed, newInitialStates, computeForInitialStatesOnly, phiStates, psiStates, oneStepProbabilities); + std::vector subresult = computeReachabilityValues(submatrix, oneStepProbabilities, submatrixTransposed, newInitialStates, computeForInitialStatesOnly, oneStepProbabilities); storm::utility::vector::setVectorValues(result, maybeStates, subresult); } @@ -497,7 +500,7 @@ namespace storm { } template - std::unique_ptr SparseDtmcEliminationModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType rewardMeasureType, CheckTask const& checkTask) { + std::unique_ptr SparseDtmcEliminationModelChecker::computeReachabilityRewards(storm::logic::RewardMeasureType, CheckTask const& checkTask) { storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula(); // Retrieve the appropriate bitvectors by model checking the subformulas. @@ -520,7 +523,7 @@ namespace storm { template std::unique_ptr SparseDtmcEliminationModelChecker::computeReachabilityRewards(storm::storage::SparseMatrix const& probabilityMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& initialStates, storm::storage::BitVector const& targetStates, std::vector& stateRewardValues, bool computeForInitialStatesOnly) { return computeReachabilityRewards(probabilityMatrix, backwardTransitions, initialStates, targetStates, - [&] (uint_fast64_t numberOfRows, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::BitVector const& maybeStates) { + [&] (uint_fast64_t numberOfRows, storm::storage::SparseMatrix const&, storm::storage::BitVector const& maybeStates) { std::vector result(numberOfRows); storm::utility::vector::selectVectorValues(result, maybeStates, stateRewardValues); return result; @@ -574,7 +577,7 @@ namespace storm { // Project the state reward vector to all maybe-states. std::vector stateRewardValues = totalStateRewardVectorGetter(submatrix.getRowCount(), probabilityMatrix, maybeStates); - std::vector subresult = computeReachabilityValues(submatrix, stateRewardValues, submatrixTransposed, newInitialStates, computeForInitialStatesOnly, trueStates, targetStates, probabilityMatrix.getConstrainedRowSumVector(maybeStates, targetStates)); + std::vector subresult = computeReachabilityValues(submatrix, stateRewardValues, submatrixTransposed, newInitialStates, computeForInitialStatesOnly, probabilityMatrix.getConstrainedRowSumVector(maybeStates, targetStates)); storm::utility::vector::setVectorValues(result, maybeStates, subresult); } @@ -851,7 +854,7 @@ namespace storm { } template - std::vector::ValueType> SparseDtmcEliminationModelChecker::computeReachabilityValues(storm::storage::SparseMatrix const& transitionMatrix, std::vector& values, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& initialStates, bool computeResultsForInitialStatesOnly, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, std::vector const& oneStepProbabilitiesToTarget) { + std::vector::ValueType> SparseDtmcEliminationModelChecker::computeReachabilityValues(storm::storage::SparseMatrix const& transitionMatrix, std::vector& values, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& initialStates, bool computeResultsForInitialStatesOnly, std::vector const& oneStepProbabilitiesToTarget) { // Then, we convert the reduced matrix to a more flexible format to be able to perform state elimination more easily. storm::storage::FlexibleSparseMatrix flexibleMatrix(transitionMatrix); storm::storage::FlexibleSparseMatrix flexibleBackwardTransitions(backwardTransitions); @@ -866,11 +869,11 @@ namespace storm { // Create a bit vector that represents the subsystem of states we still have to eliminate. storm::storage::BitVector subsystem = storm::storage::BitVector(transitionMatrix.getRowCount(), true); - uint_fast64_t maximalDepth = 0; if (storm::settings::getModule().getEliminationMethod() == storm::settings::modules::EliminationSettings::EliminationMethod::State) { performOrdinaryStateElimination(flexibleMatrix, flexibleBackwardTransitions, subsystem, initialStates, computeResultsForInitialStatesOnly, values, distanceBasedPriorities); } else if (storm::settings::getModule().getEliminationMethod() == storm::settings::modules::EliminationSettings::EliminationMethod::Hybrid) { - maximalDepth = performHybridStateElimination(transitionMatrix, flexibleMatrix, flexibleBackwardTransitions, subsystem, initialStates, computeResultsForInitialStatesOnly, values, distanceBasedPriorities); + uint64_t maximalDepth = performHybridStateElimination(transitionMatrix, flexibleMatrix, flexibleBackwardTransitions, subsystem, initialStates, computeResultsForInitialStatesOnly, values, distanceBasedPriorities); + STORM_LOG_TRACE("Maximal depth of decomposition was " << maximalDepth << "."); } STORM_LOG_ASSERT(flexibleMatrix.empty(), "Not all transitions were eliminated."); diff --git a/src/storm/modelchecker/reachability/SparseDtmcEliminationModelChecker.h b/src/storm/modelchecker/reachability/SparseDtmcEliminationModelChecker.h index eb038c3a9..6dd387725 100644 --- a/src/storm/modelchecker/reachability/SparseDtmcEliminationModelChecker.h +++ b/src/storm/modelchecker/reachability/SparseDtmcEliminationModelChecker.h @@ -58,7 +58,7 @@ namespace storm { static std::unique_ptr computeReachabilityRewards(storm::storage::SparseMatrix const& probabilityMatrix, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& initialStates, storm::storage::BitVector const& targetStates, std::function(uint_fast64_t, storm::storage::SparseMatrix const&, storm::storage::BitVector const&)> const& totalStateRewardVectorGetter, bool computeForInitialStatesOnly); - static std::vector computeReachabilityValues(storm::storage::SparseMatrix const& transitionMatrix, std::vector& values, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& initialStates, bool computeResultsForInitialStatesOnly, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, std::vector const& oneStepProbabilitiesToTarget); + static std::vector computeReachabilityValues(storm::storage::SparseMatrix const& transitionMatrix, std::vector& values, storm::storage::SparseMatrix const& backwardTransitions, storm::storage::BitVector const& initialStates, bool computeResultsForInitialStatesOnly, std::vector const& oneStepProbabilitiesToTarget); static void performPrioritizedStateElimination(std::shared_ptr& priorityQueue, storm::storage::FlexibleSparseMatrix& transitionMatrix, storm::storage::FlexibleSparseMatrix& backwardTransitions, std::vector& values, storm::storage::BitVector const& initialStates, bool computeResultsForInitialStatesOnly); diff --git a/src/storm/modelchecker/region/ApproximationModel.cpp b/src/storm/modelchecker/region/ApproximationModel.cpp index 8b82b5002..9646193f6 100644 --- a/src/storm/modelchecker/region/ApproximationModel.cpp +++ b/src/storm/modelchecker/region/ApproximationModel.cpp @@ -57,7 +57,7 @@ namespace storm { //Now pre-compute the information for the equation system. initializeProbabilities(parametricModel, newIndices); if(this->computeRewards){ - initializeRewards(parametricModel, newIndices); + initializeRewards(parametricModel); } this->matrixData.assignment.shrink_to_fit(); this->vectorData.assignment.shrink_to_fit(); @@ -198,7 +198,7 @@ namespace storm { } template - void ApproximationModel::initializeRewards(ParametricSparseModelType const& parametricModel, std::vector const& newIndices){ + void ApproximationModel::initializeRewards(ParametricSparseModelType const& parametricModel){ STORM_LOG_DEBUG("Approximation model initialization for Rewards"); //Note: Since the original model is assumed to be a DTMC, there is no outgoing transition of a maybeState that leads to an infinity state. //Hence, we do not have to set entries of the eqSys vector to infinity (as it would be required for mdp model checking...) diff --git a/src/storm/modelchecker/region/ApproximationModel.h b/src/storm/modelchecker/region/ApproximationModel.h index 5d707580e..986c555bd 100644 --- a/src/storm/modelchecker/region/ApproximationModel.h +++ b/src/storm/modelchecker/region/ApproximationModel.h @@ -81,7 +81,7 @@ namespace storm { typedef typename std::unordered_map::value_type FunctionEntry; void initializeProbabilities(ParametricSparseModelType const& parametricModel, std::vector const& newIndices); - void initializeRewards(ParametricSparseModelType const& parametricModel, std::vector const& newIndices); + void initializeRewards(ParametricSparseModelType const& parametricModel); void initializePlayer1Matrix(ParametricSparseModelType const& parametricModel); void instantiate(ParameterRegion const& region, bool computeLowerBounds); void invokeSolver(bool computeLowerBounds, storm::storage::TotalScheduler& scheduler, bool allowEarlyTermination); diff --git a/src/storm/modelchecker/region/SparseDtmcRegionModelChecker.cpp b/src/storm/modelchecker/region/SparseDtmcRegionModelChecker.cpp index 4321c328a..b516515d0 100644 --- a/src/storm/modelchecker/region/SparseDtmcRegionModelChecker.cpp +++ b/src/storm/modelchecker/region/SparseDtmcRegionModelChecker.cpp @@ -424,7 +424,7 @@ namespace storm { // std::vector statePriorities = eliminationModelChecker.getStatePriorities(forwardTransitions,backwardTransitions,newInitialStates,oneStepProbabilities); // this->reachabilityFunction=std::make_shared(eliminationModelChecker.computeReachabilityValue(forwardTransitions, oneStepProbabilities, backwardTransitions, newInitialStates , true, phiStates, simpleModel.getStates("target"), stateRewards, statePriorities)); std::vector reachFuncVector = storm::modelchecker::SparseDtmcEliminationModelChecker>::computeReachabilityValues( - forwardTransitions, values, backwardTransitions, newInitialStates , true, phiStates, simpleModel.getStates("target"), oneStepProbabilities); + forwardTransitions, values, backwardTransitions, newInitialStates, true, oneStepProbabilities); this->reachabilityFunction=std::make_shared(std::move(reachFuncVector[*simpleModel.getInitialStates().begin()])); /* std::string funcStr = " (/ " + this->reachabilityFunction->nominator().toString(false, true) + " " + diff --git a/src/storm/modelchecker/region/SparseMdpRegionModelChecker.cpp b/src/storm/modelchecker/region/SparseMdpRegionModelChecker.cpp index 5ef4cd589..31d4d5f79 100644 --- a/src/storm/modelchecker/region/SparseMdpRegionModelChecker.cpp +++ b/src/storm/modelchecker/region/SparseMdpRegionModelChecker.cpp @@ -253,19 +253,19 @@ namespace storm { } template - bool SparseMdpRegionModelChecker::checkPoint(ParameterRegion& region, std::mapconst& point, bool favorViaFunction) { - if(this->checkFormulaOnSamplingPoint(point)){ - if (region.getCheckResult()!=RegionCheckResult::EXISTSSAT){ - region.setSatPoint(point); - if(region.getCheckResult()==RegionCheckResult::EXISTSVIOLATED){ - region.setCheckResult(RegionCheckResult::EXISTSBOTH); - return true; - } - region.setCheckResult(RegionCheckResult::EXISTSSAT); - } - } - else{ - if (region.getCheckResult()!=RegionCheckResult::EXISTSVIOLATED){ + bool SparseMdpRegionModelChecker::checkPoint(ParameterRegion& region, std::mapconst& point, bool /*favorViaFunction*/) { + if(this->checkFormulaOnSamplingPoint(point)){ + if (region.getCheckResult()!=RegionCheckResult::EXISTSSAT){ + region.setSatPoint(point); + if(region.getCheckResult()==RegionCheckResult::EXISTSVIOLATED){ + region.setCheckResult(RegionCheckResult::EXISTSBOTH); + return true; + } + region.setCheckResult(RegionCheckResult::EXISTSSAT); + } + } + else{ + if (region.getCheckResult()!=RegionCheckResult::EXISTSVIOLATED){ region.setViolatedPoint(point); if(region.getCheckResult()==RegionCheckResult::EXISTSSAT){ region.setCheckResult(RegionCheckResult::EXISTSBOTH); @@ -278,7 +278,7 @@ namespace storm { } template - bool SparseMdpRegionModelChecker::checkSmt(ParameterRegion& region) { + bool SparseMdpRegionModelChecker::checkSmt(ParameterRegion& /*region*/) { STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "checkSmt invoked but smt solving has not been implemented for MDPs."); } diff --git a/src/storm/modelchecker/region/SparseMdpRegionModelChecker.h b/src/storm/modelchecker/region/SparseMdpRegionModelChecker.h index e772bad95..54f63a598 100644 --- a/src/storm/modelchecker/region/SparseMdpRegionModelChecker.h +++ b/src/storm/modelchecker/region/SparseMdpRegionModelChecker.h @@ -67,7 +67,7 @@ namespace storm { * * @return true if an violated point as well as a sat point has been found, i.e., the check result is changed to EXISTSOTH */ - virtual bool checkPoint(ParameterRegion& region, std::mapconst& point, bool favorViaFunction=false); + virtual bool checkPoint(ParameterRegion& region, std::mapconst& point, bool /*favorViaFunction*/); /*! * Starts the SMTSolver to get the result. @@ -77,7 +77,7 @@ namespace storm { * A Sat- or Violated point is set, if the solver has found one (not yet implemented!). * The region checkResult of the given region is changed accordingly. */ - virtual bool checkSmt(ParameterRegion& region); + virtual bool checkSmt(ParameterRegion& /*region*/); }; } //namespace region diff --git a/src/storm/modelchecker/region/SparseRegionModelChecker.cpp b/src/storm/modelchecker/region/SparseRegionModelChecker.cpp index 790f9395c..e98ba6485 100644 --- a/src/storm/modelchecker/region/SparseRegionModelChecker.cpp +++ b/src/storm/modelchecker/region/SparseRegionModelChecker.cpp @@ -115,7 +115,7 @@ namespace storm { template SparseRegionModelCheckerSettings const& SparseRegionModelChecker::getSettings() const { return this->settings; - }; + } diff --git a/src/storm/modelchecker/results/CheckResult.cpp b/src/storm/modelchecker/results/CheckResult.cpp index 8410c8728..210ca3b59 100644 --- a/src/storm/modelchecker/results/CheckResult.cpp +++ b/src/storm/modelchecker/results/CheckResult.cpp @@ -39,7 +39,7 @@ namespace storm { return false; } - std::ostream& operator<<(std::ostream& out, CheckResult& checkResult) { + std::ostream& operator<<(std::ostream& out, CheckResult const& checkResult) { checkResult.writeToStream(out); return out; } diff --git a/src/storm/modelchecker/results/CheckResult.h b/src/storm/modelchecker/results/CheckResult.h index 8c6b3a880..6cf39669d 100644 --- a/src/storm/modelchecker/results/CheckResult.h +++ b/src/storm/modelchecker/results/CheckResult.h @@ -106,7 +106,7 @@ namespace storm { virtual std::ostream& writeToStream(std::ostream& out) const = 0; }; - std::ostream& operator<<(std::ostream& out, CheckResult& checkResult); + std::ostream& operator<<(std::ostream& out, CheckResult const& checkResult); } } diff --git a/src/storm/modelchecker/results/ExplicitQualitativeCheckResult.cpp b/src/storm/modelchecker/results/ExplicitQualitativeCheckResult.cpp index 5a39247a5..e12de8862 100644 --- a/src/storm/modelchecker/results/ExplicitQualitativeCheckResult.cpp +++ b/src/storm/modelchecker/results/ExplicitQualitativeCheckResult.cpp @@ -153,26 +153,45 @@ namespace storm { } std::ostream& ExplicitQualitativeCheckResult::writeToStream(std::ostream& out) const { - out << "["; if (this->isResultForAllStates()) { - out << boost::get(truthValues); + vector_type const& vector = boost::get(truthValues); + bool allTrue = vector.full(); + bool allFalse = !allTrue && vector.empty(); + if (allTrue) { + out << "{true}"; + } else if (allFalse) { + out << "{false}"; + } else { + out << "{true, false}"; + } } else { std::ios::fmtflags oldflags(std::cout.flags()); out << std::boolalpha; map_type const& map = boost::get(truthValues); - bool first = true; - for (auto const& element : map) { - if (!first) { - out << ", "; + if (map.size() == 1) { + out << map.begin()->second; + } else { + bool allTrue = true; + bool allFalse = true; + for (auto const& entry : map) { + if (entry.second) { + allFalse = false; + } else { + allTrue = false; + } + } + if (allTrue) { + out << "{true}"; + } else if (allFalse) { + out << "{false}"; } else { - first = false; + out << "{true, false}"; } - out << element.second; } + std::cout.flags(oldflags); } - out << "]"; return out; } diff --git a/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.cpp b/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.cpp index 1af0e1daa..5ea662a57 100644 --- a/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.cpp +++ b/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.cpp @@ -84,7 +84,7 @@ namespace storm { template ValueType ExplicitQuantitativeCheckResult::getMin() const { - STORM_LOG_THROW(!values.empty(),storm::exceptions::InvalidOperationException, "Minimum of empty set is not defined"); + STORM_LOG_THROW(!values.empty(), storm::exceptions::InvalidOperationException, "Minimum of empty set is not defined."); if (this->isResultForAllStates()) { return storm::utility::minimum(boost::get(values)); @@ -93,10 +93,9 @@ namespace storm { } } - template ValueType ExplicitQuantitativeCheckResult::getMax() const { - STORM_LOG_THROW(!values.empty(),storm::exceptions::InvalidOperationException, "Minimum of empty set is not defined"); + STORM_LOG_THROW(!values.empty(), storm::exceptions::InvalidOperationException, "Minimum of empty set is not defined."); if (this->isResultForAllStates()) { return storm::utility::maximum(boost::get(values)); @@ -105,6 +104,17 @@ namespace storm { } } + template + std::pair ExplicitQuantitativeCheckResult::getMinMax() const { + STORM_LOG_THROW(!values.empty(), storm::exceptions::InvalidOperationException, "Minimum/maximum of empty set is not defined."); + + if (this->isResultForAllStates()) { + return storm::utility::minmax(boost::get(values)); + } else { + return storm::utility::minmax(boost::get(values)); + } + } + template ValueType ExplicitQuantitativeCheckResult::sum() const { STORM_LOG_THROW(!values.empty(),storm::exceptions::InvalidOperationException, "Minimum of empty set is not defined"); @@ -112,10 +122,12 @@ namespace storm { ValueType sum = storm::utility::zero(); if (this->isResultForAllStates()) { for (auto& element : boost::get(values)) { + STORM_LOG_THROW(element != storm::utility::infinity(), storm::exceptions::InvalidOperationException, "Cannot compute the sum of values containing infinity."); sum += element; } } else { for (auto& element : boost::get(values)) { + STORM_LOG_THROW(element.second != storm::utility::infinity(), storm::exceptions::InvalidOperationException, "Cannot compute the sum of values containing infinity."); sum += element.second; } } @@ -129,11 +141,13 @@ namespace storm { ValueType sum = storm::utility::zero(); if (this->isResultForAllStates()) { for (auto& element : boost::get(values)) { + STORM_LOG_THROW(element != storm::utility::infinity(), storm::exceptions::InvalidOperationException, "Cannot compute the average of values containing infinity."); sum += element; } return sum / boost::get(values).size(); } else { for (auto& element : boost::get(values)) { + STORM_LOG_THROW(element.second != storm::utility::infinity(), storm::exceptions::InvalidOperationException, "Cannot compute the average of values containing infinity."); sum += element.second; } return sum / boost::get(values).size(); @@ -157,32 +171,100 @@ namespace storm { } template - std::ostream& ExplicitQuantitativeCheckResult::writeToStream(std::ostream& out) const { + void print(std::ostream& out, ValueType const& value) { + if (value == storm::utility::infinity()) { + out << "inf"; + } else { + out << value; + if (std::is_same::value) { + out << " (approx. " << storm::utility::convertNumber(value) << ")"; + } + } + } + + template + void printRange(std::ostream& out, ValueType const& min, ValueType const& max) { out << "["; + if (min == storm::utility::infinity()) { + out << "inf"; + } else { + out << min; + } + out << ", "; + if (max == storm::utility::infinity()) { + out << "inf"; + } else { + out << max; + } + out << "]"; + if (std::is_same::value) { + out << " (approx. ["; + if (min == storm::utility::infinity()) { + out << "inf"; + } else { + out << storm::utility::convertNumber(min); + } + out << ", "; + if (max == storm::utility::infinity()) { + out << "inf"; + } else { + out << storm::utility::convertNumber(max); + } + out << "])"; + } + out << " (range)"; + } + + template + std::ostream& ExplicitQuantitativeCheckResult::writeToStream(std::ostream& out) const { + bool minMaxSupported = std::is_same::value || std::is_same::value; + bool printAsRange = false; + if (this->isResultForAllStates()) { vector_type const& valuesAsVector = boost::get(values); - bool first = true; - for (auto const& element : valuesAsVector) { - if (!first) { - out << ", "; - } else { - first = false; + if (valuesAsVector.size() >= 10 && minMaxSupported) { + printAsRange = true; + } else { + out << "{"; + bool first = true; + for (auto const& element : valuesAsVector) { + if (!first) { + out << ", "; + } else { + first = false; + } + print(out, element); } - out << element; + out << "}"; } } else { map_type const& valuesAsMap = boost::get(values); - bool first = true; - for (auto const& element : valuesAsMap) { - if (!first) { - out << ", "; + if (valuesAsMap.size() >= 10 && minMaxSupported) { + printAsRange = true; + } else { + if (valuesAsMap.size() == 1) { + print(out, valuesAsMap.begin()->second); } else { - first = false; + out << "{"; + bool first = true; + for (auto const& element : valuesAsMap) { + if (!first) { + out << ", "; + } else { + first = false; + } + print(out, element.second); + } + out << "}"; } - out << element.second; } } - out << "]"; + + if (printAsRange) { + std::pair minmax = this->getMinMax(); + printRange(out, minmax.first, minmax.second); + } + return out; } diff --git a/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.h b/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.h index 87689e50c..9fe1e2c29 100644 --- a/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.h +++ b/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.h @@ -56,6 +56,7 @@ namespace storm { virtual ValueType getMin() const override; virtual ValueType getMax() const override; + virtual std::pair getMinMax() const; virtual ValueType average() const override; virtual ValueType sum() const override; diff --git a/src/storm/modelchecker/results/HybridQuantitativeCheckResult.cpp b/src/storm/modelchecker/results/HybridQuantitativeCheckResult.cpp index 4fd8a7326..ef52d6028 100644 --- a/src/storm/modelchecker/results/HybridQuantitativeCheckResult.cpp +++ b/src/storm/modelchecker/results/HybridQuantitativeCheckResult.cpp @@ -92,33 +92,52 @@ namespace storm { template std::ostream& HybridQuantitativeCheckResult::writeToStream(std::ostream& out) const { - out << "["; - bool first = true; - if (!this->symbolicStates.isZero()) { - if (this->symbolicValues.isZero()) { - out << "0"; + uint64_t totalNumberOfStates = this->symbolicStates.getNonZeroCount() + this->explicitStates.getNonZeroCount(); + + if (totalNumberOfStates == 1) { + if (this->symbolicStates.isZero()) { + out << *this->explicitValues.begin(); } else { - for (auto valuationValuePair : this->symbolicValues) { + out << this->symbolicValues.getMax(); + } + } else if (totalNumberOfStates < 10) { + out << "{"; + bool first = true; + if (!this->symbolicStates.isZero()) { + if (this->symbolicValues.isZero()) { + out << "0"; + first = false; + } else { + for (auto valuationValuePair : this->symbolicValues) { + if (!first) { + out << ", "; + } else { + first = false; + } + out << valuationValuePair.second; + } + if (symbolicStates.getNonZeroCount() != this->symbolicValues.getNonZeroCount()) { + out << ", 0"; + } + } + } + if (!this->explicitStates.isZero()) { + for (auto const& element : this->explicitValues) { if (!first) { out << ", "; } else { first = false; } - out << valuationValuePair.second; - } - } - } - if (!this->explicitStates.isZero()) { - for (auto const& element : this->explicitValues) { - if (!first) { - out << ", "; - } else { - first = false; + out << element; } - out << element; } + out << "}"; + } else { + ValueType min = this->getMin(); + ValueType max = this->getMax(); + + out << "[" << min << ", " << max << "] (range)"; } - out << "]"; return out; } diff --git a/src/storm/modelchecker/results/QuantitativeCheckResult.cpp b/src/storm/modelchecker/results/QuantitativeCheckResult.cpp index 24884648a..f068ef7d6 100644 --- a/src/storm/modelchecker/results/QuantitativeCheckResult.cpp +++ b/src/storm/modelchecker/results/QuantitativeCheckResult.cpp @@ -10,7 +10,7 @@ namespace storm { namespace modelchecker { template - std::unique_ptr QuantitativeCheckResult::compareAgainstBound(storm::logic::ComparisonType comparisonType, ValueType const& bound) const { + std::unique_ptr QuantitativeCheckResult::compareAgainstBound(storm::logic::ComparisonType, ValueType const&) const { STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Unable to perform comparison against bound on the check result."); } diff --git a/src/storm/modelchecker/results/SymbolicQualitativeCheckResult.cpp b/src/storm/modelchecker/results/SymbolicQualitativeCheckResult.cpp index 84399a8ef..eb407eaa3 100644 --- a/src/storm/modelchecker/results/SymbolicQualitativeCheckResult.cpp +++ b/src/storm/modelchecker/results/SymbolicQualitativeCheckResult.cpp @@ -12,6 +12,11 @@ namespace storm { // Intentionally left empty. } + template + SymbolicQualitativeCheckResult::SymbolicQualitativeCheckResult(storm::dd::Bdd const& reachableStates, storm::dd::Bdd const& states, storm::dd::Bdd const& truthValues) : reachableStates(reachableStates), states(states), truthValues(truthValues) { + // Intentionally left empty. + } + template bool SymbolicQualitativeCheckResult::isSymbolic() const { return true; @@ -68,10 +73,20 @@ namespace storm { template std::ostream& SymbolicQualitativeCheckResult::writeToStream(std::ostream& out) const { - if (this->truthValues.isZero()) { - out << "[false]" << std::endl; + if (states.getNonZeroCount() == 1) { + if (truthValues.isZero()) { + out << "false"; + } else { + out << "true"; + } + } else if (states == truthValues) { + out << "{true}" << std::endl; } else { - out << "[true]" << std::endl; + if (truthValues.isZero()) { + out << "{false}" << std::endl; + } else { + out << "{true, false}" << std::endl; + } } return out; } @@ -79,6 +94,7 @@ namespace storm { template void SymbolicQualitativeCheckResult::filter(QualitativeCheckResult const& filter) { STORM_LOG_THROW(filter.isSymbolicQualitativeCheckResult(), storm::exceptions::InvalidOperationException, "Cannot filter symbolic check result with non-symbolic filter."); + this->states &= filter.asSymbolicQualitativeCheckResult().getTruthValuesVector();; this->truthValues &= filter.asSymbolicQualitativeCheckResult().getTruthValuesVector(); this->states &= filter.asSymbolicQualitativeCheckResult().getTruthValuesVector(); } diff --git a/src/storm/modelchecker/results/SymbolicQualitativeCheckResult.h b/src/storm/modelchecker/results/SymbolicQualitativeCheckResult.h index c0a64f1ec..0dc84690b 100644 --- a/src/storm/modelchecker/results/SymbolicQualitativeCheckResult.h +++ b/src/storm/modelchecker/results/SymbolicQualitativeCheckResult.h @@ -13,6 +13,7 @@ namespace storm { public: SymbolicQualitativeCheckResult() = default; SymbolicQualitativeCheckResult(storm::dd::Bdd const& reachableStates, storm::dd::Bdd const& truthValues); + SymbolicQualitativeCheckResult(storm::dd::Bdd const& reachableStates, storm::dd::Bdd const& states, storm::dd::Bdd const& truthValues); SymbolicQualitativeCheckResult(SymbolicQualitativeCheckResult const& other) = default; SymbolicQualitativeCheckResult& operator=(SymbolicQualitativeCheckResult const& other) = default; diff --git a/src/storm/modelchecker/results/SymbolicQuantitativeCheckResult.cpp b/src/storm/modelchecker/results/SymbolicQuantitativeCheckResult.cpp index e0a1c658f..9dce5fe56 100644 --- a/src/storm/modelchecker/results/SymbolicQuantitativeCheckResult.cpp +++ b/src/storm/modelchecker/results/SymbolicQuantitativeCheckResult.cpp @@ -17,6 +17,11 @@ namespace storm { // Intentionally left empty. } + template + SymbolicQuantitativeCheckResult::SymbolicQuantitativeCheckResult(storm::dd::Bdd const& reachableStates, storm::dd::Bdd const& states, storm::dd::Add const& values) : reachableStates(reachableStates), states(states), values(values) { + // Intentionally left empty. + } + template std::unique_ptr SymbolicQuantitativeCheckResult::compareAgainstBound(storm::logic::ComparisonType comparisonType, ValueType const& bound) const { storm::dd::Bdd states; @@ -54,21 +59,33 @@ namespace storm { template std::ostream& SymbolicQuantitativeCheckResult::writeToStream(std::ostream& out) const { - out << "["; - if (this->values.isZero()) { - out << "0"; - } else { - bool first = true; - for (auto valuationValuePair : this->values) { - if (!first) { - out << ", "; - } else { - first = false; + if (states.getNonZeroCount() == 1) { + out << this->values.getMax(); + } else if (states.getNonZeroCount() < 10) { + out << "{"; + if (this->values.isZero()) { + out << "0"; + } else { + bool first = true; + for (auto valuationValuePair : this->values) { + if (!first) { + out << ", "; + } else { + first = false; + } + out << valuationValuePair.second; + } + if (states.getNonZeroCount() != this->values.getNonZeroCount()) { + out << ", 0"; } - out << valuationValuePair.second; } + out << "}"; + } else { + ValueType min = this->getMin(); + ValueType max = this->getMax(); + + out << "[" << min << ", " << max << "] (range)"; } - out << "]"; return out; } diff --git a/src/storm/modelchecker/results/SymbolicQuantitativeCheckResult.h b/src/storm/modelchecker/results/SymbolicQuantitativeCheckResult.h index b24bf77ca..5c02e8cf0 100644 --- a/src/storm/modelchecker/results/SymbolicQuantitativeCheckResult.h +++ b/src/storm/modelchecker/results/SymbolicQuantitativeCheckResult.h @@ -13,6 +13,7 @@ namespace storm { public: SymbolicQuantitativeCheckResult() = default; SymbolicQuantitativeCheckResult(storm::dd::Bdd const& reachableStates, storm::dd::Add const& values); + SymbolicQuantitativeCheckResult(storm::dd::Bdd const& reachableStates, storm::dd::Bdd const& states, storm::dd::Add const& values); SymbolicQuantitativeCheckResult(SymbolicQuantitativeCheckResult const& other) = default; SymbolicQuantitativeCheckResult& operator=(SymbolicQuantitativeCheckResult const& other) = default; diff --git a/src/storm/models/ModelBase.h b/src/storm/models/ModelBase.h index c1a696c03..cbef9a9dc 100644 --- a/src/storm/models/ModelBase.h +++ b/src/storm/models/ModelBase.h @@ -60,14 +60,7 @@ namespace storm { * @return The number of (non-zero) transitions of the model. */ virtual uint_fast64_t getNumberOfTransitions() const = 0; - - /*! - * Retrieves (an approximation of) the size of the model in bytes. - * - * @return The size of th model in bytes. - */ - virtual std::size_t getSizeInBytes() const = 0; - + /*! * Prints information about the model to the specified stream. * diff --git a/src/storm/models/sparse/MarkovAutomaton.cpp b/src/storm/models/sparse/MarkovAutomaton.cpp index 9ba556281..069ed1936 100644 --- a/src/storm/models/sparse/MarkovAutomaton.cpp +++ b/src/storm/models/sparse/MarkovAutomaton.cpp @@ -125,44 +125,31 @@ namespace storm { template void MarkovAutomaton::close() { if (!closed) { - // First, count the number of hybrid states to know how many Markovian choices - // will be removed. - uint_fast64_t numberOfHybridStates = 0; - for (uint_fast64_t state = 0; state < this->getNumberOfStates(); ++state) { - if (this->isHybridState(state)) { - ++numberOfHybridStates; + // Get the choices that we will keep + storm::storage::BitVector keptChoices(this->getNumberOfChoices(), true); + for(auto state : this->getMarkovianStates()) { + if(this->getTransitionMatrix().getRowGroupSize(state) > 1) { + // The state is hybrid, hence, we remove the first choice. + keptChoices.set(this->getTransitionMatrix().getRowGroupIndices()[state], false); + // Afterwards, the state will no longer be Markovian. + this->markovianStates.set(state, false); + exitRates[state] = storm::utility::zero(); } } - - // Create the matrix for the new transition relation and the corresponding nondeterministic choice vector. - storm::storage::SparseMatrixBuilder newTransitionMatrixBuilder(0, 0, 0, false, true, this->getNumberOfStates()); - - // Now copy over all choices that need to be kept. - uint_fast64_t currentChoice = 0; - for (uint_fast64_t state = 0; state < this->getNumberOfStates(); ++state) { - // Record the new beginning of choices of this state. - newTransitionMatrixBuilder.newRowGroup(currentChoice); - - // If the state is a hybrid state, closing it will make it a probabilistic state, so we remove the Markovian marking. - // Additionally, we need to remember whether we need to skip the first choice of the state when - // we assemble the new transition matrix. - uint_fast64_t offset = 0; - if (this->isHybridState(state)) { - this->markovianStates.set(state, false); - offset = 1; + // Remove the Markovian choices for the different model ingredients + this->getTransitionMatrix() = this->getTransitionMatrix().restrictRows(keptChoices); + for(auto& rewModel : this->getRewardModels()) { + if(rewModel.second.hasStateActionRewards()) { + rewModel.second.getStateActionRewardVector() = storm::utility::vector::filterVector(rewModel.second.getStateActionRewardVector(), keptChoices); } - - for (uint_fast64_t row = this->getTransitionMatrix().getRowGroupIndices()[state] + offset; row < this->getTransitionMatrix().getRowGroupIndices()[state + 1]; ++row) { - for (auto const& entry : this->getTransitionMatrix().getRow(row)) { - newTransitionMatrixBuilder.addNextValue(currentChoice, entry.getColumn(), entry.getValue()); - } - ++currentChoice; + if(rewModel.second.hasTransitionRewards()) { + rewModel.second.getTransitionRewardMatrix() = rewModel.second.getTransitionRewardMatrix().restrictRows(keptChoices); } } - - // Finalize the matrix and put the new transition data in place. - this->setTransitionMatrix(newTransitionMatrixBuilder.build()); - + if(this->hasChoiceLabeling()) { + this->getOptionalChoiceLabeling() = storm::utility::vector::filterVector(this->getOptionalChoiceLabeling().get(), keptChoices); + } + // Mark the automaton as closed. closed = true; } @@ -249,11 +236,6 @@ namespace storm { } } - template - std::size_t MarkovAutomaton::getSizeInBytes() const { - return NondeterministicModel::getSizeInBytes() + markovianStates.getSizeInBytes() + exitRates.size() * sizeof(ValueType); - } - template void MarkovAutomaton::turnRatesToProbabilities() { this->exitRates.resize(this->getNumberOfStates()); @@ -349,6 +331,7 @@ namespace storm { optionalChoiceLabeling = storm::utility::vector::filterVector(optionalChoiceLabeling.get(), keepStates); } //TODO update reward models according to kept states + STORM_LOG_WARN_COND(this->getRewardModels().empty(), "Conversion of MA to CTMC does not preserve rewards."); std::unordered_map rewardModels = this->getRewardModels(); return std::make_shared>(std::move(rateMatrix), std::move(stateLabeling), std::move(rewardModels), std::move(optionalChoiceLabeling)); diff --git a/src/storm/models/sparse/MarkovAutomaton.h b/src/storm/models/sparse/MarkovAutomaton.h index cd45b141b..477d0ee5f 100644 --- a/src/storm/models/sparse/MarkovAutomaton.h +++ b/src/storm/models/sparse/MarkovAutomaton.h @@ -194,9 +194,7 @@ namespace storm { std::shared_ptr> convertToCTMC() const; virtual void writeDotToStream(std::ostream& outStream, bool includeLabeling = true, storm::storage::BitVector const* subsystem = nullptr, std::vector const* firstValue = nullptr, std::vector const* secondValue = nullptr, std::vector const* stateColoring = nullptr, std::vector const* colors = nullptr, std::vector* scheduler = nullptr, bool finalizeOutput = true) const override; - - std::size_t getSizeInBytes() const override; - + virtual void printModelInformationToStream(std::ostream& out) const override; private: diff --git a/src/storm/models/sparse/Model.cpp b/src/storm/models/sparse/Model.cpp index 4a0ec1541..3f7774759 100644 --- a/src/storm/models/sparse/Model.cpp +++ b/src/storm/models/sparse/Model.cpp @@ -167,6 +167,11 @@ namespace storm { boost::optional> const& Model::getOptionalChoiceLabeling() const { return choiceLabeling; } + + template + boost::optional>& Model::getOptionalChoiceLabeling() { + return choiceLabeling; + } template storm::models::sparse::StateLabeling const& Model::getStateLabeling() const { @@ -183,18 +188,6 @@ namespace storm { return static_cast(choiceLabeling); } - template - std::size_t Model::getSizeInBytes() const { - std::size_t result = transitionMatrix.getSizeInBytes() + stateLabeling.getSizeInBytes(); - for (auto const& rewardModel : this->rewardModels) { - result += rewardModel.second.getSizeInBytes(); - } - if (hasChoiceLabeling()) { - result += getChoiceLabeling().size() * sizeof(LabelSet); - } - return result; - } - template void Model::printModelInformationToStream(std::ostream& out) const { this->printModelInformationHeaderToStream(out); @@ -214,7 +207,6 @@ namespace storm { this->printRewardModelsInformationToStream(out); this->getStateLabeling().printLabelingInformationToStream(out); out << "choice labels: \t" << (this->hasChoiceLabeling() ? "yes" : "no") << std::noboolalpha << std::endl; - out << "Size in memory: " << (this->getSizeInBytes())/1024 << " kbytes" << std::endl; out << "-------------------------------------------------------------- " << std::endl; } @@ -233,7 +225,7 @@ namespace storm { } template - void Model::writeDotToStream(std::ostream& outStream, bool includeLabeling, storm::storage::BitVector const* subsystem, std::vector const* firstValue, std::vector const* secondValue, std::vector const* stateColoring, std::vector const* colors, std::vector* scheduler, bool finalizeOutput) const { + void Model::writeDotToStream(std::ostream& outStream, bool includeLabeling, storm::storage::BitVector const* subsystem, std::vector const* firstValue, std::vector const* secondValue, std::vector const* stateColoring, std::vector const* colors, std::vector*, bool finalizeOutput) const { outStream << "digraph model {" << std::endl; // Write all states to the stream. @@ -360,6 +352,17 @@ namespace storm { std::set getProbabilityParameters(Model const& model) { return storm::storage::getVariables(model.getTransitionMatrix()); } + + + + std::set getRewardParameters(Model const& model) { + std::set result; + for(auto rewModel : model.getRewardModels()) { + std::set tmp = getRewardModelParameters(rewModel.second); + result.insert(tmp.begin(), tmp.end()); + } + return result; + } #endif template class Model; diff --git a/src/storm/models/sparse/Model.h b/src/storm/models/sparse/Model.h index 51f43eb57..a545ae3ce 100644 --- a/src/storm/models/sparse/Model.h +++ b/src/storm/models/sparse/Model.h @@ -239,6 +239,13 @@ namespace storm { * @return The labels for the choices, if they're saved. */ boost::optional> const& getOptionalChoiceLabeling() const; + + /*! + * Retrieves an optional value that contains the choice labeling if there is one. + * + * @return The labels for the choices, if they're saved. + */ + boost::optional>& getOptionalChoiceLabeling(); /*! * Returns the state labeling associated with this model. @@ -268,14 +275,7 @@ namespace storm { * properties, but it preserves expected rewards. */ virtual void reduceToStateBasedRewards() = 0; - - /*! - * Retrieves (an approximation of) the size of the model in bytes. - * - * @return The size of the internal representation of the model measured in bytes. - */ - virtual std::size_t getSizeInBytes() const override; - + /*! * Prints information about the model to the specified stream. * @@ -374,6 +374,7 @@ namespace storm { #ifdef STORM_HAVE_CARL std::set getProbabilityParameters(Model const& model); + std::set getRewardParameters(Model const& model); #endif } // namespace sparse } // namespace models diff --git a/src/storm/models/sparse/StandardRewardModel.cpp b/src/storm/models/sparse/StandardRewardModel.cpp index c82041437..4f43c62fb 100644 --- a/src/storm/models/sparse/StandardRewardModel.cpp +++ b/src/storm/models/sparse/StandardRewardModel.cpp @@ -161,7 +161,7 @@ namespace storm { this->optionalStateActionRewardVector = boost::none; } } - + template template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix) const { @@ -177,16 +177,16 @@ namespace storm { template template - std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& weights) const { - std::vector result = this->hasTransitionRewards() ? transitionMatrix.getPointwiseProductRowSumVector(this->getTransitionRewardMatrix()) : (this->hasStateActionRewards() ? this->getStateActionRewardVector() : std::vector(transitionMatrix.getRowCount())); - if (!this->hasTransitionRewards() && this->hasStateActionRewards()) { - // If we initialized the result with the state-action rewards we can scale the result in place. - storm::utility::vector::multiplyVectorsPointwise(result, weights, result); - } - if (this->hasStateActionRewards() && this->hasTransitionRewards()) { - // If we initialized the result with the transition rewards and still have state-action rewards, - // we need to add the scaled vector directly. - storm::utility::vector::applyPointwise(weights, this->getStateActionRewardVector(), result, [] (MatrixValueType const& weight, ValueType const& rewardElement, ValueType const& resultElement) { return resultElement + weight * rewardElement; } ); + std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& weights, bool scaleTransAndActions) const { + std::vector result; + if (this->hasTransitionRewards()) { + result = transitionMatrix.getPointwiseProductRowSumVector(this->getTransitionRewardMatrix()); + storm::utility::vector::applyPointwise(weights, this->getStateActionRewardVector(), result, [] (MatrixValueType const& weight, ValueType const& rewardElement, ValueType const& resultElement) { return weight * (resultElement + rewardElement); } ); + } else { + result = std::vector(transitionMatrix.getRowCount()); + if (this->hasStateActionRewards()) { + storm::utility::vector::applyPointwise(weights, this->getStateActionRewardVector(), result, [] (MatrixValueType const& weight, ValueType const& rewardElement, ValueType const& resultElement) { return weight * rewardElement; } ); + } } if (this->hasStateRewards()) { storm::utility::vector::addVectorToGroupedVector(result, this->getStateRewardVector(), transitionMatrix.getRowGroupIndices()); @@ -211,24 +211,23 @@ namespace storm { } return result; } - - template - std::vector StandardRewardModel::getTotalStateActionRewardVector(uint_fast64_t numberOfRows, std::vector const& rowGroupIndices) const { - std::vector result = this->hasStateActionRewards() ? this->getStateActionRewardVector() : std::vector(numberOfRows); - if (this->hasStateRewards()) { - storm::utility::vector::addVectorToGroupedVector(result, this->getStateRewardVector(), rowGroupIndices); - } - return result; - } - + template - std::vector StandardRewardModel::getTotalStateActionRewardVector(uint_fast64_t numberOfRows, std::vector const& rowGroupIndices, storm::storage::BitVector const& filter) const { - std::vector result(numberOfRows); - if (this->hasStateRewards()) { - storm::utility::vector::selectVectorValuesRepeatedly(result, filter, rowGroupIndices, this->getStateRewardVector()); + template + std::vector StandardRewardModel::getTotalActionRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& stateRewardWeights) const { + std::vector result; + if (this->hasTransitionRewards()) { + result = transitionMatrix.getPointwiseProductRowSumVector(this->getTransitionRewardMatrix()); + } else { + result = std::vector(transitionMatrix.getRowCount()); } if (this->hasStateActionRewards()) { - storm::utility::vector::addFilteredVectorGroupsToGroupedVector(result, this->getStateActionRewardVector(), filter, rowGroupIndices); + storm::utility::vector::addVectors(result, this->getStateActionRewardVector(), result); + } + if (this->hasStateRewards()) { + std::vector scaledStateRewardVector(transitionMatrix.getRowGroupCount()); + storm::utility::vector::multiplyVectorsPointwise(this->getStateRewardVector(), stateRewardWeights, scaledStateRewardVector); + storm::utility::vector::addVectorToGroupedVector(result, scaledStateRewardVector, transitionMatrix.getRowGroupIndices()); } return result; } @@ -270,22 +269,6 @@ namespace storm { return true; } - - template - std::size_t StandardRewardModel::getSizeInBytes() const { - std::size_t result = 0; - if (this->hasStateRewards()) { - result += this->getStateRewardVector().size() * sizeof(ValueType); - } - if (this->hasStateActionRewards()) { - result += this->getStateActionRewardVector().size() * sizeof(ValueType); - } - if (this->hasTransitionRewards()) { - result += this->getTransitionRewardMatrix().getSizeInBytes(); - } - return result; - } - template std::ostream& operator<<(std::ostream& out, StandardRewardModel const& rewardModel) { out << std::boolalpha << "reward model [state reward: " @@ -298,11 +281,29 @@ namespace storm { << std::noboolalpha; return out; } - + + std::set getRewardModelParameters(StandardRewardModel const& rewModel) { + std::set vars; + if (rewModel.hasTransitionRewards()) { + vars = storm::storage::getVariables(rewModel.getTransitionRewardMatrix()); + } + if (rewModel.hasStateActionRewards()) { + std::set tmp = storm::utility::vector::getVariables(rewModel.getStateActionRewardVector()); + vars.insert(tmp.begin(), tmp.end()); + } + if (rewModel.hasStateRewards()) { + std::set tmp = storm::utility::vector::getVariables(rewModel.getStateRewardVector()); + vars.insert(tmp.begin(), tmp.end()); + } + return vars; + + } + // Explicitly instantiate the class. template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix) const; template std::vector StandardRewardModel::getTotalRewardVector(uint_fast64_t numberOfRows, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::BitVector const& filter) const; - template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& weights) const; + template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& weights, bool scaleTransAndActions) const; + template std::vector StandardRewardModel::getTotalActionRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& stateRewardWeights) const; template void StandardRewardModel::reduceToStateBasedRewards(storm::storage::SparseMatrix const& transitionMatrix, bool reduceToStateRewards); template void StandardRewardModel::setStateActionReward(uint_fast64_t choiceIndex, double const & newValue); template void StandardRewardModel::setStateReward(uint_fast64_t state, double const & newValue); @@ -311,7 +312,8 @@ namespace storm { template std::vector StandardRewardModel::getTotalRewardVector(uint_fast64_t numberOfRows, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::BitVector const& filter) const; template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix) const; - template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& weights) const; + template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& weights, bool scaleTransAndActions) const; + template std::vector StandardRewardModel::getTotalActionRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& stateRewardWeights) const; template void StandardRewardModel::reduceToStateBasedRewards(storm::storage::SparseMatrix const& transitionMatrix, bool reduceToStateRewards); template void StandardRewardModel::setStateActionReward(uint_fast64_t choiceIndex, float const & newValue); template void StandardRewardModel::setStateReward(uint_fast64_t state, float const & newValue); @@ -321,25 +323,28 @@ namespace storm { #ifdef STORM_HAVE_CARL template std::vector StandardRewardModel::getTotalRewardVector(uint_fast64_t numberOfRows, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::BitVector const& filter) const; template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix) const; - template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& weights) const; + template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& weights, bool scaleTransAndActions) const; + template std::vector StandardRewardModel::getTotalActionRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& stateRewardWeights) const; template void StandardRewardModel::reduceToStateBasedRewards(storm::storage::SparseMatrix const& transitionMatrix, bool reduceToStateRewards); template void StandardRewardModel::setStateActionReward(uint_fast64_t choiceIndex, storm::RationalNumber const & newValue); template void StandardRewardModel::setStateReward(uint_fast64_t state, storm::RationalNumber const & newValue); template class StandardRewardModel; template std::ostream& operator<<(std::ostream& out, StandardRewardModel const& rewardModel); - + template std::vector StandardRewardModel::getTotalRewardVector(uint_fast64_t numberOfRows, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::BitVector const& filter) const; template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix) const; - template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& weights) const; + template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& weights, bool scaleTransAndActions) const; + template std::vector StandardRewardModel::getTotalActionRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& stateRewardWeights) const; template void StandardRewardModel::reduceToStateBasedRewards(storm::storage::SparseMatrix const& transitionMatrix, bool reduceToStateRewards); template void StandardRewardModel::setStateActionReward(uint_fast64_t choiceIndex, storm::RationalFunction const & newValue); template void StandardRewardModel::setStateReward(uint_fast64_t state, storm::RationalFunction const & newValue); template class StandardRewardModel; template std::ostream& operator<<(std::ostream& out, StandardRewardModel const& rewardModel); - + template std::vector StandardRewardModel::getTotalRewardVector(uint_fast64_t numberOfRows, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::BitVector const& filter) const; template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix) const; - template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& weights) const; + template std::vector StandardRewardModel::getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& weights, bool scaleTransAndActions) const; + template std::vector StandardRewardModel::getTotalActionRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& stateRewardWeights) const; template void StandardRewardModel::setStateActionReward(uint_fast64_t choiceIndex, double const & newValue); template void StandardRewardModel::setStateActionReward(uint_fast64_t choiceIndex, storm::Interval const & newValue); template void StandardRewardModel::setStateReward(uint_fast64_t state, double const & newValue); diff --git a/src/storm/models/sparse/StandardRewardModel.h b/src/storm/models/sparse/StandardRewardModel.h index 6651b789b..7251ac656 100644 --- a/src/storm/models/sparse/StandardRewardModel.h +++ b/src/storm/models/sparse/StandardRewardModel.h @@ -1,11 +1,11 @@ -#ifndef STORM_MODELS_SPARSE_STANDARDREWARDMODEL_H_ -#define STORM_MODELS_SPARSE_STANDARDREWARDMODEL_H_ +#pragma once #include #include #include "storm/storage/SparseMatrix.h" #include "storm/utility/OsDetection.h" +#include "storm/adapters/CarlAdapter.h" namespace storm { namespace models { @@ -198,11 +198,13 @@ namespace storm { * transition-based rewards in the reward model. * * @param transitionMatrix The matrix that is used to weight the values of the transition reward matrix. - * @param weights A vector used for scaling the entries of the state-action rewards (if present). + * @param weights A vector used for scaling the entries of transition and/or state-action rewards (if present). + * @param scaleTransAndActions If true both transition rewards and state-action rewards are scaled by the + * weights. Otherwise, only the state-action rewards are scaled. * @return The full state-action reward vector. */ template - std::vector getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& weights) const; + std::vector getTotalRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& weights, bool scaleTransAndActions) const; /*! * Creates a vector representing the complete reward vector based on the state-, state-action- and @@ -215,28 +217,19 @@ namespace storm { */ template std::vector getTotalRewardVector(uint_fast64_t numberOfRows, storm::storage::SparseMatrix const& transitionMatrix, storm::storage::BitVector const& filter) const; - - /*! - * Creates a vector representing the complete state action reward vector based on the state-, state-action- - * and transition-based rewards in the reward model. - * - * @param numberOfRows The total number of rows of the resulting vector. - * @param rowGroupIndices The starting indices of the row groups. - * @return The full state-action reward vector. - */ - std::vector getTotalStateActionRewardVector(uint_fast64_t numberOfRows, std::vector const& rowGroupIndices) const; - + /*! - * Creates a vector representing the complete state action reward vector based on the state- and - * state-action rewards in the reward model. + * Creates a vector representing the complete action-based rewards, i.e., state-action- and + * transition-based rewards * * @param numberOfRows The total number of rows of the resulting vector. - * @param rowGroupIndices The starting indices of the row groups. - * @param filter A bit vector indicating which row groups to select. - * @return The full state-action reward vector. + * @param transitionMatrix The matrix that is used to weight the values of the transition reward matrix. + * @return The state-action reward vector that considers state-action rewards and transition rewards of this reward model. */ - std::vector getTotalStateActionRewardVector(uint_fast64_t numberOfRows, std::vector const& rowGroupIndices, storm::storage::BitVector const& filter) const; - + + template + std::vector getTotalActionRewardVector(storm::storage::SparseMatrix const& transitionMatrix, std::vector const& stateRewardWeights) const; + /*! * Sets the given value in the state-action reward vector at the given row. This assumes that the reward * model has state-action rewards. @@ -272,13 +265,6 @@ namespace storm { * @param nrChoices The number of choices in the model */ bool isCompatible(uint_fast64_t nrStates, uint_fast64_t nrChoices) const; - - /*! - * Retrieves (an approximation of) the size of the model in bytes. - * - * @return The size of the internal representation of the model measured in bytes. - */ - std::size_t getSizeInBytes() const; template friend std::ostream& operator<<(std::ostream& out, StandardRewardModel const& rewardModel); @@ -296,8 +282,8 @@ namespace storm { template std::ostream& operator<<(std::ostream& out, StandardRewardModel const& rewardModel); + + std::set getRewardModelParameters(StandardRewardModel const& rewModel); } } } - -#endif /* STORM_MODELS_SPARSE_STANDARDREWARDMODEL_H_ */ diff --git a/src/storm/models/sparse/StateLabeling.cpp b/src/storm/models/sparse/StateLabeling.cpp index b3037d173..55eaa76d5 100644 --- a/src/storm/models/sparse/StateLabeling.cpp +++ b/src/storm/models/sparse/StateLabeling.cpp @@ -109,14 +109,6 @@ namespace storm { this->labelings[nameToLabelingIndexMap.at(label)] = labeling; } - std::size_t StateLabeling::getSizeInBytes() const { - std::size_t result = sizeof(*this); - if (!labelings.empty()) { - result += labelings.size() * labelings.front().getSizeInBytes(); - } - return result; - } - void StateLabeling::printLabelingInformationToStream(std::ostream& out) const { out << "Labels: \t" << this->getNumberOfLabels() << std::endl; for (auto const& labelIndexPair : this->nameToLabelingIndexMap) { diff --git a/src/storm/models/sparse/StateLabeling.h b/src/storm/models/sparse/StateLabeling.h index c3de34599..330a4d8fe 100644 --- a/src/storm/models/sparse/StateLabeling.h +++ b/src/storm/models/sparse/StateLabeling.h @@ -145,14 +145,7 @@ namespace storm { * @param labeling A bit vector that represents the set of states that will get this label. */ void setStates(std::string const& label, storage::BitVector&& labeling); - - /*! - * Returns (an approximation of) the size of the labeling measured in bytes. - * - * @return The size of the labeling measured in bytes. - */ - std::size_t getSizeInBytes() const; - + /*! * Prints information about the labeling to the specified stream. * diff --git a/src/storm/models/symbolic/Ctmc.cpp b/src/storm/models/symbolic/Ctmc.cpp index e3dd2e724..410e247b5 100644 --- a/src/storm/models/symbolic/Ctmc.cpp +++ b/src/storm/models/symbolic/Ctmc.cpp @@ -24,12 +24,33 @@ namespace storm { std::map labelToExpressionMap, std::unordered_map const& rewardModels) : DeterministicModel(storm::models::ModelType::Ctmc, manager, reachableStates, initialStates, deadlockStates, transitionMatrix, rowVariables, rowExpressionAdapter, columnVariables, columnExpressionAdapter, rowColumnMetaVariablePairs, labelToExpressionMap, rewardModels) { - exitRates = this->getTransitionMatrix().sumAbstract(this->getColumnVariables()); + // Intentionally left empty. } - + + template + Ctmc::Ctmc(std::shared_ptr> manager, + storm::dd::Bdd reachableStates, + storm::dd::Bdd initialStates, + storm::dd::Bdd deadlockStates, + storm::dd::Add transitionMatrix, + boost::optional> exitRateVector, + std::set const& rowVariables, + std::shared_ptr> rowExpressionAdapter, + std::set const& columnVariables, + std::shared_ptr> columnExpressionAdapter, + std::vector> const& rowColumnMetaVariablePairs, + std::map labelToExpressionMap, + std::unordered_map const& rewardModels) + : DeterministicModel(storm::models::ModelType::Ctmc, manager, reachableStates, initialStates, deadlockStates, transitionMatrix, rowVariables, rowExpressionAdapter, columnVariables, columnExpressionAdapter, rowColumnMetaVariablePairs, labelToExpressionMap, rewardModels), exitRates(exitRateVector) { + // Intentionally left empty. + } + template storm::dd::Add const& Ctmc::getExitRateVector() const { - return exitRates; + if (!exitRates) { + exitRates = this->getTransitionMatrix().sumAbstract(this->getColumnVariables()); + } + return exitRates.get(); } // Explicitly instantiate the template class. diff --git a/src/storm/models/symbolic/Ctmc.h b/src/storm/models/symbolic/Ctmc.h index 8701ed148..c0c4054a3 100644 --- a/src/storm/models/symbolic/Ctmc.h +++ b/src/storm/models/symbolic/Ctmc.h @@ -54,7 +54,40 @@ namespace storm { std::vector> const& rowColumnMetaVariablePairs, std::map labelToExpressionMap = std::map(), std::unordered_map const& rewardModels = std::unordered_map()); - + + /*! + * Constructs a model from the given data. + * + * @param manager The manager responsible for the decision diagrams. + * @param reachableStates A DD representing the reachable states. + * @param initialStates A DD representing the initial states of the model. + * @param deadlockStates A DD representing the deadlock states of the model. + * @param transitionMatrix The matrix representing the transitions in the model. + * @param exitRateVector The vector specifying the exit rates for the states. + * @param rowVariables The set of row meta variables used in the DDs. + * @param rowExpressionAdapter An object that can be used to translate expressions in terms of the row + * meta variables. + * @param columVariables The set of column meta variables used in the DDs. + * @param columnExpressionAdapter An object that can be used to translate expressions in terms of the + * column meta variables. + * @param rowColumnMetaVariablePairs All pairs of row/column meta variables. + * @param labelToExpressionMap A mapping from label names to their defining expressions. + * @param rewardModels The reward models associated with the model. + */ + Ctmc(std::shared_ptr> manager, + storm::dd::Bdd reachableStates, + storm::dd::Bdd initialStates, + storm::dd::Bdd deadlockStates, + storm::dd::Add transitionMatrix, + boost::optional> exitRateVector, + std::set const& rowVariables, + std::shared_ptr> rowExpressionAdapter, + std::set const& columnVariables, + std::shared_ptr> columnExpressionAdapter, + std::vector> const& rowColumnMetaVariablePairs, + std::map labelToExpressionMap = std::map(), + std::unordered_map const& rewardModels = std::unordered_map()); + /*! * Retrieves the exit rate vector of the CTMC. * @@ -63,7 +96,7 @@ namespace storm { storm::dd::Add const& getExitRateVector() const; private: - storm::dd::Add exitRates; + mutable boost::optional> exitRates; }; } // namespace symbolic diff --git a/src/storm/models/symbolic/Model.cpp b/src/storm/models/symbolic/Model.cpp index 1e8f61f8a..1ebf69f48 100644 --- a/src/storm/models/symbolic/Model.cpp +++ b/src/storm/models/symbolic/Model.cpp @@ -13,6 +13,9 @@ #include "storm/models/symbolic/StandardRewardModel.h" +#include "storm-config.h" +#include "storm/adapters/CarlAdapter.h" + namespace storm { namespace models { namespace symbolic { @@ -54,6 +57,11 @@ namespace storm { return *manager; } + template + std::shared_ptr> const& Model::getManagerAsSharedPointer() const { + return manager; + } + template storm::dd::Bdd const& Model::getReachableStates() const { return reachableStates; @@ -66,21 +74,18 @@ namespace storm { template storm::dd::Bdd Model::getStates(std::string const& label) const { - auto labelIt = labelToExpressionMap.find(label); - if (labelIt != labelToExpressionMap.end()) { - return rowExpressionAdapter->translateExpression(labelIt->second).toBdd() && this->reachableStates; - } else { - if (label == "init") { - return initialStates; - } else if (label == "deadlock") { - return deadlockStates; - } - } - STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentException, "The label " << label << " is invalid for the labeling of the model."); + STORM_LOG_THROW(labelToExpressionMap.find(label) != labelToExpressionMap.end(), storm::exceptions::IllegalArgumentException, "The label " << label << " is invalid for the labeling of the model."); + return this->getStates(labelToExpressionMap.at(label)); } template storm::dd::Bdd Model::getStates(storm::expressions::Expression const& expression) const { + if (expression.isTrue()) { + return this->getReachableStates(); + } else if (expression.isFalse()) { + return manager->getBddZero(); + } + STORM_LOG_THROW(rowExpressionAdapter != nullptr, storm::exceptions::InvalidOperationException, "Cannot create BDD for expression without expression adapter."); return rowExpressionAdapter->translateExpression(expression).toBdd() && this->reachableStates; } @@ -105,9 +110,8 @@ namespace storm { } template - std::size_t Model::getSizeInBytes() const { - // FIXME: This assumes a fixed value of 16 bytes per node, which isn't necessarily true. - return sizeof(*this) + 16 * (reachableStates.getNodeCount() + initialStates.getNodeCount() + transitionMatrix.getNodeCount()); + storm::dd::Bdd Model::getQualitativeTransitionMatrix() const { + return this->getTransitionMatrix().notZero(); } template @@ -212,7 +216,6 @@ namespace storm { for (auto const& label : labelToExpressionMap) { out << " * " << label.first << std::endl; } - out << "Size in memory: \t" << (this->getSizeInBytes())/1024 << " kbytes" << std::endl; out << "-------------------------------------------------------------- " << std::endl; } @@ -252,7 +255,9 @@ namespace storm { // Explicitly instantiate the template class. template class Model; template class Model; - +#ifdef STORM_HAVE_CARL + template class Model; +#endif } // namespace symbolic } // namespace models } // namespace storm diff --git a/src/storm/models/symbolic/Model.h b/src/storm/models/symbolic/Model.h index 138a97ecf..14c4edbc5 100644 --- a/src/storm/models/symbolic/Model.h +++ b/src/storm/models/symbolic/Model.h @@ -109,6 +109,13 @@ namespace storm { * @return The manager responsible for the DDs that represent this model. */ storm::dd::DdManager& getManager(); + + /*! + * Retrieves the manager responsible for the DDs that represent this model. + * + * @return The manager responsible for the DDs that represent this model. + */ + std::shared_ptr> const& getManagerAsSharedPointer() const; /*! * Retrieves the reachable states of the model. @@ -130,15 +137,15 @@ namespace storm { * @param label The label for which to get the labeled states. * @return The set of states labeled with the requested label in the form of a bit vector. */ - storm::dd::Bdd getStates(std::string const& label) const; + virtual storm::dd::Bdd getStates(std::string const& label) const; /*! * Returns the set of states labeled satisfying the given expression (that must be of boolean type). * * @param expression The expression that needs to hold in the states. - * @return The set of states labeled satisfying the given expression. + * @return The set of states satisfying the given expression. */ - storm::dd::Bdd getStates(storm::expressions::Expression const& expression) const; + virtual storm::dd::Bdd getStates(storm::expressions::Expression const& expression) const; /*! * Retrieves whether the given label is a valid label in this model. @@ -146,7 +153,7 @@ namespace storm { * @param label The label to be checked for validity. * @return True if the given label is valid in this model. */ - bool hasLabel(std::string const& label) const; + virtual bool hasLabel(std::string const& label) const; /*! * Retrieves the matrix representing the transitions of the model. @@ -161,6 +168,14 @@ namespace storm { * @return A matrix representing the transitions of the model. */ storm::dd::Add& getTransitionMatrix(); + + /*! + * Retrieves the matrix qualitatively (i.e. without probabilities) representing the transitions of the + * model. + * + * @return A matrix representing the qualitative transitions of the model. + */ + storm::dd::Bdd getQualitativeTransitionMatrix() const; /*! * Retrieves the meta variables used to encode the rows of the transition matrix and the vector indices. @@ -239,8 +254,6 @@ namespace storm { */ uint_fast64_t getNumberOfRewardModels() const; - virtual std::size_t getSizeInBytes() const override; - virtual void printModelInformationToStream(std::ostream& out) const override; virtual bool isSymbolicModel() const override; diff --git a/src/storm/models/symbolic/NondeterministicModel.cpp b/src/storm/models/symbolic/NondeterministicModel.cpp index f85e9290c..dc6ffc07c 100644 --- a/src/storm/models/symbolic/NondeterministicModel.cpp +++ b/src/storm/models/symbolic/NondeterministicModel.cpp @@ -6,6 +6,9 @@ #include "storm/models/symbolic/StandardRewardModel.h" +#include "storm-config.h" +#include "storm/adapters/CarlAdapter.h" + namespace storm { namespace models { namespace symbolic { @@ -25,11 +28,10 @@ namespace storm { std::set const& nondeterminismVariables, std::map labelToExpressionMap, std::unordered_map const& rewardModels) - : Model(modelType, manager, reachableStates, initialStates, deadlockStates, transitionMatrix, rowVariables, rowExpressionAdapter, columnVariables, columnExpressionAdapter, rowColumnMetaVariablePairs, labelToExpressionMap, rewardModels), nondeterminismVariables(nondeterminismVariables) { + : Model(modelType, manager, reachableStates, initialStates, deadlockStates, transitionMatrix, rowVariables, rowExpressionAdapter, columnVariables, columnExpressionAdapter, rowColumnMetaVariablePairs, labelToExpressionMap, rewardModels), nondeterminismVariables(nondeterminismVariables) { // Prepare the mask of illegal nondeterministic choices. - illegalMask = transitionMatrix.notZero().existsAbstract(this->getColumnVariables()); - illegalMask = !illegalMask && reachableStates; + illegalMask = !(transitionMatrix.notZero().existsAbstract(this->getColumnVariables())) && reachableStates; } template @@ -51,6 +53,12 @@ namespace storm { return illegalMask; } + template + storm::dd::Bdd NondeterministicModel::getIllegalSuccessorMask() const { + storm::dd::Bdd transitionMatrixBdd = this->getTransitionMatrix().notZero(); + return !transitionMatrixBdd && transitionMatrixBdd.existsAbstract(this->getColumnVariables()); + } + template void NondeterministicModel::printModelInformationToStream(std::ostream& out) const { this->printModelInformationHeaderToStream(out); @@ -64,14 +72,16 @@ namespace storm { for (auto const& metaVariable : this->getNondeterminismVariables()) { nondeterminismVariableCount += this->getManager().getMetaVariable(metaVariable).getNumberOfDdVariables(); } - Model::printDdVariableInformationToStream(out); + Model::printDdVariableInformationToStream(out); out << ", nondeterminism: " << this->getNondeterminismVariables().size() << " meta variables (" << nondeterminismVariableCount << " DD variables)"; } // Explicitly instantiate the template class. template class NondeterministicModel; template class NondeterministicModel; - +#ifdef STORM_HAVE_CARL + template class NondeterministicModel; +#endif } // namespace symbolic } // namespace models } // namespace storm diff --git a/src/storm/models/symbolic/NondeterministicModel.h b/src/storm/models/symbolic/NondeterministicModel.h index 7a371e76e..cec5b0cb8 100644 --- a/src/storm/models/symbolic/NondeterministicModel.h +++ b/src/storm/models/symbolic/NondeterministicModel.h @@ -80,19 +80,27 @@ namespace storm { */ storm::dd::Bdd const& getIllegalMask() const; + /*! + * Retrieves a BDD characterizing the illegal successors for each choice. + * + * @return A BDD characterizing the illegal successors for each choice. + */ + storm::dd::Bdd getIllegalSuccessorMask() const; + virtual void printModelInformationToStream(std::ostream& out) const override; protected: virtual void printDdVariableInformationToStream(std::ostream& out) const override; + + // A mask that characterizes all illegal nondeterministic choices. + storm::dd::Bdd illegalMask; private: // The meta variables encoding the nondeterminism in the model. std::set nondeterminismVariables; - // A mask that characterizes all legal nondeterministic choices. - storm::dd::Bdd illegalMask; }; } // namespace symbolic diff --git a/src/storm/models/symbolic/StandardRewardModel.cpp b/src/storm/models/symbolic/StandardRewardModel.cpp index e42fc4b70..0a3e37e79 100644 --- a/src/storm/models/symbolic/StandardRewardModel.cpp +++ b/src/storm/models/symbolic/StandardRewardModel.cpp @@ -113,7 +113,7 @@ namespace storm { } template - storm::dd::Add StandardRewardModel::getTotalRewardVector(storm::dd::Add const& transitionMatrix, std::set const& columnVariables, storm::dd::Add const& weights) const { + storm::dd::Add StandardRewardModel::getTotalRewardVector(storm::dd::Add const& transitionMatrix, std::set const& columnVariables, storm::dd::Add const& weights, bool scaleTransAndActions) const { storm::dd::Add result = transitionMatrix.getDdManager().template getAddZero(); if (this->hasStateRewards()) { result += optionalStateRewardVector.get(); @@ -122,7 +122,11 @@ namespace storm { result += optionalStateActionRewardVector.get() * weights; } if (this->hasTransitionRewards()) { - result += (transitionMatrix * this->getTransitionRewardMatrix()).sumAbstract(columnVariables); + if (scaleTransAndActions) { + result += weights * (transitionMatrix * this->getTransitionRewardMatrix()).sumAbstract(columnVariables); + } else { + result += (transitionMatrix * this->getTransitionRewardMatrix()).sumAbstract(columnVariables); + } } return result; } diff --git a/src/storm/models/symbolic/StandardRewardModel.h b/src/storm/models/symbolic/StandardRewardModel.h index d44a96868..a4e9fb573 100644 --- a/src/storm/models/symbolic/StandardRewardModel.h +++ b/src/storm/models/symbolic/StandardRewardModel.h @@ -167,10 +167,12 @@ namespace storm { * * @param transitionMatrix The matrix that is used to weight the values of the transition reward matrix. * @param columnVariables The column variables of the model. - * @param weights The weights used to scale the state-action reward vector. + * @param weights The weights used to scale the transition rewards and/or state-action rewards. + * @param scaleTransAndActions If true both transition rewards and state-action rewards are scaled by the + * weights. Otherwise, only the state-action rewards are scaled. * @return The full state-action reward vector. */ - storm::dd::Add getTotalRewardVector(storm::dd::Add const& transitionMatrix, std::set const& columnVariables, storm::dd::Add const& weights) const; + storm::dd::Add getTotalRewardVector(storm::dd::Add const& transitionMatrix, std::set const& columnVariables, storm::dd::Add const& weights, bool scaleTransAndActions) const; /*! * Multiplies all components of the reward model with the given DD. diff --git a/src/storm/models/symbolic/StochasticTwoPlayerGame.cpp b/src/storm/models/symbolic/StochasticTwoPlayerGame.cpp index 9353c114f..fdff99c36 100644 --- a/src/storm/models/symbolic/StochasticTwoPlayerGame.cpp +++ b/src/storm/models/symbolic/StochasticTwoPlayerGame.cpp @@ -6,6 +6,9 @@ #include "storm/models/symbolic/StandardRewardModel.h" +#include "storm-config.h" +#include "storm/adapters/CarlAdapter.h" + namespace storm { namespace models { namespace symbolic { @@ -26,8 +29,26 @@ namespace storm { std::set const& nondeterminismVariables, std::map labelToExpressionMap, std::unordered_map const& rewardModels) - : NondeterministicModel(storm::models::ModelType::S2pg, manager, reachableStates, initialStates, deadlockStates, transitionMatrix, rowVariables, rowExpressionAdapter, columnVariables, columnExpressionAdapter, rowColumnMetaVariablePairs, nondeterminismVariables, labelToExpressionMap, rewardModels), player1Variables(player1Variables), player2Variables(player2Variables) { - // Intentionally left empty. + : NondeterministicModel(storm::models::ModelType::S2pg, manager, reachableStates, initialStates, deadlockStates, transitionMatrix, rowVariables, rowExpressionAdapter, columnVariables, columnExpressionAdapter, rowColumnMetaVariablePairs, nondeterminismVariables, labelToExpressionMap, rewardModels), player1Variables(player1Variables), player2Variables(player2Variables) { + + // Compute legal player 1 mask. + illegalPlayer1Mask = transitionMatrix.notZero().existsAbstract(this->getColumnVariables()).existsAbstract(this->getPlayer2Variables()); + + // Correct the mask for player 2. This is necessary, because it is not yet restricted to the legal choices of player 1. + illegalPlayer2Mask = this->getIllegalMask() && illegalPlayer1Mask; + + // Then set the illegal mask for player 1 correctly. + illegalPlayer1Mask = !illegalPlayer1Mask && reachableStates; + } + + template + storm::dd::Bdd StochasticTwoPlayerGame::getIllegalPlayer1Mask() const { + return illegalPlayer1Mask; + } + + template + storm::dd::Bdd StochasticTwoPlayerGame::getIllegalPlayer2Mask() const { + return illegalPlayer2Mask; } template @@ -41,8 +62,11 @@ namespace storm { } // Explicitly instantiate the template class. - template class StochasticTwoPlayerGame; - template class StochasticTwoPlayerGame; + template class StochasticTwoPlayerGame; + template class StochasticTwoPlayerGame; +#ifdef STORM_HAVE_CARL + template class StochasticTwoPlayerGame; +#endif } // namespace symbolic } // namespace models diff --git a/src/storm/models/symbolic/StochasticTwoPlayerGame.h b/src/storm/models/symbolic/StochasticTwoPlayerGame.h index 22d2da76e..15383b056 100644 --- a/src/storm/models/symbolic/StochasticTwoPlayerGame.h +++ b/src/storm/models/symbolic/StochasticTwoPlayerGame.h @@ -75,7 +75,27 @@ namespace storm { */ std::set const& getPlayer2Variables() const; + /*! + * Retrieves a BDD characterizing all illegal player 1 choice encodings in the model. + * + * @return A BDD characterizing all illegal player 1 choice encodings in the model. + */ + storm::dd::Bdd getIllegalPlayer1Mask() const; + + /*! + * Retrieves a BDD characterizing all illegal player 2 choice encodings in the model. + * + * @return A BDD characterizing all illegal player 2 choice encodings in the model. + */ + storm::dd::Bdd getIllegalPlayer2Mask() const; + private: + // A mask that characterizes all illegal player 1 choices. + storm::dd::Bdd illegalPlayer1Mask; + + // A mask that characterizes all illegal player 2 choices. + storm::dd::Bdd illegalPlayer2Mask; + // The meta variables used to encode the nondeterministic choices of player 1. std::set player1Variables; diff --git a/src/storm/parser/DeterministicSparseTransitionParser.cpp b/src/storm/parser/DeterministicSparseTransitionParser.cpp index 984f3cbc2..7b53415cb 100644 --- a/src/storm/parser/DeterministicSparseTransitionParser.cpp +++ b/src/storm/parser/DeterministicSparseTransitionParser.cpp @@ -54,7 +54,7 @@ namespace storm { bool insertDiagonalEntriesIfMissing = !isRewardFile; DeterministicSparseTransitionParser::FirstPassResult firstPass = DeterministicSparseTransitionParser::firstPass(file.getData(), insertDiagonalEntriesIfMissing); - STORM_LOG_INFO("First pass on " << filename << " shows " << firstPass.numberOfNonzeroEntries << " NonZeros."); + STORM_LOG_TRACE("First pass on " << filename << " shows " << firstPass.numberOfNonzeroEntries << " non-zeros."); // If first pass returned zero, the file format was wrong. if (firstPass.numberOfNonzeroEntries == 0) { diff --git a/src/storm/parser/ExpressionCreator.cpp b/src/storm/parser/ExpressionCreator.cpp index 4053a44a9..6266206ef 100644 --- a/src/storm/parser/ExpressionCreator.cpp +++ b/src/storm/parser/ExpressionCreator.cpp @@ -166,7 +166,7 @@ namespace storm { } } - storm::expressions::Expression ExpressionCreator::createIntegerLiteralExpression(int value, bool& pass) const { + storm::expressions::Expression ExpressionCreator::createIntegerLiteralExpression(int value, bool&) const { if (this->createExpressions) { return manager.integer(value); } else { @@ -175,7 +175,7 @@ namespace storm { } - storm::expressions::Expression ExpressionCreator::createBooleanLiteralExpression(bool value, bool& pass) const { + storm::expressions::Expression ExpressionCreator::createBooleanLiteralExpression(bool value, bool&) const { if (this->createExpressions) { return manager.boolean(value); } else { @@ -213,7 +213,7 @@ namespace storm { return manager.boolean(false); } - storm::expressions::Expression ExpressionCreator::getIdentifierExpression(std::string const& identifier, bool allowBacktracking, bool& pass) const { + storm::expressions::Expression ExpressionCreator::getIdentifierExpression(std::string const& identifier, bool& pass) const { if (this->createExpressions) { STORM_LOG_THROW(this->identifiers != nullptr, storm::exceptions::WrongFormatException, "Unable to substitute identifier expressions without given mapping."); storm::expressions::Expression const* expression = this->identifiers->find(identifier); @@ -228,7 +228,6 @@ namespace storm { } void ExpressionCreator::setIdentifierMapping(qi::symbols const* identifiers_) { - if (identifiers_ != nullptr) { createExpressions = true; identifiers = identifiers_; diff --git a/src/storm/parser/ExpressionCreator.h b/src/storm/parser/ExpressionCreator.h index fcc3dcd07..06b5f5a60 100644 --- a/src/storm/parser/ExpressionCreator.h +++ b/src/storm/parser/ExpressionCreator.h @@ -74,7 +74,7 @@ namespace storm { storm::expressions::Expression createBooleanLiteralExpression(bool value, bool& pass) const; storm::expressions::Expression createMinimumMaximumExpression(storm::expressions::Expression const& e1, storm::expressions::OperatorType const& operatorType, storm::expressions::Expression const& e2, bool& pass) const; storm::expressions::Expression createFloorCeilExpression(storm::expressions::OperatorType const& operatorType, storm::expressions::Expression const& e1, bool& pass) const; - storm::expressions::Expression getIdentifierExpression(std::string const& identifier, bool allowBacktracking, bool& pass) const; + storm::expressions::Expression getIdentifierExpression(std::string const& identifier, bool& pass) const; private: diff --git a/src/storm/parser/ExpressionParser.cpp b/src/storm/parser/ExpressionParser.cpp index 0bf75df0b..cd3ccd595 100644 --- a/src/storm/parser/ExpressionParser.cpp +++ b/src/storm/parser/ExpressionParser.cpp @@ -64,7 +64,7 @@ namespace storm { } prefixPowerExpression.name("pow expression"); - identifierExpression = identifier[qi::_val = phoenix::bind(&ExpressionCreator::getIdentifierExpression, phoenix::ref(*expressionCreator), qi::_1, allowBacktracking, qi::_pass)]; + identifierExpression = identifier[qi::_val = phoenix::bind(&ExpressionCreator::getIdentifierExpression, phoenix::ref(*expressionCreator), qi::_1, qi::_pass)]; identifierExpression.name("identifier expression"); literalExpression = qi::lit("true")[qi::_val = phoenix::bind(&ExpressionCreator::createBooleanLiteralExpression, phoenix::ref(*expressionCreator), true, qi::_pass)] diff --git a/src/storm/parser/FormulaParser.cpp b/src/storm/parser/FormulaParser.cpp index 7919d0878..6bb1687dc 100644 --- a/src/storm/parser/FormulaParser.cpp +++ b/src/storm/parser/FormulaParser.cpp @@ -7,6 +7,8 @@ #include "storm/storage/prism/Program.h" #include "storm/storage/jani/Model.h" +#include "storm/logic/Formulas.h" + // If the parser fails due to ill-formed data, this exception is thrown. #include "storm/exceptions/WrongFormatException.h" @@ -17,17 +19,27 @@ namespace storm { namespace parser { - FormulaParser::FormulaParser() : manager(new storm::expressions::ExpressionManager()), grammar(new FormulaParserGrammar(manager)) { // Intentionally left empty. } - FormulaParser::FormulaParser(std::shared_ptr const& manager) : manager(manager), grammar(new FormulaParserGrammar(manager)) { // Intentionally left empty. } - - FormulaParser::FormulaParser(storm::prism::Program const& program) : manager(program.getManager().getSharedPointer()), grammar(new FormulaParserGrammar(manager)) { + + FormulaParser::FormulaParser(std::shared_ptr const& manager) : manager(manager), grammar(new FormulaParserGrammar(manager)) { + // Intentionally left empty. + } + + FormulaParser::FormulaParser(storm::prism::Program const& program) : manager(program.getManager().getSharedPointer()), grammar(new FormulaParserGrammar(program.getManager().getSharedPointer())) { + this->addFormulasAsIdentifiers(program); + } + + FormulaParser::FormulaParser(storm::prism::Program& program) : manager(program.getManager().getSharedPointer()), grammar(new FormulaParserGrammar(program.getManager().getSharedPointer())) { + this->addFormulasAsIdentifiers(program); + } + + void FormulaParser::addFormulasAsIdentifiers(storm::prism::Program const& program) { // Make the formulas of the program available to the parser. for (auto const& formula : program.getFormulas()) { this->addIdentifierExpression(formula.getName(), formula.getExpression()); @@ -46,22 +58,22 @@ namespace storm { } std::shared_ptr FormulaParser::parseSingleFormulaFromString(std::string const& formulaString) const { - std::vector> formulas = parseFromString(formulaString); - STORM_LOG_THROW(formulas.size() == 1, storm::exceptions::WrongFormatException, "Expected exactly one formula, but found " << formulas.size() << " instead."); - return formulas.front(); + std::vector property = parseFromString(formulaString); + STORM_LOG_THROW(property.size() == 1, storm::exceptions::WrongFormatException, "Expected exactly one formula, but found " << property.size() << " instead."); + return property.front().getRawFormula(); } - std::vector> FormulaParser::parseFromFile(std::string const& filename) const { + std::vector FormulaParser::parseFromFile(std::string const& filename) const { // Open file and initialize result. std::ifstream inputFileStream(filename, std::ios::in); STORM_LOG_THROW(inputFileStream.good(), storm::exceptions::WrongFormatException, "Unable to read from file '" << filename << "'."); - std::vector> formulas; + std::vector properties; // Now try to parse the contents of the file. try { std::string fileContent((std::istreambuf_iterator(inputFileStream)), (std::istreambuf_iterator())); - formulas = parseFromString(fileContent); + properties = parseFromString(fileContent); } catch(std::exception& e) { // In case of an exception properly close the file before passing exception. inputFileStream.close(); @@ -70,16 +82,16 @@ namespace storm { // Close the stream in case everything went smoothly and return result. inputFileStream.close(); - return formulas; + return properties; } - std::vector> FormulaParser::parseFromString(std::string const& formulaString) const { + std::vector FormulaParser::parseFromString(std::string const& formulaString) const { PositionIteratorType first(formulaString.begin()); PositionIteratorType iter = first; PositionIteratorType last(formulaString.end()); // Create empty result; - std::vector> result; + std::vector result; // Create grammar. try { diff --git a/src/storm/parser/FormulaParser.h b/src/storm/parser/FormulaParser.h index 4db23b202..d9c06fa92 100644 --- a/src/storm/parser/FormulaParser.h +++ b/src/storm/parser/FormulaParser.h @@ -5,7 +5,7 @@ #include "storm/parser/SpiritParserDefinitions.h" #include "storm/parser/ExpressionParser.h" -#include "storm/logic/Formulas.h" +#include "storm/storage/jani/Property.h" #include "storm/storage/expressions/Expression.h" #include "storm/utility/macros.h" @@ -14,6 +14,10 @@ namespace storm { class Program; } + namespace logic { + class Formula; + } + namespace parser { // Forward-declare grammar. @@ -23,7 +27,9 @@ namespace storm { public: FormulaParser(); explicit FormulaParser(std::shared_ptr const& manager); + explicit FormulaParser(std::shared_ptr const& manager); explicit FormulaParser(storm::prism::Program const& program); + explicit FormulaParser(storm::prism::Program& program); FormulaParser(FormulaParser const& other); FormulaParser& operator=(FormulaParser const& other); @@ -37,20 +43,20 @@ namespace storm { std::shared_ptr parseSingleFormulaFromString(std::string const& formulaString) const; /*! - * Parses the formula given by the provided string. + * Parses the property given by the provided string. * - * @param formulaString The formula as a string. - * @return The contained formulas. + * @param propertyString The formula as a string. + * @return The contained properties. */ - std::vector> parseFromString(std::string const& formulaString) const; + std::vector parseFromString(std::string const& propertyString) const; /*! - * Parses the formulas in the given file. + * Parses the properties in the given file. * * @param filename The name of the file to parse. - * @return The contained formulas. + * @return The contained properties. */ - std::vector> parseFromFile(std::string const& filename) const; + std::vector parseFromFile(std::string const& filename) const; /*! * Adds an identifier and the expression it is supposed to be replaced with. This can, for example be used @@ -62,6 +68,8 @@ namespace storm { void addIdentifierExpression(std::string const& identifier, storm::expressions::Expression const& expression); private: + void addFormulasAsIdentifiers(storm::prism::Program const& program); + // The manager used to parse expressions. std::shared_ptr manager; diff --git a/src/storm/parser/FormulaParserGrammar.cpp b/src/storm/parser/FormulaParserGrammar.cpp index 2ee1861a7..70c63f22e 100644 --- a/src/storm/parser/FormulaParserGrammar.cpp +++ b/src/storm/parser/FormulaParserGrammar.cpp @@ -4,21 +4,29 @@ namespace storm { namespace parser { - FormulaParserGrammar::FormulaParserGrammar(std::shared_ptr const& manager) : FormulaParserGrammar::base_type(start), manager(manager), expressionParser(*manager, keywords_, true, true) { + FormulaParserGrammar::FormulaParserGrammar(std::shared_ptr const& manager) : FormulaParserGrammar::base_type(start), constManager(manager), manager(nullptr), expressionParser(*manager, keywords_, true, true), propertyCount(0) { + initialize(); + } + + FormulaParserGrammar::FormulaParserGrammar(std::shared_ptr const& manager) : FormulaParserGrammar::base_type(start), constManager(manager), manager(manager), expressionParser(*manager, keywords_, true, true), propertyCount(0) { + initialize(); + } + + void FormulaParserGrammar::initialize() { // Register all variables so we can parse them in the expressions. - for (auto variableTypePair : *manager) { + for (auto variableTypePair : *constManager) { identifiers_.add(variableTypePair.first.getName(), variableTypePair.first); - } + } // Set the identifier mapping to actually generate expressions. expressionParser.setIdentifierMapping(&identifiers_); longRunAverageRewardFormula = (qi::lit("LRA") | qi::lit("S"))[qi::_val = phoenix::bind(&FormulaParserGrammar::createLongRunAverageRewardFormula, phoenix::ref(*this))]; longRunAverageRewardFormula.name("long run average reward formula"); - instantaneousRewardFormula = (qi::lit("I=") >> strict_double)[qi::_val = phoenix::bind(&FormulaParserGrammar::createInstantaneousRewardFormula, phoenix::ref(*this), qi::_1)] | (qi::lit("I=") > qi::uint_)[qi::_val = phoenix::bind(&FormulaParserGrammar::createInstantaneousRewardFormula, phoenix::ref(*this), qi::_1)]; + instantaneousRewardFormula = (qi::lit("I=") > expressionParser)[qi::_val = phoenix::bind(&FormulaParserGrammar::createInstantaneousRewardFormula, phoenix::ref(*this), qi::_1)]; instantaneousRewardFormula.name("instantaneous reward formula"); - cumulativeRewardFormula = (qi::lit("C<=") >> strict_double)[qi::_val = phoenix::bind(&FormulaParserGrammar::createCumulativeRewardFormula, phoenix::ref(*this), qi::_1)] | (qi::lit("C<=") > qi::uint_)[qi::_val = phoenix::bind(&FormulaParserGrammar::createCumulativeRewardFormula, phoenix::ref(*this), qi::_1)]; + cumulativeRewardFormula = ((qi::lit("C<=")[qi::_a = false] | qi::lit("C<")[qi::_a = true]) > expressionParser)[qi::_val = phoenix::bind(&FormulaParserGrammar::createCumulativeRewardFormula, phoenix::ref(*this), qi::_1, qi::_a)]; cumulativeRewardFormula.name("cumulative reward formula"); totalRewardFormula = (qi::lit("C"))[qi::_val = phoenix::bind(&FormulaParserGrammar::createTotalRewardFormula, phoenix::ref(*this))]; @@ -45,7 +53,10 @@ namespace storm { atomicStateFormula = booleanLiteralFormula | labelFormula | expressionFormula | (qi::lit("(") > stateFormula > qi::lit(")")) | operatorFormula; atomicStateFormula.name("atomic state formula"); - notStateFormula = (-unaryBooleanOperator_ >> atomicStateFormula)[qi::_val = phoenix::bind(&FormulaParserGrammar::createUnaryBooleanStateFormula, phoenix::ref(*this), qi::_2, qi::_1)]; + atomicStateFormulaWithoutExpression = booleanLiteralFormula | labelFormula | (qi::lit("(") > stateFormula > qi::lit(")")) | operatorFormula; + atomicStateFormula.name("atomic state formula without expression"); + + notStateFormula = (unaryBooleanOperator_ >> atomicStateFormulaWithoutExpression)[qi::_val = phoenix::bind(&FormulaParserGrammar::createUnaryBooleanStateFormula, phoenix::ref(*this), qi::_2, qi::_1)] | atomicStateFormula[qi::_val = qi::_1]; notStateFormula.name("negation formula"); eventuallyFormula = (qi::lit("F") >> -timeBound >> pathFormulaWithoutUntil(qi::_r1))[qi::_val = phoenix::bind(&FormulaParserGrammar::createEventuallyFormula, phoenix::ref(*this), qi::_1, qi::_r1, qi::_2)]; @@ -66,7 +77,7 @@ namespace storm { conditionalFormula = untilFormula(qi::_r1)[qi::_val = qi::_1] >> *(qi::lit("||") >> untilFormula(storm::logic::FormulaContext::Probability))[qi::_val = phoenix::bind(&FormulaParserGrammar::createConditionalFormula, phoenix::ref(*this), qi::_val, qi::_1, qi::_r1)]; conditionalFormula.name("conditional formula"); - timeBound = (qi::lit("[") > qi::double_ > qi::lit(",") > qi::double_ > qi::lit("]"))[qi::_val = phoenix::construct>(qi::_1, qi::_2)] | (qi::lit("<=") >> strict_double)[qi::_val = phoenix::construct>(0, qi::_1)] | (qi::lit("<=") > qi::uint_)[qi::_val = qi::_1]; + timeBound = (qi::lit("[") > expressionParser > qi::lit(",") > expressionParser > qi::lit("]"))[qi::_val = phoenix::bind(&FormulaParserGrammar::createTimeBoundFromInterval, phoenix::ref(*this), qi::_1, qi::_2)] | ((qi::lit("<=")[qi::_a = true, qi::_b = false] | qi::lit("<")[qi::_a = true, qi::_b = true] | qi::lit(">=")[qi::_a = false, qi::_b = false] | qi::lit(">")[qi::_a = false, qi::_b = true]) >> expressionParser)[qi::_val = phoenix::bind(&FormulaParserGrammar::createTimeBoundFromSingleBound, phoenix::ref(*this), qi::_1, qi::_a, qi::_b)]; timeBound.name("time bound"); pathFormula = conditionalFormula(qi::_r1); @@ -105,35 +116,54 @@ namespace storm { stateFormula = (orStateFormula | multiObjectiveFormula); stateFormula.name("state formula"); - start = qi::eps > (stateFormula % +(qi::char_("\n;"))) >> qi::skip(boost::spirit::ascii::space | qi::lit("//") >> *(qi::char_ - (qi::eol | qi::eoi)))[qi::eps] >> qi::eoi; + identifier %= qi::as_string[qi::raw[qi::lexeme[((qi::alpha | qi::char_('_') | qi::char_('.')) >> *(qi::alnum | qi::char_('_')))]]]; + identifier.name("identifier"); + + formulaName = qi::lit("\"") >> identifier >> qi::lit("\"") >> qi::lit(":"); + formulaName.name("formula name"); + + constantDefinition = (qi::lit("const") > qi::eps[qi::_a = true] > -(qi::lit("int") | qi::lit("double")[qi::_a = false]) >> identifier)[phoenix::bind(&FormulaParserGrammar::addConstant, phoenix::ref(*this), qi::_1, qi::_a)]; + constantDefinition.name("constant definition"); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Woverloaded-shift-op-parentheses" + + filterProperty = (-formulaName >> qi::lit("filter") > qi::lit("(") > filterType_ > qi::lit(",") > stateFormula > -(qi::lit(",") > qi::lit("\"init\"") > qi::lit(")")))[qi::_val = phoenix::bind(&FormulaParserGrammar::createProperty, phoenix::ref(*this), qi::_1, qi::_2, qi::_3)] | (-formulaName >> stateFormula)[qi::_val = phoenix::bind(&FormulaParserGrammar::createPropertyWithDefaultFilterType, phoenix::ref(*this), qi::_1, qi::_2)]; + filterProperty.name("filter property"); + +#pragma clang diagnostic pop + + start = (qi::eps >> filterProperty[phoenix::push_back(qi::_val, qi::_1)] + | qi::eps(phoenix::bind(&FormulaParserGrammar::areConstantDefinitionsAllowed, phoenix::ref(*this))) >> constantDefinition + | qi::eps) + % +(qi::char_("\n;")) >> qi::skip(boost::spirit::ascii::space | qi::lit("//") >> *(qi::char_ - (qi::eol | qi::eoi)))[qi::eps] >> qi::eoi; start.name("start"); - //Enable the following lines to print debug output for most the rules. - /* - debug(start); - debug(stateFormula); - debug(orStateFormula); - debug(andStateFormula); - debug(probabilityOperator); - debug(rewardOperator); - debug(longRunAverageOperator); - debug(timeOperator); - debug(pathFormulaWithoutUntil); - debug(pathFormula); - // debug(conditionalFormula); - debug(nextFormula); - debug(globallyFormula); - // debug(eventuallyFormula); - debug(atomicStateFormula); - debug(booleanLiteralFormula); - debug(labelFormula); - debug(expressionFormula); - debug(rewardPathFormula); - debug(cumulativeRewardFormula); - debug(totalRewardFormula); - debug(instantaneousRewardFormula); - debug(multiObjectiveFormula); - */ + // Enable the following lines to print debug output for most the rules. +// debug(start); +// debug(constantDefinition); +// debug(stateFormula); +// debug(orStateFormula); +// debug(andStateFormula); +// debug(probabilityOperator); +// debug(rewardOperator); +// debug(longRunAverageOperator); +// debug(timeOperator); +// debug(pathFormulaWithoutUntil); +// debug(pathFormula); +// debug(conditionalFormula); +// debug(nextFormula); +// debug(globallyFormula); +// debug(eventuallyFormula); +// debug(atomicStateFormula); +// debug(booleanLiteralFormula); +// debug(labelFormula); +// debug(expressionFormula); +// debug(rewardPathFormula); +// debug(cumulativeRewardFormula); +// debug(totalRewardFormula); +// debug(instantaneousRewardFormula); +// debug(multiObjectiveFormula); // Enable error reporting. qi::on_error(start, handler(qi::_1, qi::_2, qi::_3, qi::_4)); @@ -167,26 +197,43 @@ namespace storm { this->identifiers_.add(identifier, expression); } - std::shared_ptr FormulaParserGrammar::createInstantaneousRewardFormula(boost::variant const& timeBound) const { - if (timeBound.which() == 0) { - return std::shared_ptr(new storm::logic::InstantaneousRewardFormula(static_cast(boost::get(timeBound)))); + void FormulaParserGrammar::addConstant(std::string const& name, bool integer) { + STORM_LOG_ASSERT(manager, "Mutable expression manager required to define new constants."); + storm::expressions::Variable newVariable; + if (integer) { + newVariable = manager->declareIntegerVariable(name); } else { - double timeBoundAsDouble = boost::get(timeBound); - STORM_LOG_THROW(timeBoundAsDouble >= 0, storm::exceptions::WrongFormatException, "Instantaneous reward property must have non-negative bound."); - return std::shared_ptr(new storm::logic::InstantaneousRewardFormula(timeBoundAsDouble)); + newVariable = manager->declareRationalVariable(name); } + addIdentifierExpression(name, newVariable); + } + + bool FormulaParserGrammar::areConstantDefinitionsAllowed() const { + return static_cast(manager); } - std::shared_ptr FormulaParserGrammar::createCumulativeRewardFormula(boost::variant const& timeBound) const { - if (timeBound.which() == 0) { - return std::shared_ptr(new storm::logic::CumulativeRewardFormula(static_cast(boost::get(timeBound)))); + std::pair, boost::optional> FormulaParserGrammar::createTimeBoundFromInterval(storm::expressions::Expression const& lowerBound, storm::expressions::Expression const& upperBound) const { + storm::logic::TimeBound lower(false, lowerBound); + storm::logic::TimeBound upper(false, upperBound); + return std::make_pair(lower, upper); + } + + std::pair, boost::optional> FormulaParserGrammar::createTimeBoundFromSingleBound(storm::expressions::Expression const& bound, bool upperBound, bool strict) const { + if (upperBound) { + return std::make_pair(boost::none, storm::logic::TimeBound(strict, bound)); } else { - double timeBoundAsDouble = boost::get(timeBound); - STORM_LOG_THROW(timeBoundAsDouble >= 0, storm::exceptions::WrongFormatException, "Cumulative reward property must have non-negative bound."); - return std::shared_ptr(new storm::logic::CumulativeRewardFormula(static_cast(timeBoundAsDouble))); + return std::make_pair(storm::logic::TimeBound(strict, bound), boost::none); } } + std::shared_ptr FormulaParserGrammar::createInstantaneousRewardFormula(storm::expressions::Expression const& timeBound) const { + return std::shared_ptr(new storm::logic::InstantaneousRewardFormula(timeBound)); + } + + std::shared_ptr FormulaParserGrammar::createCumulativeRewardFormula(storm::expressions::Expression const& timeBound, bool strict) const { + return std::shared_ptr(new storm::logic::CumulativeRewardFormula(storm::logic::TimeBound(strict, timeBound))); + } + std::shared_ptr FormulaParserGrammar::createTotalRewardFormula() const { return std::shared_ptr(new storm::logic::TotalRewardFormula()); } @@ -208,14 +255,9 @@ namespace storm { return std::shared_ptr(new storm::logic::AtomicLabelFormula(label)); } - std::shared_ptr FormulaParserGrammar::createEventuallyFormula(boost::optional, uint_fast64_t>> const& timeBound, storm::logic::FormulaContext context, std::shared_ptr const& subformula) const { + std::shared_ptr FormulaParserGrammar::createEventuallyFormula(boost::optional, boost::optional>> const& timeBound, storm::logic::FormulaContext context, std::shared_ptr const& subformula) const { if (timeBound) { - if (timeBound.get().which() == 0) { - std::pair const& bounds = boost::get>(timeBound.get()); - return std::shared_ptr(new storm::logic::BoundedUntilFormula(createBooleanLiteralFormula(true), subformula, bounds.first, bounds.second)); - } else { - return std::shared_ptr(new storm::logic::BoundedUntilFormula(createBooleanLiteralFormula(true), subformula, static_cast(boost::get(timeBound.get())))); - } + return std::shared_ptr(new storm::logic::BoundedUntilFormula(createBooleanLiteralFormula(true), subformula, timeBound.get().first, timeBound.get().second, storm::logic::TimeBoundType::Time)); } else { return std::shared_ptr(new storm::logic::EventuallyFormula(subformula, context)); } @@ -229,14 +271,9 @@ namespace storm { return std::shared_ptr(new storm::logic::NextFormula(subformula)); } - std::shared_ptr FormulaParserGrammar::createUntilFormula(std::shared_ptr const& leftSubformula, boost::optional, uint_fast64_t>> const& timeBound, std::shared_ptr const& rightSubformula) { + std::shared_ptr FormulaParserGrammar::createUntilFormula(std::shared_ptr const& leftSubformula, boost::optional, boost::optional>> const& timeBound, std::shared_ptr const& rightSubformula) { if (timeBound) { - if (timeBound.get().which() == 0) { - std::pair const& bounds = boost::get>(timeBound.get()); - return std::shared_ptr(new storm::logic::BoundedUntilFormula(leftSubformula, rightSubformula, bounds.first, bounds.second)); - } else { - return std::shared_ptr(new storm::logic::BoundedUntilFormula(leftSubformula, rightSubformula, static_cast(boost::get(timeBound.get())))); - } + return std::shared_ptr(new storm::logic::BoundedUntilFormula(leftSubformula, rightSubformula, timeBound.get().first, timeBound.get().second, storm::logic::TimeBoundType::Time)); } else { return std::shared_ptr(new storm::logic::UntilFormula(leftSubformula, rightSubformula)); } @@ -248,7 +285,7 @@ namespace storm { storm::logic::OperatorInformation FormulaParserGrammar::createOperatorInformation(boost::optional const& optimizationDirection, boost::optional const& comparisonType, boost::optional const& threshold) const { if (comparisonType && threshold) { - storm::expressions::ExpressionEvaluator evaluator(*manager); + storm::expressions::ExpressionEvaluator evaluator(*constManager); return storm::logic::OperatorInformation(optimizationDirection, storm::logic::Bound(comparisonType.get(), evaluator.asRational(threshold.get()))); } else { return storm::logic::OperatorInformation(optimizationDirection, boost::none); @@ -294,5 +331,26 @@ namespace storm { std::shared_ptr FormulaParserGrammar::createMultiObjectiveFormula(std::vector> const& subformulas) { return std::shared_ptr(new storm::logic::MultiObjectiveFormula(subformulas)); } + + storm::jani::Property FormulaParserGrammar::createProperty(boost::optional const& propertyName, storm::modelchecker::FilterType const& filterType, std::shared_ptr const& formula) { + storm::jani::FilterExpression filterExpression(formula, filterType); + + ++propertyCount; + if (propertyName) { + return storm::jani::Property(propertyName.get(), filterExpression); + } else { + return storm::jani::Property(std::to_string(propertyCount -1 ), filterExpression); + } + } + + storm::jani::Property FormulaParserGrammar::createPropertyWithDefaultFilterType(boost::optional const& propertyName, std::shared_ptr const& formula) { + ++propertyCount; + if (propertyName) { + return storm::jani::Property(propertyName.get(), formula); + } else { + return storm::jani::Property(std::to_string(propertyCount), formula); + } + } + } } diff --git a/src/storm/parser/FormulaParserGrammar.h b/src/storm/parser/FormulaParserGrammar.h index 21989d97d..79b272246 100644 --- a/src/storm/parser/FormulaParserGrammar.h +++ b/src/storm/parser/FormulaParserGrammar.h @@ -5,9 +5,12 @@ #include "storm/parser/SpiritErrorHandler.h" #include "storm/exceptions/WrongFormatException.h" +#include "storm/storage/jani/Property.h" #include "storm/logic/Formulas.h" #include "storm/parser/ExpressionParser.h" +#include "storm/modelchecker/results/FilterType.h" + #include "storm/storage/expressions/ExpressionEvaluator.h" namespace storm { @@ -17,9 +20,10 @@ namespace storm { namespace parser { - class FormulaParserGrammar : public qi::grammar>(), Skipper> { + class FormulaParserGrammar : public qi::grammar(), Skipper> { public: FormulaParserGrammar(std::shared_ptr const& manager); + FormulaParserGrammar(std::shared_ptr const& manager); FormulaParserGrammar(FormulaParserGrammar const& other) = default; FormulaParserGrammar& operator=(FormulaParserGrammar const& other) = default; @@ -34,6 +38,8 @@ namespace storm { void addIdentifierExpression(std::string const& identifier, storm::expressions::Expression const& expression); private: + void initialize(); + struct keywordsStruct : qi::symbols { keywordsStruct() { add @@ -107,8 +113,28 @@ namespace storm { // A parser used for recognizing the reward measure types. rewardMeasureTypeStruct rewardMeasureType_; + struct filterTypeStruct : qi::symbols { + filterTypeStruct() { + add + ("min", storm::modelchecker::FilterType::MIN) + ("max", storm::modelchecker::FilterType::MAX) + ("sum", storm::modelchecker::FilterType::SUM) + ("avg", storm::modelchecker::FilterType::AVG) + ("count", storm::modelchecker::FilterType::COUNT) + ("forall", storm::modelchecker::FilterType::FORALL) + ("exists", storm::modelchecker::FilterType::EXISTS) + ("argmin", storm::modelchecker::FilterType::ARGMIN) + ("argmax", storm::modelchecker::FilterType::ARGMAX) + ("values", storm::modelchecker::FilterType::VALUES); + } + }; + + // A parser used for recognizing the filter type. + filterTypeStruct filterType_; + // The manager used to parse expressions. - std::shared_ptr manager; + std::shared_ptr constManager; + std::shared_ptr manager; // Parser and manager used for recognizing expressions. storm::parser::ExpressionParser expressionParser; @@ -117,7 +143,11 @@ namespace storm { // they are to be replaced with. qi::symbols identifiers_; - qi::rule>(), Skipper> start; + qi::rule(), Skipper> start; + + qi::rule, Skipper> constantDefinition; + qi::rule identifier; + qi::rule formulaName; qi::rule, boost::optional, boost::optional>, Skipper> operatorInformation; qi::rule rewardMeasureType; @@ -126,12 +156,14 @@ namespace storm { qi::rule(), Skipper> timeOperator; qi::rule(), Skipper> longRunAverageOperator; + qi::rule filterProperty; qi::rule(), Skipper> simpleFormula; qi::rule(), Skipper> stateFormula; qi::rule(storm::logic::FormulaContext), Skipper> pathFormula; qi::rule(storm::logic::FormulaContext), Skipper> pathFormulaWithoutUntil; qi::rule(), Skipper> simplePathFormula; qi::rule(), Skipper> atomicStateFormula; + qi::rule(), Skipper> atomicStateFormulaWithoutExpression; qi::rule(), Skipper> operatorFormula; qi::rule label; qi::rule rewardModelName; @@ -148,10 +180,11 @@ namespace storm { qi::rule(storm::logic::FormulaContext), Skipper> nextFormula; qi::rule(storm::logic::FormulaContext), Skipper> globallyFormula; qi::rule(storm::logic::FormulaContext), Skipper> untilFormula; - qi::rule, uint_fast64_t>(), Skipper> timeBound; + + qi::rule, boost::optional>(), qi::locals, Skipper> timeBound; qi::rule(), Skipper> rewardPathFormula; - qi::rule(), Skipper> cumulativeRewardFormula; + qi::rule(), qi::locals, Skipper> cumulativeRewardFormula; qi::rule(), Skipper> totalRewardFormula; qi::rule(), Skipper> instantaneousRewardFormula; qi::rule(), Skipper> longRunAverageRewardFormula; @@ -160,19 +193,26 @@ namespace storm { // Parser that is used to recognize doubles only (as opposed to Spirit's double_ parser). boost::spirit::qi::real_parser> strict_double; + + bool areConstantDefinitionsAllowed() const; + void addConstant(std::string const& name, bool integer); + void addProperty(std::vector& properties, boost::optional const& name, std::shared_ptr const& formula); + + std::pair, boost::optional> createTimeBoundFromInterval(storm::expressions::Expression const& lowerBound, storm::expressions::Expression const& upperBound) const; + std::pair, boost::optional> createTimeBoundFromSingleBound(storm::expressions::Expression const& bound, bool upperBound, bool strict) const; // Methods that actually create the expression objects. - std::shared_ptr createInstantaneousRewardFormula(boost::variant const& timeBound) const; - std::shared_ptr createCumulativeRewardFormula(boost::variant const& timeBound) const; + std::shared_ptr createInstantaneousRewardFormula(storm::expressions::Expression const& timeBound) const; + std::shared_ptr createCumulativeRewardFormula(storm::expressions::Expression const& timeBound, bool strict) const; std::shared_ptr createTotalRewardFormula() const; std::shared_ptr createLongRunAverageRewardFormula() const; std::shared_ptr createAtomicExpressionFormula(storm::expressions::Expression const& expression) const; std::shared_ptr createBooleanLiteralFormula(bool literal) const; std::shared_ptr createAtomicLabelFormula(std::string const& label) const; - std::shared_ptr createEventuallyFormula(boost::optional, uint_fast64_t>> const& timeBound, storm::logic::FormulaContext context, std::shared_ptr const& subformula) const; + std::shared_ptr createEventuallyFormula(boost::optional, boost::optional>> const& timeBound, storm::logic::FormulaContext context, std::shared_ptr const& subformula) const; std::shared_ptr createGloballyFormula(std::shared_ptr const& subformula) const; std::shared_ptr createNextFormula(std::shared_ptr const& subformula) const; - std::shared_ptr createUntilFormula(std::shared_ptr const& leftSubformula, boost::optional, uint_fast64_t>> const& timeBound, std::shared_ptr const& rightSubformula); + std::shared_ptr createUntilFormula(std::shared_ptr const& leftSubformula, boost::optional, boost::optional>> const& timeBound, std::shared_ptr const& rightSubformula); std::shared_ptr createConditionalFormula(std::shared_ptr const& leftSubformula, std::shared_ptr const& rightSubformula, storm::logic::FormulaContext context) const; storm::logic::OperatorInformation createOperatorInformation(boost::optional const& optimizationDirection, boost::optional const& comparisonType, boost::optional const& threshold) const; std::shared_ptr createLongRunAverageOperatorFormula(storm::logic::OperatorInformation const& operatorInformation, std::shared_ptr const& subformula) const; @@ -183,8 +223,13 @@ namespace storm { std::shared_ptr createUnaryBooleanStateFormula(std::shared_ptr const& subformula, boost::optional const& operatorType); std::shared_ptr createMultiObjectiveFormula(std::vector> const& subformulas); + storm::jani::Property createProperty(boost::optional const& propertyName, storm::modelchecker::FilterType const& filterType, std::shared_ptr const& formula); + storm::jani::Property createPropertyWithDefaultFilterType(boost::optional const& propertyName, std::shared_ptr const& formula); + // An error handler function. phoenix::function handler; + + uint64_t propertyCount; }; } diff --git a/src/storm/parser/JaniParser.cpp b/src/storm/parser/JaniParser.cpp index 9836f73d0..efe033d08 100644 --- a/src/storm/parser/JaniParser.cpp +++ b/src/storm/parser/JaniParser.cpp @@ -256,14 +256,14 @@ namespace storm { if(!accTime && !accSteps) { if (rewExpr.isVariable()) { std::string rewardName = rewExpr.getVariables().begin()->getName(); - return std::make_shared(std::make_shared(static_cast(stepInstant)), rewardName, opInfo); + return std::make_shared(std::make_shared(stepInstantExpr, storm::logic::TimeBoundType::Steps), rewardName, opInfo); } else { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Only simple reward expressions are currently supported"); } } else { if (rewExpr.isVariable()) { std::string rewardName = rewExpr.getVariables().begin()->getName(); - return std::make_shared(std::make_shared(static_cast(stepInstant)), rewardName, opInfo); + return std::make_shared(std::make_shared(storm::logic::TimeBound(false, stepInstantExpr), storm::logic::TimeBoundType::Steps), rewardName, opInfo); } else { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Only simple reward expressions are currently supported"); } @@ -276,14 +276,14 @@ namespace storm { if(!accTime && !accSteps) { if (rewExpr.isVariable()) { std::string rewardName = rewExpr.getVariables().begin()->getName(); - return std::make_shared(std::make_shared(timeInstant), rewardName, opInfo); + return std::make_shared(std::make_shared(timeInstantExpr, storm::logic::TimeBoundType::Time), rewardName, opInfo); } else { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Only simple reward expressions are currently supported"); } } else { if (rewExpr.isVariable()) { std::string rewardName = rewExpr.getVariables().begin()->getName(); - return std::make_shared(std::make_shared(timeInstant), rewardName, opInfo); + return std::make_shared(std::make_shared(storm::logic::TimeBound(false, timeInstantExpr), storm::logic::TimeBoundType::Time), rewardName, opInfo); } else { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Only simple reward expressions are currently supported"); } @@ -345,7 +345,7 @@ namespace storm { upperBound--; } STORM_LOG_THROW(upperBound >= 0, storm::exceptions::InvalidJaniException, "Step-bounds cannot be negative"); - return std::make_shared(args[0], args[1], upperBound); + return std::make_shared(args[0], args[1], storm::logic::TimeBound(pi.lowerBoundStrict, pi.lowerBound), storm::logic::TimeBound(pi.upperBoundStrict, pi.upperBound), storm::logic::TimeBoundType::Steps); } else if (propertyStructure.count("time-bounds") > 0) { storm::jani::PropertyInterval pi = parsePropertyInterval(propertyStructure.at("time-bounds")); STORM_LOG_THROW(pi.hasUpperBound(), storm::exceptions::NotSupportedException, "Storm only supports time-bounded until with an upper bound."); @@ -356,7 +356,7 @@ namespace storm { double upperBound = pi.upperBound.evaluateAsDouble(); STORM_LOG_THROW(lowerBound >= 0, storm::exceptions::InvalidJaniException, "(Lower) time-bounds cannot be negative"); STORM_LOG_THROW(upperBound >= 0, storm::exceptions::InvalidJaniException, "(Upper) time-bounds cannot be negative"); - return std::make_shared(args[0], args[1], upperBound); + return std::make_shared(args[0], args[1], storm::logic::TimeBound(pi.lowerBoundStrict, pi.lowerBound), storm::logic::TimeBound(pi.upperBoundStrict, pi.upperBound), storm::logic::TimeBoundType::Time); } else if (propertyStructure.count("reward-bounds") > 0 ) { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Reward bounded properties are not supported by Storm"); @@ -939,6 +939,8 @@ namespace storm { STORM_LOG_THROW(false, storm::exceptions::InvalidJaniException, "No supported operator declaration found for complex expressions as " << expressionStructure.dump() << " in " << scopeDescription << "."); } assert(false); + // Silly warning suppression. + return storm::expressions::Expression(); } @@ -958,7 +960,7 @@ namespace storm { storm::jani::Automaton JaniParser::parseAutomaton(json const &automatonStructure, storm::jani::Model const& parentModel) { STORM_LOG_THROW(automatonStructure.count("name") == 1, storm::exceptions::InvalidJaniException, "Each automaton must have a name"); std::string name = getString(automatonStructure.at("name"), " the name field for automaton"); - storm::jani::Automaton automaton(name); + storm::jani::Automaton automaton(name, expressionManager->declareIntegerVariable("_loc_" + name)); STORM_LOG_THROW(automatonStructure.count("locations") > 0, storm::exceptions::InvalidJaniException, "Automaton '" << name << "' does not have locations."); std::unordered_map locIds; for(auto const& locEntry : automatonStructure.at("locations")) { @@ -1036,8 +1038,11 @@ namespace storm { STORM_LOG_THROW(guardExpr.hasBooleanType(), storm::exceptions::InvalidJaniException, "Guard " << guardExpr << " does not have Boolean type."); } assert(guardExpr.isInitialized()); + + std::shared_ptr templateEdge = automaton.createTemplateEdge(guardExpr); + STORM_LOG_THROW(edgeEntry.count("destinations") == 1, storm::exceptions::InvalidJaniException, "A single list of destinations must be given in edge from '" << sourceLoc << "' in automaton '" << name << "'"); - std::vector edgeDestinations; + std::vector> destinationLocationsAndProbabilities; for(auto const& destEntry : edgeEntry.at("destinations")) { // target location STORM_LOG_THROW(edgeEntry.count("location") == 1, storm::exceptions::InvalidJaniException, "Each destination in edge from '" << sourceLoc << "' in automaton '" << name << "' must have a target location"); @@ -1072,9 +1077,10 @@ namespace storm { assignments.emplace_back(lhs, assignmentExpr); } } - edgeDestinations.emplace_back(locIds.at(targetLoc), probExpr, assignments); + destinationLocationsAndProbabilities.emplace_back(locIds.at(targetLoc), probExpr); + templateEdge->addDestination(storm::jani::TemplateEdgeDestination(assignments)); } - automaton.addEdge(storm::jani::Edge(locIds.at(sourceLoc), parentModel.getActionIndex(action), rateExpr.isInitialized() ? boost::optional(rateExpr) : boost::none, guardExpr, edgeDestinations)); + automaton.addEdge(storm::jani::Edge(locIds.at(sourceLoc), parentModel.getActionIndex(action), rateExpr.isInitialized() ? boost::optional(rateExpr) : boost::none, templateEdge, destinationLocationsAndProbabilities)); } return automaton; diff --git a/src/storm/parser/PrismParser.cpp b/src/storm/parser/PrismParser.cpp index 28432349a..436d27c5d 100644 --- a/src/storm/parser/PrismParser.cpp +++ b/src/storm/parser/PrismParser.cpp @@ -87,25 +87,25 @@ namespace storm { undefinedBooleanConstantDefinition = ((qi::lit("const") >> qi::lit("bool")) > identifier > qi::lit(";"))[qi::_val = phoenix::bind(&PrismParser::createUndefinedBooleanConstant, phoenix::ref(*this), qi::_1)]; undefinedBooleanConstantDefinition.name("undefined boolean constant declaration"); - undefinedIntegerConstantDefinition = ((qi::lit("const") >> qi::lit("int")) > identifier > qi::lit(";"))[qi::_val = phoenix::bind(&PrismParser::createUndefinedIntegerConstant, phoenix::ref(*this), qi::_1)]; + undefinedIntegerConstantDefinition = ((qi::lit("const") >> -qi::lit("int")) >> identifier >> qi::lit(";"))[qi::_val = phoenix::bind(&PrismParser::createUndefinedIntegerConstant, phoenix::ref(*this), qi::_1)]; undefinedIntegerConstantDefinition.name("undefined integer constant declaration"); undefinedDoubleConstantDefinition = ((qi::lit("const") >> qi::lit("double")) > identifier > qi::lit(";"))[qi::_val = phoenix::bind(&PrismParser::createUndefinedDoubleConstant, phoenix::ref(*this), qi::_1)]; undefinedDoubleConstantDefinition.name("undefined double constant definition"); - undefinedConstantDefinition = (undefinedBooleanConstantDefinition | undefinedIntegerConstantDefinition | undefinedDoubleConstantDefinition); + undefinedConstantDefinition = (undefinedBooleanConstantDefinition | undefinedDoubleConstantDefinition | undefinedIntegerConstantDefinition); undefinedConstantDefinition.name("undefined constant definition"); definedBooleanConstantDefinition = ((qi::lit("const") >> qi::lit("bool") >> identifier >> qi::lit("=")) > expression_ > qi::lit(";"))[qi::_val = phoenix::bind(&PrismParser::createDefinedBooleanConstant, phoenix::ref(*this), qi::_1, qi::_2)]; definedBooleanConstantDefinition.name("defined boolean constant declaration"); - definedIntegerConstantDefinition = ((qi::lit("const") >> qi::lit("int") >> identifier >> qi::lit("=")) > expression_ >> qi::lit(";"))[qi::_val = phoenix::bind(&PrismParser::createDefinedIntegerConstant, phoenix::ref(*this), qi::_1, qi::_2)]; + definedIntegerConstantDefinition = ((qi::lit("const") >> -qi::lit("int") >> identifier >> qi::lit("=")) > expression_ >> qi::lit(";"))[qi::_val = phoenix::bind(&PrismParser::createDefinedIntegerConstant, phoenix::ref(*this), qi::_1, qi::_2)]; definedIntegerConstantDefinition.name("defined integer constant declaration"); definedDoubleConstantDefinition = ((qi::lit("const") >> qi::lit("double") >> identifier >> qi::lit("=")) > expression_ > qi::lit(";"))[qi::_val = phoenix::bind(&PrismParser::createDefinedDoubleConstant, phoenix::ref(*this), qi::_1, qi::_2)]; definedDoubleConstantDefinition.name("defined double constant declaration"); - definedConstantDefinition %= (definedBooleanConstantDefinition | definedIntegerConstantDefinition | definedDoubleConstantDefinition); + definedConstantDefinition %= (definedBooleanConstantDefinition | definedDoubleConstantDefinition | definedIntegerConstantDefinition); definedConstantDefinition.name("defined constant definition"); formulaDefinition = (qi::lit("formula") > identifier > qi::lit("=") > expression_ > qi::lit(";"))[qi::_val = phoenix::bind(&PrismParser::createFormula, phoenix::ref(*this), qi::_1, qi::_2)]; @@ -176,7 +176,7 @@ namespace storm { renamingComposition = (atomicComposition >> (qi::lit("{") > (actionRenamingList > qi::lit("}"))))[qi::_val = phoenix::bind(&PrismParser::createRenamingComposition, phoenix::ref(*this), qi::_1, qi::_2)]; renamingComposition.name("renaming composition"); - atomicComposition = qi::lit("(") > parallelComposition > qi::lit(")") | moduleComposition; + atomicComposition = (qi::lit("(") > parallelComposition > qi::lit(")")) | moduleComposition; atomicComposition.name("atomic composition"); moduleComposition = identifier[qi::_val = phoenix::bind(&PrismParser::createModuleComposition, phoenix::ref(*this), qi::_1)]; @@ -202,7 +202,7 @@ namespace storm { | (qi::lit("<") > -identifier > qi::lit(">")[qi::_a = true])) > +(qi::char_ - qi::lit(";")) - > qi::lit(";"))[qi::_val = phoenix::bind(&PrismParser::createCommand, phoenix::ref(*this), qi::_1, qi::_r1)]; + > qi::lit(";"))[qi::_val = phoenix::bind(&PrismParser::createDummyCommand, phoenix::ref(*this), qi::_1, qi::_r1)]; commandDefinition.name("command definition"); moduleDefinition = ((qi::lit("module") >> identifier >> *(variableDefinition(qi::_a, qi::_b))) > *commandDefinition(qi::_r1) > qi::lit("endmodule"))[qi::_val = phoenix::bind(&PrismParser::createModule, phoenix::ref(*this), qi::_1, qi::_a, qi::_b, qi::_2, qi::_r1)]; @@ -217,8 +217,8 @@ namespace storm { moduleDefinitionList.name("module list"); start = (qi::eps[phoenix::bind(&PrismParser::removeInitialConstruct, phoenix::ref(*this), qi::_a)] - > modelTypeDefinition[phoenix::bind(&GlobalProgramInformation::modelType, qi::_a) = qi::_1] - > *(definedConstantDefinition[phoenix::push_back(phoenix::bind(&GlobalProgramInformation::constants, qi::_a), qi::_1)] + > *(modelTypeDefinition[phoenix::bind(&PrismParser::setModelType, phoenix::ref(*this), qi::_a, qi::_1)] + | definedConstantDefinition[phoenix::push_back(phoenix::bind(&GlobalProgramInformation::constants, qi::_a), qi::_1)] | undefinedConstantDefinition[phoenix::push_back(phoenix::bind(&GlobalProgramInformation::constants, qi::_a), qi::_1)] | formulaDefinition[phoenix::push_back(phoenix::bind(&GlobalProgramInformation::formulas, qi::_a), qi::_1)] | globalVariableDefinition(qi::_a) @@ -299,6 +299,11 @@ namespace storm { return true; } + void PrismParser::setModelType(GlobalProgramInformation& globalProgramInformation, storm::prism::Program::ModelType const& modelType) { + STORM_LOG_THROW(globalProgramInformation.modelType == storm::prism::Program::ModelType::UNDEFINED, storm::exceptions::WrongFormatException, "Parsing error in " << this->getFilename() << ", line " << get_line(qi::_3) << ": Program must not set model type multiple times."); + globalProgramInformation.modelType = modelType; + } + std::shared_ptr PrismParser::createModuleComposition(std::string const& moduleName) const { return std::make_shared(moduleName); } @@ -420,11 +425,11 @@ namespace storm { } storm::prism::Formula PrismParser::createFormula(std::string const& formulaName, storm::expressions::Expression expression) { - if (!this->secondRun) { + // Only register formula in second run. This prevents the parser from accepting formulas that depend on future + // formulas. + if (this->secondRun) { STORM_LOG_THROW(this->identifiers_.find(formulaName) == nullptr, storm::exceptions::WrongFormatException, "Parsing error in " << this->getFilename() << ", line " << get_line(qi::_3) << ": Duplicate identifier '" << formulaName << "'."); this->identifiers_.add(formulaName, expression); - } else { - this->identifiers_.at(formulaName) = expression; } return storm::prism::Formula(formulaName, expression, this->getFilename()); } @@ -484,7 +489,7 @@ namespace storm { return storm::prism::Command(globalProgramInformation.currentCommandIndex - 1, markovian, actionIndex, realActionName, guardExpression, updates, this->getFilename()); } - storm::prism::Command PrismParser::createCommand(boost::optional const& actionName, GlobalProgramInformation& globalProgramInformation) const { + storm::prism::Command PrismParser::createDummyCommand(boost::optional const& actionName, GlobalProgramInformation& globalProgramInformation) const { STORM_LOG_ASSERT(!this->secondRun, "Dummy procedure must not be called in second run."); std::string realActionName = actionName ? actionName.get() : ""; @@ -648,7 +653,13 @@ namespace storm { } storm::prism::Program PrismParser::createProgram(GlobalProgramInformation const& globalProgramInformation) const { - return storm::prism::Program(manager, globalProgramInformation.modelType, globalProgramInformation.constants, globalProgramInformation.globalBooleanVariables, globalProgramInformation.globalIntegerVariables, globalProgramInformation.formulas, globalProgramInformation.modules, globalProgramInformation.actionIndices, globalProgramInformation.rewardModels, globalProgramInformation.labels, secondRun && !globalProgramInformation.hasInitialConstruct ? boost::none : boost::make_optional(globalProgramInformation.initialConstruct), globalProgramInformation.systemCompositionConstruct, this->getFilename(), 1, this->secondRun); + storm::prism::Program::ModelType finalModelType = globalProgramInformation.modelType; + if (globalProgramInformation.modelType == storm::prism::Program::ModelType::UNDEFINED) { + STORM_LOG_WARN("Program does not specify model type. Implicitly assuming 'mdp'."); + finalModelType = storm::prism::Program::ModelType::MDP; + } + + return storm::prism::Program(manager, finalModelType, globalProgramInformation.constants, globalProgramInformation.globalBooleanVariables, globalProgramInformation.globalIntegerVariables, globalProgramInformation.formulas, globalProgramInformation.modules, globalProgramInformation.actionIndices, globalProgramInformation.rewardModels, globalProgramInformation.labels, secondRun && !globalProgramInformation.hasInitialConstruct ? boost::none : boost::make_optional(globalProgramInformation.initialConstruct), globalProgramInformation.systemCompositionConstruct, this->getFilename(), 1, this->secondRun); } void PrismParser::removeInitialConstruct(GlobalProgramInformation& globalProgramInformation) const { diff --git a/src/storm/parser/PrismParser.h b/src/storm/parser/PrismParser.h index 1d5113d8c..f285c5cc9 100644 --- a/src/storm/parser/PrismParser.h +++ b/src/storm/parser/PrismParser.h @@ -25,7 +25,7 @@ namespace storm { class GlobalProgramInformation { public: // Default construct the header information. - GlobalProgramInformation() : modelType(), constants(), formulas(), globalBooleanVariables(), globalIntegerVariables(), moduleToIndexMap(), actionIndices(), modules(), rewardModels(), labels(), hasInitialConstruct(false), initialConstruct(), systemCompositionConstruct(boost::none), currentCommandIndex(0), currentUpdateIndex(0) { + GlobalProgramInformation() : modelType(storm::prism::Program::ModelType::UNDEFINED), constants(), formulas(), globalBooleanVariables(), globalIntegerVariables(), moduleToIndexMap(), actionIndices(), modules(), rewardModels(), labels(), hasInitialConstruct(false), initialConstruct(), systemCompositionConstruct(boost::none), currentCommandIndex(0), currentUpdateIndex(0) { // Map the empty action to index 0. actionIndices.emplace("", 0); } @@ -117,7 +117,7 @@ namespace storm { } template - result_type operator()(Entity& entity, First f, Last l) const { + result_type operator()(Entity& entity, First f, Last) const { entity.setLineNumber(get_line(f)); } private: @@ -245,7 +245,7 @@ namespace storm { bool isValidIdentifier(std::string const& identifier); bool addInitialStatesConstruct(storm::expressions::Expression const& initialStatesExpression, GlobalProgramInformation& globalProgramInformation); bool addSystemCompositionConstruct(std::shared_ptr const& composition, GlobalProgramInformation& globalProgramInformation); - + void setModelType(GlobalProgramInformation& globalProgramInformation, storm::prism::Program::ModelType const& modelType); std::shared_ptr createModuleComposition(std::string const& moduleName) const; std::shared_ptr createRenamingComposition(std::shared_ptr const& subcomposition, std::map const& renaming) const; @@ -269,7 +269,7 @@ namespace storm { storm::prism::Assignment createAssignment(std::string const& variableName, storm::expressions::Expression assignedExpression) const; storm::prism::Update createUpdate(storm::expressions::Expression likelihoodExpression, std::vector const& assignments, GlobalProgramInformation& globalProgramInformation) const; storm::prism::Command createCommand(bool markovianCommand, boost::optional const& actionName, storm::expressions::Expression guardExpression, std::vector const& updates, GlobalProgramInformation& globalProgramInformation) const; - storm::prism::Command createCommand(boost::optional const& actionName, GlobalProgramInformation& globalProgramInformation) const; + storm::prism::Command createDummyCommand(boost::optional const& actionName, GlobalProgramInformation& globalProgramInformation) const; storm::prism::BooleanVariable createBooleanVariable(std::string const& variableName, storm::expressions::Expression initialValueExpression) const; storm::prism::IntegerVariable createIntegerVariable(std::string const& variableName, storm::expressions::Expression lowerBoundExpression, storm::expressions::Expression upperBoundExpression, storm::expressions::Expression initialValueExpression) const; storm::prism::Module createModule(std::string const& moduleName, std::vector const& booleanVariables, std::vector const& integerVariables, std::vector const& commands, GlobalProgramInformation& globalProgramInformation) const; diff --git a/src/storm/permissivesched/PermissiveSchedulers.cpp b/src/storm/permissivesched/PermissiveSchedulers.cpp index 0ce53c61d..1a7e7061b 100644 --- a/src/storm/permissivesched/PermissiveSchedulers.cpp +++ b/src/storm/permissivesched/PermissiveSchedulers.cpp @@ -21,7 +21,7 @@ namespace storm { auto backwardTransitions = mdp.getBackwardTransitions(); storm::storage::BitVector goalstates = propMC.check(safeProp.getSubformula().asEventuallyFormula().getSubformula())->asExplicitQualitativeCheckResult().getTruthValuesVector(); goalstates = storm::utility::graph::performProb1A(mdp, backwardTransitions, storm::storage::BitVector(goalstates.size(), true), goalstates); - storm::storage::BitVector sinkstates = storm::utility::graph::performProb0A(mdp,backwardTransitions, storm::storage::BitVector(goalstates.size(), true), goalstates); + storm::storage::BitVector sinkstates = storm::utility::graph::performProb0A(backwardTransitions, storm::storage::BitVector(goalstates.size(), true), goalstates); auto solver = storm::utility::solver::getLpSolver("Gurobi", storm::solver::LpSolverTypeSelection::Gurobi); MilpPermissiveSchedulerComputation> comp(*solver, mdp, goalstates, sinkstates); @@ -48,7 +48,7 @@ namespace storm { auto backwardTransitions = mdp.getBackwardTransitions(); storm::storage::BitVector goalstates = propMC.check(safeProp.getSubformula().asEventuallyFormula().getSubformula())->asExplicitQualitativeCheckResult().getTruthValuesVector(); goalstates = storm::utility::graph::performProb1A(mdp, backwardTransitions, storm::storage::BitVector(goalstates.size(), true), goalstates); - storm::storage::BitVector sinkstates = storm::utility::graph::performProb0A(mdp, backwardTransitions, storm::storage::BitVector(goalstates.size(), true), goalstates); + storm::storage::BitVector sinkstates = storm::utility::graph::performProb0A(backwardTransitions, storm::storage::BitVector(goalstates.size(), true), goalstates); std::shared_ptr expressionManager = std::make_shared(); auto solver = storm::utility::solver::getSmtSolver(*expressionManager); diff --git a/src/storm/settings/Argument.cpp b/src/storm/settings/Argument.cpp index 1f4a8145d..7ebc3d484 100644 --- a/src/storm/settings/Argument.cpp +++ b/src/storm/settings/Argument.cpp @@ -1,5 +1,6 @@ +#include "storm/settings/Argument.h" -#include "Argument.h" +#include "storm/settings/ArgumentValidators.h" #include "storm/exceptions/IllegalArgumentException.h" #include "storm/exceptions/IllegalArgumentValueException.h" @@ -7,152 +8,191 @@ #include "storm/settings/ArgumentTypeInferationHelper.h" #include "storm/utility/macros.h" - namespace storm { - namespace settings { - + namespace settings { + template - Argument::Argument(std::string const& name, std::string const& description, std::vector const& validationFunctions): ArgumentBase(name, description), argumentValue(), argumentType(inferToEnumType()), validationFunctions(validationFunctions), isOptional(false), defaultValue(), hasDefaultValue(false) { - // Intentionally left empty. - } - - template - Argument::Argument(std::string const& name, std::string const& description, std::vector const& validationFunctions, bool isOptional, T defaultValue): ArgumentBase(name, description), argumentValue(), argumentType(inferToEnumType()), validationFunctions(validationFunctions), isOptional(isOptional), defaultValue(), hasDefaultValue(true) { - this->setDefaultValue(defaultValue); + Argument::Argument(std::string const& name, std::string const& description, std::vector>> const& validators): ArgumentBase(name, description), argumentValue(), argumentType(inferToEnumType()), validators(validators), isOptional(false), defaultValue(), hasDefaultValue(false) { + // Intentionally left empty. + } + + template + Argument::Argument(std::string const& name, std::string const& description, std::vector>> const& validators, bool isOptional, T defaultValue): ArgumentBase(name, description), argumentValue(), argumentType(inferToEnumType()), validators(validators), isOptional(isOptional), defaultValue(), hasDefaultValue(true) { + this->setDefaultValue(defaultValue); + } + + template + bool Argument::getIsOptional() const { + return this->isOptional; + } + + template + bool Argument::setFromStringValue(std::string const& fromStringValue) { + bool conversionOk = false; + T newValue = ArgumentBase::convertFromString(fromStringValue, conversionOk); + if (!conversionOk) { + return false; } - - template - bool Argument::getIsOptional() const { - return this->isOptional; + return this->setFromTypeValue(newValue); + } + + template + bool Argument::setFromTypeValue(T const& newValue, bool hasBeenSet) { + if (!this->validate(newValue)) { + return false; } - - template - bool Argument::setFromStringValue(std::string const& fromStringValue) { - bool conversionOk = false; - T newValue = ArgumentBase::convertFromString(fromStringValue, conversionOk); - if (!conversionOk) { - return false; - } - return this->setFromTypeValue(newValue); - } - - template - bool Argument::setFromTypeValue(T const& newValue, bool hasBeenSet) { - if (!this->validate(newValue)) { - return false; - } - this->argumentValue = newValue; - this->hasBeenSet = hasBeenSet; - return true; - } - - template - ArgumentType Argument::getType() const { - return this->argumentType; - } - - - - template - T const& Argument::getArgumentValue() const { - STORM_LOG_THROW(this->getHasBeenSet() || this->getHasDefaultValue(), storm::exceptions::IllegalFunctionCallException, "Unable to retrieve value of argument '" << this->getName() << "', because it was neither set nor specifies a default value."); - if (this->getHasBeenSet()) { - return this->argumentValue; - } else { - return this->defaultValue; - } - } - - template - bool Argument::getHasDefaultValue() const { - return this->hasDefaultValue; - } - - template - void Argument::setFromDefaultValue() { - STORM_LOG_THROW(this->hasDefaultValue, storm::exceptions::IllegalFunctionCallException, "Unable to set value from default value, because the argument has none."); - bool result = this->setFromTypeValue(this->defaultValue, false); - STORM_LOG_THROW(result, storm::exceptions::IllegalArgumentValueException, "Unable to assign default value to argument, because it was rejected."); - } - - template - std::string Argument::getValueAsString() const { - switch (this->argumentType) { - case ArgumentType::String: - return inferToString(ArgumentType::String, this->getArgumentValue()); - case ArgumentType::Boolean: { - bool iValue = inferToBoolean(ArgumentType::Boolean, this->getArgumentValue()); - if (iValue) { - return "true"; - } else { - return "false"; - } - } - default: return ArgumentBase::convertToString(this->argumentValue); - } - } - - template - int_fast64_t Argument::getValueAsInteger() const { - switch (this->argumentType) { - case ArgumentType::Integer: - return inferToInteger(ArgumentType::Integer, this->getArgumentValue()); - default: STORM_LOG_THROW(false, storm::exceptions::IllegalFunctionCallException, "Unable to retrieve argument value as integer."); break; - } + this->argumentValue = newValue; + this->hasBeenSet = hasBeenSet; + return true; + } + + template + ArgumentType Argument::getType() const { + return this->argumentType; + } + + template + T const& Argument::getArgumentValue() const { + STORM_LOG_THROW(this->getHasBeenSet() || this->getHasDefaultValue(), storm::exceptions::IllegalFunctionCallException, "Unable to retrieve value of argument '" << this->getName() << "', because it was neither set nor specifies a default value."); + if (this->getHasBeenSet()) { + return this->argumentValue; + } else { + return this->defaultValue; } - - - template - uint_fast64_t Argument::getValueAsUnsignedInteger() const { - switch (this->argumentType) { - case ArgumentType::UnsignedInteger: - return inferToUnsignedInteger(ArgumentType::UnsignedInteger, this->getArgumentValue()); - default: STORM_LOG_THROW(false, storm::exceptions::IllegalFunctionCallException, "Unable to retrieve argument value as unsigned integer."); break; + } + + template + bool Argument::getHasDefaultValue() const { + return this->hasDefaultValue; + } + + template + void Argument::setFromDefaultValue() { + STORM_LOG_THROW(this->hasDefaultValue, storm::exceptions::IllegalFunctionCallException, "Unable to set value from default value, because the argument has none."); + bool result = this->setFromTypeValue(this->defaultValue, false); + STORM_LOG_THROW(result, storm::exceptions::IllegalArgumentValueException, "Unable to assign default value to argument, because it was rejected."); + } + + template + std::string Argument::getValueAsString() const { + switch (this->argumentType) { + case ArgumentType::String: + return inferToString(ArgumentType::String, this->getArgumentValue()); + case ArgumentType::Boolean: { + bool iValue = inferToBoolean(ArgumentType::Boolean, this->getArgumentValue()); + if (iValue) { + return "true"; + } else { + return "false"; + } } + default: return ArgumentBase::convertToString(this->argumentValue); } - - - template - double Argument::getValueAsDouble() const { - switch (this->argumentType) { - case ArgumentType::Double: - return inferToDouble(ArgumentType::Double, this->getArgumentValue()); - default: STORM_LOG_THROW(false, storm::exceptions::IllegalFunctionCallException, "Unable to retrieve argument value as double."); break; - } + } + + template + int_fast64_t Argument::getValueAsInteger() const { + switch (this->argumentType) { + case ArgumentType::Integer: + return inferToInteger(ArgumentType::Integer, this->getArgumentValue()); + default: STORM_LOG_THROW(false, storm::exceptions::IllegalFunctionCallException, "Unable to retrieve argument value as integer."); break; } - - template - bool Argument::getValueAsBoolean() const { - switch (this->argumentType) { - case ArgumentType::Boolean: - return inferToBoolean(ArgumentType::Boolean, this->getArgumentValue()); - default: STORM_LOG_THROW(false, storm::exceptions::IllegalFunctionCallException, "Unable to retrieve argument value as boolean."); break; - } + } + + + template + uint_fast64_t Argument::getValueAsUnsignedInteger() const { + switch (this->argumentType) { + case ArgumentType::UnsignedInteger: + return inferToUnsignedInteger(ArgumentType::UnsignedInteger, this->getArgumentValue()); + default: STORM_LOG_THROW(false, storm::exceptions::IllegalFunctionCallException, "Unable to retrieve argument value as unsigned integer."); break; } - - - template - void Argument::setDefaultValue(T const& newDefault) { - STORM_LOG_THROW(this->validate(newDefault), storm::exceptions::IllegalArgumentValueException, "The default value for the argument did not pass all validation functions."); - this->defaultValue = newDefault; - this->hasDefaultValue = true; + } + + + template + double Argument::getValueAsDouble() const { + switch (this->argumentType) { + case ArgumentType::Double: + return inferToDouble(ArgumentType::Double, this->getArgumentValue()); + default: STORM_LOG_THROW(false, storm::exceptions::IllegalFunctionCallException, "Unable to retrieve argument value as double."); break; } - - - template - bool Argument::validate(T const& value) const { - bool result = true; - for (auto const& lambda : validationFunctions) { - result = result && lambda(value); + } + + template + bool Argument::getValueAsBoolean() const { + switch (this->argumentType) { + case ArgumentType::Boolean: + return inferToBoolean(ArgumentType::Boolean, this->getArgumentValue()); + default: STORM_LOG_THROW(false, storm::exceptions::IllegalFunctionCallException, "Unable to retrieve argument value as boolean."); break; + } + } + + + template + void Argument::setDefaultValue(T const& newDefault) { + STORM_LOG_THROW(this->validate(newDefault), storm::exceptions::IllegalArgumentValueException, "The default value for the argument did not pass all validation functions."); + this->defaultValue = newDefault; + this->hasDefaultValue = true; + } + + + template + bool Argument::validate(T const& value) const { + bool result = true; + for (auto const& validator : validators) { + result &= validator->isValid(value); + } + return result; + } + + template + void printValue(std::ostream& out, T const& value) { + out << value; + } + + template<> + void printValue(std::ostream& out, std::string const& value) { + if (value.empty()) { + out << "empty"; + } else { + out << value; + } + } + + template + void Argument::printToStream(std::ostream& out) const { + out << std::setw(0) << std::left << "<" << this->getName() << ">"; + if (!this->validators.empty() || this->hasDefaultValue) { + out << " ("; + if (!this->validators.empty()) { + for (uint64_t i = 0; i < this->validators.size(); ++i) { + out << this->validators[i]->toString(); + if (i + 1 < this->validators.size()) { + out << ", "; + } + } + + if (this->hasDefaultValue) { + out << "; "; + } } - return result; + + if (this->hasDefaultValue) { + out << "default: "; + printValue(out, defaultValue); + } + out << ")"; } - template class Argument; - template class Argument; - template class Argument; - template class Argument; - template class Argument; + out << ": " << this->getDescription(); + } + + template class Argument; + template class Argument; + template class Argument; + template class Argument; + template class Argument; } } - + diff --git a/src/storm/settings/Argument.h b/src/storm/settings/Argument.h index 6a7320a89..080d06409 100644 --- a/src/storm/settings/Argument.h +++ b/src/storm/settings/Argument.h @@ -19,40 +19,38 @@ namespace storm { - namespace settings { + namespace settings { + + template + class ArgumentValidator; /*! * This class subclasses the argument base to actually implement the pure virtual functions. This construction * is necessary so that it becomes easy to store a vector of arguments later despite variing template types, by * keeping a vector of pointers to the base class. */ - template - class Argument : public ArgumentBase { - public: - // Introduce shortcuts for validation functions. - typedef std::function userValidationFunction_t; - + template + class Argument : public ArgumentBase { + public: /*! * Creates a new argument with the given parameters. * * @param name The name of the argument. * @param description The description of the argument. - * @param validationFunctions A vector of validation functions that are to be executed upon assigning a value - * to this argument. + * @param validators A vector of validators that are to be executed upon assigning a value to this argument. * @param isOptional A flag indicating whether the argument is optional. */ - Argument(std::string const& name, std::string const& description, std::vector const& validationFunctions); + Argument(std::string const& name, std::string const& description, std::vector>> const& validators); /*! * Creates a new argument with the given parameters. * * @param name The name of the argument. * @param description The description of the argument. - * @param validationFunctions A vector of validation functions that are to be executed upon assigning a value - * to this argument. + * @param validators A vector of validators that are to be executed upon assigning a value to this argument. * @param isOptional A flag indicating whether the argument is optional. */ - Argument(std::string const& name, std::string const& description, std::vector const& validationFunctions, bool isOptional, T defaultValue); + Argument(std::string const& name, std::string const& description, std::vector>> const& validators, bool isOptional, T defaultValue); virtual bool getIsOptional() const override; @@ -82,23 +80,23 @@ namespace storm { * @return The value of the argument. */ T const& getArgumentValue() const; - + virtual bool getHasDefaultValue() const override; void setFromDefaultValue() override; virtual std::string getValueAsString() const override; - + virtual int_fast64_t getValueAsInteger() const override; virtual uint_fast64_t getValueAsUnsignedInteger() const override; - virtual double getValueAsDouble() const override; - virtual bool getValueAsBoolean() const override; + virtual void printToStream(std::ostream& out) const override; + private: // The value of the argument (in case it has been set). T argumentValue; @@ -107,7 +105,7 @@ namespace storm { ArgumentType argumentType; // The validation functions that were registered for this argument. - std::vector validationFunctions; + std::vector>> validators; // A flag indicating whether this argument is optional. bool isOptional; @@ -124,7 +122,7 @@ namespace storm { * @param newDefault The new default value of the argument. */ void setDefaultValue(T const& newDefault); - + /*! * Applies all validation functions to the given value and therefore checks the validity of a value for this * argument. diff --git a/src/storm/settings/ArgumentBase.cpp b/src/storm/settings/ArgumentBase.cpp index a36c386b8..97e3b2c00 100644 --- a/src/storm/settings/ArgumentBase.cpp +++ b/src/storm/settings/ArgumentBase.cpp @@ -6,21 +6,8 @@ namespace storm { namespace settings { - uint_fast64_t ArgumentBase::getPrintLength() const { - return this->getName().length() + 2; - } - std::ostream& operator<<(std::ostream& out, ArgumentBase const& argument) { - uint_fast64_t width = static_cast(out.width()); - uint_fast64_t charactersPrinted = 0; - out << std::setw(0) << std::left << "<" << argument.getName() << "> "; - charactersPrinted += 2 + argument.getName().length(); - - for (uint_fast64_t i = charactersPrinted; i < width; ++i) { - out << out.fill(); - } - - out << "\t" << argument.getDescription(); + argument.printToStream(out); return out; } diff --git a/src/storm/settings/ArgumentBase.h b/src/storm/settings/ArgumentBase.h index 8bfd55033..6808bd815 100644 --- a/src/storm/settings/ArgumentBase.h +++ b/src/storm/settings/ArgumentBase.h @@ -128,11 +128,9 @@ namespace storm { virtual bool getValueAsBoolean() const = 0; /*! - * Retrieves the (print) length of the argument. - * - * @return The length of the argument. + * Prints a string representation of the argument to the provided stream. */ - uint_fast64_t getPrintLength() const; + virtual void printToStream(std::ostream& out) const = 0; friend std::ostream& operator<<(std::ostream& out, ArgumentBase const& argument); diff --git a/src/storm/settings/ArgumentBuilder.h b/src/storm/settings/ArgumentBuilder.h index 229bf5604..1c1e0e723 100644 --- a/src/storm/settings/ArgumentBuilder.h +++ b/src/storm/settings/ArgumentBuilder.h @@ -21,13 +21,13 @@ #include "storm/exceptions/IllegalArgumentTypeException.h" namespace storm { - namespace settings { + namespace settings { /*! * This class serves as an API for creating arguments. */ - class ArgumentBuilder { - public: + class ArgumentBuilder { + public: /*! * Creates a string argument with the given parameters. * @@ -36,8 +36,8 @@ namespace storm { * @return The builder of the argument. */ static ArgumentBuilder createStringArgument(std::string const& name, std::string const& description) { - ArgumentBuilder ab(ArgumentType::String, name, description); - return ab; + ArgumentBuilder ab(ArgumentType::String, name, description); + return ab; } /*! @@ -48,8 +48,8 @@ namespace storm { * @return The builder of the argument. */ static ArgumentBuilder createIntegerArgument(std::string const& name, std::string const& description) { - ArgumentBuilder ab(ArgumentType::Integer, name, description); - return ab; + ArgumentBuilder ab(ArgumentType::Integer, name, description); + return ab; } /*! @@ -60,8 +60,8 @@ namespace storm { * @return The builder of the argument. */ static ArgumentBuilder createUnsignedIntegerArgument(std::string const& name, std::string const& description) { - ArgumentBuilder ab(ArgumentType::UnsignedInteger, name, description); - return ab; + ArgumentBuilder ab(ArgumentType::UnsignedInteger, name, description); + return ab; } /*! @@ -72,8 +72,8 @@ namespace storm { * @return The builder of the argument. */ static ArgumentBuilder createDoubleArgument(std::string const& name, std::string const& description) { - ArgumentBuilder ab(ArgumentType::Double, name, description); - return ab; + ArgumentBuilder ab(ArgumentType::Double, name, description); + return ab; } /*! @@ -84,8 +84,8 @@ namespace storm { * @return The builder of the argument. */ static ArgumentBuilder createBooleanArgument(std::string const& name, std::string const& description) { - ArgumentBuilder ab(ArgumentType::Boolean, name, description); - return ab; + ArgumentBuilder ab(ArgumentType::Boolean, name, description); + return ab; } /*! @@ -102,19 +102,19 @@ namespace storm { #define PPCAT_NX(A, B) A ## B #define PPCAT(A, B) PPCAT_NX(A, B) -#define MACROaddValidationFunction(funcName, funcType) ArgumentBuilder& PPCAT(addValidationFunction, funcName) (storm::settings::Argument< funcType >::userValidationFunction_t userValidationFunction) { \ +#define MACROaddValidator(funcName, funcType) ArgumentBuilder& PPCAT(addValidator, funcName) (std::shared_ptr>&& validator) { \ STORM_LOG_THROW(this->type == ArgumentType::funcName, storm::exceptions::IllegalFunctionCallException, "Illegal validation function for argument, because it takes arguments of different type."); \ -( PPCAT(this->userValidationFunctions_, funcName) ).push_back(userValidationFunction); \ +( PPCAT(this->validators_, funcName) ).emplace_back(validator); \ return *this; \ } // Add the methods to add validation functions. - MACROaddValidationFunction(String, std::string) - MACROaddValidationFunction(Integer, int_fast64_t) - MACROaddValidationFunction(UnsignedInteger, uint_fast64_t) - MACROaddValidationFunction(Double, double) - MACROaddValidationFunction(Boolean, bool) - + MACROaddValidator(String, std::string) + MACROaddValidator(Integer, int_fast64_t) + MACROaddValidator(UnsignedInteger, uint_fast64_t) + MACROaddValidator(Double, double) + MACROaddValidator(Boolean, bool) + #define MACROsetDefaultValue(funcName, funcType) ArgumentBuilder& PPCAT(setDefaultValue, funcName) (funcType const& defaultValue) { \ STORM_LOG_THROW(this->type == ArgumentType::funcName, storm::exceptions::IllegalFunctionCallException, "Illegal default value for argument" << this->name << ", because it is of different type."); \ @@ -122,7 +122,7 @@ PPCAT(this->defaultValue_, funcName) = defaultValue; \ this->hasDefaultValue = true; \ return *this; \ } - + // Add the methods to set a default value. MACROsetDefaultValue(String, std::string) MACROsetDefaultValue(Integer, int_fast64_t) @@ -139,47 +139,47 @@ return *this; \ STORM_LOG_THROW(!this->hasBeenBuilt, storm::exceptions::IllegalFunctionCallException, "Cannot rebuild argument with builder that was already used to build an argument."); this->hasBeenBuilt = true; switch (this->type) { - case ArgumentType::String: { + case ArgumentType::String: { if (this->hasDefaultValue) { - return std::shared_ptr(new Argument(this->name, this->description, this->userValidationFunctions_String, this->isOptional, this->defaultValue_String)); + return std::shared_ptr(new Argument(this->name, this->description, this->validators_String, this->isOptional, this->defaultValue_String)); } else { - return std::shared_ptr(new Argument(this->name, this->description, this->userValidationFunctions_String)); + return std::shared_ptr(new Argument(this->name, this->description, this->validators_String)); } break; - } - case ArgumentType::Integer: - if (this->hasDefaultValue) { - return std::shared_ptr(new Argument(this->name, this->description, this->userValidationFunctions_Integer, this->isOptional, this->defaultValue_Integer)); - } else { - return std::shared_ptr(new Argument(this->name, this->description, this->userValidationFunctions_Integer)); - } - break; - case ArgumentType::UnsignedInteger: - if (this->hasDefaultValue) { - return std::shared_ptr(new Argument(this->name, this->description, this->userValidationFunctions_UnsignedInteger, this->isOptional, this->defaultValue_UnsignedInteger)); - } else { - return std::shared_ptr(new Argument(this->name, this->description, this->userValidationFunctions_UnsignedInteger)); - } - break; - case ArgumentType::Double: - if (this->hasDefaultValue) { - return std::shared_ptr(new Argument(this->name, this->description, this->userValidationFunctions_Double, this->isOptional, this->defaultValue_Double)); - } else { - return std::shared_ptr(new Argument(this->name, this->description, this->userValidationFunctions_Double)); - } - break; - case ArgumentType::Boolean: - if (this->hasDefaultValue) { - return std::shared_ptr(new Argument(this->name, this->description, this->userValidationFunctions_Boolean, this->isOptional, this->defaultValue_Boolean)); - } else { - return std::shared_ptr(new Argument(this->name, this->description, this->userValidationFunctions_Boolean)); } - break; + case ArgumentType::Integer: + if (this->hasDefaultValue) { + return std::shared_ptr(new Argument(this->name, this->description, this->validators_Integer, this->isOptional, this->defaultValue_Integer)); + } else { + return std::shared_ptr(new Argument(this->name, this->description, this->validators_Integer)); + } + break; + case ArgumentType::UnsignedInteger: + if (this->hasDefaultValue) { + return std::shared_ptr(new Argument(this->name, this->description, this->validators_UnsignedInteger, this->isOptional, this->defaultValue_UnsignedInteger)); + } else { + return std::shared_ptr(new Argument(this->name, this->description, this->validators_UnsignedInteger)); + } + break; + case ArgumentType::Double: + if (this->hasDefaultValue) { + return std::shared_ptr(new Argument(this->name, this->description, this->validators_Double, this->isOptional, this->defaultValue_Double)); + } else { + return std::shared_ptr(new Argument(this->name, this->description, this->validators_Double)); + } + break; + case ArgumentType::Boolean: + if (this->hasDefaultValue) { + return std::shared_ptr(new Argument(this->name, this->description, this->validators_Boolean, this->isOptional, this->defaultValue_Boolean)); + } else { + return std::shared_ptr(new Argument(this->name, this->description, this->validators_Boolean)); + } + break; } STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentTypeException, "Argument has illegal type."); - } + } - private: + private: /*! * Creates an argument builder for an argument with the given parameters. * @@ -187,8 +187,8 @@ return *this; \ * @param name The name of the argument. * @param description The description of the argument. */ - ArgumentBuilder(ArgumentType type, std::string const& name, std::string const& description) : hasBeenBuilt(false), type(type), name(name), description(description), isOptional(false), hasDefaultValue(false), defaultValue_String(), defaultValue_Integer(), defaultValue_UnsignedInteger(), defaultValue_Double(), defaultValue_Boolean(), userValidationFunctions_String(), userValidationFunctions_Integer(), userValidationFunctions_UnsignedInteger(), userValidationFunctions_Double(), userValidationFunctions_Boolean() { - // Intentionally left empty. + ArgumentBuilder(ArgumentType type, std::string const& name, std::string const& description) : hasBeenBuilt(false), type(type), name(name), description(description), isOptional(false), hasDefaultValue(false), defaultValue_String(), defaultValue_Integer(), defaultValue_UnsignedInteger(), defaultValue_Double(), defaultValue_Boolean() { + // Intentionally left empty. } // A flag that stores whether an argument has been built using this builder. @@ -205,10 +205,10 @@ return *this; \ // A flag indicating whether the argument is optional. bool isOptional; - + // A flag that stores whether the argument has a default value. bool hasDefaultValue; - + // The default value of the argument separated by its type. std::string defaultValue_String; int_fast64_t defaultValue_Integer; @@ -217,11 +217,11 @@ return *this; \ bool defaultValue_Boolean; // The validation functions separated by their type. - std::vector::userValidationFunction_t> userValidationFunctions_String; - std::vector::userValidationFunction_t> userValidationFunctions_Integer; - std::vector::userValidationFunction_t> userValidationFunctions_UnsignedInteger; - std::vector::userValidationFunction_t> userValidationFunctions_Double; - std::vector::userValidationFunction_t> userValidationFunctions_Boolean; + std::vector>> validators_String; + std::vector>> validators_Integer; + std::vector>> validators_UnsignedInteger; + std::vector>> validators_Double; + std::vector>> validators_Boolean; }; } } diff --git a/src/storm/settings/ArgumentTypeInferationHelper.cpp b/src/storm/settings/ArgumentTypeInferationHelper.cpp index 49ea8a5e1..1f1144bcf 100644 --- a/src/storm/settings/ArgumentTypeInferationHelper.cpp +++ b/src/storm/settings/ArgumentTypeInferationHelper.cpp @@ -34,7 +34,7 @@ namespace storm { } template - std::string const& inferToString(ArgumentType const& argumentType, T const& value) { + std::string const& inferToString(ArgumentType const&, T const&) { STORM_LOG_THROW(false, storm::exceptions::InternalTypeErrorException, "Unable to infer string from non-string argument value."); } @@ -45,7 +45,7 @@ namespace storm { } template - int_fast64_t inferToInteger(ArgumentType const& argumentType, T const& value) { + int_fast64_t inferToInteger(ArgumentType const&, T const&) { STORM_LOG_THROW(false, storm::exceptions::InternalTypeErrorException, "Unable to infer integer from non-integer argument value."); } @@ -56,7 +56,7 @@ namespace storm { } template - uint_fast64_t inferToUnsignedInteger(ArgumentType const& argumentType, T const& value) { + uint_fast64_t inferToUnsignedInteger(ArgumentType const&, T const&) { STORM_LOG_THROW(false, storm::exceptions::InternalTypeErrorException, "Unable to infer unsigned integer from non-unsigned argument value."); } @@ -67,7 +67,7 @@ namespace storm { } template - double inferToDouble(ArgumentType const& argumentType, T const& value) { + double inferToDouble(ArgumentType const&, T const&) { STORM_LOG_THROW(false, storm::exceptions::InternalTypeErrorException, "Unable to infer double from non-double argument value."); } @@ -78,7 +78,7 @@ namespace storm { } template - bool inferToBoolean(ArgumentType const& argumentType, T const& value) { + bool inferToBoolean(ArgumentType const&, T const&) { STORM_LOG_THROW(false, storm::exceptions::InternalTypeErrorException, "Unable to infer boolean from non-boolean argument value."); } diff --git a/src/storm/settings/ArgumentValidators.cpp b/src/storm/settings/ArgumentValidators.cpp new file mode 100644 index 000000000..13a1792b5 --- /dev/null +++ b/src/storm/settings/ArgumentValidators.cpp @@ -0,0 +1,186 @@ +#include "storm/settings/ArgumentValidators.h" + +#include + +#include + +#include "storm/settings/Argument.h" +#include "storm/utility/macros.h" +#include "storm/exceptions/InvalidArgumentException.h" +#include "storm/exceptions/IllegalArgumentException.h" +#include "storm/exceptions/IllegalArgumentValueException.h" +#include "storm/exceptions/IllegalFunctionCallException.h" + + +namespace storm { + namespace settings { + + template + RangeArgumentValidator::RangeArgumentValidator(boost::optional const& lower, boost::optional const& upper, bool lowerIncluded, bool upperIncluded) : lower(lower), upper(upper), lowerIncluded(lowerIncluded), upperIncluded(upperIncluded) { + // Intentionally left empty. + } + + template + bool RangeArgumentValidator::isValid(ValueType const& value) { + bool result = true; + if (lower) { + if (lowerIncluded) { + result &= value >= lower.get(); + } else { + result &= value > lower.get(); + } + } + if (upper) { + if (upperIncluded) { + result &= value <= upper.get(); + } else { + result &= value < upper.get(); + } + } + return result; + } + + template + std::string RangeArgumentValidator::toString() const { + std::stringstream stream; + stream << "in "; + if (lower) { + if (lowerIncluded) { + stream << "["; + } else { + stream << "("; + } + stream << lower.get(); + } else { + stream << "(-inf"; + } + stream << ", "; + if (upper) { + stream << upper.get(); + if (upperIncluded) { + stream << "]"; + } else { + stream << ")"; + } + } else { + stream << "+inf)"; + } + + return stream.str(); + } + + FileValidator::FileValidator(Mode mode) : mode(mode) { + // Intentionally left empty. + } + + bool FileValidator::isValid(std::string const& filename) { + if (mode == Mode::Exists) { + // First check existence as ifstream::good apparently also returns true for directories. + struct stat info; + stat(filename.c_str(), &info); + STORM_LOG_THROW(info.st_mode & S_IFREG, storm::exceptions::IllegalArgumentValueException, "Unable to read from non-existing file '" << filename << "'."); + + // Now that we know it's a file, we can check its readability. + std::ifstream istream(filename); + STORM_LOG_THROW(istream.good(), storm::exceptions::IllegalArgumentValueException, "Unable to read from file '" << filename << "'."); + + return true; + } else if (mode == Mode::Writable) { + struct stat info; + STORM_LOG_THROW(stat (filename.c_str(), &info) != 0, storm::exceptions::IllegalArgumentValueException , "Could not open file '" << filename << "' for writing because file or directory already exists."); + + std::ofstream filestream(filename); + STORM_LOG_THROW(filestream.is_open(), storm::exceptions::IllegalArgumentValueException , "Could not open file '" << filename << "' for writing."); + filestream.close(); + std::remove(filename.c_str()); + + return true; + } + return false; + } + + std::string FileValidator::toString() const { + if (mode == Mode::Exists) { + return "existing file"; + } else { + return "writable file"; + } + } + + MultipleChoiceValidator::MultipleChoiceValidator(std::vector const& legalValues) : legalValues(legalValues) { + // Intentionally left empty. + } + + bool MultipleChoiceValidator::isValid(std::string const& value) { + for (auto const& legalValue : legalValues) { + if (legalValue == value) { + return true; + } + } + return false; + } + + std::string MultipleChoiceValidator::toString() const { + return "in {" + boost::join(legalValues, ", ") + "}"; + } + + std::shared_ptr> ArgumentValidatorFactory::createIntegerRangeValidatorExcluding(int_fast64_t lowerBound, int_fast64_t upperBound) { + return createRangeValidatorExcluding(lowerBound, upperBound); + } + + std::shared_ptr> ArgumentValidatorFactory::createUnsignedRangeValidatorExcluding(uint64_t lowerBound, uint64_t upperBound) { + return createRangeValidatorExcluding(lowerBound, upperBound); + } + + std::shared_ptr> ArgumentValidatorFactory::createDoubleRangeValidatorExcluding(double lowerBound, double upperBound) { + return createRangeValidatorExcluding(lowerBound, upperBound); + } + + std::shared_ptr> ArgumentValidatorFactory::createIntegerGreaterValidator(int_fast64_t lowerBound) { + return createGreaterValidator(lowerBound, false); + } + + std::shared_ptr> ArgumentValidatorFactory::createUnsignedGreaterValidator(uint64_t lowerBound) { + return createGreaterValidator(lowerBound, false); + } + + std::shared_ptr> ArgumentValidatorFactory::createDoubleGreaterValidator(double lowerBound) { + return createGreaterValidator(lowerBound, false); + } + + std::shared_ptr> ArgumentValidatorFactory::createIntegerGreaterEqualValidator(int_fast64_t lowerBound) { + return createGreaterValidator(lowerBound, true); + } + + std::shared_ptr> ArgumentValidatorFactory::createUnsignedGreaterEqualValidator(uint64_t lowerBound) { + return createGreaterValidator(lowerBound, true); + } + + std::shared_ptr> ArgumentValidatorFactory::createDoubleGreaterEqualValidator(double lowerBound) { + return createGreaterValidator(lowerBound, true); + } + + std::shared_ptr> ArgumentValidatorFactory::createExistingFileValidator() { + return std::make_unique(FileValidator::Mode::Exists); + } + + std::shared_ptr> ArgumentValidatorFactory::createWritableFileValidator() { + return std::make_unique(FileValidator::Mode::Writable); + } + + std::shared_ptr> ArgumentValidatorFactory::createMultipleChoiceValidator(std::vector const& choices) { + return std::make_unique(choices); + } + + template + std::shared_ptr> ArgumentValidatorFactory::createRangeValidatorExcluding(ValueType lowerBound, ValueType upperBound) { + return std::make_unique>(lowerBound, upperBound, false, false); + } + + template + std::shared_ptr> ArgumentValidatorFactory::createGreaterValidator(ValueType lowerBound, bool equalAllowed) { + return std::make_unique>(lowerBound, boost::none, equalAllowed, false); + } + + } +} diff --git a/src/storm/settings/ArgumentValidators.h b/src/storm/settings/ArgumentValidators.h index 5069de7c4..bbdb861f5 100644 --- a/src/storm/settings/ArgumentValidators.h +++ b/src/storm/settings/ArgumentValidators.h @@ -1,275 +1,95 @@ -#ifndef STORM_SETTINGS_ARGUMENTVALIDATORS_H_ -#define STORM_SETTINGS_ARGUMENTVALIDATORS_H_ +#pragma once -#include -#include -#include -#include -#include -#include -#include #include +#include #include -#include - -#include "storm/settings/Argument.h" -#include "storm/utility/macros.h" -#include "storm/exceptions/InvalidArgumentException.h" -#include "storm/exceptions/IllegalArgumentException.h" -#include "storm/exceptions/IllegalArgumentValueException.h" -#include "storm/exceptions/IllegalFunctionCallException.h" -#include +#include namespace storm { - namespace settings { - class ArgumentValidators { - public: - /*! - * Creates a validation function that checks whether an integer is in the given range (including the bounds). - * - * @param lowerBound The lower bound of the valid range. - * @param upperBound The upper bound of the valid range. - * @return The resulting validation function. - */ - static std::function integerRangeValidatorIncluding(int_fast64_t lowerBound, int_fast64_t upperBound) { - return rangeValidatorIncluding(lowerBound, upperBound); - } - - /*! - * Creates a validation function that checks whether an integer is in the given range (excluding the bounds). - * - * @param lowerBound The lower bound of the valid range. - * @param upperBound The upper bound of the valid range. - * @return The resulting validation function. - */ - static std::function integerRangeValidatorExcluding(int_fast64_t lowerBound, int_fast64_t upperBound) { - return rangeValidatorExcluding(lowerBound, upperBound); - } - + namespace settings { + + template + class ArgumentValidator { + public: /*! - * Creates a validation function that checks whether an integer is greater than or equal to the given threshold. - * - * @param threshold The threshold. - * @return The resulting validation function. + * Checks whether the argument passes the validation. */ - static std::function integerGreaterValidatorIncluding(int_fast64_t threshold) { - return greaterValidatorIncluding(threshold); - } + virtual bool isValid(ValueType const& value) = 0; /*! - * Creates a validation function that checks whether an integer is greater than the given threshold. - * - * @param threshold The threshold. - * @return The resulting validation function. - */ - static std::function integerGreaterValidatorExcluding(int_fast64_t threshold) { - return greaterValidatorExcluding(threshold); - } + * Retrieves a string representation of the valid values. + */ + virtual std::string toString() const = 0; + }; + + template + class RangeArgumentValidator : public ArgumentValidator { + public: + RangeArgumentValidator(boost::optional const& lower, boost::optional const& upper, bool lowerIncluded, bool upperIncluded); - /*! - * Creates a validation function that checks whether an unsigned integer is in the given range (including the bounds). - * - * @param lowerBound The lower bound of the valid range. - * @param upperBound The upper bound of the valid range. - * @return The resulting validation function. - */ - static std::function unsignedIntegerRangeValidatorIncluding(uint_fast64_t lowerBound, uint_fast64_t upperBound) { - return rangeValidatorIncluding(lowerBound, upperBound); - } + virtual bool isValid(ValueType const& value) override; + virtual std::string toString() const override; - /*! - * Creates a validation function that checks whether an unsigned integer is in the given range (excluding the bounds). - * - * @param lowerBound The lower bound of the valid range. - * @param upperBound The upper bound of the valid range. - * @return The resulting validation function. - */ - static std::function unsignedIntegerRangeValidatorExcluding(uint_fast64_t lowerBound, uint_fast64_t upperBound) { - return rangeValidatorExcluding(lowerBound, upperBound); - } + private: + boost::optional lower; + boost::optional upper; + bool lowerIncluded; + bool upperIncluded; + }; + + class FileValidator : public ArgumentValidator { + public: + enum class Mode { + Exists, Writable + }; - /*! - * Creates a validation function that checks whether an unsigned integer is greater than or equal to the given threshold. - * - * @param threshold The threshold. - * @return The resulting validation function. - */ - static std::function unsignedIntegerGreaterValidatorIncluding(uint_fast64_t threshold) { - return greaterValidatorIncluding(threshold); - } + FileValidator(Mode mode); - /*! - * Creates a validation function that checks whether an unsigned integer is greater than the given threshold. - * - * @param threshold The threshold. - * @return The resulting validation function. - */ - static std::function unsignedIntegerGreaterValidatorExcluding(uint_fast64_t threshold) { - return greaterValidatorExcluding(threshold); - } - - /*! - * Creates a validation function that checks whether a double is in the given range (including the bounds). - * - * @param lowerBound The lower bound of the valid range. - * @param upperBound The upper bound of the valid range. - * @return The resulting validation function. - */ - static std::function doubleRangeValidatorIncluding(double lowerBound, double upperBound) { - return rangeValidatorIncluding(lowerBound, upperBound); - } + virtual bool isValid(std::string const& value) override; + virtual std::string toString() const override; - /*! - * Creates a validation function that checks whether a double is in the given range (excluding the bounds). - * - * @param lowerBound The lower bound of the valid range. - * @param upperBound The upper bound of the valid range. - * @return The resulting validation function. - */ - static std::function doubleRangeValidatorExcluding(double lowerBound, double upperBound) { - return rangeValidatorExcluding(lowerBound, upperBound); - } + private: + Mode mode; + }; + + class MultipleChoiceValidator : public ArgumentValidator { + public: + MultipleChoiceValidator(std::vector const& legalValues); - /*! - * Creates a validation function that checks whether a double is greater than or equal to the given threshold. - * - * @param threshold The threshold. - * @return The resulting validation function. - */ - static std::function doubleGreaterValidatorIncluding(double threshold) { - return greaterValidatorIncluding(threshold); - } + virtual bool isValid(std::string const& value) override; + virtual std::string toString() const override; - /*! - * Creates a validation function that checks whether a double is greater than the given threshold. - * - * @param threshold The threshold. - * @return The resulting validation function. - */ - static std::function doubleGreaterValidatorExcluding(double threshold) { - return greaterValidatorExcluding(threshold); - } - - /*! - * Creates a validation function that checks whether a given string corresponds to an existing and readable - * file. - * - * @return The resulting validation function. - */ - static std::function existingReadableFileValidator() { - return [] (std::string const fileName) -> bool { - // First check existence as ifstream::good apparently als returns true for directories. - struct stat info; - stat(fileName.c_str(), &info); - STORM_LOG_THROW(info.st_mode & S_IFREG, storm::exceptions::IllegalArgumentValueException, "Unable to read from non-existing file '" << fileName << "'."); - - // Now that we know it's a file, we can check its readability. - std::ifstream istream(fileName); - STORM_LOG_THROW(istream.good(), storm::exceptions::IllegalArgumentValueException, "Unable to read from file '" << fileName << "'."); - - return true; - }; - } - - /*! - * Creates a validation function that checks whether a given string corresponds to a path to non-existing file in which we can write - * - * @return The resulting validation function. - */ - static std::function writableFileValidator() { - return [] (std::string const fileName) -> bool { - struct stat info; - STORM_LOG_THROW(stat (fileName.c_str(), &info) != 0, storm::exceptions::IllegalArgumentValueException , "Could not open file '" << fileName << "' for writing because file or directory already exists."); - - std::ofstream filestream(fileName); - STORM_LOG_THROW(filestream.is_open(), storm::exceptions::IllegalArgumentValueException , "Could not open file '" << fileName << "' for writing."); - filestream.close(); - std::remove(fileName.c_str()); - - return true; - }; - } - - /*! - * Creates a validation function that checks whether a given string is in a provided list of strings. - * - * @param list The list of valid strings. - * @return The resulting validation function. - */ - static std::function stringInListValidator(std::vector const& list) { - return [list] (std::string const& inputString) -> bool { - for (auto const& validString : list) { - if (inputString == validString) { - return true; - } - } - - STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Value '" << inputString << "' does not match any entry in the list of valid items."); - return false; - }; - } + private: + std::vector legalValues; + }; + + class ArgumentValidatorFactory { + public: + static std::shared_ptr> createIntegerRangeValidatorExcluding(int_fast64_t lowerBound, int_fast64_t upperBound); + static std::shared_ptr> createUnsignedRangeValidatorExcluding(uint64_t lowerBound, uint64_t upperBound); + static std::shared_ptr> createDoubleRangeValidatorExcluding(double lowerBound, double upperBound); - private: - /*! - * Creates a validation function that checks whether its argument is in a given range (including the bounds). - * - * @param lowerBound The lower bound of the valid range. - * @param upperBound The upper bound of the valid range. - * @return The resulting validation function. - */ - template - static std::function rangeValidatorIncluding(T lowerBound, T upperBound) { - return std::bind([](T lowerBound, T upperBound, T value) -> bool { - STORM_LOG_THROW(lowerBound <= value && value <= upperBound, storm::exceptions::InvalidArgumentException, "Value " << value << " is out of range."); - return true; - }, lowerBound, upperBound, std::placeholders::_1); - } + static std::shared_ptr> createIntegerGreaterValidator(int_fast64_t lowerBound); + static std::shared_ptr> createUnsignedGreaterValidator(uint64_t lowerBound); + static std::shared_ptr> createDoubleGreaterValidator(double lowerBound); - /*! - * Creates a validation function that checks whether its argument is in a given range (excluding the bounds). - * - * @param lowerBound The lower bound of the valid range. - * @param upperBound The upper bound of the valid range. - * @return The resulting validation function. - */ - template - static std::function rangeValidatorExcluding(T lowerBound, T upperBound) { - return std::bind([](T lowerBound, T upperBound, T value) -> bool { - STORM_LOG_THROW(lowerBound < value && value < upperBound, storm::exceptions::InvalidArgumentException, "Value " << value << " is out of range."); - return true; - }, lowerBound, upperBound, std::placeholders::_1); - } + static std::shared_ptr> createIntegerGreaterEqualValidator(int_fast64_t lowerBound); + static std::shared_ptr> createUnsignedGreaterEqualValidator(uint64_t lowerBound); + static std::shared_ptr> createDoubleGreaterEqualValidator(double lowerBound); - /*! - * Creates a validation function that checks whether its argument is greater than the given threshold. - * - * @param threshold The threshold. - * @return The resulting validation function. - */ - template - static std::function greaterValidatorExcluding(T threshold) { - return std::bind([](T threshold, T value) -> bool { - STORM_LOG_THROW(threshold < value, storm::exceptions::InvalidArgumentException, "Value " << value << " is out of range."); - return true; - }, threshold, std::placeholders::_1); - } + static std::shared_ptr> createExistingFileValidator(); + static std::shared_ptr> createWritableFileValidator(); - /*! - * Creates a validation function that checks whether its argument is greater than or equal to the given threshold. - * - * @param threshold The threshold. - * @return The resulting validation function. - */ - template - static std::function greaterValidatorIncluding(T threshold) { - return std::bind([](T threshold, T value) -> bool { - STORM_LOG_THROW(threshold <= value, storm::exceptions::InvalidArgumentException, "Value " << value << " is out of range."); - return true; - }, threshold, std::placeholders::_1); - } - }; - } + static std::shared_ptr> createMultipleChoiceValidator(std::vector const& choices); + + private: + template + static std::shared_ptr> createRangeValidatorExcluding(ValueType lowerBound, ValueType upperBound); + + template + static std::shared_ptr> createGreaterValidator(ValueType lowerBound, bool equalAllowed); + }; + + } } - -#endif // STORM_SETTINGS_ARGUMENTVALIDATORS_H_ diff --git a/src/storm/settings/Option.cpp b/src/storm/settings/Option.cpp index 98b49b900..338289fe6 100644 --- a/src/storm/settings/Option.cpp +++ b/src/storm/settings/Option.cpp @@ -76,6 +76,12 @@ namespace storm { return *argumentIterator->second; } + ArgumentBase& Option::getArgumentByName(std::string const& argumentName) { + auto argumentIterator = this->argumentNameMap.find(argumentName); + STORM_LOG_THROW(argumentIterator != this->argumentNameMap.end(), storm::exceptions::IllegalArgumentException, "Unable to retrieve argument with unknown name '" << argumentName << "'."); + return *argumentIterator->second; + } + std::string const& Option::getLongName() const { return this->longName; } @@ -140,12 +146,13 @@ namespace storm { length += this->getModuleName().length() + 1; length += this->getLongName().length(); if (this->getHasShortName()) { - length += 4; - if (!this->getRequiresModulePrefix()) { - length += 2; + length += this->getShortName().length() + 3; + } + + if (this->getArgumentCount() > 0) { + for (auto const& argument : this->getArguments()) { + length += argument->getName().size() + 3; } - length += this->getModuleName().length() + 1; - length += this->getShortName().length(); } return length; } @@ -164,7 +171,7 @@ namespace storm { out << "["; ++charactersPrinted; } - out << option.getModuleName() << ":"; + out << option.getModuleName() << ":"; charactersPrinted += option.getModuleName().length() + 1; if (!option.getRequiresModulePrefix()) { out << "]"; @@ -173,42 +180,32 @@ namespace storm { out << option.getLongName(); charactersPrinted += option.getLongName().length(); if (option.getHasShortName()) { - out << " | -"; - charactersPrinted += 4; - if (!option.getRequiresModulePrefix()) { - out << "["; - ++charactersPrinted; - } - out << option.getModuleName() << ":"; - charactersPrinted += option.getModuleName().length() + 1; - if (!option.getRequiresModulePrefix()) { - out << "]"; - ++charactersPrinted; - } - out << option.getShortName(); - charactersPrinted += option.getShortName().length(); - } - - // Now fill the width. - for (uint_fast64_t i = charactersPrinted; i < width; ++i) { - out << out.fill(); + out << " (" << option.getShortName() << ")"; + charactersPrinted += option.getShortName().length() + 3; } - out << "\t" << option.getDescription(); - if (option.getArgumentCount() > 0) { - // Start by determining the longest print length of the arguments. - uint_fast64_t maxLength = 0; for (auto const& argument : option.getArguments()) { - maxLength = std::max(maxLength, argument->getPrintLength()); + out << " <" << argument->getName() << ">"; + charactersPrinted += argument->getName().size() + 3; } - - for (auto const& argument : option.getArguments()) { - out << std::endl; - out << "\t* " << std::setw(maxLength) << std::left << *argument; + } + + // Now fill the width. + for (uint_fast64_t i = charactersPrinted; i < width; ++i) { + if (i == charactersPrinted) { + out << " "; + } else { + out << "."; } } + + out << " " << option.getDescription(); + for (auto const& argument : option.getArguments()) { + out << " " << *argument; + } + return out; } } diff --git a/src/storm/settings/Option.h b/src/storm/settings/Option.h index b043a03f2..1adf8ddff 100644 --- a/src/storm/settings/Option.h +++ b/src/storm/settings/Option.h @@ -64,7 +64,7 @@ namespace storm { * @param other The other option with which to check compatibility. * @return True iff the given argument is compatible with the current one. */ - bool isCompatibleWith(Option const& other); + bool isCompatibleWith(Option const& other); /*! * Retrieves the argument count this option expects. @@ -96,6 +96,14 @@ namespace storm { * @return The argument with the given name. */ ArgumentBase const& getArgumentByName(std::string const& argumentName) const; + + /*! + * Returns a reference to the argument with the specified long name. + * + * @param argumentName The name of the argument to retrieve. + * @return The argument with the given name. + */ + ArgumentBase& getArgumentByName(std::string const& argumentName); /*! * Retrieves the long name of this option. diff --git a/src/storm/settings/SettingsManager.cpp b/src/storm/settings/SettingsManager.cpp index 4ad25a8b1..b5db92f3d 100644 --- a/src/storm/settings/SettingsManager.cpp +++ b/src/storm/settings/SettingsManager.cpp @@ -33,13 +33,14 @@ #include "storm/settings/modules/RegionSettings.h" #include "storm/settings/modules/TopologicalValueIterationEquationSolverSettings.h" #include "storm/settings/modules/ExplorationSettings.h" +#include "storm/settings/modules/ResourceSettings.h" +#include "storm/settings/modules/AbstractionSettings.h" #include "storm/settings/modules/JaniExportSettings.h" #include "storm/settings/modules/JitBuilderSettings.h" #include "storm/settings/modules/MultiObjectiveSettings.h" #include "storm/utility/macros.h" #include "storm/settings/Option.h" - namespace storm { namespace settings { @@ -348,6 +349,7 @@ namespace storm { void SettingsManager::setOptionArguments(std::string const& optionName, std::shared_ptr
. + */ +TASK_IMPL_3(MTBDD, mtbdd_uapply_nocache, MTBDD, dd, mtbdd_uapply_op, op, size_t, param) +{ + /* Maybe perform garbage collection */ + sylvan_gc_test(); + + /* Check cache */ + MTBDD result; + //if (cache_get3(CACHE_MTBDD_UAPPLY, dd, (size_t)op, param, &result)) return result; + + /* Check terminal case */ + result = WRAP(op, dd, param); + if (result != mtbdd_invalid) { + /* Store in cache */ + //cache_put3(CACHE_MTBDD_UAPPLY, dd, (size_t)op, param, result); + return result; + } + + /* Get cofactors */ + mtbddnode_t ndd = MTBDD_GETNODE(dd); + MTBDD ddlow = node_getlow(dd, ndd); + MTBDD ddhigh = node_gethigh(dd, ndd); + + /* Recursive */ + mtbdd_refs_spawn(SPAWN(mtbdd_uapply_nocache, ddhigh, op, param)); + MTBDD low = mtbdd_refs_push(CALL(mtbdd_uapply_nocache, ddlow, op, param)); + MTBDD high = mtbdd_refs_sync(SYNC(mtbdd_uapply_nocache)); + mtbdd_refs_pop(1); + result = mtbdd_makenode(mtbddnode_getvariable(ndd), low, high); + + /* Store in cache */ + //cache_put3(CACHE_MTBDD_UAPPLY, dd, (size_t)op, param, result); + return result; +} diff --git a/resources/3rdparty/sylvan/src/sylvan_storm_rational_function.h b/resources/3rdparty/sylvan/src/sylvan_storm_rational_function.h new file mode 100644 index 000000000..0b06cdf0f --- /dev/null +++ b/resources/3rdparty/sylvan/src/sylvan_storm_rational_function.h @@ -0,0 +1,144 @@ +/** + * This is an implementation of storm::RationalFunction custom leaves of MTBDDs + */ + +#ifndef SYLVAN_STORM_RATIONAL_FUNCTION_H +#define SYLVAN_STORM_RATIONAL_FUNCTION_H + +#include +#include + +#define SYLVAN_HAVE_CARL 1 + +#if defined(SYLVAN_HAVE_CARL) || defined(STORM_HAVE_CARL) + +#define SYLVAN_STORM_RATIONAL_FUNCTION_TYPE_ID (3) + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * Initialize storm::RationalFunction custom leaves + */ +void sylvan_storm_rational_function_init(); + +/** + * Returns the identifier necessary to use these custom leaves. + */ +uint32_t sylvan_storm_rational_function_get_type(); + +/** + * Create storm::RationalFunction leaf + */ +MTBDD mtbdd_storm_rational_function(storm_rational_function_ptr val); + +/** + * Monad that converts Boolean to a storm::RationalFunction MTBDD, translate terminals true to 1 and to 0 otherwise; + */ +TASK_DECL_2(MTBDD, mtbdd_op_bool_to_storm_rational_function, MTBDD, size_t) +TASK_DECL_1(MTBDD, mtbdd_bool_to_storm_rational_function, MTBDD) +#define mtbdd_bool_to_storm_rational_function(dd) CALL(mtbdd_bool_to_storm_rational_function, dd) + +/** + * Operation "plus" for two storm::RationalFunction MTBDDs + */ +TASK_DECL_2(MTBDD, sylvan_storm_rational_function_op_plus, MTBDD*, MTBDD*) +TASK_DECL_3(MTBDD, sylvan_storm_rational_function_abstract_op_plus, MTBDD, MTBDD, int) + +/** + * Operation "minus" for two storm::RationalFunction MTBDDs + */ +TASK_DECL_2(MTBDD, sylvan_storm_rational_function_op_minus, MTBDD*, MTBDD*) + +/** + * Operation "times" for two storm::RationalFunction MTBDDs + */ +TASK_DECL_2(MTBDD, sylvan_storm_rational_function_op_times, MTBDD*, MTBDD*) +TASK_DECL_3(MTBDD, sylvan_storm_rational_function_abstract_op_times, MTBDD, MTBDD, int) + +/** + * Operation "divide" for two storm::RationalFunction MTBDDs + */ +TASK_DECL_2(MTBDD, sylvan_storm_rational_function_op_divide, MTBDD*, MTBDD*) + +/** + * Operation "negate" for one storm::RationalFunction MTBDD + */ +TASK_DECL_2(MTBDD, sylvan_storm_rational_function_op_neg, MTBDD, size_t) + +/** + * Compute a + b + */ +#define sylvan_storm_rational_function_plus(a, b) mtbdd_apply(a, b, TASK(sylvan_storm_rational_function_op_plus)) + +/** + * Compute a - b + */ +#define sylvan_storm_rational_function_minus(a, b) mtbdd_apply(a, b, TASK(sylvan_storm_rational_function_op_minus)) + +/** + * Compute a * b + */ +#define sylvan_storm_rational_function_times(a, b) mtbdd_apply(a, b, TASK(sylvan_storm_rational_function_op_times)) + +/** + * Compute a / b + */ +#define sylvan_storm_rational_function_divide(a, b) mtbdd_apply(a, b, TASK(sylvan_storm_rational_function_op_divide)) + +/** + * Compute -a + */ +#define sylvan_storm_rational_function_neg(a) mtbdd_uapply(a, TASK(sylvan_storm_rational_function_op_neg), 0) + +/** + * Multiply and , and abstract variables using summation. + * This is similar to the "and_exists" operation in BDDs. + */ +TASK_DECL_3(MTBDD, sylvan_storm_rational_function_and_exists, MTBDD, MTBDD, MTBDD); +#define sylvan_storm_rational_function_and_exists(a, b, vars) CALL(sylvan_storm_rational_function_and_exists, a, b, vars) + +/** + * Abstract the variables in from by taking the sum of all values + */ +#define sylvan_storm_rational_function_abstract_plus(dd, v) mtbdd_abstract(dd, v, TASK(sylvan_storm_rational_function_abstract_op_plus)) + +/** + * Apply a unary operation to