12#ifndef MCRL2_LPS_PARELM_H
13#define MCRL2_LPS_PARELM_H
18#include <boost/integer.hpp>
31 std::set<data::variable> tmp;
34 result.insert(tmp.begin(), tmp.end());
37 result.insert(tmp.begin(), tmp.end());
45 result.insert(tmp.begin(), tmp.end());
51 std::set<data::variable> tmp;
54 result.insert(tmp.begin(), tmp.end());
57 result.insert(tmp.begin(), tmp.end());
64template <
typename Specification>
77 std::set<data::variable> result;
79 auto const& action_summands =
m_spec.process().action_summands();
80 for (
auto i = action_summands.begin(); i != action_summands.end(); ++i)
85 auto const& deadlock_summands =
m_spec.process().deadlock_summands();
86 for (
auto i = deadlock_summands.begin(); i != deadlock_summands.end(); ++i)
97 std::clog <<
"parelm removed " << to_be_removed.size() <<
" process parameters: " <<std::endl;
100 std::clog << v <<
":" << v.sort() << std::endl;
108#ifdef MCRL2_LPS_PARELM_DEBUG
109 std::clog <<
"--- parelm 1 ---" << std::endl;
112 std::set<data::variable> process_parameters(pars.
begin(),pars.
end());
117#ifdef MCRL2_LPS_PARELM_DEBUG
118 std::clog <<
"initial significant variables: ";
119 for (
auto i = significant_variables.begin(); i != significant_variables.end(); ++i)
121 std::clog << *i <<
" ";
123 std::clog << std::endl;
127 std::set<data::variable> todo = significant_variables;
128 while (!todo.empty())
131 todo.erase(todo.begin());
133 for (
auto i =
m_spec.process().action_summands().begin(); i !=
m_spec.process().action_summands().end(); ++i)
136 auto j = std::find_if(assignments.
begin(), assignments.
end(), [&](
const data::assignment& a) { return a.lhs() == x; });
137 if (j != assignments.
end())
139 std::set<data::variable> vars;
142 todo.insert(new_variables.begin(), new_variables.end());
143 significant_variables.insert(new_variables.begin(), new_variables.end());
144#ifdef MCRL2_LPS_PARELM_DEBUG
145 for (
auto k = new_variables.begin(); k != new_variables.end(); ++k)
147 std::clog <<
"found dependency " << x <<
" -> " << *k << std::endl;
154#ifdef MCRL2_LPS_PARELM_DEBUG
165#ifdef MCRL2_LPS_PARELM_DEBUG
166 std::clog <<
"--- parelm 2 ---" << std::endl;
169 std::set<data::variable> process_parameters(pars.
begin(),pars.
end());
172 std::map<data::variable, std::size_t> m;
176#ifdef MCRL2_LPS_PARELM_DEBUG
177 std::clog <<
"vertex " << index <<
" = " <<
data::pp(*i) << std::endl;
179 m[process_parameter] = index++;
184 std::vector<std::size_t> v;
185 for (
const data::variable& significant_variable: significant_variables)
187 v.push_back(m[significant_variable]);
191 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> graph;
192 graph G(process_parameters.size());
193 for (
auto i =
m_spec.process().action_summands().begin(); i !=
m_spec.process().action_summands().end(); ++i)
197 std::size_t j0 = m[a.lhs()];
198 std::set<data::variable> vars;
202 std::size_t k0 = m[var];
203#ifdef MCRL2_LPS_PARELM_DEBUG
204 std::clog <<
"edge " << j0 <<
" -> " << k0 << std::endl;
206 boost::add_edge(j0, k0, G);
211#ifdef MCRL2_LPS_PARELM_DEBUG
212 std::clog <<
"initial significant variables: ";
213 for (
auto k = v.begin(); k != v.end(); ++k)
215 std::clog << *k <<
" ";
217 std::clog << std::endl;
222#ifdef MCRL2_LPS_PARELM_DEBUG
223 std::clog <<
"reachable nodes: ";
224 for (
auto k = r1.begin(); k != r1.end(); ++k)
226 std::clog << *k <<
" ";
228 std::clog << std::endl;
230 std::set<std::size_t> r2(r1.begin(), r1.end());
231 std::set<data::variable> to_be_removed;
234 if (r2.find(m[process_parameter]) == r2.end())
236 to_be_removed.insert(process_parameter);
239#ifdef MCRL2_LPS_PARELM_DEBUG
255 void run(
bool variant1 =
true)
272template <
typename Specification>
273void parelm(Specification& spec,
bool variant1 =
true)
276 algorithm.
run(variant1);
const_iterator end() const
Returns a const_iterator pointing to the end of the term_list.
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the term_list.
\brief Assignment of a data expression to a variable
const_iterator begin() const
LPS summand containing a multi-action.
const lps::multi_action & multi_action() const
Returns the multi-action of this summand.
LPS summand containing a deadlock.
const lps::deadlock & deadlock() const
Returns the deadlock of this summand.
Algorithm class for algorithms on linear process specifications. It can be instantiated with lps::spe...
bool verbose() const
Flag for verbose output.
lps_algorithm(Specification &spec)
Constructor.
Specification & m_spec
The specification that is processed by the algorithm.
Algorithm class for elimination of unused parameters from a linear process specification.
parelm_algorithm(Specification &spec)
Constructor.
std::set< data::variable > transition_variables()
Returns the data variables that are considered in the parelm algorithm.
void parelm2()
Second version of parelm that builds a dependency graph.
void report_results(const std::set< data::variable > &to_be_removed) const
void run(bool variant1=true)
Runs the parelm algorithm.
void parelm1()
First version of parelm1.
lps::detail::lps_algorithm< Specification > super
LPS summand containing a multi-action.
const stochastic_distribution & distribution() const
Returns the distribution of this summand.
const data::data_expression & condition() const
Returns the condition expression.
Add your file description here.
std::set< data::variable > find_all_variables(const data::data_expression &x)
std::string pp(const abstraction &x)
void collect_transition_variables(const action_summand &s, std::set< data::variable > &result)
bool check_well_typedness(const linear_process &x)
void remove_parameters(Object &x, const std::set< data::variable > &to_be_removed)
Rewrites an LPS data type.
void parelm(Specification &spec, bool variant1=true)
Removes unused parameters from a linear process specification.
std::set< data::variable > find_all_variables(const lps::deadlock &x)
std::set< T > set_difference(const std::set< T > &x, const std::set< T > &y)
Returns the difference of two sets.
std::vector< std::size_t > reachable_nodes(const Graph &g, Iter first, Iter last)
Compute reachable nodes in a graph.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
add your file description here.