mCRL2
Loading...
Searching...
No Matches
lts_fsm.h
Go to the documentation of this file.
1// Author(s): Jan Friso Groote
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
19#ifndef MCRL2_LTS_LTS_FSM_H
20#define MCRL2_LTS_LTS_FSM_H
21
25
26namespace mcrl2
27{
28namespace lts
29{
30
37class state_label_fsm: public std::vector < std::size_t >
38{
39 public:
43 {}
44
47
50
53 explicit state_label_fsm(const std::vector < std::size_t >& v):
54 std::vector < std::size_t >(v)
55 {}
56
60 {
61 if ((*this).empty())
62 {
63 return l;
64 }
65 return (*this);
66 }
67
70 static state_label_fsm number_to_label(const std::size_t n)
71 {
72 return state_label_fsm(std::vector < std::size_t >(1,n));
73 }
74};
75
78inline std::string pp(const state_label_fsm& label)
79{
80 std::string s;
81 for(const std::size_t& l: label)
82 {
83 s += std::to_string(l) + " ";
84 }
85 return s;
86}
87
88namespace detail
89{
91{
92 public:
95
96 protected:
97
100 std::vector < std::vector < std::string > > m_state_element_values;
101
105 std::vector < std::pair < std::string, std::string > > m_parameters;
106
107 public:
108
109 bool operator==(const lts_fsm_base& other) const
110 {
113 }
114
119 {
120 return lts_fsm;
121 }
122
124 void swap(lts_fsm_base& other)
125 {
127 m_parameters.swap(other.m_parameters);
128 }
129
134 void
136 {
138 m_parameters.clear();
139 }
140
147 const std::vector < std::string >& state_element_values(std::size_t idx) const
148 {
149 assert(idx<m_state_element_values.size());
150 return m_state_element_values[idx];
151 }
152
157 inline std::string state_label_to_string(const state_label_fsm& l) const
158 {
159 std::string s;
160 s = "(";
161 for (std::size_t i=0; i<l.size(); ++i)
162 {
163 s += state_element_value(i,l[i]);
164 if (i+1<l.size())
165 {
166 s += ",";
167 }
168 }
169 s += ")";
170 return s;
171 }
172
179 std::size_t add_state_element_value(std::size_t idx, const std::string& s)
180 {
181 assert(idx<m_state_element_values.size());
182 m_state_element_values[idx].push_back(s);
183 return m_state_element_values[idx].size();
184 }
185
194 std::string state_element_value(std::size_t parameter_index, std::size_t element_index) const
195 {
196 assert(parameter_index<m_state_element_values.size());
197 if (m_state_element_values[parameter_index].size()==0)
198 {
199 // The domain for this parameter has no string; return the string "i"
200 return std::to_string(element_index);
201 }
202 assert(element_index<m_state_element_values[parameter_index].size());
203 return m_state_element_values[parameter_index][element_index];
204 }
205
209 std::vector < std::pair < std::string, std::string > > process_parameters() const
210 {
211 return m_parameters;
212 }
213
218 std::pair < std::string, std::string > process_parameter(std::size_t i) const
219 {
220 assert(i<m_parameters.size());
221 return m_parameters[i];
222 }
223
227 {
228 m_parameters.clear();
230 }
231
236 void add_process_parameter(const std::string& name, const std::string& sort)
237 {
238 assert(m_parameters.size()==m_state_element_values.size());
239 m_parameters.push_back(std::pair<std::string,std::string>(name,sort));
240 m_state_element_values.push_back(std::vector < std::string >());
241 }
242
243
244};
245
246} // end namespace detail
247
254class lts_fsm_t : public lts< state_label_fsm, action_label_string, detail::lts_fsm_base >
255{
256 public:
258
263 void load(const std::string& filename);
264
269 void save(const std::string& filename) const;
270};
271
279 public probabilistic_lts< state_label_fsm,
280 action_label_string,
281 probabilistic_state< std::size_t, mcrl2::utilities::probabilistic_arbitrary_precision_fraction >,
282 detail::lts_fsm_base >
283{
284 public:
285
287
292 void load(const std::string& filename);
293
298 void save(const std::string& filename) const;
299};
300
301} // namespace lts
302} // namespace mcrl2
303
304#endif
This file contains a class that contains labelled transition systems in aut format.
void clear()
Clear the transitions system.
Definition lts_fsm.h:135
const std::vector< std::string > & state_element_values(std::size_t idx) const
Provides the vector of strings that correspond to the values of the number at position idx in a vecto...
Definition lts_fsm.h:147
std::size_t add_state_element_value(std::size_t idx, const std::string &s)
Adds a string to the state element values for the idx-th position in a state vector....
Definition lts_fsm.h:179
bool operator==(const lts_fsm_base &other) const
Definition lts_fsm.h:109
void clear_process_parameters()
Clear the state parameters for this LTS.
Definition lts_fsm.h:226
mcrl2::lts::probabilistic_state< std::size_t, mcrl2::utilities::probabilistic_arbitrary_precision_fraction > probabilistic_state
Definition lts_fsm.h:93
std::vector< std::vector< std::string > > m_state_element_values
state_element_values contain the values that can occur at the i-th position of a state label
Definition lts_fsm.h:100
lts_type type() const
The lts_type of this labelled transition system. In this case lts_fsm.
Definition lts_fsm.h:118
mcrl2::lps::state_probability_pair< std::size_t, mcrl2::utilities::probabilistic_arbitrary_precision_fraction > state_probability_pair
Definition lts_fsm.h:94
std::string state_element_value(std::size_t parameter_index, std::size_t element_index) const
Returns the element_index'th element for the parameter with index parameter_index.
Definition lts_fsm.h:194
std::pair< std::string, std::string > process_parameter(std::size_t i) const
Returns the i-th parameter of the state vectors stored in this LTS.
Definition lts_fsm.h:218
std::vector< std::pair< std::string, std::string > > m_parameters
m_parameters contain the parameters corresponding to the consecutive elements of a state vector....
Definition lts_fsm.h:105
std::vector< std::pair< std::string, std::string > > process_parameters() const
Return the parameters of the state vectors stored in this LTS.
Definition lts_fsm.h:209
void add_process_parameter(const std::string &name, const std::string &sort)
Set the state parameters for this LTS.
Definition lts_fsm.h:236
std::string state_label_to_string(const state_label_fsm &l) const
Pretty print a state value of this FSM.
Definition lts_fsm.h:157
void swap(lts_fsm_base &other)
Standard swap function.
Definition lts_fsm.h:124
The class lts_fsm_t contains labelled transition systems in .fsm format.
Definition lts_fsm.h:255
lts< state_label_fsm, action_label_string, detail::lts_fsm_base > super
Definition lts_fsm.h:257
void load(const std::string &filename)
Save the labelled transition system to file.
void save(const std::string &filename) const
Save the labelled transition system to file.
A class that contains a labelled transition system.
Definition lts.h:83
The class lts_fsm_t contains labelled transition systems in .fsm format.
Definition lts_fsm.h:283
probabilistic_lts< state_label_fsm, action_label_string, probabilistic_state_t, detail::lts_fsm_base > super
Definition lts_fsm.h:286
void save(const std::string &filename) const
Save the labelled transition system to file.
void load(const std::string &filename)
Save the labelled transition system to file.
A class that contains a labelled transition system.
A class that contains a probabilistic state.
This class contains state labels for the fsm format.
Definition lts_fsm.h:38
state_label_fsm(const state_label_fsm &)=default
Copy constructor.
state_label_fsm & operator=(const state_label_fsm &)=default
Copy assignment.
static state_label_fsm number_to_label(const std::size_t n)
Create a state label consisting of a number as the only list element.
Definition lts_fsm.h:70
state_label_fsm()
Default constructor. The label becomes an empty vector.
Definition lts_fsm.h:42
state_label_fsm(const std::vector< std::size_t > &v)
Default constructor. The label is set to the vector v.
Definition lts_fsm.h:53
state_label_fsm operator+(const state_label_fsm &l) const
An operator to concatenate two state labels. Fsm labels cannot be concatenated. Therefore,...
Definition lts_fsm.h:59
std::string pp(const abstraction &x)
Definition data.cpp:39
lts_type
The enumerated type lts_type contains an index for every type type of labelled transition system that...
Definition lts_type.h:37
std::size_t label(const outgoing_pair_t &p)
Label of a pair of a label and target state.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
STL namespace.
This file contains a class that contains labels for probabilistic transitions. These consist of a 64 ...
The file containing the core class for transition systems.