25 typedef std::pair<state_type, state_type> product_state_type;
27 state_type nextState = 0;
28 std::map<product_state_type, state_type> productStateToProductIndex;
29 std::vector<product_state_type> productIndexToProductState;
30 std::vector<state_type> prodInitial;
36 std::deque<state_type> todo;
37 for (state_type s_0 : statesOfInterest) {
38 state_type q_0 = prodOp.getInitialState(s_0);
42 product_state_type s_q(s_0, q_0);
43 state_type index = nextState++;
44 productStateToProductIndex[s_q] = index;
45 productIndexToProductState.push_back(s_q);
46 prodInitial.push_back(index);
47 todo.push_back(index);
51 std::size_t curRow = 0;
52 while (!todo.empty()) {
53 state_type prodIndexFrom = todo.front();
56 product_state_type from = productIndexToProductState.at(prodIndexFrom);
60 for (
auto const& entry : row) {
61 state_type t = entry.getColumn();
62 state_type p = prodOp.getSuccessor(from.second, t);
64 product_state_type t_p(t, p);
65 state_type prodIndexTo;
66 auto it = productStateToProductIndex.find(t_p);
67 if (it == productStateToProductIndex.end()) {
68 prodIndexTo = nextState++;
69 todo.push_back(prodIndexTo);
70 productIndexToProductState.push_back(t_p);
71 productStateToProductIndex[t_p] = prodIndexTo;
74 prodIndexTo = it->second;
79 builder.
addNextValue(prodIndexFrom, prodIndexTo, entry.getValue());
84 for (std::size_t i = 0; i < numRows; i++) {
85 auto const& row = originalMatrix.
getRow(from.first, i);
86 for (
auto const& entry : row) {
87 state_type t = entry.getColumn();
88 state_type p = prodOp.getSuccessor(from.second, t);
90 product_state_type t_p(t, p);
91 state_type prodIndexTo;
92 auto it = productStateToProductIndex.find(t_p);
93 if (it == productStateToProductIndex.end()) {
94 prodIndexTo = nextState++;
95 todo.push_back(prodIndexTo);
96 productIndexToProductState.push_back(t_p);
97 productStateToProductIndex[t_p] = prodIndexTo;
100 prodIndexTo = it->second;
105 builder.
addNextValue(curRow, prodIndexTo, entry.getValue());
112 state_type numberOfProductStates = nextState;
116 for (
auto& s : prodInitial) {
117 productStatesOfInterest.
set(s);
119 std::string prodSoiLabel = product.getStateLabeling().addUniqueLabel(
"soi", productStatesOfInterest);
125 new Product<Model>(std::move(product), std::move(prodSoiLabel), std::move(productStateToProductIndex), std::move(productIndexToProductState)));