28#ifndef MCRL2_LTS_LIBLTS_PLTS_MERGE_H
29#define MCRL2_LTS_LIBLTS_PLTS_MERGE_H
42template <
class LTS_TYPE>
45 const std::size_t old_nstates=l1.num_states();
46 const std::size_t old_n_prob_states = l1.num_probabilistic_states();
47 l1.set_num_states(l1.num_states() + l2.num_states());
51 if (l1.has_state_info() && l2.has_state_info())
53 for (std::size_t i=0; i<l2.num_states(); ++i)
55 l1.add_state(l2.state_label(i));
61 l1.clear_state_labels();
68 typedef typename LTS_TYPE::action_label_t type1;
69 typedef typename LTS_TYPE::labels_size_type type2;
70 typedef typename std::pair< typename std::map < type1,type2 >::const_iterator,
bool > insert_type;
71 std::map < type1,type2 > labs;
74 for (std::size_t i = 0; i < l1.num_action_labels(); ++i)
76 labs.insert(std::pair <typename LTS_TYPE::action_label_t,typename LTS_TYPE::labels_size_type>
77 (l1.action_label(i),i));
87 for (std::size_t i=0; i<l2.num_action_labels(); ++i)
89 typename LTS_TYPE::labels_size_type new_index;
90 const insert_type it= labs.insert(std::pair < type1,type2 >
91 (l2.action_label(i),l1.num_action_labels()));
95 new_index=l1.add_action(l2.action_label(i));
96 if (l2.is_tau(l2.apply_hidden_label_map(i)))
98 l1.hidden_label_set().insert(new_index);
103 new_index=it.first->second;
105 if (l1.is_tau(l1.apply_hidden_label_map(new_index)) != l2.is_tau(l2.apply_hidden_label_map(i)))
108 pp(l1.action_label(l1.apply_hidden_label_map(new_index))) +
" and " +
109 pp(l2.action_label(l2.apply_hidden_label_map(i))) +
".");
113 assert(new_index==it.first->second);
118 std::vector<transition> &trans1=l1.get_transitions();
121 t.set_label(labs[l1.action_label(t.label())]);
128 const std::vector<transition> &trans2=l2.get_transitions();
129 for (
const transition transition_to_add : trans2)
131 l1.add_transition(
transition(transition_to_add.from()+old_nstates,
132 labs[l2.action_label(transition_to_add.label())],
133 transition_to_add.to()+old_n_prob_states));
138 const std::size_t n_prob_states_l2 = l2.num_probabilistic_states();
139 for (std::size_t i = 0; i < n_prob_states_l2; ++i)
141 typename LTS_TYPE::probabilistic_state_t new_prob_state;
142 const typename LTS_TYPE::probabilistic_state_t& old_prob_state = l2.probabilistic_state(i);
144 if (old_prob_state.size()>1)
146 for (
const typename LTS_TYPE::probabilistic_state_t::state_probability_pair& sp_pair : old_prob_state)
148 new_prob_state.add(sp_pair.state()+ old_nstates, sp_pair.probability());
154 new_prob_state.set(old_prob_state.get()+old_nstates);
156 l1.add_probabilistic_state(new_prob_state);
161 l1.add_probabilistic_state(l1.initial_probabilistic_state());
164 typename LTS_TYPE::probabilistic_state_t new_initial_prob_state_l2;
165 if (l2.initial_probabilistic_state().size()<=1)
167 new_initial_prob_state_l2.set(l2.initial_probabilistic_state().get() + old_nstates);
171 for (
const typename LTS_TYPE::probabilistic_state_t::state_probability_pair& sp_pair : l2.initial_probabilistic_state())
173 new_initial_prob_state_l2.add(sp_pair.state() + old_nstates, sp_pair.probability());
176 l1.add_probabilistic_state(new_initial_prob_state_l2);
A class containing triples, source label and target representing transitions.
Standard exception class for reporting runtime errors.
This file contains a class that contains labelled transition systems in aut format.
This file contains a class that contains labelled transition systems in fsm format.
This file contains a class that contains labelled transition systems in lts (mcrl2) format.
std::string pp(const detail::lhs_t &lhs)
void plts_merge(LTS_TYPE &l1, const LTS_TYPE &l2)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...