mCRL2
Loading...
Searching...
No Matches
search_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 search_strategy.h
10/// \brief Search strategy when generating a BES from a PBES.
11
12#ifndef MCRL2_PBES_SEARCH_STRATEGY_H
13#define MCRL2_PBES_SEARCH_STRATEGY_H
14
15#include "mcrl2/utilities/exception.h"
16#include <string>
17
18namespace mcrl2::pbes_system
19{
20
21/// \brief Search strategy when generating a BES from a PBES.
23{
24 breadth_first, // Generate the rhs of the last generated BES variable last.
25 depth_first, // Generate the rhs of the last generated BES variable first.
28};
29
30inline
32{
33 if (s == "breadth-first")
34 {
35 return breadth_first;
36 }
37 else if (s == "b")
38 {
40 }
41 else if (s == "depth-first")
42 {
43 return depth_first;
44 }
45 else if (s == "d")
46 {
47 return depth_first_short;
48 }
49 else
50 {
51 throw mcrl2::runtime_error("unknown search strategy " + s);
52 }
53}
54
55inline
57{
58 switch(s)
59 {
60 case breadth_first: return "breadth-first";
61 case depth_first: return "depth-first";
62 case breadth_first_short: return "b";
63 case depth_first_short: return "d";
64 }
65 throw mcrl2::runtime_error("unknown search strategy");
66}
67
68inline
69std::istream& operator>>(std::istream& is, search_strategy& strategy)
70{
71 try
72 {
73 std::string s;
74 is >> s;
75 strategy = parse_search_strategy(s);
76 }
77 catch(mcrl2::runtime_error&)
78 {
79 is.setstate(std::ios_base::failbit);
80 }
81 return is;
82}
83
84inline
85std::ostream& operator<<(std::ostream& os, const search_strategy s)
86{
87 os << print_search_strategy(s);
88 return os;
89}
90
91inline
93{
94 switch(s)
95 {
96 case breadth_first: return "Compute the right hand side of the boolean variables"
97 " in a first come first served basis. This is comparable with a breadth-first search."
98 " This is good for generating counter examples. ";
99 case depth_first: return "Compute the right hand side of a boolean variables where "
100 " the last generated variable is investigated first. This corresponds to a depth-first "
101 " search. This can substantially outperform breadth-first search when the validity of a"
102 " formula is determined at a larger depth. ";
103 case breadth_first_short: return "Shorthand for breadth-first.";
104 case depth_first_short: return "Shorthand for depth-first.";
105 }
106 throw mcrl2::runtime_error("unknown search strategy");
107}
108
109} // namespace mcrl2::pbes_system
110
111
112
113#endif // MCRL2_PBES_SEARCH_STRATEGY_H
Standard exception class for reporting runtime errors.
Definition exception.h:27
search_strategy parse_search_strategy(const std::string &s)
std::string print_search_strategy(const search_strategy s)
std::istream & operator>>(std::istream &is, search_strategy &strategy)
search_strategy
Search strategy when generating a BES from a PBES.
std::string description(const search_strategy s)
std::size_t operator()(const std::vector< X > &v) const