29 typedef std::pair<state_type, state_type> product_state_type;
31 state_type nextState = 0;
32 std::map<product_state_type, state_type> productStateToProductIndex;
33 std::vector<product_state_type> productIndexToProductState;
34 std::vector<state_type> prodInitial;
40 std::deque<state_type> todo;
41 for (state_type s_0 : statesOfInterest) {
42 state_type q_0 = prodOp.getInitialState(s_0);
46 product_state_type s_q(s_0, q_0);
47 state_type index = nextState++;
48 productStateToProductIndex[s_q] = index;
49 productIndexToProductState.push_back(s_q);
50 prodInitial.push_back(index);
51 todo.push_back(index);
55 std::size_t curRow = 0;
56 while (!todo.empty()) {
57 state_type prodIndexFrom = todo.front();
60 product_state_type from = productIndexToProductState.at(prodIndexFrom);
63 typename matrix_type::const_rows row = originalMatrix.
getRow(from.first);
64 for (
auto const& entry : row) {
65 state_type t = entry.getColumn();
66 state_type p = prodOp.getSuccessor(from.second, t);
68 product_state_type t_p(t, p);
69 state_type prodIndexTo;
70 auto it = productStateToProductIndex.find(t_p);
71 if (it == productStateToProductIndex.end()) {
72 prodIndexTo = nextState++;
73 todo.push_back(prodIndexTo);
74 productIndexToProductState.push_back(t_p);
75 productStateToProductIndex[t_p] = prodIndexTo;
78 prodIndexTo = it->second;
83 builder.addNextValue(prodIndexFrom, prodIndexTo, entry.getValue());
88 for (std::size_t i = 0; i < numRows; i++) {
89 auto const& row = originalMatrix.
getRow(from.first, i);
90 for (
auto const& entry : row) {
91 state_type t = entry.getColumn();
92 state_type p = prodOp.getSuccessor(from.second, t);
94 product_state_type t_p(t, p);
95 state_type prodIndexTo;
96 auto it = productStateToProductIndex.find(t_p);
97 if (it == productStateToProductIndex.end()) {
98 prodIndexTo = nextState++;
99 todo.push_back(prodIndexTo);
100 productIndexToProductState.push_back(t_p);
101 productStateToProductIndex[t_p] = prodIndexTo;
104 prodIndexTo = it->second;
109 builder.addNextValue(curRow, prodIndexTo, entry.getValue());
116 state_type numberOfProductStates = nextState;
120 for (
auto& s : prodInitial) {
121 productStatesOfInterest.
set(s);
123 std::string prodSoiLabel = product.getStateLabeling().addUniqueLabel(
"soi", productStatesOfInterest);
129 new Product<Model>(std::move(product), std::move(prodSoiLabel), std::move(productStateToProductIndex), std::move(productIndexToProductState)));