mCRL2
Loading...
Searching...
No Matches
pbesinst_partial_solve.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/pbesinst_partial_solve.h
10/// \brief add your file description here.
11
12#ifndef MCRL2_PBES_PBESINST_PARTIAL_SOLVE_H
13#define MCRL2_PBES_PBESINST_PARTIAL_SOLVE_H
14
15#include "mcrl2/pbes/pbesinst_lazy.h"
16#include "mcrl2/pbes/simple_structure_graph.h"
17#include "mcrl2/pbes/solve_structure_graph.h"
18#include "mcrl2/pbes/structure_graph_builder.h"
19
20
21
22
23
24namespace mcrl2::pbes_system::detail {
25
26inline
28 const pbesinst_lazy_todo& todo,
29 std::array<vertex_set, 2>& S,
30 std::array<strategy_vector, 2>& tau,
31 std::size_t equation_count,
32 const detail::structure_graph_builder& graph_builder
33 )
34{
35 mCRL2log(log::debug) << "\n === partial solve (equation " << equation_count << ") ===\n" << G << std::endl;
36 mCRL2log(log::debug) << " S0 = " << S[0] << std::endl;
37 mCRL2log(log::debug) << " S1 = " << S[1] << std::endl;
38
39 std::size_t N = G.extent();
40
41 // The size of S[0] and S[1] may be bigger than N, because of the resize strategy in vertex_set.
42 S[0].truncate(N);
43 S[1].truncate(N);
44
45 mCRL2log(log::debug) << " computing S0 = attr_default_with_tau(G, S0, 0, tau0)" << std::endl;
46 S[0] = attr_default_with_tau(G, S[0], 0, tau);
47 mCRL2log(log::debug) << " computing S1 = attr_default_with_tau(G, S1, 1, tau1)" << std::endl;
48 S[1] = attr_default_with_tau(G, S[1], 1, tau);
49
50 // Si_todo := Si U todo
51 std::array<vertex_set, 2> S_todo = S;
52
53 for (const propositional_variable_instantiation& X: todo.elements())
54 {
55 structure_graph::index_type u = graph_builder.find_vertex(X);
56 S_todo[0].insert(u);
57 S_todo[1].insert(u);
58 }
59
60 bool check_strategy = false;
61 bool use_toms_optimization = false;
62 solve_structure_graph_algorithm algorithm(check_strategy, use_toms_optimization);
63
64 vertex_set W[2] = { vertex_set(N), vertex_set(N) }; // NOLINT(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
65 std::tie(W[0], W[1]) = algorithm.solve_recursive(G, set_union(S[1], attr_default_no_strategy(G, S_todo[0], 0)));
66 for (structure_graph::index_type v: W[1].vertices())
67 {
68 if (S[1].contains(v))
69 {
70 continue;
71 }
72 if (G.decoration(v) == structure_graph::d_conjunction)
73 {
74 auto tau_v = G.decoration(v);
75 local_strategy(tau, 1).set_strategy(v, tau_v);
76 }
77 }
78 std::tie(W[0], W[1]) = algorithm.solve_recursive(G, set_union(S[0], attr_default_no_strategy(G, S_todo[1], 1)));
79 for (structure_graph::index_type v: W[0].vertices())
80 {
81 if (S[0].contains(v))
82 {
83 continue;
84 }
85 if (G.decoration(v) == structure_graph::d_disjunction)
86 {
87 auto tau_v = G.decoration(v);
88 local_strategy(tau, 0).set_strategy(v, tau_v);
89 }
90 }
91
92 mCRL2log(log::debug) << "\n === result of partial solve (iteration " << equation_count << ") ===" << std::endl;
93 mCRL2log(log::debug) << " S0 = " << S[0] << std::endl;
94 mCRL2log(log::debug) << " S1 = " << S[1] << std::endl;
95 mCRL2log(log::debug) << " tau0 = " << print_strategy_vector(S[0], tau[0]) << std::endl;
96 mCRL2log(log::debug) << " tau1 = " << print_strategy_vector(S[1], tau[1]) << std::endl;
97}
98
99} // namespace mcrl2::pbes_system::detail
100
101
102
103
104
105#endif // MCRL2_PBES_PBESINST_PARTIAL_SOLVE_H
solve_structure_graph_algorithm(bool check_strategy_=false, bool use_toms_optimization_=false)
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:393
void partial_solve(structure_graph &G, const pbesinst_lazy_todo &todo, std::array< vertex_set, 2 > &S, std::array< strategy_vector, 2 > &tau, std::size_t equation_count, const detail::structure_graph_builder &graph_builder)