mCRL2
Loading...
Searching...
No Matches
transformation_strategy.h
Go to the documentation of this file.
1// Author(s): Jan Friso Groote, XIAO Qi
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9/// \file transformation_strategy.h
10/// \brief Strategies for the generation of a BES from a PBES.
11
12#ifndef MCRL2_PBES_TRANSFORMATION_STRATEGY_H
13#define MCRL2_PBES_TRANSFORMATION_STRATEGY_H
14
15#include "mcrl2/utilities/exception.h"
16#include <string>
17
18namespace mcrl2::pbes_system
19{
20
21/// \brief Strategies for the generation of a BES from a PBES
23{
24 lazy, // generate equations but do not optimize on the fly
25 optimize, // optimize by substituting true and false for already
26 // investigated variables in a rhs, while generating this rhs.
27 on_the_fly, // make a distinction between variables that occur somewhere,
28 // and variables that do not occur somewhere. When generating
29 // a rhs, optimize this rhs as in "optimize". If the rhs is
30 // equal to T or F, substitute this value throughout the
31 // equation system, and maintain which variables become unused
32 // by doing so, as these do not have to be investigated further.
33 // E.g. if a rhs is X1 && X2, X1 does not occur elsewhere and
34 // X2 turns out to be equal to false, then X1 is moved to the
35 // set of irrelevant variables, and not investigated further.
37 // Do the same as with on the fly, but for each generated variable
38 // in the rhs, investigate whether this variable lies on a loop
39 // such that depending on its fixed point, it can be set to true
40 // or false. Due to the breadth first nature of the main algorithm
41 // the existence of such loops must be investigated separately
42 // for each variable, which can take a lot of time.
43};
44
45inline
47{
48 if (s == "0")
49 {
50 return lazy;
51 }
52 else if (s == "1")
53 {
54 return optimize;
55 }
56 else if (s == "2")
57 {
58 return on_the_fly;
59 }
60 else if (s == "3")
61 {
63 }
64 else
65 {
66 throw mcrl2::runtime_error("unknown transformation strategy " + s);
67 }
68}
69
70inline
72{
73 switch(s)
74 {
75 case lazy: return "0";
76 case optimize: return "1";
77 case on_the_fly: return "2";
78 case on_the_fly_with_fixed_points: return "3";
79 }
80 throw mcrl2::runtime_error("unknown transformation strategy");
81}
82
83inline
84std::istream& operator>>(std::istream& is, transformation_strategy& strategy)
85{
86 try
87 {
88 std::string s;
89 is >> s;
90 strategy = parse_transformation_strategy(s);
91 }
92 catch(mcrl2::runtime_error&)
93 {
94 is.setstate(std::ios_base::failbit);
95 }
96 return is;
97}
98
99inline
100std::ostream& operator<<(std::ostream& os, const transformation_strategy s)
101{
102 os << print_transformation_strategy(s);
103 return os;
104}
105
106inline
108{
109 switch(s)
110 {
111 case lazy: return "Compute all boolean equations which can be reached"
112 " from the initial state, without optimization."
113 " This is is the most data efficient"
114 " option per generated equation.";
115 case optimize: return "Optimize by immediately substituting the right"
116 " hand sides for already investigated variables"
117 " that are true or false when generating an"
118 " expression. This is as memory efficient as 0.";
119 case on_the_fly: return "In addition to 1, also substitute variables that"
120 " are true or false into an already generated right"
121 " hand side. This can mean that certain variables"
122 " become unreachable (e.g. X0 in X0 and X1, when X1"
123 " becomes false, assuming X0 does not occur"
124 " elsewhere. It will be maintained which variables"
125 " have become unreachable as these do not have to be"
126 " investigated. Depending on the PBES, this can"
127 " reduce the size of the generated BES substantially"
128 " but requires a larger memory footprint.";
129 case on_the_fly_with_fixed_points: return "In addition to 2, investigate for generated"
130 " variables whether they occur on a loop, such that"
131 " they can be set to true or false, depending on the"
132 " fixed point symbol. This can increase the time"
133 " needed to generate an equation substantially.";
134 }
135 throw mcrl2::runtime_error("unknown transformation strategy");
136}
137
138} // namespace mcrl2::pbes_system
139
140
141
142#endif // MCRL2_PBES_TRANSFORMATION_STRATEGY_H
Standard exception class for reporting runtime errors.
Definition exception.h:27
std::string description(const transformation_strategy s)
std::istream & operator>>(std::istream &is, transformation_strategy &strategy)
transformation_strategy parse_transformation_strategy(const std::string &s)
transformation_strategy
Strategies for the generation of a BES from a PBES.
std::string print_transformation_strategy(const transformation_strategy s)
std::size_t operator()(const std::vector< X > &v) const