mCRL2
Loading...
Searching...
No Matches
lts2pbes_lts.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
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 mcrl2/pbes/detail/lts2pbes_lts.h
10/// \brief add your file description here.
11
12#ifndef MCRL2_PBES_DETAIL_LTS2PBES_LTS_H
13#define MCRL2_PBES_DETAIL_LTS2PBES_LTS_H
14
15#include "mcrl2/lts/lts_lts.h"
16
17
18
19
20
21namespace mcrl2::pbes_system::detail {
22
23inline
25{
26 const auto& action_labels = ltsspec.action_labels();
27 out << "LTS" << std::endl;
28 for (const auto& tr: ltsspec.get_transitions())
29 {
30 out << tr.from() << " --" << action_labels[tr.label()] << "--> " << tr.to() << std::endl;
31 }
32 return out;
33}
34
35// custom LTS type that maps states to a vector of outgoing edges
37{
38 public:
41
42 struct edge
43 {
44 edge(label_type label_, state_type state_, std::size_t index_)
45 : label(label_),
48 {}
49
53 };
54
56
57 protected:
62
63 public:
64 lts2pbes_lts(const lts::lts_lts_t& ltsspec)
65 {
66 const auto& transitions = ltsspec.get_transitions();
67 for (std::size_t i = 0; i < transitions.size(); i++)
68 {
69 const auto& transition = transitions[i];
70 state_type s = transition.from();
71 label_type a = transition.label();
72 state_type t = transition.to();
73 m_state_map[s].emplace_back(a, t, i);
74 }
75
76 for (const auto& a: ltsspec.action_labels())
77 {
78 m_action_labels.emplace_back(a.actions(), a.time());
79 }
80 m_state_count = ltsspec.num_states();
81 }
82
83 // returns the outgoing edges of state s
85 {
86 auto i = m_state_map.find(s);
87 if (i == m_state_map.end())
88 {
89 return m_empty_edge_list;
90 }
91 else
92 {
93 return i->second;
94 }
95 }
96
98 {
99 return m_action_labels;
100 }
101
103 {
104 return m_state_count;
105 }
106
108 {
109 return m_state_map;
110 }
111};
112
114{
115 const auto& action_labels = ltsspec.action_labels();
116 out << "pbes-LTS" << std::endl;
117 for (const auto& p: ltsspec.state_map())
118 {
119 for (const auto& edge: p.second)
120 {
121 out << edge.index << " " << p.first << " --" << action_labels[edge.label] << "--> " << edge.state << std::endl;
122 }
123 }
124 return out;
125}
126
127} // namespace mcrl2::pbes_system::detail
128
129
130
131
132
133#endif // MCRL2_PBES_DETAIL_LTS2PBES_LTS_H
This class contains labelled transition systems in .lts format.
Definition lts_lts.h:369
lts2pbes_lts(const lts::lts_lts_t &ltsspec)
const std::map< state_type, edge_list > & state_map() const
const edge_list & edges(state_type s) const
std::vector< lps::multi_action > m_action_labels
std::map< state_type, edge_list > m_state_map
const std::vector< lps::multi_action > & action_labels() const
std::ostream & operator<<(std::ostream &out, const lts2pbes_lts &ltsspec)
std::ostream & operator<<(std::ostream &out, const lts::lts_lts_t &ltsspec)
edge(label_type label_, state_type state_, std::size_t index_)