mCRL2
Loading...
Searching...
No Matches
solution_strategy.h
Go to the documentation of this file.
1// Author(s): Jeroen Keiren.
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 solution_strategy.h
10/// \brief Strategies to solve a BES.
11
12#ifndef MCRL2_PBES_SOLUTION_STRATEGY_H
13#define MCRL2_PBES_SOLUTION_STRATEGY_H
14
15#include <fstream>
16#include "mcrl2/utilities/exception.h"
17
18
19
20namespace mcrl2::pbes_system
21{
22
23using solution_strategy_t = enum
24{
25 gauss,
26 small_progr_measures
27};
28
29static
30std::string solution_strategy_to_string(const solution_strategy_t s)
31{
32 switch (s)
33 {
34 case gauss:
35 return "gauss";
36 break;
37 case small_progr_measures:
38 return "spm";
39 break;
40 }
41 throw mcrl2::runtime_error("unknown solution strategy");
42}
43
44static
45std::ostream& operator<<(std::ostream& os, const solution_strategy_t s)
46{
47 os << solution_strategy_to_string(s);
48 return os;
49}
50
51static
52solution_strategy_t parse_solution_strategy(const std::string& s)
53{
54 if (s == "gauss")
55 {
56 return gauss;
57 }
58 else if (s == "spm")
59 {
60 return small_progr_measures;
61 }
62 else
63 {
64 throw mcrl2::runtime_error("unsupported solution strategy '" + s + "'");
65 }
66}
67
68static
69std::istream& operator>>(std::istream& is, solution_strategy_t& s)
70{
71 try
72 {
73 std::string str;
74 is >> str;
75 s = parse_solution_strategy(str);
76 }
77 catch(mcrl2::runtime_error&)
78 {
79 is.setstate(std::ios_base::failbit);
80 }
81 return is;
82}
83
84static
85std::string description(const solution_strategy_t s)
86{
87 switch (s)
88 {
89 case gauss:
90 return "Gauss elimination (inefficient; plain implementation)";
91 break;
92 case small_progr_measures:
93 return "Small progress measures";
94 break;
95 }
96 throw mcrl2::runtime_error("unknown solution strategy");
97}
98
99} // namespace mcrl2::pbes_system
100
101
102
103#endif // MCRL2_PBES_SOLUTION_STRATEGY_H
Standard exception class for reporting runtime errors.
Definition exception.h:27
static std::string solution_strategy_to_string(const solution_strategy_t s)
static solution_strategy_t parse_solution_strategy(const std::string &s)
static std::string description(const solution_strategy_t s)
static std::istream & operator>>(std::istream &is, solution_strategy_t &s)
std::size_t operator()(const std::vector< X > &v) const