50struct ArtificialTreeState
56struct ArtificialDecisionTreeDomain
63 using State = ArtificialTreeState;
65 size_t leaf_depth = 2;
67 bool is_goal(
const State &state)
const
69 return state.depth == leaf_depth
and (state.code == 5 or state.code == 6);
72 bool is_terminal(
const State &state)
const
74 return state.depth == leaf_depth;
77 void apply(State &state,
const Move &move)
const
79 state.code = state.code*2 + (move.label ==
'R' ? 1u : 0u);
83 void undo(State &state,
const Move &move)
const
86 state.code = (state.code - (move.label ==
'R' ? 1u : 0u))/2;
89 template <
typename Visitor>
90 bool for_each_successor(
const State &state, Visitor visit)
const
92 if (state.depth >= leaf_depth)
95 if (not visit(Move{
'L'}))
98 return visit(Move{
'R'});
104 std::string signature;
105 for (
const auto &move : path)
106 signature.push_back(move.label);
114 ArtificialDecisionTreeDomain domain;
119 Engine
engine(domain, policy);
122 auto result =
engine.search(ArtificialTreeState{}, collector);
124 std::cout <<
"Visited states: " << result.stats.visited_states <<
'\n';
125 std::cout <<
"Expanded states: " << result.stats.expanded_states <<
'\n';
126 std::cout <<
"Solutions found: " << result.stats.solutions_found <<
'\n';
128 for (
auto it = collector.
solutions().
get_it(); it.has_curr(); it.next_ne())
129 std::cout <<
"Solution path: " << path_signature(it.get_curr().path) <<
'\n';
Umbrella header for the implicit state-space search framework.
Recursive depth-first backtracking over an implicit state space.
Collector that stores accepted solutions in an Aleph list.
const Container_Type & solutions() const noexcept
Access the collected solutions.
auto get_it()
Return a properly initialized iterator positioned at the first item on the container.
Main namespace for Aleph-w library functions.
std::string code(Node *root)
Compute a string with the Lukasiewicz`s word of a tree.
and
Check uniqueness with explicit hash + equality functors.
Exploration controls shared across engines.
bool stop_at_first_solution
Stop when the first goal is found.