Browse Source

Merge branch 'master' into multi-objective

main
TimQu 8 years ago
parent
commit
2da827b216
  1. 4
      CMakeLists.txt
  2. 910
      LICENSE
  3. 24
      README
  4. 3
      README.md
  5. 6
      StormCPackConfig.cmake
  6. 16
      resources/3rdparty/CMakeLists.txt
  7. 5
      resources/3rdparty/cudd-3.0.0/cudd/cuddSat.c
  8. 9
      resources/3rdparty/include_cudd.cmake
  9. 19
      resources/3rdparty/include_xerces.cmake
  10. 0
      resources/3rdparty/include_xerces.cmake.save
  11. 49
      resources/3rdparty/include_xerces.cmake.save.1
  12. 53
      resources/3rdparty/sparsepp/README.md
  13. 8
      resources/3rdparty/sparsepp/makefile
  14. 424
      resources/3rdparty/sparsepp/sparsepp.h
  15. 139
      resources/3rdparty/sparsepp/spp_test.cc
  16. 86
      resources/3rdparty/sparsepp/spp_utils.h
  17. 22
      resources/3rdparty/sylvan/CMakeLists.txt
  18. 96
      resources/cmake/find_modules/FindXerces.cmake
  19. 10
      src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
  20. 15
      src/storm-gspn-cli/storm-gspn.cpp
  21. 2
      src/storm-gspn/adapters/XercesAdapter.h
  22. 149
      src/storm-gspn/builder/JaniGSPNBuilder.cpp
  23. 159
      src/storm-gspn/builder/JaniGSPNBuilder.h
  24. 14
      src/storm-gspn/parser/GreatSpnEditorProjectParser.cpp
  25. 6
      src/storm-gspn/parser/GreatSpnEditorProjectParser.h
  26. 2
      src/storm-gspn/parser/GspnParser.cpp
  27. 6
      src/storm-gspn/parser/PnmlParser.cpp
  28. 6
      src/storm-gspn/parser/PnmlParser.h
  29. 5
      src/storm-gspn/storage/gspn/GspnBuilder.cpp
  30. 4
      src/storm/builder/DdJaniModelBuilder.cpp
  31. 1429
      src/storm/builder/DdPrismModelBuilder.cp
  32. 103
      src/storm/builder/DdPrismModelBuilder.cpp
  33. 10
      src/storm/builder/DdPrismModelBuilder.h
  34. 14
      src/storm/builder/jit/ExplicitJitJaniModelBuilder.cpp
  35. 13
      src/storm/builder/jit/StateBehaviour.cpp
  36. 93
      src/storm/cli/cli.cpp
  37. 131
      src/storm/cli/entrypoints.h
  38. 3
      src/storm/generator/JaniNextStateGenerator.cpp
  39. 4
      src/storm/generator/PrismNextStateGenerator.cpp
  40. 5
      src/storm/logic/Formula.cpp
  41. 1
      src/storm/logic/Formula.h
  42. 1
      src/storm/logic/FragmentSpecification.cpp
  43. 25
      src/storm/logic/LabelSubstitutionVisitor.cpp
  44. 4
      src/storm/logic/LabelSubstitutionVisitor.h
  45. 2
      src/storm/modelchecker/csl/SparseCtmcCslModelChecker.cpp
  46. 2
      src/storm/modelchecker/csl/helper/HybridCtmcCslHelper.cpp
  47. 19
      src/storm/modelchecker/csl/helper/SparseCtmcCslHelper.cpp
  48. 5
      src/storm/modelchecker/csl/helper/SparseCtmcCslHelper.h
  49. 13
      src/storm/modelchecker/prctl/helper/HybridMdpPrctlHelper.cpp
  50. 1
      src/storm/modelchecker/prctl/helper/SparseDtmcPrctlHelper.cpp
  51. 2
      src/storm/modelchecker/prctl/helper/SparseMdpPrctlHelper.cpp
  52. 8
      src/storm/modelchecker/prctl/helper/SymbolicDtmcPrctlHelper.cpp
  53. 2
      src/storm/modelchecker/results/CheckResult.cpp
  54. 2
      src/storm/modelchecker/results/CheckResult.h
  55. 20
      src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.cpp
  56. 12
      src/storm/modelchecker/results/HybridQuantitativeCheckResult.cpp
  57. 8
      src/storm/modelchecker/results/SymbolicQualitativeCheckResult.cpp
  58. 7
      src/storm/modelchecker/results/SymbolicQuantitativeCheckResult.cpp
  59. 9
      src/storm/models/ModelBase.h
  60. 5
      src/storm/models/sparse/MarkovAutomaton.cpp
  61. 4
      src/storm/models/sparse/MarkovAutomaton.h
  62. 13
      src/storm/models/sparse/Model.cpp
  63. 9
      src/storm/models/sparse/Model.h
  64. 21
      src/storm/models/sparse/StandardRewardModel.cpp
  65. 7
      src/storm/models/sparse/StandardRewardModel.h
  66. 8
      src/storm/models/sparse/StateLabeling.cpp
  67. 9
      src/storm/models/sparse/StateLabeling.h
  68. 27
      src/storm/models/symbolic/Ctmc.cpp
  69. 37
      src/storm/models/symbolic/Ctmc.h
  70. 7
      src/storm/models/symbolic/Model.cpp
  71. 2
      src/storm/models/symbolic/Model.h
  72. 2
      src/storm/parser/DeterministicSparseTransitionParser.cpp
  73. 1
      src/storm/parser/ExpressionCreator.cpp
  74. 10
      src/storm/parser/FormulaParser.cpp
  75. 3
      src/storm/parser/FormulaParser.h
  76. 48
      src/storm/parser/FormulaParserGrammar.cpp
  77. 26
      src/storm/parser/FormulaParserGrammar.h
  78. 2
      src/storm/parser/PrismParser.cpp
  79. 1
      src/storm/settings/modules/IOSettings.cpp
  80. 40
      src/storm/solver/EigenLinearEquationSolver.cpp
  81. 8
      src/storm/solver/GmmxxLinearEquationSolver.cpp
  82. 6
      src/storm/solver/NativeLinearEquationSolver.cpp
  83. 28
      src/storm/solver/SymbolicLinearEquationSolver.cpp
  84. 2
      src/storm/solver/SymbolicLinearEquationSolver.h
  85. 15
      src/storm/solver/SymbolicMinMaxLinearEquationSolver.cpp
  86. 13
      src/storm/storage/SparseMatrix.cpp
  87. 7
      src/storm/storage/SparseMatrix.h
  88. 12
      src/storm/storage/SymbolicModelDescription.cpp
  89. 1
      src/storm/storage/SymbolicModelDescription.h
  90. 50
      src/storm/storage/dd/Add.cpp
  91. 2
      src/storm/storage/dd/Bdd.h
  92. 13
      src/storm/storage/dd/DdManager.cpp
  93. 10
      src/storm/storage/dd/DdManager.h
  94. 2
      src/storm/storage/dd/cudd/InternalCuddAdd.cpp
  95. 5
      src/storm/storage/dd/sylvan/InternalSylvanAdd.cpp
  96. 4
      src/storm/storage/dd/sylvan/InternalSylvanAdd.h
  97. 4
      src/storm/storage/dd/sylvan/InternalSylvanBdd.cpp
  98. 2
      src/storm/storage/dd/sylvan/InternalSylvanBdd.h
  99. 44
      src/storm/storage/expressions/ExpressionEvaluator.cpp
  100. 12
      src/storm/storage/expressions/ExpressionEvaluator.h

4
CMakeLists.txt

@ -23,7 +23,7 @@ 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_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)
@ -77,6 +77,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.")

910
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. <http://fsf.org/>
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.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
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 <http://www.gnu.org/licenses/>.
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'.
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, 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.
<signature of Ty Coon>, 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
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

24
README

@ -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

3
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

6
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")

16
resources/3rdparty/CMakeLists.txt

@ -190,11 +190,13 @@ set(STORM_HAVE_CARL OFF)
if(USE_CARL)
find_package(carl QUIET)
if(carl_FOUND)
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)
@ -221,22 +223,23 @@ 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")
add_dependencies(resources carl)
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)
endif()
if(STORM_USE_CLN_NUMBERS AND NOT STORM_HAVE_CLN)
@ -348,7 +351,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 ""
@ -365,6 +368,9 @@ 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(USE_SHIPPED_CARL)
add_dependencies(sylvan carl)
endif()
list(APPEND STORM_DEP_TARGETS sylvan_STATIC)
find_package(Hwloc QUIET REQUIRED)

5
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));

9
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}.")
message(STATUS "Storm - Linking with CUDD ${CUDD_VERSION_STRING}.")

19
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)

0
resources/3rdparty/include_xerces.cmake.save

49
resources/3rdparty/include_xerces.cmake.save.1

@ -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)

53
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 <sparsepp.h>`
@ -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 <sparsepp.h>
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<uint64_t, double, Hash64> 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:

8
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

424
resources/3rdparty/sparsepp/sparsepp.h

@ -920,6 +920,12 @@ template<int S, int H> 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<T *>
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<size_t>((*(reinterpret_cast<const uintptr_t *>(&__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<size_t>(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<bool> : public std::unary_function<bool, size_t>
{
SPP_INLINE size_t operator()(bool __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(bool __v) const SPP_NOEXCEPT
{ return static_cast<size_t>(__v); }
};
template <>
struct spp_hash<char> : public std::unary_function<char, size_t>
{
SPP_INLINE size_t operator()(char __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(char __v) const SPP_NOEXCEPT
{ return static_cast<size_t>(__v); }
};
template <>
struct spp_hash<signed char> : public std::unary_function<signed char, size_t>
{
SPP_INLINE size_t operator()(signed char __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(signed char __v) const SPP_NOEXCEPT
{ return static_cast<size_t>(__v); }
};
template <>
struct spp_hash<unsigned char> : public std::unary_function<unsigned char, size_t>
{
SPP_INLINE size_t operator()(unsigned char __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(unsigned char __v) const SPP_NOEXCEPT
{ return static_cast<size_t>(__v); }
};
template <>
struct spp_hash<wchar_t> : public std::unary_function<wchar_t, size_t>
{
SPP_INLINE size_t operator()(wchar_t __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(wchar_t __v) const SPP_NOEXCEPT
{ return static_cast<size_t>(__v); }
};
template <>
struct spp_hash<short> : public std::unary_function<short, size_t>
struct spp_hash<int16_t> : public std::unary_function<int16_t, size_t>
{
SPP_INLINE size_t operator()(short __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(int16_t __v) const SPP_NOEXCEPT
{ return spp_mix_32(static_cast<uint32_t>(__v)); }
};
template <>
struct spp_hash<unsigned short> : public std::unary_function<unsigned short, size_t>
struct spp_hash<uint16_t> : public std::unary_function<uint16_t, size_t>
{
SPP_INLINE size_t operator()(unsigned short __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(uint16_t __v) const SPP_NOEXCEPT
{ return spp_mix_32(static_cast<uint32_t>(__v)); }
};
template <>
struct spp_hash<int> : public std::unary_function<int, size_t>
struct spp_hash<int32_t> : public std::unary_function<int32_t, size_t>
{
SPP_INLINE size_t operator()(int __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(int32_t __v) const SPP_NOEXCEPT
{ return spp_mix_32(static_cast<uint32_t>(__v)); }
};
template <>
struct spp_hash<unsigned int> : public std::unary_function<unsigned int, size_t>
struct spp_hash<uint32_t> : public std::unary_function<uint32_t, size_t>
{
SPP_INLINE size_t operator()(unsigned int __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(uint32_t __v) const SPP_NOEXCEPT
{ return spp_mix_32(static_cast<uint32_t>(__v)); }
};
template <>
struct spp_hash<long> : public std::unary_function<long, size_t>
struct spp_hash<int64_t> : public std::unary_function<int64_t, size_t>
{
SPP_INLINE size_t operator()(long __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(int64_t __v) const SPP_NOEXCEPT
{ return spp_mix_64(static_cast<uint64_t>(__v)); }
};
template <>
struct spp_hash<unsigned long> : public std::unary_function<unsigned long, size_t>
struct spp_hash<uint64_t> : public std::unary_function<uint64_t, size_t>
{
SPP_INLINE size_t operator()(unsigned long __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(uint64_t __v) const SPP_NOEXCEPT
{ return spp_mix_64(static_cast<uint64_t>(__v)); }
};
template <>
@ -1033,22 +1073,20 @@ struct spp_hash<float> : public std::unary_function<float, size_t>
{
// -0.0 and 0.0 should return same hash
uint32_t *as_int = reinterpret_cast<uint32_t *>(&__v);
return (__v == 0) ? static_cast<size_t>(0) : static_cast<size_t>(*as_int);
return (__v == 0) ? static_cast<size_t>(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<double> : public std::unary_function<double, size_t>
{
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<uint64_t *>(&__v);
return (__v == 0) ? static_cast<size_t>(0) : spp_mix_64(*as_int);
}
};
#endif
template <class T, int sz> 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<typename Key, typename HashFunc,
typename SizeType, int HT_MIN_BUCKETS>
template<typename Key, typename HashFunc, typename SizeType, int HT_MIN_BUCKETS>
class sh_hashtable_settings : public HashFunc
{
private:
#ifndef SPP_MIX_HASH
template <class T, int sz> struct Mixer
{
inline T operator()(T h) const { return h; }
};
#else
template <class T, int sz> struct Mixer
{
inline T operator()(T h) const;
};
template <class T> struct Mixer<T, 4>
template <class T> struct Mixer<T, 4>
{
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 <class T, class U> struct is_relocatable<std::pair<T, U> > :
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
template <class tabletype>
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<tabletype> reference;
typedef table_element_adaptor<tabletype>* 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<tabletype>(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<sparsegroup<T, Alloc> > 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<K, V>, but we need to return std::pair<const K, V>
// ---------------------------------------------------------------------
@ -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<mutable_pointer, bool> 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<bool,
(spp_::is_relocatable<value_type>::value &&
spp_::is_same<allocator_type,
spp_::libc_allocator_with_realloc<mutable_value_type> >::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<bool,
(spp_::is_relocatable<value_type>::value &&
spp_::is_same<allocator_type,
spp_::libc_allocator_with_realloc<mutable_value_type> >::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 <class Val>
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 <class Val>
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 <class Val>
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 <class Val>
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<sparsetable<T, Alloc> > iterator; // defined with index
typedef const_table_iterator<sparsetable<T, Alloc> > const_iterator; // defined with index
typedef table_element_adaptor<sparsetable<T, Alloc> > element_adaptor;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::reverse_iterator<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 <class Val>
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<Value>::type value_type;
typedef HashFcn hasher;
typedef HashFcn hasher; // user provided or spp_hash<Key>
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 <class T>
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<iterator, bool> _insert_noresize(const_reference obj)
template <class T>
std::pair<iterator, bool> _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 <class... Args>
pair<iterator, bool> emplace(Args&&... args)
std::pair<iterator, bool> emplace(Args&&... args)
{
return rep.emplace_unique(std::forward<Args>(args)...);
}
template <class... Args>
iterator emplace_hint(const_iterator p, Args&&... args)
{
return rep.emplace_unique(std::forward<Args>(args)...).first;
_resize_delta(1);
value_type obj(std::forward<Args>(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 <class... Args>
std::pair<iterator, bool> emplace(Args&&... args)
{
return rep.emplace(std::forward<Args>(args)...);
}
template <class... Args>
iterator emplace_hint(const_iterator , Args&&... args)
{
return rep.emplace(std::forward<Args>(args)...).first;
}
#endif
// Insert
// ------
std::pair<iterator, bool>
@ -5496,17 +5448,17 @@ public:
std::pair<iterator, iterator>
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 <class... Args>
pair<iterator, bool> emplace(Args&&... args)
std::pair<iterator, bool> emplace(Args&&... args)
{
return rep.emplace_unique(std::forward<Args>(args)...);
return rep.emplace(std::forward<Args>(args)...);
}
template <class... Args>
iterator emplace_hint(const_iterator p, Args&&... args)
iterator emplace_hint(const_iterator , Args&&... args)
{
return rep.emplace_unique(std::forward<Args>(args)...).first;
return rep.emplace(std::forward<Args>(args)...).first;
}
#endif

139
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<typename C1, typename C2, typename C3, typename C4, typename C5,
typename C6, typename C7, typename C8, typename C9>
@ -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<typename TypeParam> \
@ -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<char*> g_unique_charstar_objects(16);
std::vector<char*> 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<char*>::size_type table_size = g_unique_charstar_objects.size();
size_t table_size = g_unique_charstar_objects.size();
while (index >= static_cast<int>(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<size_t>(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<size_t>(index)] = _strdup(buffer);
}
return g_unique_charstar_objects.get((size_t)index);
return g_unique_charstar_objects[static_cast<size_t>(index)];
}
template<> const char* UniqueObjectHelper(int index) {
return UniqueObjectHelper<char*>(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 <class T> struct MyHash;
typedef std::pair<std::string, std::string> StringPair;
template<> struct MyHash<StringPair>
{
size_t operator()(StringPair const& p) const
{
return std::hash<string>()(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<iterations;++i)
{
spp::sparse_hash_map<std::string,MovableOnlyType> m;
m.reserve(static_cast<size_t>(container_size));
char buff[20];
for (int j=0; j<container_size; ++j)
{
sprintf(buff, "%d", j);
m.emplace(buff, MovableOnlyType());
}
}
}
TEST(HashtableTest, Emplace)
{
{
sparse_hash_map<std::string, std::string> 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<StringPair, MyHash<StringPair> > 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<int *, int> ht2;
ht2[&i] = 3;
struct Bogus;
sparse_hash_map<Bogus *, int> ht3;
ht3[(Bogus *)0] = 8;
}
#endif
#if !defined(SPP_NO_CXX11_VARIADIC_TEMPLATES)
TEST(HashtableTest, ReferenceWrapper)
{
sparse_hash_map<int, std::reference_wrapper<int>> 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.

86
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<T *>
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<size_t>((*(reinterpret_cast<const uintptr_t *>(&__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<size_t>(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<bool> : public std::unary_function<bool, size_t>
{
SPP_INLINE size_t operator()(bool __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(bool __v) const SPP_NOEXCEPT
{ return static_cast<size_t>(__v); }
};
template <>
struct spp_hash<char> : public std::unary_function<char, size_t>
{
SPP_INLINE size_t operator()(char __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(char __v) const SPP_NOEXCEPT
{ return static_cast<size_t>(__v); }
};
template <>
struct spp_hash<signed char> : public std::unary_function<signed char, size_t>
{
SPP_INLINE size_t operator()(signed char __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(signed char __v) const SPP_NOEXCEPT
{ return static_cast<size_t>(__v); }
};
template <>
struct spp_hash<unsigned char> : public std::unary_function<unsigned char, size_t>
{
SPP_INLINE size_t operator()(unsigned char __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(unsigned char __v) const SPP_NOEXCEPT
{ return static_cast<size_t>(__v); }
};
template <>
struct spp_hash<wchar_t> : public std::unary_function<wchar_t, size_t>
{
SPP_INLINE size_t operator()(wchar_t __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(wchar_t __v) const SPP_NOEXCEPT
{ return static_cast<size_t>(__v); }
};
template <>
struct spp_hash<short> : public std::unary_function<short, size_t>
struct spp_hash<int16_t> : public std::unary_function<int16_t, size_t>
{
SPP_INLINE size_t operator()(short __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(int16_t __v) const SPP_NOEXCEPT
{ return spp_mix_32(static_cast<uint32_t>(__v)); }
};
template <>
struct spp_hash<unsigned short> : public std::unary_function<unsigned short, size_t>
struct spp_hash<uint16_t> : public std::unary_function<uint16_t, size_t>
{
SPP_INLINE size_t operator()(unsigned short __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(uint16_t __v) const SPP_NOEXCEPT
{ return spp_mix_32(static_cast<uint32_t>(__v)); }
};
template <>
struct spp_hash<int> : public std::unary_function<int, size_t>
struct spp_hash<int32_t> : public std::unary_function<int32_t, size_t>
{
SPP_INLINE size_t operator()(int __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(int32_t __v) const SPP_NOEXCEPT
{ return spp_mix_32(static_cast<uint32_t>(__v)); }
};
template <>
struct spp_hash<unsigned int> : public std::unary_function<unsigned int, size_t>
struct spp_hash<uint32_t> : public std::unary_function<uint32_t, size_t>
{
SPP_INLINE size_t operator()(unsigned int __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(uint32_t __v) const SPP_NOEXCEPT
{ return spp_mix_32(static_cast<uint32_t>(__v)); }
};
template <>
struct spp_hash<long> : public std::unary_function<long, size_t>
struct spp_hash<int64_t> : public std::unary_function<int64_t, size_t>
{
SPP_INLINE size_t operator()(long __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(int64_t __v) const SPP_NOEXCEPT
{ return spp_mix_64(static_cast<uint64_t>(__v)); }
};
template <>
struct spp_hash<unsigned long> : public std::unary_function<unsigned long, size_t>
struct spp_hash<uint64_t> : public std::unary_function<uint64_t, size_t>
{
SPP_INLINE size_t operator()(unsigned long __v) const SPP_NOEXCEPT {return static_cast<size_t>(__v);}
SPP_INLINE size_t operator()(uint64_t __v) const SPP_NOEXCEPT
{ return spp_mix_64(static_cast<uint64_t>(__v)); }
};
template <>
@ -227,22 +267,20 @@ struct spp_hash<float> : public std::unary_function<float, size_t>
{
// -0.0 and 0.0 should return same hash
uint32_t *as_int = reinterpret_cast<uint32_t *>(&__v);
return (__v == 0) ? static_cast<size_t>(0) : static_cast<size_t>(*as_int);
return (__v == 0) ? static_cast<size_t>(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<double> : public std::unary_function<double, size_t>
{
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<uint64_t *>(&__v);
return (__v == 0) ? static_cast<size_t>(0) : spp_mix_64(*as_int);
}
};
#endif
template <class T, int sz> 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_

22
resources/3rdparty/sylvan/CMakeLists.txt

@ -2,8 +2,15 @@ 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)
@ -30,15 +37,9 @@ if(WITH_COVERAGE)
endif()
if(USE_CARL)
find_package(carl QUIET REQUIRED)
if(carl_FOUND)
add_definitions(-DSYLVAN_HAVE_CARL)
include_directories("${carl_INCLUDE_DIR}")
list(APPEND STORM_LINK_LIBRARIES ${carl_LIBRARIES})
message(STATUS "Sylvan - using CARL.")
else()
message(FATAL_ERROR "Sylvan - CARL was requested but not found")
endif()
add_definitions(-DSYLVAN_HAVE_CARL)
include_directories("${carl_INCLUDE_DIR}")
message(STATUS "Sylvan - using CARL.")
else()
message(STATUS "Sylvan - not using CARL.")
endif()
@ -51,7 +52,6 @@ include_directories("${PROJECT_SOURCE_DIR}/../../../src")
include_directories("${PROJECT_BINARY_DIR}/../../../include")
include_directories(src)
include_directories(src)
add_subdirectory(src)

96
resources/cmake/find_modules/FindXerces.cmake

@ -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)

10
src/storm-dft/modelchecker/dft/DFTModelChecker.cpp

@ -412,11 +412,11 @@ namespace storm {
template<typename ValueType>
void DFTModelChecker<ValueType>::printTimings(std::ostream& os) {
os << "Times:" << std::endl;
os << "Exploration:\t" << explorationTimer.getTimeSeconds() << "s" << std::endl;
os << "Building:\t" << buildingTimer.getTimeSeconds() << "s" << std::endl;
os << "Bisimulation:\t" << bisimulationTimer.getTimeSeconds() << "s" << std::endl;
os << "Modelchecking:\t" << modelCheckingTimer.getTimeSeconds() << "s" << std::endl;
os << "Total:\t\t" << totalTimer.getTimeSeconds() << "s" << 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<typename ValueType>

15
src/storm-gspn-cli/storm-gspn.cpp

@ -31,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.
@ -45,6 +46,7 @@ void initializeSettings() {
storm::settings::addModule<storm::settings::modules::CoreSettings>();
storm::settings::addModule<storm::settings::modules::DebugSettings>();
storm::settings::addModule<storm::settings::modules::JaniExportSettings>();
storm::settings::addModule<storm::settings::modules::ResourceSettings>();
}
@ -94,21 +96,16 @@ int main(const int argc, const char **argv) {
auto capacities = parseCapacitiesList(storm::settings::getModule<storm::settings::modules::GSPNSettings>().getCapacitiesFilename());
gspn->setCapacities(capacities);
}
if(storm::settings::getModule<storm::settings::modules::GSPNExportSettings>().isWriteToDotSet()) {
std::ofstream file;
file.open(storm::settings::getModule<storm::settings::modules::GSPNExportSettings>().getWriteToDotFilename());
gspn->writeDotToStream(file);
}
storm::handleGSPNExportSettings(*gspn);
if(storm::settings::getModule<storm::settings::modules::JaniExportSettings>().isJaniFileSet()) {
storm::jani::Model* model = storm::buildJani(*gspn);
storm::exportJaniModel(*model, {}, storm::settings::getModule<storm::settings::modules::JaniExportSettings>().getJaniFilename());
delete model;
}
delete gspn;
return 0;
//

2
src/storm-gspn/adapters/XercesAdapter.h

@ -1,7 +1,7 @@
#pragma once
#include "storm-config.h"
#ifdef USE_XERCES
#ifdef STORM_HAVE_XERCES
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/util/XMLString.hpp>

149
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<storm::jani::OrderedAssignments> oas;
std::vector<storm::expressions::Expression> probabilities;
std::vector<uint64_t> 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<storm::jani::Assignment> 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<storm::jani::TemplateEdge> 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<storm::jani::Assignment> 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<storm::jani::TemplateEdge> 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);
}
}
}
}

159
src/storm-gspn/builder/JaniGSPNBuilder.h

@ -8,165 +8,32 @@ namespace storm {
namespace builder {
class JaniGSPNBuilder {
public:
JaniGSPNBuilder(storm::gspn::GSPN const& gspn, std::shared_ptr<storm::expressions::ExpressionManager> const& expManager) : gspn(gspn), expressionManager(expManager) {
JaniGSPNBuilder(storm::gspn::GSPN const& gspn, std::shared_ptr<storm::expressions::ExpressionManager> 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", expressionManager->declareIntegerVariable("loc"));
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);
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<storm::jani::OrderedAssignments> oas;
std::vector<storm::expressions::Expression> probabilities;
std::vector<uint64_t> 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<storm::jani::Assignment> 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<storm::jani::TemplateEdge> 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<storm::jani::Assignment> 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<storm::jani::TemplateEdge> 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);
}
}
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<uint64_t, storm::jani::Variable const*> vars;

14
src/storm-gspn/parser/GreatSpnEditorProjectParser.cpp

@ -1,9 +1,9 @@
#include "GreatSpnEditorProjectParser.h"
#ifdef USE_XERCES
#ifdef STORM_HAVE_XERCES
#include <iostream>
#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!
}

6
src/storm-gspn/parser/GreatSpnEditorProjectParser.h

@ -1,15 +1,15 @@
#pragma once
#include "storm-config.h"
#ifdef USE_XERCES
#ifdef STORM_HAVE_XERCES
#include <string>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/util/XMLString.hpp>
#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 {

2
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();

6
src/storm-gspn/parser/PnmlParser.cpp

@ -1,9 +1,9 @@
#include "storm-gspn/parser/PnmlParser.h"
#ifdef USE_XERCES
#ifdef STORM_HAVE_XERCES
#include <iostream>
#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") {

6
src/storm-gspn/parser/PnmlParser.h

@ -1,14 +1,14 @@
#pragma once
#include "storm-config.h"
#ifdef USE_XERCES
#ifdef STORM_HAVE_XERCES
#include <string>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/util/XMLString.hpp>
#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 {

5
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;
}

4
src/storm/builder/DdJaniModelBuilder.cpp

@ -51,9 +51,7 @@ namespace storm {
template <storm::dd::DdType Type, typename ValueType>
DdJaniModelBuilder<Type, ValueType>::Options::Options(std::vector<std::shared_ptr<storm::logic::Formula const>> 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);
}

1429
src/storm/builder/DdPrismModelBuilder.cp
File diff suppressed because it is too large
View File

103
src/storm/builder/DdPrismModelBuilder.cpp

@ -470,7 +470,7 @@ namespace storm {
};
template <storm::dd::DdType Type, typename ValueType>
DdPrismModelBuilder<Type, ValueType>::Options::Options() : buildAllRewardModels(true), rewardModelsToBuild(), buildAllLabels(true), labelsToBuild(), terminalStates(), negatedTerminalStates() {
DdPrismModelBuilder<Type, ValueType>::Options::Options() : buildAllRewardModels(false), rewardModelsToBuild(), buildAllLabels(false), labelsToBuild(), terminalStates(), negatedTerminalStates() {
// Intentionally left empty.
}
@ -482,16 +482,11 @@ namespace storm {
template <storm::dd::DdType Type, typename ValueType>
DdPrismModelBuilder<Type, ValueType>::Options::Options(std::vector<std::shared_ptr<storm::logic::Formula const>> 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 <storm::dd::DdType Type, typename ValueType>
struct DdPrismModelBuilder<Type, ValueType>::SystemResult {
SystemResult(storm::dd::Add<Type, ValueType> const& allTransitionsDd, DdPrismModelBuilder<Type, ValueType>::ModuleDecisionDiagram const& globalModule, storm::dd::Add<Type, ValueType> const& stateActionDd) : allTransitionsDd(allTransitionsDd), globalModule(globalModule), stateActionDd(stateActionDd) {
SystemResult(storm::dd::Add<Type, ValueType> const& allTransitionsDd, DdPrismModelBuilder<Type, ValueType>::ModuleDecisionDiagram const& globalModule, boost::optional<storm::dd::Add<Type, ValueType>> const& stateActionDd) : allTransitionsDd(allTransitionsDd), globalModule(globalModule), stateActionDd(stateActionDd) {
// Intentionally left empty.
}
storm::dd::Add<Type, ValueType> allTransitionsDd;
typename DdPrismModelBuilder<Type, ValueType>::ModuleDecisionDiagram globalModule;
storm::dd::Add<Type, ValueType> stateActionDd;
boost::optional<storm::dd::Add<Type, ValueType>> stateActionDd;
};
template <storm::dd::DdType Type, typename ValueType>
@ -623,14 +618,14 @@ namespace storm {
template <storm::dd::DdType Type, typename ValueType>
typename DdPrismModelBuilder<Type, ValueType>::ActionDecisionDiagram DdPrismModelBuilder<Type, ValueType>::createCommandDecisionDiagram(GenerationInformation& generationInfo, storm::prism::Module const& module, storm::prism::Command const& command) {
STORM_LOG_TRACE("Translating guard " << command.getGuardExpression());
storm::dd::Add<Type, ValueType> guard = generationInfo.rowExpressionAdapter->translateExpression(command.getGuardExpression()) * generationInfo.moduleToRangeMap[module.getName()];
storm::dd::Bdd<Type> 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<UpdateDecisionDiagram> 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<ValueType>(), 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<ValueType>() * commandDd, globalVariablesInSomeUpdate);
} else {
return ActionDecisionDiagram(*generationInfo.manager);
}
@ -754,9 +749,9 @@ namespace storm {
template <storm::dd::DdType Type, typename ValueType>
typename DdPrismModelBuilder<Type, ValueType>::ActionDecisionDiagram DdPrismModelBuilder<Type, ValueType>::combineCommandsToActionMarkovChain(GenerationInformation& generationInfo, std::vector<ActionDecisionDiagram>& commandDds) {
storm::dd::Add<Type, ValueType> allGuards = generationInfo.manager->template getAddZero<ValueType>();
storm::dd::Bdd<Type> allGuards = generationInfo.manager->getBddZero();
storm::dd::Add<Type, ValueType> allCommands = generationInfo.manager->template getAddZero<ValueType>();
storm::dd::Add<Type, ValueType> temporary;
storm::dd::Bdd<Type> temporary;
// Make all command DDs assign to the same global variables.
std::set<storm::expressions::Variable> 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<Type, ValueType> sumOfGuards = generationInfo.manager->template getAddZero<ValueType>();
for (auto const& commandDd : commandDds) {
sumOfGuards += commandDd.guardDd;
allGuards |= commandDd.guardDd.toBdd();
sumOfGuards += commandDd.guardDd.template toAdd<ValueType>();
allGuards |= commandDd.guardDd;
}
uint_fast64_t maxChoices = static_cast<uint_fast64_t>(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<uint_fast64_t>(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<Type> guardChoicesIntersection = commandDds[j].guardDd.toBdd() && equalsNumberOfChoicesDd;
storm::dd::Bdd<Type> guardChoicesIntersection = commandDds[j].guardDd && equalsNumberOfChoicesDd;
// If there is no such state, continue with the next command.
if (guardChoicesIntersection.isZero()) {
@ -888,7 +883,7 @@ namespace storm {
sumOfGuards = sumOfGuards * (!equalsNumberOfChoicesDd).template toAdd<ValueType>();
}
return ActionDecisionDiagram(allGuards.template toAdd<ValueType>(), allCommands, assignedGlobalVariables, nondeterminismVariableOffset + numberOfBinaryVariables);
return ActionDecisionDiagram(allGuards, allCommands, assignedGlobalVariables, nondeterminismVariableOffset + numberOfBinaryVariables);
}
}
@ -896,7 +891,7 @@ namespace storm {
typename DdPrismModelBuilder<Type, ValueType>::ActionDecisionDiagram DdPrismModelBuilder<Type, ValueType>::combineSynchronizingActions(ActionDecisionDiagram const& action1, ActionDecisionDiagram const& action2) {
std::set<storm::expressions::Variable> 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 <storm::dd::DdType Type, typename ValueType>
@ -919,7 +914,7 @@ namespace storm {
std::set<storm::expressions::Variable> 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<Type, ValueType> combinedTransitions = generationInfo.manager->getEncoding(generationInfo.nondeterminismMetaVariables[numberOfUsedNondeterminismVariables], 1).ite(action2.transitionsDd, action1.transitionsDd);
return ActionDecisionDiagram((action1.guardDd.toBdd() || action2.guardDd.toBdd()).template toAdd<ValueType>(), 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<Type, ValueType> result = createSystemFromModule(generationInfo, system);
// Create an auxiliary DD that is used later during the construction of reward models.
storm::dd::Add<Type, ValueType> stateActionDd = result.sumAbstract(generationInfo.columnMetaVariables);
boost::optional<storm::dd::Add<Type, ValueType>> 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::dd::DdType Type, typename ValueType>
storm::models::symbolic::StandardRewardModel<Type, ValueType> DdPrismModelBuilder<Type, ValueType>::createRewardModelDecisionDiagrams(GenerationInformation& generationInfo, storm::prism::RewardModel const& rewardModel, ModuleDecisionDiagram const& globalModule, storm::dd::Add<Type, ValueType> const& reachableStatesAdd, storm::dd::Add<Type, ValueType> const& stateActionDd) {
std::unordered_map<std::string, storm::models::symbolic::StandardRewardModel<Type, ValueType>> DdPrismModelBuilder<Type, ValueType>::createRewardModelDecisionDiagrams(std::vector<std::reference_wrapper<storm::prism::RewardModel const>> const& selectedRewardModels, SystemResult& system, GenerationInformation& generationInfo, ModuleDecisionDiagram const& globalModule, storm::dd::Add<Type, ValueType> const& reachableStatesAdd, storm::dd::Add<Type, ValueType> const& transitionMatrix) {
std::unordered_map<std::string, storm::models::symbolic::StandardRewardModel<Type, ValueType>> rewardModels;
for (auto const& rewardModel : selectedRewardModels) {
rewardModels.emplace(rewardModel.get().getName(), createRewardModelDecisionDiagrams(generationInfo, rewardModel.get(), globalModule, reachableStatesAdd, transitionMatrix, system.stateActionDd));
}
return rewardModels;
}
template <storm::dd::DdType Type, typename ValueType>
storm::models::symbolic::StandardRewardModel<Type, ValueType> DdPrismModelBuilder<Type, ValueType>::createRewardModelDecisionDiagrams(GenerationInformation& generationInfo, storm::prism::RewardModel const& rewardModel, ModuleDecisionDiagram const& globalModule, storm::dd::Add<Type, ValueType> const& reachableStatesAdd, storm::dd::Add<Type, ValueType> const& transitionMatrix, boost::optional<storm::dd::Add<Type, ValueType>>& stateActionDd) {
// Start by creating the state reward vector.
boost::optional<storm::dd::Add<Type, ValueType>> 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<ValueType>() * reachableStatesAdd;
storm::dd::Add<Type, ValueType> 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<ValueType>();
}
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<Type, ValueType> transitionMatrix = system.allTransitionsDd;
ModuleDecisionDiagram const& globalModule = system.globalModule;
storm::dd::Add<Type, ValueType> stateActionDd = system.stateActionDd;
// If we were asked to treat some states as terminal states, we cut away their transitions now.
storm::dd::Bdd<Type> terminalStatesBdd = generationInfo.manager->getBddZero();
@ -1314,7 +1324,9 @@ namespace storm {
storm::dd::Bdd<Type> reachableStates = storm::utility::dd::computeReachableStates<Type>(initialStates, transitionMatrixBdd, generationInfo.rowMetaVariables, generationInfo.columnMetaVariables);
storm::dd::Add<Type, ValueType> reachableStatesAdd = reachableStates.template toAdd<ValueType>();
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<Type> statesWithTransition = transitionMatrixBdd.existsAbstract(generationInfo.columnMetaVariables);
@ -1382,10 +1394,7 @@ namespace storm {
selectedRewardModels.push_back(program.getRewardModel(0));
}
std::unordered_map<std::string, storm::models::symbolic::StandardRewardModel<Type, ValueType>> rewardModels;
for (auto const& rewardModel : selectedRewardModels) {
rewardModels.emplace(rewardModel.get().getName(), createRewardModelDecisionDiagrams(generationInfo, rewardModel.get(), globalModule, reachableStatesAdd, stateActionDd));
}
std::unordered_map<std::string, storm::models::symbolic::StandardRewardModel<Type, ValueType>> rewardModels = createRewardModelDecisionDiagrams(selectedRewardModels, system, generationInfo, globalModule, reachableStatesAdd, transitionMatrix);
// Build the labels that can be accessed as a shortcut.
std::map<std::string, storm::expressions::Expression> labelToExpressionMapping;
@ -1396,7 +1405,7 @@ namespace storm {
if (program.getModelType() == storm::prism::Program::ModelType::DTMC) {
return std::shared_ptr<storm::models::symbolic::Model<Type, ValueType>>(new storm::models::symbolic::Dtmc<Type, ValueType>(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<storm::models::symbolic::Model<Type, ValueType>>(new storm::models::symbolic::Ctmc<Type, ValueType>(generationInfo.manager, reachableStates, initialStates, deadlockStates, transitionMatrix, generationInfo.rowMetaVariables, generationInfo.rowExpressionAdapter, generationInfo.columnMetaVariables, generationInfo.columnExpressionAdapter, generationInfo.rowColumnMetaVariablePairs, labelToExpressionMapping, rewardModels));
return std::shared_ptr<storm::models::symbolic::Model<Type, ValueType>>(new storm::models::symbolic::Ctmc<Type, ValueType>(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<storm::models::symbolic::Model<Type, ValueType>>(new storm::models::symbolic::Mdp<Type, ValueType>(generationInfo.manager, reachableStates, initialStates, deadlockStates, transitionMatrix, generationInfo.rowMetaVariables, generationInfo.rowExpressionAdapter, generationInfo.columnMetaVariables, generationInfo.columnExpressionAdapter, generationInfo.rowColumnMetaVariablePairs, generationInfo.allNondeterminismVariables, labelToExpressionMapping, rewardModels));
} else {

10
src/storm/builder/DdPrismModelBuilder.h

@ -122,11 +122,11 @@ namespace storm {
// Intentionally left empty.
}
ActionDecisionDiagram(storm::dd::DdManager<Type> const& manager, std::set<storm::expressions::Variable> const& assignedGlobalVariables = std::set<storm::expressions::Variable>(), uint_fast64_t numberOfUsedNondeterminismVariables = 0) : guardDd(manager.template getAddZero<ValueType>()), transitionsDd(manager.template getAddZero<ValueType>()), numberOfUsedNondeterminismVariables(numberOfUsedNondeterminismVariables), assignedGlobalVariables(assignedGlobalVariables) {
ActionDecisionDiagram(storm::dd::DdManager<Type> const& manager, std::set<storm::expressions::Variable> const& assignedGlobalVariables = std::set<storm::expressions::Variable>(), uint_fast64_t numberOfUsedNondeterminismVariables = 0) : guardDd(manager.getBddZero()), transitionsDd(manager.template getAddZero<ValueType>()), numberOfUsedNondeterminismVariables(numberOfUsedNondeterminismVariables), assignedGlobalVariables(assignedGlobalVariables) {
// Intentionally left empty.
}
ActionDecisionDiagram(storm::dd::Add<Type, ValueType> guardDd, storm::dd::Add<Type, ValueType> transitionsDd, std::set<storm::expressions::Variable> const& assignedGlobalVariables = std::set<storm::expressions::Variable>(), uint_fast64_t numberOfUsedNondeterminismVariables = 0) : guardDd(guardDd), transitionsDd(transitionsDd), numberOfUsedNondeterminismVariables(numberOfUsedNondeterminismVariables), assignedGlobalVariables(assignedGlobalVariables) {
ActionDecisionDiagram(storm::dd::Bdd<Type> guardDd, storm::dd::Add<Type, ValueType> transitionsDd, std::set<storm::expressions::Variable> const& assignedGlobalVariables = std::set<storm::expressions::Variable>(), 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<Type, ValueType> guardDd;
storm::dd::Bdd<Type> guardDd;
// The actual transitions (source and target states).
storm::dd::Add<Type, ValueType> transitionsDd;
@ -230,7 +230,9 @@ namespace storm {
static storm::dd::Add<Type, ValueType> createSystemFromModule(GenerationInformation& generationInfo, ModuleDecisionDiagram const& module);
static storm::models::symbolic::StandardRewardModel<Type, ValueType> createRewardModelDecisionDiagrams(GenerationInformation& generationInfo, storm::prism::RewardModel const& rewardModel, ModuleDecisionDiagram const& globalModule, storm::dd::Add<Type, ValueType> const& reachableStatesAdd, storm::dd::Add<Type, ValueType> const& stateActionDd);
static std::unordered_map<std::string, storm::models::symbolic::StandardRewardModel<Type, ValueType>> createRewardModelDecisionDiagrams(std::vector<std::reference_wrapper<storm::prism::RewardModel const>> const& selectedRewardModels, SystemResult& system, GenerationInformation& generationInfo, ModuleDecisionDiagram const& globalModule, storm::dd::Add<Type, ValueType> const& reachableStatesAdd, storm::dd::Add<Type, ValueType> const& transitionMatrix);
static storm::models::symbolic::StandardRewardModel<Type, ValueType> createRewardModelDecisionDiagrams(GenerationInformation& generationInfo, storm::prism::RewardModel const& rewardModel, ModuleDecisionDiagram const& globalModule, storm::dd::Add<Type, ValueType> const& reachableStatesAdd, storm::dd::Add<Type, ValueType> const& transitionMatrix, boost::optional<storm::dd::Add<Type, ValueType>>& stateActionDd);
static SystemResult createSystemDecisionDiagram(GenerationInformation& generationInfo);

14
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
@ -924,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;
@ -1544,7 +1546,7 @@ namespace storm {
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(), parallelAutomata);
if (terminalEntry.second) {
if (!terminalEntry.second) {
labelExpression = !labelExpression;
}
terminalExpressions.push_back(expressionTranslator.translate(shiftVariablesWrtLowerBound(labelExpression), storm::expressions::ToCppTranslationOptions(variablePrefixes, variableToName)));
@ -1578,7 +1580,7 @@ namespace storm {
template <typename ValueType, typename RewardModelType>
std::string const& ExplicitJitJaniModelBuilder<ValueType, RewardModelType>::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.";
@ -2348,7 +2350,7 @@ namespace storm {
}
void addStateBehaviour(IndexType const& stateId, StateBehaviour<IndexType, ValueType>& behaviour) {
if (behaviour.empty()) {
if (behaviour.empty() && behaviour.isExpanded()) {
deadlockStates.push_back(stateId);
}

13
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<ValueType>();
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));
}

93
src/storm/cli/cli.cpp

@ -130,52 +130,30 @@ 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 << " 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;
}
std::cout << "STATISTICS_OVERALL_HEADERS;" << "memory;CPU time;wallclock time;" << std::endl;
std::cout << "STATISTICS_OVERALL_HEADERS;" << "memory;CPU time;wallclock time;" << std::endl;
std::cout << "STATISTICS_OVERALL_DATA;"
<< ru.ru_maxrss/1024 << ";"
<< ru.ru_utime.tv_sec << "." << std::setw(3) << std::setfill('0') << ru.ru_utime.tv_usec/1000 << ";"
<< (wallclockMilliseconds/1000) << "." << std::setw(3) << std::setfill('0') << (wallclockMilliseconds % 1000) << ";" << 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<double>(uLargeInteger.QuadPart) / 10000.0; // 100 ns Resolution to milliseconds
uLargeInteger.LowPart = ftUser.dwLowDateTime;
uLargeInteger.HighPart = ftUser.dwHighDateTime;
double userTime = static_cast<double>(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[]) {
@ -232,16 +210,29 @@ namespace storm {
propertyFilter = storm::parsePropertyFilter(storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPropertyFilter());
}
auto coreSettings = storm::settings::getModule<storm::settings::modules::CoreSettings>();
auto generalSettings = storm::settings::getModule<storm::settings::modules::GeneralSettings>();
auto ioSettings = storm::settings::getModule<storm::settings::modules::IOSettings>();
if (ioSettings.isPrismOrJaniInputSet()) {
storm::storage::SymbolicModelDescription model;
std::vector<storm::jani::Property> properties;
STORM_LOG_TRACE("Parsing symbolic input.");
boost::optional<std::map<std::string, std::string>> 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());
@ -261,11 +252,19 @@ namespace storm {
// Then proceed to parsing the properties (if given), since the model we are building may depend on the property.
STORM_LOG_TRACE("Parsing properties.");
if (storm::settings::getModule<storm::settings::modules::GeneralSettings>().isPropertySet()) {
if (generalSettings.isPropertySet()) {
if (model.isJaniModel()) {
properties = storm::parsePropertiesForJaniModel(storm::settings::getModule<storm::settings::modules::GeneralSettings>().getProperty(), model.asJaniModel(), propertyFilter);
properties = storm::parsePropertiesForJaniModel(generalSettings.getProperty(), model.asJaniModel(), propertyFilter);
if (labelRenaming) {
std::vector<storm::jani::Property> amendedProperties;
for (auto const& property : properties) {
amendedProperties.emplace_back(property.substituteLabels(labelRenaming.get()));
}
properties = std::move(amendedProperties);
}
} else {
properties = storm::parsePropertiesForPrismProgram(storm::settings::getModule<storm::settings::modules::GeneralSettings>().getProperty(), model.asPrismProgram(), propertyFilter);
properties = storm::parsePropertiesForPrismProgram(generalSettings.getProperty(), model.asPrismProgram(), propertyFilter);
}
constantDefinitions = model.parseConstantDefinitions(constantDefinitionString);
@ -284,13 +283,13 @@ namespace storm {
}
STORM_LOG_TRACE("Building and checking symbolic model.");
if (storm::settings::getModule<storm::settings::modules::GeneralSettings>().isParametricSet()) {
if (generalSettings.isParametricSet()) {
#ifdef STORM_HAVE_CARL
buildAndCheckSymbolicModel<storm::RationalFunction>(model, properties, true);
#else
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "No parameters are supported in this build.");
#endif
} else if (storm::settings::getModule<storm::settings::modules::GeneralSettings>().isExactSet()) {
} else if (generalSettings.isExactSet()) {
#ifdef STORM_HAVE_CARL
buildAndCheckSymbolicModel<storm::RationalNumber>(model, properties, true);
#else
@ -299,14 +298,14 @@ namespace storm {
} else {
buildAndCheckSymbolicModel<double>(model, properties, true);
}
} else if (storm::settings::getModule<storm::settings::modules::IOSettings>().isExplicitSet()) {
STORM_LOG_THROW(storm::settings::getModule<storm::settings::modules::CoreSettings>().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<storm::jani::Property> properties;
if (storm::settings::getModule<storm::settings::modules::GeneralSettings>().isPropertySet()) {
properties = storm::parsePropertiesForExplicit(storm::settings::getModule<storm::settings::modules::GeneralSettings>().getProperty(), propertyFilter);
if (generalSettings.isPropertySet()) {
properties = storm::parsePropertiesForExplicit(generalSettings.getProperty(), propertyFilter);
}
buildAndCheckExplicitModel<double>(properties, true);

131
src/storm/cli/entrypoints.h

@ -7,6 +7,7 @@
#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"
@ -18,24 +19,23 @@ namespace storm {
template<typename ValueType>
void applyFilterFunctionAndOutput(std::unique_ptr<storm::modelchecker::CheckResult> 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<ValueType>().sum();
return;
STORM_PRINT_AND_LOG(result->asQuantitativeCheckResult<ValueType>().sum());
break;
case storm::modelchecker::FilterType::AVG:
std::cout << result->asQuantitativeCheckResult<ValueType>().average();
return;
STORM_PRINT_AND_LOG(result->asQuantitativeCheckResult<ValueType>().average());
break;
case storm::modelchecker::FilterType::MIN:
std::cout << result->asQuantitativeCheckResult<ValueType>().getMin();
return;
STORM_PRINT_AND_LOG(result->asQuantitativeCheckResult<ValueType>().getMin());
break;
case storm::modelchecker::FilterType::MAX:
std::cout << result->asQuantitativeCheckResult<ValueType>().getMax();
return;
STORM_PRINT_AND_LOG(result->asQuantitativeCheckResult<ValueType>().getMax());
break;
case storm::modelchecker::FilterType::ARGMIN:
case storm::modelchecker::FilterType::ARGMAX:
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Outputting states is not supported");
@ -45,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:
@ -68,24 +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<typename ValueType>
void verifySparseModel(std::shared_ptr<storm::models::sparse::Model<ValueType>> model, std::vector<storm::jani::Property> 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<storm::modelchecker::CheckResult> 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<ValueType>(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);
}
}
}
@ -96,17 +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<storm::modelchecker::CheckResult> 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<storm::RationalFunction>(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<storm::settings::modules::ParametricSettings>().exportResultToFile()) {
@ -120,15 +122,17 @@ namespace storm {
void verifySymbolicModelWithAbstractionRefinementEngine(storm::storage::SymbolicModelDescription const& model, std::vector<storm::jani::Property> const& properties, bool onlyInitialStatesRelevant = false) {
typedef double ValueType;
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<storm::modelchecker::CheckResult> result(storm::verifySymbolicModelWithAbstractionRefinementEngine<DdType, ValueType>(model, property.getFilter().getFormula(), onlyInitialStatesRelevant));
modelCheckingWatch.stop();
if (result) {
std::cout << " done." << std::endl;
std::cout << "Result (initial states): ";
std::cout << *result << std::endl;
STORM_PRINT_AND_LOG("Result (initial states): ");
STORM_PRINT_AND_LOG(*result);
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);
}
}
}
@ -140,18 +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<storm::modelchecker::CheckResult> result;
storm::utility::Stopwatch modelCheckingWatch(false);
if (program.getModelType() == storm::prism::Program::ModelType::DTMC) {
storm::modelchecker::SparseExplorationModelChecker<storm::models::sparse::Dtmc<ValueType>> checker(program);
storm::modelchecker::CheckTask<storm::logic::Formula> 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<storm::models::sparse::Mdp<ValueType>> checker(program);
@ -159,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<ValueType>(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,18 +199,20 @@ namespace storm {
template<storm::dd::DdType DdType>
void verifySymbolicModelWithHybridEngine(std::shared_ptr<storm::models::symbolic::Model<DdType>> model, std::vector<storm::jani::Property> 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<storm::modelchecker::CheckResult> 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<DdType>(model->getReachableStates(), model->getInitialStates()));
applyFilterFunctionAndOutput<double>(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);
}
}
}
@ -209,17 +220,19 @@ namespace storm {
template<storm::dd::DdType DdType>
void verifySymbolicModelWithDdEngine(std::shared_ptr<storm::models::symbolic::Model<DdType>> model, std::vector<storm::jani::Property> 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<storm::modelchecker::CheckResult> 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<DdType>(model->getReachableStates(), model->getInitialStates()));
applyFilterFunctionAndOutput<double>(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);
}
}
}
@ -267,7 +280,10 @@ namespace storm {
template<storm::dd::DdType LibraryType>
void buildAndCheckSymbolicModelWithSymbolicEngine(bool hybrid, storm::storage::SymbolicModelDescription const& model, std::vector<storm::jani::Property> const& properties, bool onlyInitialStatesRelevant = false) {
// Start by building the model.
storm::utility::Stopwatch modelBuildingWatch(true);
auto markovModel = buildSymbolicModel<double, LibraryType>(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);
@ -284,7 +300,10 @@ namespace storm {
void buildAndCheckSymbolicModelWithSparseEngine(storm::storage::SymbolicModelDescription const& model, std::vector<storm::jani::Property> const& properties, bool onlyInitialStatesRelevant = false) {
auto formulas = extractFormulasFromProperties(properties);
// Start by building the model.
storm::utility::Stopwatch modelBuildingWatch(true);
std::shared_ptr<storm::models::ModelBase> markovModel = buildSparseModel<ValueType>(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.");
@ -359,7 +378,11 @@ namespace storm {
storm::settings::modules::IOSettings const& settings = storm::settings::getModule<storm::settings::modules::IOSettings>();
STORM_LOG_THROW(settings.isExplicitSet(), storm::exceptions::InvalidStateException, "Unable to build explicit model without model files.");
storm::utility::Stopwatch modelBuildingWatch(true);
std::shared_ptr<storm::models::ModelBase> model = buildExplicitModel<ValueType>(settings.getTransitionFilename(), settings.getLabelingFilename(), settings.isStateRewardsSet() ? boost::optional<std::string>(settings.getStateRewardsFilename()) : boost::none, settings.isTransitionRewardsSet() ? boost::optional<std::string>(settings.getTransitionRewardsFilename()) : boost::none, settings.isChoiceLabelingSet() ? boost::optional<std::string>(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, extractFormulasFromProperties(properties));

3
src/storm/generator/JaniNextStateGenerator.cpp

@ -467,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<ValueType>()) {
auto targetStateIt = newTargetStates->find(newTargetState);
if (targetStateIt != newTargetStates->end()) {

4
src/storm/generator/PrismNextStateGenerator.cpp

@ -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.

5
src/storm/logic/Formula.cpp

@ -443,6 +443,11 @@ namespace storm {
return visitor.substitute(*this);
}
std::shared_ptr<Formula> Formula::substitute(std::map<std::string, std::string> const& labelSubstitution) const {
LabelSubstitutionVisitor visitor(labelSubstitution);
return visitor.substitute(*this);
}
storm::expressions::Expression Formula::toExpression(storm::expressions::ExpressionManager const& manager, std::map<std::string, storm::expressions::Expression> const& labelToExpressionMapping) const {
ToExpressionVisitor visitor;
if (labelToExpressionMapping.empty()) {

1
src/storm/logic/Formula.h

@ -197,6 +197,7 @@ namespace storm {
std::shared_ptr<Formula> substitute(std::map<storm::expressions::Variable, storm::expressions::Expression> const& substitution) const;
std::shared_ptr<Formula> substitute(std::map<std::string, storm::expressions::Expression> const& labelSubstitution) const;
std::shared_ptr<Formula> substitute(std::map<std::string, std::string> const& labelSubstitution) const;
/*!
* Takes the formula and converts it to an equivalent expression. The formula may contain atomic labels, but

1
src/storm/logic/FragmentSpecification.cpp

@ -325,7 +325,6 @@ namespace storm {
return *this;
}
bool FragmentSpecification::areTotalRewardFormulasAllowed() const {
return totalRewardFormula;
}

25
src/storm/logic/LabelSubstitutionVisitor.cpp

@ -5,22 +5,35 @@
namespace storm {
namespace logic {
LabelSubstitutionVisitor::LabelSubstitutionVisitor(std::map<std::string, storm::expressions::Expression> const& labelToExpressionMapping) : labelToExpressionMapping(labelToExpressionMapping) {
LabelSubstitutionVisitor::LabelSubstitutionVisitor(std::map<std::string, storm::expressions::Expression> const& labelToExpressionMapping) : labelToExpressionMapping(&labelToExpressionMapping), labelToLabelMapping(nullptr) {
// Intentionally left empty.
}
LabelSubstitutionVisitor::LabelSubstitutionVisitor(std::map<std::string, std::string> const& labelToLabelMapping) : labelToExpressionMapping(nullptr), labelToLabelMapping(&labelToLabelMapping) {
// Intentionally left empty.
}
std::shared_ptr<Formula> LabelSubstitutionVisitor::substitute(Formula const& f) const {
boost::any result = f.accept(*this, boost::any());
return boost::any_cast<std::shared_ptr<Formula>>(result);
}
boost::any LabelSubstitutionVisitor::visit(AtomicLabelFormula const& f, boost::any const&) const {
auto it = labelToExpressionMapping.find(f.getLabel());
if (it != labelToExpressionMapping.end()) {
return std::static_pointer_cast<Formula>(std::make_shared<AtomicExpressionFormula>(it->second));
if (labelToExpressionMapping) {
auto it = labelToExpressionMapping->find(f.getLabel());
if (it != labelToExpressionMapping->end()) {
return std::static_pointer_cast<Formula>(std::make_shared<AtomicExpressionFormula>(it->second));
} else {
return f.asSharedPointer();
}
} else {
return std::static_pointer_cast<Formula>(std::make_shared<AtomicLabelFormula>(f));
auto it = labelToLabelMapping->find(f.getLabel());
if (it != labelToLabelMapping->end()) {
return std::static_pointer_cast<Formula>(std::make_shared<AtomicLabelFormula>(it->second));
} else {
return f.asSharedPointer();
}
}
}
}
}
}

4
src/storm/logic/LabelSubstitutionVisitor.h

@ -13,13 +13,15 @@ namespace storm {
class LabelSubstitutionVisitor : public CloneVisitor {
public:
LabelSubstitutionVisitor(std::map<std::string, storm::expressions::Expression> const& labelToExpressionMapping);
LabelSubstitutionVisitor(std::map<std::string, std::string> const& labelToLabelMapping);
std::shared_ptr<Formula> substitute(Formula const& f) const;
virtual boost::any visit(AtomicLabelFormula const& f, boost::any const& data) const override;
private:
std::map<std::string, storm::expressions::Expression> const& labelToExpressionMapping;
std::map<std::string, storm::expressions::Expression> const* labelToExpressionMapping;
std::map<std::string, std::string> const* labelToLabelMapping;
};
}

2
src/storm/modelchecker/csl/SparseCtmcCslModelChecker.cpp

@ -49,7 +49,7 @@ namespace storm {
template<typename CValueType, typename std::enable_if<!storm::NumberTraits<CValueType>::SupportsExponential, int>::type>
bool SparseCtmcCslModelChecker<SparseCtmcModelType>::canHandleImplementation(CheckTask<storm::logic::Formula, CValueType> 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 <typename SparseCtmcModelType>

2
src/storm/modelchecker/csl/helper/HybridCtmcCslHelper.cpp

@ -269,7 +269,7 @@ namespace storm {
// Then compute the state reward vector to use in the computation.
storm::dd::Add<DdType, ValueType> totalRewardVector = rewardModel.getTotalRewardVector(rateMatrix, model.getColumnVariables(), exitRateVector, false);
std::vector<ValueType> explicitTotalRewardVector = totalRewardVector.toVector(odd);
// Finally, compute the transient probabilities.
std::vector<ValueType> result = storm::modelchecker::helper::SparseCtmcCslHelper::computeTransientProbabilities<ValueType, true>(explicitUniformizedMatrix, nullptr, timeBound, uniformizationRate, explicitTotalRewardVector, linearEquationSolverFactory);
return std::unique_ptr<CheckResult>(new HybridQuantitativeCheckResult<DdType>(model.getReachableStates(), model.getManager().getBddZero(), model.getManager().template getAddZero<ValueType>(), model.getReachableStates(), std::move(odd), std::move(result)));

19
src/storm/modelchecker/csl/helper/SparseCtmcCslHelper.cpp

@ -293,7 +293,7 @@ namespace storm {
return storm::modelchecker::helper::SparseDtmcPrctlHelper<ValueType>::computeReachabilityRewards(probabilityMatrix, backwardTransitions, totalRewardVector, targetStates, qualitative, linearEquationSolverFactory);
}
template <typename ValueType, typename RewardModelType, typename std::enable_if<storm::NumberTraits<ValueType>::SupportsExponential, int>::type>
template <typename ValueType, typename RewardModelType>
std::vector<ValueType> SparseCtmcCslHelper::computeReachabilityRewards(storm::storage::SparseMatrix<ValueType> const& rateMatrix, storm::storage::SparseMatrix<ValueType> const& backwardTransitions, std::vector<ValueType> const& exitRateVector, RewardModelType const& rewardModel, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory<ValueType> const& linearEquationSolverFactory) {
STORM_LOG_THROW(!rewardModel.empty(), storm::exceptions::InvalidPropertyException, "Missing reward model for formula. Skipping formula.");
@ -324,11 +324,6 @@ namespace storm {
return storm::modelchecker::helper::SparseDtmcPrctlHelper<ValueType>::computeReachabilityRewards(probabilityMatrix, backwardTransitions, totalRewardVector, targetStates, qualitative, linearEquationSolverFactory);
}
template <typename ValueType, typename RewardModelType, typename std::enable_if<!storm::NumberTraits<ValueType>::SupportsExponential, int>::type>
std::vector<ValueType> SparseCtmcCslHelper::computeReachabilityRewards(storm::storage::SparseMatrix<ValueType> const&, storm::storage::SparseMatrix<ValueType> const&, std::vector<ValueType> const&, RewardModelType const&, storm::storage::BitVector const&, bool, storm::solver::LinearEquationSolverFactory<ValueType> const&) {
STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Computing reachability rewards is unsupported for this value type.");
}
template <typename ValueType>
std::vector<ValueType> SparseCtmcCslHelper::computeLongRunAverageProbabilities(storm::storage::SparseMatrix<ValueType> const& probabilityMatrix, storm::storage::BitVector const& psiStates, std::vector<ValueType> const* exitRateVector, storm::solver::LinearEquationSolverFactory<ValueType> const& linearEquationSolverFactory) {
@ -496,12 +491,6 @@ namespace storm {
solver->solveEquations(bsccEquationSystemSolution, bsccEquationSystemRightSide);
}
// std::vector<ValueType> tmp(probabilityMatrix.getRowCount(), storm::utility::zero<ValueType>());
// probabilityMatrix.multiplyVectorWithMatrix(bsccEquationSystemSolution, tmp);
// for (uint64_t i = 0; i < tmp.size(); ++i) {
// std::cout << tmp[i] << " vs. " << bsccEquationSystemSolution[i] << std::endl;
// }
// If exit rates were given, we need to 'fix' the results to also account for the timing behaviour.
if (exitRateVector != nullptr) {
std::vector<ValueType> bsccTotalValue(bsccDecomposition.size(), zero);
@ -513,11 +502,7 @@ namespace storm {
bsccEquationSystemSolution[indexInStatesInBsccs[*stateIter]] = (bsccEquationSystemSolution[indexInStatesInBsccs[*stateIter]] * (one / (*exitRateVector)[*stateIter])) / bsccTotalValue[stateToBsccIndexMap[indexInStatesInBsccs[*stateIter]]];
}
}
// for (auto const& val : bsccEquationSystemSolution) {
// std::cout << "val: " << val << std::endl;
// }
// 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];

5
src/storm/modelchecker/csl/helper/SparseCtmcCslHelper.h

@ -38,10 +38,7 @@ namespace storm {
template <typename ValueType, typename RewardModelType, typename std::enable_if<!storm::NumberTraits<ValueType>::SupportsExponential, int>::type = 0>
static std::vector<ValueType> computeCumulativeRewards(storm::storage::SparseMatrix<ValueType> const& rateMatrix, std::vector<ValueType> const& exitRateVector, RewardModelType const& rewardModel, double timeBound, storm::solver::LinearEquationSolverFactory<ValueType> const& linearEquationSolverFactory);
template <typename ValueType, typename RewardModelType, typename std::enable_if<storm::NumberTraits<ValueType>::SupportsExponential, int>::type = 0>
static std::vector<ValueType> computeReachabilityRewards(storm::storage::SparseMatrix<ValueType> const& rateMatrix, storm::storage::SparseMatrix<ValueType> const& backwardTransitions, std::vector<ValueType> const& exitRateVector, RewardModelType const& rewardModel, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory<ValueType> const& linearEquationSolverFactory);
template <typename ValueType, typename RewardModelType, typename std::enable_if<!storm::NumberTraits<ValueType>::SupportsExponential, int>::type = 0>
template <typename ValueType, typename RewardModelType>
static std::vector<ValueType> computeReachabilityRewards(storm::storage::SparseMatrix<ValueType> const& rateMatrix, storm::storage::SparseMatrix<ValueType> const& backwardTransitions, std::vector<ValueType> const& exitRateVector, RewardModelType const& rewardModel, storm::storage::BitVector const& targetStates, bool qualitative, storm::solver::LinearEquationSolverFactory<ValueType> const& linearEquationSolverFactory);
template <typename ValueType>

13
src/storm/modelchecker/prctl/helper/HybridMdpPrctlHelper.cpp

@ -243,16 +243,21 @@ namespace storm {
// Then compute the state reward vector to use in the computation.
storm::dd::Add<DdType, ValueType> 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<ValueType>();
}
// 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<DdType> choicesWithInfinitySuccessor = (maybeStates && transitionMatrixBdd && infinityStates.swapVariables(model.getRowColumnMetaVariablePairs())).existsAbstract(model.getColumnVariables());
subvector = choicesWithInfinitySuccessor.ite(model.getManager().template getInfinity<ValueType>(), subvector);
// Before cutting the non-maybe columns, we need to compute the sizes of the row groups.
storm::dd::Add<DdType, uint_fast64_t> stateActionAdd = (submatrix.notZero().existsAbstract(model.getColumnVariables()) || subvector.notZero()).template toAdd<uint_fast64_t>();
storm::dd::Add<DdType, uint_fast64_t> stateActionAdd = submatrix.notZero().existsAbstract(model.getColumnVariables()).template toAdd<uint_fast64_t>();
std::vector<uint_fast64_t> rowGroupSizes = stateActionAdd.sumAbstract(model.getNondeterminismVariables()).toVector(odd);
// Finally cut away all columns targeting non-maybe states.
submatrix *= maybeStatesAdd.swapVariables(model.getRowColumnMetaVariablePairs());
@ -261,7 +266,7 @@ namespace storm {
// Translate the symbolic matrix/vector to their explicit representations.
std::pair<storm::storage::SparseMatrix<ValueType>, std::vector<ValueType>> explicitRepresentation = submatrix.toMatrixVector(subvector, std::move(rowGroupSizes), model.getNondeterminismVariables(), odd, odd);
// Now solve the resulting equation system.
std::unique_ptr<storm::solver::MinMaxLinearEquationSolver<ValueType>> solver = linearEquationSolverFactory.create(std::move(explicitRepresentation.first));
solver->solveEquations(dir, x, explicitRepresentation.second);

1
src/storm/modelchecker/prctl/helper/SparseDtmcPrctlHelper.cpp

@ -88,7 +88,6 @@ 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<ValueType> b = transitionMatrix.getConstrainedRowSumVector(maybeStates, statesWithProbability1);

2
src/storm/modelchecker/prctl/helper/SparseMdpPrctlHelper.cpp

@ -330,7 +330,7 @@ namespace storm {
}
}
}
// Create vector for results for maybe states.
std::vector<ValueType> x(maybeStates.getNumberOfSetBits(), storm::utility::zero<ValueType>());

8
src/storm/modelchecker/prctl/helper/SymbolicDtmcPrctlHelper.cpp

@ -58,7 +58,7 @@ namespace storm {
// Solve the equation system.
std::unique_ptr<storm::solver::SymbolicLinearEquationSolver<DdType, ValueType>> solver = linearEquationSolverFactory.create(submatrix, maybeStates, model.getRowVariables(), model.getColumnVariables(), model.getRowColumnMetaVariablePairs());
storm::dd::Add<DdType, ValueType> result = solver->solveEquations(model.getManager().getConstant(0.5) * maybeStatesAdd, subvector);
storm::dd::Add<DdType, ValueType> result = solver->solveEquations(model.getManager().getConstant(0.0), subvector);
return statesWithProbability01.second.template toAdd<ValueType>() + result;
} else {
@ -166,16 +166,16 @@ namespace storm {
storm::dd::Add<DdType, ValueType> submatrix = transitionMatrix * maybeStatesAdd;
// Then compute the state reward vector to use in the computation.
storm::dd::Add<DdType, ValueType> subvector = rewardModel.getTotalRewardVector(submatrix, model.getColumnVariables());
storm::dd::Add<DdType, ValueType> 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<storm::solver::SymbolicLinearEquationSolver<DdType, ValueType>> solver = linearEquationSolverFactory.create(submatrix, maybeStates, model.getRowVariables(), model.getColumnVariables(), model.getRowColumnMetaVariablePairs());
storm::dd::Add<DdType, ValueType> result = solver->solveEquations(model.getManager().getConstant(0.5) * maybeStatesAdd, subvector);
storm::dd::Add<DdType, ValueType> result = solver->solveEquations(model.getManager().getConstant(0.0), subvector);
return infinityStates.ite(model.getManager().getConstant(storm::utility::infinity<ValueType>()), result);
} else {

2
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;
}

2
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);
}
}

20
src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.cpp

@ -208,14 +208,20 @@ namespace storm {
if (valuesAsMap.size() >= 10 && minMaxSupported) {
printAsRange = true;
} else {
bool first = true;
for (auto const& element : valuesAsMap) {
if (!first) {
out << ", ";
} else {
first = false;
if (valuesAsMap.size() == 1) {
print(out, valuesAsMap.begin()->second);
} else {
out << "{";
bool first = true;
for (auto const& element : valuesAsMap) {
if (!first) {
out << ", ";
} else {
first = false;
}
print(out, element.second);
}
print(out, element.second);
out << "}";
}
}
}

12
src/storm/modelchecker/results/HybridQuantitativeCheckResult.cpp

@ -94,12 +94,19 @@ namespace storm {
std::ostream& HybridQuantitativeCheckResult<Type, ValueType>::writeToStream(std::ostream& out) const {
uint64_t totalNumberOfStates = this->symbolicStates.getNonZeroCount() + this->explicitStates.getNonZeroCount();
if (totalNumberOfStates < 10) {
if (totalNumberOfStates == 1) {
if (this->symbolicStates.isZero()) {
out << *this->explicitValues.begin();
} else {
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) {
@ -109,6 +116,9 @@ namespace storm {
}
out << valuationValuePair.second;
}
if (symbolicStates.getNonZeroCount() != this->symbolicValues.getNonZeroCount()) {
out << ", 0";
}
}
}
if (!this->explicitStates.isZero()) {

8
src/storm/modelchecker/results/SymbolicQualitativeCheckResult.cpp

@ -73,7 +73,13 @@ namespace storm {
template <storm::dd::DdType Type>
std::ostream& SymbolicQualitativeCheckResult<Type>::writeToStream(std::ostream& out) const {
if (states == truthValues) {
if (states.getNonZeroCount() == 1) {
if (truthValues.isZero()) {
out << "false";
} else {
out << "true";
}
} else if (states == truthValues) {
out << "{true}" << std::endl;
} else {
if (truthValues.isZero()) {

7
src/storm/modelchecker/results/SymbolicQuantitativeCheckResult.cpp

@ -59,7 +59,9 @@ namespace storm {
template<storm::dd::DdType Type, typename ValueType>
std::ostream& SymbolicQuantitativeCheckResult<Type, ValueType>::writeToStream(std::ostream& out) const {
if (states.getNonZeroCount() < 10) {
if (states.getNonZeroCount() == 1) {
out << this->values.getMax();
} else if (states.getNonZeroCount() < 10) {
out << "{";
if (this->values.isZero()) {
out << "0";
@ -73,6 +75,9 @@ namespace storm {
}
out << valuationValuePair.second;
}
if (states.getNonZeroCount() != this->values.getNonZeroCount()) {
out << ", 0";
}
}
out << "}";
} else {

9
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.
*

5
src/storm/models/sparse/MarkovAutomaton.cpp

@ -236,11 +236,6 @@ namespace storm {
}
}
template <typename ValueType, typename RewardModelType>
std::size_t MarkovAutomaton<ValueType, RewardModelType>::getSizeInBytes() const {
return NondeterministicModel<ValueType, RewardModelType>::getSizeInBytes() + markovianStates.getSizeInBytes() + exitRates.size() * sizeof(ValueType);
}
template <typename ValueType, typename RewardModelType>
void MarkovAutomaton<ValueType, RewardModelType>::turnRatesToProbabilities() {
this->exitRates.resize(this->getNumberOfStates());

4
src/storm/models/sparse/MarkovAutomaton.h

@ -194,9 +194,7 @@ namespace storm {
std::shared_ptr<storm::models::sparse::Ctmc<ValueType, RewardModelType>> convertToCTMC() const;
virtual void writeDotToStream(std::ostream& outStream, bool includeLabeling = true, storm::storage::BitVector const* subsystem = nullptr, std::vector<ValueType> const* firstValue = nullptr, std::vector<ValueType> const* secondValue = nullptr, std::vector<uint_fast64_t> const* stateColoring = nullptr, std::vector<std::string> const* colors = nullptr, std::vector<uint_fast64_t>* scheduler = nullptr, bool finalizeOutput = true) const override;
std::size_t getSizeInBytes() const override;
virtual void printModelInformationToStream(std::ostream& out) const override;
private:

13
src/storm/models/sparse/Model.cpp

@ -188,18 +188,6 @@ namespace storm {
return static_cast<bool>(choiceLabeling);
}
template<typename ValueType, typename RewardModelType>
std::size_t Model<ValueType, RewardModelType>::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<typename ValueType, typename RewardModelType>
void Model<ValueType, RewardModelType>::printModelInformationToStream(std::ostream& out) const {
this->printModelInformationHeaderToStream(out);
@ -219,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;
}

9
src/storm/models/sparse/Model.h

@ -275,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.
*

21
src/storm/models/sparse/StandardRewardModel.cpp

@ -165,11 +165,6 @@ namespace storm {
template<typename ValueType>
template<typename MatrixValueType>
std::vector<ValueType> StandardRewardModel<ValueType>::getTotalRewardVector(storm::storage::SparseMatrix<MatrixValueType> const& transitionMatrix) const {
if (this->hasStateActionRewards()) {
for (auto const& e : this->getStateActionRewardVector()) {
std::cout << "e " << e << std::endl;
}
}
std::vector<ValueType> result = this->hasTransitionRewards() ? transitionMatrix.getPointwiseProductRowSumVector(this->getTransitionRewardMatrix()) : (this->hasStateActionRewards() ? this->getStateActionRewardVector() : std::vector<ValueType>(transitionMatrix.getRowCount()));
if (this->hasStateActionRewards() && this->hasTransitionRewards()) {
storm::utility::vector::addVectors(result, this->getStateActionRewardVector(), result);
@ -275,22 +270,6 @@ namespace storm {
return true;
}
template<typename ValueType>
std::size_t StandardRewardModel<ValueType>::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 <typename ValueType>
std::ostream& operator<<(std::ostream& out, StandardRewardModel<ValueType> const& rewardModel) {
out << std::boolalpha << "reward model [state reward: "

7
src/storm/models/sparse/StandardRewardModel.h

@ -274,13 +274,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 <typename ValueTypePrime>
friend std::ostream& operator<<(std::ostream& out, StandardRewardModel<ValueTypePrime> const& rewardModel);

8
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) {

9
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.
*

27
src/storm/models/symbolic/Ctmc.cpp

@ -24,12 +24,33 @@ namespace storm {
std::map<std::string, storm::expressions::Expression> labelToExpressionMap,
std::unordered_map<std::string, RewardModelType> const& rewardModels)
: DeterministicModel<Type, ValueType>(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<storm::dd::DdType Type, typename ValueType>
Ctmc<Type, ValueType>::Ctmc(std::shared_ptr<storm::dd::DdManager<Type>> manager,
storm::dd::Bdd<Type> reachableStates,
storm::dd::Bdd<Type> initialStates,
storm::dd::Bdd<Type> deadlockStates,
storm::dd::Add<Type, ValueType> transitionMatrix,
boost::optional<storm::dd::Add<Type, ValueType>> exitRateVector,
std::set<storm::expressions::Variable> const& rowVariables,
std::shared_ptr<storm::adapters::AddExpressionAdapter<Type, ValueType>> rowExpressionAdapter,
std::set<storm::expressions::Variable> const& columnVariables,
std::shared_ptr<storm::adapters::AddExpressionAdapter<Type, ValueType>> columnExpressionAdapter,
std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs,
std::map<std::string, storm::expressions::Expression> labelToExpressionMap,
std::unordered_map<std::string, RewardModelType> const& rewardModels)
: DeterministicModel<Type, ValueType>(storm::models::ModelType::Ctmc, manager, reachableStates, initialStates, deadlockStates, transitionMatrix, rowVariables, rowExpressionAdapter, columnVariables, columnExpressionAdapter, rowColumnMetaVariablePairs, labelToExpressionMap, rewardModels), exitRates(exitRateVector) {
// Intentionally left empty.
}
template<storm::dd::DdType Type, typename ValueType>
storm::dd::Add<Type, ValueType> const& Ctmc<Type, ValueType>::getExitRateVector() const {
return exitRates;
if (!exitRates) {
exitRates = this->getTransitionMatrix().sumAbstract(this->getColumnVariables());
}
return exitRates.get();
}
// Explicitly instantiate the template class.

37
src/storm/models/symbolic/Ctmc.h

@ -54,7 +54,40 @@ namespace storm {
std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs,
std::map<std::string, storm::expressions::Expression> labelToExpressionMap = std::map<std::string, storm::expressions::Expression>(),
std::unordered_map<std::string, RewardModelType> const& rewardModels = std::unordered_map<std::string, RewardModelType>());
/*!
* 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<storm::dd::DdManager<Type>> manager,
storm::dd::Bdd<Type> reachableStates,
storm::dd::Bdd<Type> initialStates,
storm::dd::Bdd<Type> deadlockStates,
storm::dd::Add<Type, ValueType> transitionMatrix,
boost::optional<storm::dd::Add<Type, ValueType>> exitRateVector,
std::set<storm::expressions::Variable> const& rowVariables,
std::shared_ptr<storm::adapters::AddExpressionAdapter<Type, ValueType>> rowExpressionAdapter,
std::set<storm::expressions::Variable> const& columnVariables,
std::shared_ptr<storm::adapters::AddExpressionAdapter<Type, ValueType>> columnExpressionAdapter,
std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs,
std::map<std::string, storm::expressions::Expression> labelToExpressionMap = std::map<std::string, storm::expressions::Expression>(),
std::unordered_map<std::string, RewardModelType> const& rewardModels = std::unordered_map<std::string, RewardModelType>());
/*!
* Retrieves the exit rate vector of the CTMC.
*
@ -63,7 +96,7 @@ namespace storm {
storm::dd::Add<Type, ValueType> const& getExitRateVector() const;
private:
storm::dd::Add<Type, ValueType> exitRates;
mutable boost::optional<storm::dd::Add<Type, ValueType>> exitRates;
};
} // namespace symbolic

7
src/storm/models/symbolic/Model.cpp

@ -114,12 +114,6 @@ namespace storm {
return this->getTransitionMatrix().notZero();
}
template<storm::dd::DdType Type, typename ValueType>
std::size_t Model<Type, ValueType>::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());
}
template<storm::dd::DdType Type, typename ValueType>
std::set<storm::expressions::Variable> const& Model<Type, ValueType>::getRowVariables() const {
return rowVariables;
@ -222,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;
}

2
src/storm/models/symbolic/Model.h

@ -254,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;

2
src/storm/parser/DeterministicSparseTransitionParser.cpp

@ -54,7 +54,7 @@ namespace storm {
bool insertDiagonalEntriesIfMissing = !isRewardFile;
DeterministicSparseTransitionParser<ValueType>::FirstPassResult firstPass = DeterministicSparseTransitionParser<ValueType>::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) {

1
src/storm/parser/ExpressionCreator.cpp

@ -228,7 +228,6 @@ namespace storm {
}
void ExpressionCreator::setIdentifierMapping(qi::symbols<char, storm::expressions::Expression> const* identifiers_) {
if (identifiers_ != nullptr) {
createExpressions = true;
identifiers = identifiers_;

10
src/storm/parser/FormulaParser.cpp

@ -31,7 +31,15 @@ namespace storm {
// Intentionally left empty.
}
FormulaParser::FormulaParser(storm::prism::Program const& program) : manager(program.getManager().getSharedPointer()), grammar(new FormulaParserGrammar(manager)) {
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());

3
src/storm/parser/FormulaParser.h

@ -29,6 +29,7 @@ namespace storm {
explicit FormulaParser(std::shared_ptr<storm::expressions::ExpressionManager const> const& manager);
explicit FormulaParser(std::shared_ptr<storm::expressions::ExpressionManager> const& manager);
explicit FormulaParser(storm::prism::Program const& program);
explicit FormulaParser(storm::prism::Program& program);
FormulaParser(FormulaParser const& other);
FormulaParser& operator=(FormulaParser const& other);
@ -67,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<storm::expressions::ExpressionManager const> manager;

48
src/storm/parser/FormulaParserGrammar.cpp

@ -16,8 +16,7 @@ namespace storm {
// Register all variables so we can parse them in the expressions.
for (auto variableTypePair : *constManager) {
identifiers_.add(variableTypePair.first.getName(), variableTypePair.first);
}
}
// Set the identifier mapping to actually generate expressions.
expressionParser.setIdentifierMapping(&identifiers_);
@ -54,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)];
@ -123,7 +125,15 @@ namespace storm {
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");
start = qi::eps > (((-formulaName >> stateFormula)[phoenix::bind(&FormulaParserGrammar::addProperty, phoenix::ref(*this), qi::_val, qi::_1, qi::_2)] | 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;
#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.
@ -195,15 +205,6 @@ namespace storm {
addIdentifierExpression(name, newVariable);
}
void FormulaParserGrammar::addProperty(std::vector<storm::jani::Property>& properties, boost::optional<std::string> const& name, std::shared_ptr<storm::logic::Formula const> const& formula) {
if (name) {
properties.emplace_back(name.get(), formula);
} else {
properties.emplace_back(std::to_string(propertyCount), formula);
}
++propertyCount;
}
bool FormulaParserGrammar::areConstantDefinitionsAllowed() const {
return static_cast<bool>(manager);
}
@ -327,5 +328,26 @@ namespace storm {
std::shared_ptr<storm::logic::Formula const> FormulaParserGrammar::createMultiObjectiveFormula(std::vector<std::shared_ptr<storm::logic::Formula const>> const& subformulas) {
return std::shared_ptr<storm::logic::Formula const>(new storm::logic::MultiObjectiveFormula(subformulas));
}
storm::jani::Property FormulaParserGrammar::createProperty(boost::optional<std::string> const& propertyName, storm::modelchecker::FilterType const& filterType, std::shared_ptr<storm::logic::Formula const> 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<std::string> const& propertyName, std::shared_ptr<storm::logic::Formula const> const& formula) {
++propertyCount;
if (propertyName) {
return storm::jani::Property(propertyName.get(), formula);
} else {
return storm::jani::Property(std::to_string(propertyCount), formula);
}
}
}
}

26
src/storm/parser/FormulaParserGrammar.h

@ -9,6 +9,8 @@
#include "storm/logic/Formulas.h"
#include "storm/parser/ExpressionParser.h"
#include "storm/modelchecker/results/FilterType.h"
#include "storm/storage/expressions/ExpressionEvaluator.h"
namespace storm {
@ -111,6 +113,25 @@ namespace storm {
// A parser used for recognizing the reward measure types.
rewardMeasureTypeStruct rewardMeasureType_;
struct filterTypeStruct : qi::symbols<char, storm::modelchecker::FilterType> {
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<storm::expressions::ExpressionManager const> constManager;
std::shared_ptr<storm::expressions::ExpressionManager> manager;
@ -135,12 +156,14 @@ namespace storm {
qi::rule<Iterator, std::shared_ptr<storm::logic::Formula const>(), Skipper> timeOperator;
qi::rule<Iterator, std::shared_ptr<storm::logic::Formula const>(), Skipper> longRunAverageOperator;
qi::rule<Iterator, storm::jani::Property(), Skipper> filterProperty;
qi::rule<Iterator, std::shared_ptr<storm::logic::Formula const>(), Skipper> simpleFormula;
qi::rule<Iterator, std::shared_ptr<storm::logic::Formula const>(), Skipper> stateFormula;
qi::rule<Iterator, std::shared_ptr<storm::logic::Formula const>(storm::logic::FormulaContext), Skipper> pathFormula;
qi::rule<Iterator, std::shared_ptr<storm::logic::Formula const>(storm::logic::FormulaContext), Skipper> pathFormulaWithoutUntil;
qi::rule<Iterator, std::shared_ptr<storm::logic::Formula const>(), Skipper> simplePathFormula;
qi::rule<Iterator, std::shared_ptr<storm::logic::Formula const>(), Skipper> atomicStateFormula;
qi::rule<Iterator, std::shared_ptr<storm::logic::Formula const>(), Skipper> atomicStateFormulaWithoutExpression;
qi::rule<Iterator, std::shared_ptr<storm::logic::Formula const>(), Skipper> operatorFormula;
qi::rule<Iterator, std::string(), Skipper> label;
qi::rule<Iterator, std::string(), Skipper> rewardModelName;
@ -200,6 +223,9 @@ namespace storm {
std::shared_ptr<storm::logic::Formula const> createUnaryBooleanStateFormula(std::shared_ptr<storm::logic::Formula const> const& subformula, boost::optional<storm::logic::UnaryBooleanStateFormula::OperatorType> const& operatorType);
std::shared_ptr<storm::logic::Formula const> createMultiObjectiveFormula(std::vector<std::shared_ptr<storm::logic::Formula const>> const& subformulas);
storm::jani::Property createProperty(boost::optional<std::string> const& propertyName, storm::modelchecker::FilterType const& filterType, std::shared_ptr<storm::logic::Formula const> const& formula);
storm::jani::Property createPropertyWithDefaultFilterType(boost::optional<std::string> const& propertyName, std::shared_ptr<storm::logic::Formula const> const& formula);
// An error handler function.
phoenix::function<SpiritErrorHandler> handler;

2
src/storm/parser/PrismParser.cpp

@ -99,7 +99,7 @@ namespace storm {
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)];

1
src/storm/settings/modules/IOSettings.cpp

@ -195,7 +195,6 @@ namespace storm {
return storm::parser::parseCommaSeperatedValues(this->getOption(janiPropertyOptionName).getArgumentByName("values").getValueAsString());
}
bool IOSettings::isPrismCompatibilityEnabled() const {
return this->getOption(prismCompatibilityOptionName).getHasOptionBeenSet();
}

40
src/storm/solver/EigenLinearEquationSolver.cpp

@ -140,6 +140,9 @@ namespace storm {
solver.compute(*this->eigenA);
solver._solve_impl(eigenB, eigenX);
} else {
bool converged = false;
uint64_t numberOfIterations = 0;
typename EigenLinearEquationSolverSettings<ValueType>::Preconditioner preconditioner = this->getSettings().getPreconditioner();
if (solutionMethod == EigenLinearEquationSolverSettings<ValueType>::SolutionMethod::BiCGSTAB) {
if (preconditioner == EigenLinearEquationSolverSettings<ValueType>::Preconditioner::Ilu) {
@ -148,21 +151,24 @@ namespace storm {
solver.setTolerance(this->getSettings().getPrecision());
solver.setMaxIterations(this->getSettings().getMaximalNumberOfIterations());
eigenX = solver.solveWithGuess(eigenB, eigenX);
return solver.info() == StormEigen::ComputationInfo::Success;
converged = solver.info() == StormEigen::ComputationInfo::Success;
numberOfIterations = solver.iterations();
} else if (preconditioner == EigenLinearEquationSolverSettings<ValueType>::Preconditioner::Diagonal) {
StormEigen::BiCGSTAB<StormEigen::SparseMatrix<ValueType>, StormEigen::DiagonalPreconditioner<ValueType>> solver;
solver.setTolerance(this->getSettings().getPrecision());
solver.setMaxIterations(this->getSettings().getMaximalNumberOfIterations());
solver.compute(*this->eigenA);
eigenX = solver.solveWithGuess(eigenB, eigenX);
return solver.info() == StormEigen::ComputationInfo::Success;
converged = solver.info() == StormEigen::ComputationInfo::Success;
numberOfIterations = solver.iterations();
} else {
StormEigen::BiCGSTAB<StormEigen::SparseMatrix<ValueType>, StormEigen::IdentityPreconditioner> solver;
solver.setTolerance(this->getSettings().getPrecision());
solver.setMaxIterations(this->getSettings().getMaximalNumberOfIterations());
solver.compute(*this->eigenA);
eigenX = solver.solveWithGuess(eigenB, eigenX);
return solver.info() == StormEigen::ComputationInfo::Success;
numberOfIterations = solver.iterations();
converged = solver.info() == StormEigen::ComputationInfo::Success;
}
} else if (solutionMethod == EigenLinearEquationSolverSettings<ValueType>::SolutionMethod::DGMRES) {
if (preconditioner == EigenLinearEquationSolverSettings<ValueType>::Preconditioner::Ilu) {
@ -172,7 +178,8 @@ namespace storm {
solver.set_restart(this->getSettings().getNumberOfIterationsUntilRestart());
solver.compute(*this->eigenA);
eigenX = solver.solveWithGuess(eigenB, eigenX);
return solver.info() == StormEigen::ComputationInfo::Success;
converged = solver.info() == StormEigen::ComputationInfo::Success;
numberOfIterations = solver.iterations();
} else if (preconditioner == EigenLinearEquationSolverSettings<ValueType>::Preconditioner::Diagonal) {
StormEigen::DGMRES<StormEigen::SparseMatrix<ValueType>, StormEigen::DiagonalPreconditioner<ValueType>> solver;
solver.setTolerance(this->getSettings().getPrecision());
@ -180,7 +187,8 @@ namespace storm {
solver.set_restart(this->getSettings().getNumberOfIterationsUntilRestart());
solver.compute(*this->eigenA);
eigenX = solver.solveWithGuess(eigenB, eigenX);
return solver.info() == StormEigen::ComputationInfo::Success;
converged = solver.info() == StormEigen::ComputationInfo::Success;
numberOfIterations = solver.iterations();
} else {
StormEigen::DGMRES<StormEigen::SparseMatrix<ValueType>, StormEigen::IdentityPreconditioner> solver;
solver.setTolerance(this->getSettings().getPrecision());
@ -188,7 +196,8 @@ namespace storm {
solver.set_restart(this->getSettings().getNumberOfIterationsUntilRestart());
solver.compute(*this->eigenA);
eigenX = solver.solveWithGuess(eigenB, eigenX);
return solver.info() == StormEigen::ComputationInfo::Success;
converged = solver.info() == StormEigen::ComputationInfo::Success;
numberOfIterations = solver.iterations();
}
} else if (solutionMethod == EigenLinearEquationSolverSettings<ValueType>::SolutionMethod::GMRES) {
if (preconditioner == EigenLinearEquationSolverSettings<ValueType>::Preconditioner::Ilu) {
@ -198,7 +207,8 @@ namespace storm {
solver.set_restart(this->getSettings().getNumberOfIterationsUntilRestart());
solver.compute(*this->eigenA);
eigenX = solver.solveWithGuess(eigenB, eigenX);
return solver.info() == StormEigen::ComputationInfo::Success;
converged = solver.info() == StormEigen::ComputationInfo::Success;
numberOfIterations = solver.iterations();
} else if (preconditioner == EigenLinearEquationSolverSettings<ValueType>::Preconditioner::Diagonal) {
StormEigen::GMRES<StormEigen::SparseMatrix<ValueType>, StormEigen::DiagonalPreconditioner<ValueType>> solver;
solver.setTolerance(this->getSettings().getPrecision());
@ -206,7 +216,8 @@ namespace storm {
solver.set_restart(this->getSettings().getNumberOfIterationsUntilRestart());
solver.compute(*this->eigenA);
eigenX = solver.solveWithGuess(eigenB, eigenX);
return solver.info() == StormEigen::ComputationInfo::Success;
converged = solver.info() == StormEigen::ComputationInfo::Success;
numberOfIterations = solver.iterations();
} else {
StormEigen::GMRES<StormEigen::SparseMatrix<ValueType>, StormEigen::IdentityPreconditioner> solver;
solver.setTolerance(this->getSettings().getPrecision());
@ -214,10 +225,21 @@ namespace storm {
solver.set_restart(this->getSettings().getNumberOfIterationsUntilRestart());
solver.compute(*this->eigenA);
eigenX = solver.solveWithGuess(eigenB, eigenX);
return solver.info() == StormEigen::ComputationInfo::Success;
converged = solver.info() == StormEigen::ComputationInfo::Success;
numberOfIterations = solver.iterations();
}
}
// Check if the solver converged and issue a warning otherwise.
if (converged) {
STORM_LOG_DEBUG("Iterative solver converged after " << numberOfIterations << " iterations.");
return true;
} else {
STORM_LOG_WARN("Iterative solver did not converge.");
return false;
}
}
return false;
}

8
src/storm/solver/GmmxxLinearEquationSolver.cpp

@ -138,7 +138,7 @@ namespace storm {
bool GmmxxLinearEquationSolver<ValueType>::solveEquations(std::vector<ValueType>& x, std::vector<ValueType> const& b) const {
auto method = this->getSettings().getSolutionMethod();
auto preconditioner = this->getSettings().getPreconditioner();
STORM_LOG_INFO("Using method '" << method << "' with preconditioner '" << preconditioner << "' (max. " << this->getSettings().getMaximalNumberOfIterations() << " iterations).");
STORM_LOG_DEBUG("Using method '" << method << "' with preconditioner '" << preconditioner << "' (max. " << this->getSettings().getMaximalNumberOfIterations() << " iterations).");
if (method == GmmxxLinearEquationSolverSettings<ValueType>::SolutionMethod::Jacobi && preconditioner != GmmxxLinearEquationSolverSettings<ValueType>::Preconditioner::None) {
STORM_LOG_WARN("Jacobi method currently does not support preconditioners. The requested preconditioner will be ignored.");
}
@ -187,13 +187,13 @@ namespace storm {
}
}
if(!this->isCachingEnabled()) {
if (!this->isCachingEnabled()) {
clearCache();
}
// Check if the solver converged and issue a warning otherwise.
if (iter.converged()) {
STORM_LOG_INFO("Iterative solver converged after " << iter.get_iteration() << " iterations.");
STORM_LOG_DEBUG("Iterative solver converged after " << iter.get_iteration() << " iterations.");
return true;
} else {
STORM_LOG_WARN("Iterative solver did not converge.");
@ -204,7 +204,7 @@ namespace storm {
// Check if the solver converged and issue a warning otherwise.
if (iterations < this->getSettings().getMaximalNumberOfIterations()) {
STORM_LOG_INFO("Iterative solver converged after " << iterations << " iterations.");
STORM_LOG_DEBUG("Iterative solver converged after " << iterations << " iterations.");
return true;
} else {
STORM_LOG_WARN("Iterative solver did not converge.");

6
src/storm/solver/NativeLinearEquationSolver.cpp

@ -110,7 +110,7 @@ namespace storm {
template<typename ValueType>
bool NativeLinearEquationSolver<ValueType>::solveEquations(std::vector<ValueType>& x, std::vector<ValueType> const& b) const {
if(!this->cachedRowVector) {
if (!this->cachedRowVector) {
this->cachedRowVector = std::make_unique<std::vector<ValueType>>(getMatrixRowCount());
}
@ -180,7 +180,7 @@ namespace storm {
std::swap(x, *currentX);
}
if(!this->isCachingEnabled()) {
if (!this->isCachingEnabled()) {
clearCache();
}
@ -208,7 +208,7 @@ namespace storm {
result.swap(*this->cachedRowVector);
}
if(!this->isCachingEnabled()) {
if (!this->isCachingEnabled()) {
clearCache();
}
}

28
src/storm/solver/SymbolicLinearEquationSolver.cpp

@ -37,7 +37,10 @@ namespace storm {
storm::dd::Add<DdType, ValueType> lu = diagonal.ite(this->A.getDdManager().template getAddZero<ValueType>(), this->A);
storm::dd::Add<DdType> diagonalAdd = diagonal.template toAdd<ValueType>();
storm::dd::Add<DdType, ValueType> dinv = diagonalAdd / (diagonalAdd * this->A);
storm::dd::Add<DdType, ValueType> diag = diagonalAdd.multiplyMatrix(this->A, this->columnMetaVariables);
storm::dd::Add<DdType, ValueType> scaledLu = lu / diag;
storm::dd::Add<DdType, ValueType> scaledB = b / diag;
// Set up additional environment variables.
storm::dd::Add<DdType, ValueType> xCopy = x;
@ -46,24 +49,23 @@ namespace storm {
while (!converged && iterationCount < maximalNumberOfIterations) {
storm::dd::Add<DdType, ValueType> xCopyAsColumn = xCopy.swapVariables(this->rowColumnMetaVariablePairs);
storm::dd::Add<DdType, ValueType> tmp = lu.multiplyMatrix(xCopyAsColumn, this->columnMetaVariables);
tmp = b - tmp;
tmp = tmp.swapVariables(this->rowColumnMetaVariablePairs);
tmp = dinv.multiplyMatrix(tmp, this->columnMetaVariables);
storm::dd::Add<DdType, ValueType> tmp = scaledB - scaledLu.multiplyMatrix(xCopyAsColumn, this->columnMetaVariables);
// Now check if the process already converged within our precision.
converged = xCopy.equalModuloPrecision(tmp, precision, relative);
// If the method did not converge yet, we prepare the x vector for the next iteration.
if (!converged) {
xCopy = tmp;
}
converged = tmp.equalModuloPrecision(xCopy, precision, relative);
xCopy = tmp;
// Increase iteration count so we can abort if convergence is too slow.
++iterationCount;
}
if (converged) {
STORM_LOG_TRACE("Iterative solver converged in " << iterationCount << " iterations.");
} else {
STORM_LOG_WARN("Iterative solver did not converge in " << iterationCount << " iterations.");
}
return xCopy;
}

2
src/storm/solver/SymbolicLinearEquationSolver.h

@ -83,7 +83,7 @@ namespace storm {
protected:
// The matrix defining the coefficients of the linear equation system.
storm::dd::Add<DdType, ValueType> const& A;
storm::dd::Add<DdType, ValueType> A;
// A BDD characterizing all rows of the equation system.
storm::dd::Bdd<DdType> const& allRows;

15
src/storm/solver/SymbolicMinMaxLinearEquationSolver.cpp

@ -43,8 +43,6 @@ namespace storm {
tmp += b;
if (minimize) {
// This is a hack and only here because of the lack of a suitable minAbstract/maxAbstract function
// that can properly deal with a restriction of the choices.
tmp += illegalMaskAdd;
tmp = tmp.minAbstract(this->choiceVariables);
} else {
@ -54,14 +52,17 @@ namespace storm {
// Now check if the process already converged within our precision.
converged = xCopy.equalModuloPrecision(tmp, precision, relative);
// If the method did not converge yet, we prepare the x vector for the next iteration.
if (!converged) {
xCopy = tmp;
}
xCopy = tmp;
++iterations;
}
if (converged) {
STORM_LOG_TRACE("Iterative solver converged in " << iterations << " iterations.");
} else {
STORM_LOG_WARN("Iterative solver did not converge in " << iterations << " iterations.");
}
return xCopy;
}

13
src/storm/storage/SparseMatrix.cpp

@ -1295,19 +1295,6 @@ namespace storm {
}
}
template<typename ValueType>
std::size_t SparseMatrix<ValueType>::getSizeInBytes() const {
uint_fast64_t size = sizeof(*this);
// Add size of columns and values.
size += sizeof(MatrixEntry<index_type, ValueType>) * columnsAndValues.capacity();
// Add row_indications size.
size += sizeof(uint_fast64_t) * rowIndications.capacity();
return size;
}
template<typename ValueType>
typename SparseMatrix<ValueType>::const_rows SparseMatrix<ValueType>::getRows(index_type startRow, index_type endRow) const {
return const_rows(this->columnsAndValues.begin() + this->rowIndications[startRow], this->rowIndications[endRow] - this->rowIndications[startRow]);

7
src/storm/storage/SparseMatrix.h

@ -846,13 +846,6 @@ namespace storm {
* @out The stream to output to.
*/
void printAsMatlabMatrix(std::ostream& out) const;
/*!
* Returns the size of the matrix in memory measured in bytes.
*
* @return The size of the matrix in memory measured in bytes.
*/
std::size_t getSizeInBytes() const;
/*!
* Calculates a hash value over all values contained in the matrix.

12
src/storm/storage/SymbolicModelDescription.cpp

@ -126,6 +126,18 @@ namespace storm {
}
}
std::pair<SymbolicModelDescription, std::map<std::string, std::string>> SymbolicModelDescription::toJaniWithLabelRenaming(bool makeVariablesGlobal) const {
if (this->isJaniModel()) {
return std::make_pair(*this, std::map<std::string, std::string>());
}
if (this->isPrismProgram()) {
auto modelAndRenaming = this->asPrismProgram().toJaniWithLabelRenaming(makeVariablesGlobal);
return std::make_pair(SymbolicModelDescription(modelAndRenaming.first), modelAndRenaming.second);
} else {
STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Cannot transform model description to the JANI format.");
}
}
SymbolicModelDescription SymbolicModelDescription::preprocess(std::string const& constantDefinitionString) const {
std::map<storm::expressions::Variable, storm::expressions::Expression> substitution = parseConstantDefinitions(constantDefinitionString);
if (this->isJaniModel()) {

1
src/storm/storage/SymbolicModelDescription.h

@ -39,6 +39,7 @@ namespace storm {
std::vector<std::string> getParameterNames() const;
SymbolicModelDescription toJani(bool makeVariablesGlobal = true) const;
std::pair<SymbolicModelDescription, std::map<std::string, std::string>> toJaniWithLabelRenaming(bool makeVariablesGlobal = true) const;
SymbolicModelDescription preprocess(std::string const& constantDefinitionString = "") const;
SymbolicModelDescription preprocess(std::map<storm::expressions::Variable, storm::expressions::Expression> const& constantDefinitions) const;

50
src/storm/storage/dd/Add.cpp

@ -550,7 +550,11 @@ namespace storm {
// Next, we split the matrix into one for each group. Note that this only works if the group variables are
// at the very top.
std::vector<InternalAdd<LibraryType, ValueType>> groups = internalAdd.splitIntoGroups(ddGroupVariableIndices);
std::vector<InternalAdd<LibraryType, ValueType>> internalAddGroups = internalAdd.splitIntoGroups(ddGroupVariableIndices);
std::vector<Add<LibraryType, ValueType>> groups;
for (auto const& internalAdd : internalAddGroups) {
groups.push_back(Add<LibraryType, ValueType>(this->getDdManager(), internalAdd, rowAndColumnMetaVariables));
}
// Create the actual storage for the non-zero entries.
std::vector<storm::storage::MatrixEntry<uint_fast64_t, ValueType>> columnsAndValues(this->getNonZeroCount());
@ -561,17 +565,20 @@ namespace storm {
std::vector<InternalAdd<LibraryType, uint_fast64_t>> statesWithGroupEnabled(groups.size());
InternalAdd<LibraryType, uint_fast64_t> stateToRowGroupCount = this->getDdManager().template getAddZero<uint_fast64_t>();
for (uint_fast64_t i = 0; i < groups.size(); ++i) {
auto const& dd = groups[i];
auto const& group = groups[i];
auto groupNotZero = group.notZero();
dd.toMatrixComponents(rowGroupIndices, rowIndications, columnsAndValues, rowOdd, columnOdd, ddRowVariableIndices, ddColumnVariableIndices, false);
std::vector<uint64_t> tmpRowIndications = groupNotZero.template toAdd<uint_fast64_t>().sumAbstract(columnMetaVariables).toVector(rowOdd);
for (uint64_t offset = 0; offset < tmpRowIndications.size(); ++offset) {
rowIndications[rowGroupIndices[offset]] += tmpRowIndications[offset];
}
statesWithGroupEnabled[i] = dd.notZero().existsAbstract(columnVariableCube).template toAdd<uint_fast64_t>();
stateToRowGroupCount += statesWithGroupEnabled[i];
statesWithGroupEnabled[i] = groupNotZero.existsAbstract(columnMetaVariables).template toAdd<uint_fast64_t>();
statesWithGroupEnabled[i].composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::plus<uint_fast64_t>());
}
// Since we modified the rowGroupIndices, we need to restore the correct values.
stateToRowGroupCount.composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::minus<uint_fast64_t>());
stateToNumberOfChoices.internalAdd.composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::minus<uint_fast64_t>());
// Now that we computed the number of entries in each row, compute the corresponding offsets in the entry vector.
tmp = 0;
@ -585,15 +592,15 @@ namespace storm {
// Now actually fill the entry vector.
for (uint_fast64_t i = 0; i < groups.size(); ++i) {
auto const& dd = groups[i];
auto const& group = groups[i];
dd.toMatrixComponents(rowGroupIndices, rowIndications, columnsAndValues, rowOdd, columnOdd, ddRowVariableIndices, ddColumnVariableIndices, true);
group.internalAdd.toMatrixComponents(rowGroupIndices, rowIndications, columnsAndValues, rowOdd, columnOdd, ddRowVariableIndices, ddColumnVariableIndices, true);
statesWithGroupEnabled[i].composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::plus<uint_fast64_t>());
}
// Since we modified the rowGroupIndices, we need to restore the correct values.
stateToRowGroupCount.composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::minus<uint_fast64_t>());
stateToNumberOfChoices.internalAdd.composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::minus<uint_fast64_t>());
// Since the last call to toMatrixRec modified the rowIndications, we need to restore the correct values.
for (uint_fast64_t i = rowIndications.size() - 1; i > 0; --i) {
@ -674,7 +681,11 @@ namespace storm {
std::vector<ValueType> explicitVector(rowGroupIndices.back());
// Next, we split the matrix into one for each group. Note that this only works if the group variables are at the very top.
std::vector<std::pair<InternalAdd<LibraryType, ValueType>, InternalAdd<LibraryType, ValueType>>> groups = internalAdd.splitIntoGroups(vector, ddGroupVariableIndices);
std::vector<std::pair<InternalAdd<LibraryType, ValueType>, InternalAdd<LibraryType, ValueType>>> internalAddGroups = internalAdd.splitIntoGroups(vector, ddGroupVariableIndices);
std::vector<std::pair<Add<LibraryType, ValueType>, Add<LibraryType, ValueType>>> groups;
for (auto const& internalAdd : internalAddGroups) {
groups.push_back(std::make_pair(Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.first, rowAndColumnMetaVariables), Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.second, rowMetaVariables)));
}
// Create the actual storage for the non-zero entries.
std::vector<storm::storage::MatrixEntry<uint_fast64_t, ValueType>> columnsAndValues(this->getNonZeroCount());
@ -685,12 +696,18 @@ namespace storm {
std::vector<InternalAdd<LibraryType, uint_fast64_t>> statesWithGroupEnabled(groups.size());
InternalAdd<LibraryType, uint_fast64_t> stateToRowGroupCount = this->getDdManager().template getAddZero<uint_fast64_t>();
for (uint_fast64_t i = 0; i < groups.size(); ++i) {
std::pair<InternalAdd<LibraryType, ValueType>, InternalAdd<LibraryType, ValueType>> const& ddPair = groups[i];
ddPair.first.toMatrixComponents(rowGroupIndices, rowIndications, columnsAndValues, rowOdd, columnOdd, ddRowVariableIndices, ddColumnVariableIndices, false);
ddPair.second.composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, explicitVector, std::plus<ValueType>());
std::pair<Add<LibraryType, ValueType>, Add<LibraryType, ValueType>> const& ddPair = groups[i];
Bdd<LibraryType> matrixDdNotZero = ddPair.first.notZero();
Bdd<LibraryType> vectorDdNotZero = ddPair.second.notZero();
std::vector<uint64_t> tmpRowIndications = matrixDdNotZero.template toAdd<uint_fast64_t>().sumAbstract(columnMetaVariables).toVector(rowOdd);
for (uint64_t offset = 0; offset < tmpRowIndications.size(); ++offset) {
rowIndications[rowGroupIndices[offset]] += tmpRowIndications[offset];
}
ddPair.second.internalAdd.composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, explicitVector, std::plus<ValueType>());
statesWithGroupEnabled[i] = (ddPair.first.notZero().existsAbstract(columnVariableCube) || ddPair.second.notZero()).template toAdd<uint_fast64_t>();
statesWithGroupEnabled[i] = (matrixDdNotZero.existsAbstract(columnMetaVariables) || vectorDdNotZero).template toAdd<uint_fast64_t>();
stateToRowGroupCount += statesWithGroupEnabled[i];
statesWithGroupEnabled[i].composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::plus<uint_fast64_t>());
}
@ -712,8 +729,7 @@ namespace storm {
for (uint_fast64_t i = 0; i < groups.size(); ++i) {
auto const& dd = groups[i].first;
dd.toMatrixComponents(rowGroupIndices, rowIndications, columnsAndValues, rowOdd, columnOdd, ddRowVariableIndices, ddColumnVariableIndices, true);
dd.internalAdd.toMatrixComponents(rowGroupIndices, rowIndications, columnsAndValues, rowOdd, columnOdd, ddRowVariableIndices, ddColumnVariableIndices, true);
statesWithGroupEnabled[i].composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::plus<uint_fast64_t>());
}

2
src/storm/storage/dd/Bdd.h

@ -35,7 +35,7 @@ namespace storm {
Bdd& operator=(Bdd<LibraryType> const& other) = default;
Bdd(Bdd<LibraryType>&& other) = default;
Bdd& operator=(Bdd<LibraryType>&& other) = default;
/*!
* Constructs a BDD representation of all encodings that are in the requested relation with the given value.
*

13
src/storm/storage/dd/DdManager.cpp

@ -111,8 +111,17 @@ namespace storm {
template<DdType LibraryType>
Bdd<LibraryType> DdManager<LibraryType>::getCube(storm::expressions::Variable const& variable) const {
storm::dd::DdMetaVariable<LibraryType> const& metaVariable = this->getMetaVariable(variable);
return metaVariable.getCube();
return getCube({variable});
}
template<DdType LibraryType>
Bdd<LibraryType> DdManager<LibraryType>::getCube(std::set<storm::expressions::Variable> const& variables) const {
Bdd<LibraryType> result = this->getBddOne();
for (auto const& variable : variables) {
storm::dd::DdMetaVariable<LibraryType> const& metaVariable = this->getMetaVariable(variable);
result &= metaVariable.getCube();
}
return result;
}
template<DdType LibraryType>

10
src/storm/storage/dd/DdManager.h

@ -125,7 +125,15 @@ namespace storm {
* @return The cube of the meta variable.
*/
Bdd<LibraryType> getCube(storm::expressions::Variable const& variable) const;
/*!
* Retrieves a BDD that is the cube of the variables representing the given meta variables.
*
* @param variables The expression variables associated with the meta variables.
* @return The cube of the meta variables.
*/
Bdd<LibraryType> getCube(std::set<storm::expressions::Variable> const& variables) const;
/*!
* Adds an integer meta variable with the given range.
*

2
src/storm/storage/dd/cudd/InternalCuddAdd.cpp

@ -17,7 +17,7 @@ namespace storm {
InternalAdd<DdType::CUDD, ValueType>::InternalAdd(InternalDdManager<DdType::CUDD> const* ddManager, cudd::ADD cuddAdd) : ddManager(ddManager), cuddAdd(cuddAdd) {
// Intentionally left empty.
}
template<typename ValueType>
bool InternalAdd<DdType::CUDD, ValueType>::operator==(InternalAdd<DdType::CUDD, ValueType> const& other) const {
return this->getCuddAdd() == other.getCuddAdd();

5
src/storm/storage/dd/sylvan/InternalSylvanAdd.cpp

@ -14,6 +14,11 @@
namespace storm {
namespace dd {
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType>::InternalAdd() : ddManager(nullptr), sylvanMtbdd() {
// Intentionally left empty.
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType>::InternalAdd(InternalDdManager<DdType::Sylvan> const* ddManager, sylvan::Mtbdd const& sylvanMtbdd) : ddManager(ddManager), sylvanMtbdd(sylvanMtbdd) {
// Intentionally left empty.

4
src/storm/storage/dd/sylvan/InternalSylvanAdd.h

@ -55,12 +55,12 @@ namespace storm {
InternalAdd(InternalDdManager<DdType::Sylvan> const* ddManager, sylvan::Mtbdd const& sylvanMtbdd);
// Instantiate all copy/move constructors/assignments with the default implementation.
InternalAdd() = default;
InternalAdd();
InternalAdd(InternalAdd<DdType::Sylvan, ValueType> const& other) = default;
InternalAdd& operator=(InternalAdd<DdType::Sylvan, ValueType> const& other) = default;
InternalAdd(InternalAdd<DdType::Sylvan, ValueType>&& other) = default;
InternalAdd& operator=(InternalAdd<DdType::Sylvan, ValueType>&& other) = default;
/*!
* Retrieves whether the two DDs represent the same function.
*

4
src/storm/storage/dd/sylvan/InternalSylvanBdd.cpp

@ -18,6 +18,10 @@
namespace storm {
namespace dd {
InternalBdd<DdType::Sylvan>::InternalBdd() : ddManager(nullptr), sylvanBdd() {
// Intentionally left empty.
}
InternalBdd<DdType::Sylvan>::InternalBdd(InternalDdManager<DdType::Sylvan> const* ddManager, sylvan::Bdd const& sylvanBdd) : ddManager(ddManager), sylvanBdd(sylvanBdd) {
// Intentionally left empty.
}

2
src/storm/storage/dd/sylvan/InternalSylvanBdd.h

@ -35,7 +35,7 @@ namespace storm {
InternalBdd(InternalDdManager<DdType::Sylvan> const* ddManager, sylvan::Bdd const& sylvanBdd);
// Instantiate all copy/move constructors/assignments with the default implementation.
InternalBdd() = default;
InternalBdd();
InternalBdd(InternalBdd<DdType::Sylvan> const& other) = default;
InternalBdd& operator=(InternalBdd<DdType::Sylvan> const& other) = default;
InternalBdd(InternalBdd<DdType::Sylvan>&& other) = default;

44
src/storm/storage/expressions/ExpressionEvaluator.cpp

@ -1,6 +1,8 @@
#include "storm/storage/expressions/ExpressionEvaluator.h"
#include "storm/storage/expressions/ExpressionManager.h"
#include "storm/utility/constants.h"
namespace storm {
namespace expressions {
ExpressionEvaluator<double>::ExpressionEvaluator(storm::expressions::ExpressionManager const& manager) : ExprtkExpressionEvaluator(manager) {
@ -31,22 +33,52 @@ namespace storm {
}
#ifdef STORM_HAVE_CARL
ExpressionEvaluator<RationalNumber>::ExpressionEvaluator(storm::expressions::ExpressionManager const& manager) : ExpressionEvaluatorWithVariableToExpressionMap<RationalNumber>(manager) {
ExpressionEvaluator<RationalNumber>::ExpressionEvaluator(storm::expressions::ExpressionManager const& manager) : ExprtkExpressionEvaluatorBase<RationalNumber>(manager) {
// Intentionally left empty.
}
void ExpressionEvaluator<RationalNumber>::setBooleanValue(storm::expressions::Variable const& variable, bool value) {
ExprtkExpressionEvaluatorBase<RationalNumber>::setBooleanValue(variable, value);
// Not forwarding value of variable to rational number visitor as it cannot treat boolean variables anyway.
}
void ExpressionEvaluator<RationalNumber>::setIntegerValue(storm::expressions::Variable const& variable, int_fast64_t value) {
ExprtkExpressionEvaluatorBase<RationalNumber>::setIntegerValue(variable, value);
rationalNumberVisitor.setMapping(variable, storm::utility::convertNumber<RationalNumber>(value));
}
void ExpressionEvaluator<RationalNumber>::setRationalValue(storm::expressions::Variable const& variable, double value) {
ExprtkExpressionEvaluatorBase<RationalNumber>::setRationalValue(variable, value);
rationalNumberVisitor.setMapping(variable, storm::utility::convertNumber<RationalNumber>(value));
}
RationalNumber ExpressionEvaluator<RationalNumber>::asRational(Expression const& expression) const {
Expression substitutedExpression = expression.substitute(this->variableToExpressionMap);
return this->rationalNumberVisitor.toRationalNumber(substitutedExpression);
return this->rationalNumberVisitor.toRationalNumber(expression);
}
ExpressionEvaluator<RationalFunction>::ExpressionEvaluator(storm::expressions::ExpressionManager const& manager) : ExpressionEvaluatorWithVariableToExpressionMap<RationalFunction>(manager) {
ExpressionEvaluator<RationalFunction>::ExpressionEvaluator(storm::expressions::ExpressionManager const& manager) : ExprtkExpressionEvaluatorBase<RationalFunction>(manager) {
// Intentionally left empty.
}
void ExpressionEvaluator<RationalFunction>::setBooleanValue(storm::expressions::Variable const& variable, bool value) {
ExprtkExpressionEvaluatorBase<RationalFunction>::setBooleanValue(variable, value);
// Not forwarding value of variable to rational number visitor as it cannot treat boolean variables anyway.
}
void ExpressionEvaluator<RationalFunction>::setIntegerValue(storm::expressions::Variable const& variable, int_fast64_t value) {
ExprtkExpressionEvaluatorBase<RationalFunction>::setIntegerValue(variable, value);
rationalFunctionVisitor.setMapping(variable, storm::utility::convertNumber<RationalFunction>(value));
}
void ExpressionEvaluator<RationalFunction>::setRationalValue(storm::expressions::Variable const& variable, double value) {
ExprtkExpressionEvaluatorBase<RationalFunction>::setRationalValue(variable, value);
rationalFunctionVisitor.setMapping(variable, storm::utility::convertNumber<RationalFunction>(value));
}
RationalFunction ExpressionEvaluator<RationalFunction>::asRational(Expression const& expression) const {
Expression substitutedExpression = expression.substitute(this->variableToExpressionMap);
return this->rationalFunctionVisitor.toRationalFunction(substitutedExpression);
return this->rationalFunctionVisitor.toRationalFunction(expression);
}
template class ExpressionEvaluatorWithVariableToExpressionMap<RationalNumber>;

12
src/storm/storage/expressions/ExpressionEvaluator.h

@ -37,10 +37,14 @@ namespace storm {
#ifdef STORM_HAVE_CARL
template<>
class ExpressionEvaluator<RationalNumber> : public ExpressionEvaluatorWithVariableToExpressionMap<RationalNumber> {
class ExpressionEvaluator<RationalNumber> : public ExprtkExpressionEvaluatorBase<RationalNumber> {
public:
ExpressionEvaluator(storm::expressions::ExpressionManager const& manager);
void setBooleanValue(storm::expressions::Variable const& variable, bool value) override;
void setIntegerValue(storm::expressions::Variable const& variable, int_fast64_t value) override;
void setRationalValue(storm::expressions::Variable const& variable, double value) override;
RationalNumber asRational(Expression const& expression) const override;
private:
@ -49,10 +53,14 @@ namespace storm {
};
template<>
class ExpressionEvaluator<RationalFunction> : public ExpressionEvaluatorWithVariableToExpressionMap<RationalFunction> {
class ExpressionEvaluator<RationalFunction> : public ExprtkExpressionEvaluatorBase<RationalFunction> {
public:
ExpressionEvaluator(storm::expressions::ExpressionManager const& manager);
void setBooleanValue(storm::expressions::Variable const& variable, bool value) override;
void setIntegerValue(storm::expressions::Variable const& variable, int_fast64_t value) override;
void setRationalValue(storm::expressions::Variable const& variable, double value) override;
RationalFunction asRational(Expression const& expression) const override;
private:

Some files were not shown because too many files changed in this diff

|||||||
100:0
Loading…
Cancel
Save