Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74495 - in sandbox/automata: . boost boost/automata boost/automata/_detail boost/automata/builder boost/automata/builder/from_graph boost/automata/concept_check boost/automata/generator boost/automata/input_rule boost/automata/keys boost/automata/keyword boost/automata/observer boost/automata/policy boost/automata/tags boost/automata/transition_function boost/detail boost/detail/metafunction libs libs/automata libs/automata/doc libs/automata/example libs/automata/test
From: sponage_at_[hidden]
Date: 2011-09-21 13:16:16


Author: expaler
Date: 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
New Revision: 74495
URL: http://svn.boost.org/trac/boost/changeset/74495

Log:
Added Boost.Automata candidate library.
Added:
   sandbox/automata/
   sandbox/automata/LICENSE_1_0.txt (contents, props changed)
   sandbox/automata/boost/
   sandbox/automata/boost.png (contents, props changed)
   sandbox/automata/boost/automata/
   sandbox/automata/boost/automata.hpp (contents, props changed)
   sandbox/automata/boost/automata/_detail/
   sandbox/automata/boost/automata/_detail/extensible_memento.hpp (contents, props changed)
   sandbox/automata/boost/automata/_detail/impl.hpp (contents, props changed)
   sandbox/automata/boost/automata/_detail/memento.hpp (contents, props changed)
   sandbox/automata/boost/automata/automaton.hpp (contents, props changed)
   sandbox/automata/boost/automata/builder/
   sandbox/automata/boost/automata/builder/from_graph/
   sandbox/automata/boost/automata/builder/from_graph.hpp (contents, props changed)
   sandbox/automata/boost/automata/builder/from_graph/multiple_final_states.hpp (contents, props changed)
   sandbox/automata/boost/automata/builder/from_graph/single_final_state.hpp (contents, props changed)
   sandbox/automata/boost/automata/builder/function.hpp (contents, props changed)
   sandbox/automata/boost/automata/concept_check/
   sandbox/automata/boost/automata/concept_check.hpp (contents, props changed)
   sandbox/automata/boost/automata/concept_check/cons_input_trans_func.hpp (contents, props changed)
   sandbox/automata/boost/automata/concept_check/cons_state_trans_func.hpp (contents, props changed)
   sandbox/automata/boost/automata/concept_check/dfa_trans_func.hpp (contents, props changed)
   sandbox/automata/boost/automata/concept_check/dpda_trans_func.hpp (contents, props changed)
   sandbox/automata/boost/automata/concept_check/mapped_in_tab_trans_func.hpp (contents, props changed)
   sandbox/automata/boost/automata/concept_check/mapped_in_trans_func.hpp (contents, props changed)
   sandbox/automata/boost/automata/concept_check/mdp_trans_func.hpp (contents, props changed)
   sandbox/automata/boost/automata/concept_check/next_state_trans_func.hpp (contents, props changed)
   sandbox/automata/boost/automata/concept_check/prob_trans_func.hpp (contents, props changed)
   sandbox/automata/boost/automata/concept_check/sr_trans_func.hpp (contents, props changed)
   sandbox/automata/boost/automata/concept_check/tabular_trans_func.hpp (contents, props changed)
   sandbox/automata/boost/automata/concept_check/trans_func.hpp (contents, props changed)
   sandbox/automata/boost/automata/concept_check/trans_func_matrix.hpp (contents, props changed)
   sandbox/automata/boost/automata/function_automaton.hpp (contents, props changed)
   sandbox/automata/boost/automata/generator/
   sandbox/automata/boost/automata/generator/deterministic.hpp (contents, props changed)
   sandbox/automata/boost/automata/generator/dfa.hpp (contents, props changed)
   sandbox/automata/boost/automata/generator/dpda.hpp (contents, props changed)
   sandbox/automata/boost/automata/generator/probabilistic.hpp (contents, props changed)
   sandbox/automata/boost/automata/input_rule/
   sandbox/automata/boost/automata/input_rule/cellular_graph.hpp (contents, props changed)
   sandbox/automata/boost/automata/input_rule/wolfram_code.hpp (contents, props changed)
   sandbox/automata/boost/automata/keys/
   sandbox/automata/boost/automata/keys/common.hpp (contents, props changed)
   sandbox/automata/boost/automata/keys/dpda.hpp (contents, props changed)
   sandbox/automata/boost/automata/keys/observer.hpp (contents, props changed)
   sandbox/automata/boost/automata/keyword/
   sandbox/automata/boost/automata/keyword/name.hpp (contents, props changed)
   sandbox/automata/boost/automata/keyword/template.hpp (contents, props changed)
   sandbox/automata/boost/automata/observer/
   sandbox/automata/boost/automata/observer/base.hpp (contents, props changed)
   sandbox/automata/boost/automata/observer/full_noop.hpp (contents, props changed)
   sandbox/automata/boost/automata/observer/output.hpp (contents, props changed)
   sandbox/automata/boost/automata/policy/
   sandbox/automata/boost/automata/policy/bool_insertion.hpp (contents, props changed)
   sandbox/automata/boost/automata/policy/default_input_validation.hpp (contents, props changed)
   sandbox/automata/boost/automata/policy/dfa_insertion.hpp (contents, props changed)
   sandbox/automata/boost/automata/policy/dpda_insertion.hpp (contents, props changed)
   sandbox/automata/boost/automata/policy/input_validation.hpp (contents, props changed)
   sandbox/automata/boost/automata/policy/mdp_best_input.hpp (contents, props changed)
   sandbox/automata/boost/automata/policy/mealy_output.hpp (contents, props changed)
   sandbox/automata/boost/automata/policy/moore_output.hpp (contents, props changed)
   sandbox/automata/boost/automata/policy/parallel_final_states.hpp (contents, props changed)
   sandbox/automata/boost/automata/policy/serial_final_states.hpp (contents, props changed)
   sandbox/automata/boost/automata/policy/single_final_state.hpp (contents, props changed)
   sandbox/automata/boost/automata/tags/
   sandbox/automata/boost/automata/tags/base.hpp (contents, props changed)
   sandbox/automata/boost/automata/tags/builder.hpp (contents, props changed)
   sandbox/automata/boost/automata/tags/transition_function.hpp (contents, props changed)
   sandbox/automata/boost/automata/transition_function/
   sandbox/automata/boost/automata/transition_function/adaptor.hpp (contents, props changed)
   sandbox/automata/boost/automata/transition_function/decision_tree.hpp (contents, props changed)
   sandbox/automata/boost/automata/transition_function/dpda.hpp (contents, props changed)
   sandbox/automata/boost/automata/transition_function/input_rule.hpp (contents, props changed)
   sandbox/automata/boost/automata/transition_function/mapped_input.hpp (contents, props changed)
   sandbox/automata/boost/automata/transition_function/mapped_input_tabular.hpp (contents, props changed)
   sandbox/automata/boost/automata/transition_function/matrix.hpp (contents, props changed)
   sandbox/automata/boost/automata/transition_function/mdp_mapped_input.hpp (contents, props changed)
   sandbox/automata/boost/automata/transition_function/next_state.hpp (contents, props changed)
   sandbox/automata/boost/automata/transition_function/totalistic_boolean_cell.hpp (contents, props changed)
   sandbox/automata/boost/automata/transition_function/totalistic_dt_cell.hpp (contents, props changed)
   sandbox/automata/boost/automata/typeof.hpp (contents, props changed)
   sandbox/automata/boost/detail/
   sandbox/automata/boost/detail/metafunction/
   sandbox/automata/boost/detail/metafunction/adaptable_unary_argument.hpp (contents, props changed)
   sandbox/automata/boost/detail/metafunction/data_type.hpp (contents, props changed)
   sandbox/automata/boost/detail/metafunction/has_argument_type.hpp (contents, props changed)
   sandbox/automata/boost/detail/metafunction/has_first_argument_type.hpp (contents, props changed)
   sandbox/automata/boost/detail/metafunction/has_key_type.hpp (contents, props changed)
   sandbox/automata/boost/detail/metafunction/has_second_argument_type.hpp (contents, props changed)
   sandbox/automata/boost/detail/metafunction/has_value_type.hpp (contents, props changed)
   sandbox/automata/boost/detail/metafunction/is_adaptable_binary_function.hpp (contents, props changed)
   sandbox/automata/boost/detail/metafunction/is_adaptable_unary_function.hpp (contents, props changed)
   sandbox/automata/boost/detail/metafunction/is_n_ary_function.hpp (contents, props changed)
   sandbox/automata/boost/detail/metafunction/is_predicate.hpp (contents, props changed)
   sandbox/automata/boost/detail/metafunction/property_map_key.hpp (contents, props changed)
   sandbox/automata/boost/detail/metafunction/property_map_value.hpp (contents, props changed)
   sandbox/automata/boost/detail/metafunction/unary_argument.hpp (contents, props changed)
   sandbox/automata/libs/
   sandbox/automata/libs/automata/
   sandbox/automata/libs/automata/doc/
   sandbox/automata/libs/automata/doc/Jamroot (contents, props changed)
   sandbox/automata/libs/automata/doc/automata.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/concepts.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/glossary.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/ref_automaton.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/ref_builder.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/ref_function_automaton.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/ref_generator.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/ref_input_rule.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/ref_observer.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/ref_policy.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/ref_transition_function.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/reference.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/tut_basics.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/tut_builders.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/tut_byo_automata.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/tut_cellular_automata.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/tut_dfa.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/tut_func2a.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/tut_input_rules.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/tut_observer_policies.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/tut_undo.qbk (contents, props changed)
   sandbox/automata/libs/automata/doc/tutorials.qbk (contents, props changed)
   sandbox/automata/libs/automata/example/
   sandbox/automata/libs/automata/example/decision_tree_agent.cpp (contents, props changed)
   sandbox/automata/libs/automata/example/dfa.cpp (contents, props changed)
   sandbox/automata/libs/automata/example/dfa_builder.cpp (contents, props changed)
   sandbox/automata/libs/automata/example/dfa_builder.hpp (contents, props changed)
   sandbox/automata/libs/automata/example/dpda.cpp (contents, props changed)
   sandbox/automata/libs/automata/example/dpda.hpp (contents, props changed)
   sandbox/automata/libs/automata/example/elem_cell_automaton.cpp (contents, props changed)
   sandbox/automata/libs/automata/example/game_of_life.cpp (contents, props changed)
   sandbox/automata/libs/automata/example/markov_chain.cpp (contents, props changed)
   sandbox/automata/libs/automata/example/markov_decision_process.cpp (contents, props changed)
   sandbox/automata/libs/automata/example/maze.cpp (contents, props changed)
   sandbox/automata/libs/automata/example/maze.hpp (contents, props changed)
   sandbox/automata/libs/automata/example/neural_network.cpp (contents, props changed)
   sandbox/automata/libs/automata/example/neural_network_builder.hpp (contents, props changed)
   sandbox/automata/libs/automata/example/neural_network_generator.hpp (contents, props changed)
   sandbox/automata/libs/automata/example/neural_network_make_samples.hpp (contents, props changed)
   sandbox/automata/libs/automata/example/neural_network_policy.hpp (contents, props changed)
   sandbox/automata/libs/automata/example/neural_network_trans_func.hpp (contents, props changed)
   sandbox/automata/libs/automata/example/wireworld.cpp (contents, props changed)
   sandbox/automata/libs/automata/index.html (contents, props changed)
   sandbox/automata/libs/automata/test/
   sandbox/automata/libs/automata/test/basics.cpp (contents, props changed)
   sandbox/automata/libs/automata/test/basics.hpp (contents, props changed)
   sandbox/automata/libs/automata/test/builder_from_graph.cpp (contents, props changed)
   sandbox/automata/libs/automata/test/dfa.cpp (contents, props changed)
   sandbox/automata/libs/automata/test/dfa_builder.cpp (contents, props changed)
   sandbox/automata/libs/automata/test/dfa_builder.hpp (contents, props changed)
   sandbox/automata/libs/automata/test/dpda.cpp (contents, props changed)
   sandbox/automata/libs/automata/test/dpda_builder.cpp (contents, props changed)
   sandbox/automata/libs/automata/test/dpda_builder.hpp (contents, props changed)

Added: sandbox/automata/LICENSE_1_0.txt
==============================================================================
--- (empty file)
+++ sandbox/automata/LICENSE_1_0.txt 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,23 @@
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.

Added: sandbox/automata/boost.png
==============================================================================
Binary file. No diff available.

Added: sandbox/automata/boost/automata.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,57 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_HPP_INCLUDED
+#define BOOST_AUTOMATA_HPP_INCLUDED
+
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/tags/base.hpp>
+#include <boost/automata/tags/builder.hpp>
+#include <boost/automata/keys/common.hpp>
+#include <boost/automata/keys/dpda.hpp>
+#include <boost/automata/keys/observer.hpp>
+#include <boost/automata/concept_check.hpp>
+#include <boost/automata/keyword/template.hpp>
+#include <boost/automata/keyword/name.hpp>
+#include <boost/automata/generator/dpda.hpp>
+#include <boost/automata/transition_function/dpda.hpp>
+#include <boost/automata/generator/dfa.hpp>
+#include <boost/automata/transition_function/matrix.hpp>
+#include <boost/automata/transition_function/mapped_input_tabular.hpp>
+#include <boost/automata/transition_function/mapped_input.hpp>
+#include <boost/automata/transition_function/next_state.hpp>
+#include <boost/automata/generator/deterministic.hpp>
+#include <boost/automata/transition_function/adaptor.hpp>
+#include <boost/automata/transition_function/input_rule.hpp>
+#include <boost/automata/input_rule/cellular_graph.hpp>
+#include <boost/automata/transition_function/totalistic_boolean_cell.hpp>
+#include <boost/automata/transition_function/totalistic_dfa_cell.hpp>
+#include <boost/automata/input_rule/wolfram_code.hpp>
+#include <boost/automata/generator/probabilistic.hpp>
+#include <boost/automata/transition_function/mdp_mapped_input.hpp>
+#include <boost/automata/transition_function/decision_tree.hpp>
+#include <boost/automata/builder/function.hpp>
+#include <boost/automata/builder/from_graph.hpp>
+#include <boost/automata/builder/from_graph/single_final_state.hpp>
+#include <boost/automata/builder/from_graph/multiple_final_states.hpp>
+#include <boost/automata/observer/base.hpp>
+#include <boost/automata/observer/full_noop.hpp>
+#include <boost/automata/observer/output.hpp>
+#include <boost/automata/policy/single_final_state.hpp>
+#include <boost/automata/policy/parallel_final_states.hpp>
+#include <boost/automata/policy/serial_final_states.hpp>
+#include <boost/automata/policy/bool_insertion.hpp>
+#include <boost/automata/policy/dpda_insertion.hpp>
+#include <boost/automata/policy/dfa_insertion.hpp>
+#include <boost/automata/policy/mdp_best_input.hpp>
+#include <boost/automata/policy/moore_output.hpp>
+#include <boost/automata/policy/mealy_output.hpp>
+#include <boost/automata/policy/default_input_validation.hpp>
+#include <boost/automata/policy/input_validation.hpp>
+#include <boost/automata/automaton.hpp>
+#include <boost/automata/function_automaton.hpp>
+
+#endif // BOOST_AUTOMATA_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/_detail/extensible_memento.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/_detail/extensible_memento.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,221 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA__DETAIL_EXTENSIBLE_MEMENTO_HPP_INCLUDED
+#define BOOST_AUTOMATA__DETAIL_EXTENSIBLE_MEMENTO_HPP_INCLUDED
+
+#include <deque>
+
+namespace boost { namespace automata { namespace _detail {
+
+ template <typename Base, typename Observers>
+ class extensible_memento
+ {
+ typedef ::std::deque<Base*> BaseSnapshots;
+ typedef ::std::deque<Observers*> ObserverSnapshots;
+
+ public:
+ typedef ::std::size_t size_type;
+
+ private:
+ BaseSnapshots _base_snapshots;
+ ObserverSnapshots _observer_snapshots;
+ size_type _limit;
+
+ public:
+ explicit extensible_memento(size_type const limit);
+
+ extensible_memento(extensible_memento const& copy);
+
+ extensible_memento& operator=(extensible_memento const& copy);
+
+ ~extensible_memento();
+
+ void clear();
+
+ size_type get_save_limit() const;
+
+ void save(Base const& base, Observers const& observers);
+
+ bool can_restore() const;
+
+ void restore(Base& base, Observers& observers);
+
+ private:
+ void _clone(extensible_memento const& copy);
+ };
+
+ template <typename Base, typename Observers>
+ extensible_memento<Base,Observers>::extensible_memento(
+ size_type const limit
+ ) : _base_snapshots(), _observer_snapshots(), _limit(limit)
+ {
+ }
+
+ template <typename Base, typename Observers>
+ extensible_memento<Base,Observers>::extensible_memento(
+ extensible_memento const& copy
+ ) : _base_snapshots(), _observer_snapshots(), _limit(copy._limit)
+ {
+ _clone(copy);
+ }
+
+ template <typename Base, typename Observers>
+ extensible_memento<Base,Observers>&
+ extensible_memento<Base,Observers>::operator=(
+ extensible_memento const& copy
+ )
+ {
+ if (this != &copy)
+ {
+ clear();
+ _clone(copy);
+ _limit = copy._limit;
+ }
+
+ return *this;
+ }
+
+ template <typename Base, typename Observers>
+ extensible_memento<Base,Observers>::~extensible_memento()
+ {
+ clear();
+ }
+
+ template <typename Base, typename Observers>
+ void extensible_memento<Base,Observers>::clear()
+ {
+ for (
+ typename ObserverSnapshots::iterator
+ itr = _observer_snapshots.begin();
+ itr != _observer_snapshots.end();
+ ++itr
+ )
+ {
+ delete *itr;
+ }
+
+ _observer_snapshots.clear();
+
+ for (
+ typename BaseSnapshots::iterator itr = _base_snapshots.begin();
+ itr != _base_snapshots.end();
+ ++itr
+ )
+ {
+ delete *itr;
+ }
+
+ _base_snapshots.clear();
+ }
+
+ template <typename Base, typename Observers>
+ void
+ extensible_memento<Base,Observers>::_clone(
+ extensible_memento const& copy
+ )
+ {
+ typename BaseSnapshots::const_iterator
+ base_end = copy._base_snapshots.end();
+
+ for (
+ typename BaseSnapshots::const_iterator
+ base_itr = copy._base_snapshots.begin();
+ base_itr != base_end;
+ ++base_itr
+ )
+ {
+ _base_snapshots.push_back(new Base(*(*base_itr)));
+ }
+
+ typename ObserverSnapshots::const_iterator
+ observer_end = copy._observer_snapshots.end();
+
+ for (
+ typename ObserverSnapshots::const_iterator
+ observer_itr = copy._observer_snapshots.begin();
+ observer_itr != observer_end;
+ ++observer_itr
+ )
+ {
+ _observer_snapshots.push_back(new Observers(*(*observer_itr)));
+ }
+ }
+
+ template <typename Base, typename Observers>
+ inline typename extensible_memento<Base,Observers>::size_type
+ extensible_memento<Base,Observers>::get_save_limit() const
+ {
+ return _limit;
+ }
+
+ template <typename Base, typename Observers>
+ inline void
+ extensible_memento<Base,Observers>::save(
+ Base const& base
+ , Observers const& observers
+ )
+ {
+ switch (_limit)
+ {
+ case 0:
+ _base_snapshots.push_back(new Base(base));
+ _observer_snapshots.push_back(new Observers(observers));
+ break;
+
+ case 1:
+ if (_base_snapshots.empty())
+ {
+ _base_snapshots.push_back(new Base(base));
+ _observer_snapshots.push_back(new Observers(observers));
+ }
+ else
+ {
+ *(_base_snapshots.back()) = base;
+ *(_observer_snapshots.back()) = observers;
+ }
+
+ break;
+
+ default:
+ _base_snapshots.push_back(new Base(base));
+ _observer_snapshots.push_back(new Observers(observers));
+
+ if (_limit < _base_snapshots.size())
+ {
+ delete _base_snapshots.front();
+ _base_snapshots.pop_front();
+ delete _observer_snapshots.front();
+ _observer_snapshots.pop_front();
+ }
+
+ break;
+ }
+ }
+
+ template <typename Base, typename Observers>
+ inline bool extensible_memento<Base,Observers>::can_restore() const
+ {
+ return !_base_snapshots.empty();
+ }
+
+ template <typename Base, typename Observers>
+ inline void
+ extensible_memento<Base,Observers>::restore(
+ Base& base
+ , Observers& observers
+ )
+ {
+ base = *(_base_snapshots.back());
+ observers = *(_observer_snapshots.back());
+ delete _base_snapshots.front();
+ _base_snapshots.pop_front();
+ delete _observer_snapshots.front();
+ _observer_snapshots.pop_front();
+ }
+}}} // namespace boost::automata::_detail
+
+#endif // BOOST_AUTOMATA__DETAIL_EXTENSIBLE_MEMENTO_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/_detail/impl.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/_detail/impl.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,1473 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA__DETAIL_IMPL_HPP_INCLUDED
+#define BOOST_AUTOMATA__DETAIL_IMPL_HPP_INCLUDED
+
+#include <boost/preprocessor/cat.hpp>
+#include <boost/parameter.hpp>
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/void.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/bind.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <boost/function.hpp>
+#include <boost/functional/value_factory.hpp>
+#include <boost/fusion/algorithm/transformation/transform.hpp>
+#include <boost/fusion/algorithm/iteration/for_each.hpp>
+#include <boost/fusion/sequence/intrinsic/empty.hpp>
+#include <boost/fusion/container/list/cons.hpp>
+#include <boost/fusion/container/map/convert.hpp>
+#include <boost/fusion/support/pair.hpp>
+#include <boost/detail/metafunction/data_type.hpp>
+#include <boost/detail/metafunction/is_adaptable_unary_function.hpp>
+#include <boost/detail/metafunction/is_adaptable_binary_function.hpp>
+#include <boost/detail/metafunction/is_n_ary_function.hpp>
+#include <boost/detail/metafunction/unary_argument.hpp>
+#include <boost/automata/_detail/memento.hpp>
+#include <boost/automata/_detail/extensible_memento.hpp>
+#include <boost/automata/tags/base.hpp>
+#include <boost/automata/tags/builder.hpp>
+#include <boost/automata/concept_check.hpp>
+#include <boost/automata/keyword/name.hpp>
+
+namespace boost { namespace automata { namespace _detail {
+
+ template <typename Builder, typename State>
+ struct builder_argument_tester
+ : ::std::tr1::is_same<
+ typename ::boost::detail::data_type<
+ typename ::boost::detail::unary_argument<Builder>::type
+ >::type
+ , State
+ >
+ {
+ };
+
+ template <typename Builder, typename State>
+ struct builder_dispatch_helper
+ {
+ typedef typename ::boost::mpl::if_<
+ typename ::boost::mpl::if_<
+ ::boost::mpl::or_<
+ ::boost::detail::is_n_ary_function<
+ Builder
+ , ::std::tr1::integral_constant<unsigned int,1>
+ >
+ , ::boost::detail::is_adaptable_unary_function<
+ Builder
+ >
+ >
+ , builder_argument_tester<Builder,State>
+ , ::std::tr1::false_type
+ >::type
+ , state_builder_tag
+ , function_builder_tag
+ >::type
+ type;
+ };
+
+ // This metafunction determines which of the base constructors
+ // the impl::type argument pack constructor should delegate to.
+ template <typename Builder, typename State>
+ struct builder_dispatch
+ {
+ typedef typename ::boost::mpl::eval_if<
+ ::std::tr1::is_same<Builder,::boost::mpl::void_>
+ , ::boost::mpl::identity<function_setter_tag>
+ , ::boost::mpl::eval_if<
+ ::boost::mpl::or_<
+ ::boost::detail::is_n_ary_function<
+ Builder
+ , ::std::tr1::integral_constant<unsigned int,2>
+ >
+ , ::boost::detail::is_adaptable_binary_function<
+ Builder
+ >
+ >
+ , ::boost::mpl::identity<state_and_function_builder_tag>
+ , builder_dispatch_helper<Builder,State>
+ >
+ >::type
+ type;
+ };
+
+ // This function object class allows the automaton's default and copy
+ // constructors to call the on_construction() member function of each
+ // associated AutomatonObserver.
+ struct observer_on_construction_dispatch
+ {
+ template <typename FusionPair>
+ inline void operator()(FusionPair& pair) const
+ {
+ pair.second.on_construction();
+ }
+ };
+
+ // This function object class allows the automaton's argument-pack
+ // constructors to call the on_construction() tag-dispatched member
+ // function of each associated AutomatonObserver.
+ template <typename Builder, typename Tag>
+ class observer_on_arg_pack_construction_dispatch
+ {
+ Builder const& _builder;
+
+ public:
+ explicit observer_on_arg_pack_construction_dispatch(
+ Builder const& builder
+ ) : _builder(builder)
+ {
+ }
+
+ template <typename FusionPair>
+ inline void operator()(FusionPair& pair) const
+ {
+ pair.second.on_construction(_builder, Tag());
+ }
+ };
+
+ // This function object class allows the automaton's initialize() methods
+ // to call the on_initialize() member function of each associated
+ // AutomatonObserver.
+ template <typename Builder, typename Tag>
+ class observer_on_initialize_dispatch
+ {
+ Builder const& _builder;
+
+ public:
+ explicit observer_on_initialize_dispatch(Builder const& builder)
+ : _builder(builder)
+ {
+ }
+
+ template <typename FusionPair>
+ inline void operator()(FusionPair& pair) const
+ {
+ pair.second.on_initialize(_builder, Tag());
+ }
+ };
+
+ // This function object class allows the automaton's reset() method to call
+ // the on_reset() member function of each associated AutomatonObserver.
+ struct observer_on_reset_dispatch
+ {
+ template <typename FusionPair>
+ inline void operator()(FusionPair& pair) const
+ {
+ pair.second.on_reset();
+ }
+ };
+
+ // This function object class template allows the automaton's function
+ // call operator to call the on_accept_input() member function of each
+ // associated AutomatonObserver.
+ template <typename Input>
+ class observer_on_accept_input_dispatch
+ {
+ Input const& _input;
+
+ public:
+ observer_on_accept_input_dispatch(Input const& i) : _input(i)
+ {
+ }
+
+ template <typename FusionPair>
+ inline void operator()(FusionPair& pair) const
+ {
+ pair.second.on_accept_input(_input);
+ }
+ };
+
+ // This function object class template allows the automaton's function
+ // call operator to call the on_reject_input() member function of each
+ // associated AutomatonObserver.
+ template <typename Input>
+ class observer_on_reject_input_dispatch
+ {
+ Input const& _input;
+
+ public:
+ observer_on_reject_input_dispatch(Input const& i) : _input(i)
+ {
+ }
+
+ template <typename FusionPair>
+ inline void operator()(FusionPair& pair) const
+ {
+ pair.second.on_reject_input(_input);
+ }
+ };
+
+ // This function object class template allows the automaton's function
+ // call operator to call the on_invalid_input() member function of each
+ // associated AutomatonObserver.
+ template <typename Input>
+ class observer_on_invalid_input_dispatch
+ {
+ Input const& _input;
+
+ public:
+ observer_on_invalid_input_dispatch(Input const& i) : _input(i)
+ {
+ }
+
+ template <typename FusionPair>
+ inline void operator()(FusionPair& pair) const
+ {
+ pair.second.on_invalid_input(_input);
+ }
+ };
+
+ // This function object class allows the automaton's undo() method to call
+ // the on_accept_undo() member function of each associated
+ // AutomatonObserver.
+ struct observer_on_accept_undo_dispatch
+ {
+ template <typename FusionPair>
+ inline void operator()(FusionPair& pair) const
+ {
+ pair.second.on_accept_undo();
+ }
+ };
+
+ // This function object class allows the automaton's undo() method to call
+ // the on_reject_undo() member function of each associated
+ // AutomatonObserver.
+ struct observer_on_reject_undo_dispatch
+ {
+ template <typename FusionPair>
+ inline void operator()(FusionPair& pair) const
+ {
+ pair.second.on_reject_undo();
+ }
+ };
+
+ // The function object class templates responsible for creating the actual
+ // policy maps must inherit from this base class template in order to
+ // possess the nested result struct template, and also because the result
+ // sequences need to be assignable to the _observers member variable.
+ template <typename SubjectAutomaton>
+ struct observer_maker
+ {
+ template <typename T>
+ struct result;
+
+ template <typename ObserverMaker, typename Key>
+ struct result<ObserverMaker(Key)>
+ {
+ typedef ::boost::fusion::pair<
+ typename ::boost::detail::data_type<Key>::type
+ , typename ::boost::mpl::apply_wrap1<
+ typename ::boost::detail::data_type<Key>::type
+ , SubjectAutomaton
+ >::type
+ >
+ type;
+ };
+
+ // Fortunately, this base class template doesn't need to define a
+ // virtual templated function call operator, which is illegal anyway.
+ };
+
+ // This function object class template is used by the default constructor
+ // and the argument pack constructors to create the policy map.
+ template <typename SubjectAutomaton>
+ class observer_default_maker : public observer_maker<SubjectAutomaton>
+ {
+ SubjectAutomaton const& _subject_automaton;
+
+ public:
+ explicit observer_default_maker(SubjectAutomaton const& automaton)
+ : _subject_automaton(automaton)
+ {
+ }
+
+ template <typename Key>
+ inline ::boost::fusion::pair<
+ Key
+ , typename ::boost::mpl::apply_wrap1<Key,SubjectAutomaton>::type
+ >
+ operator()(Key const& key) const
+ {
+ return ::boost::fusion::pair<
+ Key
+ , typename ::boost::mpl::apply_wrap1<Key,SubjectAutomaton>::type
+ >(
+ typename ::boost::mpl::apply_wrap1<Key,SubjectAutomaton>::type(
+ key
+ , _subject_automaton
+ )
+ );
+ }
+ };
+
+ // This function object class template is used by the copy constructor
+ // to create the policy map.
+ template <typename SubjectAutomaton>
+ class observer_copy_maker : public observer_maker<SubjectAutomaton>
+ {
+ SubjectAutomaton const& _copy;
+ SubjectAutomaton const& _subject_automaton;
+
+ public:
+ observer_copy_maker(
+ SubjectAutomaton const& copy
+ , SubjectAutomaton const& automaton
+ ) : _copy(copy), _subject_automaton(automaton)
+ {
+ }
+
+ template <typename Key>
+ inline ::boost::fusion::pair<
+ Key
+ , typename ::boost::mpl::apply_wrap1<Key,SubjectAutomaton>::type
+ >
+ operator()(Key const& key) const
+ {
+ return ::boost::fusion::pair<
+ Key
+ , typename ::boost::mpl::apply_wrap1<Key,SubjectAutomaton>::type
+ >(
+ typename ::boost::mpl::apply_wrap1<Key,SubjectAutomaton>::type(
+ ::boost::fusion::at_key<Key>(_copy.get_observer_map())
+ , _subject_automaton
+ )
+ );
+ }
+ };
+
+ // This function object class template is used to invoke
+ // the assignment operator of each observer in the policy map.
+ template <typename ObserverMap>
+ class observer_map_assign
+ {
+ ObserverMap& _observer_map;
+
+ public:
+ explicit observer_map_assign(ObserverMap& map) : _observer_map(map)
+ {
+ }
+
+ template <typename FusionPair>
+ inline void operator()(FusionPair& pair) const
+ {
+ ::boost::fusion::at_key<typename FusionPair::first_type>(
+ _observer_map
+ ) = pair.second;
+ }
+ };
+
+ template <
+ typename BaseGenerator
+ , typename Function
+ , typename Policies
+ , typename InputValidationPolicy
+ , typename IsUndoable
+ >
+ struct impl
+ {
+#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
+ private:
+#endif // MSVC 7.1 and earlier
+ BOOST_CONCEPT_ASSERT((TransitionFunction<Function>));
+
+ typedef typename ::boost::mpl::apply_wrap1<
+ BaseGenerator
+ , Function
+ >::type
+ Ancestor;
+
+// Macros are evil, but the alternative here is massive code duplication.
+#define BOOST_AUTOMATA_IMPL_ARG_DATA_TYPE(Tag) \
+ typename ::boost::parameter::value_type< \
+ ArgumentPack \
+ , keyword::tag::Tag \
+ >::type \
+//
+
+#define BOOST_AUTOMATA_IMPL_BUILDER_TAG_TYPE(Builder) \
+ typename builder_dispatch_helper< \
+ typename ::boost::detail::data_type< \
+ Builder \
+ >::type \
+ , typename Function::state \
+ >::type \
+//
+
+ class Base : public Ancestor
+ {
+ Function _function;
+ typename Function::state _current_state;
+ ::boost::function1<void,typename Function::state&> _state_builder;
+
+ protected:
+ typedef typename Ancestor::tag tag;
+ typedef typename Ancestor::traits traits;
+
+ inline Base()
+ : Ancestor()
+ , _function()
+ , _current_state()
+ , _state_builder(
+ ::boost::lambda::_1 = typename Function::state()
+ )
+ {
+ }
+
+ template <typename TFunction>
+ inline Base(
+ TFunction function
+ , typename Function::state const& source_state
+ , function_setter_tag
+ ) : Ancestor()
+ , _function(function)
+ , _current_state(source_state)
+ , _state_builder(::boost::lambda::_1 = source_state)
+ {
+ }
+
+ template <typename FunctionBuilder>
+ inline Base(
+ FunctionBuilder builder
+ , typename Function::state const& source_state
+ , function_builder_tag
+ ) : Ancestor()
+ , _function()
+ , _current_state(source_state)
+ , _state_builder(::boost::lambda::_1 = source_state)
+ {
+ ::boost::function1<void,Function&> build_function = builder;
+ build_function(_function);
+ }
+
+ template <typename StateBuilder>
+ inline Base(
+ StateBuilder builder
+ , typename Function::state const& source_state
+ , state_builder_tag
+ ) : Ancestor()
+ , _function()
+ , _current_state(source_state)
+ , _state_builder(builder)
+ {
+ _state_builder(_current_state);
+ }
+
+ template <typename Builder>
+ inline Base(
+ Builder builder
+ , typename Function::state const& source_state
+ , state_and_function_builder_tag
+ ) : Ancestor()
+ , _function()
+ , _current_state(source_state)
+ , _state_builder(::boost::bind(builder, _1, _function))
+ {
+ _state_builder(_current_state);
+ }
+
+ public:
+ Base(Base const& copy)
+ : Ancestor(static_cast<Ancestor const&>(copy))
+ , _function(copy._function)
+ , _current_state(copy._current_state)
+ , _state_builder(copy._state_builder)
+ {
+ }
+
+ inline Base& operator=(Base const& copy)
+ {
+ Ancestor::operator=(static_cast<Ancestor const&>(copy));
+ _function = copy._function;
+ _current_state = copy._current_state;
+ _state_builder = copy._state_builder;
+ return *this;
+ }
+
+ protected:
+ inline void reset_impl()
+ {
+ _state_builder(_current_state);
+ Ancestor::reset_impl();
+ }
+
+ template <typename Input>
+ inline bool process_input_impl(Input const& i)
+ {
+ return Ancestor::process_input_impl(
+ get_transition_function()
+ , _current_state
+ , i
+ );
+ }
+
+ template <typename Builder>
+ inline void initialize_impl(Builder builder)
+ {
+ this->_initialize_impl(
+ builder
+ , BOOST_AUTOMATA_IMPL_BUILDER_TAG_TYPE(Builder)()
+ );
+ }
+
+ template <typename Builder>
+ inline void
+ initialize_impl(
+ Builder builder
+ , typename Function::state const& source_state
+ )
+ {
+ this->set_source_state(source_state);
+ this->_initialize_impl(
+ builder
+ , BOOST_AUTOMATA_IMPL_BUILDER_TAG_TYPE(Builder)()
+ );
+ }
+
+ inline void
+ set_source_state(typename Function::state const& source_state)
+ {
+ _state_builder = (boost::lambda::_1 = source_state);
+ }
+
+ private:
+ template <typename TFunction>
+ inline void
+ _initialize_impl(TFunction function, function_setter_tag)
+ {
+ _function = function;
+ }
+
+ template <typename Builder>
+ inline void
+ _initialize_impl(
+ Builder builder
+ , function_builder_tag
+ )
+ {
+ ::boost::function1<void,Function&> build_function = builder;
+ build_function(_function);
+ }
+
+ template <typename Builder>
+ inline void
+ _initialize_impl(Builder builder, state_builder_tag)
+ {
+ _state_builder = builder;
+ }
+
+ template <typename Builder>
+ inline void
+ _initialize_impl(
+ Builder builder
+ , state_and_function_builder_tag
+ )
+ {
+ _state_builder = ::boost::bind(builder, _1, _function);
+ }
+
+ public:
+ inline Function const& get_transition_function() const
+ {
+ return _function;
+ }
+
+ inline typename Function::state const& get_current_state() const
+ {
+ return _current_state;
+ }
+
+ template <typename Input>
+ inline bool is_nontrivial_input(Input const& i) const
+ {
+ return Ancestor::is_nontrivial_input_impl(
+ get_transition_function()
+ , get_current_state()
+ , i
+ );
+ }
+
+ template <typename Iterator>
+ inline void
+ make_nontrivial_inputs(Iterator itr) const
+ {
+ Ancestor::make_nontrivial_inputs_impl(
+ get_transition_function()
+ , _current_state
+ , itr
+ );
+ }
+ };
+
+// The transition function should be stored in a wrapper derived from the Base
+// class instead of within the Base class itself, where it may be all too easy
+// for the process_input_impl method, which is non-const (as well as the
+// reset_impl method) to modify the transition function by mistake.
+#define BOOST_AUTOMATA_IMPL_ANY_TYPE_PREAMBLE(Type) \
+ typedef Function \
+ transition_function; \
+ typedef typename Function::state \
+ state; \
+ typedef typename Base::traits \
+ traits; \
+ private: \
+ typedef typename ::boost::mpl::apply_wrap1< \
+ InputValidationPolicy \
+ , Type \
+ >::type \
+ InputChecker; \
+ InputChecker _input_validator; \
+//
+
+#define BOOST_AUTOMATA_IMPL_PLAIN_TYPE_PREAMBLE(Type) \
+ public: \
+ typedef ::boost::fusion::nil \
+ observer_map; \
+ BOOST_AUTOMATA_IMPL_ANY_TYPE_PREAMBLE(Type) \
+//
+
+// The _policies member variable is used only by the constructors. Its
+// presence is mandatory for the copy constructor to work correctly,
+// even though the _observers member variable holds all the necessary
+// information.
+//
+// No other member functions should access the elements of the _policies
+// member variable, since it may become a dangling reference once the regular
+// constructor has finished execution. The copy constructor needs only the
+// corresponding type of each element.
+#define BOOST_AUTOMATA_IMPL_EXT_TYPE_PREAMBLE(Type) \
+ public: \
+ BOOST_AUTOMATA_IMPL_ANY_TYPE_PREAMBLE(Type) \
+ public: \
+ typedef typename ::boost::fusion::result_of::as_map< \
+ typename ::boost::fusion::result_of::transform< \
+ Policies \
+ , observer_maker<Type> \
+ >::type \
+ >::type \
+ observer_map; \
+ private: \
+ observer_map _observers; \
+ Policies const& _policies; \
+//
+
+#define BOOST_AUTOMATA_IMPL_PLAIN_TYPE_DEFAULT_CTOR_HEAD(Type) \
+ Type() \
+ : Base() \
+ , _input_validator(InputValidationPolicy(), *this) \
+//
+
+#define BOOST_AUTOMATA_IMPL_EXT_TYPE_DEFAULT_CTOR_HEAD(Type) \
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_DEFAULT_CTOR_HEAD(Type) \
+ , _observers( \
+ ::boost::fusion::as_map( \
+ ::boost::fusion::transform( \
+ _policies \
+ , observer_default_maker<Type>(*this) \
+ ) \
+ ) \
+ ) \
+ , _policies(Policies()) \
+//
+
+#define BOOST_AUTOMATA_IMPL_ANY_TYPE_ARG_PACK_W_FUNC_CTOR_HEAD(Type) \
+ template <typename ArgumentPack> \
+ Type(ArgumentPack const& args, ::std::tr1::true_type) \
+ : Base( \
+ args[::boost::automata::keyword::_function] \
+ , args[ \
+ ::boost::automata::keyword::_source_state \
+ || value_factory<state>() \
+ ] \
+ , function_setter_tag() \
+ ) \
+//
+
+#define BOOST_AUTOMATA_IMPL_ANY_TYPE_ARG_PACK_W_BUILDER_CTOR_HEAD(Type) \
+ template <typename ArgumentPack> \
+ Type(ArgumentPack const& args, ::std::tr1::false_type) \
+ : Base( \
+ args[::boost::automata::keyword::_builder] \
+ , args[ \
+ ::boost::automata::keyword::_source_state \
+ || value_factory<state>() \
+ ] \
+ , BOOST_AUTOMATA_IMPL_BUILDER_TAG_TYPE( \
+ BOOST_AUTOMATA_IMPL_ARG_DATA_TYPE(builder) \
+ )() \
+ ) \
+//
+
+#define BOOST_AUTOMATA_IMPL_PLAIN_TYPE_ARG_PACK_CTOR_HEAD_SUFFIX \
+ , _input_validator( \
+ args[ \
+ ::boost::automata::keyword::_input_validation_policy \
+ || value_factory<InputValidationPolicy>() \
+ ] \
+ , *this \
+ ) \
+//
+
+#define BOOST_AUTOMATA_IMPL_EXT_TYPE_ARG_PACK_CTOR_HEAD_SUFFIX(Type) \
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_ARG_PACK_CTOR_HEAD_SUFFIX \
+ , _observers( \
+ ::boost::fusion::as_map( \
+ ::boost::fusion::transform( \
+ args[ \
+ ::boost::automata::keyword::_policies \
+ || value_factory<Policies>() \
+ ] \
+ , observer_default_maker<Type>(*this) \
+ ) \
+ ) \
+ ) \
+ , _policies( \
+ args[ \
+ ::boost::automata::keyword::_policies \
+ || value_factory<Policies>() \
+ ] \
+ ) \
+//
+
+#define BOOST_AUTOMATA_IMPL_PLAIN_TYPE_COPY_CTOR_HEAD(Type) \
+ Type(Type const& copy) \
+ : Base(static_cast<Base const&>(copy)) \
+ , _input_validator(copy._input_validator, *this) \
+//
+
+#define BOOST_AUTOMATA_IMPL_EXT_TYPE_COPY_CTOR_HEAD(Type) \
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_COPY_CTOR_HEAD(Type) \
+ , _observers( \
+ ::boost::fusion::as_map( \
+ ::boost::fusion::transform( \
+ copy._policies \
+ , observer_copy_maker<Type>(copy, *this) \
+ ) \
+ ) \
+ ) \
+ , _policies(copy._policies) \
+//
+
+#define BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_CTOR \
+ _input_validator.on_construction(); \
+ ::boost::fusion::for_each( \
+ _observers \
+ , observer_on_construction_dispatch() \
+ ); \
+//
+
+#define BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_ARG_CTOR(Tag) \
+ typedef BOOST_AUTOMATA_IMPL_ARG_DATA_TYPE(Tag) Builder; \
+ _input_validator.on_construction( \
+ args[::boost::automata::keyword::BOOST_PP_CAT(_, Tag)] \
+ , BOOST_AUTOMATA_IMPL_BUILDER_TAG_TYPE(Builder)() \
+ ); \
+//
+
+#define BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_ARG_CTOR(Tag) \
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_ARG_CTOR(Tag) \
+ ::boost::fusion::for_each( \
+ _observers \
+ , observer_on_arg_pack_construction_dispatch< \
+ Builder \
+ , BOOST_AUTOMATA_IMPL_BUILDER_TAG_TYPE(Builder) \
+ >(args[::boost::automata::keyword::BOOST_PP_CAT(_, Tag)]) \
+ ); \
+//
+
+#define BOOST_AUTOMATA_IMPL_PLAIN_TYPE_ASSIGNABLE \
+ Base::operator=(static_cast<Base const&>(copy)); \
+ _input_validator = copy._input_validator; \
+//
+
+#define BOOST_AUTOMATA_IMPL_EXT_TYPE_ASSIGNABLE \
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_ASSIGNABLE \
+ ::boost::fusion::for_each( \
+ copy.get_observer_map() \
+ , observer_map_assign<observer_map>(_observers) \
+ ); \
+//
+
+#define BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_INIT \
+ _input_validator.on_initialize( \
+ builder \
+ , BOOST_AUTOMATA_IMPL_BUILDER_TAG_TYPE(Builder)() \
+ ); \
+//
+
+#define BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_INIT \
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_INIT \
+ ::boost::fusion::for_each( \
+ _observers \
+ , observer_on_initialize_dispatch< \
+ Builder \
+ , BOOST_AUTOMATA_IMPL_BUILDER_TAG_TYPE(Builder) \
+ >(builder) \
+ ); \
+//
+
+#define BOOST_AUTOMATA_IMPL_ANY_TYPE_ASSIGN_OPS(Type) \
+ inline Type& operator=(state const& source_state) \
+ { \
+ this->set_source_state(source_state); \
+ reset(); \
+ return *this; \
+ } \
+//
+
+#define BOOST_AUTOMATA_IMPL_UNDOABLE_TYPE_PROCESS_INPUT \
+ template <typename Input> \
+ inline bool operator()(Input const& i) \
+ { \
+ return \
+ _process_input( \
+ i \
+ , typename ::std::tr1::is_base_of< \
+ discrete_automaton_base_tag \
+ , typename Base::tag \
+ >::type() \
+ ); \
+ } \
+//
+
+#define BOOST_AUTOMATA_IMPL_UNDOABLE_TYPE_ACCESS \
+ inline typename memento<Base>::size_type get_undo_limit() const \
+ { \
+ return _memento.get_save_limit(); \
+ } \
+ inline bool can_undo() const \
+ { \
+ return _memento.can_restore(); \
+ } \
+//
+
+ class ext_type : public Base
+ {
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_PREAMBLE(ext_type)
+
+ protected:
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_DEFAULT_CTOR_HEAD(ext_type)
+ {
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_CTOR
+ }
+
+ BOOST_AUTOMATA_IMPL_ANY_TYPE_ARG_PACK_W_FUNC_CTOR_HEAD(ext_type)
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_ARG_PACK_CTOR_HEAD_SUFFIX(ext_type)
+ {
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_ARG_CTOR(function)
+ }
+
+ BOOST_AUTOMATA_IMPL_ANY_TYPE_ARG_PACK_W_BUILDER_CTOR_HEAD(ext_type)
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_ARG_PACK_CTOR_HEAD_SUFFIX(ext_type)
+ {
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_ARG_CTOR(builder)
+ }
+
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_COPY_CTOR_HEAD(ext_type)
+ {
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_CTOR
+ }
+
+ ext_type& operator=(ext_type const& copy)
+ {
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_ASSIGNABLE
+ return *this;
+ }
+
+ BOOST_AUTOMATA_IMPL_ANY_TYPE_ASSIGN_OPS(ext_type)
+
+ public:
+ template <typename Builder>
+ inline void initialize(Builder builder)
+ {
+ initialize_impl(builder);
+ this->reset_impl();
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_INIT
+ }
+
+ template <typename Builder>
+ inline void
+ initialize(Builder builder, state const& source_state)
+ {
+ initialize_impl(builder, source_state);
+ this->reset_impl();
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_INIT
+ }
+
+ template <typename Builder>
+ inline void
+ initialize(state const& source_state, Builder builder)
+ {
+ initialize_impl(builder, source_state);
+ this->reset_impl();
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_INIT
+ }
+
+ inline observer_map const& get_observer_map() const
+ {
+ return _observers;
+ }
+
+ inline void reset()
+ {
+ this->reset_impl();
+ ::boost::fusion::for_each(
+ _observers
+ , observer_on_reset_dispatch()
+ );
+ }
+
+ template <typename Input>
+ inline bool operator()(Input const& i)
+ {
+ if (_input_validator(i))
+ {
+ if (this->process_input_impl(i))
+ {
+ ::boost::fusion::for_each(
+ _observers
+ , observer_on_accept_input_dispatch<Input>(i)
+ );
+ return true;
+ }
+ else
+ {
+ ::boost::fusion::for_each(
+ _observers
+ , observer_on_reject_input_dispatch<Input>(i)
+ );
+ return false;
+ }
+ }
+ else
+ {
+ ::boost::fusion::for_each(
+ _observers
+ , observer_on_invalid_input_dispatch<Input>(i)
+ );
+ return false;
+ }
+ }
+ };
+
+ class undo_ext_type : public Base
+ {
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_PREAMBLE(undo_ext_type)
+ extensible_memento<Base,observer_map> _memento;
+
+ protected:
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_DEFAULT_CTOR_HEAD(undo_ext_type)
+ , _memento()
+ {
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_CTOR
+ }
+
+ BOOST_AUTOMATA_IMPL_ANY_TYPE_ARG_PACK_W_FUNC_CTOR_HEAD(
+ undo_ext_type
+ )
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_ARG_PACK_CTOR_HEAD_SUFFIX(
+ undo_ext_type
+ )
+ , _memento(
+ args[
+ ::boost::automata::keyword::_undo_limit
+ | ::std::size_t()
+ ]
+ )
+ {
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_ARG_CTOR(function)
+ }
+
+ BOOST_AUTOMATA_IMPL_ANY_TYPE_ARG_PACK_W_BUILDER_CTOR_HEAD(
+ undo_ext_type
+ )
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_ARG_PACK_CTOR_HEAD_SUFFIX(
+ undo_ext_type
+ )
+ , _memento(
+ args[
+ ::boost::automata::keyword::_undo_limit
+ | ::std::size_t()
+ ]
+ )
+ {
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_ARG_CTOR(builder)
+ }
+
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_COPY_CTOR_HEAD(undo_ext_type)
+ , _memento(copy._memento)
+ {
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_CTOR
+ }
+
+ undo_ext_type& operator=(undo_ext_type const& copy)
+ {
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_ASSIGNABLE
+ _memento = copy._memento;
+ return *this;
+ }
+
+ BOOST_AUTOMATA_IMPL_ANY_TYPE_ASSIGN_OPS(undo_ext_type)
+
+ public:
+ template <typename Builder>
+ inline void initialize(Builder builder)
+ {
+ _memento.clear();
+ initialize_impl(builder);
+ this->reset_impl();
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_INIT
+ }
+
+ template <typename Builder>
+ inline void
+ initialize(Builder builder, state const& source_state)
+ {
+ _memento.clear();
+ initialize_impl(builder, source_state);
+ this->reset_impl();
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_INIT
+ }
+
+ template <typename Builder>
+ inline void
+ initialize(state const& source_state, Builder builder)
+ {
+ _memento.clear();
+ initialize_impl(builder, source_state);
+ this->reset_impl();
+ BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_INIT
+ }
+
+ inline observer_map const& get_observer_map() const
+ {
+ return _observers;
+ }
+
+ inline void reset()
+ {
+ _memento.clear();
+ this->reset_impl();
+ ::boost::fusion::for_each(
+ _observers
+ , observer_on_reset_dispatch()
+ );
+ }
+
+ private:
+ template <typename Input>
+ inline bool _process_input(Input const& i, ::std::tr1::true_type)
+ {
+ if (_input_validator(i))
+ {
+ if (is_nontrivial_input(i))
+ {
+ _memento.save(*this, get_observer_map());
+ Base::process_input_impl(i);
+ ::boost::fusion::for_each(
+ _observers
+ , observer_on_accept_input_dispatch<Input>(i)
+ );
+ return true;
+ }
+ else
+ {
+ ::boost::fusion::for_each(
+ _observers
+ , observer_on_reject_input_dispatch<Input>(i)
+ );
+ return false;
+ }
+ }
+ else
+ {
+ ::boost::fusion::for_each(
+ _observers
+ , observer_on_invalid_input_dispatch<Input>(i)
+ );
+ return false;
+ }
+ }
+
+ template <typename Input>
+ inline bool _process_input(Input const& i, ::std::tr1::false_type)
+ {
+ if (_input_validator(i))
+ {
+ _memento.save(*this, get_observer_map());
+
+ if (Base::process_input_impl(i))
+ {
+ ::boost::fusion::for_each(
+ _observers
+ , observer_on_accept_input_dispatch<Input>(i)
+ );
+ return true;
+ }
+ else
+ {
+ ::boost::fusion::for_each(
+ _observers
+ , observer_on_reject_input_dispatch<Input>(i)
+ );
+ return false;
+ }
+ }
+ else
+ {
+ ::boost::fusion::for_each(
+ _observers
+ , observer_on_invalid_input_dispatch<Input>(i)
+ );
+ return false;
+ }
+ }
+
+ public:
+ BOOST_AUTOMATA_IMPL_UNDOABLE_TYPE_PROCESS_INPUT
+
+ BOOST_AUTOMATA_IMPL_UNDOABLE_TYPE_ACCESS
+
+ inline void undo()
+ {
+ if (can_undo())
+ {
+ _memento.restore(*this, _observers);
+ ::boost::fusion::for_each(
+ _observers
+ , observer_on_accept_undo_dispatch()
+ );
+ }
+ else
+ {
+ ::boost::fusion::for_each(
+ _observers
+ , observer_on_reject_undo_dispatch()
+ );
+ }
+ }
+ };
+
+ class plain_type : public Base
+ {
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_PREAMBLE(plain_type)
+
+ protected:
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_DEFAULT_CTOR_HEAD(plain_type)
+ {
+ _input_validator.on_construction();
+ }
+
+ BOOST_AUTOMATA_IMPL_ANY_TYPE_ARG_PACK_W_FUNC_CTOR_HEAD(
+ plain_type
+ )
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_ARG_PACK_CTOR_HEAD_SUFFIX
+ {
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_ARG_CTOR(function)
+ }
+
+ BOOST_AUTOMATA_IMPL_ANY_TYPE_ARG_PACK_W_BUILDER_CTOR_HEAD(
+ plain_type
+ )
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_ARG_PACK_CTOR_HEAD_SUFFIX
+ {
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_ARG_CTOR(builder)
+ }
+
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_COPY_CTOR_HEAD(plain_type)
+ {
+ _input_validator.on_construction();
+ }
+
+ inline plain_type& operator=(plain_type const& copy)
+ {
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_ASSIGNABLE
+ return *this;
+ }
+
+ BOOST_AUTOMATA_IMPL_ANY_TYPE_ASSIGN_OPS(plain_type)
+
+ public:
+ template <typename Builder>
+ inline void initialize(Builder builder)
+ {
+ initialize_impl(builder);
+ this->reset_impl();
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_INIT
+ }
+
+ template <typename Builder>
+ inline void
+ initialize(Builder builder, state const& source_state)
+ {
+ initialize_impl(builder, source_state);
+ this->reset_impl();
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_INIT
+ }
+
+ template <typename Builder>
+ inline void
+ initialize(state const& source_state, Builder builder)
+ {
+ initialize_impl(builder, source_state);
+ this->reset_impl();
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_INIT
+ }
+
+ inline void reset()
+ {
+ this->reset_impl();
+ }
+
+ template <typename Input>
+ inline bool operator()(Input const& i)
+ {
+ return (
+ _input_validator(i)
+ && this->process_input_impl(i)
+ );
+ }
+ };
+
+ class undo_plain_type : public Base
+ {
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_PREAMBLE(undo_plain_type)
+ memento<Base> _memento;
+
+ protected:
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_DEFAULT_CTOR_HEAD(undo_plain_type)
+ , _memento()
+ {
+ }
+
+ BOOST_AUTOMATA_IMPL_ANY_TYPE_ARG_PACK_W_FUNC_CTOR_HEAD(
+ undo_plain_type
+ )
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_ARG_PACK_CTOR_HEAD_SUFFIX
+ , _memento(
+ args[
+ ::boost::automata::keyword::_undo_limit
+ | ::std::size_t()
+ ]
+ )
+ {
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_ARG_CTOR(function)
+ }
+
+ BOOST_AUTOMATA_IMPL_ANY_TYPE_ARG_PACK_W_BUILDER_CTOR_HEAD(
+ undo_plain_type
+ )
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_ARG_PACK_CTOR_HEAD_SUFFIX
+ , _memento(
+ args[
+ ::boost::automata::keyword::_undo_limit
+ | ::std::size_t()
+ ]
+ )
+ {
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_ARG_CTOR(builder)
+ }
+
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_COPY_CTOR_HEAD(undo_plain_type)
+ , _memento(copy._memento)
+ {
+ }
+
+ inline undo_plain_type& operator=(undo_plain_type const& copy)
+ {
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_ASSIGNABLE
+ _memento = copy._memento;
+ return *this;
+ }
+
+ BOOST_AUTOMATA_IMPL_ANY_TYPE_ASSIGN_OPS(undo_plain_type)
+
+ public:
+ template <typename Builder>
+ inline void initialize(Builder builder)
+ {
+ _memento.clear();
+ initialize_impl(builder);
+ this->reset_impl();
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_INIT
+ }
+
+ template <typename Builder>
+ inline void
+ initialize(Builder builder, state const& source_state)
+ {
+ _memento.clear();
+ initialize_impl(builder, source_state);
+ this->reset_impl();
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_INIT
+ }
+
+ template <typename Builder>
+ inline void
+ initialize(state const& source_state, Builder builder)
+ {
+ _memento.clear();
+ initialize_impl(builder, source_state);
+ this->reset_impl();
+ BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_INIT
+ }
+
+ inline void reset()
+ {
+ _memento.clear();
+ this->reset_impl();
+ }
+
+ private:
+ template <typename Input>
+ inline bool _process_input(Input const& i, ::std::tr1::true_type)
+ {
+ if (_input_validator(i) && is_nontrivial_input(i))
+ {
+ _memento.save(*this);
+ this->process_input_impl(i);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ template <typename Input>
+ inline bool _process_input(Input const& i, ::std::tr1::false_type)
+ {
+ if (_input_validator(i))
+ {
+ _memento.save(*this);
+ return this->process_input_impl(i);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public:
+ BOOST_AUTOMATA_IMPL_UNDOABLE_TYPE_PROCESS_INPUT
+
+ BOOST_AUTOMATA_IMPL_UNDOABLE_TYPE_ACCESS
+
+ inline void undo()
+ {
+ if (can_undo())
+ {
+ _memento.restore(*this);
+ }
+ }
+ };
+
+ typedef typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::result_of::empty<Policies>::type
+ , ::boost::mpl::if_<
+ IsUndoable
+ , undo_plain_type
+ , plain_type
+ >
+ , ::boost::mpl::if_<
+ IsUndoable
+ , undo_ext_type
+ , ext_type
+ >
+ >::type
+ Base0;
+
+ public:
+ struct type : public Base0
+ {
+ typedef typename Base0::transition_function
+ transition_function;
+ typedef typename Base0::state
+ state;
+ typedef typename Base0::traits
+ traits;
+ typedef typename Base0::observer_map
+ observer_map;
+
+ protected:
+ type() : Base0()
+ {
+ }
+
+ public:
+ template <typename ArgumentPack>
+ type(ArgumentPack const& args)
+ : Base0(
+ args
+ , ::std::tr1::is_same<
+ typename ::boost::parameter::value_type<
+ ArgumentPack
+ , ::boost::automata::keyword::tag::builder
+ , ::boost::mpl::void_
+ >::type
+ , boost::mpl::void_
+ >()
+ )
+ {
+ }
+
+ protected:
+ type(type const& copy) : Base0(static_cast<Base0 const&>(copy))
+ {
+ }
+
+ inline type& operator=(type const& copy)
+ {
+ Base0::operator=(static_cast<Base0 const&>(copy));
+ return *this;
+ }
+
+ inline type& operator=(state const& src_state)
+ {
+ Base0::operator=(src_state);
+ return *this;
+ }
+
+ template <typename TFunction>
+ inline type& operator=(TFunction f)
+ {
+ Base0::initialize(f);
+ return *this;
+ }
+ };
+
+#undef BOOST_AUTOMATA_IMPL_UNDOABLE_TYPE_ACCESS
+#undef BOOST_AUTOMATA_IMPL_UNDOABLE_TYPE_PROCESS_INPUT
+#undef BOOST_AUTOMATA_IMPL_ANY_TYPE_ASSIGN_OPS
+#undef BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_INIT
+#undef BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_INIT
+#undef BOOST_AUTOMATA_IMPL_EXT_TYPE_ASSIGNABLE
+#undef BOOST_AUTOMATA_IMPL_PLAIN_TYPE_ASSIGNABLE
+#undef BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_ARG_CTOR
+#undef BOOST_AUTOMATA_IMPL_PLAIN_TYPE_OBSERVERS_ON_ARG_CTOR
+#undef BOOST_AUTOMATA_IMPL_EXT_TYPE_OBSERVERS_ON_CTOR
+#undef BOOST_AUTOMATA_IMPL_EXT_TYPE_COPY_CTOR_HEAD
+#undef BOOST_AUTOMATA_IMPL_PLAIN_TYPE_COPY_CTOR_HEAD
+#undef BOOST_AUTOMATA_IMPL_EXT_TYPE_ARG_PACK_CTOR_HEAD_SUFFIX
+#undef BOOST_AUTOMATA_IMPL_PLAIN_TYPE_ARG_PACK_CTOR_HEAD_SUFFIX
+#undef BOOST_AUTOMATA_IMPL_ANY_TYPE_ARG_PACK_W_BUILDER_CTOR_HEAD
+#undef BOOST_AUTOMATA_IMPL_ANY_TYPE_ARG_PACK_W_FUNC_CTOR_HEAD
+#undef BOOST_AUTOMATA_IMPL_EXT_TYPE_DEFAULT_CTOR_HEAD
+#undef BOOST_AUTOMATA_IMPL_PLAIN_TYPE_DEFAULT_CTOR_HEAD
+#undef BOOST_AUTOMATA_IMPL_EXT_TYPE_PREAMBLE
+#undef BOOST_AUTOMATA_IMPL_PLAIN_TYPE_PREAMBLE
+#undef BOOST_AUTOMATA_IMPL_ANY_TYPE_PREAMBLE
+#undef BOOST_AUTOMATA_IMPL_BUILDER_TAG_TYPE
+#undef BOOST_AUTOMATA_IMPL_ARG_DATA_TYPE
+ };
+}}} // namespace boost::automata::_detail
+
+#endif // BOOST_AUTOMATA__DETAIL_IMPL_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/_detail/memento.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/_detail/memento.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,166 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA__DETAIL_MEMENTO_HPP_INCLUDED
+#define BOOST_AUTOMATA__DETAIL_MEMENTO_HPP_INCLUDED
+
+#include <deque>
+
+namespace boost { namespace automata { namespace _detail {
+
+ template <typename Snapshot>
+ class memento
+ {
+ typedef ::std::deque<Snapshot*> Snapshots;
+
+ public:
+ typedef typename Snapshots::size_type size_type;
+
+ private:
+ Snapshots _snapshots;
+ size_type _limit;
+
+ public:
+ explicit memento(size_type const limit);
+
+ memento(memento const& copy);
+
+ memento& operator=(memento const& copy);
+
+ ~memento();
+
+ void clear();
+
+ size_type get_save_limit() const;
+
+ void save(Snapshot const& snapshot);
+
+ bool can_restore() const;
+
+ void restore(Snapshot& snapshot);
+
+ private:
+ void _clone(memento const& copy);
+ };
+
+ template <typename Snapshot>
+ memento<Snapshot>::memento(size_type const limit)
+ : _snapshots(), _limit(limit)
+ {
+ }
+
+ template <typename Snapshot>
+ memento<Snapshot>::memento(memento const& copy)
+ : _snapshots(), _limit(copy._limit)
+ {
+ _clone(copy);
+ }
+
+ template <typename Snapshot>
+ memento<Snapshot>& memento<Snapshot>::operator=(memento const& copy)
+ {
+ if (this != &copy)
+ {
+ clear();
+ _clone(copy);
+ _limit = copy._limit;
+ }
+
+ return *this;
+ }
+
+ template <typename Snapshot>
+ memento<Snapshot>::~memento()
+ {
+ clear();
+ }
+
+ template <typename Snapshot>
+ void memento<Snapshot>::clear()
+ {
+ for (
+ typename Snapshots::iterator itr = _snapshots.begin();
+ itr != _snapshots.end();
+ ++itr
+ )
+ {
+ delete *itr;
+ }
+
+ _snapshots.clear();
+ }
+
+ template <typename Snapshot>
+ void memento<Snapshot>::_clone(memento const& copy)
+ {
+ typename Snapshots::const_iterator copy_end = copy._snapshots.end();
+
+ for (
+ typename Snapshots::const_iterator
+ copy_itr = copy._snapshots.begin();
+ copy_itr != copy_end;
+ ++copy_itr
+ )
+ {
+ _snapshots.push_back(new Snapshot(*(*copy_itr)));
+ }
+ }
+
+ template <typename Snapshot>
+ inline typename memento<Snapshot>::size_type
+ memento<Snapshot>::get_save_limit() const
+ {
+ return _limit;
+ }
+
+ template <typename Snapshot>
+ void memento<Snapshot>::save(Snapshot const& snapshot)
+ {
+ switch (_limit)
+ {
+ case 0:
+ _snapshots.push_back(new Snapshot(snapshot));
+ break;
+
+ case 1:
+ if (_snapshots.empty())
+ {
+ _snapshots.push_back(new Snapshot(snapshot));
+ }
+ else
+ {
+ *(_snapshots.back()) = snapshot;
+ }
+ break;
+
+ default:
+ _snapshots.push_back(new Snapshot(snapshot));
+
+ if (_limit < _snapshots.size())
+ {
+ delete _snapshots.front();
+ _snapshots.pop_front();
+ }
+ break;
+ }
+ }
+
+ template <typename Snapshot>
+ inline bool memento<Snapshot>::can_restore() const
+ {
+ return !_snapshots.empty();
+ }
+
+ template <typename Snapshot>
+ void memento<Snapshot>::restore(Snapshot& snapshot)
+ {
+ snapshot = *(_snapshots.back());
+ delete _snapshots.back();
+ _snapshots.pop_back();
+ }
+}}} // namespace boost::automata::_detail
+
+#endif // BOOST_AUTOMATA__DETAIL_MEMENTO_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/automaton.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/automaton.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,297 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_AUTOMATON_HPP_INCLUDED
+#define BOOST_AUTOMATA_AUTOMATON_HPP_INCLUDED
+
+#include <boost/preprocessor/comparison/less.hpp>
+#include <boost/parameter.hpp>
+#include <boost/parameter/preprocessor.hpp>
+
+#if BOOST_PP_LESS(BOOST_PARAMETER_MAX_ARITY, 5)
+#error Set BOOST_PARAMETER_MAX_ARITY to 5 or more.
+#endif
+
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/fusion/container/list/cons.hpp>
+#include <boost/detail/metafunction/data_type.hpp>
+#include <boost/automata/keyword/template.hpp>
+#include <boost/automata/keyword/name.hpp>
+#include <boost/automata/policy/default_input_validation.hpp>
+#include <boost/automata/_detail/impl.hpp>
+
+//[reference__automaton
+namespace boost { namespace automata {
+
+//<-
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+#define BOOST_AUTOMATA_AUTOMATON_ARGS \
+ typename ::boost::parameter::parameters< \
+ ::boost::parameter::required<keyword::tag::_BaseGenerator> \
+ , ::boost::parameter::required<keyword::tag::_Function> \
+ , ::boost::parameter::optional<keyword::tag::_Policies> \
+ , ::boost::parameter::optional<keyword::tag::_InputValidationPolicy> \
+ , ::boost::parameter::optional<keyword::tag::_IsUndoable> \
+ >::BOOST_NESTED_TEMPLATE bind<T0,T1,T2,T3,T4,parameter::void_>::type \
+//
+#else
+#define BOOST_AUTOMATA_AUTOMATON_ARGS \
+ typename ::boost::parameter::parameters< \
+ ::boost::parameter::required<keyword::tag::_BaseGenerator> \
+ , ::boost::parameter::required<keyword::tag::_Function> \
+ , ::boost::parameter::optional<keyword::tag::_Policies> \
+ , ::boost::parameter::optional<keyword::tag::_InputValidationPolicy> \
+ , ::boost::parameter::optional<keyword::tag::_IsUndoable> \
+ >::BOOST_NESTED_TEMPLATE bind<T0,T1,T2,T3,T4>::type \
+//
+#endif
+
+#define BOOST_AUTOMATA_AUTOMATON_REQUIRED_TPL_PARAM(_args, _keyword) \
+ typename ::boost::parameter::value_type< \
+ _args \
+ , keyword::tag::_keyword \
+ >::type \
+//
+
+#define BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM(_args, _keyword, _default) \
+ typename ::boost::parameter::value_type< \
+ _args \
+ , keyword::tag::_keyword \
+ , _default \
+ >::type \
+//
+//->
+
+ template <
+ typename T0
+ , typename T1
+ , typename T2 = ::boost::parameter::void_
+ , typename T3 = ::boost::parameter::void_
+ , typename T4 = ::boost::parameter::void_
+ >
+ class automaton
+ : public // Base
+ //<-
+ _detail::impl<
+ BOOST_AUTOMATA_AUTOMATON_REQUIRED_TPL_PARAM(
+ BOOST_AUTOMATA_AUTOMATON_ARGS
+ , _BaseGenerator
+ )
+ , BOOST_AUTOMATA_AUTOMATON_REQUIRED_TPL_PARAM(
+ BOOST_AUTOMATA_AUTOMATON_ARGS
+ , _Function
+ )
+ , BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM(
+ BOOST_AUTOMATA_AUTOMATON_ARGS
+ , _Policies
+ , ::boost::fusion::nil
+ )
+ , BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM(
+ BOOST_AUTOMATA_AUTOMATON_ARGS
+ , _InputValidationPolicy
+ , default_input_validation_policy
+ )
+ , BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM(
+ BOOST_AUTOMATA_AUTOMATON_ARGS
+ , _IsUndoable
+ , ::boost::mpl::false_
+ )
+ >::type
+ //->
+ {
+ //<-
+ typedef BOOST_AUTOMATA_AUTOMATON_ARGS
+ Args;
+ typedef BOOST_AUTOMATA_AUTOMATON_REQUIRED_TPL_PARAM(
+ Args
+ , _BaseGenerator
+ )
+ BaseGenerator;
+ typedef BOOST_AUTOMATA_AUTOMATON_REQUIRED_TPL_PARAM(
+ Args
+ , _Function
+ )
+ Function;
+ typedef BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM(
+ Args
+ , _Policies
+ , ::boost::fusion::nil
+ )
+ Policies;
+ typedef BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM(
+ Args
+ , _InputValidationPolicy
+ , default_input_validation_policy
+ )
+ InputValidationPolicy;
+ typedef BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM(
+ Args
+ , _IsUndoable
+ , ::boost::mpl::false_
+ )
+ IsUndoable;
+ typedef typename _detail::impl<
+ BaseGenerator
+ , Function
+ , Policies
+ , InputValidationPolicy
+ , IsUndoable
+ >::type
+ Base;
+ //->
+
+ public:
+ typedef typename Base::transition_function
+ transition_function;
+ typedef typename Base::state
+ state;
+ typedef typename Base::observer_map
+ observer_map;
+ typedef typename Base::traits
+ traits;
+
+ automaton() : Base()
+ {
+ }
+
+ //<-
+#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
+ private:
+ typedef ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , Policies
+ >
+ PoliciesPredicate;
+ typedef ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , InputValidationPolicy
+ >
+ InputValidationPredicate;
+ typedef ::std::tr1::is_convertible< ::boost::mpl::_,state>
+ StatePredicate;
+ typedef ::std::tr1::is_integral<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ >
+ UndoLimitPredicate;
+
+ public:
+ BOOST_PARAMETER_CONSTRUCTOR(
+ automaton, (Base), keyword::tag,
+ (deduced
+ (required
+ (builder, *)
+ )
+ (optional
+ (policies, *(PoliciesPredicate))
+ (input_validation_policy, *(InputValidationPredicate))
+ (source_state, *(StatePredicate))
+ (undo_limit, *(UndoLimitPredicate))
+ )
+ )
+ )
+#else // !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
+ //->
+ BOOST_PARAMETER_CONSTRUCTOR(
+ automaton, (Base), keyword::tag,
+ (required
+ (builder
+ , *
+ )
+ )
+ (deduced
+ (optional
+ (policies
+ , *(
+ ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , Policies
+ >
+ )
+ )
+ (input_validation_policy
+ , *(
+ ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , InputValidationPolicy
+ >
+ )
+ )
+ (source_state
+ , *(::std::tr1::is_convertible< ::boost::mpl::_,state>)
+ )
+ (undo_limit
+ , *(
+ ::std::tr1::is_integral<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ >
+ )
+ )
+ )
+ )
+ )
+ //<-
+#endif // BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
+ //->
+
+ automaton(automaton const& copy)
+ : Base(static_cast<Base const&>(copy))
+ {
+ }
+
+ //<-
+ inline
+ //->
+ automaton& operator=(automaton const& copy)
+ //<-
+ {
+ if (this != &copy)
+ {
+ Base::operator=(static_cast<Base const&>(copy));
+ }
+
+ return *this;
+ }
+ //->
+ ;
+
+ //<-
+ inline
+ //->
+ automaton& operator=(state const& source_state)
+ //<-
+ {
+ Base::operator=(source_state);
+ return *this;
+ }
+ //->
+ ;
+
+ template <typename TFunction>
+ //<-
+ inline
+ //->
+ automaton& operator=(TFunction f)
+ //<-
+ {
+ Base::operator=(f);
+ return *this;
+ }
+ //->
+ ;
+ };
+
+//<-
+#undef BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM
+#undef BOOST_AUTOMATA_AUTOMATON_REQUIRED_TPL_PARAM
+#undef BOOST_AUTOMATA_AUTOMATON_ARGS
+//->
+
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_AUTOMATON_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/builder/from_graph.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/builder/from_graph.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,894 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_BUILDER_FROM_GRAPH_HPP_INCLUDED
+#define BOOST_AUTOMATA_BUILDER_FROM_GRAPH_HPP_INCLUDED
+
+#include <boost/preprocessor/comparison/less.hpp>
+#include <boost/parameter.hpp>
+#include <boost/parameter/preprocessor.hpp>
+
+#if BOOST_PP_LESS(BOOST_PARAMETER_MAX_ARITY, 4)
+#error Set BOOST_PARAMETER_MAX_ARITY to 4 or more.
+#endif
+
+#include <vector>
+#include <boost/tr1/type_traits.hpp>
+#include <boost/tr1/tuple.hpp>
+#include <boost/config.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/void.hpp>
+#include <boost/functional/value_factory.hpp>
+#include <boost/fusion/algorithm/transformation/transform.hpp>
+#include <boost/fusion/container/list/cons.hpp>
+#include <boost/fusion/container/map/convert.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/fusion/support/pair.hpp>
+#include <boost/range.hpp>
+#include <boost/property_map/property_map.hpp>
+#include <boost/graph/graph_concepts.hpp>
+#include <boost/graph/graph_traits.hpp>
+#include <boost/graph/properties.hpp>
+#include <boost/detail/metafunction/data_type.hpp>
+#include <boost/detail/metafunction/property_map_key.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/concept_check.hpp>
+#include <boost/automata/keyword/template.hpp>
+#include <boost/automata/keyword/name.hpp>
+
+//[reference__builder_from_graph
+namespace boost {
+ namespace automata {
+
+ template <
+ typename Graph
+ , typename VertexStateMap
+ , typename EdgeInputMap
+ , typename Function
+ >
+ void
+ build_from_graph(
+ Graph const& graph
+ , VertexStateMap const& vertex_state_map
+ , EdgeInputMap const& edge_input_map
+ , Function& function
+ , dpda_transition_function_tag
+ )
+ {
+ BOOST_CONCEPT_ASSERT((DPDATransitionFunction<Function>));
+
+ function.reset(::boost::num_vertices(graph));
+
+ typename ::boost::graph_traits<Graph>::edge_iterator ei, eend;
+
+ for (
+ ::std::tr1::tie(ei, eend) = ::boost::edges(graph);
+ ei != eend;
+ ++ei
+ )
+ {
+ typename property_traits<EdgeInputMap>::value_type const&
+ i = get(edge_input_map, *ei);
+ typename Function::result_map
+ r_map(
+ ::boost::fusion::make_pair<next_state_key>(
+ get(vertex_state_map, target(*ei, graph))
+ )
+ , ::boost::fusion::make_pair<push_to_stack_key>(
+ ::boost::fusion::at_key<push_to_stack_key>(i)
+ )
+ );
+
+ if (
+ typename Function::optional_stack_element const&
+ o_e = ::boost::fusion::at_key<pop_from_stack_key>(i)
+ )
+ {
+ function.set_transition(
+ get(vertex_state_map, source(*ei, graph))
+ , ::boost::fusion::at_key<input_symbol_key>(i)
+ , *o_e
+ , r_map
+ );
+ }
+ else
+ {
+ function.set_transition(
+ get(vertex_state_map, source(*ei, graph))
+ , ::boost::fusion::at_key<input_symbol_key>(i)
+ , r_map
+ );
+ }
+ }
+ }
+
+ template <
+ typename Graph
+ , typename VertexStateMap
+ , typename EdgeInputMap
+ , typename Function
+ >
+ void
+ build_from_graph(
+ Graph const& graph
+ , VertexStateMap const& vertex_state_map
+ , EdgeInputMap const& edge_input_map
+ , Function& function
+ , tabular_transition_function_tag
+ )
+ {
+ BOOST_CONCEPT_ASSERT((TabularTransitionFunction<Function>));
+
+ typename Function::second_argument_type
+ input = typename Function::second_argument_type();
+ typename ::boost::graph_traits<Graph>::edge_iterator ei, eend;
+
+ for (
+ ::std::tr1::tie(ei, eend) = ::boost::edges(graph);
+ ei != eend;
+ ++ei
+ )
+ {
+ if (input < get(edge_input_map, *ei))
+ {
+ input = get(edge_input_map, *ei);
+ }
+ }
+
+ if (input)
+ {
+ function.reset(::boost::num_vertices(graph), ++input);
+
+ for (
+ ::std::tr1::tie(ei, eend) = ::boost::edges(graph);
+ ei != eend;
+ ++ei
+ )
+ {
+ function.set_transition(
+ get(vertex_state_map, source(*ei, graph))
+ , get(edge_input_map, *ei)
+ , get(vertex_state_map, target(*ei, graph))
+ );
+ }
+ }
+ }
+
+ template <
+ typename Graph
+ , typename VertexStateMap
+ , typename EdgeInputMap
+ , typename Function
+ >
+ void
+ build_from_graph(
+ Graph const& graph
+ , VertexStateMap const& vertex_state_map
+ , EdgeInputMap const& edge_input_map
+ , Function& function
+ , mapped_input_tabular_transition_function_tag
+ )
+ {
+ BOOST_CONCEPT_ASSERT((MappedInputTabularTransitionFunction<Function>));
+
+ std::vector<typename Function::second_argument_type> inputs;
+ typename ::boost::graph_traits<Graph>::edge_iterator ei, eend;
+
+ for (
+ ::std::tr1::tie(ei, eend) = ::boost::edges(graph);
+ ei != eend;
+ ++ei
+ )
+ {
+ inputs.push_back(get(edge_input_map, *ei));
+ }
+
+ function.reset(::boost::num_vertices(graph), inputs);
+
+ for (
+ ::std::tr1::tie(ei, eend) = ::boost::edges(graph);
+ ei != eend;
+ ++ei
+ )
+ {
+ function.set_transition(
+ get(vertex_state_map, source(*ei, graph))
+ , get(edge_input_map, *ei)
+ , get(vertex_state_map, target(*ei, graph))
+ );
+ }
+ }
+
+ template <
+ typename Graph
+ , typename VertexStateMap
+ , typename EdgeInputMap
+ , typename Function
+ >
+ void
+ build_from_graph(
+ Graph const& graph
+ , VertexStateMap const& vertex_state_map
+ , EdgeInputMap const& edge_input_map
+ , Function& function
+ , mapped_input_transition_function_tag
+ )
+ {
+ BOOST_CONCEPT_ASSERT((MappedInputTransitionFunction<Function>));
+
+ function.reset(num_vertices(graph));
+
+ typename ::boost::graph_traits<Graph>::edge_iterator ei, eend;
+
+ for (
+ ::std::tr1::tie(ei, eend) = ::boost::edges(graph);
+ ei != eend;
+ ++ei
+ )
+ {
+ function.set_transition(
+ get(vertex_state_map, source(*ei, graph))
+ , get(edge_input_map, *ei)
+ , get(vertex_state_map, target(*ei, graph))
+ );
+ }
+ }
+
+ template <
+ typename Graph
+ , typename VertexStateMap
+ , typename Function
+ >
+ void
+ build_from_graph(
+ Graph const& graph
+ , VertexStateMap const& vertex_state_map
+ , Function& function
+ , next_state_transition_function_tag
+ )
+ {
+ BOOST_CONCEPT_ASSERT((NextStateTransitionFunction<Function>));
+
+ function.reset(::boost::num_vertices(graph));
+
+ typename ::boost::graph_traits<Graph>::vertex_iterator vi, vend;
+ typename ::boost::graph_traits<Graph>::adjacency_iterator ai, aend;
+ typename Function::state state;
+
+ for (
+ ::std::tr1::tie(vi, vend) = ::boost::vertices(graph);
+ vi != vend;
+ ++vi
+ )
+ {
+ state = get(vertex_state_map, *vi);
+
+ for (
+ ::std::tr1::tie(ai, aend) = ::boost::adjacent_vertices(
+ *vi
+ , graph
+ );
+ ai != aend;
+ ++ai
+ )
+ {
+ function.add_transition(state, get(vertex_state_map, *ai));
+ }
+ }
+ }
+ } // namespace automata
+
+ enum edge_input_t
+ {
+ edge_input
+ };
+
+ template <>
+ struct property_kind<edge_input_t>
+ {
+ typedef edge_property_tag type;
+ };
+
+ namespace automata {
+ namespace _detail {
+
+ template <
+ typename Graph
+ , typename VertexStateMap
+ , typename EdgeInputMap
+ , typename Policies
+ >
+ class builder_from_graph_w_eim
+ {
+ BOOST_CONCEPT_ASSERT((
+ ::boost::concepts::VertexAndEdgeListGraph<Graph>
+ ));
+ typedef typename ::boost::graph_traits<Graph>::vertex_descriptor
+ Vertex;
+ BOOST_CONCEPT_ASSERT((
+ ReadablePropertyMapConcept<VertexStateMap,Vertex>
+ ));
+ BOOST_CONCEPT_ASSERT((
+ ReadablePropertyMapConcept<
+ EdgeInputMap
+ , typename ::boost::graph_traits<Graph>::edge_descriptor
+ >
+ ));
+
+ Graph const& _g;
+ VertexStateMap const& _vertex_state_map;
+ EdgeInputMap const& _edge_input_map;
+
+ class observer_builder_maker
+ {
+ builder_from_graph_w_eim const& _builder;
+
+ public:
+ observer_builder_maker(builder_from_graph_w_eim const& builder)
+ : _builder(builder)
+ {
+ }
+
+ template <typename T>
+ struct result;
+
+ template <typename BuilderMaker, typename T>
+ struct result<BuilderMaker(T)>
+ {
+ private:
+ typedef typename ::boost::detail::data_type<T>::type
+ T_data;
+
+ public:
+ typedef ::boost::fusion::pair<
+ typename T_data::key_type
+ , typename ::boost::mpl::apply_wrap3<
+ T_data
+ , Graph
+ , VertexStateMap
+ , EdgeInputMap
+ >::type
+ >
+ type;
+ };
+
+ template <typename T>
+ inline ::boost::fusion::pair<
+ typename T::key_type
+ , typename ::boost::mpl::apply_wrap3<
+ T
+ , Graph
+ , VertexStateMap
+ , EdgeInputMap
+ >::type
+ >
+ operator()(T const& t) const
+ {
+ return ::boost::fusion::pair<
+ typename T::key_type
+ , typename ::boost::mpl::apply_wrap3<
+ T
+ , Graph
+ , VertexStateMap
+ , EdgeInputMap
+ >::type
+ >(
+ typename ::boost::mpl::apply_wrap3<
+ T
+ , Graph
+ , VertexStateMap
+ , EdgeInputMap
+ >::type(
+ t
+ , _builder._g
+ , _builder._vertex_state_map
+ , _builder._edge_input_map
+ )
+ );
+ }
+ };
+
+ public:
+ typedef typename ::boost::fusion::result_of::as_map<
+ typename ::boost::fusion::result_of::transform<
+ Policies
+ , observer_builder_maker
+ >::type
+ >::type
+ observer_builder_map;
+
+ private:
+ observer_builder_map _observer_builder_map;
+
+ public:
+ template <typename ArgumentPack>
+ builder_from_graph_w_eim(ArgumentPack const& args);
+
+ template <typename Function>
+ void operator()(Function& function) const;
+
+ observer_builder_map const& get_observer_builder_map() const;
+ };
+
+ template <
+ typename Graph
+ , typename VertexStateMap
+ , typename EdgeInputMap
+ , typename Policies
+ >
+ template <typename ArgumentPack>
+ builder_from_graph_w_eim<
+ Graph
+ , VertexStateMap
+ , EdgeInputMap
+ , Policies
+ >::builder_from_graph_w_eim(ArgumentPack const& args)
+ : _g(args[::boost::automata::keyword::_graph])
+ , _vertex_state_map(args[::boost::automata::keyword::_vertex_state_map])
+ , _edge_input_map(
+ args[
+ ::boost::automata::keyword::_edge_input_map
+ || value_factory< ::boost::mpl::void_>()
+ ]
+ )
+ , _observer_builder_map(
+ ::boost::fusion::as_map(
+ ::boost::fusion::transform(
+ args[
+ ::boost::automata::keyword::_policies
+ || value_factory<Policies>()
+ ]
+ , observer_builder_maker(*this)
+ )
+ )
+ )
+ {
+ }
+
+ template <
+ typename Graph
+ , typename VertexStateMap
+ , typename EdgeInputMap
+ , typename Policies
+ >
+ template <typename Function>
+ inline void
+ builder_from_graph_w_eim<
+ Graph
+ , VertexStateMap
+ , EdgeInputMap
+ , Policies
+ >::operator()(Function& function) const
+ {
+ build_from_graph(
+ _g
+ , _vertex_state_map
+ , _edge_input_map
+ , function
+ , typename Function::tag()
+ );
+ }
+
+ template <
+ typename Graph
+ , typename VertexStateMap
+ , typename EdgeInputMap
+ , typename Policies
+ >
+ inline typename builder_from_graph_w_eim<
+ Graph
+ , VertexStateMap
+ , EdgeInputMap
+ , Policies
+ >::observer_builder_map const&
+ builder_from_graph_w_eim<
+ Graph
+ , VertexStateMap
+ , EdgeInputMap
+ , Policies
+ >::get_observer_builder_map() const
+ {
+ return _observer_builder_map;
+ }
+
+ template <typename Graph, typename VertexStateMap, typename Policies>
+ class builder_from_graph_wo_eim
+ {
+ BOOST_CONCEPT_ASSERT((
+ ::boost::concepts::VertexListGraph<Graph>
+ ));
+ BOOST_CONCEPT_ASSERT((
+ ::boost::concepts::AdjacencyGraph<Graph>
+ ));
+ typedef typename ::boost::graph_traits<Graph>::vertex_descriptor
+ Vertex;
+ BOOST_CONCEPT_ASSERT((
+ ReadablePropertyMapConcept<VertexStateMap,Vertex>
+ ));
+
+ Graph const& _g;
+ VertexStateMap const& _vertex_state_map;
+
+ class observer_builder_maker
+ {
+ builder_from_graph_wo_eim const& _builder;
+
+ public:
+ observer_builder_maker(builder_from_graph_wo_eim const& builder)
+ : _builder(builder)
+ {
+ }
+
+ template <typename T>
+ struct result;
+
+ template <typename BuilderMaker, typename T>
+ struct result<BuilderMaker(T)>
+ {
+ private:
+ typedef typename ::boost::detail::data_type<T>::type
+ T_data;
+
+ public:
+ typedef ::boost::fusion::pair<
+ typename T_data::key_type
+ , typename ::boost::mpl::apply_wrap2<
+ T_data
+ , Graph
+ , VertexStateMap
+ >::type
+ >
+ type;
+ };
+
+ template <typename T>
+ inline ::boost::fusion::pair<
+ typename T::key_type
+ , typename ::boost::mpl::apply_wrap2<
+ T
+ , Graph
+ , VertexStateMap
+ >::type
+ >
+ operator()(T const& t) const
+ {
+ return ::boost::fusion::pair<
+ typename T::key_type
+ , typename ::boost::mpl::apply_wrap2<
+ T
+ , Graph
+ , VertexStateMap
+ >::type
+ >(
+ typename ::boost::mpl::apply_wrap2<
+ T
+ , Graph
+ , VertexStateMap
+ >::type(
+ t
+ , _builder._g
+ , _builder._vertex_state_map
+ )
+ );
+ }
+ };
+
+ public:
+ typedef typename ::boost::fusion::result_of::as_map<
+ typename ::boost::fusion::result_of::transform<
+ Policies
+ , observer_builder_maker
+ >::type
+ >::type
+ observer_builder_map;
+
+ private:
+ observer_builder_map _observer_builder_map;
+
+ public:
+ template <typename ArgumentPack>
+ builder_from_graph_wo_eim(ArgumentPack const& args);
+
+ template <typename Function>
+ void operator()(Function& function) const;
+
+ observer_builder_map const& get_observer_builder_map() const;
+ };
+
+ template <typename Graph, typename VertexStateMap, typename Policies>
+ template <typename ArgumentPack>
+ builder_from_graph_wo_eim<
+ Graph
+ , VertexStateMap
+ , Policies
+ >::builder_from_graph_wo_eim(ArgumentPack const& args)
+ : _g(args[::boost::automata::keyword::_graph])
+ , _vertex_state_map(args[::boost::automata::keyword::_vertex_state_map])
+ , _observer_builder_map(
+ ::boost::fusion::as_map(
+ ::boost::fusion::transform(
+ args[
+ ::boost::automata::keyword::_policies
+ || value_factory<Policies>()
+ ]
+ , observer_builder_maker(*this)
+ )
+ )
+ )
+ {
+ }
+
+ template <typename Graph, typename VertexStateMap, typename Policies>
+ template <typename Function>
+ inline void
+ builder_from_graph_wo_eim<Graph,VertexStateMap,Policies>::operator()(
+ Function& function
+ ) const
+ {
+ build_from_graph(
+ _g
+ , _vertex_state_map
+ , function
+ , typename Function::tag()
+ );
+ }
+
+ template <typename Graph, typename VertexStateMap, typename Policies>
+ inline typename builder_from_graph_wo_eim<
+ Graph
+ , VertexStateMap
+ , Policies
+ >::observer_builder_map const&
+ builder_from_graph_wo_eim<
+ Graph
+ , VertexStateMap
+ , Policies
+ >::get_observer_builder_map() const
+ {
+ return _observer_builder_map;
+ }
+ } // namespace _detail
+
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+#define BOOST_AUTOMATA_BUILDER_ARG_TYPE \
+ typename ::boost::parameter::parameters< \
+ ::boost::parameter::required<keyword::tag::_Graph> \
+ , ::boost::parameter::required<keyword::tag::_VertexStateMap> \
+ , ::boost::parameter::optional<keyword::tag::_EdgeInputMap> \
+ , ::boost::parameter::optional<keyword::tag::_Policies> \
+ >::BOOST_NESTED_TEMPLATE bind<T0,T1,T2,T3,boost::parameter::void_>::type \
+//
+#else
+#define BOOST_AUTOMATA_BUILDER_ARG_TYPE \
+ typename ::boost::parameter::parameters< \
+ ::boost::parameter::required<keyword::tag::_Graph> \
+ , ::boost::parameter::required<keyword::tag::_VertexStateMap> \
+ , ::boost::parameter::optional<keyword::tag::_EdgeInputMap> \
+ , ::boost::parameter::optional<keyword::tag::_Policies> \
+ >::BOOST_NESTED_TEMPLATE bind<T0,T1,T2,T3>::type \
+//
+#endif
+#define BOOST_AUTOMATA_BUILDER_REQUIRED_TYPE(_args, _keyword) \
+ typename ::boost::detail::data_type< \
+ typename ::boost::parameter::binding< \
+ _args \
+ , keyword::tag::_keyword \
+ >::type \
+ >::type \
+//
+#define BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE(_args, _keyword, _default) \
+ typename ::boost::detail::data_type< \
+ typename ::boost::parameter::binding< \
+ _args \
+ , keyword::tag::_keyword \
+ , _default \
+ >::type \
+ >::type \
+//
+
+ template <
+ typename T0
+ , typename T1
+ , typename T2 = ::boost::parameter::void_
+ , typename T3 = ::boost::parameter::void_
+ >
+ class builder_from_graph
+ : public ::boost::mpl::if_<
+ ::std::tr1::is_same<
+ BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE(
+ BOOST_AUTOMATA_BUILDER_ARG_TYPE
+ , _EdgeInputMap
+ , ::boost::mpl::void_
+ )
+ , ::boost::mpl::void_
+ >
+ , _detail::builder_from_graph_wo_eim<
+ BOOST_AUTOMATA_BUILDER_REQUIRED_TYPE(
+ BOOST_AUTOMATA_BUILDER_ARG_TYPE
+ , _Graph
+ )
+ , BOOST_AUTOMATA_BUILDER_REQUIRED_TYPE(
+ BOOST_AUTOMATA_BUILDER_ARG_TYPE
+ , _VertexStateMap
+ )
+ , BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE(
+ BOOST_AUTOMATA_BUILDER_ARG_TYPE
+ , _Policies
+ , ::boost::fusion::nil
+ )
+ >
+ , _detail::builder_from_graph_w_eim<
+ BOOST_AUTOMATA_BUILDER_REQUIRED_TYPE(
+ BOOST_AUTOMATA_BUILDER_ARG_TYPE
+ , _Graph
+ )
+ , BOOST_AUTOMATA_BUILDER_REQUIRED_TYPE(
+ BOOST_AUTOMATA_BUILDER_ARG_TYPE
+ , _VertexStateMap
+ )
+ , BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE(
+ BOOST_AUTOMATA_BUILDER_ARG_TYPE
+ , _EdgeInputMap
+ , ::boost::mpl::void_
+ )
+ , BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE(
+ BOOST_AUTOMATA_BUILDER_ARG_TYPE
+ , _Policies
+ , ::boost::fusion::nil
+ )
+ >
+ >::type
+ {
+ typedef BOOST_AUTOMATA_BUILDER_ARG_TYPE
+ Args;
+ typedef BOOST_AUTOMATA_BUILDER_REQUIRED_TYPE(Args, _Graph)
+ Graph;
+ typedef BOOST_AUTOMATA_BUILDER_REQUIRED_TYPE(Args, _VertexStateMap)
+ VertexStateMap;
+ typedef BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE(
+ Args
+ , _EdgeInputMap
+ , ::boost::mpl::void_
+ )
+ EdgeInputMap;
+ typedef BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE(
+ Args
+ , _Policies
+ , ::boost::fusion::nil
+ )
+ Policies;
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_same<EdgeInputMap,::boost::mpl::void_>
+ , _detail::builder_from_graph_wo_eim<
+ Graph
+ , VertexStateMap
+ , Policies
+ >
+ , _detail::builder_from_graph_w_eim<
+ Graph
+ , VertexStateMap
+ , EdgeInputMap
+ , Policies
+ >
+ >::type
+ Base;
+
+ public:
+ typedef typename Base::observer_builder_map
+ observer_builder_map;
+
+#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
+ private:
+ typedef ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , Graph
+ >
+ GraphPredicate;
+ typedef ::std::tr1::is_same<
+ ::boost::detail::property_map_key< ::boost::mpl::_>
+ , typename graph_traits<Graph>::vertex_descriptor
+ >
+ VertexStateMapPredicate;
+ typedef ::std::tr1::is_same<
+ ::boost::detail::property_map_key< ::boost::mpl::_>
+ , typename graph_traits<Graph>::edge_descriptor
+ >
+ EdgeInputMapPredicate;
+ typedef ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , Policies
+ >
+ PoliciesPredicate;
+
+ public:
+ BOOST_PARAMETER_CONSTRUCTOR(
+ builder_from_graph, (Base), keyword::tag,
+ (deduced
+ (required
+ (graph
+ , *(GraphPredicate)
+ )
+ (vertex_state_map
+ , *(VertexStateMapPredicate)
+ )
+ )
+ (optional
+ (edge_input_map
+ , *(EdgeInputMapPredicate)
+// , ::boost::mpl::void_()
+ )
+ (policies
+ , *(PoliciesPredicate)
+// , Policies()
+ )
+ )
+ )
+ )
+#else
+ BOOST_PARAMETER_CONSTRUCTOR(
+ builder_from_graph, (Base), keyword::tag,
+ (deduced
+ (required
+ (graph
+ , *(
+ ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , Graph
+ >
+ )
+ )
+ (vertex_state_map
+ , *(
+ ::std::tr1::is_same<
+ ::boost::detail::property_map_key<
+ ::boost::mpl::_
+ >
+ , typename ::boost::graph_traits<
+ Graph
+ >::vertex_descriptor
+ >
+ )
+ )
+ )
+ (optional
+ (edge_input_map
+ , *(
+ ::std::tr1::is_same<
+ ::boost::detail::property_map_key<
+ ::boost::mpl::_
+ >
+ , typename ::boost::graph_traits<
+ Graph
+ >::edge_descriptor
+ >
+ )
+// , ::boost::mpl::void_()
+ )
+ (policies
+ , *(
+ ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , Policies
+ >
+ )
+// , Policies()
+ )
+ )
+ )
+ )
+#endif // BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
+ };
+
+#undef BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE
+#undef BOOST_AUTOMATA_BUILDER_REQUIRED_TYPE
+#undef BOOST_AUTOMATA_BUILDER_ARG_TYPE
+
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_BUILDER_FROM_GRAPH_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/builder/from_graph/multiple_final_states.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/builder/from_graph/multiple_final_states.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,131 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_BUILDER_FROM_GRAPH_MULTIPLE_FINAL_STATES_HPP_INCLUDED
+#define BOOST_AUTOMATA_BUILDER_FROM_GRAPH_MULTIPLE_FINAL_STATES_HPP_INCLUDED
+
+#include <algorithm>
+#include <iterator>
+#include <boost/mpl/void.hpp>
+#include <boost/range.hpp>
+#include <boost/property_map/property_map.hpp>
+#include <boost/graph/graph_traits.hpp>
+#include <boost/automata/keys/observer.hpp>
+
+//[reference__multiple_final_states_builder_from_graph
+namespace boost { namespace automata {
+
+ template <typename Targets, unsigned long Uid = 0UL>
+ class multiple_final_states_builder_from_graph
+ {
+ public:
+ typedef single_final_state_key<Uid> key_type;
+
+ private:
+ Targets _targets;
+
+ public:
+ explicit multiple_final_states_builder_from_graph(
+ Targets const& targets
+ );
+
+ template <
+ typename Graph
+ , typename VertexStateMap
+ , typename EdgeInputMap = ::boost::mpl::void_
+ >
+ struct apply
+ {
+ class type
+ {
+ multiple_final_states_builder_from_graph _builder;
+ VertexStateMap const& _vertex_state_map;
+
+ public:
+ type(
+ multiple_final_states_builder_from_graph const& builder
+ , Graph const& graph
+ , VertexStateMap const& vertex_state_map
+ , EdgeInputMap const& edge_input_map
+ );
+
+ type(
+ multiple_final_states_builder_from_graph const& builder
+ , Graph const& graph
+ , VertexStateMap const& vertex_state_map
+ );
+
+ template <typename States>
+ void make_final_states(States& states) const;
+ };
+ };
+ };
+
+ template <typename Targets, unsigned long Uid>
+ multiple_final_states_builder_from_graph<Targets,Uid>
+ ::multiple_final_states_builder_from_graph(Targets const& targets)
+ : _targets(targets)
+ {
+ }
+
+ template <typename Targets, unsigned long Uid>
+ template <typename Graph, typename VertexStateMap, typename EdgeInputMap>
+ multiple_final_states_builder_from_graph<Targets,Uid>::apply<
+ Graph
+ , VertexStateMap
+ , EdgeInputMap
+ >::type::type(
+ multiple_final_states_builder_from_graph const& builder
+ , Graph const& graph
+ , VertexStateMap const& vertex_state_map
+ , EdgeInputMap const& edge_input_map
+ ) : _builder(builder), _vertex_state_map(vertex_state_map)
+ {
+ }
+
+ template <typename Targets, unsigned long Uid>
+ template <typename Graph, typename VertexStateMap, typename EdgeInputMap>
+ multiple_final_states_builder_from_graph<Targets,Uid>::apply<
+ Graph
+ , VertexStateMap
+ , EdgeInputMap
+ >::type::type(
+ multiple_final_states_builder_from_graph const& builder
+ , Graph const& graph
+ , VertexStateMap const& vertex_state_map
+ ) : _builder(builder), _vertex_state_map(vertex_state_map)
+ {
+ }
+
+ template <typename Targets, unsigned long Uid>
+ template <typename Graph, typename VertexStateMap, typename EdgeInputMap>
+ template <typename States>
+ void
+ multiple_final_states_builder_from_graph<Targets,Uid>::apply<
+ Graph
+ , VertexStateMap
+ , EdgeInputMap
+ >::type::make_final_states(States& states) const
+ {
+ ::std::insert_iterator<States> inserter(states, begin(states));
+ typename range_const_iterator<Targets>::type
+ v_end = end(_builder._targets);
+
+ for (
+ typename range_const_iterator<Targets>::type
+ v_i = begin(_builder._targets);
+ v_i != v_end;
+ ++v_i
+ )
+ {
+ *inserter = get(_vertex_state_map, *v_i);
+ ++inserter;
+ }
+ }
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_BUILDER_FROM_GRAPH_MULTIPLE_FINAL_STATES_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/builder/from_graph/single_final_state.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/builder/from_graph/single_final_state.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,120 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_BUILDER_FROM_GRAPH_SINGLE_FINAL_STATE_HPP_INCLUDED
+#define BOOST_AUTOMATA_BUILDER_FROM_GRAPH_SINGLE_FINAL_STATE_HPP_INCLUDED
+
+#include <boost/mpl/void.hpp>
+#include <boost/property_map/property_map.hpp>
+#include <boost/graph/graph_traits.hpp>
+#include <boost/automata/keys/observer.hpp>
+
+//[reference__single_final_state_builder_from_graph
+namespace boost { namespace automata {
+
+ template <typename Vertex, unsigned long Uid = 0UL>
+ class single_final_state_builder_from_graph
+ {
+ public:
+ typedef single_final_state_key<Uid> key_type;
+
+ private:
+ Vertex _target;
+
+ public:
+ explicit single_final_state_builder_from_graph(Vertex const& target);
+
+ template <
+ typename Graph
+ , typename VertexStateMap
+ , typename EdgeInputMap = ::boost::mpl::void_
+ >
+ struct apply
+ {
+ class type
+ {
+ typedef single_final_state_builder_from_graph<
+ typename ::boost::graph_traits<
+ Graph
+ >::vertex_descriptor
+ >
+ Builder;
+
+ Builder _builder;
+ VertexStateMap const& _vertex_state_map;
+
+ public:
+ type(
+ Builder const& builder
+ , Graph const& graph
+ , VertexStateMap const& vertex_state_map
+ , EdgeInputMap const& edge_input_map
+ );
+
+ type(
+ Builder const& builder
+ , Graph const& graph
+ , VertexStateMap const& vertex_state_map
+ );
+
+ typename property_traits<VertexStateMap>::value_type
+ get_final_state() const;
+ };
+ };
+ };
+
+ template <typename Vertex, unsigned long Uid>
+ single_final_state_builder_from_graph<Vertex,Uid>
+ ::single_final_state_builder_from_graph(Vertex const& target)
+ : _target(target)
+ {
+ }
+
+ template <typename Vertex, unsigned long Uid>
+ template <typename Graph, typename VertexStateMap, typename EdgeInputMap>
+ single_final_state_builder_from_graph<Vertex,Uid>::apply<
+ Graph
+ , VertexStateMap
+ , EdgeInputMap
+ >::type::type(
+ Builder const& builder
+ , Graph const& graph
+ , VertexStateMap const& vertex_state_map
+ , EdgeInputMap const& edge_input_map
+ ) : _builder(builder), _vertex_state_map(vertex_state_map)
+ {
+ }
+
+ template <typename Vertex, unsigned long Uid>
+ template <typename Graph, typename VertexStateMap, typename EdgeInputMap>
+ single_final_state_builder_from_graph<Vertex,Uid>::apply<
+ Graph
+ , VertexStateMap
+ , EdgeInputMap
+ >::type::type(
+ Builder const& builder
+ , Graph const& graph
+ , VertexStateMap const& vertex_state_map
+ ) : _builder(builder), _vertex_state_map(vertex_state_map)
+ {
+ }
+
+ template <typename Vertex, unsigned long Uid>
+ template <typename Graph, typename VertexStateMap, typename EdgeInputMap>
+ inline typename property_traits<VertexStateMap>::value_type
+ single_final_state_builder_from_graph<Vertex,Uid>::apply<
+ Graph
+ , VertexStateMap
+ , EdgeInputMap
+ >::type::get_final_state()
+ const
+ {
+ return get(_vertex_state_map, _builder._target);
+ }
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_BUILDER_FROM_GRAPH_SINGLE_FINAL_STATE_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/builder/function.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/builder/function.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,594 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_BUILDER_FUNCTION_HPP_INCLUDED
+#define BOOST_AUTOMATA_BUILDER_FUNCTION_HPP_INCLUDED
+
+#include <boost/preprocessor/comparison/less.hpp>
+#include <boost/parameter.hpp>
+#include <boost/parameter/preprocessor.hpp>
+
+#if BOOST_PP_LESS(BOOST_PARAMETER_MAX_ARITY, 4)
+#error Set BOOST_PARAMETER_MAX_ARITY to 4 or more.
+#endif
+
+#include <boost/config.hpp>
+#include <boost/type_traits/function_traits.hpp>
+#include <boost/tr1/type_traits.hpp>
+#include <boost/tr1/functional.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/void.hpp>
+#include <boost/functional/value_factory.hpp>
+#include <boost/fusion/algorithm/transformation/transform.hpp>
+#include <boost/fusion/container/list/cons.hpp>
+#include <boost/fusion/container/map/convert.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/fusion/support/pair.hpp>
+#include <boost/fusion/support/is_sequence.hpp>
+#include <boost/detail/metafunction/data_type.hpp>
+#include <boost/detail/metafunction/is_predicate.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/concept_check.hpp>
+#include <boost/automata/keyword/template.hpp>
+#include <boost/automata/keyword/name.hpp>
+
+//[reference__builder_function
+namespace boost { namespace automata {
+ namespace _detail {
+
+ template <typename Recognizer, typename Argument>
+ struct can_recognize_argument_helper
+ : ::std::tr1::is_convertible<
+ typename ::boost::detail::data_type<
+ typename ::boost::function_traits<
+ Recognizer
+ >::arg1_type
+ >::type
+ , Argument
+ >
+ {
+ };
+
+ template <typename Recognizer, typename Argument>
+ struct can_recognize_argument
+ : ::boost::mpl::eval_if<
+ ::boost::detail::is_predicate<Recognizer>
+ , can_recognize_argument_helper<Recognizer,Argument>
+ , ::std::tr1::false_type
+ >::type
+ {
+ };
+
+ template <
+ typename Function
+ , typename StateRecognizer
+ , typename InputRecognizer
+ , typename Policies
+ >
+ class function_builder_impl
+ {
+ Function const& _function;
+ StateRecognizer const& _state_recognizer;
+ InputRecognizer const& _input_recognizer;
+
+ class observer_builder_maker
+ {
+ function_builder_impl const& _builder;
+
+ public:
+ observer_builder_maker(function_builder_impl const& builder)
+ : _builder(builder)
+ {
+ }
+
+ template <typename T>
+ struct result;
+
+ template <typename BuilderMaker, typename T>
+ struct result<BuilderMaker(T)>
+ {
+ private:
+ typedef typename ::boost::detail::data_type<T>::type
+ T_data;
+
+ public:
+ typedef ::boost::fusion::pair<
+ typename T_data::key_type
+ , typename ::boost::mpl::apply_wrap1<
+ T_data
+ , Function
+ >::type
+ >
+ type;
+ };
+
+ template <typename T>
+ inline ::boost::fusion::pair<
+ typename T::key_type
+ , typename ::boost::mpl::apply_wrap1<T,Function>::type
+ >
+ operator()(T const& t) const
+ {
+ return ::boost::fusion::pair<
+ typename T::key_type
+ , typename ::boost::mpl::apply_wrap1<T,Function>::type
+ >(
+ typename ::boost::mpl::apply_wrap1<T,Function>::type(
+ t
+ , _builder._function
+ )
+ );
+ }
+ };
+
+ public:
+ typedef typename ::boost::fusion::result_of::as_map<
+ typename ::boost::fusion::result_of::transform<
+ Policies
+ , observer_builder_maker
+ >::type
+ >::type
+ observer_builder_map;
+
+ private:
+ observer_builder_map _observer_builder_map;
+
+ public:
+ function_builder_impl(
+ Function const& function
+ , StateRecognizer const& state_recognizer
+ , InputRecognizer const& input_recognizer
+ );
+
+ template <typename ArgumentPack>
+ function_builder_impl(ArgumentPack const& args);
+
+ function_builder_impl(function_builder_impl const& copy);
+
+ private:
+ template <typename TFunction>
+ void
+ _build_input_recognizer(
+ TFunction& function
+ , ::std::tr1::true_type
+ ) const;
+
+ template <typename TFunction>
+ void
+ _build_input_recognizer(
+ TFunction& function
+ , ::std::tr1::false_type
+ ) const;
+
+ template <typename TFunction>
+ void
+ _build_state_recognizer(
+ TFunction& function
+ , ::std::tr1::true_type
+ ) const;
+
+ template <typename TFunction>
+ void
+ _build_state_recognizer(
+ TFunction& function
+ , ::std::tr1::false_type
+ ) const;
+
+ public:
+ template <typename TFunction>
+ void operator()(TFunction& function) const;
+
+ observer_builder_map const& get_observer_builder_map() const;
+ };
+
+ template <
+ typename Function
+ , typename StateRecognizer
+ , typename InputRecognizer
+ , typename Policies
+ >
+ function_builder_impl<
+ Function
+ , StateRecognizer
+ , InputRecognizer
+ , Policies
+ >::function_builder_impl(
+ Function const& function
+ , StateRecognizer const& state_recognizer
+ , InputRecognizer const& input_recognizer
+ ) : _function(function)
+ , _state_recognizer(state_recognizer)
+ , _input_recognizer(input_recognizer)
+ {
+ }
+
+ template <
+ typename Function
+ , typename StateRecognizer
+ , typename InputRecognizer
+ , typename Policies
+ >
+ template <typename ArgumentPack>
+ function_builder_impl<
+ Function
+ , StateRecognizer
+ , InputRecognizer
+ , Policies
+ >::function_builder_impl(ArgumentPack const& args)
+ : _function(args[::boost::automata::keyword::_function])
+ , _state_recognizer(
+ args[
+ ::boost::automata::keyword::_state_recognizer
+ || value_factory<StateRecognizer>()
+ ]
+ )
+ , _input_recognizer(
+ args[
+ ::boost::automata::keyword::_input_recognizer
+ || value_factory<InputRecognizer>()
+ ]
+ )
+ , _observer_builder_map(
+ ::boost::fusion::as_map(
+ ::boost::fusion::transform(
+ args[
+ ::boost::automata::keyword::_policies
+ || value_factory<Policies>()
+ ]
+ , observer_builder_maker(*this)
+ )
+ )
+ )
+ {
+ }
+
+ template <
+ typename Function
+ , typename StateRecognizer
+ , typename InputRecognizer
+ , typename Policies
+ >
+ function_builder_impl<
+ Function
+ , StateRecognizer
+ , InputRecognizer
+ , Policies
+ >::function_builder_impl(function_builder_impl const& copy)
+ : _function(copy._function)
+ , _state_recognizer(copy._state_recognizer)
+ , _input_recognizer(copy._input_recognizer)
+ {
+ }
+
+ template <
+ typename Function
+ , typename StateRecognizer
+ , typename InputRecognizer
+ , typename Policies
+ >
+ template <typename TFunction>
+ inline void
+ function_builder_impl<
+ Function
+ , StateRecognizer
+ , InputRecognizer
+ , Policies
+ >::_build_input_recognizer(
+ TFunction& function
+ , ::std::tr1::true_type
+ ) const
+ {
+ function.set_input_recognizer(_input_recognizer);
+ }
+
+ template <
+ typename Function
+ , typename StateRecognizer
+ , typename InputRecognizer
+ , typename Policies
+ >
+ template <typename TFunction>
+ inline void
+ function_builder_impl<
+ Function
+ , StateRecognizer
+ , InputRecognizer
+ , Policies
+ >::_build_input_recognizer(
+ TFunction& function
+ , ::std::tr1::false_type
+ ) const
+ {
+ }
+
+ template <
+ typename Function
+ , typename StateRecognizer
+ , typename InputRecognizer
+ , typename Policies
+ >
+ template <typename TFunction>
+ inline void
+ function_builder_impl<
+ Function
+ , StateRecognizer
+ , InputRecognizer
+ , Policies
+ >::_build_state_recognizer(
+ TFunction& function
+ , ::std::tr1::true_type
+ ) const
+ {
+ function.set_state_recognizer(_state_recognizer);
+ }
+
+ template <
+ typename Function
+ , typename StateRecognizer
+ , typename InputRecognizer
+ , typename Policies
+ >
+ template <typename TFunction>
+ inline void
+ function_builder_impl<
+ Function
+ , StateRecognizer
+ , InputRecognizer
+ , Policies
+ >::_build_state_recognizer(
+ TFunction& function
+ , ::std::tr1::false_type
+ ) const
+ {
+ }
+
+ template <
+ typename Function
+ , typename StateRecognizer
+ , typename InputRecognizer
+ , typename Policies
+ >
+ template <typename TFunction>
+ inline void
+ function_builder_impl<
+ Function
+ , StateRecognizer
+ , InputRecognizer
+ , Policies
+ >::operator()(TFunction& function) const
+ {
+ function = _function;
+ _build_state_recognizer(
+ function
+ , typename can_recognize_argument<
+ StateRecognizer
+ , typename TFunction::first_argument_type
+ >::type()
+ );
+ _build_input_recognizer(
+ function
+ , typename can_recognize_argument<
+ InputRecognizer
+ , typename TFunction::second_argument_type
+ >::type()
+ );
+ }
+
+ template <
+ typename Function
+ , typename StateRecognizer
+ , typename InputRecognizer
+ , typename Policies
+ >
+ inline typename function_builder_impl<
+ Function
+ , StateRecognizer
+ , InputRecognizer
+ , Policies
+ >::observer_builder_map const&
+ function_builder_impl<
+ Function
+ , StateRecognizer
+ , InputRecognizer
+ , Policies
+ >::get_observer_builder_map() const
+ {
+ return _observer_builder_map;
+ }
+ } // namespace _detail
+
+#define BOOST_AUTOMATA_BUILDER_ARG_TYPE \
+ typename ::boost::parameter::parameters< \
+ ::boost::parameter::required<keyword::tag::_Function> \
+ , ::boost::parameter::optional<keyword::tag::_StateRecognizer> \
+ , ::boost::parameter::optional<keyword::tag::_InputRecognizer> \
+ , ::boost::parameter::optional<keyword::tag::_Policies> \
+ >::BOOST_NESTED_TEMPLATE bind<T0,T1>::type \
+//
+
+#define BOOST_AUTOMATA_BUILDER_REQUIRED_TYPE(_args, _keyword) \
+ typename ::boost::detail::data_type< \
+ typename ::boost::parameter::binding< \
+ _args \
+ , keyword::tag::_keyword \
+ >::type \
+ >::type \
+//
+
+#define BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE(_args, _keyword, _default) \
+ typename ::boost::detail::data_type< \
+ typename ::boost::parameter::binding< \
+ _args \
+ , keyword::tag::_keyword \
+ , _default \
+ >::type \
+ >::type \
+//
+
+ template <
+ typename T0
+ , typename T1 = ::boost::parameter::void_
+ , typename T2 = ::boost::parameter::void_
+ , typename T3 = ::boost::parameter::void_
+ >
+ class function_builder
+ : public _detail::function_builder_impl<
+ BOOST_AUTOMATA_BUILDER_REQUIRED_TYPE(
+ BOOST_AUTOMATA_BUILDER_ARG_TYPE
+ , _Function
+ )
+ , BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE(
+ BOOST_AUTOMATA_BUILDER_ARG_TYPE
+ , _StateRecognizer
+ , ::boost::parameter::void_
+ )
+ , BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE(
+ BOOST_AUTOMATA_BUILDER_ARG_TYPE
+ , _InputRecognizer
+ , ::boost::parameter::void_
+ )
+ , BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE(
+ BOOST_AUTOMATA_BUILDER_ARG_TYPE
+ , _Policies
+ , ::boost::fusion::nil
+ )
+ >
+ {
+ typedef BOOST_AUTOMATA_BUILDER_ARG_TYPE
+ Args;
+ typedef BOOST_AUTOMATA_BUILDER_REQUIRED_TYPE(Args, _Function)
+ Function;
+ typedef BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE(
+ Args
+ , _StateRecognizer
+ , ::boost::parameter::void_
+ )
+ StateRecognizer;
+ typedef BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE(
+ Args
+ , _InputRecognizer
+ , ::boost::parameter::void_
+ )
+ InputRecognizer;
+ typedef BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE(
+ Args
+ , _Policies
+ , ::boost::fusion::nil
+ )
+ Policies;
+ typedef _detail::function_builder_impl<
+ Function
+ , StateRecognizer
+ , InputRecognizer
+ , Policies
+ >
+ Base;
+
+ public:
+ typedef typename Base::observer_builder_map
+ observer_builder_map;
+
+ function_builder(Function const& function)
+ : Base(static_cast<Function const&>(function))
+ {
+ }
+
+#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
+ private:
+ typedef ::std::tr1::is_convertible<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , Function
+ >
+ FunctionPredicate;
+ typedef ::std::tr1::is_convertible<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , StateRecognizer
+ >
+ StateRecognizerPredicate;
+ typedef ::std::tr1::is_convertible<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , InputRecognizer
+ >
+ InputRecognizerPredicate;
+ typedef ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , Policies
+ >
+ PoliciesPredicate;
+
+ public:
+ BOOST_PARAMETER_CONSTRUCTOR(
+ function_builder, (Base), keyword::tag,
+ (deduced
+ (required
+ (function, *(FunctionPredicate))
+ )
+ (optional
+ (state_recognizer, *(StateRecognizerPredicate))
+ (input_recognizer, *(InputRecognizerPredicate))
+ (policies, *(PoliciesPredicate))
+ )
+ )
+ )
+#else // !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
+ BOOST_PARAMETER_CONSTRUCTOR(
+ function_builder, (Base), keyword::tag,
+ (deduced
+ (required
+ (function
+ , *(
+ ::std::tr1::is_convertible<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , Function
+ >
+ )
+ )
+ )
+ (optional
+ (state_recognizer
+ , *(
+ ::std::tr1::is_convertible<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , StateRecognizer
+ >
+ )
+ )
+ (input_recognizer
+ , *(
+ ::std::tr1::is_convertible<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , InputRecognizer
+ >
+ )
+ )
+ (policies
+ , *(
+ ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , Policies
+ >
+ )
+ )
+ )
+ )
+ )
+#endif // ctor
+
+ function_builder(function_builder const& copy)
+ : Base(static_cast<Base const&>(copy))
+ {
+ }
+ };
+
+#undef BOOST_AUTOMATA_BUILDER_OPTIONAL_TYPE
+#undef BOOST_AUTOMATA_BUILDER_REQUIRED_TYPE
+#undef BOOST_AUTOMATA_BUILDER_ARG_TYPE
+
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_BUILDER_FUNCTION_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/concept_check.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/concept_check.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,21 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_CONCEPT_CHECK_HPP_INCLUDED
+#define BOOST_AUTOMATA_CONCEPT_CHECK_HPP_INCLUDED
+
+#include <boost/automata/concept_check/trans_func.hpp>
+#include <boost/automata/concept_check/cons_input_trans_func.hpp>
+#include <boost/automata/concept_check/sr_trans_func.hpp>
+#include <boost/automata/concept_check/dpda_trans_func.hpp>
+#include <boost/automata/concept_check/dfa_trans_func.hpp>
+#include <boost/automata/concept_check/tabular_trans_func.hpp>
+#include <boost/automata/concept_check/mapped_in_tab_trans_func.hpp>
+#include <boost/automata/concept_check/mapped_in_trans_func.hpp>
+#include <boost/automata/concept_check/next_state_trans_func.hpp>
+#include <boost/automata/concept_check/trans_func_matrix.hpp>
+
+#endif // BOOST_AUTOMATA_CONCEPT_CHECK_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/concept_check/cons_input_trans_func.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/concept_check/cons_input_trans_func.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,59 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_CONCEPT_CHECK_CONS_INPUT_TRANS_FUNC_HPP_INCLUDED
+#define BOOST_AUTOMATA_CONCEPT_CHECK_CONS_INPUT_TRANS_FUNC_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/concept_check/trans_func.hpp>
+#include <boost/concept/detail/concept_def.hpp>
+
+//[concept__constrained_input_transition_function
+namespace boost { namespace automata {
+
+ BOOST_concept(ConstrainedInputTransitionFunction, (Function)(Input))
+ //]
+ //[concept__constrained_input_transition_function__refinement_of
+ : TransitionFunction<Function>
+ {
+ //]
+ //[concept__constrained_input_transition_function__types_and_variables
+ public:
+ typedef typename Function::tag tag;
+ typedef typename Function::state state;
+
+ private:
+ BOOST_STATIC_ASSERT((
+ is_base_of<constrained_input_transition_function_tag,tag>::value
+ ));
+
+ bool b;
+ Input const& i;
+ Function& function;
+ //]
+
+ //[concept__constrained_input_transition_function__expressions
+ public:
+ BOOST_CONCEPT_USAGE(ConstrainedInputTransitionFunction)
+ {
+ const_constraints(function);
+ }
+
+ private:
+ void const_constraints(Function const& const_function)
+ {
+ b = const_function.recognizes_input(i);
+ }
+ };
+}} // namespace boost::automata
+//]
+
+#include <boost/concept/detail/concept_undef.hpp>
+
+#endif // BOOST_AUTOMATA_CONCEPT_CHECK_CONS_INPUT_TRANS_FUNC_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/concept_check/cons_state_trans_func.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/concept_check/cons_state_trans_func.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,59 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_CONCEPT_CHECK_CONS_STATE_TRANS_FUNC_HPP_INCLUDED
+#define BOOST_AUTOMATA_CONCEPT_CHECK_CONS_STATE_TRANS_FUNC_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/concept_check/trans_func.hpp>
+#include <boost/concept/detail/concept_def.hpp>
+
+//[concept__constrained_state_transition_function
+namespace boost { namespace automata {
+
+ BOOST_concept(ConstrainedStateTransitionFunction, (Function))
+ //]
+ //[concept__constrained_state_transition_function__refinement_of
+ : TransitionFunction<Function>
+ {
+ //]
+ //[concept__constrained_state_transition_function__types_and_variables
+ public:
+ typedef typename Function::tag tag;
+ typedef typename Function::state state;
+
+ private:
+ BOOST_STATIC_ASSERT((
+ is_base_of<constrained_state_transition_function_tag,tag>::value
+ ));
+
+ bool b;
+ state const& s;
+ Function& function;
+ //]
+
+ //[concept__constrained_state_transition_function__expressions
+ public:
+ BOOST_CONCEPT_USAGE(ConstrainedStateTransitionFunction)
+ {
+ const_constraints(function);
+ }
+
+ private:
+ void const_constraints(Function const& const_function)
+ {
+ b = const_function.recognizes_state(s);
+ }
+ };
+}} // namespace boost::automata
+//]
+
+#include <boost/concept/detail/concept_undef.hpp>
+
+#endif // BOOST_AUTOMATA_CONCEPT_CHECK_CONS_STATE_TRANS_FUNC_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/concept_check/dfa_trans_func.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/concept_check/dfa_trans_func.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,78 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_CONCEPT_CHECK_DFA_TRANS_FUNC_HPP_INCLUDED
+#define BOOST_AUTOMATA_CONCEPT_CHECK_DFA_TRANS_FUNC_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/concept_archetype.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/concept_check/cons_input_trans_func.hpp>
+#include <boost/automata/concept_check/sr_trans_func.hpp>
+#include <boost/concept/detail/concept_def.hpp>
+
+//[concept__dfa_transition_function
+namespace boost { namespace automata {
+
+ BOOST_concept(DFATransitionFunction, (Function))
+ //]
+ //[concept__dfa_transition_function__refinement_of
+ : ConstrainedInputTransitionFunction<
+ Function
+ , typename Function::second_argument_type
+ >
+ , StateRegisterTransitionFunction<Function>
+ {
+ //]
+ //[concept__dfa_transition_function__types_and_variables
+ public:
+ typedef typename Function::tag tag;
+ typedef typename Function::state state;
+ typedef typename Function::result_type result_type;
+ typedef typename Function::first_argument_type first_argument_type;
+ typedef typename Function::second_argument_type second_argument_type;
+
+ private:
+ BOOST_STATIC_ASSERT((
+ is_base_of<dfa_transition_function_tag,tag>::value
+ ));
+ BOOST_STATIC_ASSERT((
+ is_same<result_type,first_argument_type>::value
+ ));
+ BOOST_STATIC_ASSERT((
+ is_same<result_type,state>::value
+ ));
+
+ state const& current_state;
+ second_argument_type const& i;
+ output_iterator_archetype<second_argument_type> out_itr;
+ Function& function;
+ //]
+
+ //[concept__dfa_transition_function__expressions
+ public:
+ BOOST_CONCEPT_USAGE(DFATransitionFunction)
+ {
+ const_constraints(function);
+ }
+
+ private:
+ void const_constraints(Function const& const_function)
+ {
+ result_type next_state = const_function(current_state, i);
+ next_state = const_function.get_state_count();
+ const_function.make_nontrivial_inputs(current_state, out_itr);
+ }
+ };
+}} // namespace boost::automata
+//]
+
+#include <boost/concept/detail/concept_undef.hpp>
+
+#endif // BOOST_AUTOMATA_CONCEPT_CHECK_DFA_TRANS_FUNC_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/concept_check/dpda_trans_func.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/concept_check/dpda_trans_func.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,115 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_CONCEPT_CHECK_DPDA_TRANS_FUNC_HPP_INCLUDED
+#define BOOST_AUTOMATA_CONCEPT_CHECK_DPDA_TRANS_FUNC_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/concept_archetype.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/keys/common.hpp>
+#include <boost/automata/keys/dpda.hpp>
+#include <boost/automata/concept_check/cons_input_trans_func.hpp>
+#include <boost/automata/concept_check/sr_trans_func.hpp>
+#include <boost/concept/detail/concept_def.hpp>
+
+//[concept__dpda_transition_function
+namespace boost { namespace automata {
+
+ BOOST_concept(DPDATransitionFunction, (Function))
+ //]
+ //[concept__dpda_transition_function__refinement_of
+ : ConstrainedInputTransitionFunction<Function,typename Function::input>
+ , StateRegisterTransitionFunction<Function>
+ {
+ //]
+ //[concept__dpda_transition_function__types_and_variables
+ public:
+ typedef typename Function::tag
+ tag;
+ typedef typename Function::input
+ input;
+ typedef typename Function::state
+ state;
+ typedef typename Function::stack_element
+ stack_element;
+ typedef typename Function::optional_stack_element
+ optional_stack_element;
+ typedef typename Function::result_map
+ result_map;
+ typedef typename Function::result_type
+ result_type;
+
+ private:
+ BOOST_STATIC_ASSERT((
+ is_base_of<tag,dpda_transition_function_tag>::value
+ ));
+
+ bool b;
+ input const& i;
+ std::size_t const& state_count;
+ state const& current_state;
+ state next_state;
+ stack_element e;
+ stack_element const& const_e;
+ output_iterator_archetype<input> out_itr;
+ result_map const& r_map;
+ Function& function;
+ //]
+
+ //[concept__dpda_transition_function__expressions
+ public:
+ BOOST_CONCEPT_USAGE(DPDATransitionFunction)
+ {
+ function.set_transition(current_state, i, r_map);
+ function(current_state, i) = r_map;
+ function.set_transition(current_state, i, const_e, r_map);
+ function(current_state, i, const_e) = r_map;
+ function.reset(state_count);
+ const_constraints(function);
+ }
+
+ private:
+ void const_constraints(Function const& const_function)
+ {
+ b = const_function.recognizes_stack_element(const_e);
+ result_type r1 = const_function(current_state, i);
+ result_type r2 = const_function(current_state, i, const_e);
+
+ if (r1)
+ {
+ result_map const& m = *r2;
+ next_state = boost::fusion::at_key<next_state_key>(m);
+ optional_stack_element const&
+ o_e = boost::fusion::at_key<push_to_stack_key>(m);
+
+ if (o_e)
+ {
+ e = *o_e;
+ }
+ }
+
+ const_function.make_nontrivial_inputs(
+ current_state
+ , out_itr
+ );
+ const_function.make_nontrivial_inputs(
+ current_state
+ , const_e
+ , out_itr
+ );
+ }
+ };
+}} // namespace boost::automata
+//]
+
+#include <boost/concept/detail/concept_undef.hpp>
+
+#endif // BOOST_AUTOMATA_CONCEPT_CHECK_DPDA_TRANS_FUNC_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/concept_check/mapped_in_tab_trans_func.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/concept_check/mapped_in_tab_trans_func.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,62 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_CONCEPT_CHECK_MAPPED_IN_TAB_TRANS_FUNC_HPP_INCLUDED
+#define BOOST_AUTOMATA_CONCEPT_CHECK_MAPPED_IN_TAB_TRANS_FUNC_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/concept_archetype.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/concept_check/dfa_trans_func.hpp>
+#include <boost/concept/detail/concept_def.hpp>
+
+//[concept__mapped_input_tabular_transition_function
+namespace boost { namespace automata {
+
+ BOOST_concept(MappedInputTabularTransitionFunction, (Function))
+ //]
+ //[concept__mapped_input_tabular_transition_function__refinement_of
+ : DFATransitionFunction<Function>
+ {
+ //]
+ //[concept__mapped_input_tabular_transition_function__types_and_variables
+ public:
+ typedef typename Function::tag tag;
+ typedef typename Function::state state;
+ typedef typename Function::result_type result_type;
+ typedef typename Function::first_argument_type first_argument_type;
+ typedef typename Function::second_argument_type second_argument_type;
+
+ private:
+ BOOST_STATIC_ASSERT((
+ is_base_of<mapped_input_tabular_transition_function_tag,tag>::value
+ ));
+
+ std::size_t const& state_count;
+ input_iterator_archetype<second_argument_type> in_itr;
+ state const& current_state;
+ second_argument_type const& i;
+ state const& next_state;
+ Function& function;
+ //]
+
+ //[concept__mapped_input_tabular_transition_function__expressions
+ public:
+ BOOST_CONCEPT_USAGE(MappedInputTabularTransitionFunction)
+ {
+ function.set_transition(current_state, i, next_state);
+ function(current_state, i) = next_state;
+ function.reset(state_count, in_itr, in_itr);
+ }
+ };
+}} // namespace boost::automata
+//]
+
+#include <boost/concept/detail/concept_undef.hpp>
+
+#endif // BOOST_AUTOMATA_CONCEPT_CHECK_MAPPED_IN_TAB_TRANS_FUNC_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/concept_check/mapped_in_trans_func.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/concept_check/mapped_in_trans_func.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,60 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_CONCEPT_CHECK_MAPPED_IN_TRANS_FUNC_HPP_INCLUDED
+#define BOOST_AUTOMATA_CONCEPT_CHECK_MAPPED_IN_TRANS_FUNC_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/concept_check/dfa_trans_func.hpp>
+#include <boost/concept/detail/concept_def.hpp>
+
+//[concept__mapped_input_transition_function
+namespace boost { namespace automata {
+
+ BOOST_concept(MappedInputTransitionFunction, (Function))
+ //]
+ //[concept__mapped_input_transition_function__refinement_of
+ : DFATransitionFunction<Function>
+ {
+ //]
+ //[concept__mapped_input_transition_function__types_and_variables
+ public:
+ typedef typename Function::tag tag;
+ typedef typename Function::state state;
+ typedef typename Function::result_type result_type;
+ typedef typename Function::first_argument_type first_argument_type;
+ typedef typename Function::second_argument_type second_argument_type;
+
+ private:
+ BOOST_STATIC_ASSERT((
+ is_base_of<mapped_input_transition_function_tag,tag>::value
+ ));
+
+ std::size_t const& state_count;
+ state const& current_state;
+ second_argument_type const& i;
+ state const& next_state;
+ Function& function;
+ //]
+
+ //[concept__mapped_input_transition_function__expressions
+ public:
+ BOOST_CONCEPT_USAGE(MappedInputTransitionFunction)
+ {
+ function.set_transition(current_state, i, next_state);
+ function(current_state, i) = next_state;
+ function.reset(state_count);
+ }
+ };
+}} // namespace boost::automata
+//]
+
+#include <boost/concept/detail/concept_undef.hpp>
+
+#endif // BOOST_AUTOMATA_CONCEPT_CHECK_MAPPED_IN_TRANS_FUNC_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/concept_check/mdp_trans_func.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/concept_check/mdp_trans_func.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,70 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_CONCEPT_CHECK_MDP_TRANS_FUNC_HPP_INCLUDED
+#define BOOST_AUTOMATA_CONCEPT_CHECK_MDP_TRANS_FUNC_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/concept_archetype.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/concept_check/cons_input_trans_func.hpp>
+#include <boost/automata/concept_check/sr_trans_func.hpp>
+#include <boost/automata/concept_check/prob_trans_func.hpp>
+#include <boost/concept/detail/concept_def.hpp>
+
+//[concept__mdp_transition_function
+namespace boost { namespace automata {
+
+ BOOST_concept(MDPTransitionFunction, (Function))
+ //]
+ //[concept__mdp_transition_function__refinement_of
+ : ConstrainedInputTransitionFunction<Function,typename Function::input>
+ , StateRegisterTransitionFunction<Function>
+ , ProbabilisticTransitionFunction<Function,typename Function::input>
+ {
+ //]
+ //[concept__mdp_transition_function__types_and_variables
+ public:
+ typedef typename Function::tag tag;
+ typedef typename Function::input input;
+ typedef typename Function::state state;
+ typedef typename Function::result_type result_type;
+
+ private:
+ BOOST_STATIC_ASSERT((
+ is_base_of<mdp_transition_function_tag,tag>::value
+ ));
+ BOOST_STATIC_ASSERT((
+ is_same<result_type,bool>::value
+ ));
+
+ state const& current_state;
+ output_iterator_archetype<input> out_itr;
+ Function& function;
+ //]
+
+ //[concept__mdp_transition_function__expressions
+ public:
+ BOOST_CONCEPT_USAGE(MDPTransitionFunction)
+ {
+ const_constraints(function);
+ }
+
+ private:
+ void const_constraints(Function const& const_function)
+ {
+ const_function.make_nontrivial_inputs(current_state, out_itr);
+ }
+ };
+}} // namespace boost::automata
+//]
+
+#include <boost/concept/detail/concept_undef.hpp>
+
+#endif // BOOST_AUTOMATA_CONCEPT_CHECK_MDP_TRANS_FUNC_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/concept_check/next_state_trans_func.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/concept_check/next_state_trans_func.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,66 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_CONCEPT_CHECK_NEXT_STATE_TRANS_FUNC_HPP_INCLUDED
+#define BOOST_AUTOMATA_CONCEPT_CHECK_NEXT_STATE_TRANS_FUNC_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/concept_check/dfa_trans_func.hpp>
+#include <boost/concept/detail/concept_def.hpp>
+
+//[concept__next_state_transition_function
+namespace boost { namespace automata {
+
+ BOOST_concept(NextStateTransitionFunction, (Function))
+ //]
+ //[concept__next_state_transition_function__refinement_of
+ : DFATransitionFunction<Function>
+ {
+ //]
+ //[concept__next_state_transition_function__types_and_variables
+ public:
+ typedef typename Function::tag tag;
+ typedef typename Function::state state;
+ typedef typename Function::result_type result_type;
+ typedef typename Function::first_argument_type first_argument_type;
+ typedef typename Function::second_argument_type second_argument_type;
+
+ private:
+ BOOST_STATIC_ASSERT((
+ is_base_of<next_state_transition_function_tag,tag>::value
+ ));
+ BOOST_STATIC_ASSERT((
+ is_same<state,second_argument_type>::value
+ ));
+ BOOST_STATIC_ASSERT((
+ is_same<second_argument_type,first_argument_type>::value
+ ));
+
+ std::size_t const& state_count;
+ state const& current_state;
+ state const& next_state;
+ Function& function;
+ //]
+
+ //[concept__next_state_transition_function__expressions
+ public:
+ BOOST_CONCEPT_USAGE(NextStateTransitionFunction)
+ {
+ function.add_transition(current_state, next_state);
+ function(current_state) += next_state;
+ function.reset(state_count);
+ }
+ };
+}} // namespace boost::automata
+//]
+
+#include <boost/concept/detail/concept_undef.hpp>
+
+#endif // BOOST_AUTOMATA_CONCEPT_CHECK_NEXT_STATE_TRANS_FUNC_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/concept_check/prob_trans_func.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/concept_check/prob_trans_func.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_CONCEPT_CHECK_PROB_TRANS_FUNC_HPP_INCLUDED
+#define BOOST_AUTOMATA_CONCEPT_CHECK_PROB_TRANS_FUNC_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/concept_archetype.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/concept_check/trans_func.hpp>
+#include <boost/concept/detail/concept_def.hpp>
+
+//[concept__probabilistic_transition_function
+namespace boost { namespace automata {
+
+ BOOST_concept(ProbabilisticTransitionFunction, (Function)(Input))
+ //]
+ //[concept__probabilistic_transition_function__refinement_of
+ : TransitionFunction<Function>
+ {
+ //]
+ //[concept__probabilistic_transition_function__types_and_variables
+ public:
+ typedef typename Function::tag tag;
+ typedef typename Function::state state;
+
+ private:
+ bool b;
+ generator_archetype<unsigned int> engine;
+ state const& s;
+ Input const& i;
+ Function& function;
+ //]
+
+ //[concept__probabilistic_transition_function__expressions
+ public:
+ BOOST_CONCEPT_USAGE(ProbabilisticTransitionFunction)
+ {
+ const_constraints(function);
+ }
+
+ private:
+ void const_constraints(Function const& const_function)
+ {
+ b = const_function(s, i, engine);
+ }
+ };
+}} // namespace boost::automata
+//]
+
+#include <boost/concept/detail/concept_undef.hpp>
+
+#endif // BOOST_AUTOMATA_CONCEPT_CHECK_PROB_TRANS_FUNC_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/concept_check/sr_trans_func.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/concept_check/sr_trans_func.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,62 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_CONCEPT_CHECK_SR_TRANS_FUNC_HPP_INCLUDED
+#define BOOST_AUTOMATA_CONCEPT_CHECK_SR_TRANS_FUNC_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/concept_check/cons_state_trans_func.hpp>
+#include <boost/concept/detail/concept_def.hpp>
+
+//[concept__state_register_transition_function
+namespace boost { namespace automata {
+
+ BOOST_concept(StateRegisterTransitionFunction, (Function))
+ //]
+ //[concept__state_register_transition_function__refinement_of
+ : ConstrainedStateTransitionFunction<Function>
+ {
+ //]
+ //[concept__state_register_transition_function__types_and_variables
+ public:
+ typedef typename Function::tag tag;
+ typedef typename Function::state state;
+
+ private:
+ BOOST_STATIC_ASSERT((
+ is_base_of<state_register_transition_function_tag,tag>::value
+ ));
+ BOOST_STATIC_ASSERT((
+ is_same<state,std::size_t>::value
+ ));
+
+ Function& function;
+ //]
+
+ //[concept__state_register_transition_function__expressions
+ public:
+ BOOST_CONCEPT_USAGE(StateRegisterTransitionFunction)
+ {
+ const_constraints(function);
+ }
+
+ private:
+ void const_constraints(Function const& const_function)
+ {
+ state const& s = const_function.get_state_count();
+ if (const_function.recognizes_state(s));
+ }
+ };
+}} // namespace boost::automata
+//]
+
+#include <boost/concept/detail/concept_undef.hpp>
+
+#endif // BOOST_AUTOMATA_CONCEPT_CHECK_SR_TRANS_FUNC_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/concept_check/tabular_trans_func.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/concept_check/tabular_trans_func.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,65 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_CONCEPT_CHECK_TABULAR_TRANS_FUNC_HPP_INCLUDED
+#define BOOST_AUTOMATA_CONCEPT_CHECK_TABULAR_TRANS_FUNC_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/concept_check/dfa_trans_func.hpp>
+#include <boost/concept/detail/concept_def.hpp>
+
+//[concept__tabular_transition_function
+namespace boost { namespace automata {
+
+ BOOST_concept(TabularTransitionFunction, (Function))
+ //]
+ //[concept__tabular_transition_function__refinement_of
+ : DFATransitionFunction<Function>
+ {
+ //]
+ //[concept__tabular_transition_function__types_and_variables
+ public:
+ typedef typename Function::tag tag;
+ typedef typename Function::state state;
+ typedef typename Function::result_type result_type;
+ typedef typename Function::first_argument_type first_argument_type;
+ typedef typename Function::second_argument_type second_argument_type;
+
+ private:
+ BOOST_STATIC_ASSERT((
+ is_base_of<tabular_transition_function_tag,tag>::value
+ ));
+ BOOST_STATIC_ASSERT((
+ is_same<second_argument_type,std::size_t>::value
+ ));
+
+ std::size_t const& state_count;
+ std::size_t const& input_count;
+ state const& current_state;
+ second_argument_type const& i;
+ state const& next_state;
+ Function& function;
+ //]
+
+ //[concept__tabular_transition_function__expressions
+ public:
+ BOOST_CONCEPT_USAGE(TabularTransitionFunction)
+ {
+ function.set_transition(current_state, i, next_state);
+ function(current_state, i) = next_state;
+ function.reset(state_count, input_count);
+ }
+ };
+}} // namespace boost::automata
+//]
+
+#include <boost/concept/detail/concept_undef.hpp>
+
+#endif // BOOST_AUTOMATA_CONCEPT_CHECK_TABULAR_TRANS_FUNC_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/concept_check/trans_func.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/concept_check/trans_func.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,53 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_CONCEPT_CHECK_TRANS_FUNC_HPP_INCLUDED
+#define BOOST_AUTOMATA_CONCEPT_CHECK_TRANS_FUNC_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/concept/detail/concept_def.hpp>
+
+//[concept__transition_function
+namespace boost { namespace automata {
+
+ BOOST_concept(TransitionFunction, (Function))
+ //]
+ //[concept__transition_function__refinement_of
+ : DefaultConstructible<Function>
+ {
+ //]
+ //[concept__transition_function__types_and_variables
+ public:
+ typedef typename Function::tag tag;
+ typedef typename Function::state state;
+
+ private:
+ BOOST_STATIC_ASSERT((is_base_of<transition_function_tag,tag>::value));
+
+ Function& function;
+ //]
+
+ //[concept__transition_function__expressions
+ public:
+ BOOST_CONCEPT_USAGE(TransitionFunction)
+ {
+ const_constraints(function);
+ }
+
+ private:
+ void const_constraints(Function const& const_function)
+ {
+ }
+ };
+}} // namespace boost::automata
+//]
+
+#include <boost/concept/detail/concept_undef.hpp>
+
+#endif // BOOST_AUTOMATA_CONCEPT_CHECK_TRANS_FUNC_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/concept_check/trans_func_matrix.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/concept_check/trans_func_matrix.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,62 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_CONCEPT_CHECK_TRANS_FUNC_MATRIX_HPP_INCLUDED
+#define BOOST_AUTOMATA_CONCEPT_CHECK_TRANS_FUNC_MATRIX_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/concept/detail/concept_def.hpp>
+
+//[concept__transition_function_matrix
+namespace boost { namespace automata {
+
+ BOOST_concept(TransitionFunctionMatrix, (Matrix))
+ //]
+ //[concept__transition_function_matrix__refinement_of
+ : DefaultConstructible<Matrix>
+ {
+ //]
+ //[concept__transition_function_matrix__types_and_variables
+ public:
+ typedef typename Matrix::value_type
+ value_type;
+ typedef typename Matrix::size_type
+ size_type;
+
+ private:
+ BOOST_STATIC_ASSERT((is_same<value_type,size_type>::value));
+
+ Matrix matrix;
+ value_type element;
+ size_type row;
+ size_type column;
+ size_type row_count;
+ size_type column_count;
+ //]
+
+ //[concept__transition_function_matrix__expressions
+ public:
+ BOOST_CONCEPT_USAGE(TransitionFunctionMatrix)
+ {
+ matrix.resize(row_count, column_count);
+ matrix(row, column) = element;
+ const_constraints(matrix);
+ }
+
+ private:
+ void const_constraints(Matrix const& const_matrix)
+ {
+ element = const_matrix(row, column);
+ }
+ };
+}} // namespace boost::automata
+//]
+
+#include <boost/concept/detail/concept_undef.hpp>
+
+#endif // BOOST_AUTOMATA_CONCEPT_CHECK_TRANS_FUNC_MATRIX_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/function_automaton.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/function_automaton.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,396 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_FUNCTION_AUTOMATON_HPP_INCLUDED
+#define BOOST_AUTOMATA_FUNCTION_AUTOMATON_HPP_INCLUDED
+
+#include <boost/preprocessor/comparison/less.hpp>
+#include <boost/parameter.hpp>
+#include <boost/parameter/preprocessor.hpp>
+
+#if BOOST_PP_LESS(BOOST_PARAMETER_MAX_ARITY, 5)
+#error Set BOOST_PARAMETER_MAX_ARITY to 5 or more.
+#endif
+
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/fusion/container/list/cons.hpp>
+#include <boost/detail/metafunction/data_type.hpp>
+#include <boost/automata/keyword/template.hpp>
+#include <boost/automata/keyword/name.hpp>
+#include <boost/automata/generator/deterministic.hpp>
+#include <boost/automata/transition_function/adaptor.hpp>
+#include <boost/automata/policy/default_input_validation.hpp>
+#include <boost/automata/_detail/impl.hpp>
+
+//#define __BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__
+
+//[reference__function_automaton
+namespace boost { namespace automata {
+
+//<-
+#ifdef __BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+#define BOOST_AUTOMATA_AUTOMATON_ARGS \
+ typename ::boost::parameter::parameters< \
+ ::boost::parameter::optional<keyword::tag::_Policies> \
+ , ::boost::parameter::optional<keyword::tag::_InputValidationPolicy> \
+ , ::boost::parameter::optional<keyword::tag::_IsUndoable> \
+ >::BOOST_NESTED_TEMPLATE bind<T1,T2,T3,parameter::void_>::type \
+//
+#else // !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
+#define BOOST_AUTOMATA_AUTOMATON_ARGS \
+ typename ::boost::parameter::parameters< \
+ ::boost::parameter::optional<keyword::tag::_Policies> \
+ , ::boost::parameter::optional<keyword::tag::_InputValidationPolicy> \
+ , ::boost::parameter::optional<keyword::tag::_IsUndoable> \
+ >::BOOST_NESTED_TEMPLATE bind<T1,T2,T3>::type \
+//
+#endif // BOOST_AUTOMATA_AUTOMATON_ARGS
+#else // !defined(__BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__)
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+#define BOOST_AUTOMATA_AUTOMATON_ARGS \
+ typename ::boost::parameter::parameters< \
+ ::boost::parameter::required<keyword::tag::_Function> \
+ , ::boost::parameter::optional<keyword::tag::_Policies> \
+ , ::boost::parameter::optional<keyword::tag::_InputValidationPolicy> \
+ , ::boost::parameter::optional<keyword::tag::_IsUndoable> \
+ >::BOOST_NESTED_TEMPLATE bind<T0,T1,T2,T3,parameter::void_>::type \
+//
+#else // !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
+#define BOOST_AUTOMATA_AUTOMATON_ARGS \
+ typename ::boost::parameter::parameters< \
+ ::boost::parameter::required<keyword::tag::_Function> \
+ , ::boost::parameter::optional<keyword::tag::_Policies> \
+ , ::boost::parameter::optional<keyword::tag::_InputValidationPolicy> \
+ , ::boost::parameter::optional<keyword::tag::_IsUndoable> \
+ >::BOOST_NESTED_TEMPLATE bind<T0,T1,T2,T3>::type \
+//
+#endif // BOOST_AUTOMATA_AUTOMATON_ARGS
+#endif // __BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__
+
+#define BOOST_AUTOMATA_AUTOMATON_REQUIRED_TPL_PARAM(_args, _keyword) \
+ typename ::boost::parameter::value_type< \
+ _args \
+ , keyword::tag::_keyword \
+ >::type \
+//
+
+#define BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM(_args, _keyword, _default) \
+ typename ::boost::parameter::value_type< \
+ _args \
+ , keyword::tag::_keyword \
+ , _default \
+ >::type \
+//
+//->
+
+ template <
+//<-
+#ifdef __BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__
+//->
+ typename Function
+//<-
+#else // !defined(__BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__)
+ typename T0
+#endif // __BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__
+//->
+ , typename T1 = ::boost::parameter::void_
+ , typename T2 = ::boost::parameter::void_
+ , typename T3 = ::boost::parameter::void_
+ >
+ class function_automaton
+ : public // Base
+ //<-
+ _detail::impl<
+ deterministic_generator
+#ifdef __BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__
+ , adaptor_transition_function<Function>
+#else // !defined(__BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__)
+ , adaptor_transition_function<
+ BOOST_AUTOMATA_AUTOMATON_REQUIRED_TPL_PARAM(
+ BOOST_AUTOMATA_AUTOMATON_ARGS
+ , _Function
+ )
+ >
+#endif // __BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__
+ , BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM(
+ BOOST_AUTOMATA_AUTOMATON_ARGS
+ , _Policies
+ , ::boost::fusion::nil
+ )
+ , BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM(
+ BOOST_AUTOMATA_AUTOMATON_ARGS
+ , _InputValidationPolicy
+ , default_input_validation_policy
+ )
+ , BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM(
+ BOOST_AUTOMATA_AUTOMATON_ARGS
+ , _IsUndoable
+ , ::boost::mpl::false_
+ )
+ >::type
+ //->
+ {
+ //<-
+ typedef BOOST_AUTOMATA_AUTOMATON_ARGS
+ Args;
+#ifndef __BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__
+ typedef BOOST_AUTOMATA_AUTOMATON_REQUIRED_TPL_PARAM(
+ Args
+ , _Function
+ )
+ Function;
+#endif // !defined(__BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__)
+ typedef BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM(
+ Args
+ , _Policies
+ , ::boost::fusion::nil
+ )
+ Policies;
+ typedef BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM(
+ Args
+ , _InputValidationPolicy
+ , default_input_validation_policy
+ )
+ InputValidationPolicy;
+ typedef BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM(
+ Args
+ , _IsUndoable
+ , ::boost::mpl::false_
+ )
+ IsUndoable;
+ typedef typename _detail::impl<
+ deterministic_generator
+ , adaptor_transition_function<Function>
+ , Policies
+ , InputValidationPolicy
+ , IsUndoable
+ >::type
+ Base;
+ //->
+
+ public:
+ typedef typename Base::transition_function
+ transition_function;
+ typedef typename Base::state
+ state;
+ typedef typename Base::observer_map
+ observer_map;
+ typedef typename Base::traits
+ traits;
+
+ function_automaton() : Base()
+ {
+ }
+
+ //<-
+#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
+ private:
+ typedef ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , Policies
+ >
+ PoliciesPredicate;
+ typedef ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , InputValidationPolicy
+ >
+ InputValidationPredicate;
+ typedef ::std::tr1::is_convertible< ::boost::mpl::_,state>
+ StatePredicate;
+ typedef ::std::tr1::is_integral<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ >
+ UndoLimitPredicate;
+
+#ifdef __BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__
+ public:
+ BOOST_PARAMETER_CONSTRUCTOR(
+ function_automaton, (Base), keyword::tag,
+ (required
+ (function, *)
+ )
+ (deduced
+ (optional
+ (policies, *(PoliciesPredicate))
+ (input_validation_policy, *(InputValidationPredicate))
+ (source_state, *(StatePredicate))
+ (undo_limit, *(UndoLimitPredicate))
+ )
+ )
+ )
+#else // !defined(__BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__)
+ typedef ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , Function
+ >
+ FunctionPredicate;
+
+ public:
+ BOOST_PARAMETER_CONSTRUCTOR(
+ function_automaton, (Base), keyword::tag,
+ (deduced
+ (required
+ (function, *(FunctionPredicate))
+ )
+ (optional
+ (policies, *(PoliciesPredicate))
+ (input_validation_policy, *(InputValidationPredicate))
+ (source_state, *(StatePredicate))
+ (undo_limit, *(UndoLimitPredicate))
+ )
+ )
+ )
+#endif // __BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__
+#else // !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
+#ifdef __BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__
+ //->
+ BOOST_PARAMETER_CONSTRUCTOR(
+ function_automaton, (Base), keyword::tag,
+ (required
+ (function
+ , *
+ )
+ )
+ (deduced
+ (optional
+ (policies
+ , *(
+ ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , Policies
+ >
+ )
+ )
+ (input_validation_policy
+ , *(
+ ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , InputValidationPolicy
+ >
+ )
+ )
+ (source_state
+ , *(::std::tr1::is_convertible< ::boost::mpl::_,state>)
+ )
+ (undo_limit
+ , *(
+ ::std::tr1::is_integral<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ >
+ )
+ )
+ )
+ )
+ )
+ //<-
+#else // !defined(__BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__)
+ BOOST_PARAMETER_CONSTRUCTOR(
+ function_automaton, (Base), keyword::tag,
+ (deduced
+ (required
+ (function
+ , *(
+ ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , Function
+ >
+ )
+ )
+ )
+ (optional
+ (policies
+ , *(
+ ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , Policies
+ >
+ )
+ )
+ (input_validation_policy
+ , *(
+ ::std::tr1::is_same<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ , InputValidationPolicy
+ >
+ )
+ )
+ (source_state
+ , *(::std::tr1::is_convertible< ::boost::mpl::_,state>)
+ )
+ (undo_limit
+ , *(
+ ::std::tr1::is_integral<
+ ::boost::detail::data_type< ::boost::mpl::_>
+ >
+ )
+ )
+ )
+ )
+ )
+#endif // __BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__
+#endif // BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
+ //->
+
+ function_automaton(function_automaton const& copy)
+ : Base(static_cast<Base const&>(copy))
+ {
+ }
+
+ //<-
+ inline
+ //->
+ function_automaton& operator=(function_automaton const& copy)
+ //<-
+ {
+ if (this != &copy)
+ {
+ Base::operator=(static_cast<Base const&>(copy));
+ }
+
+ return *this;
+ }
+ //->
+ ;
+
+ //<-
+ inline
+ //->
+ function_automaton& operator=(state const& source_state)
+ //<-
+ {
+ Base::operator=(source_state);
+ return *this;
+ }
+ //->
+ ;
+
+ template <typename TFunction>
+ //<-
+ inline
+ //->
+ function_automaton& operator=(TFunction f)
+ //<-
+ {
+ Base::operator=(f);
+ return *this;
+ }
+ //->
+ ;
+ };
+
+//<-
+#undef BOOST_AUTOMATA_AUTOMATON_OPTIONAL_TPL_PARAM
+#undef BOOST_AUTOMATA_AUTOMATON_REQUIRED_TPL_PARAM
+#undef BOOST_AUTOMATA_AUTOMATON_ARGS
+//->
+
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_FUNCTION_AUTOMATON_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/generator/deterministic.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/generator/deterministic.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,141 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_GENERATOR_DETERMINISTIC_HPP_INCLUDED
+#define BOOST_AUTOMATA_GENERATOR_DETERMINISTIC_HPP_INCLUDED
+
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/tags/base.hpp>
+
+//[reference__deterministic_generator
+namespace boost { namespace automata {
+ //<-
+ namespace _detail {
+
+ template <typename Tag>
+ struct deterministic_state_1
+ {
+ template <typename Function, typename Input>
+ static inline void
+ evaluate(
+ typename Function::state& state
+ , Function const& function
+ , Input const& i
+ )
+ {
+ state = function(state, i);
+ }
+ };
+
+ template <>
+ struct deterministic_state_1<combinatorial_transition_function_tag>
+ {
+ template <typename Function, typename Input>
+ static inline void
+ evaluate(
+ typename Function::state& state
+ , Function const& function
+ , Input const& i
+ )
+ {
+ state = function(i);
+ }
+ };
+
+ template <typename IsComplexState>
+ struct deterministic_state_2
+ {
+ template <typename Function, typename Input>
+ static inline bool
+ evaluate(
+ typename Function::state& state
+ , Function const& function
+ , Input const& i
+ )
+ {
+ return function(state, i);
+ }
+ };
+
+ template <>
+ struct deterministic_state_2< ::std::tr1::false_type>
+ {
+ template <typename Function, typename Input>
+ static inline bool
+ evaluate(
+ typename Function::state& state
+ , Function const& function
+ , Input const& i
+ )
+ {
+ deterministic_state_1<typename Function::tag>::evaluate(
+ state
+ , function
+ , i
+ );
+ return true;
+ }
+ };
+ } // namespace _detail
+ //->
+
+ struct deterministic_generator
+ {
+ template <typename Function>
+ struct apply
+ {
+ struct type
+ {
+ protected:
+ typedef automaton_base_tag tag;
+ typedef void traits;
+
+ static void reset_impl();
+
+ template <typename Input>
+ static bool
+ process_input_impl(
+ Function const& function
+ , typename Function::state& current_state
+ , Input const& i
+ );
+ };
+ };
+ };
+
+ //<-
+ template <typename Function>
+ inline void
+ deterministic_generator::apply<Function>::type::reset_impl()
+ {
+ }
+
+ template <typename Function>
+ template <typename Input>
+ inline bool
+ deterministic_generator::apply<Function>::type::process_input_impl(
+ Function const& function
+ , typename Function::state& current_state
+ , Input const& i
+ )
+ {
+ typedef typename Function::result_type r_type;
+
+ return _detail::deterministic_state_2<
+ typename ::boost::mpl::if_<
+ ::std::tr1::is_same<r_type,typename Function::state>
+ , ::std::tr1::false_type
+ , ::std::tr1::is_same<r_type,bool>
+ >::type
+ >::evaluate(current_state, function, i);
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_GENERATOR_DETERMINISTIC_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/generator/dfa.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/generator/dfa.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,111 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_GENERATOR_DFA_HPP_INCLUDED
+#define BOOST_AUTOMATA_GENERATOR_DFA_HPP_INCLUDED
+
+#include <boost/automata/tags/base.hpp>
+#include <boost/automata/concept_check.hpp>
+
+//[reference__dfa_generator
+namespace boost { namespace automata {
+
+ struct dfa_generator
+ {
+ template <typename Function>
+ struct apply
+ {
+ BOOST_CONCEPT_ASSERT((DFATransitionFunction<Function>));
+
+ struct type
+ {
+ protected:
+ typedef input_enumerable_automaton_base_tag tag;
+ typedef void traits;
+
+ static void reset_impl();
+
+ template <typename Input>
+ static bool
+ is_nontrivial_input_impl(
+ Function const& function
+ , typename Function::state const& current_state
+ , Input const& i
+ );
+
+ template <typename Iterator>
+ static void
+ make_nontrivial_inputs_impl(
+ Function const& function
+ , typename Function::state const& current_state
+ , Iterator itr
+ );
+
+ template <typename Input>
+ static bool
+ process_input_impl(
+ Function const& function
+ , typename Function::state& current_state
+ , Input const& i
+ );
+ };
+ };
+ };
+
+ //<-
+ template <typename Function>
+ inline void dfa_generator::apply<Function>::type::reset_impl()
+ {
+ }
+
+ template <typename Function>
+ template <typename Input>
+ inline bool
+ dfa_generator::apply<Function>::type::is_nontrivial_input_impl(
+ Function const& function
+ , typename Function::state const& current_state
+ , Input const& i
+ )
+ {
+ return current_state != function(current_state, i);
+ }
+
+ template <typename Function>
+ template <typename Iterator>
+ inline void
+ dfa_generator::apply<Function>::type::make_nontrivial_inputs_impl(
+ Function const& function
+ , typename Function::state const& current_state
+ , Iterator itr
+ )
+ {
+ function.make_nontrivial_inputs(current_state, itr);
+ }
+
+ template <typename Function>
+ template <typename Input>
+ inline bool
+ dfa_generator::apply<Function>::type::process_input_impl(
+ Function const& function
+ , typename Function::state& current_state
+ , Input const& i
+ )
+ {
+ if (type::is_nontrivial_input_impl(function, current_state, i))
+ {
+ current_state = function(current_state, i);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_GENERATOR_DFA_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/generator/dpda.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/generator/dpda.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,307 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_GENERATOR_DPDA_HPP_INCLUDED
+#define BOOST_AUTOMATA_GENERATOR_DPDA_HPP_INCLUDED
+
+#include <deque>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/fusion/support/pair.hpp>
+#include <boost/automata/tags/base.hpp>
+#include <boost/automata/keys/dpda.hpp>
+#include <boost/automata/concept_check.hpp>
+#include <boost/assert.hpp>
+
+//[reference__dpda_generator
+namespace boost { namespace automata {
+
+ struct dpda_generator
+ {
+ template <typename Function>
+ struct apply
+ {
+ BOOST_CONCEPT_ASSERT((DPDATransitionFunction<Function>));
+
+ class type
+ {
+ //typedef implementation_defined stack_sequence;
+ //<-
+ typedef ::std::deque<typename Function::stack_element>
+ stack_sequence;
+ //->
+
+ protected:
+ typedef input_enumerable_automaton_base_tag tag;
+
+ struct traits
+ {
+ typedef typename Function::stack_element
+ stack_element;
+ typedef typename stack_sequence::const_iterator
+ stack_iterator;
+ };
+
+ //<-
+ private:
+ stack_sequence _sequence;
+
+ protected:
+ //->
+ type();
+
+ public:
+ type(type const& copy);
+
+ type& operator=(type const& copy);
+
+ bool has_empty_stack() const;
+
+ //<-
+ inline
+ //->
+ typename traits::stack_element const& get_stack_top() const
+ //<-
+ {
+ BOOST_ASSERT(!has_empty_stack());
+ return _sequence.back();
+ }
+ //->
+ ;
+
+ //<-
+ inline
+ //->
+ typename traits::stack_iterator get_stack_begin() const
+ //<-
+ {
+ return _sequence.begin();
+ }
+ //->
+ ;
+
+ //<-
+ inline
+ //->
+ typename traits::stack_iterator get_stack_end() const
+ //<-
+ {
+ return _sequence.end();
+ }
+ //->
+ ;
+
+ protected:
+ void reset_impl();
+
+ template <typename Input>
+ bool
+ is_nontrivial_input_impl(
+ Function const& function
+ , typename Function::state const& current_state
+ , Input const& i
+ ) const;
+
+ template <typename Iterator>
+ void
+ make_nontrivial_inputs_impl(
+ Function const& function
+ , typename Function::state const& current_state
+ , Iterator itr
+ ) const;
+
+ template <typename Input>
+ bool
+ process_input_impl(
+ Function const& function
+ , typename Function::state& current_state
+ , Input const& i
+ );
+
+ //<-
+ private:
+ bool
+ _process_input(
+ typename Function::state& current_state
+ , typename Function::result_map const& m
+ );
+
+#if 0
+ // Not used yet.
+ static bool
+ _has_equal_states(type const& lhs, type const& rhs);
+#endif // 0
+ //->
+ };
+ };
+ };
+
+ //<-
+ template <typename Function>
+ dpda_generator::apply<Function>::type::type() : _sequence()
+ {
+ }
+
+ template <typename Function>
+ dpda_generator::apply<Function>::type::type(type const& copy)
+ : _sequence(copy._sequence)
+ {
+ }
+
+ template <typename Function>
+ inline typename dpda_generator::BOOST_NESTED_TEMPLATE apply<
+ Function
+ >::type&
+ dpda_generator::apply<Function>::type::operator=(type const& copy)
+ {
+ _sequence = copy._sequence;
+ return *this;
+ }
+
+ template <typename Function>
+ inline bool dpda_generator::apply<Function>::type::has_empty_stack() const
+ {
+ return _sequence.empty();
+ }
+
+ template <typename Function>
+ inline void dpda_generator::apply<Function>::type::reset_impl()
+ {
+ _sequence.clear();
+ }
+
+ template <typename Function>
+ template <typename Input>
+ inline bool
+ dpda_generator::apply<Function>::type::is_nontrivial_input_impl(
+ Function const& function
+ , typename Function::state const& current_state
+ , Input const& i
+ ) const
+ {
+ if (!has_empty_stack())
+ {
+ if (function(current_state, i, get_stack_top()))
+ {
+ return true;
+ }
+ }
+
+ if (function(current_state, i))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ template <typename Function>
+ template <typename Iterator>
+ inline void
+ dpda_generator::apply<Function>::type::make_nontrivial_inputs_impl(
+ Function const& function
+ , typename Function::state const& current_state
+ , Iterator itr
+ ) const
+ {
+ if (!has_empty_stack())
+ {
+ function.make_nontrivial_inputs(
+ current_state
+ , get_stack_top()
+ , itr
+ );
+ }
+
+ function.make_nontrivial_inputs(current_state, itr);
+ }
+
+ template <typename Function>
+ template <typename Input>
+ bool
+ dpda_generator::apply<Function>::type::process_input_impl(
+ Function const& function
+ , typename Function::state& current_state
+ , Input const& i
+ )
+ {
+ if (!has_empty_stack())
+ {
+ if (
+ typename Function::result_type r = function(
+ current_state
+ , i
+ , get_stack_top()
+ )
+ )
+ {
+ _sequence.pop_back();
+ return _process_input(current_state, *r);
+ }
+ }
+
+ if (typename Function::result_type r = function(current_state, i))
+ {
+ return _process_input(current_state, *r);
+ }
+
+ return false;
+ }
+
+ template <typename Function>
+ bool
+ dpda_generator::apply<Function>::type::_process_input(
+ typename Function::state& current_state
+ , typename Function::result_map const& m
+ )
+ {
+ current_state = ::boost::fusion::at_key<next_state_key>(m);
+
+ if (
+ typename Function::optional_stack_element const&
+ o_e = ::boost::fusion::at_key<push_to_stack_key>(m)
+ )
+ {
+ _sequence.push_back(*o_e);
+ }
+
+ return true;
+ }
+
+#if 0
+ // Not used yet.
+ template <typename Function>
+ bool
+ dpda_generator::apply<Function>::type::_has_equal_states(
+ type const& lhs
+ , type const& rhs
+ )
+ {
+ typename traits::stack_iterator l_end = lhs.get_stack_end();
+ typename traits::stack_iterator r_itr = rhs.get_stack_begin();
+ typename traits::stack_iterator r_end = rhs.get_stack_end();
+
+ for (
+ typename traits::stack_iterator l_itr = lhs.get_stack_begin();
+ l_itr != l_end;
+ ++l_itr
+ )
+ {
+ if ((r_itr == r_end) || !(*l_itr == *r_itr))
+ {
+ return false;
+ }
+
+ ++r_itr;
+ }
+
+ return r_itr == r_end;
+ }
+#endif // 0
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_GENERATOR_DPDA_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/generator/probabilistic.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/generator/probabilistic.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,155 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_GENERATOR_PROBABILISTIC_HPP_INCLUDED
+#define BOOST_AUTOMATA_GENERATOR_PROBABILISTIC_HPP_INCLUDED
+
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/tags/base.hpp>
+
+//[reference__probabiistic_generator
+namespace boost { namespace automata {
+
+ template <typename RNGEngine>
+ struct probabilistic_generator
+ {
+ template <typename Function>
+ struct apply
+ {
+ class type
+ {
+ RNGEngine _rng_engine;
+
+ protected:
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_base_of<
+ mdp_transition_function_tag
+ , typename Function::tag
+ >
+ , input_enumerable_automaton_base_tag
+ , automaton_base_tag
+ >::type
+ tag;
+ typedef void
+ traits;
+
+ void reset_impl();
+
+ template <typename Input>
+ static bool
+ is_nontrivial_input_impl(
+ Function const& function
+ , typename Function::state const& current_state
+ , Input const& i
+ );
+
+ template <typename Iterator>
+ static void
+ make_nontrivial_inputs_impl(
+ Function const& function
+ , typename Function::state const& current_state
+ , Iterator itr
+ );
+
+ template <typename Input>
+ bool
+ process_input_impl(
+ Function const& function
+ , typename Function::state& current_state
+ , Input const& i
+ );
+
+ public:
+ template <typename T>
+ void seed(T t);
+
+ template <typename Iterator>
+ void seed(Iterator& first, Iterator last);
+ };
+ };
+ };
+
+ //<-
+ template <typename RNGEngine>
+ template <typename Function>
+ template <typename T>
+ inline void
+ probabilistic_generator<RNGEngine>::apply<Function>::type::seed(T t)
+ {
+ _rng_engine.seed(t);
+ }
+
+ template <typename RNGEngine>
+ template <typename Function>
+ template <typename Iterator>
+ inline void
+ probabilistic_generator<RNGEngine>::apply<Function>::type::seed(
+ Iterator& first
+ , Iterator last
+ )
+ {
+ _rng_engine.seed(first, last);
+ }
+
+ template <typename RNGEngine>
+ template <typename Function>
+ inline void
+ probabilistic_generator<RNGEngine>::apply<Function>::type::reset_impl()
+ {
+ _rng_engine.seed();
+ }
+
+ template <typename RNGEngine>
+ template <typename Function>
+ template <typename Input>
+ inline bool
+ probabilistic_generator<RNGEngine>::apply<
+ Function
+ >::type::is_nontrivial_input_impl(
+ Function const& function
+ , typename Function::state const& current_state
+ , Input const& i
+ )
+ {
+ return function.is_nontrivial_input(current_state, i);
+ }
+
+ template <typename RNGEngine>
+ template <typename Function>
+ template <typename Iterator>
+ inline void
+ probabilistic_generator<RNGEngine>::apply<
+ Function
+ >::type::make_nontrivial_inputs_impl(
+ Function const& function
+ , typename Function::state const& current_state
+ , Iterator itr
+ )
+ {
+ function.make_nontrivial_inputs(current_state, itr);
+ }
+
+ template <typename RNGEngine>
+ template <typename Function>
+ template <typename Input>
+ inline bool
+ probabilistic_generator<RNGEngine>::apply<
+ Function
+ >::type::process_input_impl(
+ Function const& function
+ , typename Function::state& current_state
+ , Input const& i
+ )
+ {
+ return function(current_state, i, _rng_engine);
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_GENERATOR_PROBABILISTIC_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/input_rule/cellular_graph.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/input_rule/cellular_graph.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,133 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_INPUT_RULE_CELLULAR_GRAPH_HPP_INCLUDED
+#define BOOST_AUTOMATA_INPUT_RULE_CELLULAR_GRAPH_HPP_INCLUDED
+
+#include <deque>
+#include <utility>
+#include <boost/tr1/tuple.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+#include <boost/graph/properties.hpp>
+#include <boost/graph/graph_traits.hpp>
+#include <boost/graph/vertex_property_map_gen.hpp>
+
+//[reference__cellular_graph_input_rule
+namespace boost { namespace automata {
+ //<-
+ namespace _detail {
+
+ template <typename Map>
+ class get_map_value
+ {
+ Map& _map;
+
+ public:
+ typedef typename property_traits<Map>::key_type argument_type;
+ typedef typename property_traits<Map>::value_type& result_type;
+
+ explicit get_map_value(Map& map);
+
+ result_type operator()(argument_type const& arg) const;
+ };
+
+ template <typename Map>
+ inline get_map_value<Map>::get_map_value(Map& map) : _map(map)
+ {
+ }
+
+ template <typename Map>
+ inline typename get_map_value<Map>::result_type
+ get_map_value<Map>::operator()(argument_type const& arg) const
+ {
+ return get(_map, arg);
+ }
+ } // namespace _detail
+ //->
+
+ template <typename Graph>
+ class cellular_graph_input_rule
+ {
+ Graph const& _graph;
+
+ public:
+ typedef bool result_type;
+
+ explicit cellular_graph_input_rule(Graph const& graph);
+
+ template <typename CellMap>
+ result_type operator()(CellMap& cell_map) const;
+ };
+
+ //<-
+ template <typename Graph>
+ cellular_graph_input_rule<Graph>::cellular_graph_input_rule(
+ Graph const& graph
+ ) : _graph(graph)
+ {
+ }
+
+ template <typename Graph>
+ template <typename CellMap>
+ typename cellular_graph_input_rule<Graph>::result_type
+ cellular_graph_input_rule<Graph>::operator()(CellMap& cell_map) const
+ {
+ typedef typename property_traits<CellMap>::value_type
+ Cell;
+ typedef typename ::boost::vertex_property_map_gen<
+ Graph
+ , typename Cell::state
+ >::type
+ StateMap;
+
+ StateMap state_map(_graph);
+ typename ::boost::graph_traits<Graph>::vertex_iterator v_itr, v_end;
+
+ for (
+ ::std::tr1::tie(v_itr, v_end) = boost::vertices(_graph);
+ v_itr != v_end;
+ ++v_itr
+ )
+ {
+ put(state_map, *v_itr, get(cell_map, *v_itr).get_current_state());
+ }
+
+ _detail::get_map_value<StateMap> getter(state_map);
+ typename ::boost::graph_traits<Graph>::adjacency_iterator a_itr, a_end;
+ bool result = false;
+
+ for (
+ ::std::tr1::tie(v_itr, v_end) = ::boost::vertices(_graph);
+ v_itr != v_end;
+ ++v_itr
+ )
+ {
+ ::std::tr1::tie(a_itr, a_end) = ::boost::adjacent_vertices(
+ *v_itr
+ , _graph
+ );
+ Cell& cell = get(cell_map, *v_itr);
+
+ cell(
+ ::std::make_pair(
+ make_transform_iterator(a_itr, getter)
+ , make_transform_iterator(a_end, getter)
+ )
+ );
+
+ if (cell.get_current_state() != getter(*v_itr))
+ {
+ result = true;
+ }
+ }
+
+ return result;
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_INPUT_RULE_CELLULAR_GRAPH_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/input_rule/wolfram_code.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/input_rule/wolfram_code.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,312 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_INPUT_RULE_WOLFRAM_CODE_HPP_INCLUDED
+#define BOOST_AUTOMATA_INPUT_RULE_WOLFRAM_CODE_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/concept/assert.hpp>
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <boost/tuple/tuple_comparison.hpp>
+#include <boost/utility/associative_container_gen.hpp>
+
+//[reference__wolfram_code_input_rule
+namespace boost { namespace automata {
+
+ template <
+ typename StateElement
+ , typename AssociativeContainerSelector = ::boost::mapS
+ >
+ class wolfram_code_input_rule
+ {
+ // typedef implementation_defined Setter;
+ //<-
+ typedef ::boost::tuple<StateElement,StateElement,StateElement>
+ Neighborhood;
+ typedef typename ::boost::mpl::apply_wrap2<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , Neighborhood
+ , StateElement
+ >::type
+ Code;
+
+ class Setter
+ {
+ wolfram_code_input_rule& _rule;
+ Neighborhood _key;
+
+ public:
+ Setter(
+ wolfram_code_input_rule& rule
+ , StateElement const& prior_old_value
+ , StateElement const& old_value
+ , StateElement const& next_old_value
+ );
+
+ void operator=(StateElement const& new_value);
+ };
+
+ Code _code;
+ StateElement _blank;
+ //->
+
+ public:
+ wolfram_code_input_rule();
+
+ explicit wolfram_code_input_rule(StateElement const& blank);
+
+ void reset();
+
+ void reset(StateElement const& blank);
+
+ void
+ add_association(
+ StateElement const& prior_old_value
+ , StateElement const& old_value
+ , StateElement const& next_old_value
+ , StateElement const& new_value
+ );
+
+ Setter
+ operator()(
+ StateElement const& prior_old_value
+ , StateElement const& old_value
+ , StateElement const& next_old_value
+ );
+
+ template <typename StateSequence>
+ StateSequence operator()(StateSequence const& current_state) const;
+
+ //<-
+ private:
+ StateElement const&
+ _find_element(
+ StateElement const& e1
+ , StateElement const& e2
+ , StateElement const& e3
+ ) const;
+
+ template <typename StateSequence>
+ void _normalize(StateSequence& next_state) const;
+ //->
+ };
+
+ //<-
+ template <typename StateElement, typename AssociativeContainerSelector>
+ wolfram_code_input_rule<
+ StateElement
+ , AssociativeContainerSelector
+ >::Setter::Setter(
+ wolfram_code_input_rule& rule
+ , StateElement const& prior_old_value
+ , StateElement const& old_value
+ , StateElement const& next_old_value
+ ) : _rule(rule), _key(prior_old_value, old_value, next_old_value)
+ {
+ }
+
+ template <typename StateElement, typename AssociativeContainerSelector>
+ inline void
+ wolfram_code_input_rule<
+ StateElement
+ , AssociativeContainerSelector
+ >::Setter::operator=(StateElement const& new_value)
+ {
+ _rule._code.insert(typename Code::value_type(_key, new_value));
+ }
+
+ template <typename StateElement, typename AssociativeContainerSelector>
+ wolfram_code_input_rule<
+ StateElement
+ , AssociativeContainerSelector
+ >::wolfram_code_input_rule() : _code(), _blank()
+ {
+ }
+
+ template <typename StateElement, typename AssociativeContainerSelector>
+ wolfram_code_input_rule<
+ StateElement
+ , AssociativeContainerSelector
+ >::wolfram_code_input_rule(StateElement const& blank)
+ : _code(), _blank(blank)
+ {
+ }
+
+ template <typename StateElement, typename AssociativeContainerSelector>
+ inline void
+ wolfram_code_input_rule<
+ StateElement
+ , AssociativeContainerSelector
+ >::reset()
+ {
+ _code.clear();
+ }
+
+ template <typename StateElement, typename AssociativeContainerSelector>
+ inline void
+ wolfram_code_input_rule<
+ StateElement
+ , AssociativeContainerSelector
+ >::reset(StateElement const& blank)
+ {
+ _code.clear();
+ _blank = blank;
+ }
+
+ template <typename StateElement, typename AssociativeContainerSelector>
+ inline void
+ wolfram_code_input_rule<
+ StateElement
+ , AssociativeContainerSelector
+ >::add_association(
+ StateElement const& prior_old_value
+ , StateElement const& old_value
+ , StateElement const& next_old_value
+ , StateElement const& new_value
+ )
+ {
+ _code.insert(
+ typename Code::value_type(
+ Neighborhood(prior_old_value, old_value, next_old_value)
+ , new_value
+ )
+ );
+ }
+
+ template <typename StateElement, typename AssociativeContainerSelector>
+ inline typename wolfram_code_input_rule<
+ StateElement
+ , AssociativeContainerSelector
+ >::Setter
+ wolfram_code_input_rule<
+ StateElement
+ , AssociativeContainerSelector
+ >::operator()(
+ StateElement const& prior_old_value
+ , StateElement const& old_value
+ , StateElement const& next_old_value
+ )
+ {
+ return Setter(*this, prior_old_value, old_value, next_old_value);
+ }
+
+ template <typename StateElement, typename AssociativeContainerSelector>
+ inline StateElement const&
+ wolfram_code_input_rule<
+ StateElement
+ , AssociativeContainerSelector
+ >::_find_element(
+ StateElement const& e1
+ , StateElement const& e2
+ , StateElement const& e3
+ ) const
+ {
+ typename Code::const_iterator itr = _code.find(
+ Neighborhood(e1, e2, e3)
+ );
+
+ return (itr == _code.end()) ? _blank : itr->second;
+ }
+
+ template <typename StateElement, typename AssociativeContainerSelector>
+ template <typename StateSequence>
+ void
+ wolfram_code_input_rule<
+ StateElement
+ , AssociativeContainerSelector
+ >::_normalize(StateSequence& next_state) const
+ {
+ while (!next_state.empty() && (next_state.back() == _blank))
+ {
+ next_state.pop_back();
+ }
+
+ while (!next_state.empty() && (next_state.front() == _blank))
+ {
+ next_state.pop_front();
+ }
+ }
+
+ template <typename StateElement, typename AssociativeContainerSelector>
+ template <typename StateSequence>
+ StateSequence
+ wolfram_code_input_rule<
+ StateElement
+ , AssociativeContainerSelector
+ >::operator()(StateSequence const& current_state) const
+ {
+ BOOST_CONCEPT_ASSERT((::boost::FrontInsertionSequence<StateSequence>));
+ BOOST_CONCEPT_ASSERT((::boost::BackInsertionSequence<StateSequence>));
+ BOOST_MPL_ASSERT((
+ ::std::tr1::is_same<
+ typename StateSequence::value_type
+ , StateElement
+ >
+ ));
+
+ typename StateSequence::const_iterator itr_0 = current_state.begin();
+ typename StateSequence::const_iterator itr_begin = itr_0;
+ typename StateSequence::const_iterator itr_end = current_state.end();
+ StateSequence next_state(current_state);
+
+ if (itr_0 == itr_end)
+ {
+ next_state.push_back(_find_element(_blank, _blank, _blank));
+ _normalize(next_state);
+ return next_state;
+ }
+
+ typename StateSequence::const_iterator itr_1 = itr_0;
+
+ if (++itr_1 == itr_end)
+ {
+ next_state.push_front(_find_element(_blank, _blank, *itr_0));
+ next_state.back() = _find_element(_blank, *itr_0, _blank);
+ next_state.push_back(_find_element(*itr_0, _blank, _blank));
+ _normalize(next_state);
+ return next_state;
+ }
+
+ typename StateSequence::const_iterator itr_2 = itr_1;
+
+ next_state.front() = _find_element(_blank, *itr_0, *itr_1);
+ next_state.push_front(_find_element(_blank, _blank, *itr_0));
+
+ if (++itr_2 == itr_end)
+ {
+ next_state.back() = _find_element(*itr_0, *itr_1, _blank);
+ next_state.push_back(_find_element(*itr_1, _blank, _blank));
+ _normalize(next_state);
+ return next_state;
+ }
+
+ typename StateSequence::iterator n_itr = next_state.begin();
+
+ ++n_itr;
+
+ do
+ {
+ *(++n_itr) = _find_element(*itr_0, *itr_1, *itr_2);
+ ++itr_0;
+ ++itr_1;
+ }
+ while (++itr_2 != itr_end);
+
+ *(++n_itr) = _find_element(*itr_0, *itr_1, _blank);
+ next_state.push_back(_find_element(*itr_1, _blank, _blank));
+ _normalize(next_state);
+ return next_state;
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_INPUT_RULE_WOLFRAM_CODE_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/keys/common.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/keys/common.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,17 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_KEYS_COMMON_HPP_INCLUDED
+#define BOOST_AUTOMATA_KEYS_COMMON_HPP_INCLUDED
+
+namespace boost { namespace automata {
+
+ struct input_symbol_key;
+ struct next_state_key;
+ struct rng_engine_key;
+}} // namespace boost::automata
+
+#endif // BOOST_AUTOMATA_KEYS_COMMON_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/keys/dpda.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/keys/dpda.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,16 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_KEYS_DPDA_HPP_INCLUDED
+#define BOOST_AUTOMATA_KEYS_DPDA_HPP_INCLUDED
+
+namespace boost { namespace automata {
+
+ struct pop_from_stack_key;
+ struct push_to_stack_key;
+}} // namespace boost::automata
+
+#endif // BOOST_AUTOMATA_KEYS_DPDA_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/keys/observer.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/keys/observer.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_KEYS_OBSERVER_HPP_INCLUDED
+#define BOOST_AUTOMATA_KEYS_OBSERVER_HPP_INCLUDED
+
+namespace boost { namespace automata {
+
+ template <unsigned long Uid = 0UL>
+ struct single_final_state_key;
+
+ template <unsigned long Uid = 0UL>
+ struct multiple_final_states_key;
+}} // namespace boost::automata
+
+#endif // BOOST_AUTOMATA_KEYS_OBSERVER_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/keyword/name.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/keyword/name.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,29 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_KEYWORD_NAME_HPP_INCLUDED
+#define BOOST_AUTOMATA_KEYWORD_NAME_HPP_INCLUDED
+
+#include <boost/parameter/name.hpp>
+
+namespace boost { namespace automata { namespace keyword {
+
+ BOOST_PARAMETER_NAME(source_state)
+ BOOST_PARAMETER_NAME(graph)
+ BOOST_PARAMETER_NAME(vertex_state_map)
+ BOOST_PARAMETER_NAME(edge_input_map)
+ BOOST_PARAMETER_NAME(target)
+ BOOST_PARAMETER_NAME(function)
+ BOOST_PARAMETER_NAME(input_recognizer)
+ BOOST_PARAMETER_NAME(state_recognizer)
+ BOOST_PARAMETER_NAME(builder)
+ BOOST_PARAMETER_NAME(policies)
+ BOOST_PARAMETER_NAME(input_validation_policy)
+ BOOST_PARAMETER_NAME(undo_limit)
+
+}}} // namespace boost::automata::keyword
+
+#endif // BOOST_AUTOMATA_KEYWORD_NAME_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/keyword/template.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/keyword/template.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,162 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_KEYWORD_TEMPLATE_HPP_INCLUDED
+#define BOOST_AUTOMATA_KEYWORD_TEMPLATE_HPP_INCLUDED
+
+#include <boost/parameter/aux_/template_keyword.hpp>
+
+namespace boost { namespace automata { namespace keyword {
+ namespace tag {
+
+ struct _Function;
+ struct _State;
+ struct _Input;
+ struct _StackElement;
+ struct _AttributeKey;
+ struct _AttributeValue;
+ struct _RealNumber;
+ struct _AssociativeContainerSelector;
+ struct _RandomAccessContainerSelector;
+ } // namespace tag
+
+ template <typename T>
+ struct _Function
+ : boost::parameter::template_keyword<tag::_Function,T>
+ {
+ };
+
+ template <typename T>
+ struct _State
+ : boost::parameter::template_keyword<tag::_State,T>
+ {
+ };
+
+ template <typename T>
+ struct _Input
+ : boost::parameter::template_keyword<tag::_Input,T>
+ {
+ };
+
+ template <typename T>
+ struct _StackElement
+ : boost::parameter::template_keyword<tag::_StackElement,T>
+ {
+ };
+
+ template <typename T>
+ struct _AttributeKey
+ : boost::parameter::template_keyword<tag::_AttributeKey,T>
+ {
+ };
+
+ template <typename T>
+ struct _AttributeValue
+ : boost::parameter::template_keyword<tag::_AttributeValue,T>
+ {
+ };
+
+ template <typename T>
+ struct _RealNumber
+ : boost::parameter::template_keyword<tag::_RealNumber,T>
+ {
+ };
+
+ template <typename T>
+ struct _AssociativeContainerSelector
+ : boost::parameter::template_keyword<
+ tag::_AssociativeContainerSelector
+ , T
+ >
+ {
+ };
+
+ template <typename T>
+ struct _RandomAccessContainerSelector
+ : boost::parameter::template_keyword<
+ tag::_RandomAccessContainerSelector
+ , T
+ >
+ {
+ };
+
+ namespace tag {
+
+ struct _StateRecognizer;
+ struct _InputRecognizer;
+ } // namespace tag
+
+ template <typename T>
+ struct _StateRecognizer
+ : boost::parameter::template_keyword<tag::_StateRecognizer,T>
+ {
+ };
+
+ template <typename T>
+ struct _InputRecognizer
+ : boost::parameter::template_keyword<tag::_InputRecognizer,T>
+ {
+ };
+
+ namespace tag {
+
+ struct _Graph;
+ struct _VertexStateMap;
+ struct _EdgeInputMap;
+ struct _Policies;
+ } // namespace tag
+
+ template <typename T>
+ struct _Graph
+ : boost::parameter::template_keyword<tag::_Graph,T>
+ {
+ };
+
+ template <typename T>
+ struct _VertexStateMap
+ : boost::parameter::template_keyword<tag::_VertexStateMap,T>
+ {
+ };
+
+ template <typename T>
+ struct _EdgeInputMap
+ : boost::parameter::template_keyword<tag::_EdgeInputMap,T>
+ {
+ };
+
+ template <typename T>
+ struct _Policies
+ : boost::parameter::template_keyword<tag::_Policies,T>
+ {
+ };
+
+ namespace tag {
+
+ struct _BaseGenerator;
+ struct _InputValidationPolicy;
+ struct _IsUndoable;
+ } // namespace tag
+
+ template <typename T>
+ struct _BaseGenerator
+ : boost::parameter::template_keyword<tag::_BaseGenerator,T>
+ {
+ };
+
+ template <typename T>
+ struct _InputValidationPolicy
+ : boost::parameter::template_keyword<tag::_InputValidationPolicy,T>
+ {
+ };
+
+ template <typename T>
+ struct _IsUndoable
+ : boost::parameter::template_keyword<tag::_IsUndoable,T>
+ {
+ };
+}}} // namespace boost::automata:keyword
+
+#endif // BOOST_AUTOMATA_KEYWORD_TEMPLATE_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/observer/base.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/observer/base.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,105 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_OBSERVER_BASE_HPP_INCLUDED
+#define BOOST_AUTOMATA_OBSERVER_BASE_HPP_INCLUDED
+
+//[reference__base_observer
+namespace boost { namespace automata {
+
+ template <typename SubjectAutomaton>
+ class base_observer
+ {
+ //<-
+ SubjectAutomaton const& _subject_automaton;
+
+ base_observer(base_observer const& copy);
+ //->
+
+ protected:
+ explicit base_observer(SubjectAutomaton const& automaton);
+
+ public:
+ void on_reset();
+
+ template <typename Input>
+ void on_accept_input(Input const& i);
+
+ template <typename Input>
+ void on_reject_input(Input const& i);
+
+ template <typename Input>
+ void on_invalid_input(Input const& i);
+
+ void on_accept_undo();
+
+ void on_reject_undo();
+
+ protected:
+ SubjectAutomaton const& get_subject_automaton() const;
+ };
+
+ //<-
+ template <typename SubjectAutomaton>
+ base_observer<SubjectAutomaton>::base_observer(base_observer const& copy)
+ : _subject_automaton(copy._subject_automaton)
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ base_observer<SubjectAutomaton>::base_observer(
+ SubjectAutomaton const& automaton
+ ) : _subject_automaton(automaton)
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ inline void base_observer<SubjectAutomaton>::on_reset()
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ template <typename Input>
+ inline void
+ base_observer<SubjectAutomaton>::on_accept_input(Input const& i)
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ template <typename Input>
+ inline void
+ base_observer<SubjectAutomaton>::on_reject_input(Input const& i)
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ template <typename Input>
+ inline void
+ base_observer<SubjectAutomaton>::on_invalid_input(Input const& i)
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ inline void base_observer<SubjectAutomaton>::on_accept_undo()
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ inline void base_observer<SubjectAutomaton>::on_reject_undo()
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ inline SubjectAutomaton const&
+ base_observer<SubjectAutomaton>::get_subject_automaton() const
+ {
+ return _subject_automaton;
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_OBSERVER_BASE_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/observer/full_noop.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/observer/full_noop.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,67 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_OBSERVER_FULL_NOOP_HPP_INCLUDED
+#define BOOST_AUTOMATA_OBSERVER_FULL_NOOP_HPP_INCLUDED
+
+#include <boost/automata/observer/base.hpp>
+
+//[reference__full_noop_observer
+namespace boost { namespace automata {
+
+ template <typename SubjectAutomaton>
+ class full_noop_observer : public base_observer<SubjectAutomaton>
+ {
+ protected:
+ explicit full_noop_observer(SubjectAutomaton const& automaton);
+
+ public:
+ void on_construction();
+
+ template <typename Builder, typename Tag>
+ void on_construction(Builder const& builder, Tag);
+
+ template <typename Builder, typename Tag>
+ void on_initialize(Builder const& builder, Tag);
+ };
+
+ //<-
+ template <typename SubjectAutomaton>
+ full_noop_observer<SubjectAutomaton>::full_noop_observer(
+ SubjectAutomaton const& automaton
+ ) : base_observer<SubjectAutomaton>(automaton)
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ inline void full_noop_observer<SubjectAutomaton>::on_construction()
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ template <typename Builder, typename Tag>
+ inline void
+ full_noop_observer<SubjectAutomaton>::on_construction(
+ Builder const& builder
+ , Tag
+ )
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ template <typename Builder, typename Tag>
+ inline void
+ full_noop_observer<SubjectAutomaton>::on_initialize(
+ Builder const& builder
+ , Tag
+ )
+ {
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_OBSERVER_FULL_NOOP_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/observer/output.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/observer/output.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,190 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_OBSERVER_OUTPUT_HPP_INCLUDED
+#define BOOST_AUTOMATA_OBSERVER_OUTPUT_HPP_INCLUDED
+
+//[reference__output_observer
+namespace boost { namespace automata {
+
+ template <typename Policy, typename SubjectAutomaton>
+ class output_observer
+ {
+ //<-
+ Policy _policy;
+ SubjectAutomaton const& _subject_automaton;
+ //->
+
+ public:
+ output_observer(
+ Policy const& policy
+ , SubjectAutomaton const& automaton
+ );
+
+ output_observer(
+ output_observer const& copy
+ , SubjectAutomaton const& automaton
+ );
+
+ output_observer(output_observer const& copy);
+
+ output_observer& operator=(output_observer const& copy);
+
+ void on_construction();
+
+ template <typename Builder, typename Tag>
+ void on_construction(Builder const& builder, Tag);
+
+ template <typename Builder, typename Tag>
+ void on_initialize(Builder const& builder, Tag);
+
+ void on_reset();
+
+ template <typename Input>
+ void on_accept_input(Input const& i);
+
+ template <typename Input>
+ void on_reject_input(Input const& i);
+
+ template <typename Input>
+ void on_invalid_input(Input const& i);
+
+ void on_accept_undo();
+
+ void on_reject_undo();
+ };
+
+ //<-
+ template <typename Policy, typename SubjectAutomaton>
+ output_observer<Policy,SubjectAutomaton>::output_observer(
+ Policy const& policy
+ , SubjectAutomaton const& automaton
+ ) : _policy(policy), _subject_automaton(automaton)
+ {
+ }
+
+ template <typename Policy, typename SubjectAutomaton>
+ output_observer<Policy,SubjectAutomaton>::output_observer(
+ output_observer const& copy
+ , SubjectAutomaton const& automaton
+ ) : _policy(copy._policy), _subject_automaton(automaton)
+ {
+ }
+
+ template <typename Policy, typename SubjectAutomaton>
+ output_observer<Policy,SubjectAutomaton>::output_observer(
+ output_observer const& copy
+ ) : _policy(copy._policy), _subject_automaton(copy._subject_automaton)
+ {
+ }
+
+ template <typename Policy, typename SubjectAutomaton>
+ inline output_observer<Policy,SubjectAutomaton>&
+ output_observer<Policy,SubjectAutomaton>::operator=(
+ output_observer const& copy
+ )
+ {
+ return *this;
+ }
+
+ template <typename Policy, typename SubjectAutomaton>
+ void output_observer<Policy,SubjectAutomaton>::on_construction()
+ {
+ _policy.process_string(__FUNCTION__);
+ _policy.process(_subject_automaton);
+ _policy.output();
+ }
+
+ template <typename Policy, typename SubjectAutomaton>
+ template <typename Builder, typename Tag>
+ void
+ output_observer<Policy,SubjectAutomaton>::on_construction(
+ Builder const& builder
+ , Tag
+ )
+ {
+ _policy.process_string(__FUNCTION__);
+ _policy.process(_subject_automaton);
+ _policy.output();
+ }
+
+ template <typename Policy, typename SubjectAutomaton>
+ template <typename Builder, typename Tag>
+ void
+ output_observer<Policy,SubjectAutomaton>::on_initialize(
+ Builder const& builder
+ , Tag
+ )
+ {
+ _policy.process_string(__FUNCTION__);
+ _policy.process(_subject_automaton);
+ _policy.output();
+ }
+
+ template <typename Policy, typename SubjectAutomaton>
+ void output_observer<Policy,SubjectAutomaton>::on_reset()
+ {
+ _policy.process_string(__FUNCTION__);
+ _policy.process(_subject_automaton);
+ _policy.output();
+ }
+
+ template <typename Policy, typename SubjectAutomaton>
+ template <typename Input>
+ void
+ output_observer<Policy,SubjectAutomaton>::on_accept_input(
+ Input const& i
+ )
+ {
+ _policy.process_string(__FUNCTION__);
+ _policy.process(_subject_automaton, i);
+ _policy.output();
+ }
+
+ template <typename Policy, typename SubjectAutomaton>
+ template <typename Input>
+ void
+ output_observer<Policy,SubjectAutomaton>::on_reject_input(
+ Input const& i
+ )
+ {
+ _policy.process_string(__FUNCTION__);
+ _policy.process(_subject_automaton, i);
+ _policy.output();
+ }
+
+ template <typename Policy, typename SubjectAutomaton>
+ template <typename Input>
+ void
+ output_observer<Policy,SubjectAutomaton>::on_invalid_input(
+ Input const& i
+ )
+ {
+ _policy.process_string(__FUNCTION__);
+ _policy.process(_subject_automaton, i);
+ _policy.output();
+ }
+
+ template <typename Policy, typename SubjectAutomaton>
+ void output_observer<Policy,SubjectAutomaton>::on_accept_undo()
+ {
+ _policy.process_string(__FUNCTION__);
+ _policy.process(_subject_automaton);
+ _policy.output();
+ }
+
+ template <typename Policy, typename SubjectAutomaton>
+ void output_observer<Policy,SubjectAutomaton>::on_reject_undo()
+ {
+ _policy.process_string(__FUNCTION__);
+ _policy.process(_subject_automaton);
+ _policy.output();
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_OBSERVER_OUTPUT_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/policy/bool_insertion.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/policy/bool_insertion.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,134 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_POLICY_BOOL_INSERTION_HPP_INCLUDED
+#define BOOST_AUTOMATA_POLICY_BOOL_INSERTION_HPP_INCLUDED
+
+#include <iosfwd>
+#include <boost/format.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/automata/observer/output.hpp>
+
+//[reference__bool_insertion_policy
+namespace boost { namespace automata {
+
+ template <typename InsertionTarget, typename Policy, typename CharT = char>
+ class bool_insertion_policy
+ {
+ //<-
+ InsertionTarget& _target;
+ basic_format<CharT> _true_format_string;
+ basic_format<CharT> _false_format_string;
+ //->
+
+ public:
+ bool_insertion_policy(
+ InsertionTarget& target
+ , CharT const* true_format_string
+ , CharT const* false_format_string
+ );
+
+ bool_insertion_policy(bool_insertion_policy const& copy);
+
+ template <typename String>
+ void process_string(String const& string);
+
+ template <typename SubjectAutomaton>
+ void process(SubjectAutomaton const& subject_automaton);
+
+ template <typename SubjectAutomaton, typename Input>
+ void
+ process(SubjectAutomaton const& subject_automaton, Input const& i);
+
+ void output();
+
+ template <typename SubjectAutomaton>
+ struct apply
+ {
+ typedef output_observer<bool_insertion_policy,SubjectAutomaton>
+ type;
+ };
+ };
+
+ //<-
+ template <typename InsertionTarget, typename Policy, typename CharT>
+ bool_insertion_policy<InsertionTarget,Policy,CharT>::bool_insertion_policy(
+ InsertionTarget& target
+ , CharT const* true_format_string
+ , CharT const* false_format_string
+ ) : _target(target)
+ , _true_format_string(true_format_string)
+ , _false_format_string(false_format_string)
+ {
+ }
+
+ template <typename InsertionTarget, typename Policy, typename CharT>
+ bool_insertion_policy<InsertionTarget,Policy,CharT>::bool_insertion_policy(
+ bool_insertion_policy const& copy
+ ) : _target(copy._target)
+ , _true_format_string(copy._true_format_string)
+ , _false_format_string(copy._false_format_string)
+ {
+ }
+
+ template <typename InsertionTarget, typename Policy, typename CharT>
+ template <typename String>
+ inline void
+ bool_insertion_policy<InsertionTarget,Policy,CharT>::process_string(
+ String const& string
+ )
+ {
+ }
+
+ template <typename InsertionTarget, typename Policy, typename CharT>
+ template <typename SubjectAutomaton>
+ void
+ bool_insertion_policy<InsertionTarget,Policy,CharT>::process(
+ SubjectAutomaton const& subject_automaton
+ )
+ {
+ if (
+ ::boost::fusion::at_key<Policy>(
+ subject_automaton.get_observer_map()
+ )
+ )
+ {
+ _target << (
+ _true_format_string
+ % subject_automaton.get_current_state()
+ ) << ::std::endl;
+ _true_format_string.clear_binds();
+ }
+ else
+ {
+ _target << (
+ _false_format_string
+ % subject_automaton.get_current_state()
+ ) << ::std::endl;
+ _false_format_string.clear_binds();
+ }
+ }
+
+ template <typename InsertionTarget, typename Policy, typename CharT>
+ template <typename SubjectAutomaton, typename Input>
+ inline void
+ bool_insertion_policy<InsertionTarget,Policy,CharT>::process(
+ SubjectAutomaton const& subject_automaton
+ , Input const& i
+ )
+ {
+ this->process(subject_automaton);
+ }
+
+ template <typename InsertionTarget, typename Policy, typename CharT>
+ inline void bool_insertion_policy<InsertionTarget,Policy,CharT>::output()
+ {
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_POLICY_BOOL_INSERTION_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/policy/default_input_validation.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/policy/default_input_validation.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,97 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_POLICY_DEFAULT_INPUT_VALIDATION_HPP_INCLUDED
+#define BOOST_AUTOMATA_POLICY_DEFAULT_INPUT_VALIDATION_HPP_INCLUDED
+
+//[reference__default_input_validation_policy
+namespace boost { namespace automata {
+
+ struct default_input_validation_policy
+ {
+ template <typename SubjectAutomaton>
+ struct apply
+ {
+ struct type
+ {
+ type(
+ default_input_validation_policy const& policy
+ , SubjectAutomaton const& automaton
+ );
+
+ type(type const& copy, SubjectAutomaton const& automaton);
+
+ void on_construction();
+
+ template <typename Builder, typename Tag>
+ void on_construction(Builder const& builder, Tag);
+
+ template <typename Builder, typename Tag>
+ void on_initialize(Builder const& builder, Tag);
+
+ template <typename Input>
+ bool operator()(Input const& i);
+ };
+ };
+ };
+
+ //<-
+ template <typename SubjectAutomaton>
+ default_input_validation_policy::apply<SubjectAutomaton>::type::type(
+ default_input_validation_policy const& policy
+ , SubjectAutomaton const& automaton
+ )
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ default_input_validation_policy::apply<SubjectAutomaton>::type::type(
+ type const& copy
+ , SubjectAutomaton const& automaton
+ )
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ inline void
+ default_input_validation_policy::apply<
+ SubjectAutomaton
+ >::type::on_construction()
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ template <typename Builder, typename Tag>
+ inline void
+ default_input_validation_policy::apply<
+ SubjectAutomaton
+ >::type::on_construction(Builder const& builder, Tag)
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ template <typename Builder, typename Tag>
+ inline void
+ default_input_validation_policy::apply<
+ SubjectAutomaton
+ >::type::on_initialize(Builder const& builder, Tag)
+ {
+ }
+
+ template <typename SubjectAutomaton>
+ template <typename Input>
+ inline bool
+ default_input_validation_policy::apply<
+ SubjectAutomaton
+ >::type::operator()(Input const& i)
+ {
+ return true;
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_POLICY_DEFAULT_INPUT_VALIDATION_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/policy/dfa_insertion.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/policy/dfa_insertion.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,193 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_POLICY_DFA_INSERTION_HPP_INCLUDED
+#define BOOST_AUTOMATA_POLICY_DFA_INSERTION_HPP_INCLUDED
+
+#include <vector>
+#include <iterator>
+#include <iosfwd>
+#include <sstream>
+#include <boost/format.hpp>
+#include <boost/automata/observer/output.hpp>
+
+//[reference__dfa_insertion_policy
+namespace boost { namespace automata {
+
+ template <
+ typename InsertionTarget
+ , typename NontrivialInput
+ , typename CharT = char
+ >
+ class dfa_insertion_policy
+ {
+ //<-
+ InsertionTarget& _target;
+ basic_format<CharT> _format_string;
+ CharT _element_delimiter;
+ //->
+
+ public:
+ dfa_insertion_policy(
+ InsertionTarget& target
+ , CharT const* format_string
+ , CharT element_delimiter
+ );
+
+ dfa_insertion_policy(dfa_insertion_policy const& copy);
+
+ template <typename String>
+ void process_string(String const& string);
+
+ template <typename SubjectAutomaton>
+ void process(SubjectAutomaton const& subject_automaton);
+
+ template <typename SubjectAutomaton, typename Input>
+ void
+ process(SubjectAutomaton const& subject_automaton, Input const& i);
+
+ void output();
+
+ template <typename SubjectAutomaton>
+ struct apply
+ {
+ typedef output_observer<dfa_insertion_policy,SubjectAutomaton>
+ type;
+ };
+ };
+
+ //<-
+ template <
+ typename InsertionTarget
+ , typename NontrivialInput
+ , typename CharT
+ >
+ dfa_insertion_policy<
+ InsertionTarget
+ , NontrivialInput
+ , CharT
+ >::dfa_insertion_policy(
+ InsertionTarget& target
+ , CharT const* format_string
+ , CharT element_delimiter
+ ) : _target(target)
+ , _format_string(format_string)
+ , _element_delimiter(element_delimiter)
+ {
+ _format_string.exceptions(
+ ::boost::io::all_error_bits ^ ::boost::io::too_few_args_bit
+ );
+ }
+
+ template <
+ typename InsertionTarget
+ , typename NontrivialInput
+ , typename CharT
+ >
+ dfa_insertion_policy<
+ InsertionTarget
+ , NontrivialInput
+ , CharT
+ >::dfa_insertion_policy(dfa_insertion_policy const& copy)
+ : _target(copy._target)
+ , _format_string(copy._format_string)
+ , _element_delimiter(copy._element_delimiter)
+ {
+ }
+
+ template <
+ typename InsertionTarget
+ , typename NontrivialInput
+ , typename CharT
+ >
+ template <typename String>
+ inline void
+ dfa_insertion_policy<
+ InsertionTarget
+ , NontrivialInput
+ , CharT
+ >::process_string(String const& string)
+ {
+ _format_string % string;
+ }
+
+ template <
+ typename InsertionTarget
+ , typename NontrivialInput
+ , typename CharT
+ >
+ template <typename SubjectAutomaton>
+ void
+ dfa_insertion_policy<
+ InsertionTarget
+ , NontrivialInput
+ , CharT
+ >::process(SubjectAutomaton const& subject_automaton)
+ {
+ _format_string % subject_automaton.get_current_state();
+
+ typedef ::std::vector<NontrivialInput> Inputs;
+
+ Inputs inputs;
+ subject_automaton.make_nontrivial_inputs(::std::back_inserter(inputs));
+
+ ::std::basic_ostringstream<CharT> container_stream;
+ typename Inputs::const_iterator i_i = inputs.begin();
+ typename Inputs::const_iterator i_end = inputs.end();
+
+ if (i_i != i_end)
+ {
+ for (;;)
+ {
+ container_stream << *i_i;
+
+ if (++i_i == i_end)
+ {
+ break;
+ }
+ else
+ {
+ container_stream << _element_delimiter;
+ }
+ }
+ }
+
+ _format_string % container_stream.str().c_str();
+ }
+
+ template <
+ typename InsertionTarget
+ , typename NontrivialInput
+ , typename CharT
+ >
+ template <typename SubjectAutomaton, typename Input>
+ inline void
+ dfa_insertion_policy<
+ InsertionTarget
+ , NontrivialInput
+ , CharT
+ >::process(SubjectAutomaton const& subject_automaton, Input const& i)
+ {
+ this->process(subject_automaton);
+ _format_string % i;
+ }
+
+ template <
+ typename InsertionTarget
+ , typename NontrivialInput
+ , typename CharT
+ >
+ inline void
+ dfa_insertion_policy<InsertionTarget,NontrivialInput,CharT>::output()
+ {
+ _target << _format_string << ::std::endl;
+ _format_string.clear_binds();
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_POLICY_DFA_INSERTION_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/policy/dpda_insertion.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/policy/dpda_insertion.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,217 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_POLICY_DPDA_INSERTION_HPP_INCLUDED
+#define BOOST_AUTOMATA_POLICY_DPDA_INSERTION_HPP_INCLUDED
+
+#include <vector>
+#include <iterator>
+#include <iosfwd>
+#include <sstream>
+#include <boost/format.hpp>
+#include <boost/automata/observer/output.hpp>
+
+//[reference__dpda_insertion_policy
+namespace boost { namespace automata {
+
+ template <
+ typename InsertionTarget
+ , typename NontrivialInput
+ , typename CharT = char
+ >
+ class dpda_insertion_policy
+ {
+ //<-
+ InsertionTarget& _target;
+ basic_format<CharT> _format_string;
+ CharT _element_delimiter;
+ //->
+
+ public:
+ dpda_insertion_policy(
+ InsertionTarget& target
+ , CharT const* format_string
+ , CharT element_delimiter
+ );
+
+ dpda_insertion_policy(dpda_insertion_policy const& copy);
+
+ template <typename String>
+ void process_string(String const& string);
+
+ template <typename SubjectAutomaton>
+ void process(SubjectAutomaton const& subject_automaton);
+
+ template <typename SubjectAutomaton, typename Input>
+ void
+ process(SubjectAutomaton const& subject_automaton, Input const& i);
+
+ void output();
+
+ template <typename SubjectAutomaton>
+ struct apply
+ {
+ typedef output_observer<dpda_insertion_policy,SubjectAutomaton>
+ type;
+ };
+ };
+
+ //<-
+ template <
+ typename InsertionTarget
+ , typename NontrivialInput
+ , typename CharT
+ >
+ dpda_insertion_policy<
+ InsertionTarget
+ , NontrivialInput
+ , CharT
+ >::dpda_insertion_policy(
+ InsertionTarget& target
+ , CharT const* format_string
+ , CharT element_delimiter
+ ) : _target(target)
+ , _format_string(format_string)
+ , _element_delimiter(element_delimiter)
+ {
+ _format_string.exceptions(
+ ::boost::io::all_error_bits ^ ::boost::io::too_few_args_bit
+ );
+ }
+
+ template <
+ typename InsertionTarget
+ , typename NontrivialInput
+ , typename CharT
+ >
+ dpda_insertion_policy<
+ InsertionTarget
+ , NontrivialInput
+ , CharT
+ >::dpda_insertion_policy(dpda_insertion_policy const& copy)
+ : _target(copy._target)
+ , _format_string(copy._format_string)
+ , _element_delimiter(copy._element_delimiter)
+ {
+ }
+
+ template <
+ typename InsertionTarget
+ , typename NontrivialInput
+ , typename CharT
+ >
+ template <typename String>
+ inline void
+ dpda_insertion_policy<
+ InsertionTarget
+ , NontrivialInput
+ , CharT
+ >::process_string(String const& string)
+ {
+ _format_string % string;
+ }
+
+ template <
+ typename InsertionTarget
+ , typename NontrivialInput
+ , typename CharT
+ >
+ template <typename SubjectAutomaton>
+ void
+ dpda_insertion_policy<
+ InsertionTarget
+ , NontrivialInput
+ , CharT
+ >::process(SubjectAutomaton const& subject_automaton)
+ {
+ _format_string % subject_automaton.get_current_state();
+
+ ::std::basic_ostringstream<CharT> stack_stream;
+ typename SubjectAutomaton::traits::stack_iterator
+ s_i = subject_automaton.get_stack_begin()
+ , s_end = subject_automaton.get_stack_end();
+
+ if (s_i != s_end)
+ {
+ for (;;)
+ {
+ stack_stream << *s_i;
+
+ if (++s_i == s_end)
+ {
+ break;
+ }
+ else
+ {
+ stack_stream << _element_delimiter;
+ }
+ }
+ }
+
+ _format_string % stack_stream.str().c_str();
+
+ typedef ::std::vector<NontrivialInput> Inputs;
+
+ ::std::basic_ostringstream<CharT> inputs_stream;
+ Inputs inputs;
+ subject_automaton.make_nontrivial_inputs(::std::back_inserter(inputs));
+
+ typename Inputs::const_iterator i_i = inputs.begin();
+ typename Inputs::const_iterator i_end = inputs.end();
+
+ if (i_i != i_end)
+ {
+ for (;;)
+ {
+ inputs_stream << *i_i;
+
+ if (++i_i == i_end)
+ {
+ break;
+ }
+ else
+ {
+ inputs_stream << _element_delimiter;
+ }
+ }
+ }
+
+ _format_string % inputs_stream.str().c_str();
+ }
+
+ template <
+ typename InsertionTarget
+ , typename NontrivialInput
+ , typename CharT
+ >
+ template <typename SubjectAutomaton, typename Input>
+ inline void
+ dpda_insertion_policy<
+ InsertionTarget
+ , NontrivialInput
+ , CharT
+ >::process(SubjectAutomaton const& subject_automaton, Input const& i)
+ {
+ this->process(subject_automaton);
+ _format_string % i;
+ }
+
+ template <
+ typename InsertionTarget
+ , typename NontrivialInput
+ , typename CharT
+ >
+ inline void
+ dpda_insertion_policy<InsertionTarget,NontrivialInput,CharT>::output()
+ {
+ _target << _format_string << ::std::endl;
+ _format_string.clear_binds();
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_POLICY_DPDA_INSERTION_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/policy/input_validation.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/policy/input_validation.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,197 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_POLICY_INPUT_VALIDATION_HPP_INCLUDED
+#define BOOST_AUTOMATA_POLICY_INPUT_VALIDATION_HPP_INCLUDED
+
+//[reference__input_validation_policy
+namespace boost { namespace automata {
+
+ template <typename Exception = void>
+ struct input_validation_policy
+ {
+ template <typename SubjectAutomaton>
+ struct apply
+ {
+ class type
+ {
+ //<-
+ SubjectAutomaton const& _subject_automaton;
+ //->
+
+ public:
+ type(
+ input_validation_policy<Exception> const& policy
+ , SubjectAutomaton const& automaton
+ );
+
+ type(type const& copy, SubjectAutomaton const& automaton);
+
+ type(type const& copy);
+
+ type& operator=(type const& copy);
+
+ void on_construction();
+
+ template <typename Builder, typename Tag>
+ void on_construction(Builder const& builder, Tag);
+
+ template <typename Builder, typename Tag>
+ void on_initialize(Builder const& builder, Tag);
+
+ template <typename Input>
+ bool operator()(Input const& i);
+ };
+ };
+ };
+
+ //<-
+ template <typename Exception>
+ template <typename SubjectAutomaton>
+ input_validation_policy<Exception>::apply<SubjectAutomaton>::type::type(
+ input_validation_policy<Exception> const& policy
+ , SubjectAutomaton const& automaton
+ ) : _subject_automaton(automaton)
+ {
+ }
+
+ template <typename Exception>
+ template <typename SubjectAutomaton>
+ input_validation_policy<Exception>::apply<SubjectAutomaton>::type::type(
+ type const& copy
+ , SubjectAutomaton const& automaton
+ ) : _subject_automaton(automaton)
+ {
+ }
+
+ template <typename Exception>
+ template <typename SubjectAutomaton>
+ input_validation_policy<Exception>::apply<SubjectAutomaton>::type::type(
+ type const& copy
+ ) : _subject_automaton(copy._subject_automaton)
+ {
+ }
+
+ template <typename Exception>
+ template <typename SubjectAutomaton>
+ inline typename input_validation_policy<
+ Exception
+ >::BOOST_NESTED_TEMPLATE apply<SubjectAutomaton>::type&
+ input_validation_policy<Exception>::apply<
+ SubjectAutomaton
+ >::type::operator=(type const& copy)
+ {
+ return *this;
+ }
+
+ template <typename Exception>
+ template <typename SubjectAutomaton>
+ inline void
+ input_validation_policy<Exception>::apply<
+ SubjectAutomaton
+ >::type::on_construction()
+ {
+ }
+
+ template <typename Exception>
+ template <typename SubjectAutomaton>
+ template <typename Builder, typename Tag>
+ inline void
+ input_validation_policy<Exception>::apply<
+ SubjectAutomaton
+ >::type::on_construction(Builder const& builder, Tag)
+ {
+ }
+
+ template <typename Exception>
+ template <typename SubjectAutomaton>
+ template <typename Builder, typename Tag>
+ inline void
+ input_validation_policy<Exception>::apply<
+ SubjectAutomaton
+ >::type::on_initialize(Builder const& builder, Tag)
+ {
+ }
+
+ template <typename Exception>
+ template <typename SubjectAutomaton>
+ template <typename Input>
+ inline bool
+ input_validation_policy<Exception>::apply<
+ SubjectAutomaton
+ >::type::operator()(Input const& i)
+ {
+ if (!_subject_automaton.get_transition_function().recognizes_input(i))
+ {
+ throw Exception(i);
+ }
+
+ return true;
+ }
+ //->
+
+ template <>
+ struct input_validation_policy<void>
+ {
+ template <typename SubjectAutomaton>
+ struct apply
+ {
+ class type
+ {
+ SubjectAutomaton const& _subject_automaton;
+
+ public:
+ type(
+ input_validation_policy<void> const& policy
+ , SubjectAutomaton const& automaton
+ ) : _subject_automaton(automaton)
+ {
+ }
+
+ type(type const& copy, SubjectAutomaton const& automaton)
+ : _subject_automaton(automaton)
+ {
+ }
+
+ type(type const& copy)
+ : _subject_automaton(copy._subject_automaton)
+ {
+ }
+
+ inline type& operator=(type const& copy)
+ {
+ return *this;
+ }
+
+ inline void on_construction()
+ {
+ }
+
+ template <typename Builder, typename Tag>
+ inline void on_construction(Builder const& builder, Tag)
+ {
+ }
+
+ template <typename Builder, typename Tag>
+ inline void on_initialize(Builder const& builder, Tag)
+ {
+ }
+
+ template <typename Input>
+ inline bool operator()(Input const& i)
+ {
+ return
+ _subject_automaton
+ .get_transition_function()
+ .recognizes_input(i);
+ }
+ };
+ };
+ };
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_POLICY_INPUT_VALIDATION_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/policy/mdp_best_input.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/policy/mdp_best_input.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,385 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_POLICY_MDP_BEST_INPUT_HPP_INCLUDED
+#define BOOST_AUTOMATA_POLICY_MDP_BEST_INPUT_HPP_INCLUDED
+
+#include <iterator>
+#include <vector>
+#include <boost/config.hpp>
+#include <boost/utility/value_init.hpp>
+#include <boost/function.hpp>
+#include <boost/automata/tags/builder.hpp>
+#include <boost/automata/observer/base.hpp>
+
+//[reference__mdp_best_input_policy
+namespace boost { namespace automata {
+
+ template <typename Input, typename RealNumber = double>
+ class mdp_best_input_policy
+ {
+ //<-
+ ::boost::function3<
+ RealNumber
+ , ::std::size_t
+ , Input const&
+ , ::std::size_t
+ > _reward;
+ RealNumber _discount_rate;
+ //->
+
+ public:
+ template <typename Function>
+ mdp_best_input_policy(
+ Function function
+ , RealNumber const& discount_rate = RealNumber()
+ );
+
+ mdp_best_input_policy(mdp_best_input_policy const& copy);
+
+ template <typename SubjectAutomaton>
+ struct apply
+ {
+ class type : public base_observer<SubjectAutomaton>
+ {
+ //<-
+ mdp_best_input_policy _policy;
+ ::std::vector<Input> _best_inputs;
+ //->
+
+ public:
+ type(
+ mdp_best_input_policy const& policy
+ , SubjectAutomaton const& automaton
+ )
+ //<-
+ : base_observer<SubjectAutomaton>(automaton)
+ , _policy(policy)
+ , _best_inputs()
+ {
+ }
+ //->
+ ;
+
+ type(
+ type const& copy
+ , SubjectAutomaton const& automaton
+ )
+ //<-
+ : base_observer<SubjectAutomaton>(automaton)
+ , _policy(copy._policy)
+ , _best_inputs(copy._best_inputs)
+ {
+ }
+ //->
+ ;
+
+ type(type const& copy)
+ //<-
+ : base_observer<SubjectAutomaton>(
+ copy.get_subject_automaton()
+ )
+ , _policy(copy._policy)
+ , _best_inputs(copy._best_inputs)
+ {
+ }
+ //->
+ ;
+
+ type& operator=(type const& copy)
+ //<-
+ {
+ return *this;
+ }
+ //->
+ ;
+
+ //<-
+ inline
+ //->
+ Input const& get_current_best() const
+ //<-
+ {
+ return _best_inputs[
+ this->get_subject_automaton().get_current_state()
+ ];
+ }
+ //->
+ ;
+
+ template <typename Builder>
+ //<-
+ inline
+ //->
+ void
+ on_construction(
+ Builder const& builder
+ , function_setter_tag
+ )
+ //<-
+ {
+ _precompute();
+ }
+ //->
+ ;
+
+ template <typename Builder>
+ //<-
+ inline
+ //->
+ void
+ on_construction(
+ Builder const& builder
+ , function_builder_tag
+ )
+ //<-
+ {
+ _precompute();
+ }
+ //->
+ ;
+
+ template <typename Builder>
+ //<-
+ inline
+ //->
+ void
+ on_construction(
+ Builder const& builder
+ , state_and_function_builder_tag
+ )
+ //<-
+ {
+ _precompute();
+ }
+ //->
+ ;
+
+ template <typename Builder>
+ //<-
+ inline
+ //->
+ void
+ on_initialize(
+ Builder const& builder
+ , function_setter_tag
+ )
+ //<-
+ {
+ _precompute();
+ }
+ //->
+ ;
+
+ template <typename Builder>
+ //<-
+ inline
+ //->
+ void
+ on_initialize(
+ Builder const& builder
+ , function_builder_tag
+ )
+ //<-
+ {
+ _precompute();
+ }
+ //->
+ ;
+
+ template <typename Builder>
+ //<-
+ inline
+ //->
+ void
+ on_initialize(
+ Builder const& builder
+ , state_and_function_builder_tag
+ )
+ //<-
+ {
+ _precompute();
+ }
+ //->
+ ;
+
+ //<-
+ private:
+ void _precompute();
+ //->
+ };
+ };
+ };
+
+ //<-
+ template <typename Input, typename RealNumber>
+ template <typename Function>
+ mdp_best_input_policy<Input,RealNumber>::mdp_best_input_policy(
+ Function function
+ , RealNumber const& discount_rate
+ ) : _reward(function), _discount_rate(discount_rate)
+ {
+ }
+
+ template <typename Input, typename RealNumber>
+ mdp_best_input_policy<Input,RealNumber>::mdp_best_input_policy(
+ mdp_best_input_policy const& copy
+ ) : _reward(copy._reward), _discount_rate(copy._discount_rate)
+ {
+ }
+
+ template <typename Input, typename RealNumber>
+ template <typename SubjectAutomaton>
+ void
+ mdp_best_input_policy<Input,RealNumber>::apply<
+ SubjectAutomaton
+ >::type::_precompute()
+ {
+ typename SubjectAutomaton::transition_function const&
+ f = this->get_subject_automaton().get_transition_function();
+ ::std::size_t const state_count = f.get_state_count();
+ Input const zero_input = initialized_value;
+
+ ::std::vector<Input> inputs;
+
+ _best_inputs.resize(state_count, zero_input);
+
+ for (::std::size_t s = 0; s < state_count; ++s)
+ {
+ inputs.clear();
+ f.make_nontrivial_inputs(s, ::std::back_inserter(inputs));
+
+ if (!inputs.empty())
+ {
+ RealNumber max_sum = initialized_value;
+
+ for (::std::size_t i = 0; i < inputs.size(); ++i)
+ {
+ Input const& input = inputs[i];
+
+ RealNumber sum = initialized_value;
+
+ for (
+ ::std::size_t s_tick = 0;
+ s_tick < state_count;
+ ++s_tick
+ )
+ {
+ sum
+ += _policy._reward(s, input, s_tick)
+ * f.get_probability(s, input, s_tick);
+ }
+
+ if (max_sum < sum)
+ {
+ _best_inputs[s] = input;
+ max_sum = sum;
+ }
+ }
+ }
+ }
+
+ RealNumber const& discount_rate = _policy._discount_rate;
+
+ ::std::vector<RealNumber> values(state_count);
+ bool is_not_done;
+
+ do
+ {
+ for (;;)
+ {
+ ::std::vector<RealNumber> new_values(state_count);
+ bool has_converged = true;
+
+ for (::std::size_t s = 0; s < state_count; ++s)
+ {
+ Input const& input = _best_inputs[s];
+
+ new_values[s] = initialized_value;
+
+ for (
+ ::std::size_t s_tick = 0;
+ s_tick < state_count;
+ ++s_tick
+ )
+ {
+ new_values[s] += (
+ values[s_tick] * discount_rate
+ + _policy._reward(s, input, s_tick)
+ ) * f.get_probability(s, input, s_tick);
+ }
+
+ if (
+ (new_values[s] < values[s])
+ || (values[s] < new_values[s])
+ )
+ {
+ has_converged = false;
+ }
+ }
+
+ if (has_converged)
+ {
+ break;
+ }
+ else
+ {
+ values = new_values;
+ }
+ }
+
+ is_not_done = false;
+
+ for (::std::size_t s = 0; s < state_count; ++s)
+ {
+ inputs.clear();
+ f.make_nontrivial_inputs(s, ::std::back_inserter(inputs));
+
+ if (!inputs.empty())
+ {
+ Input best_input = inputs[0];
+ RealNumber max_sum = initialized_value;
+
+ for (::std::size_t i = 0; i < inputs.size(); ++i)
+ {
+ Input const& input = inputs[i];
+
+ RealNumber sum = initialized_value;
+
+ for (
+ ::std::size_t s_tick = 0;
+ s_tick < state_count;
+ ++s_tick
+ )
+ {
+ sum += (
+ values[s_tick] * discount_rate
+ + _policy._reward(s, input, s_tick)
+ ) * f.get_probability(s, input, s_tick);
+ }
+
+ if (max_sum < sum)
+ {
+ best_input = inputs[i];
+ max_sum = sum;
+ }
+ }
+
+ if (best_input != _best_inputs[s])
+ {
+ is_not_done = true;
+ _best_inputs[s] = best_input;
+ }
+ }
+ }
+ }
+ while (is_not_done);
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_POLICY_MDP_BEST_INPUT_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/policy/mealy_output.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/policy/mealy_output.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,109 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_POLICY_MEALY_OUTPUT_HPP_INCLUDED
+#define BOOST_AUTOMATA_POLICY_MEALY_OUTPUT_HPP_INCLUDED
+
+#include <vector>
+#include <iterator>
+#include <iosfwd>
+#include <sstream>
+#include <boost/format.hpp>
+#include <boost/automata/observer/output.hpp>
+
+//[reference__mealy_output_policy
+namespace boost { namespace automata {
+
+ template <typename Functor>
+ class mealy_output_policy
+ {
+ //<-
+ Functor _output;
+ //->
+
+ public:
+ mealy_output_policy();
+
+ template <typename Function>
+ mealy_output_policy(Function output);
+
+ mealy_output_policy(mealy_output_policy const& copy);
+
+ template <typename String>
+ void process_string(String const& string);
+
+ template <typename SubjectAutomaton>
+ void process(SubjectAutomaton const& subject_automaton);
+
+ template <typename SubjectAutomaton, typename Input>
+ void
+ process(SubjectAutomaton const& subject_automaton, Input const& i);
+
+ void output();
+
+ template <typename SubjectAutomaton>
+ struct apply
+ {
+ typedef output_observer<mealy_output_policy,SubjectAutomaton> type;
+ };
+ };
+
+ //<-
+ template <typename Functor>
+ mealy_output_policy<Functor>::mealy_output_policy() : _output()
+ {
+ }
+
+ template <typename Functor>
+ template <typename Function>
+ mealy_output_policy<Functor>::mealy_output_policy(Function output)
+ : _output(output)
+ {
+ }
+
+ template <typename Functor>
+ mealy_output_policy<Functor>::mealy_output_policy(
+ mealy_output_policy const& copy
+ ) : _output(copy._output)
+ {
+ }
+
+ template <typename Functor>
+ template <typename String>
+ inline void
+ mealy_output_policy<Functor>::process_string(String const& string)
+ {
+ }
+
+ template <typename Functor>
+ template <typename SubjectAutomaton>
+ inline void
+ mealy_output_policy<Functor>::process(
+ SubjectAutomaton const& subject_automaton
+ )
+ {
+ }
+
+ template <typename Functor>
+ template <typename SubjectAutomaton, typename Input>
+ inline void
+ mealy_output_policy<Functor>::process(
+ SubjectAutomaton const& subject_automaton
+ , Input const& i
+ )
+ {
+ _output(subject_automaton, i);
+ }
+
+ template <typename Functor>
+ inline void mealy_output_policy<Functor>::output()
+ {
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_POLICY_MEALY_OUTPUT_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/policy/moore_output.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/policy/moore_output.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,110 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_POLICY_MOORE_OUTPUT_HPP_INCLUDED
+#define BOOST_AUTOMATA_POLICY_MOORE_OUTPUT_HPP_INCLUDED
+
+#include <vector>
+#include <iterator>
+#include <iosfwd>
+#include <sstream>
+#include <boost/format.hpp>
+#include <boost/automata/observer/output.hpp>
+
+//[reference__moore_output_policy
+namespace boost { namespace automata {
+
+ template <typename Functor>
+ class moore_output_policy
+ {
+ //<-
+ Functor _output;
+ //->
+
+ public:
+ moore_output_policy();
+
+ template <typename Function>
+ moore_output_policy(Function output);
+
+ moore_output_policy(moore_output_policy const& copy);
+
+ template <typename String>
+ void process_string(String const& string);
+
+ template <typename SubjectAutomaton>
+ void process(SubjectAutomaton const& subject_automaton);
+
+ template <typename SubjectAutomaton, typename Input>
+ void
+ process(SubjectAutomaton const& subject_automaton, Input const& i);
+
+ void output();
+
+ template <typename SubjectAutomaton>
+ struct apply
+ {
+ typedef output_observer<moore_output_policy,SubjectAutomaton> type;
+ };
+ };
+
+ //<-
+ template <typename Functor>
+ moore_output_policy<Functor>::moore_output_policy() : _output()
+ {
+ }
+
+ template <typename Functor>
+ template <typename Function>
+ moore_output_policy<Functor>::moore_output_policy(Function output)
+ : _output(output)
+ {
+ }
+
+ template <typename Functor>
+ moore_output_policy<Functor>::moore_output_policy(
+ moore_output_policy const& copy
+ ) : _output(copy._output)
+ {
+ }
+
+ template <typename Functor>
+ template <typename String>
+ inline void
+ moore_output_policy<Functor>::process_string(String const& string)
+ {
+ }
+
+ template <typename Functor>
+ template <typename SubjectAutomaton>
+ inline void
+ moore_output_policy<Functor>::process(
+ SubjectAutomaton const& subject_automaton
+ )
+ {
+ _output(subject_automaton);
+ }
+
+ template <typename Functor>
+ template <typename SubjectAutomaton, typename Input>
+ inline void
+ moore_output_policy<Functor>::process(
+ SubjectAutomaton const& subject_automaton
+ , Input const& i
+ )
+ {
+ _output(subject_automaton);
+ }
+
+ template <typename Functor>
+ inline void moore_output_policy<Functor>::output()
+ {
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_POLICY_MOORE_OUTPUT_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/policy/parallel_final_states.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/policy/parallel_final_states.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,209 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_POLICY_PARALLEL_FINAL_STATES_HPP_INCLUDED
+#define BOOST_AUTOMATA_POLICY_PARALLEL_FINAL_STATES_HPP_INCLUDED
+
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/utility/associative_container_gen.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/keys/observer.hpp>
+#include <boost/automata/observer/full_noop.hpp>
+
+//[reference__has_visited_any_state
+namespace boost { namespace automata {
+
+ template <
+ typename States
+ , typename SubjectAutomaton
+ , typename TransitionFunctionTag
+ >
+ bool
+ has_visited_any_state(
+ States const& states
+ , SubjectAutomaton const& subject_automaton
+ , TransitionFunctionTag
+ );
+
+ //<-
+ template <
+ typename States
+ , typename SubjectAutomaton
+ , typename TransitionFunctionTag
+ >
+ inline bool
+ has_visited_any_state(
+ States const& states
+ , SubjectAutomaton const& subject_automaton
+ , TransitionFunctionTag
+ )
+ {
+ return states.find(
+ subject_automaton.get_current_state()
+ ) != states.end();
+ }
+
+ template <typename States, typename SubjectAutomaton>
+ inline bool
+ has_visited_any_state(
+ States const& states
+ , SubjectAutomaton const& subject_automaton
+ , dpda_transition_function_tag
+ )
+ {
+ return subject_automaton.has_empty_stack() && (
+ states.find(subject_automaton.get_current_state()) != states.end()
+ );
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+//[reference__parallel_final_states_policy
+namespace boost { namespace automata {
+
+ template <
+ unsigned long Uid = 0UL
+ , typename AssociativeContainerSelector = ::boost::setS
+ >
+ struct parallel_final_states_policy
+ {
+ template <typename SubjectAutomaton>
+ struct apply
+ {
+ class type : public full_noop_observer<SubjectAutomaton>
+ {
+ //<-
+ typedef typename ::boost::mpl::apply_wrap1<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , typename SubjectAutomaton::state
+ >::type
+ States;
+
+ States _states;
+ //->
+
+ public:
+ type(
+ parallel_final_states_policy const& policy
+ , SubjectAutomaton const& automaton
+ );
+
+ type(type const& copy, SubjectAutomaton const& automaton);
+
+ type(type const& copy);
+
+ type& operator=(type const& copy);
+
+ template <typename Builder, typename Tag>
+ void on_construction(Builder const& builder, Tag);
+
+ template <typename Builder, typename Tag>
+ void on_initialize(Builder const& builder, Tag);
+
+ operator bool() const;
+ };
+ };
+ };
+
+ //<-
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ parallel_final_states_policy<Uid,AssociativeContainerSelector>::apply<
+ SubjectAutomaton
+ >::type::type(
+ parallel_final_states_policy const& policy
+ , SubjectAutomaton const& automaton
+ ) : full_noop_observer<SubjectAutomaton>(automaton), _states()
+ {
+ }
+
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ parallel_final_states_policy<Uid,AssociativeContainerSelector>::apply<
+ SubjectAutomaton
+ >::type::type(type const& copy, SubjectAutomaton const& automaton)
+ : full_noop_observer<SubjectAutomaton>(automaton), _states(copy._states)
+ {
+ }
+
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ parallel_final_states_policy<Uid,AssociativeContainerSelector>::apply<
+ SubjectAutomaton
+ >::type::type(type const& copy)
+ : full_noop_observer<SubjectAutomaton>(copy.get_subject_automaton())
+ , _states(copy._states)
+ {
+ }
+
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ inline typename parallel_final_states_policy<
+ Uid
+ , AssociativeContainerSelector
+ >::BOOST_NESTED_TEMPLATE apply<SubjectAutomaton>::type&
+ parallel_final_states_policy<Uid,AssociativeContainerSelector>::apply<
+ SubjectAutomaton
+ >::type::operator=(type const& copy)
+ {
+ if (this != &copy)
+ {
+ _states = copy._states;
+ }
+
+ return *this;
+ }
+
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ template <typename Builder, typename Tag>
+ inline void
+ parallel_final_states_policy<Uid,AssociativeContainerSelector>::apply<
+ SubjectAutomaton
+ >::type::on_construction(Builder const& builder, Tag)
+ {
+ _states.clear();
+ ::boost::fusion::at_key<multiple_final_states_key<Uid> >(
+ builder.get_observer_builder_map()
+ ).make_final_states(_states);
+ }
+
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ template <typename Builder, typename Tag>
+ inline void
+ parallel_final_states_policy<Uid,AssociativeContainerSelector>::apply<
+ SubjectAutomaton
+ >::type::on_initialize(Builder const& builder, Tag)
+ {
+ _states.clear();
+ ::boost::fusion::at_key<multiple_final_states_key<Uid> >(
+ builder.get_observer_builder_map()
+ ).make_final_states(_states);
+ }
+
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ inline parallel_final_states_policy<
+ Uid
+ , AssociativeContainerSelector
+ >::apply<SubjectAutomaton>::type::operator bool() const
+ {
+ return has_visited_any_state(
+ _states
+ , this->get_subject_automaton()
+ , typename SubjectAutomaton::transition_function::tag()
+ );
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_POLICY_PARALLEL_FINAL_STATES_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/policy/serial_final_states.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/policy/serial_final_states.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,257 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_POLICY_SERIAL_FINAL_STATES_HPP_INCLUDED
+#define BOOST_AUTOMATA_POLICY_SERIAL_FINAL_STATES_HPP_INCLUDED
+
+#include <iterator>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/range.hpp>
+#include <boost/utility/associative_container_gen.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/keys/observer.hpp>
+#include <boost/automata/observer/full_noop.hpp>
+
+//[reference__has_no_unvisited_states
+namespace boost { namespace automata {
+
+ template <
+ typename States
+ , typename SubjectAutomaton
+ , typename TransitionFunctionTag
+ >
+ bool
+ has_no_unvisited_states(
+ States const& unvisited_states
+ , SubjectAutomaton const& subject_automaton
+ , TransitionFunctionTag
+ );
+
+ //<-
+ template <
+ typename States
+ , typename SubjectAutomaton
+ , typename TransitionFunctionTag
+ >
+ inline bool
+ has_no_unvisited_states(
+ States const& unvisited_states
+ , SubjectAutomaton const& subject_automaton
+ , TransitionFunctionTag
+ )
+ {
+ return unvisited_states.empty();
+ }
+
+ template <typename States, typename SubjectAutomaton>
+ inline bool
+ has_no_unvisited_states(
+ States const& unvisited_states
+ , SubjectAutomaton const& subject_automaton
+ , dpda_transition_function_tag
+ )
+ {
+ return subject_automaton.has_empty_stack() && unvisited_states.empty();
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+//[reference__serial_final_states_policy
+namespace boost { namespace automata {
+
+ template <
+ unsigned long Uid = 0UL
+ , typename AssociativeContainerSelector = ::boost::setS
+ >
+ struct serial_final_states_policy
+ {
+ template <typename SubjectAutomaton>
+ struct apply
+ {
+ class type : public full_noop_observer<SubjectAutomaton>
+ {
+ //<-
+ typedef typename ::boost::mpl::apply_wrap1<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , typename SubjectAutomaton::state
+ >::type
+ States;
+
+ States _final_states;
+ States _states;
+ //->
+
+ public:
+ type(
+ serial_final_states_policy const& policy
+ , SubjectAutomaton const& automaton
+ );
+
+ type(type const& copy, SubjectAutomaton const& automaton);
+
+ type(type const& copy);
+
+ type& operator=(type const& copy);
+
+ template <typename Builder, typename Tag>
+ void on_construction(Builder const& builder, Tag);
+
+ template <typename Builder, typename Tag>
+ void on_initialize(Builder const& builder, Tag);
+
+ void on_reset();
+
+ template <typename Input>
+ void on_accept_input(Input const& i);
+
+ operator bool() const;
+ };
+ };
+ };
+
+ //<-
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ serial_final_states_policy<Uid,AssociativeContainerSelector>::apply<
+ SubjectAutomaton
+ >::type::type(
+ serial_final_states_policy const& policy
+ , SubjectAutomaton const& automaton
+ ) : full_noop_observer<SubjectAutomaton>(automaton)
+ , _final_states()
+ , _states()
+ {
+ }
+
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ serial_final_states_policy<Uid,AssociativeContainerSelector>::apply<
+ SubjectAutomaton
+ >::type::type(type const& copy, SubjectAutomaton const& automaton)
+ : full_noop_observer<SubjectAutomaton>(automaton)
+ , _final_states(copy._final_states)
+ , _states(copy._states)
+ {
+ }
+
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ serial_final_states_policy<Uid,AssociativeContainerSelector>::apply<
+ SubjectAutomaton
+ >::type::type(type const& copy)
+ : full_noop_observer<SubjectAutomaton>(copy.get_subject_automaton())
+ , _final_states(copy._final_states)
+ , _states(copy._states)
+ {
+ }
+
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ inline typename serial_final_states_policy<
+ Uid
+ , AssociativeContainerSelector
+ >::BOOST_NESTED_TEMPLATE apply<SubjectAutomaton>::type&
+ serial_final_states_policy<Uid,AssociativeContainerSelector>::apply<
+ SubjectAutomaton
+ >::type::operator=(type const& copy)
+ {
+ if (this != &copy)
+ {
+ _final_states = copy._final_states;
+ _states = copy._states;
+ }
+
+ return *this;
+ }
+
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ template <typename Builder, typename Tag>
+ inline void
+ serial_final_states_policy<Uid,AssociativeContainerSelector>::apply<
+ SubjectAutomaton
+ >::type::on_construction(Builder const& builder, Tag)
+ {
+ _final_states.clear();
+ ::boost::fusion::at_key<multiple_final_states_key<Uid> >(
+ builder.get_observer_builder_map()
+ ).make_final_states(_final_states);
+ }
+
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ template <typename Builder, typename Tag>
+ inline void
+ serial_final_states_policy<Uid,AssociativeContainerSelector>::apply<
+ SubjectAutomaton
+ >::type::on_initialize(Builder const& builder, Tag)
+ {
+ _final_states.clear();
+ ::boost::fusion::at_key<multiple_final_states_key<Uid> >(
+ builder.get_observer_builder_map()
+ ).make_final_states(_final_states);
+ }
+
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ void
+ serial_final_states_policy<Uid,AssociativeContainerSelector>::apply<
+ SubjectAutomaton
+ >::type::on_reset()
+ {
+ _states.clear();
+ ::std::insert_iterator<States> inserter(_states, begin(_states));
+ typename range_const_iterator<States>::type s_end = end(
+ _final_states
+ );
+
+ for (
+ typename range_const_iterator<States>::type s_i = begin(
+ _final_states
+ );
+ s_i != s_end;
+ ++s_i
+ )
+ {
+ *inserter = *s_i;
+ ++inserter;
+ }
+ }
+
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ template <typename Input>
+ inline void
+ serial_final_states_policy<Uid,AssociativeContainerSelector>::apply<
+ SubjectAutomaton
+ >::type::on_accept_input(Input const& i)
+ {
+ _states.remove(this->get_subject_automaton().get_current_state());
+ }
+
+ template <unsigned long Uid, typename AssociativeContainerSelector>
+ template <typename SubjectAutomaton>
+ inline serial_final_states_policy<
+ Uid
+ , AssociativeContainerSelector
+ >::apply<SubjectAutomaton>::type::operator bool() const
+ {
+ return has_no_unvisited_states(
+ _states
+ , this->get_subject_automaton()
+ , typename SubjectAutomaton::transition_function::tag()
+ );
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_POLICY_SERIAL_FINAL_STATES_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/policy/single_final_state.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/policy/single_final_state.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,181 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_POLICY_SINGLE_FINAL_STATE_HPP_INCLUDED
+#define BOOST_AUTOMATA_POLICY_SINGLE_FINAL_STATE_HPP_INCLUDED
+
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/keys/observer.hpp>
+#include <boost/automata/observer/full_noop.hpp>
+
+//[reference__is_at_final_state
+namespace boost { namespace automata {
+
+ template <typename SubjectAutomaton, typename TransitionFunctionTag>
+ bool
+ is_at_final_state(
+ typename SubjectAutomaton::state const& final_state
+ , SubjectAutomaton const& subject_automaton
+ , TransitionFunctionTag
+ );
+
+ //<-
+ template <typename SubjectAutomaton, typename TransitionFunctionTag>
+ inline bool
+ is_at_final_state(
+ typename SubjectAutomaton::state const& final_state
+ , SubjectAutomaton const& subject_automaton
+ , TransitionFunctionTag
+ )
+ {
+ return final_state == subject_automaton.get_current_state();
+ }
+
+ template <typename SubjectAutomaton>
+ inline bool
+ is_at_final_state(
+ typename SubjectAutomaton::state const& final_state
+ , SubjectAutomaton const& subject_automaton
+ , dpda_transition_function_tag
+ )
+ {
+ return subject_automaton.has_empty_stack() && (
+ final_state == subject_automaton.get_current_state()
+ );
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+//[reference__single_final_state_policy
+namespace boost { namespace automata {
+
+ template <unsigned long Uid = 0UL>
+ struct single_final_state_policy
+ {
+ template <typename SubjectAutomaton>
+ struct apply
+ {
+ class type : public full_noop_observer<SubjectAutomaton>
+ {
+ // <-
+ typename SubjectAutomaton::state _final_state;
+ // ->
+
+ public:
+ type(
+ single_final_state_policy const& policy
+ , SubjectAutomaton const& automaton
+ );
+
+ type(type const& copy, SubjectAutomaton const& automaton);
+
+ type(type const& copy);
+
+ type& operator=(type const& copy);
+
+ template <typename Builder, typename Tag>
+ void on_construction(Builder const& builder, Tag);
+
+ template <typename Builder, typename Tag>
+ void on_initialize(Builder const& builder, Tag);
+
+ operator bool() const;
+ };
+ };
+ };
+
+ //<-
+ template <unsigned long Uid>
+ template <typename SubjectAutomaton>
+ single_final_state_policy<Uid>::apply<SubjectAutomaton>::type::type(
+ single_final_state_policy const& policy
+ , SubjectAutomaton const& automaton
+ ) : full_noop_observer<SubjectAutomaton>(automaton)
+ , _final_state()
+ {
+ }
+
+ template <unsigned long Uid>
+ template <typename SubjectAutomaton>
+ single_final_state_policy<Uid>::apply<SubjectAutomaton>::type::type(
+ type const& copy
+ , SubjectAutomaton const& automaton
+ ) : full_noop_observer<SubjectAutomaton>(automaton)
+ , _final_state(copy._final_state)
+ {
+ }
+
+ template <unsigned long Uid>
+ template <typename SubjectAutomaton>
+ single_final_state_policy<Uid>::apply<SubjectAutomaton>::type::type(
+ type const& copy
+ ) : full_noop_observer<SubjectAutomaton>(copy.get_subject_automaton())
+ , _final_state(copy._final_state)
+ {
+ }
+
+ template <unsigned long Uid>
+ template <typename SubjectAutomaton>
+ inline typename single_final_state_policy<
+ Uid
+ >::BOOST_NESTED_TEMPLATE apply<SubjectAutomaton>::type&
+ single_final_state_policy<Uid>::apply<
+ SubjectAutomaton
+ >::type::operator=(type const& copy)
+ {
+ if (this != &copy)
+ {
+ _final_state = copy._final_state;
+ }
+
+ return *this;
+ }
+
+ template <unsigned long Uid>
+ template <typename SubjectAutomaton>
+ template <typename Builder, typename Tag>
+ void
+ single_final_state_policy<Uid>::apply<
+ SubjectAutomaton
+ >::type::on_construction(Builder const& builder, Tag)
+ {
+ _final_state = ::boost::fusion::at_key<single_final_state_key<Uid> >(
+ builder.get_observer_builder_map()
+ ).get_final_state();
+ }
+
+ template <unsigned long Uid>
+ template <typename SubjectAutomaton>
+ template <typename Builder, typename Tag>
+ void
+ single_final_state_policy<Uid>::apply<
+ SubjectAutomaton
+ >::type::on_initialize(Builder const& builder, Tag)
+ {
+ _final_state = ::boost::fusion::at_key<single_final_state_key<Uid> >(
+ builder.get_observer_builder_map()
+ ).get_final_state();
+ }
+
+ template <unsigned long Uid>
+ template <typename SubjectAutomaton>
+ inline single_final_state_policy<Uid>::apply<
+ SubjectAutomaton
+ >::type::operator bool() const
+ {
+ return is_at_final_state(
+ _final_state
+ , this->get_subject_automaton()
+ , typename SubjectAutomaton::transition_function::tag()
+ );
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_POLICY_SINGLE_FINAL_STATE_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/tags/base.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/tags/base.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,27 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_TAGS_BASE_HPP_INCLUDED
+#define BOOST_AUTOMATA_TAGS_BASE_HPP_INCLUDED
+
+namespace boost { namespace automata {
+
+ struct automaton_base_tag
+ {
+ };
+
+ struct discrete_automaton_base_tag
+ : automaton_base_tag
+ {
+ };
+
+ struct input_enumerable_automaton_base_tag
+ : discrete_automaton_base_tag
+ {
+ };
+}} // namespace boost::automata
+
+#endif // BOOST_AUTOMATA_TAGS_BASE_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/tags/builder.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/tags/builder.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,29 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_TAGS_BUILDER_HPP_INCLUDED
+#define BOOST_AUTOMATA_TAGS_BUILDER_HPP_INCLUDED
+
+namespace boost { namespace automata {
+
+ struct function_setter_tag
+ {
+ };
+
+ struct function_builder_tag
+ {
+ };
+
+ struct state_builder_tag
+ {
+ };
+
+ struct state_and_function_builder_tag
+ {
+ };
+}} // namespace boost::automata
+
+#endif // BOOST_AUTOMATA_TAGS_BUILDER_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/tags/transition_function.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/tags/transition_function.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,80 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_TAGS_TRANSITION_FUNCTION_HPP_INCLUDED
+#define BOOST_AUTOMATA_TAGS_TRANSITION_FUNCTION_HPP_INCLUDED
+
+namespace boost { namespace automata {
+
+ struct transition_function_tag
+ {
+ };
+
+ struct combinatorial_transition_function_tag
+ : transition_function_tag
+ {
+ };
+
+ struct constrained_input_transition_function_tag
+ : transition_function_tag
+ {
+ };
+
+ struct constrained_state_transition_function_tag
+ : transition_function_tag
+ {
+ };
+
+ struct state_register_transition_function_tag
+ : constrained_state_transition_function_tag
+ {
+ };
+
+ struct dpda_transition_function_tag
+ : constrained_input_transition_function_tag
+ , state_register_transition_function_tag
+ {
+ };
+
+ struct dfa_transition_function_tag
+ : constrained_input_transition_function_tag
+ , state_register_transition_function_tag
+ {
+ };
+
+ struct mdp_transition_function_tag
+ : constrained_input_transition_function_tag
+ , state_register_transition_function_tag
+ {
+ };
+
+ struct tabular_transition_function_tag
+ : dfa_transition_function_tag
+ {
+ };
+
+ struct mapped_input_tabular_transition_function_tag
+ : dfa_transition_function_tag
+ {
+ };
+
+ struct mapped_input_transition_function_tag
+ : dfa_transition_function_tag
+ {
+ };
+
+ struct next_state_transition_function_tag
+ : dfa_transition_function_tag
+ {
+ };
+
+ struct mdp_mapped_input_transition_function_tag
+ : mdp_transition_function_tag
+ {
+ };
+}} // namespace boost::automata
+
+#endif // BOOST_AUTOMATA_TAGS_TRANSITION_FUNCTION_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/transition_function/adaptor.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/transition_function/adaptor.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,388 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_TRANSITION_FUNCTION_ADAPTOR_HPP_INCLUDED
+#define BOOST_AUTOMATA_TRANSITION_FUNCTION_ADAPTOR_HPP_INCLUDED
+
+#include <boost/tr1/type_traits.hpp>
+#include <boost/tr1/functional.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/detail/metafunction/data_type.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/assert.hpp>
+
+//[reference__adaptor_transition_function
+namespace boost { namespace automata {
+
+ template <typename Function>
+ class adaptor_transition_function;
+
+ template <typename F, typename Arg>
+ class adaptor_transition_function<F(Arg)>
+ {
+ public:
+ typedef combinatorial_transition_function_tag
+ tag;
+ typedef typename ::std::tr1::function<F(Arg)>::result_type
+ result_type;
+ typedef result_type
+ state;
+
+ //<-
+ private:
+ ::std::tr1::function<F(Arg)> _function;
+ ::std::tr1::function<bool(Arg const&)> _input_recognizer;
+
+ public:
+ //->
+ adaptor_transition_function()
+ //<-
+ : _function(), _input_recognizer()
+ {
+ }
+ //->
+ ;
+
+ template <typename Function>
+ adaptor_transition_function(Function function)
+ //<-
+ : _function(function), _input_recognizer()
+ {
+ }
+ //->
+ ;
+
+ adaptor_transition_function(adaptor_transition_function const& copy)
+ //<-
+ : _function(copy._function)
+ , _input_recognizer(copy._input_recognizer)
+ {
+ }
+ //->
+ ;
+
+ //<-
+ inline
+ //->
+ adaptor_transition_function&
+ operator=(adaptor_transition_function const& copy)
+ //<-
+ {
+ if (this != &copy)
+ {
+ _function = copy._function;
+ _input_recognizer = copy._input_recognizer;
+ }
+
+ return *this;
+ }
+ //->
+ ;
+
+ template <typename Input>
+ //<-
+ inline
+ //->
+ bool recognizes_input(Input const& i) const
+ //<-
+ {
+ return _input_recognizer ? _input_recognizer(i) : true;
+ }
+ //->
+ ;
+
+ template <typename Input>
+ //<-
+ inline
+ //->
+ result_type operator()(Input const& i) const
+ //<-
+ {
+ return _function(i);
+ }
+ //->
+ ;
+
+ template <typename InputRecognizer>
+ //<-
+ inline
+ //->
+ void set_input_recognizer(InputRecognizer input_recognizer)
+ //<-
+ {
+ _input_recognizer = input_recognizer;
+ }
+ //->
+ ;
+
+ template <typename F1, typename A1, typename F2, typename A2>
+ //<-
+ inline
+ //->
+ friend bool
+ operator==(
+ adaptor_transition_function<F1(A1)> const& lhs
+ , adaptor_transition_function<F2(A2)> const& rhs
+ )
+ //<-
+ {
+ return lhs._function == rhs._function;
+ }
+ //->
+ ;
+
+ template <typename F1, typename A1, typename F2, typename A2>
+ //<-
+ inline
+ //->
+ friend bool
+ operator!=(
+ adaptor_transition_function<F1(A1)> const& lhs
+ , adaptor_transition_function<F2(A2)> const& rhs
+ )
+ //<-
+ {
+ return lhs._function != rhs._function;
+ }
+ //->
+ ;
+ };
+
+ template <typename F, typename Arg1, typename Arg2>
+ class adaptor_transition_function<F(Arg1,Arg2)>
+ {
+ struct error__state_must_be_convertible_to_either_argument;
+
+ public:
+ typedef transition_function_tag
+ tag;
+ typedef typename ::std::tr1::function<F(Arg1,Arg2)>::result_type
+ result_type;
+ typedef result_type
+ state;
+
+ private:
+ // typedef implementation_defined Arg1_Data;
+ // typedef implementation_defined Arg2_Data;
+ // typedef implementation_defined Is_State_Convertible_To_Arg1;
+ //<-
+ typedef typename ::boost::detail::data_type<Arg1>::type
+ Arg1_Data;
+ typedef typename ::boost::detail::data_type<Arg2>::type
+ Arg2_Data;
+ typedef typename ::std::tr1::is_convertible<state,Arg1_Data>::type
+ Is_State_Convertible_To_Arg1;
+ //->
+
+ public:
+ typedef state
+ first_argument_type;
+ typedef typename ::boost::mpl::eval_if<
+ Is_State_Convertible_To_Arg1
+ , ::boost::mpl::identity<Arg2_Data>
+ , ::boost::mpl::eval_if<
+ ::std::tr1::is_convertible<state,Arg2_Data>
+ , ::boost::mpl::identity<Arg1_Data>
+ , error__state_must_be_convertible_to_either_argument
+ >
+ >::type
+ second_argument_type;
+
+ //<-
+ private:
+ ::std::tr1::function<F(Arg1,Arg2)>
+ _function;
+ ::std::tr1::function<bool(first_argument_type const&)>
+ _state_recognizer;
+ ::std::tr1::function<bool(second_argument_type const&)>
+ _input_recognizer;
+
+ public:
+ //->
+ adaptor_transition_function()
+ //<-
+ : _function(), _state_recognizer(), _input_recognizer()
+ {
+ }
+ //->
+ ;
+
+ template <typename Function>
+ adaptor_transition_function(Function function)
+ //<-
+ : _function(function), _state_recognizer(), _input_recognizer()
+ {
+ }
+ //->
+ ;
+
+ adaptor_transition_function(adaptor_transition_function const& copy)
+ //<-
+ : _function(copy._function)
+ , _state_recognizer(copy._state_recognizer)
+ , _input_recognizer(copy._input_recognizer)
+ {
+ }
+ //->
+ ;
+
+ //<-
+ inline
+ //->
+ adaptor_transition_function&
+ operator=(adaptor_transition_function const& copy)
+ //<-
+ {
+ if (this != &copy)
+ {
+ _function = copy._function;
+ _state_recognizer = copy._state_recognizer;
+ _input_recognizer = copy._input_recognizer;
+ }
+
+ return *this;
+ }
+ //->
+ ;
+
+ //<-
+ inline
+ //->
+ bool recognizes_input(second_argument_type const& i) const
+ //<-
+ {
+ return _input_recognizer ? _input_recognizer(i) : true;
+ }
+ //->
+ ;
+
+ //<-
+ inline
+ //->
+ bool recognizes_state(first_argument_type const& s) const
+ //<-
+ {
+ return _state_recognizer ? _state_recognizer(s) : true;
+ }
+ //->
+ ;
+
+ //<-
+ inline
+ //->
+ result_type
+ operator()(
+ first_argument_type const& current_state
+ , second_argument_type const& i
+ ) const
+ //<-
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(recognizes_input(i));
+
+ return _evaluate(current_state, i, Is_State_Convertible_To_Arg1());
+ }
+ //->
+ ;
+
+ template <typename InputRecognizer>
+ //<-
+ inline
+ //->
+ void set_input_recognizer(InputRecognizer input_recognizer)
+ //<-
+ {
+ _input_recognizer = input_recognizer;
+ }
+ //->
+ ;
+
+ template <typename StateRecognizer>
+ //<-
+ inline
+ //->
+ void set_state_recognizer(StateRecognizer state_recognizer)
+ //<-
+ {
+ _state_recognizer = state_recognizer;
+ }
+ //->
+ ;
+
+ //<-
+ private:
+ inline state
+ _evaluate(
+ first_argument_type const& current_state
+ , second_argument_type const& i
+ , ::std::tr1::true_type
+ ) const
+ {
+ return _function(current_state, i);
+ }
+
+ inline state
+ _evaluate(
+ first_argument_type const& current_state
+ , second_argument_type const& i
+ , ::std::tr1::false_type
+ ) const
+ {
+ return _function(i, current_state);
+ }
+ //->
+
+ template <
+ typename F1
+ , typename A1_1
+ , typename A1_2
+ , typename F2
+ , typename A2_1
+ , typename A2_2
+ >
+ //<-
+ inline
+ //->
+ friend bool
+ operator==(
+ adaptor_transition_function<F1(A1_1,A1_2)> const& lhs
+ , adaptor_transition_function<F2(A2_1,A2_2)> const& rhs
+ )
+ //<-
+ {
+ return lhs._function == rhs._function;
+ }
+ //->
+ ;
+
+ template <
+ typename F1
+ , typename A1_1
+ , typename A1_2
+ , typename F2
+ , typename A2_1
+ , typename A2_2
+ >
+ //<-
+ inline
+ //->
+ friend bool
+ operator!=(
+ adaptor_transition_function<F1(A1_1,A1_2)> const& lhs
+ , adaptor_transition_function<F2(A2_1,A2_2)> const& rhs
+ )
+ //<-
+ {
+ return lhs._function != rhs._function;
+ }
+ //->
+ ;
+ };
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_TRANSITION_FUNCTION_ADAPTOR_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/transition_function/decision_tree.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/transition_function/decision_tree.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,1963 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_TRANSITION_FUNCTION_DECISION_TREE_HPP_INCLUDED
+#define BOOST_AUTOMATA_TRANSITION_FUNCTION_DECISION_TREE_HPP_INCLUDED
+
+#include <boost/preprocessor/comparison/less.hpp>
+#include <boost/parameter.hpp>
+#include <boost/parameter/preprocessor.hpp>
+
+#if BOOST_PP_LESS(BOOST_PARAMETER_MAX_ARITY, 5)
+#error Set BOOST_PARAMETER_MAX_ARITY to 5 or more.
+#endif
+
+#include <cmath>
+#include <boost/tr1/type_traits.hpp>
+#include <boost/tr1/random.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/none.hpp>
+#include <boost/optional/optional.hpp>
+#include <boost/fusion/container/map.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/fusion/support/pair.hpp>
+#include <boost/range/distance.hpp>
+#include <boost/range/algorithm/copy.hpp>
+#include <boost/utility/container_gen.hpp>
+#include <boost/utility/associative_container_gen.hpp>
+#include <boost/tree_node/raw_associative_node.hpp>
+#include <boost/tree_node/breadth_first_iterator.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/keys/common.hpp>
+#include <boost/automata/keyword/template.hpp>
+#include <boost/assert.hpp>
+
+//[reference__decision_tree_transition_function
+namespace boost { namespace automata {
+ //<-
+ namespace _detail {
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ class decision_tree_transition_function_helper
+ {
+ typedef typename ::boost::container_gen<
+ RandomAccessContainerSelector
+ , State
+ >::type
+ StateArray;
+ typedef typename ::boost::mpl::apply_wrap1<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , State
+ >::type
+ StateSet;
+ typedef typename ::boost::mpl::apply_wrap1<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , AttributeKey
+ >::type
+ AttributeKeySet;
+ typedef typename ::boost::mpl::apply_wrap2<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , AttributeKey
+ , AttributeValue
+ >::type
+ InputMap;
+ typedef ::boost::fusion::pair<input_symbol_key,InputMap>
+ InputEntry;
+ typedef ::boost::fusion::pair<next_state_key,State>
+ NextStateEntry;
+ typedef ::boost::fusion::map<InputEntry,NextStateEntry>
+ Example;
+ typedef typename ::boost::container_gen<
+ RandomAccessContainerSelector
+ , Example
+ >::type
+ ExampleArray;
+ typedef typename ::boost::mpl::apply_wrap2<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , AttributeValue
+ , ExampleArray
+ >::type
+ LightweightTree;
+
+ class ExampleMaker
+ {
+ decision_tree_transition_function_helper& _helper;
+ StateSet& _states;
+ Example _example;
+
+ public:
+ ExampleMaker(
+ decision_tree_transition_function_helper& helper
+ , StateSet& states
+ );
+
+ inline Example const& get() const
+ {
+ return _example;
+ }
+
+ void
+ input(
+ AttributeKey const& key
+ , AttributeValue const& value
+ , ::std::tr1::true_type
+ );
+
+ void
+ input(
+ AttributeKey const& key
+ , AttributeValue const& value
+ , ::std::tr1::false_type
+ );
+
+ void set_next_state(State const& next_state);
+ };
+
+ public:
+ class builder
+ {
+ class Helper
+ {
+ builder& _builder;
+ ExampleMaker _maker;
+
+ public:
+ explicit Helper(builder& builder);
+
+ inline Helper&
+ operator()(
+ AttributeKey const& key
+ , AttributeValue const& value
+ )
+ {
+ _maker.input(
+ key
+ , value
+ , ::std::tr1::is_convertible<AttributeValue,State>()
+ );
+ return *this;
+ }
+
+ inline builder& operator[](State const& next_state)
+ {
+ _maker.set_next_state(next_state);
+ _builder._examples.push_back(_maker.get());
+ return _builder;
+ }
+ };
+
+ decision_tree_transition_function_helper& _helper;
+ StateSet _states;
+ ExampleArray _examples;
+ bool _check_for_homogeneity;
+
+ public:
+ builder(
+ decision_tree_transition_function_helper& helper
+ , bool check_for_homogeneity
+ );
+
+ builder(
+ decision_tree_transition_function_helper& helper
+ , AttributeKey const& state_key
+ , bool check_for_homogeneity
+ );
+
+ ~builder();
+
+ inline Helper
+ operator()(
+ AttributeKey const& key
+ , AttributeValue const& value
+ )
+ {
+ Helper helper(*this);
+
+ helper(key, value);
+ return helper;
+ }
+ };
+
+ class incremental_builder
+ {
+ decision_tree_transition_function_helper& _helper;
+ StateSet _states;
+ ExampleMaker _maker;
+
+ public:
+ explicit incremental_builder(
+ decision_tree_transition_function_helper& helper
+ );
+
+ inline incremental_builder&
+ operator()(
+ AttributeKey const& key
+ , AttributeValue const& value
+ )
+ {
+ _maker.input(
+ key
+ , value
+ , ::std::tr1::is_same<AttributeValue,State>()
+ );
+ return *this;
+ }
+
+ void operator[](State const& next_state);
+ };
+
+ private:
+ class NodeData
+ {
+ bool _has_homogeneous_examples;
+ ExampleArray _input_examples;
+ AttributeKey _split_attribute_key;
+
+ public:
+ NodeData();
+
+ inline bool has_homogeneous_examples() const
+ {
+ return _has_homogeneous_examples;
+ }
+
+ inline ExampleArray const& get_input_examples() const
+ {
+ return _input_examples;
+ }
+
+ inline AttributeKey const& get_split_attribute_key() const
+ {
+ return _split_attribute_key;
+ }
+
+ void set_input_examples(ExampleArray const& examples);
+
+ void add_input_example(Example const& example);
+
+ void set_split_attribute_key(AttributeKey const& key);
+
+ void clear();
+ };
+
+ typedef ::boost::tree_node::raw_associative_node<
+ AttributeValue
+ , NodeData
+ , AssociativeContainerSelector
+ >
+ Node;
+
+ Node _root;
+ StateArray _states;
+ AttributeKeySet _attribute_keys;
+ optional<AttributeKey> _state_key;
+
+ public:
+ bool is_ready_to_process_input() const;
+
+ template <typename Input>
+ bool
+ process_input(
+ State& current_state
+ , Input const& i
+ , ::std::tr1::true_type
+ ) const;
+
+ template <typename Input>
+ bool
+ process_input(
+ State& current_state
+ , Input const& i
+ , ::std::tr1::false_type
+ ) const;
+
+ template <typename Input, typename RNGEngine>
+ void
+ process_input(
+ State& current_state
+ , Input const& i
+ , RNGEngine& engine
+ , ::std::tr1::true_type
+ ) const;
+
+ template <typename Input, typename RNGEngine>
+ void
+ process_input(
+ State& current_state
+ , Input const& i
+ , RNGEngine& engine
+ , ::std::tr1::false_type
+ ) const;
+
+ template <typename Examples>
+ void learn_examples(Examples const& examples);
+
+ template <typename NewExample>
+ void learn_example(NewExample const& example);
+
+ void reset();
+
+ private:
+ static double _compute_entropy(ExampleArray const& examples);
+
+ static double _compute_average_entropy(LightweightTree const& l_tree);
+
+ static void
+ _id3(
+ AttributeKeySet const& available_keys
+ , NodeData& data
+ , LightweightTree& output_tree
+ , bool check_for_homogeneity
+ );
+
+ static void
+ _create_descendants(
+ typename Node::pointer node
+ , AttributeKeySet const& attribute_keys
+ , LightweightTree& l_tree
+ , bool check_for_homogeneity
+ );
+
+ void _id4(Example const& example, bool check_for_homogeneity);
+ };
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::ExampleMaker::ExampleMaker(
+ decision_tree_transition_function_helper& helper
+ , StateSet& states
+ ) : _helper(helper), _states(states), _example()
+ {
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ inline void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::ExampleMaker::input(
+ AttributeKey const& key
+ , AttributeValue const& value
+ , ::std::tr1::true_type
+ )
+ {
+ if (_helper._attribute_keys.find(key) == _helper._attribute_keys.end())
+ {
+ _helper._attribute_keys.insert(key);
+ }
+
+ if (
+ (_helper._state_key)
+ && (key == *_helper._state_key)
+ && (_states.find(value) == _states.end())
+ )
+ {
+ _states.insert(value);
+ }
+
+ ::boost::fusion::at_key<input_symbol_key>(_example).insert(
+ typename InputMap::value_type(key, value)
+ );
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ inline void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::ExampleMaker::input(
+ AttributeKey const& key
+ , AttributeValue const& value
+ , ::std::tr1::false_type
+ )
+ {
+ if (_helper._attribute_keys.find(key) == _helper._attribute_keys.end())
+ {
+ _helper._attribute_keys.insert(key);
+ }
+
+ ::boost::fusion::at_key<input_symbol_key>(_example).insert(
+ typename InputMap::value_type(key, value)
+ );
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ inline void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::ExampleMaker::set_next_state(State const& next_state)
+ {
+ if (_states.find(next_state) == _states.end())
+ {
+ _states.insert(next_state);
+ }
+
+ ::boost::fusion::at_key<next_state_key>(_example) = next_state;
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::builder::Helper::Helper(builder& builder)
+ : _builder(builder), _maker(builder._helper, builder._states)
+ {
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::builder::builder(
+ decision_tree_transition_function_helper& helper
+ , bool check_for_homogeneity
+ ) : _helper(helper)
+ , _states()
+ , _examples()
+ , _check_for_homogeneity(check_for_homogeneity)
+ {
+ _helper._state_key = boost::none;
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::builder::builder(
+ decision_tree_transition_function_helper& helper
+ , AttributeKey const& state_key
+ , bool check_for_homogeneity
+ ) : _helper(helper)
+ , _states()
+ , _examples()
+ , _check_for_homogeneity(check_for_homogeneity)
+ {
+ _helper._state_key = state_key;
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::builder::~builder()
+ {
+ LightweightTree l_tree;
+
+ _helper._states.resize(_states.size());
+ ::boost::range::copy(_states, _helper._states.begin());
+ _helper._root.remove_all_children();
+ _helper._root.get_data().set_input_examples(_examples);
+ decision_tree_transition_function_helper::_create_descendants(
+ &_helper._root
+ , _helper._attribute_keys
+ , l_tree
+ , _check_for_homogeneity
+ );
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::incremental_builder::incremental_builder(
+ decision_tree_transition_function_helper& helper
+ ) : _helper(helper)
+ , _states(_helper._states.begin(), _helper._states.end())
+ , _maker(helper, _states)
+ {
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ inline void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::incremental_builder::operator[](State const& next_state)
+ {
+ _maker.set_next_state(next_state);
+ _helper._states.resize(_states.size());
+ ::boost::range::copy(_states, _helper._states.begin());
+ _helper._id4(_maker.get(), true);
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::NodeData::NodeData()
+ : _has_homogeneous_examples(false)
+ , _input_examples()
+ , _split_attribute_key()
+ {
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::NodeData::set_input_examples(ExampleArray const& examples)
+ {
+ _input_examples = examples;
+
+ if (!examples.empty())
+ {
+ typename ExampleArray::const_iterator itr = examples.begin();
+ State const& state = ::boost::fusion::at_key<next_state_key>(*itr);
+
+ _has_homogeneous_examples = true;
+
+ while (++itr != examples.end())
+ {
+ if (::boost::fusion::at_key<next_state_key>(*itr) != state)
+ {
+ _has_homogeneous_examples = false;
+ break;
+ }
+ }
+ }
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ inline void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::NodeData::add_input_example(Example const& example)
+ {
+ if (_input_examples.empty())
+ {
+ _has_homogeneous_examples = true;
+ }
+ else if (_has_homogeneous_examples)
+ {
+ _has_homogeneous_examples = (
+ ::boost::fusion::at_key<next_state_key>(example)
+ == ::boost::fusion::at_key<next_state_key>(_input_examples[0])
+ );
+ }
+
+ _input_examples.push_back(example);
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ inline void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::NodeData::set_split_attribute_key(AttributeKey const& key)
+ {
+ _split_attribute_key = key;
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ inline void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::NodeData::clear()
+ {
+ _has_homogeneous_examples = false;
+ _input_examples.clear();
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ inline bool
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::is_ready_to_process_input() const
+ {
+ return !_root.get_data().get_input_examples().empty();
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ template <typename Input>
+ bool
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::process_input(
+ State& current_state
+ , Input const& i
+ , ::std::tr1::true_type
+ ) const
+ {
+ typename Node::const_pointer node = &_root;
+ typename Node::const_child_iterator c_itr;
+ typename Node::const_child_iterator c_end;
+ typename Input::const_iterator in_itr;
+ typename Input::const_iterator in_end = i.end();
+
+ for (;;)
+ {
+ c_itr = node->get_child_begin();
+ c_end = node->get_child_end();
+
+ if (c_itr == c_end)
+ {
+ break;
+ }
+
+ NodeData const& data = node->get_data();
+ AttributeKey const& key = data.get_split_attribute_key();
+
+ if ((_state_key) && (key == *_state_key))
+ {
+ c_itr = node->find_child(current_state);
+
+ if (c_itr == c_end)
+ {
+ return false;
+ }
+
+ node = c_itr->second;
+ continue;
+ }
+
+ in_itr = i.find(key);
+
+ if (in_itr == in_end)
+ {
+ return false;
+ }
+
+ c_itr = node->find_child(in_itr->second);
+
+ if (c_itr == c_end)
+ {
+ return false;
+ }
+
+ node = c_itr->second;
+ }
+
+ ExampleArray const& examples = node->get_data().get_input_examples();
+
+ BOOST_ASSERT(!examples.empty() && "Descendant creation bug.");
+ current_state = ::boost::fusion::at_key<next_state_key>(examples[0]);
+ return true;
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ template <typename Input>
+ bool
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::process_input(
+ State& current_state
+ , Input const& i
+ , ::std::tr1::false_type
+ ) const
+ {
+ typename Node::const_pointer node = &_root;
+ typename Node::const_child_iterator c_itr;
+ typename Node::const_child_iterator c_end;
+ typename Input::const_iterator in_itr;
+ typename Input::const_iterator in_end = i.end();
+
+ for (;;)
+ {
+ c_itr = node->get_child_begin();
+ c_end = node->get_child_end();
+
+ if (c_itr == c_end)
+ {
+ break;
+ }
+
+ NodeData const& data = node->get_data();
+
+ in_itr = i.find(data.get_split_attribute_key());
+
+ if (in_itr == in_end)
+ {
+ return false;
+ }
+
+ c_itr = node->find_child(in_itr->second);
+
+ if (c_itr == c_end)
+ {
+ return false;
+ }
+
+ node = c_itr->second;
+ }
+
+ ExampleArray const& examples = node->get_data().get_input_examples();
+
+ BOOST_ASSERT(!examples.empty() && "Descendant creation bug.");
+ current_state = ::boost::fusion::at_key<next_state_key>(examples[0]);
+ return true;
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ template <typename Input, typename RNGEngine>
+ void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::process_input(
+ State& current_state
+ , Input const& i
+ , RNGEngine& engine
+ , ::std::tr1::true_type
+ ) const
+ {
+ typename Node::const_pointer node = &_root;
+ typename Node::const_child_iterator c_itr;
+ typename Node::const_child_iterator c_end;
+ typename Input::const_iterator in_itr;
+ typename Input::const_iterator in_end = i.end();
+
+ for (;;)
+ {
+ c_itr = node->get_child_begin();
+ c_end = node->get_child_end();
+
+ if (c_itr == c_end)
+ {
+ break;
+ }
+
+ NodeData const& data = node->get_data();
+ AttributeKey const& key = data.get_split_attribute_key();
+
+ if ((_state_key) && (key == *_state_key))
+ {
+ c_itr = node->find_child(current_state);
+
+ if (c_itr == c_end)
+ {
+ typedef ::std::tr1::uniform_int< ::std::size_t>
+ Distribution;
+
+ current_state = _states[
+ ::std::tr1::variate_generator<RNGEngine&,Distribution>(
+ engine
+ , Distribution(0, _states.size() - 1)
+ )()
+ ];
+ return;
+ }
+
+ node = c_itr->second;
+ continue;
+ }
+
+ in_itr = i.find(key);
+
+ if (in_itr == in_end)
+ {
+ typedef ::std::tr1::uniform_int< ::std::size_t> Distribution;
+
+ ExampleArray const& examples = data.get_input_examples();
+
+ current_state = ::boost::fusion::at_key<next_state_key>(
+ examples[
+ ::std::tr1::variate_generator<RNGEngine&,Distribution>(
+ engine
+ , Distribution(0, examples.size() - 1)
+ )()
+ ]
+ );
+ return;
+ }
+
+ c_itr = node->find_child(in_itr->second);
+
+ if (c_itr == c_end)
+ {
+ typedef ::std::tr1::uniform_int<std::size_t> Distribution;
+
+ current_state = _states[
+ ::std::tr1::variate_generator<RNGEngine&,Distribution>(
+ engine
+ , Distribution(0, _states.size() - 1)
+ )()
+ ];
+ return;
+ }
+
+ node = c_itr->second;
+ }
+
+ ExampleArray const& examples = node->get_data().get_input_examples();
+
+ BOOST_ASSERT(!examples.empty() && "Descendant creation bug.");
+ current_state = ::boost::fusion::at_key<next_state_key>(examples[0]);
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ template <typename Input, typename RNGEngine>
+ void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::process_input(
+ State& current_state
+ , Input const& i
+ , RNGEngine& engine
+ , ::std::tr1::false_type
+ ) const
+ {
+ typename Node::const_pointer node = &_root;
+ typename Node::const_child_iterator c_itr;
+ typename Node::const_child_iterator c_end;
+ typename Input::const_iterator in_itr;
+ typename Input::const_iterator in_end = i.end();
+
+ for (;;)
+ {
+ c_itr = node->get_child_begin();
+ c_end = node->get_child_end();
+
+ if (c_itr == c_end)
+ {
+ break;
+ }
+
+ NodeData const& data = node->get_data();
+
+ in_itr = i.find(data.get_split_attribute_key());
+
+ if (in_itr == in_end)
+ {
+ typedef ::std::tr1::uniform_int< ::std::size_t> Distribution;
+
+ ExampleArray const& examples = data.get_input_examples();
+
+ current_state = ::boost::fusion::at_key<next_state_key>(
+ examples[
+ ::std::tr1::variate_generator<RNGEngine&,Distribution>(
+ engine
+ , Distribution(0, examples.size() - 1)
+ )()
+ ]
+ );
+ return;
+ }
+
+ c_itr = node->find_child(in_itr->second);
+
+ if (c_itr == c_end)
+ {
+ typedef ::std::tr1::uniform_int< ::std::size_t> Distribution;
+
+ current_state = _states[
+ ::std::tr1::variate_generator<RNGEngine&,Distribution>(
+ engine
+ , Distribution(0, _states.size() - 1)
+ )()
+ ];
+ return;
+ }
+
+ node = c_itr->second;
+ }
+
+ ExampleArray const& examples = node->get_data().get_input_examples();
+
+ BOOST_ASSERT(!examples.empty() && "Descendant creation bug.");
+ current_state = ::boost::fusion::at_key<next_state_key>(examples[0]);
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ template <typename Examples>
+ void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::learn_examples(Examples const& examples)
+ {
+ // TODO:
+ // 1. Copy examples into root node data.
+ // Add each attribute key found in each example input map
+ // if it is not already added.
+ // Add each state found in each example
+ // if it is not already added.
+ // 2. Create the tree.
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ template <typename NewExample>
+ void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::learn_example(NewExample const& example)
+ {
+ // TODO: Add the example into the tree where appropriate using ID4.
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::reset()
+ {
+ _root->remove_all_children();
+ _root->get_data().reset();
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ double
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::_compute_entropy(ExampleArray const& examples)
+ {
+ using namespace std;
+
+ typedef typename ::boost::mpl::apply_wrap2<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , State
+ , size_t
+ >::type
+ NextStateTallies;
+
+ NextStateTallies tallies;
+ typename ExampleArray::const_iterator e_itr_end = examples.end();
+
+ for (
+ typename ExampleArray::const_iterator itr = examples.begin();
+ itr != e_itr_end;
+ ++itr
+ )
+ {
+ ++tallies[::boost::fusion::at_key<next_state_key>(*itr)];
+ }
+
+ double result = 0.0;
+ double examples_size = static_cast<double>(examples.size());
+ typename NextStateTallies::const_iterator nst_end = tallies.end();
+
+ for (
+ typename NextStateTallies::const_iterator itr = tallies.begin();
+ itr != nst_end;
+ ++itr
+ )
+ {
+ double const proportion = itr->second / examples_size;
+
+ result -= proportion * log(proportion);
+ }
+
+ return result;
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ double
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::_compute_average_entropy(LightweightTree const& l_tree)
+ {
+ double example_count = 0.0;
+ typename LightweightTree::const_iterator itr_end = l_tree.end();
+
+ for (
+ typename LightweightTree::const_iterator itr = l_tree.begin();
+ itr != itr_end;
+ ++itr
+ )
+ {
+ example_count += itr->second.size();
+ }
+
+ double result = 0.0;
+
+ for (
+ typename LightweightTree::const_iterator itr = l_tree.begin();
+ itr != itr_end;
+ ++itr
+ )
+ {
+ ExampleArray const& examples = itr->second;
+ double const proportion = examples.size() / example_count;
+
+ result += proportion * _compute_entropy(examples);
+ }
+
+ return result;
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::_id3(
+ AttributeKeySet const& keys
+ , NodeData& data
+ , LightweightTree& output_tree
+ , bool check_for_homogeneity
+ )
+ {
+ LightweightTree current_tree;
+ ExampleArray const& examples = data.get_input_examples();
+ double init_entropy = _compute_entropy(examples);
+ double best_information_gain = 0.0;
+ typename AttributeKeySet::const_iterator k_itr_end = keys.end();
+ typename ExampleArray::const_iterator e_itr;
+ typename ExampleArray::const_iterator e_itr_end = examples.end();
+ typename InputMap::const_iterator in_itr;
+ bool can_use_as_split_attribute;
+
+ for (
+ typename AttributeKeySet::const_iterator k_itr = keys.begin();
+ k_itr != k_itr_end;
+ ++k_itr
+ )
+ {
+ can_use_as_split_attribute = true;
+ current_tree.clear();
+
+ for (e_itr = examples.begin(); e_itr != e_itr_end; ++e_itr)
+ {
+ InputMap const& in_map = ::boost::fusion::at_key<
+ input_symbol_key
+ >(*e_itr);
+
+ in_itr = in_map.find(*k_itr);
+
+ if (in_itr == in_map.end())
+ {
+ can_use_as_split_attribute = false;
+ break;
+ }
+
+ current_tree[in_itr->second].push_back(*e_itr);
+ }
+
+ if (can_use_as_split_attribute)
+ {
+ double const information_gain = (
+ init_entropy - _compute_average_entropy(current_tree)
+ );
+
+ if (
+ !check_for_homogeneity && output_tree.empty()
+ || (best_information_gain < information_gain)
+ )
+ {
+ data.set_split_attribute_key(*k_itr);
+ output_tree = current_tree;
+ best_information_gain = information_gain;
+ }
+ }
+ }
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::_create_descendants(
+ typename Node::pointer node
+ , AttributeKeySet const& attribute_keys
+ , LightweightTree& l_tree
+ , bool check_for_homogeneity
+ )
+ {
+ typename LightweightTree::const_iterator lt_itr;
+ typename LightweightTree::const_iterator lt_itr_end;
+
+ for (
+ ::boost::tree_node::breadth_first_iterator<
+ typename Node::pointer
+ , ::std::tr1::false_type
+ > node_itr(node);
+ node_itr;
+ ++node_itr
+ )
+ {
+ NodeData& data = (node = *node_itr)->get_data();
+
+ if (check_for_homogeneity)
+ {
+ if (data.has_homogeneous_examples())
+ {
+ continue;
+ }
+ }
+ else if (data.get_input_examples().size() < 2)
+ {
+ continue;
+ }
+
+ if (l_tree.empty())
+ {
+ AttributeKeySet available_keys(attribute_keys);
+ typename Node::const_pointer p(node);
+
+ while (p = p->get_parent())
+ {
+ available_keys.erase(
+ p->get_data().get_split_attribute_key()
+ );
+
+ if (available_keys.empty())
+ {
+ return;
+ }
+ }
+
+ _id3(available_keys, data, l_tree, check_for_homogeneity);
+ }
+
+ if (!l_tree.empty())
+ {
+ lt_itr_end = l_tree.end();
+
+ for (lt_itr = l_tree.begin(); lt_itr != lt_itr_end; ++lt_itr)
+ {
+ node->add_child(
+ lt_itr->first
+ )->get_data().set_input_examples(lt_itr->second);
+ }
+ }
+
+ l_tree.clear();
+ }
+ }
+
+ template <
+ typename State
+ , typename AttributeKey
+ , typename AttributeValue
+ , typename RandomAccessContainerSelector
+ , typename AssociativeContainerSelector
+ >
+ void
+ decision_tree_transition_function_helper<
+ State
+ , AttributeKey
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >::_id4(Example const& example, bool check_for_homogeneity)
+ {
+ AttributeKey previous_key;
+ AttributeKey new_key;
+ LightweightTree l_tree;
+ typename InputMap::const_iterator in_itr;
+ typename Node::pointer node = &_root;
+ typename Node::child_iterator c_itr;
+ typename Node::child_iterator c_end;
+
+ for (;;)
+ {
+ NodeData& data = node->get_data();
+
+ data.add_input_example(example);
+ c_itr = node->get_child_begin();
+ c_end = node->get_child_end();
+
+ if (c_itr == c_end)
+ {
+ break;
+ }
+
+ InputMap const& in_map = ::boost::fusion::at_key<
+ input_symbol_key
+ >(example);
+
+ l_tree.clear();
+ in_itr = in_map.find(
+ previous_key = data.get_split_attribute_key()
+ );
+
+ if (in_itr == in_map.end())
+ {
+ _create_descendants(
+ node
+ , _attribute_keys
+ , l_tree
+ , check_for_homogeneity
+ );
+ return;
+ }
+
+ _id3(_attribute_keys, data, l_tree, check_for_homogeneity);
+
+ if (l_tree.empty())
+ {
+ node->remove_all_children();
+ return;
+ }
+
+ new_key = data.get_split_attribute_key();
+
+ if (previous_key != new_key)
+ {
+ _create_descendants(
+ node
+ , _attribute_keys
+ , l_tree
+ , check_for_homogeneity
+ );
+ return;
+ }
+
+ c_itr = node->find_child(in_itr->second);
+
+ if (c_itr == c_end)
+ {
+ node->add_child(
+ in_itr->second
+ )->get_data().add_input_example(example);
+ return;
+ }
+
+ node = c_itr->second;
+ }
+
+ if (!node->get_data().has_homogeneous_examples())
+ {
+ l_tree.clear();
+ _create_descendants(
+ node
+ , _attribute_keys
+ , l_tree
+ , check_for_homogeneity
+ );
+ }
+ }
+ } // namespace _detail
+ //->
+
+ template <
+ typename T0
+ , typename T1
+ , typename T2 = ::boost::parameter::void_
+ , typename T3 = ::boost::parameter::void_
+ , typename T4 = ::boost::parameter::void_
+ >
+ class decision_tree_transition_function
+ {
+ //<-
+ typedef typename ::boost::parameter::parameters<
+ ::boost::parameter::required<keyword::tag::_State>
+ , ::boost::parameter::required<keyword::tag::_AttributeKey>
+ , ::boost::parameter::optional<keyword::tag::_AttributeValue>
+ , ::boost::parameter::optional<
+ keyword::tag::_AssociativeContainerSelector
+ >
+ , ::boost::parameter::optional<
+ keyword::tag::_RandomAccessContainerSelector
+ >
+ >::BOOST_NESTED_TEMPLATE bind<
+ T0
+ , T1
+ , T2
+ , T3
+ , T4
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+ , ::boost::parameter::void_
+#endif
+ >::type
+ Args;
+ //->
+
+ public:
+ typedef transition_function_tag
+ tag;
+ typedef // implementation_defined
+ //<-
+ typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_State
+ >::type
+ //->
+ state;
+ typedef bool
+ result_type;
+ typedef // implementation_defined
+ //<-
+ typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_AttributeKey
+ >::type
+ //->
+ attribute_key;
+
+ //<-
+ private:
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_AttributeValue
+ , state
+ >::type
+ AttributeValue;
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_AssociativeContainerSelector
+ , ::boost::mapS
+ >::type
+ AssociativeContainerSelector;
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_RandomAccessContainerSelector
+ , ::boost::vecS
+ >::type
+ RandomAccessContainerSelector;
+ typedef _detail::decision_tree_transition_function_helper<
+ state
+ , attribute_key
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >
+ Helper;
+
+ public:
+ //->
+ typedef typename Helper::builder
+ builder;
+ typedef typename Helper::incremental_builder
+ incremental_builder;
+
+ //<-
+ private:
+ Helper _helper;
+
+ public:
+ //->
+ decision_tree_transition_function();
+
+ decision_tree_transition_function(
+ decision_tree_transition_function const& copy
+ );
+
+ decision_tree_transition_function&
+ operator=(decision_tree_transition_function const& copy);
+
+ template <typename Input, typename RNGEngine>
+ result_type
+ operator()(
+ state& current_state
+ , Input const& i
+ , RNGEngine& rng_engine
+ ) const;
+
+ void reset();
+
+ builder set_examples();
+
+ builder set_examples(attribute_key const& state_key);
+
+ incremental_builder add_example();
+ };
+
+ //<-
+ template <typename T0, typename T1, typename T2, typename T3, typename T4>
+ decision_tree_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ , T4
+ >::decision_tree_transition_function() : _helper()
+ {
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3, typename T4>
+ decision_tree_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ , T4
+ >::decision_tree_transition_function(
+ decision_tree_transition_function const& copy
+ ) : _helper(copy._helper)
+ {
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3, typename T4>
+ decision_tree_transition_function<T0,T1,T2,T3,T4>&
+ decision_tree_transition_function<T0,T1,T2,T3,T4>::operator=(
+ decision_tree_transition_function const& copy
+ )
+ {
+ if (this != &copy)
+ {
+ _helper = copy._helper;
+ }
+
+ return *this;
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3, typename T4>
+ template <typename Input, typename RNGEngine>
+ inline typename decision_tree_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ , T4
+ >::result_type
+ decision_tree_transition_function<T0,T1,T2,T3,T4>::operator()(
+ state& current_state
+ , Input const& input
+ , RNGEngine& rng_engine
+ ) const
+ {
+ if (_helper.is_ready_to_process_input())
+ {
+ _helper.process_input(
+ current_state
+ , input
+ , rng_engine
+ , ::std::tr1::is_same<attribute_key,state>()
+ );
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3, typename T4>
+ inline void decision_tree_transition_function<T0,T1,T2,T3,T4>::reset()
+ {
+ _helper.reset();
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3, typename T4>
+ inline typename decision_tree_transition_function<T0,T1,T2,T3,T4>::builder
+ decision_tree_transition_function<T0,T1,T2,T3,T4>::set_examples()
+ {
+ return builder(_helper, true);
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3, typename T4>
+ inline typename decision_tree_transition_function<T0,T1,T2,T3,T4>::builder
+ decision_tree_transition_function<T0,T1,T2,T3,T4>::set_examples(
+ attribute_key const& state_key
+ )
+ {
+ return builder(_helper, state_key, true);
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3, typename T4>
+ inline typename decision_tree_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ , T4
+ >::incremental_builder
+ decision_tree_transition_function<T0,T1,T2,T3,T4>::add_example()
+ {
+ return incremental_builder(_helper);
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+//[reference__decision_tree_explicit_transition_function
+namespace boost { namespace automata {
+
+ template <
+ typename T0
+ , typename T1
+ , typename T2 = ::boost::parameter::void_
+ , typename T3 = ::boost::parameter::void_
+ , typename T4 = ::boost::parameter::void_
+ >
+ class decision_tree_explicit_transition_function
+ {
+ //<-
+ typedef typename ::boost::parameter::parameters<
+ ::boost::parameter::required<keyword::tag::_State>
+ , ::boost::parameter::required<keyword::tag::_AttributeKey>
+ , ::boost::parameter::optional<keyword::tag::_AttributeValue>
+ , ::boost::parameter::optional<
+ keyword::tag::_AssociativeContainerSelector
+ >
+ , ::boost::parameter::optional<
+ keyword::tag::_RandomAccessContainerSelector
+ >
+ >::BOOST_NESTED_TEMPLATE bind<
+ T0
+ , T1
+ , T2
+ , T3
+ , T4
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+ , ::boost::parameter::void_
+#endif
+ >::type
+ Args;
+ //->
+
+ public:
+ typedef transition_function_tag
+ tag;
+ typedef // implementation_defined
+ //<-
+ typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_State
+ >::type
+ //->
+ state;
+ typedef bool
+ result_type;
+ typedef // implementation_defined
+ //<-
+ typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_AttributeKey
+ >::type
+ //->
+ attribute_key;
+
+ //<-
+ private:
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_AttributeValue
+ , state
+ >::type
+ AttributeValue;
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_AssociativeContainerSelector
+ , mapS
+ >::type
+ AssociativeContainerSelector;
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_RandomAccessContainerSelector
+ , vecS
+ >::type
+ RandomAccessContainerSelector;
+ typedef _detail::decision_tree_transition_function_helper<
+ state
+ , attribute_key
+ , AttributeValue
+ , RandomAccessContainerSelector
+ , AssociativeContainerSelector
+ >
+ Helper;
+
+ public:
+ //->
+ typedef typename Helper::builder
+ builder;
+
+ //<-
+ private:
+ Helper _helper;
+
+ public:
+ //->
+ decision_tree_explicit_transition_function();
+
+ decision_tree_explicit_transition_function(
+ decision_tree_explicit_transition_function const& copy
+ );
+
+ decision_tree_explicit_transition_function&
+ operator=(decision_tree_explicit_transition_function const& copy);
+
+ template <typename Input>
+ result_type operator()(state& current_state, Input const& i) const;
+
+ void reset();
+
+ builder add_transitions();
+
+ builder add_transitions(attribute_key const& state_key);
+ };
+
+ //<-
+ template <typename T0, typename T1, typename T2, typename T3, typename T4>
+ decision_tree_explicit_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ , T4
+ >::decision_tree_explicit_transition_function() : _helper()
+ {
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3, typename T4>
+ decision_tree_explicit_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ , T4
+ >::decision_tree_explicit_transition_function(
+ decision_tree_explicit_transition_function const& copy
+ ) : _helper(copy._helper)
+ {
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3, typename T4>
+ decision_tree_explicit_transition_function<T0,T1,T2,T3,T4>&
+ decision_tree_explicit_transition_function<T0,T1,T2,T3,T4>::operator=(
+ decision_tree_explicit_transition_function const& copy
+ )
+ {
+ if (this != &copy)
+ {
+ _helper = copy._helper;
+ }
+
+ return *this;
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3, typename T4>
+ template <typename Input>
+ inline typename decision_tree_explicit_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ , T4
+ >::result_type
+ decision_tree_explicit_transition_function<T0,T1,T2,T3,T4>::operator()(
+ state& current_state
+ , Input const& input
+ ) const
+ {
+ if (_helper.is_ready_to_process_input())
+ {
+ return _helper.process_input(
+ current_state
+ , input
+ , ::std::tr1::is_same<attribute_key,state>()
+ );
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3, typename T4>
+ inline void
+ decision_tree_explicit_transition_function<T0,T1,T2,T3,T4>::reset()
+ {
+ _helper.reset();
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3, typename T4>
+ inline typename decision_tree_explicit_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ , T4
+ >::builder
+ decision_tree_explicit_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ , T4
+ >::add_transitions()
+ {
+ return builder(_helper, false);
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3, typename T4>
+ inline typename decision_tree_explicit_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ , T4
+ >::builder
+ decision_tree_explicit_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ , T4
+ >::add_transitions(attribute_key const& state_key)
+ {
+ return builder(_helper, state_key, false);
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_TRANSITION_FUNCTION_DECISION_TREE_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/transition_function/dpda.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/transition_function/dpda.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,929 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_TRANSITION_FUNCTION_DPDA_HPP_INCLUDED
+#define BOOST_AUTOMATA_TRANSITION_FUNCTION_DPDA_HPP_INCLUDED
+
+#include <boost/preprocessor/comparison/less.hpp>
+#include <boost/parameter.hpp>
+#include <boost/parameter/preprocessor.hpp>
+
+#if BOOST_PP_LESS(BOOST_PARAMETER_MAX_ARITY, 4)
+#error Set BOOST_PARAMETER_MAX_ARITY to 4 or more.
+#endif
+
+#include <map>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/optional/optional.hpp>
+//#include <boost/fusion/sequence/comparison/less.hpp>
+#include <boost/fusion/container/map.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/fusion/support/pair.hpp>
+#include <boost/utility/container_gen.hpp>
+#include <boost/utility/associative_container_gen.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/keys/common.hpp>
+#include <boost/automata/keys/dpda.hpp>
+#include <boost/automata/keyword/template.hpp>
+#include <boost/assert.hpp>
+
+//[reference__dpda_transition_function
+namespace boost { namespace automata {
+ //<-
+ namespace _detail {
+
+ template <typename InputMap>
+ struct deterministic_pushdown_less
+ {
+ typedef bool result_type;
+ typedef InputMap const& first_argument_type;
+ typedef first_argument_type second_argument_type;
+
+ result_type
+ operator()(
+ first_argument_type arg1
+ , second_argument_type arg2
+ ) const;
+ };
+
+ template <typename InputMap>
+ inline typename deterministic_pushdown_less<InputMap>::result_type
+ deterministic_pushdown_less<InputMap>::operator()(
+ first_argument_type arg1
+ , second_argument_type arg2
+ ) const
+ {
+ return (
+ (
+ ::boost::fusion::at_key<input_symbol_key>(arg1)
+ < ::boost::fusion::at_key<input_symbol_key>(arg2)
+ )
+ || (
+ (
+ ::boost::fusion::at_key<input_symbol_key>(arg1)
+ == ::boost::fusion::at_key<input_symbol_key>(arg2)
+ )
+ && (
+ ::boost::fusion::at_key<pop_from_stack_key>(arg1)
+ < ::boost::fusion::at_key<pop_from_stack_key>(arg2)
+ )
+ )
+ );
+ }
+ } // namespace _detail
+ //->
+
+ template <
+ typename T0
+ , typename T1
+ , typename T2 = ::boost::parameter::void_
+ , typename T3 = ::boost::parameter::void_
+ >
+ class dpda_transition_function
+ {
+ //<-
+ typedef typename ::boost::parameter::parameters<
+ ::boost::parameter::required<keyword::tag::_Input>
+ , ::boost::parameter::required<keyword::tag::_StackElement>
+ , ::boost::parameter::optional<
+ keyword::tag::_AssociativeContainerSelector
+ >
+ , ::boost::parameter::optional<
+ keyword::tag::_RandomAccessContainerSelector
+ >
+ >::BOOST_NESTED_TEMPLATE bind<
+ T0
+ , T1
+ , T2
+ , T3
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+ , boost::parameter::void_
+#endif
+ >::type
+ Args;
+ //->
+
+ public:
+ typedef dpda_transition_function_tag
+ tag;
+ typedef ::std::size_t
+ state;
+ typedef // implementation_defined
+ //<-
+ typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_Input
+ >::type
+ //->
+ input;
+ typedef // implementation_defined
+ //<-
+ typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_StackElement
+ >::type
+ //->
+ stack_element;
+
+ //<-
+ private:
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_AssociativeContainerSelector
+ , ::boost::mapS
+ >::type
+ AssociativeContainerSelector;
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_RandomAccessContainerSelector
+ , ::boost::vecS
+ >::type
+ RandomAccessContainerSelector;
+ typedef typename ::boost::mpl::apply_wrap1<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , input
+ >::type
+ InputSet;
+ typedef typename ::boost::mpl::apply_wrap1<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , stack_element
+ >::type
+ StackElements;
+
+ public:
+ //->
+ typedef ::boost::optional<stack_element>
+ optional_stack_element;
+
+ private:
+ typedef ::boost::fusion::pair<next_state_key,state>
+ NextState;
+ typedef ::boost::fusion::pair<push_to_stack_key,optional_stack_element>
+ StackPush;
+
+ public:
+ typedef ::boost::fusion::map<NextState,StackPush>
+ result_map;
+
+ private:
+ // typedef implementation_defined Result;
+ //<-
+ typedef ::boost::optional<result_map>
+ Result;
+ typedef typename ::boost::mpl::apply_wrap2<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , input
+ , Result
+ >::type
+ TransitionMap1;
+ typedef typename ::boost::container_gen<
+ RandomAccessContainerSelector
+ , TransitionMap1
+ >::type
+ Transitions1;
+ typedef ::boost::fusion::map<
+ ::boost::fusion::pair<input_symbol_key,input>
+ , ::boost::fusion::pair<pop_from_stack_key,stack_element>
+ >
+ InputMap;
+ typedef ::std::map<
+ InputMap
+ , Result
+ , _detail::deterministic_pushdown_less<InputMap>
+ >
+ TransitionMap2;
+ typedef typename container_gen<
+ RandomAccessContainerSelector
+ , TransitionMap2
+ >::type
+ Transitions2;
+ //->
+ // typedef implementation_defined Setter1;
+ // typedef implementation_defined Setter2;
+
+ public:
+ typedef Result const& result_type;
+
+ //<-
+ private:
+ class Setter1
+ {
+ dpda_transition_function& _function;
+ state const& _current_state;
+ input const& _i;
+
+ public:
+ Setter1(
+ dpda_transition_function& f
+ , state const& current_state
+ , input const& i
+ );
+
+ void operator=(result_map const& result);
+ };
+
+ class Setter2
+ {
+ dpda_transition_function& _function;
+ state const& _current_state;
+ input const& _i;
+ stack_element const& _e;
+
+ public:
+ Setter2(
+ dpda_transition_function& f
+ , state const& current_state
+ , input const& i
+ , stack_element const& e
+ );
+
+ void operator=(result_map const& result);
+ };
+
+ static Result const _null_state;
+
+ InputSet _inputs;
+ StackElements _stack_elements;
+ Transitions1 _transitions_1;
+ Transitions2 _transitions_2;
+
+ public:
+ //->
+ dpda_transition_function();
+
+ dpda_transition_function(dpda_transition_function const& copy);
+
+ dpda_transition_function&
+ operator=(dpda_transition_function const& copy);
+
+ ::std::size_t get_state_count() const;
+
+ bool recognizes_input(input const& i) const;
+
+ bool recognizes_state(state const& s) const;
+
+ bool recognizes_stack_element(stack_element const& e) const;
+
+ result_type
+ operator()(state const& current_state, input const& i) const;
+
+ result_type
+ operator()(
+ state const& current_state
+ , input const& i
+ , stack_element const& e
+ ) const;
+
+ template <typename Iterator>
+ void
+ make_nontrivial_inputs(
+ state const& current_state
+ , Iterator itr
+ ) const;
+
+ template <typename Iterator>
+ void
+ make_nontrivial_inputs(
+ state const& current_state
+ , stack_element const& e
+ , Iterator itr
+ ) const;
+
+ void
+ set_transition(
+ state const& current_state
+ , input const& i
+ , result_map const& result
+ );
+
+ Setter1 operator()(state const& current_state, input const& i);
+
+ void
+ set_transition(
+ state const& current_state
+ , input const& i
+ , stack_element const& e
+ , result_map const& result
+ );
+
+ Setter2
+ operator()(
+ state const& current_state
+ , input const& i
+ , stack_element const& e
+ );
+
+ void reset(::std::size_t state_count);
+
+ //<-
+ template <
+ typename T0_
+ , typename T1_
+ , typename T2_
+ , typename T3_
+ , typename T4_
+ , typename T5_
+ , typename T6_
+ , typename T7_
+ >
+ friend bool
+ operator==(
+ dpda_transition_function<T0_,T1_,T2_,T3_> const& lhs
+ , dpda_transition_function<T4_,T5_,T6_,T7_> const& rhs
+ );
+ //->
+ };
+
+ //<-
+ template <typename T0, typename T1, typename T2, typename T3>
+ typename dpda_transition_function<T0,T1,T2,T3>::Result const
+ dpda_transition_function<T0,T1,T2,T3>::_null_state = Result();
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ dpda_transition_function<T0,T1,T2,T3>::dpda_transition_function()
+ : _inputs(), _stack_elements(), _transitions_1(), _transitions_2()
+ {
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ dpda_transition_function<T0,T1,T2,T3>::dpda_transition_function(
+ dpda_transition_function const& copy
+ ) : _inputs(copy._inputs)
+ , _stack_elements(copy._stack_elements)
+ , _transitions_1(copy._transitions_1)
+ , _transitions_2(copy._transitions_2)
+ {
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ dpda_transition_function<T0,T1,T2,T3>&
+ dpda_transition_function<T0,T1,T2,T3>::operator=(
+ dpda_transition_function const& copy
+ )
+ {
+ if (this != &copy)
+ {
+ _inputs = copy._inputs;
+ _stack_elements = copy._stack_elements;
+ _transitions_1 = copy._transitions_1;
+ _transitions_2 = copy._transitions_2;
+ }
+
+ return *this;
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ inline ::std::size_t
+ dpda_transition_function<T0,T1,T2,T3>::get_state_count() const
+ {
+ return _transitions_1.size();
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ inline bool
+ dpda_transition_function<T0,T1,T2,T3>::recognizes_input(
+ input const& i
+ ) const
+ {
+ return _inputs.find(i) != _inputs.end();
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ inline bool
+ dpda_transition_function<T0,T1,T2,T3>::recognizes_state(
+ state const& s
+ ) const
+ {
+ return s < _transitions_1.size();
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ inline bool
+ dpda_transition_function<T0,T1,T2,T3>::recognizes_stack_element(
+ stack_element const& e
+ ) const
+ {
+ return _stack_elements.find(e) != _stack_elements.end();
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ inline typename dpda_transition_function<T0,T1,T2,T3>::result_type
+ dpda_transition_function<T0,T1,T2,T3>::operator()(
+ state const& current_state
+ , input const& i
+ ) const
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(recognizes_input(i));
+
+ TransitionMap1 const& t_map = _transitions_1[current_state];
+ typename TransitionMap1::const_iterator map_itr = t_map.find(i);
+ return (map_itr == t_map.end()) ? _null_state : map_itr->second;
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ inline typename dpda_transition_function<T0,T1,T2,T3>::result_type
+ dpda_transition_function<T0,T1,T2,T3>::operator()(
+ state const& current_state
+ , input const& i
+ , stack_element const& e
+ ) const
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(recognizes_input(i));
+ BOOST_ASSERT(recognizes_stack_element(e));
+
+ TransitionMap2 const&
+ t_map = _transitions_2[current_state];
+ typename TransitionMap2::const_iterator
+ map_itr = t_map.find(InputMap(i, e));
+ return (map_itr == t_map.end()) ? _null_state : map_itr->second;
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ template <typename Iterator>
+ void
+ dpda_transition_function<T0,T1,T2,T3>::make_nontrivial_inputs(
+ state const& current_state
+ , Iterator itr
+ ) const
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+
+ TransitionMap1 const& t_map = _transitions_1[current_state];
+ typename TransitionMap1::const_iterator map_end = t_map.end();
+
+ for (
+ typename TransitionMap1::const_iterator map_itr = t_map.begin();
+ map_itr != map_end;
+ ++map_itr
+ )
+ {
+ *itr = map_itr->first;
+ ++itr;
+ }
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ template <typename Iterator>
+ void
+ dpda_transition_function<T0,T1,T2,T3>::make_nontrivial_inputs(
+ state const& current_state
+ , stack_element const& e
+ , Iterator itr
+ ) const
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(recognizes_stack_element(e));
+
+ TransitionMap2 const& t_map = _transitions_2[current_state];
+ typename TransitionMap2::const_iterator map_end = t_map.end();
+
+ for (
+ typename TransitionMap2::const_iterator map_itr = t_map.begin();
+ map_itr != map_end;
+ ++map_itr
+ )
+ {
+ if (
+ ::boost::fusion::at_key<pop_from_stack_key>(map_itr->first)
+ == e
+ )
+ {
+ *itr = boost::fusion::at_key<input_symbol_key>(map_itr->first);
+ ++itr;
+ }
+ }
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ inline void
+ dpda_transition_function<T0,T1,T2,T3>::set_transition(
+ state const& current_state
+ , input const& i
+ , result_map const& result
+ )
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(
+ recognizes_state(::boost::fusion::at_key<next_state_key>(result))
+ );
+
+ _inputs.insert(i);
+
+ if (
+ optional_stack_element const& o_e = ::boost::fusion::at_key<
+ push_to_stack_key
+ >(result)
+ )
+ {
+ _stack_elements.insert(*o_e);
+ }
+
+ _transitions_1[current_state][i] = Result(result);
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ dpda_transition_function<T0,T1,T2,T3>::Setter1::Setter1(
+ dpda_transition_function& f
+ , state const& current_state
+ , input const& i
+ ) : _function(f), _current_state(current_state), _i(i)
+ {
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ void
+ dpda_transition_function<T0,T1,T2,T3>::Setter1::operator=(
+ result_map const& result
+ )
+ {
+ _function.set_transition(_current_state, _i, result);
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ typename dpda_transition_function<T0,T1,T2,T3>::Setter1
+ dpda_transition_function<T0,T1,T2,T3>::operator()(
+ state const& current_state
+ , input const& i
+ )
+ {
+ return Setter1(*this, current_state, i);
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ inline void
+ dpda_transition_function<T0,T1,T2,T3>::set_transition(
+ state const& current_state
+ , input const& i
+ , stack_element const& e
+ , result_map const& result
+ )
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(
+ recognizes_state(::boost::fusion::at_key<next_state_key>(result))
+ );
+
+ _inputs.insert(i);
+ _stack_elements.insert(e);
+
+ if (
+ optional_stack_element const& o_e = ::boost::fusion::at_key<
+ push_to_stack_key
+ >(result)
+ )
+ {
+ _stack_elements.insert(*o_e);
+ }
+
+ _transitions_2[current_state][InputMap(i, e)] = Result(result);
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ dpda_transition_function<T0,T1,T2,T3>::Setter2::Setter2(
+ dpda_transition_function& f
+ , state const& current_state
+ , input const& i
+ , stack_element const& e
+ ) : _function(f), _current_state(current_state), _i(i), _e(e)
+ {
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ void
+ dpda_transition_function<T0,T1,T2,T3>::Setter2::operator=(
+ result_map const& result
+ )
+ {
+ _function.set_transition(_current_state, _i, _e, result);
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ typename dpda_transition_function<T0,T1,T2,T3>::Setter2
+ dpda_transition_function<T0,T1,T2,T3>::operator()(
+ state const& current_state
+ , input const& i
+ , stack_element const& e
+ )
+ {
+ return Setter2(*this, current_state, i, e);
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ void
+ dpda_transition_function<T0,T1,T2,T3>::reset(::std::size_t state_count)
+ {
+ _inputs.clear();
+ _stack_elements.clear();
+ _transitions_1.resize(state_count);
+ _transitions_2.resize(state_count);
+
+ while (state_count)
+ {
+ _transitions_1[--state_count].clear();
+ _transitions_2[state_count].clear();
+ }
+ }
+ //->
+
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ , typename T6
+ , typename T7
+ >
+ bool
+ operator==(
+ dpda_transition_function<T0,T1,T2,T3> const& lhs
+ , dpda_transition_function<T4,T5,T6,T7> const& rhs
+ );
+
+ //<-
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ , typename T6
+ , typename T7
+ >
+ bool
+ operator==(
+ dpda_transition_function<T0,T1,T2,T3> const& lhs
+ , dpda_transition_function<T4,T5,T6,T7> const& rhs
+ )
+ {
+ if (
+ !(lhs._inputs.size() == rhs._inputs.size())
+ && !(lhs._stack_elements.size() == rhs._stack_elements.size())
+ && !(lhs._transitions_1.size() == rhs._transitions_1.size())
+ )
+ {
+ return false;
+ }
+
+ typedef typename dpda_transition_function<T0,T1,T2,T3>::InputSet
+ LHS_InputSet;
+ typedef typename LHS_InputSet::const_iterator
+ LHS_InputSetIterator;
+ typedef typename dpda_transition_function<T4,T5,T6,T7>::InputSet
+ RHS_InputSet;
+ typedef typename RHS_InputSet::const_iterator
+ RHS_InputSetIterator;
+
+ RHS_InputSetIterator rhs_in_end = rhs._inputs.end();
+ LHS_InputSetIterator lhs_in_end = lhs._inputs.end();
+ LHS_InputSetIterator lhs_in_itr = lhs._inputs.begin();
+
+ while (lhs_in_itr != lhs_in_end)
+ {
+ if (rhs._inputs.find(*lhs_in_itr) == rhs_in_end)
+ {
+ return false;
+ }
+
+ ++lhs_in_itr;
+ }
+
+ typedef typename dpda_transition_function<T0,T1,T2,T3>::StackElements
+ LHS_StackElements;
+ typedef typename LHS_StackElements::const_iterator
+ LHS_StackElementsIterator;
+ typedef typename dpda_transition_function<T4,T5,T6,T7>::StackElements
+ RHS_StackElements;
+ typedef typename RHS_StackElements::const_iterator
+ RHS_StackElementsIterator;
+
+ RHS_StackElementsIterator rhs_se_end = rhs._stack_elements.end();
+ LHS_StackElementsIterator lhs_se_end = lhs._stack_elements.end();
+ LHS_StackElementsIterator lhs_se_itr = lhs._stack_elements.begin();
+
+ while (lhs_se_itr != lhs_se_end)
+ {
+ if (rhs._stack_elements.find(*lhs_se_itr) == rhs_se_end)
+ {
+ return false;
+ }
+
+ ++lhs_se_itr;
+ }
+
+ typedef typename dpda_transition_function<T0,T1,T2,T3>::TransitionMap1
+ LHS_TransitionMap1;
+ typedef typename dpda_transition_function<T0,T1,T2,T3>::TransitionMap2
+ LHS_TransitionMap2;
+ typedef typename LHS_TransitionMap1::const_iterator
+ LHS_TransitionMapIterator1;
+ typedef typename LHS_TransitionMap2::const_iterator
+ LHS_TransitionMapIterator2;
+ typedef typename dpda_transition_function<T0,T1,T2,T3>::result_map
+ LHS_ResultMap;
+ typedef typename dpda_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ >::optional_stack_element
+ LHS_OptionalStackElement;
+ typedef typename dpda_transition_function<T4,T5,T6,T7>::TransitionMap1
+ RHS_TransitionMap1;
+ typedef typename dpda_transition_function<T4,T5,T6,T7>::TransitionMap2
+ RHS_TransitionMap2;
+ typedef typename RHS_TransitionMap1::const_iterator
+ RHS_TransitionMapIterator1;
+ typedef typename RHS_TransitionMap2::const_iterator
+ RHS_TransitionMapIterator2;
+ typedef typename dpda_transition_function<T4,T5,T6,T7>::result_map
+ RHS_ResultMap;
+ typedef typename dpda_transition_function<
+ T4
+ , T5
+ , T6
+ , T7
+ >::optional_stack_element
+ RHS_OptionalStackElement;
+
+ LHS_TransitionMapIterator1 lhs_tm1_itr, lhs_tm1_end;
+ LHS_TransitionMapIterator2 lhs_tm2_itr, lhs_tm2_end;
+ RHS_TransitionMapIterator1 rhs_tm1_itr, rhs_tm1_end;
+ RHS_TransitionMapIterator2 rhs_tm2_itr, rhs_tm2_end;
+ std::size_t s = lhs._transitions_1.size();
+
+ while (s)
+ {
+ LHS_TransitionMap1 const& lhs_tm1 = lhs._transitions_1[--s];
+ RHS_TransitionMap1 const& rhs_tm1 = rhs._transitions_1[s];
+ LHS_TransitionMap2 const& lhs_tm2 = lhs._transitions_2[s];
+ RHS_TransitionMap2 const& rhs_tm2 = rhs._transitions_2[s];
+
+ if (
+ !(lhs_tm1.size() == rhs_tm1.size())
+ || !(lhs_tm2.size() == rhs_tm2.size())
+ )
+ {
+ return false;
+ }
+
+ lhs_tm1_end = lhs_tm1.end();
+ rhs_tm1_end = rhs_tm1.end();
+
+ for (
+ lhs_tm1_itr = lhs_tm1.begin();
+ lhs_tm1_itr != lhs_tm1_end;
+ ++lhs_tm1_itr
+ )
+ {
+ rhs_tm1_itr = rhs_tm1.find(lhs_tm1_itr->first);
+
+ if (rhs_tm1_itr == rhs_tm1_end)
+ {
+ return false;
+ }
+
+ LHS_ResultMap const& lhs_r_map = *(lhs_tm1_itr->second);
+ RHS_ResultMap const& rhs_r_map = *(rhs_tm1_itr->second);
+
+ if (
+ LHS_OptionalStackElement const&
+ lhs_o_e
+ = ::boost::fusion::at_key<push_to_stack_key>(
+ lhs_r_map
+ )
+ )
+ {
+ if (
+ RHS_OptionalStackElement const&
+ rhs_o_e
+ = ::boost::fusion::at_key<push_to_stack_key>(
+ rhs_r_map
+ )
+ )
+ {
+ if (*lhs_o_e != *rhs_o_e)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if (::boost::fusion::at_key<push_to_stack_key>(rhs_r_map))
+ {
+ return false;
+ }
+ }
+
+ lhs_tm2_end = lhs_tm2.end();
+ rhs_tm2_end = rhs_tm2.end();
+
+ for (
+ lhs_tm2_itr = lhs_tm2.begin();
+ lhs_tm2_itr != lhs_tm2_end;
+ ++lhs_tm2_itr
+ )
+ {
+ rhs_tm2_itr = rhs_tm2.find(lhs_tm2_itr->first);
+
+ if (rhs_tm2_itr == rhs_tm2_end)
+ {
+ return false;
+ }
+
+ LHS_ResultMap const& lhs_r_map = *(lhs_tm1_itr->second);
+ RHS_ResultMap const& rhs_r_map = *(rhs_tm1_itr->second);
+
+ if (
+ LHS_OptionalStackElement const&
+ lhs_o_e
+ = ::boost::fusion::at_key<push_to_stack_key>(
+ lhs_r_map
+ )
+ )
+ {
+ if (
+ RHS_OptionalStackElement const&
+ rhs_o_e
+ = ::boost::fusion::at_key<push_to_stack_key>(
+ rhs_r_map
+ )
+ )
+ {
+ if (*lhs_o_e != *rhs_o_e)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if (::boost::fusion::at_key<push_to_stack_key>(rhs_r_map))
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+ //->
+
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ , typename T6
+ , typename T7
+ >
+ bool
+ operator!=(
+ dpda_transition_function<T0,T1,T2,T3> const& lhs
+ , dpda_transition_function<T4,T5,T6,T7> const& rhs
+ );
+
+ //<-
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ , typename T6
+ , typename T7
+ >
+ inline bool
+ operator!=(
+ dpda_transition_function<T0,T1,T2,T3> const& lhs
+ , dpda_transition_function<T4,T5,T6,T7> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_TRANSITION_FUNCTION_DPDA_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/transition_function/input_rule.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/transition_function/input_rule.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,91 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_TRANSITION_FUNCTION_INPUT_RULE_HPP_INCLUDED
+#define BOOST_AUTOMATA_TRANSITION_FUNCTION_INPUT_RULE_HPP_INCLUDED
+
+#include <boost/mpl/if.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+
+//[reference__input_rule_transition_function
+namespace boost { namespace automata {
+ //<-
+ namespace _detail {
+
+ template <typename State>
+ struct in_place_input_rule_transition_function
+ {
+ template <typename InputRule>
+ bool
+ operator()(
+ State& current_state
+ , InputRule const& input_rule
+ ) const;
+ };
+
+ template <typename State>
+ template <typename InputRule>
+ inline bool
+ in_place_input_rule_transition_function<State>::operator()(
+ State& current_state
+ , InputRule const& input_rule
+ ) const
+ {
+ return input_rule(current_state);
+ }
+
+ template <typename State>
+ struct new_state_input_rule_transition_function
+ {
+ template <typename InputRule>
+ State
+ operator()(
+ State const& current_state
+ , InputRule const& input_rule
+ ) const;
+ };
+
+ template <typename State>
+ template <typename InputRule>
+ inline State
+ new_state_input_rule_transition_function<State>::operator()(
+ State const& current_state
+ , InputRule const& input_rule
+ ) const
+ {
+ return input_rule(current_state);
+ }
+ } // namespace _detail
+ //->
+
+ template <typename State, bool ModifiesInPlace = false>
+ struct input_rule_transition_function
+ //<-
+ : ::boost::mpl::if_c<
+ ModifiesInPlace
+ , _detail::in_place_input_rule_transition_function<State>
+ , _detail::new_state_input_rule_transition_function<State>
+ >::type
+ //->
+ {
+ typedef transition_function_tag
+ tag;
+ typedef // implementation_defined
+ //<-
+ typename ::boost::mpl::if_c<
+ ModifiesInPlace
+ , bool
+ , State
+ >::type
+ //->
+ result_type;
+ typedef State
+ state;
+ };
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_TRANSITION_FUNCTION_INPUT_RULE_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/transition_function/mapped_input.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/transition_function/mapped_input.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,504 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_TRANSITION_FUNCTION_MAPPED_INPUT_HPP_INCLUDED
+#define BOOST_AUTOMATA_TRANSITION_FUNCTION_MAPPED_INPUT_HPP_INCLUDED
+
+#include <boost/preprocessor/comparison/less.hpp>
+#include <boost/parameter.hpp>
+#include <boost/parameter/preprocessor.hpp>
+
+#if BOOST_PP_LESS(BOOST_PARAMETER_MAX_ARITY, 3)
+#error Set BOOST_PARAMETER_MAX_ARITY to 3 or more.
+#endif
+
+#include <boost/config.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/utility/container_gen.hpp>
+#include <boost/utility/associative_container_gen.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/keyword/template.hpp>
+#include <boost/assert.hpp>
+
+//[reference__mapped_input_transition_function
+namespace boost { namespace automata {
+
+ template <
+ typename T0
+ , typename T1 = ::boost::parameter::void_
+ , typename T2 = ::boost::parameter::void_
+ >
+ class mapped_input_transition_function
+ {
+ //<-
+ typedef typename ::boost::parameter::parameters<
+ ::boost::parameter::required<keyword::tag::_Input>
+ , ::boost::parameter::optional<
+ keyword::tag::_AssociativeContainerSelector
+ >
+ , ::boost::parameter::optional<
+ keyword::tag::_RandomAccessContainerSelector
+ >
+ >::BOOST_NESTED_TEMPLATE bind<
+ T0
+ , T1
+ , T2
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+ , ::boost::parameter::void_
+#endif
+ >::type
+ Args;
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_AssociativeContainerSelector
+ , ::boost::mapS
+ >::type
+ AssociativeContainerSelector;
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_RandomAccessContainerSelector
+ , ::boost::vecS
+ >::type
+ RandomAccessContainerSelector;
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_Input
+ >::type
+ input;
+ //->
+
+ public:
+ typedef mapped_input_transition_function_tag
+ tag;
+ typedef ::std::size_t
+ state;
+ typedef state
+ result_type;
+ typedef state
+ first_argument_type;
+ typedef // implementation_defined
+ // <-
+ input
+ // ->
+ second_argument_type;
+
+ private:
+ // typedef implementation_defined Setter;
+ //<-
+ typedef typename ::boost::mpl::apply_wrap1<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , input
+ >::type
+ InputSet;
+ typedef typename ::boost::mpl::apply_wrap2<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , input
+ , state
+ >::type
+ TransitionMap;
+ typedef typename ::boost::container_gen<
+ RandomAccessContainerSelector
+ , TransitionMap
+ >::type
+ Transitions;
+
+ class Setter
+ {
+ mapped_input_transition_function& _function;
+ first_argument_type const& _current_state;
+ second_argument_type const& _i;
+
+ public:
+ Setter(
+ mapped_input_transition_function& f
+ , first_argument_type const& current_state
+ , second_argument_type const& i
+ );
+
+ void operator=(result_type next_state);
+ };
+
+ Transitions _transitions;
+ InputSet _inputs;
+ //->
+
+ public:
+ mapped_input_transition_function();
+
+ mapped_input_transition_function(
+ mapped_input_transition_function const& copy
+ );
+
+ mapped_input_transition_function&
+ operator=(mapped_input_transition_function const& copy);
+
+ bool recognizes_input(second_argument_type const& i) const;
+
+ bool recognizes_state(first_argument_type const& s) const;
+
+ ::std::size_t get_state_count() const;
+
+ result_type const&
+ operator()(
+ first_argument_type const& current_state
+ , second_argument_type const& i
+ ) const;
+
+ template <typename Iterator>
+ void
+ make_nontrivial_inputs(
+ first_argument_type const& current_state
+ , Iterator itr
+ ) const;
+
+ void
+ set_transition(
+ first_argument_type const& current_state
+ , second_argument_type const& i
+ , result_type next_state
+ );
+
+ Setter
+ operator()(
+ first_argument_type const& current_state
+ , second_argument_type const& i
+ );
+
+ void reset(::std::size_t state_count);
+
+ //<-
+ template <
+ typename T0_
+ , typename T1_
+ , typename T2_
+ , typename T3_
+ , typename T4_
+ , typename T5_
+ >
+ friend bool
+ operator==(
+ mapped_input_transition_function<T0_,T1_,T2_> const& lhs
+ , mapped_input_transition_function<T3_,T4_,T5_> const& rhs
+ );
+ //->
+ };
+
+ //<-
+ template <typename T0, typename T1, typename T2>
+ mapped_input_transition_function<
+ T0
+ , T1
+ , T2
+ >::mapped_input_transition_function() : _transitions(), _inputs()
+ {
+ }
+
+ template <typename T0, typename T1, typename T2>
+ mapped_input_transition_function<
+ T0
+ , T1
+ , T2
+ >::mapped_input_transition_function(
+ mapped_input_transition_function const& copy
+ ) : _transitions(copy._transitions), _inputs(copy._inputs)
+ {
+ }
+
+ template <typename T0, typename T1, typename T2>
+ mapped_input_transition_function<T0,T1,T2>&
+ mapped_input_transition_function<T0,T1,T2>::operator=(
+ mapped_input_transition_function const& copy
+ )
+ {
+ if (this != &copy)
+ {
+ _transitions = copy._transitions;
+ _inputs = copy._inputs;
+ }
+
+ return *this;
+ }
+
+ template <typename T0, typename T1, typename T2>
+ inline bool
+ mapped_input_transition_function<T0,T1,T2>::recognizes_input(
+ second_argument_type const& i
+ ) const
+ {
+ return _inputs.find(i) != _inputs.end();
+ }
+
+ template <typename T0, typename T1, typename T2>
+ inline bool
+ mapped_input_transition_function<T0,T1,T2>::recognizes_state(
+ first_argument_type const& s
+ ) const
+ {
+ return s < _transitions.size();
+ }
+
+ template <typename T0, typename T1, typename T2>
+ inline ::std::size_t
+ mapped_input_transition_function<T0,T1,T2>::get_state_count() const
+ {
+ return _transitions.size();
+ }
+
+ template <typename T0, typename T1, typename T2>
+ inline typename mapped_input_transition_function<
+ T0
+ , T1
+ , T2
+ >::result_type const&
+ mapped_input_transition_function<T0,T1,T2>::operator()(
+ first_argument_type const& current_state
+ , second_argument_type const& i
+ ) const
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(recognizes_input(i));
+
+ TransitionMap const& t_map = _transitions[current_state];
+ typename TransitionMap::const_iterator map_itr = t_map.find(i);
+ return (map_itr == t_map.end()) ? current_state : map_itr->second;
+ }
+
+ template <typename T0, typename T1, typename T2>
+ template <typename Iterator>
+ void
+ mapped_input_transition_function<T0,T1,T2>::make_nontrivial_inputs(
+ first_argument_type const& current_state
+ , Iterator itr
+ ) const
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+
+ TransitionMap const& t_map = _transitions[current_state];
+ typename TransitionMap::const_iterator map_end = t_map.end();
+
+ for (
+ typename TransitionMap::const_iterator map_itr = t_map.begin();
+ map_itr != map_end;
+ ++map_itr
+ )
+ {
+ *itr = map_itr->first;
+ ++itr;
+ }
+ }
+
+ template <typename T0, typename T1, typename T2>
+ inline void
+ mapped_input_transition_function<T0,T1,T2>::set_transition(
+ first_argument_type const& current_state
+ , second_argument_type const& i
+ , result_type next_state
+ )
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(recognizes_state(next_state));
+
+ _inputs.insert(i);
+ _transitions[current_state][i] = next_state;
+ }
+
+ template <typename T0, typename T1, typename T2>
+ mapped_input_transition_function<T0,T1,T2>::Setter::Setter(
+ mapped_input_transition_function& f
+ , first_argument_type const& current_state
+ , second_argument_type const& i
+ ) : _function(f), _current_state(current_state), _i(i)
+ {
+ }
+
+ template <typename T0, typename T1, typename T2>
+ void
+ mapped_input_transition_function<T0,T1,T2>::Setter::operator=(
+ result_type next_state
+ )
+ {
+ _function.set_transition(_current_state, _i, next_state);
+ }
+
+ template <typename T0, typename T1, typename T2>
+ typename mapped_input_transition_function<T0,T1,T2>::Setter
+ mapped_input_transition_function<T0,T1,T2>::operator()(
+ first_argument_type const& current_state
+ , second_argument_type const& i
+ )
+ {
+ return Setter(*this, current_state, i);
+ }
+
+ template <typename T0, typename T1, typename T2>
+ void
+ mapped_input_transition_function<T0,T1,T2>::reset(
+ ::std::size_t state_count
+ )
+ {
+ _inputs.clear();
+ _transitions.resize(state_count);
+
+ while (state_count)
+ {
+ _transitions[--state_count].clear();
+ }
+ }
+ //->
+
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ >
+ bool
+ operator==(
+ mapped_input_transition_function<T0,T1,T2> const& lhs
+ , mapped_input_transition_function<T3,T4,T5> const& rhs
+ );
+
+ //<-
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ >
+ bool
+ operator==(
+ mapped_input_transition_function<T0,T1,T2> const& lhs
+ , mapped_input_transition_function<T3,T4,T5> const& rhs
+ )
+ {
+ if (
+ !(lhs.get_state_count() == rhs.get_state_count())
+ || !(lhs._inputs.size() == rhs._inputs.size())
+ )
+ {
+ return false;
+ }
+
+ typedef typename mapped_input_transition_function<T0,T1,T2>::InputSet
+ LHS_InputSet;
+ typedef typename LHS_InputSet::const_iterator
+ LHS_InputSetIterator;
+ typedef typename mapped_input_transition_function<T3,T4,T5>::InputSet
+ RHS_InputSet;
+ typedef typename RHS_InputSet::const_iterator
+ RHS_InputSetIterator;
+
+ RHS_InputSetIterator r_end = rhs._inputs.end();
+ LHS_InputSetIterator l_end = lhs._inputs.end();
+ LHS_InputSetIterator l_itr = lhs._inputs.begin();
+
+ while (l_itr != l_end)
+ {
+ if (rhs._inputs.find(*l_itr) == r_end)
+ {
+ return false;
+ }
+
+ ++l_itr;
+ }
+
+ typedef typename mapped_input_transition_function<
+ T0
+ , T1
+ , T2
+ >::TransitionMap
+ LHS_TransitionMap;
+ typedef typename LHS_TransitionMap::const_iterator
+ LHS_TransitionMapIterator;
+ typedef typename mapped_input_transition_function<
+ T3
+ , T4
+ , T5
+ >::TransitionMap
+ RHS_TransitionMap;
+ typedef typename RHS_TransitionMap::const_iterator
+ RHS_TransitionMapIterator;
+
+ LHS_TransitionMapIterator l_map_itr;
+ LHS_TransitionMapIterator l_map_end;
+ RHS_TransitionMapIterator r_map_itr;
+ RHS_TransitionMapIterator r_map_end;
+ ::std::size_t s = lhs._transitions.size();
+
+ while (s)
+ {
+ LHS_TransitionMap const& lhs_map = lhs._transitions[--s];
+ RHS_TransitionMap const& rhs_map = rhs._transitions[s];
+
+ l_map_end = lhs_map.end();
+ r_map_end = rhs_map.end();
+
+ for (
+ l_map_itr = lhs_map.begin();
+ l_map_itr != l_map_end;
+ ++l_map_itr
+ )
+ {
+ r_map_itr = rhs_map.find(l_map_itr->first);
+
+ if (
+ (r_map_itr == r_map_end)
+ || !(r_map_itr->second == l_map_itr->second)
+ )
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+ //->
+
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ >
+ bool
+ operator!=(
+ mapped_input_transition_function<T0,T1,T2> const& lhs
+ , mapped_input_transition_function<T3,T4,T5> const& rhs
+ );
+
+ //<-
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ >
+ inline bool
+ operator!=(
+ mapped_input_transition_function<T0,T1,T2> const& lhs
+ , mapped_input_transition_function<T3,T4,T5> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_TRANSITION_FUNCTION_MAPPED_INPUT_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/transition_function/mapped_input_tabular.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/transition_function/mapped_input_tabular.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,499 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_TRANSITION_FUNCTION_MAPPED_INPUT_TABULAR_HPP_INCLUDED
+#define BOOST_AUTOMATA_TRANSITION_FUNCTION_MAPPED_INPUT_TABULAR_HPP_INCLUDED
+
+#include <boost/preprocessor/comparison/less.hpp>
+#include <boost/parameter.hpp>
+#include <boost/parameter/preprocessor.hpp>
+
+#if BOOST_PP_LESS(BOOST_PARAMETER_MAX_ARITY, 3)
+#error Set BOOST_PARAMETER_MAX_ARITY to 3 or more.
+#endif
+
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/utility/associative_container_gen.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/concept_check.hpp>
+#include <boost/automata/keyword/template.hpp>
+#include <boost/assert.hpp>
+
+//[reference__mapped_input_tabular_transition_function
+namespace boost { namespace automata {
+
+ template <
+ typename T0
+ , typename T1
+ , typename T2 = ::boost::parameter::void_
+ >
+ class mapped_input_tabular_transition_function
+ {
+ // typedef implementation_defined Function;
+ //<-
+ typedef typename ::boost::parameter::parameters<
+ ::boost::parameter::required<keyword::tag::_Input>
+ , ::boost::parameter::required<keyword::tag::_Function>
+ , ::boost::parameter::optional<
+ keyword::tag::_AssociativeContainerSelector
+ >
+ >::BOOST_NESTED_TEMPLATE bind<
+ T0
+ , T1
+ , T2
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+ , ::boost::parameter::void_
+#endif
+ >::type
+ Args;
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_Function
+ >::type
+ Function;
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_AssociativeContainerSelector
+ , ::boost::mapS
+ >::type
+ AssociativeContainerSelector;
+ //->
+
+ BOOST_CONCEPT_ASSERT((TabularTransitionFunction<Function>));
+
+ public:
+ typedef mapped_input_tabular_transition_function_tag
+ tag;
+ typedef typename Function::state
+ state;
+ typedef typename Function::result_type
+ result_type;
+ typedef typename Function::first_argument_type
+ first_argument_type;
+ typedef // implementation_defined
+ //<-
+ typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_Input
+ >::type
+ //->
+ second_argument_type;
+
+ private:
+ // typedef implementation_defined Setter;
+ //<-
+ typedef typename ::boost::mpl::apply_wrap2<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , second_argument_type
+ , typename Function::second_argument_type
+ >::type
+ InputMap;
+
+ class Setter
+ {
+ mapped_input_tabular_transition_function& _function;
+ first_argument_type _current_state;
+ second_argument_type _i;
+
+ public:
+ Setter(
+ mapped_input_tabular_transition_function& f
+ , first_argument_type current_state
+ , second_argument_type i
+ );
+
+ void operator=(result_type next_state);
+ };
+
+ Function _function;
+ InputMap _input_map;
+ //->
+
+ public:
+ mapped_input_tabular_transition_function();
+
+ mapped_input_tabular_transition_function(
+ mapped_input_tabular_transition_function const& copy
+ );
+
+ mapped_input_tabular_transition_function&
+ operator=(mapped_input_tabular_transition_function const& copy);
+
+ bool recognizes_input(second_argument_type i) const;
+
+ bool recognizes_state(first_argument_type s) const;
+
+ ::std::size_t get_state_count() const;
+
+ result_type
+ operator()(
+ first_argument_type current_state
+ , second_argument_type i
+ ) const;
+
+ template <typename Iterator>
+ void
+ make_nontrivial_inputs(
+ first_argument_type current_state
+ , Iterator itr
+ ) const;
+
+ void
+ set_transition(
+ first_argument_type current_state
+ , second_argument_type i
+ , result_type next_state
+ );
+
+ Setter
+ operator()(
+ first_argument_type current_state
+ , second_argument_type i
+ );
+
+ template <typename Iterator>
+ void reset(::std::size_t state_count, Iterator itr, Iterator itr_end);
+
+ //<-
+ template <
+ typename T0_
+ , typename T1_
+ , typename T2_
+ , typename T3_
+ , typename T4_
+ , typename T5_
+ >
+ friend bool
+ operator==(
+ mapped_input_tabular_transition_function<
+ T0_
+ , T1_
+ , T2_
+ > const& lhs
+ , mapped_input_tabular_transition_function<
+ T3_
+ , T4_
+ , T5_
+ > const& rhs
+ );
+ //->
+ };
+
+ //<-
+ template <typename T0, typename T1, typename T2>
+ mapped_input_tabular_transition_function<
+ T0
+ , T1
+ , T2
+ >::mapped_input_tabular_transition_function() : _function(), _input_map()
+ {
+ }
+
+ template <typename T0, typename T1, typename T2>
+ mapped_input_tabular_transition_function<
+ T0
+ , T1
+ , T2
+ >::mapped_input_tabular_transition_function(
+ mapped_input_tabular_transition_function const& copy
+ ) : _function(copy._function), _input_map(copy._input_map)
+ {
+ }
+
+ template <typename T0, typename T1, typename T2>
+ mapped_input_tabular_transition_function<T0,T1,T2>&
+ mapped_input_tabular_transition_function<T0,T1,T2>::operator=(
+ mapped_input_tabular_transition_function const& copy
+ )
+ {
+ if (this != &copy)
+ {
+ _function = copy._function;
+ _input_map = copy._input_map;
+ }
+
+ return *this;
+ }
+
+ template <typename T0, typename T1, typename T2>
+ inline bool
+ mapped_input_tabular_transition_function<T0,T1,T2>::recognizes_input(
+ second_argument_type i
+ ) const
+ {
+ return _input_map.find(i) != _input_map.end();
+ }
+
+ template <typename T0, typename T1, typename T2>
+ inline bool
+ mapped_input_tabular_transition_function<T0,T1,T2>::recognizes_state(
+ first_argument_type s
+ ) const
+ {
+ return _function.recognizes_state(s);
+ }
+
+ template <typename T0, typename T1, typename T2>
+ inline ::std::size_t
+ mapped_input_tabular_transition_function<
+ T0
+ , T1
+ , T2
+ >::get_state_count() const
+ {
+ return _function.get_state_count();
+ }
+
+ template <typename T0, typename T1, typename T2>
+ inline typename mapped_input_tabular_transition_function<
+ T0
+ , T1
+ , T2
+ >::result_type
+ mapped_input_tabular_transition_function<T0,T1,T2>::operator()(
+ first_argument_type current_state
+ , second_argument_type i
+ ) const
+ {
+ BOOST_ASSERT(recognizes_input(i));
+
+ return _function(current_state, _input_map.find(i)->second);
+ }
+
+ template <typename T0, typename T1, typename T2>
+ template <typename Iterator>
+ void
+ mapped_input_tabular_transition_function<
+ T0
+ , T1
+ , T2
+ >::make_nontrivial_inputs(
+ first_argument_type current_state
+ , Iterator itr
+ ) const
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+
+ typename InputMap::const_iterator map_end = _input_map.end();
+
+ for (
+ typename InputMap::const_iterator map_itr = _input_map.begin();
+ map_itr != map_end;
+ ++map_itr
+ )
+ {
+ if (current_state != _function(current_state, map_itr->second))
+ {
+ *itr = map_itr->first;
+ ++itr;
+ }
+ }
+ }
+
+ template <typename T0, typename T1, typename T2>
+ inline void
+ mapped_input_tabular_transition_function<T0,T1,T2>::set_transition(
+ first_argument_type current_state
+ , second_argument_type i
+ , result_type next_state
+ )
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(recognizes_input(i));
+ BOOST_ASSERT(recognizes_state(next_state));
+
+ _function.set_transition(
+ current_state
+ , _input_map.find(i)->second
+ , next_state
+ );
+ }
+
+ template <typename T0, typename T1, typename T2>
+ mapped_input_tabular_transition_function<T0,T1,T2>::Setter::Setter(
+ mapped_input_tabular_transition_function& f
+ , first_argument_type current_state
+ , second_argument_type i
+ ) : _function(f), _current_state(current_state), _i(i)
+ {
+ }
+
+ template <typename T0, typename T1, typename T2>
+ void
+ mapped_input_tabular_transition_function<T0,T1,T2>::Setter::operator=(
+ result_type next_state
+ )
+ {
+ _function.set_transition(_current_state, _i, next_state);
+ }
+
+ template <typename T0, typename T1, typename T2>
+ typename mapped_input_tabular_transition_function<T0,T1,T2>::Setter
+ mapped_input_tabular_transition_function<T0,T1,T2>::operator()(
+ first_argument_type current_state
+ , second_argument_type i
+ )
+ {
+ return Setter(*this, current_state, i);
+ }
+
+ template <typename T0, typename T1, typename T2>
+ template <typename Iterator>
+ void
+ mapped_input_tabular_transition_function<T0,T1,T2>::reset(
+ ::std::size_t state_count
+ , Iterator itr
+ , Iterator itr_end
+ )
+ {
+ _input_map.clear();
+
+ ::std::size_t i = std::size_t();
+
+ while (itr != itr_end)
+ {
+ if (_input_map.find(*itr) == _input_map.end())
+ {
+ _input_map[*itr] = i;
+ ++i;
+ }
+
+ ++itr;
+ }
+
+ _function.reset(state_count, i);
+ }
+ //->
+
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ >
+ bool
+ operator==(
+ mapped_input_tabular_transition_function<T0,T1,T2> const& lhs
+ , mapped_input_tabular_transition_function<T3,T4,T5> const& rhs
+ );
+
+ //<-
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ >
+ bool
+ operator==(
+ mapped_input_tabular_transition_function<T0,T1,T2> const& lhs
+ , mapped_input_tabular_transition_function<T3,T4,T5> const& rhs
+ )
+ {
+ if (
+ !(lhs.get_state_count() == rhs.get_state_count())
+ || !(lhs._input_map.size() == rhs._input_map.size())
+ )
+ {
+ return false;
+ }
+
+ typedef typename mapped_input_tabular_transition_function<
+ T0
+ , T1
+ , T2
+ >::InputMap
+ LHS_InputMap;
+ typedef typename LHS_InputMap::const_iterator
+ LHS_InputMapIterator;
+ typedef typename mapped_input_tabular_transition_function<
+ T3
+ , T4
+ , T5
+ >::InputMap
+ RHS_InputMap;
+ typedef typename RHS_InputMap::const_iterator
+ RHS_InputMapIterator;
+
+ RHS_InputMapIterator r_end = rhs._input_map.end();
+ LHS_InputMapIterator l_end = lhs._input_map.end();
+ LHS_InputMapIterator l_itr = lhs._input_map.begin();
+
+ while (l_itr != l_end)
+ {
+ if (rhs._input_map.find(l_itr->first) == r_end)
+ {
+ return false;
+ }
+
+ ++l_itr;
+ }
+
+ ::std::size_t s = lhs.get_state_count();
+
+ while (s)
+ {
+ --s;
+
+ for (l_itr = lhs._input_map.begin(); l_itr != l_end; ++l_itr)
+ {
+ if (
+ lhs._function(s, l_itr->first)
+ != rhs._function(s, l_itr->first)
+ )
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+ //->
+
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ >
+ bool
+ operator!=(
+ mapped_input_tabular_transition_function<T0,T1,T2> const& lhs
+ , mapped_input_tabular_transition_function<T3,T4,T5> const& rhs
+ );
+
+ //<-
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ >
+ inline bool
+ operator!=(
+ mapped_input_tabular_transition_function<T0,T1,T2> const& lhs
+ , mapped_input_tabular_transition_function<T3,T4,T5> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_TRANSITION_FUNCTION_MAPPED_INPUT_TABULAR_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/transition_function/matrix.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/transition_function/matrix.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,365 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_TRANSITION_FUNCTION_MATRIX_HPP_INCLUDED
+#define BOOST_AUTOMATA_TRANSITION_FUNCTION_MATRIX_HPP_INCLUDED
+
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/concept_check.hpp>
+#include <boost/assert.hpp>
+
+//[reference__matrix_transition_function
+namespace boost { namespace automata {
+
+ template <typename StateInputMatrix>
+ class matrix_transition_function
+ {
+ BOOST_CONCEPT_ASSERT((TransitionFunctionMatrix<StateInputMatrix>));
+
+ public:
+ typedef tabular_transition_function_tag tag;
+ typedef typename StateInputMatrix::value_type state;
+ typedef state result_type;
+ typedef state first_argument_type;
+ typedef state second_argument_type;
+
+ private:
+ // typedef implementation_defined Setter;
+ //<-
+ class Setter
+ {
+ matrix_transition_function& _function;
+ first_argument_type const _current_state;
+ second_argument_type const _i;
+
+ public:
+ Setter(
+ matrix_transition_function& f
+ , first_argument_type current_state
+ , second_argument_type i
+ );
+
+ void operator=(result_type next_state);
+ };
+
+ StateInputMatrix _transition_matrix;
+
+ // The TransitionFunctionMatrix concept does not require the presence
+ // of size accessors, so the matrix_transition_function class template
+ // must keep track of the dimensions itself.
+ ::std::size_t _state_count;
+ ::std::size_t _input_count;
+ //->
+
+ public:
+ matrix_transition_function();
+
+ matrix_transition_function(matrix_transition_function const& copy);
+
+ matrix_transition_function&
+ operator=(matrix_transition_function const& copy);
+
+ bool recognizes_input(second_argument_type i) const;
+
+ bool recognizes_state(first_argument_type s) const;
+
+ ::std::size_t const& get_state_count() const;
+
+ result_type
+ operator()(
+ first_argument_type current_state
+ , second_argument_type i
+ ) const;
+
+ template <typename Iterator>
+ void
+ make_nontrivial_inputs(
+ first_argument_type current_state
+ , Iterator itr
+ ) const;
+
+ void
+ set_transition(
+ first_argument_type current_state
+ , second_argument_type i
+ , result_type next_state
+ );
+
+ Setter
+ operator()(
+ first_argument_type current_state
+ , second_argument_type i
+ );
+
+ void reset(::std::size_t state_count, ::std::size_t input_count);
+
+ //<-
+ template <typename T0, typename T1>
+ friend bool
+ operator==(
+ matrix_transition_function<T0> const& lhs
+ , matrix_transition_function<T1> const& rhs
+ );
+ //->
+ };
+
+ //<-
+ template <typename StateInputMatrix>
+ matrix_transition_function<StateInputMatrix>::matrix_transition_function()
+ : _transition_matrix(), _state_count(), _input_count()
+ {
+ }
+
+ template <typename StateInputMatrix>
+ matrix_transition_function<StateInputMatrix>::matrix_transition_function(
+ matrix_transition_function const& copy
+ ) : _transition_matrix(_state_count, _input_count)
+ , _state_count(copy._state_count)
+ , _input_count(copy._input_count)
+ {
+ std::size_t s = _state_count;
+ std::size_t i;
+
+ while (s)
+ {
+ --s;
+ i = _input_count;
+
+ while (i)
+ {
+ --i;
+ _transition_matrix(s, i) = copy._transition_matrix(s, i);
+ }
+ }
+ }
+
+ template <typename StateInputMatrix>
+ matrix_transition_function<StateInputMatrix>&
+ matrix_transition_function<StateInputMatrix>::operator=(
+ matrix_transition_function const& copy
+ )
+ {
+ if (this != &copy)
+ {
+ _state_count = copy._state_count;
+ _input_count = copy._input_count;
+ _transition_matrix.resize(_state_count, _input_count);
+
+ ::std::size_t s = _state_count;
+ ::std::size_t i;
+
+ while (s)
+ {
+ --s;
+ i = _input_count;
+
+ while (i)
+ {
+ --i;
+ _transition_matrix(s, i) = copy._transition_matrix(s, i);
+ }
+ }
+ }
+
+ return *this;
+ }
+
+ template <typename StateInputMatrix>
+ inline bool
+ matrix_transition_function<StateInputMatrix>::recognizes_input(
+ second_argument_type const i
+ ) const
+ {
+ return i < _input_count;
+ }
+
+ template <typename StateInputMatrix>
+ inline bool
+ matrix_transition_function<StateInputMatrix>::recognizes_state(
+ first_argument_type const s
+ ) const
+ {
+ return s < _state_count;
+ }
+
+ template <typename StateInputMatrix>
+ inline ::std::size_t const&
+ matrix_transition_function<StateInputMatrix>::get_state_count() const
+ {
+ return _state_count;
+ }
+
+ template <typename StateInputMatrix>
+ inline typename matrix_transition_function<StateInputMatrix>::result_type
+ matrix_transition_function<StateInputMatrix>::operator()(
+ first_argument_type const current_state
+ , second_argument_type const i
+ ) const
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(recognizes_input(i));
+
+ return _transition_matrix(current_state, i);
+ }
+
+ template <typename StateInputMatrix>
+ template <typename Iterator>
+ void
+ matrix_transition_function<StateInputMatrix>::make_nontrivial_inputs(
+ first_argument_type const current_state
+ , Iterator itr
+ ) const
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+
+ for (::std::size_t i = ::std::size_t(); i < _input_count; ++i)
+ {
+ if (current_state != _transition_matrix(current_state, i))
+ {
+ *itr = i;
+ ++itr;
+ }
+ }
+ }
+
+ template <typename StateInputMatrix>
+ inline void
+ matrix_transition_function<StateInputMatrix>::set_transition(
+ first_argument_type const current_state
+ , second_argument_type const i
+ , result_type const next_state
+ )
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(recognizes_input(i));
+ BOOST_ASSERT(recognizes_state(next_state));
+
+ _transition_matrix(current_state, i) = next_state;
+ }
+
+ template <typename StateInputMatrix>
+ matrix_transition_function<StateInputMatrix>::Setter::Setter(
+ matrix_transition_function& f
+ , first_argument_type const current_state
+ , second_argument_type const i
+ ) : _function(f), _current_state(current_state), _i(i)
+ {
+ }
+
+ template <typename StateInputMatrix>
+ inline void
+ matrix_transition_function<StateInputMatrix>::Setter::operator=(
+ result_type const next_state
+ )
+ {
+ _function.set_transition(_current_state, _i, next_state);
+ }
+
+ template <typename StateInputMatrix>
+ typename matrix_transition_function<StateInputMatrix>::Setter
+ matrix_transition_function<StateInputMatrix>::operator()(
+ first_argument_type const current_state
+ , second_argument_type const i
+ )
+ {
+ return Setter(*this, current_state, i);
+ }
+
+ template <typename StateInputMatrix>
+ void
+ matrix_transition_function<StateInputMatrix>::reset(
+ ::std::size_t state_count
+ , ::std::size_t input_count
+ )
+ {
+ _state_count = state_count;
+ _input_count = input_count;
+ _transition_matrix.resize(state_count, input_count);
+
+ while (state_count)
+ {
+ --state_count;
+ input_count = _input_count;
+
+ while (input_count)
+ {
+ _transition_matrix(state_count, --input_count) = state_count;
+ }
+ }
+ }
+ //->
+
+ template <typename StateInputMatrix, typename OtherStateInputMatrix>
+ bool
+ operator==(
+ matrix_transition_function<StateInputMatrix> const& lhs
+ , matrix_transition_function<OtherStateInputMatrix> const& rhs
+ );
+
+ //<-
+ template <typename StateInputMatrix, typename OtherStateInputMatrix>
+ bool
+ operator==(
+ matrix_transition_function<StateInputMatrix> const& lhs
+ , matrix_transition_function<OtherStateInputMatrix> const& rhs
+ )
+ {
+ if (
+ !(lhs._state_count == rhs._state_count)
+ || !(lhs._input_count == rhs._input_count)
+ )
+ {
+ return false;
+ }
+
+ ::std::size_t i = lhs._state_count;
+ ::std::size_t j;
+
+ while (i)
+ {
+ --i;
+ j = lhs._input_count;
+
+ while (j)
+ {
+ --j;
+
+ if (
+ lhs._transition_matrix(i, j)
+ != rhs._transition_matrix(i, j)
+ )
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+ //->
+
+ template <typename StateInputMatrix, typename OtherStateInputMatrix>
+ bool
+ operator!=(
+ matrix_transition_function<StateInputMatrix> const& lhs
+ , matrix_transition_function<OtherStateInputMatrix> const& rhs
+ );
+
+ //<-
+ template <typename StateInputMatrix, typename OtherStateInputMatrix>
+ inline bool
+ operator!=(
+ matrix_transition_function<StateInputMatrix> const& lhs
+ , matrix_transition_function<OtherStateInputMatrix> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_TRANSITION_FUNCTION_MATRIX_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/transition_function/mdp_mapped_input.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/transition_function/mdp_mapped_input.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,508 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_TRANSITION_FUNCTION_MDP_MAPPED_INPUT_HPP_INCLUDED
+#define BOOST_AUTOMATA_TRANSITION_FUNCTION_MDP_MAPPED_INPUT_HPP_INCLUDED
+
+#include <boost/preprocessor/comparison/less.hpp>
+#include <boost/parameter.hpp>
+#include <boost/parameter/preprocessor.hpp>
+
+#if BOOST_PP_LESS(BOOST_PARAMETER_MAX_ARITY, 4)
+#error Set BOOST_PARAMETER_MAX_ARITY to 4 or more.
+#endif
+
+#include <iterator>
+#include <algorithm>
+#include <numeric>
+#include <boost/tr1/type_traits.hpp>
+#include <boost/tr1/random.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/utility/value_init.hpp>
+#include <boost/utility/container_gen.hpp>
+#include <boost/utility/associative_container_gen.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/keyword/template.hpp>
+#include <boost/assert.hpp>
+
+//[reference__mdp_mapped_input_transition_function
+namespace boost { namespace automata {
+
+ template <
+ typename T0
+ , typename T1 = ::boost::parameter::void_
+ , typename T2 = ::boost::parameter::void_
+ , typename T3 = ::boost::parameter::void_
+ >
+ class mdp_mapped_input_transition_function
+ {
+ //<-
+ typedef typename ::boost::parameter::parameters<
+ ::boost::parameter::required<keyword::tag::_Input>
+ , ::boost::parameter::optional<keyword::tag::_RealNumber>
+ , ::boost::parameter::optional<
+ keyword::tag::_AssociativeContainerSelector
+ >
+ , ::boost::parameter::optional<
+ keyword::tag::_RandomAccessContainerSelector
+ >
+ >::BOOST_NESTED_TEMPLATE bind<
+ T0
+ , T1
+ , T2
+ , T3
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+ , ::boost::parameter::void_
+#endif
+ >::type
+ Args;
+ //->
+
+ public:
+ typedef mdp_transition_function_tag
+ tag;
+ typedef ::std::size_t
+ state;
+ typedef // implementation_defined
+ //<-
+ typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_Input
+ >::type
+ //->
+ input;
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_RealNumber
+ , double
+ >::type
+ real_number;
+ typedef bool
+ result_type;
+
+ //<-
+ private:
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_AssociativeContainerSelector
+ , ::boost::mapS
+ >::type
+ AssociativeContainerSelector;
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_RandomAccessContainerSelector
+ , ::boost::vecS
+ >::type
+ RandomAccessContainerSelector;
+ typedef typename ::boost::mpl::apply_wrap1<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , input
+ >::type
+ InputSet;
+ typedef typename ::boost::container_gen<
+ RandomAccessContainerSelector
+ , real_number
+ >::type
+ Probabilities;
+ typedef typename ::boost::mpl::apply_wrap2<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , input
+ , Probabilities
+ >::type
+ TransitionMap;
+ typedef typename ::boost::container_gen<
+ RandomAccessContainerSelector
+ , TransitionMap
+ >::type
+ Transitions;
+
+ class Setter
+ {
+ Probabilities& _probabilities;
+ mdp_mapped_input_transition_function& _function;
+
+ public:
+ Setter(
+ Probabilities& probabilities
+ , mdp_mapped_input_transition_function& f
+ );
+
+ template <typename Integral>
+ typename ::boost::enable_if<
+ ::std::tr1::is_integral<Integral>
+ , Setter&
+ >::type
+ operator=(Integral const& next_state)
+ {
+ BOOST_ASSERT(_function.recognizes_state(next_state));
+
+ real_number const zero_value = initialized_value;
+
+ for (::std::size_t i = 0; i < _probabilities.size(); ++i)
+ {
+ _probabilities[i] = zero_value;
+ }
+
+ _probabilities[next_state] += 1;
+ return *this;
+ }
+
+ template <typename PairContainer>
+ typename ::boost::disable_if<
+ ::std::tr1::is_integral<PairContainer>
+ , Setter&
+ >::type
+ operator=(PairContainer const& container)
+ {
+ real_number const zero_value = initialized_value;
+
+ for (::std::size_t i = 0; i < _probabilities.size(); ++i)
+ {
+ _probabilities[i] = zero_value;
+ }
+
+ *this += container;
+ return *this;
+ }
+
+ template <typename PairContainer>
+ void operator+=(PairContainer const& container);
+ };
+
+ Transitions _transitions;
+ InputSet _inputs;
+ //->
+ // typedef implementation_defined Setter;
+
+ public:
+ mdp_mapped_input_transition_function();
+
+ mdp_mapped_input_transition_function(
+ mdp_mapped_input_transition_function const& copy
+ );
+
+ mdp_mapped_input_transition_function&
+ operator=(mdp_mapped_input_transition_function const& copy);
+
+ bool recognizes_input(input const& i) const;
+
+ bool recognizes_state(state s) const;
+
+ ::std::size_t get_state_count() const;
+
+ bool
+ is_nontrivial_input(
+ state current_state
+ , input const& i
+ ) const;
+
+ template <typename Iterator>
+ void
+ make_nontrivial_inputs(
+ state current_state
+ , Iterator itr
+ ) const;
+
+ real_number
+ get_probability(
+ state current_state
+ , input const& i
+ , state next_state
+ ) const;
+
+ template <typename RNGEngine>
+ result_type
+ operator()(
+ state& current_state
+ , input const& i
+ , RNGEngine& rng_engine
+ ) const;
+
+ Setter operator()(state current_state, input const& i);
+
+ void reset(::std::size_t state_count);
+ };
+
+ //<-
+ template <typename T0, typename T1, typename T2, typename T3>
+ mdp_mapped_input_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ >::mdp_mapped_input_transition_function()
+ : _transitions(), _inputs()
+ {
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ mdp_mapped_input_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ >::mdp_mapped_input_transition_function(
+ mdp_mapped_input_transition_function const& copy
+ ) : _transitions(copy._transitions), _inputs(copy._inputs)
+ {
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ mdp_mapped_input_transition_function<T0,T1,T2,T3>&
+ mdp_mapped_input_transition_function<T0,T1,T2,T3>::operator=(
+ mdp_mapped_input_transition_function const& copy
+ )
+ {
+ if (this != &copy)
+ {
+ _transitions = copy._transitions;
+ _inputs = copy._inputs;
+ }
+
+ return *this;
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ inline bool
+ mdp_mapped_input_transition_function<T0,T1,T2,T3>::recognizes_input(
+ input const& i
+ ) const
+ {
+ return _inputs.find(i) != _inputs.end();
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ inline bool
+ mdp_mapped_input_transition_function<T0,T1,T2,T3>::recognizes_state(
+ state const s
+ ) const
+ {
+ return s < _transitions.size();
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ inline ::std::size_t
+ mdp_mapped_input_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ >::get_state_count() const
+ {
+ return _transitions.size();
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ inline bool
+ mdp_mapped_input_transition_function<T0,T1,T2,T3>::is_nontrivial_input(
+ state const current_state
+ , input const& i
+ ) const
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(recognizes_input(i));
+
+ TransitionMap const& t_map = _transitions[current_state];
+ return t_map.find(i) != t_map.end();
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ template <typename Iterator>
+ void
+ mdp_mapped_input_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ >::make_nontrivial_inputs(
+ state const current_state
+ , Iterator itr
+ ) const
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+
+ TransitionMap const& t_map = _transitions[current_state];
+ typename TransitionMap::const_iterator t_end = t_map.end();
+
+ for (
+ typename TransitionMap::const_iterator t_itr = t_map.begin();
+ t_itr != t_end;
+ ++t_itr
+ )
+ {
+ *itr = t_itr->first;
+ ++itr;
+ }
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ typename mdp_mapped_input_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ >::real_number
+ mdp_mapped_input_transition_function<T0,T1,T2,T3>::get_probability(
+ state const current_state
+ , input const& i
+ , state const next_state
+ ) const
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(recognizes_input(i));
+ BOOST_ASSERT(recognizes_state(next_state));
+
+ TransitionMap const& t_map = _transitions[current_state];
+ typename TransitionMap::const_iterator map_itr = t_map.find(i);
+
+ if (map_itr == t_map.end())
+ {
+ real_number const zero_value = initialized_value;
+ return zero_value;
+ }
+ else
+ {
+ return map_itr->second[next_state];
+ }
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ template <typename RNGEngine>
+ typename mdp_mapped_input_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ >::result_type
+ mdp_mapped_input_transition_function<T0,T1,T2,T3>::operator()(
+ state& current_state
+ , input const& i
+ , RNGEngine& rng_engine
+ ) const
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(recognizes_input(i));
+
+ TransitionMap const& t_map = _transitions[current_state];
+ typename TransitionMap::const_iterator map_itr = t_map.find(i);
+
+ if (map_itr == t_map.end())
+ {
+ return false;
+ }
+ else
+ {
+ typedef ::std::tr1::uniform_real<real_number> Distribution;
+
+ Probabilities const& probabilities = map_itr->second;
+ Probabilities cumulative;
+ real_number const zero_value = initialized_value;
+
+ ::std::partial_sum(
+ probabilities.begin()
+ , probabilities.end()
+ , std::back_inserter(cumulative)
+ );
+
+ ::std::tr1::variate_generator<RNGEngine&,Distribution> rng(
+ rng_engine
+ , Distribution(zero_value, cumulative.back())
+ );
+ current_state = ::std::distance(
+ cumulative.begin()
+ , std::lower_bound(cumulative.begin(), cumulative.end(), rng())
+ );
+ return true;
+ }
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ mdp_mapped_input_transition_function<T0,T1,T2,T3>::Setter::Setter(
+ Probabilities& probabilities
+ , mdp_mapped_input_transition_function& function
+ ) : _probabilities(probabilities), _function(function)
+ {
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ template <typename PairContainer>
+ inline void
+ mdp_mapped_input_transition_function<
+ T0
+ , T1
+ , T2
+ , T3
+ >::Setter::operator+=(PairContainer const& container)
+ {
+ real_number const zero_value = initialized_value;
+ typename PairContainer::const_iterator c_end = container.end();
+
+ for (
+ typename PairContainer::const_iterator c_itr = container.begin();
+ c_itr != c_end;
+ ++c_itr
+ )
+ {
+ BOOST_ASSERT(_function.recognizes_state(c_itr->second));
+ BOOST_ASSERT(zero_value < c_itr->second);
+ _probabilities[c_itr->first] = c_itr->second;
+ }
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ typename mdp_mapped_input_transition_function<T0,T1,T2,T3>::Setter
+ mdp_mapped_input_transition_function<T0,T1,T2,T3>::operator()(
+ state const current_state
+ , input const& i
+ )
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+
+ if (_inputs.find(i) == _inputs.end())
+ {
+ _inputs.insert(i);
+ }
+
+ TransitionMap& t_map = _transitions[current_state];
+ typename TransitionMap::iterator t_itr = t_map.find(i);
+
+ if (t_itr == t_map.end())
+ {
+ return Setter(
+ t_map[i] = Probabilities(_transitions.size())
+ , *this
+ );
+ }
+ else
+ {
+ return Setter(t_itr->second, *this);
+ }
+ }
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ void
+ mdp_mapped_input_transition_function<T0,T1,T2,T3>::reset(
+ std::size_t state_count
+ )
+ {
+ _inputs.clear();
+ _transitions.resize(state_count);
+
+ while (state_count)
+ {
+ _transitions[--state_count].clear();
+ }
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_TRANSITION_FUNCTION_MDP_MAPPED_INPUT_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/transition_function/next_state.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/transition_function/next_state.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,387 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_TRANSITION_FUNCTION_NEXT_STATE_HPP_INCLUDED
+#define BOOST_AUTOMATA_TRANSITION_FUNCTION_NEXT_STATE_HPP_INCLUDED
+
+#include <boost/preprocessor/comparison/less.hpp>
+#include <boost/parameter.hpp>
+#include <boost/parameter/preprocessor.hpp>
+
+#if BOOST_PP_LESS(BOOST_PARAMETER_MAX_ARITY, 2)
+#error Set BOOST_PARAMETER_MAX_ARITY to 2 or more.
+#endif
+
+#include <vector>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/utility/container_gen.hpp>
+#include <boost/utility/associative_container_gen.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/keyword/template.hpp>
+#include <boost/assert.hpp>
+
+//[reference__next_state_transition_function
+namespace boost { namespace automata {
+
+ template <
+ typename T0 = ::boost::parameter::void_
+ , typename T1 = ::boost::parameter::void_
+ >
+ class next_state_transition_function
+ {
+ //<-
+ typedef typename ::boost::parameter::parameters<
+ ::boost::parameter::optional<
+ keyword::tag::_AssociativeContainerSelector
+ >
+ , ::boost::parameter::optional<
+ keyword::tag::_RandomAccessContainerSelector
+ >
+ >::BOOST_NESTED_TEMPLATE bind<
+ T0
+ , T1
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+ , ::boost::parameter::void_
+#endif
+ >::type
+ Args;
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_AssociativeContainerSelector
+ , ::boost::setS
+ >::type
+ AssociativeContainerSelector;
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_RandomAccessContainerSelector
+ , ::boost::vecS
+ >::type
+ RandomAccessContainerSelector;
+ //->
+
+ public:
+ typedef next_state_transition_function_tag tag;
+ typedef ::std::size_t state;
+ typedef state result_type;
+ typedef state first_argument_type;
+ typedef state second_argument_type;
+
+ private:
+ // typedef implementation_defined Adder;
+ //<-
+ class Adder
+ {
+ next_state_transition_function& _function;
+ first_argument_type const _current_state;
+
+ public:
+ Adder(
+ next_state_transition_function& f
+ , first_argument_type current_state
+ );
+
+ void operator+=(result_type next_state);
+ };
+
+ typedef typename ::boost::mpl::apply_wrap1<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , second_argument_type
+ >::type
+ InputSet;
+ typedef typename ::boost::container_gen<
+ RandomAccessContainerSelector
+ , InputSet
+ >::type
+ Transitions;
+
+ Transitions _transitions;
+ //->
+
+ public:
+ next_state_transition_function();
+
+ next_state_transition_function(
+ next_state_transition_function const& copy
+ );
+
+ next_state_transition_function&
+ operator=(next_state_transition_function const& copy);
+
+ bool recognizes_input(second_argument_type i) const;
+
+ bool recognizes_state(first_argument_type s) const;
+
+ ::std::size_t get_state_count() const;
+
+ result_type
+ operator()(
+ first_argument_type current_state
+ , second_argument_type i
+ ) const;
+
+ template <typename Iterator>
+ void
+ make_nontrivial_inputs(
+ first_argument_type current_state
+ , Iterator itr
+ ) const;
+
+ void
+ add_transition(
+ first_argument_type current_state
+ , second_argument_type next_state
+ );
+
+ Adder operator()(first_argument_type current_state);
+
+ void reset(::std::size_t state_count);
+
+ //<-
+ template <typename T0_, typename T1_, typename T2_, typename T3_>
+ friend bool
+ operator==(
+ next_state_transition_function<T0_,T1_> const& lhs
+ , next_state_transition_function<T2_,T3_> const& rhs
+ );
+ //->
+ };
+
+ //<-
+ template <typename T0, typename T1>
+ next_state_transition_function<T0,T1>::next_state_transition_function()
+ : _transitions()
+ {
+ }
+
+ template <typename T0, typename T1>
+ next_state_transition_function<T0,T1>::next_state_transition_function(
+ next_state_transition_function const& copy
+ ) : _transitions(copy._transitions)
+ {
+ }
+
+ template <typename T0, typename T1>
+ inline next_state_transition_function<T0,T1>&
+ next_state_transition_function<T0,T1>::operator=(
+ next_state_transition_function const& copy
+ )
+ {
+ if (this != &copy)
+ {
+ _transitions = copy._transitions;
+ }
+
+ return *this;
+ }
+
+ template <typename T0, typename T1>
+ inline bool
+ next_state_transition_function<T0,T1>::recognizes_input(
+ second_argument_type const i
+ ) const
+ {
+ return i < _transitions.size();
+ }
+
+ template <typename T0, typename T1>
+ inline bool
+ next_state_transition_function<T0,T1>::recognizes_state(
+ first_argument_type const s
+ ) const
+ {
+ return s < _transitions.size();
+ }
+
+ template <typename T0, typename T1>
+ inline ::std::size_t
+ next_state_transition_function<T0,T1>::get_state_count() const
+ {
+ return _transitions.size();
+ }
+
+ template <typename T0, typename T1>
+ inline typename next_state_transition_function<T0,T1>::result_type
+ next_state_transition_function<T0,T1>::operator()(
+ first_argument_type const current_state
+ , second_argument_type const i
+ ) const
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(recognizes_input(i));
+
+ InputSet const& input_set = _transitions[current_state];
+
+ return (input_set.find(i) == input_set.end()) ? current_state : i;
+ }
+
+ template <typename T0, typename T1>
+ template <typename Iterator>
+ void
+ next_state_transition_function<T0,T1>::make_nontrivial_inputs(
+ first_argument_type const current_state
+ , Iterator itr
+ ) const
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+
+ InputSet const& input_set = _transitions[current_state];
+ typename InputSet::const_iterator set_end = input_set.end();
+
+ for (
+ typename InputSet::const_iterator set_itr = input_set.begin();
+ set_itr != set_end;
+ ++set_itr
+ )
+ {
+ *itr = *set_itr;
+ ++itr;
+ }
+ }
+
+ template <typename T0, typename T1>
+ inline void
+ next_state_transition_function<T0,T1>::add_transition(
+ first_argument_type const current_state
+ , second_argument_type const next_state
+ )
+ {
+ BOOST_ASSERT(recognizes_state(current_state));
+ BOOST_ASSERT(recognizes_state(next_state));
+
+ if (current_state != next_state)
+ {
+ InputSet& input_set = _transitions[current_state];
+
+ if (input_set.find(next_state) == input_set.end())
+ {
+ input_set.insert(next_state);
+ }
+ }
+ // The else case is degenerate.
+ }
+
+ template <typename T0, typename T1>
+ next_state_transition_function<T0,T1>::Adder::Adder(
+ next_state_transition_function& f
+ , first_argument_type const current_state
+ ) : _function(f), _current_state(current_state)
+ {
+ }
+
+ template <typename T0, typename T1>
+ void
+ next_state_transition_function<T0,T1>::Adder::operator+=(
+ second_argument_type const next_state
+ )
+ {
+ _function.add_transition(_current_state, next_state);
+ }
+
+ template <typename T0, typename T1>
+ typename next_state_transition_function<T0,T1>::Adder
+ next_state_transition_function<T0,T1>::operator()(
+ first_argument_type const current_state
+ )
+ {
+ return Adder(*this, current_state);
+ }
+
+ template <typename T0, typename T1>
+ void
+ next_state_transition_function<T0,T1>::reset(::std::size_t state_count)
+ {
+ _transitions.resize(state_count);
+
+ while (state_count)
+ {
+ _transitions[--state_count].clear();
+ }
+ }
+ //->
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ bool
+ operator==(
+ next_state_transition_function<T0,T1> const& lhs
+ , next_state_transition_function<T2,T3> const& rhs
+ );
+
+ //<-
+ template <typename T0, typename T1, typename T2, typename T3>
+ bool
+ operator==(
+ next_state_transition_function<T0,T1> const& lhs
+ , next_state_transition_function<T2,T3> const& rhs
+ )
+ {
+ if (lhs.get_state_count() != rhs.get_state_count())
+ {
+ return false;
+ }
+
+ typedef typename next_state_transition_function<T0,T1>::InputSet
+ LHS_InputSet;
+ typedef typename LHS_InputSet::const_iterator
+ LHS_InputSetIterator;
+ typedef typename next_state_transition_function<T2,T3>::InputSet
+ RHS_InputSet;
+ typedef typename RHS_InputSet::const_iterator
+ RHS_InputSetIterator;
+
+ LHS_InputSetIterator lhs_itr, lhs_end;
+ RHS_InputSetIterator rhs_end;
+ ::std::size_t s = lhs._transitions.size();
+
+ while (s)
+ {
+ LHS_InputSet const& lhs_set = lhs._transitions[--s];
+ RHS_InputSet const& rhs_set = rhs._transitions[s];
+
+ if (lhs_set.size() != rhs_set.size())
+ {
+ return false;
+ }
+
+ lhs_end = lhs_set.end();
+ rhs_end = rhs_set.end();
+
+ for (lhs_itr = lhs_set.begin(); lhs_itr != lhs_end; ++lhs_itr)
+ {
+ if (rhs_set.find(*lhs_itr) == rhs_end)
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+ //->
+
+ template <typename T0, typename T1, typename T2, typename T3>
+ bool
+ operator!=(
+ next_state_transition_function<T0,T1> const& lhs
+ , next_state_transition_function<T2,T3> const& rhs
+ );
+
+ //<-
+ template <typename T0, typename T1, typename T2, typename T3>
+ inline bool
+ operator!=(
+ next_state_transition_function<T0,T1> const& lhs
+ , next_state_transition_function<T2,T3> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_TRANSITION_FUNCTION_NEXT_STATE_HPP_INCLUDED
+

Added: sandbox/automata/boost/automata/transition_function/totalistic_boolean_cell.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/transition_function/totalistic_boolean_cell.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,186 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_TRANSITION_FUNCTION_TOTALISTIC_BOOLEAN_CELL_HPP_INC
+#define BOOST_AUTOMATA_TRANSITION_FUNCTION_TOTALISTIC_BOOLEAN_CELL_HPP_INC
+
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/range/algorithm/count.hpp>
+#include <boost/detail/metafunction/class/associative_container_gen.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+
+//[reference__totalistic_boolean_cell_transition_function
+namespace boost { namespace automata {
+
+ template <typename AssociativeContainerSelector = setS>
+ class totalistic_boolean_cell_transition_function
+ {
+ //typedef implementation_defined Inserter;
+ //<-
+ typedef typename ::boost::mpl::apply_wrap1<
+ ::boost::detail::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , ::std::size_t
+ >::type
+ CountSet;
+
+ class Inserter
+ {
+ CountSet& _set;
+
+ public:
+ explicit Inserter(CountSet& set);
+
+ Inserter& operator,(::std::size_t count);
+ };
+ //->
+
+ public:
+ typedef transition_function_tag tag;
+ typedef bool state;
+ typedef state result_type;
+
+ //<-
+ private:
+ CountSet _birth_set;
+ CountSet _stay_alive_set;
+
+ public:
+ //->
+ totalistic_boolean_cell_transition_function();
+
+ totalistic_boolean_cell_transition_function(
+ totalistic_boolean_cell_transition_function const& copy
+ );
+
+ totalistic_boolean_cell_transition_function&
+ operator=(totalistic_boolean_cell_transition_function const& copy);
+
+ template <typename Input>
+ result_type operator()(state current_state, Input const& i) const;
+
+ Inserter operator|=(::std::size_t count);
+
+ Inserter operator&=(::std::size_t count);
+
+ void reset();
+ };
+
+ //<-
+ template <typename AssociativeContainerSelector>
+ totalistic_boolean_cell_transition_function<
+ AssociativeContainerSelector
+ >::Inserter::Inserter(CountSet& set) : _set(set)
+ {
+ }
+
+ template <typename AssociativeContainerSelector>
+ inline typename totalistic_boolean_cell_transition_function<
+ AssociativeContainerSelector
+ >::Inserter&
+ totalistic_boolean_cell_transition_function<
+ AssociativeContainerSelector
+ >::Inserter::operator,(::std::size_t count)
+ {
+ _set.insert(count);
+ return *this;
+ }
+
+ template <typename AssociativeContainerSelector>
+ totalistic_boolean_cell_transition_function<
+ AssociativeContainerSelector
+ >::totalistic_boolean_cell_transition_function()
+ : _birth_set(), _stay_alive_set()
+ {
+ }
+
+ template <typename AssociativeContainerSelector>
+ totalistic_boolean_cell_transition_function<
+ AssociativeContainerSelector
+ >::totalistic_boolean_cell_transition_function(
+ totalistic_boolean_cell_transition_function const& copy
+ ) : _birth_set(copy._birth_set), _stay_alive_set(copy._stay_alive_set)
+ {
+ }
+
+ template <typename AssociativeContainerSelector>
+ inline totalistic_boolean_cell_transition_function<
+ AssociativeContainerSelector
+ >&
+ totalistic_boolean_cell_transition_function<
+ AssociativeContainerSelector
+ >::operator=(totalistic_boolean_cell_transition_function const& copy)
+ {
+ if (this != &copy)
+ {
+ _birth_set = copy._birth_set;
+ _stay_alive_set = copy._stay_alive_set;
+ }
+
+ return *this;
+ }
+
+ template <typename AssociativeContainerSelector>
+ template <typename Input>
+ inline typename totalistic_boolean_cell_transition_function<
+ AssociativeContainerSelector
+ >::result_type
+ totalistic_boolean_cell_transition_function<
+ AssociativeContainerSelector
+ >::operator()(state current_state, Input const& i) const
+ {
+ return (
+ current_state
+ ? (
+ _stay_alive_set.find(::boost::range::count(i, true))
+ != _stay_alive_set.end()
+ )
+ : (
+ _birth_set.find(::boost::range::count(i, true))
+ != _birth_set.end()
+ )
+ );
+ }
+
+ template <typename AssociativeContainerSelector>
+ inline typename totalistic_boolean_cell_transition_function<
+ AssociativeContainerSelector
+ >::Inserter
+ totalistic_boolean_cell_transition_function<
+ AssociativeContainerSelector
+ >::operator|=(::std::size_t count)
+ {
+ _birth_set.insert(count);
+ return Inserter(_birth_set);
+ }
+
+ template <typename AssociativeContainerSelector>
+ inline typename totalistic_boolean_cell_transition_function<
+ AssociativeContainerSelector
+ >::Inserter
+ totalistic_boolean_cell_transition_function<
+ AssociativeContainerSelector
+ >::operator&=(::std::size_t count)
+ {
+ _stay_alive_set.insert(count);
+ return Inserter(_stay_alive_set);
+ }
+
+ template <typename AssociativeContainerSelector>
+ void
+ totalistic_boolean_cell_transition_function<
+ AssociativeContainerSelector
+ >::reset()
+ {
+ _birth_set.clear();
+ _stay_alive_set.clear();
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_TRANSITION_FUNCTION_TOTALISTIC_BOOLEAN_CELL_HPP_INC
+

Added: sandbox/automata/boost/automata/transition_function/totalistic_dt_cell.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/transition_function/totalistic_dt_cell.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,245 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_TRANSITION_FUNCTION_TOTALISTIC_DT_CELL_HPP_INC
+#define BOOST_AUTOMATA_TRANSITION_FUNCTION_TOTALISTIC_DT_CELL_HPP_INC
+
+#include <utility>
+#include <boost/config.hpp>
+#include <boost/parameter.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/tr1/type_traits.hpp>
+#include <boost/range.hpp>
+#include <boost/utility/associative_container_gen.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+#include <boost/automata/keyword/template.hpp>
+#include <boost/automata/transition_function/decision_tree.hpp>
+
+//[reference__totalistic_dfa_cell_transition_function
+namespace boost { namespace automata {
+
+ template <
+ typename T0
+ , typename T1 = ::boost::parameter::void_
+ , typename T2 = ::boost::parameter::void_
+ >
+ class totalistic_dt_cell_transition_function
+ {
+ //<-
+ typedef typename ::boost::parameter::parameters<
+ ::boost::parameter::required<keyword::tag::_State>
+ , ::boost::parameter::optional<
+ keyword::tag::_AssociativeContainerSelector
+ >
+ , ::boost::parameter::optional<
+ keyword::tag::_RandomAccessContainerSelector
+ >
+ >::BOOST_NESTED_TEMPLATE bind<
+ T0
+ , T1
+ , T2
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+ , ::boost::parameter::void_
+#endif
+ >::type
+ Args;
+ //->
+
+ public:
+ typedef transition_function_tag
+ tag;
+ typedef // implementation_defined
+ //<-
+ typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_State
+ >::type
+ //->
+ state;
+ typedef bool
+ result_type;
+
+ //<-
+ private:
+ BOOST_STATIC_ASSERT((::std::tr1::is_integral<state>::value));
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_AssociativeContainerSelector
+ , ::boost::mapS
+ >::type
+ AssociativeContainerSelector;
+ typedef typename ::boost::parameter::value_type<
+ Args
+ , keyword::tag::_RandomAccessContainerSelector
+ , ::boost::vecS
+ >::type
+ RandomAccessContainerSelector;
+ typedef decision_tree_explicit_transition_function<
+ state
+ , state
+ , state
+ , AssociativeContainerSelector
+ , RandomAccessContainerSelector
+ >
+ Function;
+
+ public:
+ //->
+ typedef typename Function::builder
+ builder;
+
+ //<-
+ private:
+ Function _function;
+ state _state_key;
+
+ public:
+ //->
+ totalistic_dt_cell_transition_function();
+
+ totalistic_dt_cell_transition_function(
+ totalistic_dt_cell_transition_function const& copy
+ );
+
+ totalistic_dt_cell_transition_function&
+ operator=(totalistic_dt_cell_transition_function const& copy);
+
+ template <typename Input>
+ result_type operator()(state& current_state, Input const& i) const;
+
+ void reset();
+
+ builder add_transitions(state const& state_key);
+
+ private:
+ template <typename Iterator>
+ result_type
+ _process_input(
+ state& current_state
+ , Iterator itr
+ , Iterator itr_end
+ ) const;
+ };
+
+ //<-
+ template <typename T0, typename T1, typename T2>
+ totalistic_dt_cell_transition_function<
+ T0
+ , T1
+ , T2
+ >::totalistic_dt_cell_transition_function() : _function(), _state_key()
+ {
+ }
+
+ template <typename T0, typename T1, typename T2>
+ totalistic_dt_cell_transition_function<
+ T0
+ , T1
+ , T2
+ >::totalistic_dt_cell_transition_function(
+ totalistic_dt_cell_transition_function const& copy
+ ) : _function(copy._function), _state_key(copy._state_key)
+ {
+ }
+
+ template <typename T0, typename T1, typename T2>
+ inline totalistic_dt_cell_transition_function<T0,T1,T2>&
+ totalistic_dt_cell_transition_function<T0,T1,T2>::operator=(
+ totalistic_dt_cell_transition_function const& copy
+ )
+ {
+ if (this != &copy)
+ {
+ _function = copy._function;
+ _state_key = copy._state_key;
+ }
+
+ return *this;
+ }
+
+ template <typename T0, typename T1, typename T2>
+ template <typename Input>
+ inline typename totalistic_dt_cell_transition_function<
+ T0
+ , T1
+ , T2
+ >::result_type
+ totalistic_dt_cell_transition_function<T0,T1,T2>::operator()(
+ state& current_state
+ , Input const& i
+ ) const
+ {
+ return _process_input(
+ current_state
+ , ::boost::begin(i)
+ , ::boost::end(i)
+ );
+ }
+
+ template <typename T0, typename T1, typename T2>
+ template <typename Iterator>
+ typename totalistic_dt_cell_transition_function<T0,T1,T2>::result_type
+ totalistic_dt_cell_transition_function<T0,T1,T2>::_process_input(
+ state& current_state
+ , Iterator itr
+ , Iterator itr_end
+ ) const
+ {
+ typedef typename ::boost::mpl::apply_wrap2<
+ ::boost::associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , state
+ , state
+ >::type
+ InputMap;
+
+ InputMap input_map;
+ typename InputMap::iterator in_itr;
+
+ for (
+ input_map.insert(
+ typename InputMap::value_type(_state_key, current_state)
+ );
+ itr != itr_end;
+ ++itr
+ )
+ {
+ in_itr = input_map.find(*itr);
+
+ if (in_itr == input_map.end())
+ {
+ input_map.insert(typename InputMap::value_type(*itr, 1));
+ }
+ else
+ {
+ ++in_itr->second;
+ }
+ }
+
+ return _function(current_state, input_map);
+ }
+
+ template <typename T0, typename T1, typename T2>
+ inline void totalistic_dt_cell_transition_function<T0,T1,T2>::reset()
+ {
+ _function.reset();
+ }
+
+ template <typename T0, typename T1, typename T2>
+ inline typename totalistic_dt_cell_transition_function<T0,T1,T2>::builder
+ totalistic_dt_cell_transition_function<T0,T1,T2>::add_transitions(
+ state const& state_key
+ )
+ {
+ return _function.add_transitions(_state_key = state_key);
+ }
+ //->
+}} // namespace boost::automata
+//]
+
+#endif // BOOST_AUTOMATA_TRANSITION_FUNCTION_TOTALISTIC_DT_CELL_HPP_INC
+

Added: sandbox/automata/boost/automata/typeof.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/automata/typeof.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,96 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_AUTOMATA_TYPEOF_HPP_INCLUDED
+#define BOOST_AUTOMATA_TYPEOF_HPP_INCLUDED
+
+#include <boost/typeof/typeof.hpp>
+#include <boost/automata.hpp>
+
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+BOOST_TYPEOF_REGISTER_TYPE(boost::automata::dpda_generator)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::dpda_transition_function, 4)
+BOOST_TYPEOF_REGISTER_TYPE(boost::automata::dfa_generator)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::matrix_transition_function, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::automata::mapped_input_tabular_transition_function
+ , 3
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::automata::mapped_input_transition_function
+ , 3
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::automata::next_state_transition_function
+ , 2
+)
+BOOST_TYPEOF_REGISTER_TYPE(boost::automata::deterministic_generator)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::adaptor_transition_function, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::automata::input_rule_transition_function
+ , (typename)(bool)
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::cellular_graph_input_rule, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::automata::totalistic_boolean_cell_transition_function
+ , 1
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::automata::totalistic_dfa_cell_transition_function
+ , 2
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::wolfram_code_input_rule, 2)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::probabilistic_generator, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::automata::mdp_mapped_input_transition_function
+ , 4
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::automata::decision_tree_transition_function
+ , 5
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::automata::decision_tree_explicit_transition_function
+ , 5
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::function_builder, 4)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::builder_from_graph, 4)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::output_observer, 2)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::automata::single_final_state_builder_from_graph
+ , (typename)(unsigned long)
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::automata::multiple_final_states_builder_from_graph
+ , (typename)(unsigned long)
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::base_observer, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::full_noop_observer, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::output_observer, 2)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::automata::single_final_state_policy
+ , (unsigned long)
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::automata::parallel_final_states_policy
+ , (unsigned long)(typename)
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::automata::serial_final_states_policy
+ , (unsigned long)(typename)
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::bool_insertion_policy, 3)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::dpda_insertion_policy, 4)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::dfa_insertion_policy, 4)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::mdp_best_input_policy, 2)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::moore_output_policy, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::mealy_output_policy, 1)
+BOOST_TYPEOF_REGISTER_TYPE(boost::automata::default_input_validation_policy)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::input_validation_policy, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::automaton, 5)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::automata::function_automaton, 4)
+
+#endif // BOOST_AUTOMATA_TYPEOF_HPP_INCLUDED
+

Added: sandbox/automata/boost/detail/metafunction/adaptable_unary_argument.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/detail/metafunction/adaptable_unary_argument.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,22 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_ADAPTABLE_UNARY_ARGUMENT_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_ADAPTABLE_UNARY_ARGUMENT_HPP_INCLUDED
+
+#include <boost/mpl/aux_/lambda_support.hpp>
+
+namespace boost { namespace detail {
+
+ template <typename T>
+ struct adaptable_unary_argument
+ {
+ typedef typename T::argument_type type;
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,adaptable_unary_argument,(T))
+ };
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_ADAPTABLE_UNARY_ARGUMENT_HPP_INCLUDED
+

Added: sandbox/automata/boost/detail/metafunction/data_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/detail/metafunction/data_type.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,52 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_DATA_TYPE_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_DATA_TYPE_HPP_INCLUDED
+
+#include <boost/ref.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/type_traits/remove_pointer.hpp>
+#include <boost/type_traits/remove_volatile.hpp>
+#include <boost/type_traits/remove_all_extents.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+
+namespace boost { namespace detail {
+
+ template <typename T>
+ struct data_type
+ {
+ private:
+ typedef typename ::boost::remove_const<
+ typename ::boost::remove_reference<
+ typename ::boost::remove_pointer<
+ typename ::boost::remove_volatile<
+ typename ::boost::remove_all_extents<
+ typename ::boost::unwrap_reference<T>::type
+ >::type
+ >::type
+ >::type
+ >::type
+ >::type
+ lower_type;
+
+ public:
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::is_same<T,lower_type>
+ , ::boost::mpl::identity<T>
+ , data_type<lower_type>
+ >::type
+ type;
+
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,data_type,(T))
+ };
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_DATA_TYPE_HPP_INCLUDED
+

Added: sandbox/automata/boost/detail/metafunction/has_argument_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/detail/metafunction/has_argument_type.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_HAS_ARGUMENT_TYPE_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_HAS_ARGUMENT_TYPE_HPP_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost { namespace detail {
+
+ // The has_argument_type metafunction will determine whether or not
+ // the specified type has a nested 'argument_type' type definition.
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(argument_type)
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_HAS_ARGUMENT_TYPE_HPP_INCLUDED
+

Added: sandbox/automata/boost/detail/metafunction/has_first_argument_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/detail/metafunction/has_first_argument_type.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_HAS_FIRST_ARGUMENT_TYPE_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_HAS_FIRST_ARGUMENT_TYPE_HPP_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost { namespace detail {
+
+ // The has_first_argument_type metafunction will determine whether or not
+ // the specified type has a nested 'first_argument_type' type definition.
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(first_argument_type)
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_HAS_FIRST_ARGUMENT_TYPE_HPP_INCLUDED
+

Added: sandbox/automata/boost/detail/metafunction/has_key_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/detail/metafunction/has_key_type.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_HAS_KEY_TYPE_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_HAS_KEY_TYPE_HPP_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost { namespace detail {
+
+ // The has_key_type metafunction will determine whether or not the specified
+ // type has a nested 'key_type' type definition.
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(key_type)
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_HAS_KEY_TYPE_HPP_INCLUDED
+

Added: sandbox/automata/boost/detail/metafunction/has_second_argument_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/detail/metafunction/has_second_argument_type.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_HAS_SECOND_ARGUMENT_TYPE_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_HAS_SECOND_ARGUMENT_TYPE_HPP_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost { namespace detail {
+
+ // The has_second_argument_type metafunction will determine whether or not
+ // the specified type has a nested 'second_argument_type' type definition.
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(second_argument_type)
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_HAS_SECOND_ARGUMENT_TYPE_HPP_INCLUDED
+

Added: sandbox/automata/boost/detail/metafunction/has_value_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/detail/metafunction/has_value_type.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_HAS_VALUE_TYPE_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_HAS_VALUE_TYPE_HPP_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost { namespace detail {
+
+ // The has_value_type metafunction will determine whether or not the
+ // specified type has a nested 'value_type' type definition.
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type)
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_HAS_VALUE_TYPE_HPP_INCLUDED
+

Added: sandbox/automata/boost/detail/metafunction/is_adaptable_binary_function.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/detail/metafunction/is_adaptable_binary_function.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,28 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_IS_ADAPTABLE_BINARY_FUNCTION_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_IS_ADAPTABLE_BINARY_FUNCTION_HPP_INCLUDED
+
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/detail/metafunction/has_first_argument_type.hpp>
+#include <boost/detail/metafunction/has_second_argument_type.hpp>
+
+namespace boost { namespace detail {
+
+ template <typename T>
+ struct is_adaptable_binary_function
+ : boost::mpl::and_<
+ typename has_first_argument_type<T>::type
+ , typename has_second_argument_type<T>::type
+ >::type
+ {
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_adaptable_binary_function,(T))
+ };
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_IS_ADAPTABLE_BINARY_FUNCTION_HPP_INCLUDED
+

Added: sandbox/automata/boost/detail/metafunction/is_adaptable_unary_function.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/detail/metafunction/is_adaptable_unary_function.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,25 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_IS_ADAPTABLE_UNARY_FUNCTION_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_IS_ADAPTABLE_UNARY_FUNCTION_HPP_INCLUDED
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/detail/metafunction/has_argument_type.hpp>
+
+namespace boost { namespace detail {
+
+ template <typename T>
+ struct is_adaptable_unary_function
+ : has_argument_type<T>::type
+ {
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_adaptable_unary_function,(T))
+ };
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_IS_ADAPTABLE_UNARY_FUNCTION_HPP_INCLUDED
+

Added: sandbox/automata/boost/detail/metafunction/is_n_ary_function.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/detail/metafunction/is_n_ary_function.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,33 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_IS_N_ARY_FUNCTION_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_IS_N_ARY_FUNCTION_HPP_INCLUDED
+
+#include <boost/tr1/type_traits.hpp>
+#include <boost/function_types/function_arity.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/equal_to.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+
+namespace boost { namespace detail {
+
+ template <typename T, typename N>
+ struct is_n_ary_function
+ : ::boost::mpl::if_<
+ ::std::tr1::is_function<T>
+ , ::boost::mpl::equal_to<
+ ::boost::function_types::function_arity<T>
+ , N
+ >
+ , ::std::tr1::false_type
+ >::type
+ {
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(2,is_n_ary_function,(T, N))
+ };
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_IS_N_ARY_FUNCTION_HPP_INCLUDED
+

Added: sandbox/automata/boost/detail/metafunction/is_predicate.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/detail/metafunction/is_predicate.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,47 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_IS_PREDICATE_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_IS_PREDICATE_HPP_INCLUDED
+
+#include <boost/tr1/type_traits.hpp>
+#include <boost/tr1/functional.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+
+namespace boost { namespace detail {
+
+#ifdef BOOST_NO_RESULT_OF
+ template <typename T>
+ struct is_predicate
+ : ::std::tr1::is_same<typename T::result_type,bool>
+#else
+ template <typename T>
+ struct is_predicate_function
+ : ::std::tr1::is_same<typename ::std::tr1::result_of<T>::type,bool>
+ {
+ };
+
+ template <typename T>
+ struct is_predicate_class
+ : ::std::tr1::is_same<typename T::result_type,bool>
+ {
+ };
+
+ template <typename T>
+ struct is_predicate
+ : ::boost::mpl::if_<
+ ::std::tr1::is_function<T>
+ , is_predicate_function<T>
+ , is_predicate_class<T>
+ >::type
+#endif // BOOST_NO_RESULT_OF
+ {
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_predicate,(T))
+ };
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_IS_PREDICATE_HPP_INCLUDED
+

Added: sandbox/automata/boost/detail/metafunction/property_map_key.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/detail/metafunction/property_map_key.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,58 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_PROPERTY_MAP_KEY_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_PROPERTY_MAP_KEY_HPP_INCLUDED
+
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/property_map/property_map.hpp>
+#include <boost/detail/metafunction/data_type.hpp>
+#include <boost/detail/metafunction/has_key_type.hpp>
+
+namespace boost { namespace detail {
+
+ template <bool b>
+ struct property_map_key_impl
+ {
+ template <typename T>
+ struct apply
+ {
+ typedef typename property_traits<T>::key_type type;
+ };
+ };
+
+ template <>
+ struct property_map_key_impl<false>
+ {
+ template <typename T>
+ struct apply
+ {
+ typedef void type;
+ };
+ };
+
+ template <typename T>
+ struct property_map_key
+ {
+ private:
+ typedef typename data_type<T>::type
+ DataType;
+ typedef typename has_key_type<DataType>::type
+ HasKeyType;
+
+ public:
+ typedef typename ::boost::mpl::apply_wrap1<
+ property_map_key_impl<HasKeyType::value>
+ , DataType
+ >::type
+ type;
+
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,property_map_key,(T))
+ };
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_PROPERTY_MAP_KEY_HPP_INCLUDED
+

Added: sandbox/automata/boost/detail/metafunction/property_map_value.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/detail/metafunction/property_map_value.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,58 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_PROPERTY_MAP_VALUE_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_PROPERTY_MAP_VALUE_HPP_INCLUDED
+
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/property_map/property_map.hpp>
+#include <boost/detail/metafunction/data_type.hpp>
+#include <boost/detail/metafunction/has_value_type.hpp>
+
+namespace boost { namespace detail {
+
+ template <bool b>
+ struct property_map_value_impl
+ {
+ template <typename T>
+ struct apply
+ {
+ typedef typename property_traits<T>::value_type type;
+ };
+ };
+
+ template <>
+ struct property_map_value_impl<false>
+ {
+ template <typename T>
+ struct apply
+ {
+ typedef void type;
+ };
+ };
+
+ template <typename T>
+ struct property_map_value
+ {
+ private:
+ typedef typename data_type<T>::type
+ DataType;
+ typedef typename has_value_type<DataType>::type
+ HasValueType;
+
+ public:
+ typedef typename ::boost::mpl::apply_wrap1<
+ property_map_value_impl<HasValueType::value>
+ , DataType
+ >::type
+ type;
+
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,property_map_value,(T))
+ };
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_PROPERTY_MAP_VALUE_HPP_INCLUDED
+

Added: sandbox/automata/boost/detail/metafunction/unary_argument.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/boost/detail/metafunction/unary_argument.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,34 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_UNARY_ARGUMENT_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_UNARY_ARGUMENT_HPP_INCLUDED
+
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/front.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/function_types/parameter_types.hpp>
+#include <boost/detail/metafunction/adaptable_unary_argument.hpp>
+
+namespace boost { namespace detail {
+
+ template <typename T>
+ struct unary_argument
+ {
+ typedef typename ::boost::mpl::eval_if<
+ ::std::tr1::is_function<T>
+ , ::boost::mpl::front<
+ ::boost::function_types::parameter_types<T>
+ >
+ , ::boost::detail::adaptable_unary_argument<T>
+ >::type
+ type;
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,unary_argument,(T))
+ };
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_UNARY_ARGUMENT_HPP_INCLUDED
+

Added: sandbox/automata/libs/automata/doc/Jamroot
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/Jamroot 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,29 @@
+project html ;
+import boostbook : boostbook ;
+using quickbook ;
+
+xml automata
+ :
+ automata.qbk
+ ;
+boostbook standalone
+ :
+ automata
+ :
+ <xsl:param>admon.graphics.path=images/
+ <xsl:param>navig.graphics.path=images/
+ <xsl:param>boost.root=http://www.boost.org
+ <xsl:param>boost.libraries=http://www.boost.org/libs/libraries.htm
+ <xsl:param>boost.image.src=../../../../boost.png
+ <xsl:param>boost.image.alt="C++ Boost"
+ <xsl:param>boost.image.w=277
+ <xsl:param>boost.image.h=86
+ <xsl:param>html.stylesheet=boostbook.css
+ <xsl:param>nav.layout=none
+ <xsl:param>chunk.section.depth=2
+ <xsl:param>chunk.first.sections=1
+ <xsl:param>generate.section.toc.level=3
+ <xsl:param>toc.section.depth=3
+ <xsl:param>toc.max.depth=3
+ ;
+

Added: sandbox/automata/libs/automata/doc/automata.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/automata.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,529 @@
+[library Automata
+ [quickbook 1.5]
+ [version 0.1]
+ [authors [Enage, Cromwell D.]]
+ [copyright 2007-2011 Cromwell D. Enage]
+ [purpose Dynamically configurable state machine framework]
+ [license
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+ ]
+]
+
+[/ Images.]
+[def __logo__ [$images/logo.png]]
+[def __mdp_example__ [$http://en.wikipedia.org/wiki/File:Markov_Decision_Process_example.png]]
+[def __maze_before__ [$images/maze_before.png]]
+[def __maze_after__ [$images/maze_after.png]]
+[def __neural_network_layout__ [$images/neural_network_layout.png]]
+[def __neural_network_mystery__ [$images/neural_network_mystery.png]]
+[def __neuron__ [$images/neuron.png]]
+
+[/ General links.]
+[def __concept_based_overloading__ [@http://www.generic-programming.org/languages/conceptcpp/ concept-based overloading]]
+[def __tag_dispatching__ [@http://www.generic-programming.org/languages/cpp/techniques.html#tag_dispatching tag dispatching]]
+[def __automata_theory__ [@http://en.wikipedia.org/wiki/Automata_theory automata theory]]
+[def __Chomsky_hierarchy__ [@http://en.wikipedia.org/wiki/Chomsky_hierarchy Chomsky hierarchy]]
+[def __pushdown_automata__ [@http://en.wikipedia.org/wiki/Pushdown_automaton pushdown automata]]
+[def __dfa__ [@http://en.wikipedia.org/wiki/Deterministic_finite-state_machine DFA]]
+[def __zero_player_game__ [@http://en.wikipedia.org/wiki/Zero-player_game zero-player game]]
+[def __cellular_automaton__ [@http://en.wikipedia.org/wiki/Cellular_automaton cellular automaton]]
+[def __Wolfram_code__ [@http://en.wikipedia.org/wiki/Wolfram_code Wolfram code]]
+[def __Rule_30__ [@http://en.wikipedia.org/wiki/Rule_30 Rule 30]]
+[def __Rule_90__ [@http://en.wikipedia.org/wiki/Rule_90 Rule 90]]
+[def __Rule_110__ [@http://en.wikipedia.org/wiki/Rule_110 Rule 110]]
+[def __Rule_184__ [@http://en.wikipedia.org/wiki/Rule_184 Rule 184]]
+[def __Conway_Game_of_Life__ [@http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life Conway's Game of Life]]
+[def __glider__ [@http://en.wikipedia.org/wiki/Glider_(cellular_automaton) glider]]
+[def __Wireworld__ [@http://en.wikipedia.org/wiki/Wireworld Wireworld]]
+[def __Runtime_Complexity__ [@http://en.wikipedia.org/wiki/Amortized_analysis Runtime Complexity]]
+[def __STL__ [@http://www.sgi.com/tech/stl/ STL]]
+[def __Standard_Template_Library__ [@http://www.sgi.com/tech/stl/ Standard Template Library]]
+[def __MTL__ [@http://osl.iu.edu/research/mtl/ MTL]]
+[def __Matrix_Template_Library__ [@http://osl.iu.edu/research/mtl/ Matrix Template Library]]
+
+[/ TODO: Apply custom styles to concept and code links.]
+[/ template stl_conceptlink[page text] [@http://www.sgi.com/tech/stl/[page].html [*[text]]]]
+[/ template stl_codelink[page text] [@http://www.sgi.com/tech/stl/[page].html [^[text]]]]
+[/ template stl_link[page text] [@http://www.sgi.com/tech/stl/[page].html [text]]]
+
+[/ General concept links.]
+[def __Default_Constructible__ [@http://www.sgi.com/tech/stl/DefaultConstructible.html [*Default Constructible]]]
+[def __STL_Container__ [@http://www.sgi.com/tech/stl/Container.html [*STL Container]]]
+[def __Sequence__ [@http://www.sgi.com/tech/stl/Sequence.html [*Sequence]]]
+[def __Input_Iterator__ [@http://www.sgi.com/tech/stl/InputIterator.html [*Input Iterator]]]
+[def __Output_Iterator__ [@http://www.sgi.com/tech/stl/OutputIterator.html [*Output Iterator]]]
+[def __Unary_Function__ [@http://www.sgi.com/tech/stl/UnaryFunction.html [*Unary Function]]]
+[def __Binary_Function__ [@http://www.sgi.com/tech/stl/BinaryFunction.html [*Binary Function]]]
+[def __Binary_Functions__ [@http://www.sgi.com/tech/stl/BinaryFunction.html [*Binary Functions]]]
+[def __Adaptable_Unary_Function__ [@http://www.sgi.com/tech/stl/AdaptableUnaryFunction.html [*Adaptable Unary Function]]]
+[def __Adaptable_Binary_Function__ [@http://www.sgi.com/tech/stl/AdaptableBinaryFunction.html [*Adaptable Binary Function]]]
+[def __Equality_Comparable__ [@http://www.sgi.com/tech/stl/EqualityComparable.html [*Equality Comparable]]]
+[def __MTL_Matrix__ __MTL__ [@http://osl.iu.edu/research/mtl/reference/html/Matrix.html [*Matrix]]]
+
+[/ STL reference links.]
+[def __std_vector__ [@http://www.sgi.com/tech/stl/Vector.html `std::vector`]]
+[def _std_vector_ [@http://www.sgi.com/tech/stl/Vector.html std::vector]]
+[def __std_deque__ [@http://www.sgi.com/tech/stl/Deque.html `std::deque`]]
+[def _std_deque_ [@http://www.sgi.com/tech/stl/Deque.html std::deque]]
+[def __std_list__ [@http://www.sgi.com/tech/stl/List.html `std::list`]]
+[def _std_list_ [@http://www.sgi.com/tech/stl/List.html std::list]]
+[def __std_map__ [@http://www.sgi.com/tech/stl/Map.html `std::map`]]
+[def _std_map_ [@http://www.sgi.com/tech/stl/Map.html std::map]]
+[def __non_std_hash_map__ [@http://www.sgi.com/tech/stl/hash_map.html `std::hash_map`]]
+[def _non_std_hash_map_ [@http://www.sgi.com/tech/stl/hash_map.html std::hash_map]]
+[def __std_string__ [@http://www.sgi.com/tech/stl/basic_string.html `std::string`]]
+[def _std_string_ [@http://www.sgi.com/tech/stl/basic_string.html std::string]]
+[def __std_insert_iterator__ [@http://www.sgi.com/tech/stl/insert_iterator.html `std::insert_iterator`]]
+[def _std_insert_iterator_ [@http://www.sgi.com/tech/stl/insert_iterator.html std::insert_iterator]]
+
+[/ Boost library and installation links.]
+[def __Build__ [@boost:more/getting_started.html Build]]
+[def __build__ [@boost:more/getting_started.html build]]
+[def __MPL__ [@boost:libs/mpl/doc/index.html MPL]]
+[def __Boost_Statechart__ [@boost:libs/statechart/doc/index.html Boost.Statechart]]
+[def __Boost_Concept_Check__ [@boost:libs/concept_check/concept_check.htm Boost.ConceptCheck]]
+[def __Boost_Test__ [@boost:libs/test/doc/index.html Boost.Test] ]
+[def __Boost_Typeof__ [@boost:doc/html/typeof.html Boost.Typeof]]
+[def __Boost_Fusion__ [@boost:libs/fusion/doc/html/index.html Boost.Fusion]]
+[def __Boost_Function__ [@boost:doc/html/function.html Boost.Function]]
+[def __Boost_Optional__ [@boost:libs/optional/doc/html/index.html Boost.Optional]]
+[def __Boost_Parameter__ [@boost:libs/parameter/doc/html/index.html Boost.Parameter]]
+[def __Boost_Format__ [@boost:libs/format/index.html Boost.Format]]
+[def __Boost_Random__ [@boost:libs/random/doc/index.html Boost.Random]]
+[def __Boost_uBlas__ [@boost:libs/numeric/ublas/doc/index.html Boost.uBlas]]
+[def __Boost_Property_Map__ [@boost:libs/property_map/property_map.html Boost.PropertyMap]]
+[def __BGL__ [@boost:libs/graph/doc/index.html BGL]]
+[def __Boost_Graph__ [@boost:libs/graph/doc/index.html Boost.Graph]]
+[def __Boost_Graph_Library__ [@boost:libs/graph/doc/index.html Boost Graph Library]]
+[def __SVN_Trac__ [@http://svn.boost.org/ SVN Trac]]
+[def __Boost_Type_Traits_Operators__ [@http://svn.boost.org/svn/boost/sandbox/type_traits/libs/type_traits/doc/html/index.html [*Boost.TypeTraitsOperators]]]
+
+[/ Boost concept links.]
+[def __Copy_Constructible__ [@boost:libs/utility/CopyConstructible.html [*Copy Constructible]]]
+[def __Assignable__ [@boost:libs/utility/Assignable.html [*Assignable]]]
+[def __Optional_Pointee__ [@boost:libs/utility/OptionalPointee.html [*Optional Pointee]]]
+[def __Metafunction_Class__ [@boost:libs/mpl/doc/refmanual/metafunction-class.html [*Metafunction Class]]]
+[def __Metafunction_Classes__ [@boost:libs/mpl/doc/refmanual/metafunction-class.html [*Metafunction Classes]]]
+[def __Unary_Metafunction_Class__ [@boost:libs/mpl/doc/refmanual/metafunction-class.html [*Unary Metafunction Class]]]
+[def __Unary_Metafunction_Classes__ [@boost:libs/mpl/doc/refmanual/metafunction-class.html [*Unary Metafunction Classes]]]
+[def __Boolean_Integral_Constant__ [@boost:libs/mpl/doc/refmanual/integral-constant.html [*Boolean Integral Constant]]]
+[def __Fusion_Forward_Sequence__ [@boost:libs/fusion/doc/html/fusion/sequence/concepts/forward_sequence.html [*Fusion Associative Sequence]]]
+[def __Fusion_Associative_Sequence__ [@boost:libs/fusion/doc/html/fusion/sequence/concepts/associative_sequence.html [*Fusion Associative Sequence]]]
+[def __Uniform_Random_Number_Generator__ [@boost:doc/html/boost_random/reference.html#boost_random.reference_concepts.uniform_random_number_generator [*Uniform Random Number Generator]]]
+[def __uBlas_Matrix_Expression__ [__Boost_uBlas] [@boost:libs/numeric/ublas/doc/expression_concept.htm#matrix_expression [*Matrix Expression]]]
+
+[/ Boost reference links in text.]
+[def __empty__ [@boost:libs/fusion/doc/html/fusion/sequence/intrinsic/metafunctions/empty.html *empty*]]
+[def __named_parameter__ [@boost:libs/parameter/doc/html/index.html named parameter]]
+[def __name_each_parameter__ [@boost:libs/parameter/doc/html/index.html name each parameter]]
+[def __deduced_argument__ [@boost:libs/parameter/doc/html/index.html#deduced-parameters deduced argument]]
+[def __named_template_parameter__ [@boost:libs/parameter/doc/html/index.html#named-template-parameters named template parameter]]
+[def __template_keywords__ [@boost:libs/parameter/doc/html/index.html#parameter-enabled-class-templates template keywords]]
+[def __property_maps__ [@boost:libs/graph/doc/using_property_maps.html property maps]]
+[def __property_tags__ [@boost:libs/graph/doc/PropertyTag.html property tags]]
+
+[/ Boost reference links in code.]
+[def __mpl_void__ [@boost:libs/mpl/doc/refmanual/void.html `boost::mpl::void_`]]
+[def _mpl_void_ [@boost:libs/mpl/doc/refmanual/void.html boost::mpl::void_]]
+[def __mpl_true__ [@boost:libs/mpl/doc/refmanual/bool.html `boost::mpl::true_`]]
+[def _mpl_true_ [@boost:libs/mpl/doc/refmanual/bool.html boost::mpl::true_]]
+[def __mpl_false__ [@boost:libs/mpl/doc/refmanual/bool.html `boost::mpl::false_`]]
+[def _mpl_false_ [@boost:libs/mpl/doc/refmanual/bool.html boost::mpl::false_]]
+[def __fusion_nil__ [@boost:libs/fusion/doc/html/fusion/container/cons.html `boost::fusion::nil`]]
+[def _fusion_nil_ [@boost:libs/fusion/doc/html/fusion/container/cons.html boost::fusion::nil]]
+[def __fusion_map__ [@boost:libs/fusion/doc/html/fusion/container/map.html `boost::fusion::map`]]
+[def __fusion_has_key__ [@boost:libs/fusion/doc/html/fusion/sequence/intrinsic/functions/has_key.html `boost::fusion::has_key`]]
+[def _fusion_has_key_ [@boost:libs/fusion/doc/html/fusion/sequence/intrinsic/functions/has_key.html boost::fusion::has_key]]
+[def __result_of_has_key__ [@boost:libs/fusion/doc/html/fusion/sequence/intrinsic/metafunctions/has_key.html boost::fusion::result_of::has_key]]
+[def __fusion_at_key__ [@boost:libs/fusion/doc/html/fusion/sequence/intrinsic/functions/at_key.html `boost::fusion::at_key`]]
+[def _fusion_at_key_ [@boost:libs/fusion/doc/html/fusion/sequence/intrinsic/functions/at_key.html boost::fusion::at_key]]
+[def __result_of_at_key__ [@boost:libs/fusion/doc/html/fusion/sequence/intrinsic/metafunctions/at_key.html boost::fusion::result_of::at_key]]
+[def __fusion_pair__ [@boost:libs/fusion/doc/html/fusion/support/pair.html boost::fusion::pair]]
+[def __fusion_make_pair__ [@boost:libs/fusion/doc/html/fusion/support/pair.html boost::fusion::make_pair]]
+[def __basic_format__ [@boost:doc/html/format.html `boost::basic_format`]]
+[def __array__ [@boost:doc/html/boost/array.html `boost::array`]]
+[def __tr1_unordered_set__ [@boost:doc/html/boost/unordered_set.html `std::tr1::unordered_set`]]
+[def _tr1_unordered_set_ [@boost:doc/html/boost/unordered_set.html std::tr1::unordered_set]]
+[def __tr1_unordered_map__ [@boost:doc/html/boost/unordered_map.html `std::tr1::unordered_map`]]
+[def _tr1_unordered_map_ [@boost:doc/html/boost/unordered_map.html std::tr1::unordered_map]]
+[def __ublas_matrix__ [@boost:libs/numeric/ublas/doc/matrix.htm `boost::numeric::ublas::matrix`]]
+[def _ublas_matrix_ [@boost:libs/numeric/ublas/doc/matrix.htm boost::numeric::ublas::matrix]]
+[def __ublas_prod__ [@boost:numeric/ublas/doc/matrix_expression.htm#matrix_vector_operations `boost::numeric::ublas::prod()`]]
+[def __property_map__ [@boost:libs/graph/doc/property_map.html `boost::property_map`]]
+[def _property_map_ [@boost:libs/graph/doc/property_map.html boost::property_map]]
+[def __property__ [@boost:libs/graph/doc/using_property_maps.html `boost::property`]]
+[def _property_ [@boost:libs/graph/doc/using_property_maps.html boost::property]]
+[def __vertex_index__ [@boost:libs/graph/doc/PropertyTag.html `boost::vertex_index`]]
+[def _vertex_index_ [@boost:libs/graph/doc/PropertyTag.html boost::vertex_index]]
+[def __graph_traits__ [@boost:libs/graph/doc/graph_traits.html `boost::graph_traits`]]
+[def _graph_traits_ [@boost:libs/graph/doc/graph_traits.html boost::graph_traits]]
+[def __graph_adjacency_list__ [@boost:libs/graph/doc/adjacency_list.html `boost::adjacency_list`]]
+[def __graph_kruskal_mst__ [@boost:libs/graph/doc/kruskal_min_spanning_tree.html `boost::kruskal_minimum_spanning_tree`]]
+
+[/ Boost.Automata dependencies.]
+[def __Boost_ContainerGen__ [@http://svn.boost.org/svn/boost/sandbox/utility-container_gen/libs/utility/container_gen/doc/html/index.html [*Boost.ContainerGen]]]
+[def __Boost_Tree_Node__ [@http://svn.boost.org/svn/boost/sandbox/tree_node/libs/tree_node/doc/html/index.html [*Boost.TreeNode]]]
+[def __BGL_loop_erased_random_tree__ [@@http://svn.boost.org/svn/boost/sandbox/graph-loop_erased_random_tree/libs/graph/doc/loop_erased_random_tree.html [*Boost.Graph.LoopErasedRandomTree]]]
+[def __BGL_Intrusive_Layout__ [@@http://svn.boost.org/svn/boost/sandbox/graph-intrusive_layout/libs/graph/doc/set_orthogonal_grid_layout.html [*Boost.Graph.IntrusiveLayout]]]
+
+[/ These phrase-level bootstrap templates power the phrase-level]
+[/ nullary templates that evaluate to Boost.Automata links.]
+[template termlink[term] [link automata.glossary [term]]]
+[/ template tutoriallink[id name] [link automata.tutorials.[id] [*[name]]]]
+[/ template conceptlink[id name] [link automata.concepts.[id] [*[name]]]]
+[/ template codelink[id name] [link automata.reference.[id] [^[name]]]]
+[/ template lcodelink[id name] [link automata.reference.[id] [name]]]
+
+[/ Boost.Automata tutorial links.]
+[def __Basics_tutorial__ [link automata.tutorials.basics [*Basics tutorial]]]
+[def __DFA_program__ [link automata.tutorials.dfa [*DFA program]]]
+[def __DFA_tutorial__ [link automata.tutorials.dfa [*DFA tutorial]]]
+[def __Deterministic_Finite_Automata_tutorial__ [link automata.tutorials.dfa [*Deterministic Finite Automata tutorial]]]
+[def __Function_to_Automaton_tutorial__ [link automata.tutorials.func2a [*Function-to-Automaton tutorial]]]
+[def __Automata_Builders_tutorial__ [link automata.tutorials.builders [*Automata Builders tutorial]]]
+[def __Input_Rules_tutorial__ [link automata.tutorials.input_rules [*Input Rules tutorial]]]
+[def __Observer_Policies_tutorial__ [link automata.tutorials.observer_policies [*Observer Policies tutorial]]]
+[def __Cellular_Automata_tutorial__ [link automata.tutorials.cellular_automata [*Cellular Automata tutorial]]]
+[def __Input_Validation_and_Undoable_Automata_tutorial__ [link automata.tutorials.undo [*Input Validation and Undoable Automata tutorial]]]
+[def __t_basic_test_program__ [link automata.tutorials.basics basic test program]]
+[def __t_the_original_program__ [link automata.tutorials.dfa the original program]]
+[def __t_Automata_builders__ [link automata.tutorials.builders Automata builders]]
+[def __t_input_rules__ [link automata.tutorials.input_rules input rules]]
+[def __t_observers__ [link automata.tutorials.observer_policies observers]]
+[def __t_policies__ [link automata.tutorials.observer_policies policies]]
+[def __t_built_in_insertion_policies__ [link automata.tutorials.observer_policies built-in insertion policies]]
+[def __t_maze_application__ [link automata.tutorials.undo maze application]]
+[def __t_random_maze_situations__ [link automata.tutorials.undo random-maze simulations]]
+[def __t_input_validators_or_undo_capability__ [link automata.tutorials.undo input validators or undo capability]]
+[def __t_two_of_our_program_requirements__ [link automata.tutorials.undo two of our program requirements]]
+[def __t_neural_network__ [link automata.tutorials.byo_automata neural network]]
+[def __t_building_your_own_automata_types__ [link automata.tutorials.byo_automata building your own automata types]]
+[def __t_generator_type__ [link automata.tutorials.byo_automata.generator generator type]]
+[def __t_section_on_transition_functions__ [link automata.tutorials.byo_automata.transition_function section on transition functions]]
+[def __t_build_your_own_policy_types__ [link automata.tutorials.byo_automata.policy build your own policy types]]
+
+[/ This template works only if used within a Boost.Automata tutorial section.]
+[/ template tutorial_source[file] [@../../../[file] [file]]]
+
+[/ Boost.Automata tutorial source file links.]
+[def __test_dpda_builder_hpp__ [@../../test/dpda_builder.hpp test/dpda_builder.hpp]]
+[def __test_dpda_builder_cpp__ [@../../test/dpda_builder.cpp test/dpda_builder.cpp]]
+[def __test_basics_hpp__ [@../../test/basics.hpp test/basics.hpp]]
+[def __test_basics_cpp__ [@../../test/basics.cpp test/basics.cpp]]
+[def __test_builder_from_graph_cpp__ [@../../test/builder_from_graph.cpp test/builder_from_graph.cpp]]
+[def __test_dfa_builder_hpp__ [@../../test/dfa_builder.hpp test/dfa_builder.hpp]]
+[def __test_dfa_builder_cpp__ [@../../test/dfa_builder.cpp test/dfa_builder.cpp]]
+[def __test_dfa_cpp__ [@../../test/dfa.cpp test/dfa.cpp]]
+[def __example_dfa_builder_hpp__ [@../../example/dfa_builder.hpp example/dfa_builder.hpp]]
+[def __example_dfa_builder_cpp__ [@../../example/dfa_builder.cpp example/dfa_builder.cpp]]
+[def __example_dfa_cpp__ [@../../.xample/dfa.cpp example/dfa.cpp]]
+[def __example_markov_chain_cpp__ [@../../example/markov.cpp example/markov_chain.cpp]]
+[def __example_markov_decision_process_cpp__ [@../../example/markov_decision_process.cpp example/markov_decision_process.cpp]]
+[def __example_decision_tree_agent_cpp__ [@../../example/decision_tree_agent.cpp example/decision_tree_agent.cpp]]
+[def __example_elem_cell_automaton_cpp__ [@../../example/elem_cell_automaton.cpp example/elem_cell_automaton.cpp]]
+[def __example_game_of_life_cpp__ [@../../example/game_of_life.cpp example/game_of_life.cpp]]
+[def __example_wireworld_cpp__ [@../../example/wireworld.cpp example/wireworld.cpp]]
+[def __example_maze_hpp__ [@../../example/maze.hpp example/maze.hpp]]
+[def __example_maze_cpp__ [@../../example/maze.cpp example/maze.cpp]]
+[def __example_neural_network_generator_hpp__ [@../../example/neural_network_generator.hpp example/neural_network_generator.hpp]]
+[def __example_neural_network_trans_func_hpp__ [@../../example/neural_network_trans_func.hpp example/neural_network_trans_func.hpp]]
+[def __example_neural_network_make_samples_hpp__ [@../../example/neural_network_make_samples.hpp example/neural_network_make_samples.hpp]]
+[def __example_neural_network_builder_hpp__ [@../../example/neural_network_builder.hpp example/neural_network_builder.hpp]]
+[def __example_neural_network_policy_hpp__ [@../../example/neural_network_policy.hpp example/neural_network_policy.hpp]]
+[def __example_neural_network_cpp__ [@../../example/neural_network.cpp example/neural_network.cpp]]
+
+[/ This template works only if used within a Boost.Automata reference section.]
+[/ template automata_header[file] [@../../../../../../boost/automata/[file].hpp <boost/automata/[file].hpp>]]
+
+[/ Boost.Automata reference header file links.]
+[def __boost_automata_automaton_hpp__ [@../../../../boost/automata/automaton.hpp boost/automata/automaton.hpp]]
+[def __boost_automata_function_automaton_hpp__ [@../../../../boost/automata/function_automaton.hpp boost/automata/function_automaton.hpp]]
+[def __boost_automata_generator_dpda_hpp__ [@../../../../boost/automata/generator/dpda.hpp boost/automata/generator/dpda.hpp]]
+[def __boost_automata_transition_function_dpda_hpp__ [@../../../../boost/automata/transition_function/dpda.hpp boost/automata/transition_function/dpda.hpp]]
+[def __boost_automata_generator_dfa_hpp__ [@../../../../boost/automata/generator/dfa.hpp boost/automata/generator/dfa.hpp]]
+[def __boost_automata_transition_function_matrix_hpp__ [@../../../../boost/automata/transition_function/matrix.hpp boost/automata/transition_function/matrix.hpp]]
+[def __boost_automata_transition_function_mapped_input_tabular_hpp__ [@../../../../boost/automata/transition_function/mapped_input_tabular.hpp boost/automata/transition_function/mapped_input_tabular.hpp]]
+[def __boost_automata_transition_function_mapped_input_hpp__ [@../../../../boost/automata/transition_function/mapped_input.hpp boost/automata/transition_function/mapped_input.hpp]]
+[def __boost_automata_transition_function_next_state_hpp__ [@../../../../boost/automata/transition_function/next_state.hpp boost/automata/transition_function/next_state.hpp]]
+[def __boost_automata_generator_deterministic_hpp__ [@../../../../boost/automata/generator/deterministic.hpp boost/automata/generator/deterministic.hpp]]
+[def __boost_automata_transition_function_adaptor_hpp__ [@../../../../boost/automata/transition_function/adaptor.hpp boost/automata/transition_function/adaptor.hpp]]
+[def __boost_automata_transition_function_input_rule_hpp__ [@../../../../boost/automata/transition_function/input_rule.hpp boost/automata/transition_function/input_rule.hpp]]
+[def __boost_automata_input_rule_cellular_graph_hpp__ [@../../../../boost/automata/input_rule/cellular_graph.hpp boost/automata/input_rule/cellular_graph.hpp]]
+[def __boost_automata_transition_function_totalistic_boolean_cell_hpp__ [@../../../../boost/automata/transition_function/totalistic_boolean_cell.hpp boost/automata/transition_function/totalistic_boolean_cell.hpp]]
+[def __boost_automata_transition_function_totalistic_dt_cell_hpp__ [@../../../../boost/automata/transition_function/totalistic_dt_cell.hpp boost/automata/transition_function/totalistic_dt_cell.hpp]]
+[def __boost_automata_input_rule_wolfram_code_hpp__ [@../../../../boost/automata/input_rule/wolfram_code.hpp boost/automata/input_rule/wolfram_code.hpp]]
+[def __boost_automata_generator_probabilistic_hpp__ [@../../../../boost/automata/generator/probabilistic.hpp boost/automata/generator/probabilistic.hpp]]
+[def __boost_automata_transition_function_mdp_mapped_input_hpp__ [@../../../../boost/automata/transition_function/mdp_mapped_input.hpp boost/automata/transition_function/mdp_mapped_input.hpp]]
+[def __boost_automata_transition_function_decision_tree_hpp__ [@../../../../boost/automata/transition_function/decision_tree.hpp boost/automata/transition_function/decision_tree.hpp]]
+[def __boost_automata_observer_base_hpp__ [@../../../../boost/automata/observer/base.hpp boost/automata/observer/base.hpp]]
+[def __boost_automata_observer_full_noop_hpp__ [@../../../../boost/automata/observer/full_noop.hpp boost/automata/observer/full_noop.hpp]]
+[def __boost_automata_observer_output_hpp__ [@../../../../boost/automata/observer/output.hpp boost/automata/observer/output.hpp]]
+[def __boost_automata_policy_single_final_state__ [@../../../../boost/automata/policy/single_final_state.hpp boost/automata/policy/single_final_state.hpp]]
+[def __boost_automata_policy_parallel_final_states__ [@../../../../boost/automata/policy/parallel_final_states.hpp boost/automata/policy/parallel_final_states.hpp]]
+[def __boost_automata_policy_serial_final_states__ [@../../../../boost/automata/policy/serial_final_states.hpp boost/automata/policy/serial_final_states.hpp]]
+[def __boost_automata_policy_bool_insertion__ [@../../../../boost/automata/policy/bool_insertion.hpp boost/automata/policy/bool_insertion.hpp]]
+[def __boost_automata_policy_dpda_insertion__ [@../../../../boost/automata/policy/dpda_insertion.hpp boost/automata/policy/dpda_insertion.hpp]]
+[def __boost_automata_policy_dfa_insertion__ [@../../../../boost/automata/policy/dfa_insertion.hpp boost/automata/policy/dfa_insertion.hpp]]
+[def __boost_automata_policy_mdp_best_input__ [@../../../../boost/automata/policy/mdp_best_input.hpp boost/automata/policy/mdp_best_input.hpp]]
+[def __boost_automata_policy_moore_output__ [@../../../../boost/automata/policy/moore_output.hpp boost/automata/policy/moore_output.hpp]]
+[def __boost_automata_policy_mealy_output__ [@../../../../boost/automata/policy/mealy_output.hpp boost/automata/policy/mealy_output.hpp]]
+[def __boost_automata_policy_input_validation__ [@../../../../boost/automata/policy/input_validation.hpp boost/automata/policy/input_validation.hpp]]
+[def __boost_automata_policy_default_input_validation__ [@../../../../boost/automata/policy/default_input_validation.hpp boost/automata/policy/default_input_validation.hpp]]
+[def __boost_automata_builder_from_graph_hpp__ [@../../../../boost/automata/builder/from_graph.hpp boost/automata/builder/from_graph.hpp]]
+[def __boost_automata_builder_from_graph_single_final_state_hpp__ [@../../../../boost/automata/builder/from_graph/single_final_state.hpp boost/automata/builder/from_graph/single_final_state.hpp]]
+[def __boost_automata_builder_from_graph_multiple_final_states_hpp__ [@../../../../boost/automata/builder/from_graph/multiple_final_states.hpp boost/automata/builder/from_graph/multiple_final_states.hpp]]
+[def __boost_automata_builder_function_hpp__ [@../../../../boost/automata/builder/function.hpp boost/automata/builder/function.hpp]]
+
+[/ Boost.Automata concept links.]
+[def __Automaton__ [link automata.concepts.automaton [*Automaton]]]
+[def __Automata__ [link automata.concepts.automaton [*Automata]]]
+[def __Discrete_Automaton__ [link automata.concepts.discrete_automaton [*Discrete Automaton]]]
+[def __Input_Enumerable_Automaton__ [link automata.concepts.input_enum_automaton [*Input-Enumerable Automaton]]]
+[def __Automaton_With_State_Register__ [link automata.concepts.automaton_wsr [*Automaton With State Register]]]
+[def __DPDA__ [link automata.concepts.dpda [*Deterministic Pushdown Automaton]]]
+[def __DFA__ [link automata.concepts.dfa [*Deterministic Finite Automaton]]]
+[def __Extensible_Automaton__ [link automata.concepts.ext_automaton [*Extensible Automaton]]]
+[def __Undoable_Automaton__ [link automata.concepts.undo_automaton [*Undoable Automaton]]]
+[def __Automaton_Base__ [link automata.concepts.automaton_base [*Automaton Base]]]
+[def __Discrete_Automaton_Base__ [link automata.concepts.discrete_automaton_base [*Discrete Automaton Base]]]
+[def __Finite_Input_Automaton_Base__ [link automata.concepts.finite_input_auto_base [*Finite-Input Automaton Base]]]
+[def __Transition_Function__ [link automata.concepts.trans_func [*Transition Function]]]
+[def __Transition_Functions__ [link automata.concepts.trans_func [*Transition Functions]]]
+[def __Constrained_Input_Transition_Function__ [link automata.concepts.const_input_trans_func [*Constrained-Input Transition Function]]]
+[def __State_Register_Transition_Function__ [link automata.concepts.sr_trans_func [*State Register Transition Function]]]
+[def __DPDA_Transition_Function__ [link automata.concepts.dpda_trans_func [*DPDA Transition Function]]]
+[def __DFA_Transition_Function__ [link automata.concepts.dfa_trans_func [*DFA Transition Function]]]
+[def __Tabular_Transition_Function__ [link automata.concepts.tabular_trans_func [*Tabular Transition Function]]]
+[def __Mapped_Input_Tabular_Transition_Function__ [link automata.concepts.mapped_in_tab_trans_func [*Mapped-Input Tabular Transition Function]]]
+[def __Mapped_Input_Transition_Function__ [link automata.concepts.mapped_in_trans_func [*Mapped-Input Transition Function]]]
+[def __Next_State_Transition_Function__ [link automata.concepts.next_state_trans_func [*Next-State Transition Function]]]
+[def __Probabilistic_Transition_Function__ [link automata.concepts.prob_trans_func [*Probabilistic Transition Function]]]
+[def __Input_Rule__ [link automata.concepts.input_rule [*Input Rule]]]
+[def __Observer__ [link automata.concepts.observer [*Observer]]]
+[def __Tagged_Construction_Observer__ [link automata.concepts.tagged_cons_observer [*Tagged Construction Observer]]]
+[def __Non_Tagged_Construction_Observer__ [link automata.concepts.non_tagged_cons_observer [*Non-Tagged Construction Observer]]]
+[def __Copyable_Observer__ [link automata.concepts.copyable_observer [*Copyable Observer]]]
+[def __Automaton_Observer__ [link automata.concepts.automaton_observer [*Automaton Observer]]]
+[def __Automaton_Observers__ [link automata.concepts.automaton_observer [*Automaton Observers]]]
+[def __Undoable_Automaton_Observer__ [link automata.concepts.undo_automaton_observer [*Undoable Automaton Observer]]]
+[def __Input_Validator__ [link automata.concepts.input_validator [*Input Validator]]]
+[def __Input_Validators__ [link automata.concepts.input_validator [*Input Validators]]]
+[def __Automaton_Builder__ [link automata.concepts.automaton_builder [*Automaton Builder]]]
+[def __Automaton_Builders__ [link automata.concepts.automaton_builder [*Automaton Builders]]]
+[def __Extensible_Automaton_Builder__ [link automata.concepts.ext_automaton_builder [*Extensible Automaton Builder]]]
+[def __Observer_Builder__ [link automata.concepts.observer_build [*Observer Builder]]]
+[def __Observer_Builders__ [link automata.concepts.observer_build [*Observer Builders]]]
+[def __Observer_Builder_From_Graph__ [link automata.concepts.observer_build_from_graph [*Observer Builder From Graph]]]
+[def __Extraction_Source__ [link automata.concepts.extraction_source [*Extraction Source]]]
+[def __Insertion_Target__ [link automata.concepts.insertion_target [*Insertion Target]]]
+[def __Transition_Function_Matrix__ [link automata.concepts.trans_func_matrix [*Transition Function Matrix]]]
+
+[/ Boost.Automata reference links.]
+[def __automaton__ [link automata.reference.automaton `automaton`]]
+[def _automaton_ [link automata.reference.automaton automaton]]
+[def __function_automaton__ [link automata.reference.function_automaton `function_automaton`]]
+[def _function_automaton_ [link automata.reference.function_automaton function_automaton]]
+[def __dpda_generator__ [link automata.reference.dpda_generator `dpda_generator`]]
+[def _dpda_generator_ [link automata.reference.dpda_generator dpda_generator]]
+[def __dpda_transition_function__ [link automata.reference.dpda_trans_func `dpda_transition_function`]]
+[def _dpda_transition_function_ [link automata.reference.dpda_trans_func dpda_transition_function]]
+[def __dfa_generator__ [link automata.reference.dfa_generator `dfa_generator`]]
+[def _dfa_generator_ [link automata.reference.dfa_generator dfa_generator]]
+[def __matrix_transition_function__ [link automata.reference.matrix_trans_func `matrix_transition_function`]]
+[def _matrix_transition_function_ [link automata.reference.matrix_trans_func matrix_transition_function]]
+[def __mapped_input_tabular_transition_function__ [link automata.reference.mapped_in_tab_trans_func `mapped_input_tabular_transition_function`]]
+[def _mapped_input_tabular_transition_function_ [link automata.reference.mapped_in_tab_trans_func mapped_input_tabular_transition_function]]
+[def __mapped_input_transition_function__ [link automata.reference.mapped_in_trans_func `mapped_input_transition_function`]]
+[def _mapped_input_transition_function_ [link automata.reference.mapped_in_trans_func mapped_input_transition_function]]
+[def __next_state_transition_function__ [link automata.reference.next_state_trans_func `next_state_transition_function`]]
+[def _next_state_transition_function_ [link automata.reference.next_state_trans_func next_state_transition_function]]
+[def __deterministic_generator__ [link automata.reference.deterministic_generator `deterministic_generator`]]
+[def _deterministic_generator_ [link automata.reference.deterministic_generator deterministic_generator]]
+[def __adaptor_transition_function__ [link automata.reference.adaptor_trans_func `adaptor_transition_function`]]
+[def _adaptor_transition_function_ [link automata.reference.adaptor_trans_func adaptor_transition_function]]
+[def __decision_tree_explicit_transition_function__ [link automata.reference.decision_tree_xp_trans_func `decision_tree_explicit_transition_function`]]
+[def _decision_tree_explicit_transition_function_ [link automata.reference.decision_tree_xp_trans_func decision_tree_explicit_transition_function]]
+[def __input_rule_transition_function__ [link automata.reference.input_rule_trans_func `input_rule_transition_function`]]
+[def _input_rule_transition_function_ [link automata.reference.input_rule_trans_func input_rule_transition_function]]
+[def __wolfram_code_input_rule__ [link automata.reference.wolfram_code_input_rule `wolfram_code_input_rule`]]
+[def _wolfram_code_input_rule_ [link automata.reference.wolfram_code_input_rule wolfram_code_input_rule]]
+[def __cellular_graph_input_rule__ [link automata.reference.cellular_graph_input_rule `cellular_graph_input_rule`]]
+[def _cellular_graph_input_rule_ [link automata.reference.cellular_graph_input_rule cellular_graph_input_rule]]
+[def __totalistic_boolean_cell_transition_function__ [link automata.reference.ttl_bool_cell_trans_func `totalistic_boolean_cell_transition_function`]]
+[def _totalistic_boolean_cell_transition_function_ [link automata.reference.ttl_bool_cell_trans_func totalistic_boolean_cell_transition_function]]
+[def __totalistic_dt_cell_transition_function__ [link automata.reference.ttl_dt_cell_trans_func `totalistic_dt_cell_transition_function`]]
+[def _totalistic_dt_cell_transition_function_ [link automata.reference.ttl_dt_cell_trans_func totalistic_dt_cell_transition_function]]
+[def __probabilistic_generator__ [link automata.reference.probabilistic_generator `probabilistic_generator`]]
+[def _probabilistic_generator_ [link automata.reference.probabilistic_generator probabilistic_generator]]
+[def __mdp_mapped_input_transition_function__ [link automata.reference.mdp_mapped_input_trans_func `mdp_mapped_input_transition_function`]]
+[def _mdp_mapped_input_transition_function_ [link automata.reference.mdp_mapped_input_trans_func mdp_mapped_input_transition_function]]
+[def __decision_tree_transition_function__ [link automata.reference.decision_tree_trans_func `decision_tree_transition_function`]]
+[def _decision_tree_transition_function_ [link automata.reference.decision_tree_trans_func decision_tree_transition_function]]
+[def __base_observer__ [link automata.reference.base_observer `base_observer`]]
+[def _base_observer_ [link automata.reference.base_observer base_observer]]
+[def __full_noop_observer__ [link automata.reference.full_noop_observer `full_noop_observer`]]
+[def _full_noop_observer_ [link automata.reference.full_noop_observer full_noop_observer]]
+[def __output_observer__ [link automata.reference.output_observer `output_observer`]]
+[def _output_observer_ [link automata.reference.output_observer output_observer]]
+[def __single_final_state_policy__ [link automata.reference.single_final_state_policy `single_final_state_policy`]]
+[def _single_final_state_policy_ [link automata.reference.single_final_state_policy single_final_state_policy]]
+[def __is_at_final_state__ [link automata.reference.is_at_final_state `is_at_final_state()`]]
+[def _is_at_final_state_ [link automata.reference.is_at_final_state is_at_final_state]]
+[def __parallel_final_states_policy__ [link automata.reference.parall_final_states_policy `parallel_final_states_policy`]]
+[def _parallel_final_states_policy_ [link automata.reference.parall_final_states_policy parallel_final_states_policy]]
+[def __has_visited_any_state__ [link automata.reference.has_visited_any_state `has_visited_any_state()`]]
+[def _has_visited_any_state_ [link automata.reference.has_visited_any_state has_visited_any_state]]
+[def __serial_final_states_policy__ [link automata.reference.serial_final_states_policy `serial_final_states_policy`]]
+[def _serial_final_states_policy_ [link automata.reference.serial_final_states_policy serial_final_states_policy]]
+[def __has_no_unvisited_states__ [link automata.reference.has_no_unvisited_states `has_no_unvisited_states()`]]
+[def _has_no_unvisited_states_ [link automata.reference.has_no_unvisited_states has_no_unvisited_states]]
+[def __bool_insertion_policy__ [link automata.reference.bool_insertion_policy `bool_insertion_policy`]]
+[def _bool_insertion_policy_ [link automata.reference.bool_insertion_policy bool_insertion_policy]]
+[def __dpda_insertion_policy__ [link automata.reference.dpda_insertion_policy `dpda_insertion_policy`]]
+[def _dpda_insertion_policy_ [link automata.reference.dpda_insertion_policy dpda_insertion_policy]]
+[def __dfa_insertion_policy__ [link automata.reference.dfa_insertion_policy `dfa_insertion_policy`]]
+[def _dfa_insertion_policy_ [link automata.reference.dfa_insertion_policy dfa_insertion_policy]]
+[def __mdp_best_input_policy__ [link automata.reference.mdp_best_input `mdp_best_input`]]
+[def _mdp_best_input_policy_ [link automata.reference.mdp_best_input mdp_best_input]]
+[def __moore_output_policy__ [link automata.reference.moore_output_policy `moore_output_policy`]]
+[def _moore_output_policy_ [link automata.reference.moore_output_policy moore_output_policy]]
+[def __mealy_output_policy__ [link automata.reference.mealy_output_policy `mealy_output_policy`]]
+[def _mealy_output_policy_ [link automata.reference.mealy_output_policy mealy_output_policy]]
+[def __input_validation_policy__ [link automata.reference.input_valid_policy `input_validation_policy`]]
+[def _input_validation_policy_ [link automata.reference.input_valid_policy input_validation_policy]]
+[def __default_input_validation_policy__ [link automata.reference.def_input_valid_policy `default_input_validation_policy`]]
+[def _default_input_validation_policy_ [link automata.reference.def_input_valid_policy default_input_validation_policy]]
+[def __builder_from_graph__ [link automata.reference.builder_from_graph `builder_from_graph`]]
+[def _builder_from_graph_ [link automata.reference.builder_from_graph builder_from_graph]]
+[def __single_final_state_builder_from_graph__ [link automata.reference.single_final_state_bfg `single_final_state_builder_from_graph`]]
+[def _single_final_state_builder_from_graph_ [link automata.reference.single_final_state_bfg single_final_state_builder_from_graph]]
+[def __multiple_final_states_builder_from_graph__ [link automata.reference.multi_final_states_bfg `multiple_final_states_builder_from_graph`]]
+[def _multiple_final_states_builder_from_graph_ [link automata.reference.multi_final_states_bfg multiple_final_states_builder_from_graph]]
+[def __function_builder__ [link automata.reference.function_builder `function_builder`]]
+[def _function_builder_ [link automata.reference.function_builder function_builder]]
+
+[/ Autogenerate concept and reference documentation directly from code.]
+[/ Bypass Doxygen.]
+[import ../../../boost/automata/concept_check/trans_func.hpp]
+[import ../../../boost/automata/concept_check/sr_trans_func.hpp]
+[import ../../../boost/automata/concept_check/dpda_trans_func.hpp]
+[import ../../../boost/automata/concept_check/dfa_trans_func.hpp]
+[import ../../../boost/automata/concept_check/tabular_trans_func.hpp]
+[import ../../../boost/automata/concept_check/mapped_in_tab_trans_func.hpp]
+[import ../../../boost/automata/concept_check/mapped_in_trans_func.hpp]
+[import ../../../boost/automata/concept_check/next_state_trans_func.hpp]
+[import ../../../boost/automata/concept_check/trans_func_matrix.hpp]
+[import ../../../boost/automata/keyword/template.hpp]
+[import ../../../boost/automata/keyword/name.hpp]
+[import ../../../boost/automata/generator/dpda.hpp]
+[import ../../../boost/automata/transition_function/dpda.hpp]
+[import ../../../boost/automata/generator/dfa.hpp]
+[import ../../../boost/automata/transition_function/matrix.hpp]
+[import ../../../boost/automata/transition_function/mapped_input_tabular.hpp]
+[import ../../../boost/automata/transition_function/mapped_input.hpp]
+[import ../../../boost/automata/transition_function/next_state.hpp]
+[import ../../../boost/automata/generator/deterministic.hpp]
+[import ../../../boost/automata/transition_function/adaptor.hpp]
+[import ../../../boost/automata/transition_function/input_rule.hpp]
+[import ../../../boost/automata/input_rule/wolfram_code.hpp]
+[import ../../../boost/automata/input_rule/cellular_graph.hpp]
+[import ../../../boost/automata/transition_function/totalistic_boolean_cell.hpp]
+[import ../../../boost/automata/transition_function/totalistic_dt_cell.hpp]
+[import ../../../boost/automata/generator/probabilistic.hpp]
+[import ../../../boost/automata/transition_function/mdp_mapped_input.hpp]
+[import ../../../boost/automata/transition_function/decision_tree.hpp]
+[import ../../../boost/automata/builder/function.hpp]
+[import ../../../boost/automata/builder/from_graph.hpp]
+[import ../../../boost/automata/builder/from_graph/single_final_state.hpp]
+[import ../../../boost/automata/builder/from_graph/multiple_final_states.hpp]
+[import ../../../boost/automata/observer/base.hpp]
+[import ../../../boost/automata/observer/full_noop.hpp]
+[import ../../../boost/automata/observer/output.hpp]
+[import ../../../boost/automata/policy/single_final_state.hpp]
+[import ../../../boost/automata/policy/parallel_final_states.hpp]
+[import ../../../boost/automata/policy/serial_final_states.hpp]
+[import ../../../boost/automata/policy/bool_insertion.hpp]
+[import ../../../boost/automata/policy/dpda_insertion.hpp]
+[import ../../../boost/automata/policy/dfa_insertion.hpp]
+[import ../../../boost/automata/policy/mdp_best_input.hpp]
+[import ../../../boost/automata/policy/moore_output.hpp]
+[import ../../../boost/automata/policy/mealy_output.hpp]
+[import ../../../boost/automata/policy/default_input_validation.hpp]
+[import ../../../boost/automata/policy/input_validation.hpp]
+[import ../../../boost/automata/automaton.hpp]
+[import ../../../boost/automata/function_automaton.hpp]
+[import ../test/dpda_builder.hpp]
+[import ../test/dpda_builder.cpp]
+[import ../test/basics.hpp]
+[import ../test/basics.cpp]
+[import ../test/dfa_builder.hpp]
+[import ../test/dfa_builder.cpp]
+[import ../test/dfa.cpp]
+[import ../test/builder_from_graph.cpp]
+[import ../example/dfa_builder.hpp]
+[import ../example/dfa_builder.cpp]
+[import ../example/dfa.cpp]
+[import ../example/markov_chain.cpp]
+[import ../example/elem_cell_automaton.cpp]
+[import ../example/game_of_life.cpp]
+[import ../example/wireworld.cpp]
+[import ../example/markov_decision_process.cpp]
+[import ../example/decision_tree_agent.cpp]
+[import ../example/maze.hpp]
+[import ../example/maze.cpp]
+[import ../example/neural_network_generator.hpp]
+[import ../example/neural_network_trans_func.hpp]
+[import ../example/neural_network_builder.hpp]
+[import ../example/neural_network_make_samples.hpp]
+[import ../example/neural_network_policy.hpp]
+[import ../example/neural_network.cpp]
+
+[/ index.html Start]
+
+[heading What It Is]
+Boost.Automata is a library of *data structures* that can be used to implement
+/dynamically configurable/ state machines. Such state machines enjoy
+widespread use in artificial intelligence, language processing, and graph
+walking simulations. Boost.Automaton's data structures derive their
+flexibility and power from *algorithms* that manipulate them.
+
+[heading What It Is Not]
+[*Boost.Automata is not a replacement for
+__Boost_Statechart__!] Boost.Statechart is a framework for implementing
+/static/ state machines, which are configurable only during compile
+time. These state machines are highly optimized and fault-tolerant because of
+the requirements placed upon them. They derive their flexibility and power
+from their near-conformance to UML standards, enabling /state machine
+designers/ to employ Boost.Statechart effectively. Boost.Automata, on the
+other hand, is modeled after the __STL__, where genericity is the main
+concern.
+
+[heading Getting Started]
+Boost.Automata is a header-only library. However, you need an up-to-date
+compiler to be able to use it in your programs.
+
+[important
+ Some components depend on __Boost_Type_Traits_Operators__, which has been
+ recently accepted into Boost but is currently not part of an official
+ release. For now, you must perform a Subversion checkout from the
+ __SVN_Trac__.
+
+ Some components and tutorials depend on __Boost_Tree_Node__,
+ __BGL_loop_erased_random_tree__, and __BGL_Intrusive_Layout__, none of
+ which have been been submitted for review yet.
+]
+
+[/ index.html End]
+
+[warning
+ The documentation is still lagging and/or under construction in most areas,
+ especially concepts.
+]
+
+[include tutorials.qbk]
+[include glossary.qbk]
+[include reference.qbk]
+[include concepts.qbk]
+

Added: sandbox/automata/libs/automata/doc/concepts.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/concepts.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,80 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section Concepts]
+
+[include cc_automaton.qbk]
+[include cc_discrete_automaton.qbk]
+[include cc_finite_input_automaton.qbk]
+[include cc_automaton_wsr.qbk]
+[include cc_dpda.qbk]
+[include cc_dfa.qbk]
+[include cc_ext_automaton.qbk]
+[include cc_undo_automaton.qbk]
+[include cc_automaton_base.qbk]
+[include cc_discrete_auto_base.qbk]
+[include cc_finite_input_auto_base.qbk]
+[include cc_transition_function.qbk]
+[include cc_sr_trans_func.qbk]
+[include cc_dpda_trans_func.qbk]
+[include cc_dfa_trans_func.qbk]
+[include cc_tabular_trans_func.qbk]
+[include cc_mapped_in_tab_trans_func.qbk]
+[include cc_mapped_input_trans_func.qbk]
+[include cc_next_state_trans_func.qbk]
+[include cc_observer.qbk]
+[include cc_automaton_observer.qbk]
+[include cc_undo_automaton_observer.qbk]
+[include cc_input_validator.qbk]
+[include cc_automaton_builder.qbk]
+[include cc_ext_automaton_builder.qbk]
+[include cc_observer_builder.qbk]
+[include cc_obs_builder_from_graph.qbk]
+[include cc_extraction_source.qbk]
+[include cc_insertion_target.qbk]
+[include cc_trans_func_matrix.qbk]
+
+[heading Core Concepts]
+
+ * __Automaton__
+ * __Discrete_Automaton__
+ * __Finite_Input_Automaton__
+ * __Automaton_With_State_Register__
+ * __DPDA__
+ * __DFA__
+ * __Extensible_Automaton__
+ * __Undoable_Automaton__
+ * __Automaton_Base__
+ * __Discrete_Automaton_Base__
+ * __Finite_Input_Automaton_Base__
+ * __Transition_Function__
+ * __State_Register_Transition_Function__
+ * __DPDA_Transition_Function__
+ * __DFA_Transition_Function__
+ * __Tabular_Transition_Function__
+ * __Mapped_Input_Tabular_Transition_Function__
+ * __Mapped_Input_Transition_Function__
+ * __Next_State_Transition_Function__
+ * __Observer__
+ * __Copyable_Observer__
+ * __Automaton_Observer__
+ * __Undoable_Automaton_Observer__
+ * __Input_Validator__
+ * __Automaton_Builder__
+ * __Extensible_Automaton_Builder__
+ * __Observer_Builder__
+ * __Observer_Builder_From_Graph__
+
+[heading Auxiliary Concepts]
+
+ * __Extraction_Source__
+ * __Insertion_Target__
+ * __Transition_Function_Matrix__
+
+[endsect] [/ Concepts]
+

Added: sandbox/automata/libs/automata/doc/glossary.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/glossary.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,225 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section Glossary]
+The design of Boost.Automata is based primarily on the most practical aspects
+of __automata_theory__. (Implementations of other state machines in the
+__Chomsky_hierarchy__ or elsewhere are also welcome to be subsumed,
+however.) A glossary of terms is included below to help you understand this
+library's various moving parts and their relation to one another.
+
+[table
+ [[Term][Definition]]
+ [
+ [*automaton*]
+ [
+ Also known as a *state machine*. Depending on the context, an
+ automaton may represent an artificially intelligent agent, a
+ parser, or a graph walker. When you initialize an automaton, you
+ change its *transition function*. When you otherwise modify an
+ automaton, either by resetting it or by processing *input symbols*,
+ you change its *state*.
+ ]
+ ]
+ [
+ [*state*]
+ ['''
+ <orderedlist numeration='arabic'>
+ <listitem>
+ <para>An entity that determines the behavior of an
+ <emphasis role='strong'>automaton</emphasis>. Depending on the
+ context, a state may describe an agent's logical thought process,
+ a node in a parse tree, or a location that a graph walker can
+ reach.</para>
+ </listitem>
+ <listitem>
+ <para>A collection of data that corresponds to such an
+ entity.</para>
+ </listitem>
+ </orderedlist>
+ ''']
+ ]
+ [
+ [*current state*]
+ ['''
+ <orderedlist numeration='arabic'>
+ <listitem>
+ <para>The entity that determines the current behavior of an
+ <emphasis role='strong'>automaton</emphasis>.</para>
+ </listitem>
+ <listitem>
+ <para>The collection of data that corresponds to such an entity
+ by virtue of being currently stored in the automaton.</para>
+ </listitem>
+ </orderedlist>
+ ''']
+ ]
+ [
+ [*input symbol*]
+ [
+ An entity that an *automaton* processes. Depending on the context,
+ an input symbol may represent the firing of an axon in a neural
+ network, a letter in an alphabet, or a signal that tells the graph
+ walker to traverse a certain edge.
+ ]
+ ]
+ [
+ [*nontrivial input symbol*]
+ [
+ An *input symbol* that, if processed by an *automaton*, causes it
+ to change its *current state*.
+ ]
+ ]
+ [
+ [*source state*]
+ [
+ The *current state* of an *automaton* that has been initialized or
+ reset. Depending on the context, the source state may describe an
+ agent's first thought, the root of a parse tree, or the source
+ vertex of a graph.
+ ]
+ ]
+ [
+ [*final state*]
+ [
+ A *state* at which an *automaton* should stop processing *input
+ symbols* during a normal course of execution; also known as an
+ *accepting state*. Depending on the context, a final state may
+ describe AI enlightenment, a leaf in a parse tree, or the target
+ vertex of a graph.
+ ]
+ ]
+ [
+ [*transition function*]
+ [
+ A function that takes in the *current state* of an *automaton* and
+ one or more *input symbols* and calculates the set of *states* to
+ which the automaton may change if it processes the input symbol(s).
+ ]
+ ]
+ [
+ [*state set*]
+ [
+ The collection of *states* that can be members of the set returned
+ by a *transition function*.
+ ]
+ ]
+ [
+ [*nondeterministic automaton*]
+ [
+ An *automaton* whose *transition function* may process /zero or
+ more/ *input symbols* and/or return /one or more/ *states* at
+ which the automaton could end up.
+ ]
+ ]
+ [
+ [*deterministic automaton*]
+ [
+ An *automaton* whose *transition function* returns /exactly one/
+ *state*, the state at which the automaton will end up.
+ ]
+ ]
+ [
+ [*discrete automaton*]
+ [
+ An *automaton* that recognizes a countable (but not necessarily
+ finite) *state set*. With such a state set it is possible to
+ calculate which *input symbols* are *nontrivial* for a certain
+ state.
+ ]
+ ]
+ [
+ [*finite automaton*]
+ [
+ A *discrete automaton* that recognizes a bounded or non-infinite
+ *state set*.
+ ]
+ ]
+ [
+ [*nondeterministic finite automaton (NFA)*]
+ [
+ A *finite automaton* that is also a *nondeterministic automaton*.
+ ]
+ ]
+ [
+ [*deterministic finite automaton (DFA)*]
+ [
+ A *finite automaton* whose *transition function* processes
+ /exactly one/ *input symbol* and returns /exactly one/ *state*,
+ the state at which the automaton will end up. An unsigned integer
+ can therefore represent the *current state* of a DFA.
+ ]
+ ]
+ [
+ [*state register*]
+ [
+ The part of a *DFA* that stores its *current state*.
+ ]
+ ]
+ [
+ [*pushdown automaton (PDA)*]
+ [
+ A *discrete automaton* that can be (though not necessarily is)
+ implemented as a *finite automaton* plus a stack that recognizes a
+ different set of symbols from the one the automaton itself regards
+ as *input symbols*. As a result, its *transition function* accepts
+ an additional but optional parameter that tells the automaton
+ whether or not to pop from the stack, and its return value includes
+ an optional symbol to push on top of the stack.
+ ]
+ ]
+ [
+ [*nondeterministic pushdown automaton (NPDA)*]
+ [
+ A *pushdown automaton* whose (conceptually) underlying *finite
+ automaton* is an *NFA*.
+ ]
+ ]
+ [
+ [*deterministic pushdown automaton (DPDA)*]
+ [
+ A *pushdown automaton* whose (conceptually) underlying *finite
+ automaton* is a *DFA*.
+ ]
+ ]
+ [
+ [*memento*]
+ [
+ A data structure used to save the *current state* of an *automaton*
+ before an *input symbol* is processed so that the automaton can be
+ restored to that state when the processing of that input symbol
+ needs to be undone.
+ ]
+ ]
+ [
+ [*previous state*]
+ [
+ The *state* of an *automaton* that was saved to the *memento*
+ before it processed an *input symbol*.
+ ]
+ ]
+ [
+ [*cellular automaton*]
+ [
+ An *automaton* whose *state* is stored in cells that are themselves
+ automata. The *transition function* of each cell takes in the
+ states of the neighboring cells as input.
+ ]
+ ]
+ [
+ [*totalistic cellular automaton*]
+ [
+ A *cellular automaton* whose cell *state* is a discrete value and
+ whose cell *transition function* either adds up or tallies the
+ states of the neighboring cells.
+ ]
+ ]
+]
+
+[endsect] [/ Glossary]
+

Added: sandbox/automata/libs/automata/doc/ref_automaton.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/ref_automaton.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,501 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:automaton `automaton`]
+
+[section Synopsis]
+[reference__automaton]
+[endsect]
+
+[section Description]
+This class template serves as the primary front-end of Boost.Automata; in most
+cases, you will use it to pull together all the components you need--such as
+state registers, transition functions, and observer-generating policies--into
+a single state machine, or as many as you need for the task at hand. With the
+appropriate components, an `automaton` type can model any refinement of the
+__Automaton__ concept defined by this library or by the user.
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_automaton_hpp__>
+``
+[endsect]
+
+[section:tpl_param Template Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`_BaseGenerator`]
+ [
+ The type that determines what comprises the [termlink state] of
+ this `automaton`.
+ ]
+ [
+ * It must model the __Unary_Metafunction_Class__ concept.
+ * Its return type must model the __Automaton_Base__ concept.
+ * If the `_IsUndoable` template-argument type evaluates to
+ __mpl_true__, then the return type must also model the
+ __Copy_Constructible__ concept.
+ ]
+ []
+ ]
+ [
+ [`_Function`]
+ [The type of the underlying transition function.]
+ [
+ * It must model the __Transition_Function__
+ concept.
+ * It must be a valid argument to the `_BaseGenerator`
+ template-argument type.
+ ]
+ []
+ ]
+ [
+ [`_Policies`]
+ [
+ The type of a heterogeneous container of policies that this
+ `automaton` will enact.
+ ]
+ [
+ * It must model the __Fusion_Forward_Sequence__ concept.
+ * Each of its element types must model the
+ __Unary_Metafunction_Class__ concept.
+ * The return type of the `_BaseGenerator` template-argument type
+ must be a valid argument for each element type.
+ * If the `_IsUndoable` template-argument type evaluates to
+ __mpl_true__, then the return type of each element type must
+ model the __Undoable_Automaton_Observer__ concept; otherwise,
+ the return type of each element type must model the
+ __Automaton_Observer__ concept.
+ ]
+ [__fusion_nil__]
+ ]
+ [
+ [`_InputValidationPolicy`]
+ [
+ The type that determines how this `automaton` will validate its
+ inputs.
+ ]
+ [
+ * It must model the __Unary_Metafunction_Class__ concept.
+ * The return type of the `_BaseGenerator` template-argument type
+ must be a valid argument to this type.
+ * The return type must model the __Input_Validator__ concept.
+ ]
+ [__default_input_validation_policy__]
+ ]
+ [
+ [`_IsUndoable`]
+ [
+ The type that determines whether or not this `automaton` type will
+ model the __Undoable_Automaton__ concept.
+ ]
+ [It must model the __Boolean_Integral_Constant__ concept.]
+ [__mpl_false__]
+ ]
+]
+
+You can use the parameter names as __template_keywords__. For example, the
+following type definitions are semantically equivalent:
+
+``
+typedef automaton<
+ _dfa_generator_
+ , _matrix_transition_function_<_ublas_matrix_<std::size_t> >
+ , _fusion_nil_
+ , _default_input_validation_policy_
+ , _mpl_true_
+ >
+ DFA1;
+typedef automaton<
+ _dfa_generator_
+ , _matrix_transition_function_<_ublas_matrix_<std::size_t> >
+ , [*_IsUndoable]<_mpl_true_>
+ >
+ DFA2;
+typedef automaton<
+ [*_IsUndoable]<_mpl_true_>
+ , [*_BaseGenerator]<_dfa_generator_>
+ , [*_Function]<
+ _matrix_transition_function_< _ublas_matrix_<std::size_t> >
+ >
+ >
+ DFA3;
+``
+
+The last two definitions have the added benefit of not having to specify the
+default types of the `_Policies` and `_InputValidationPolicy` template
+parameters.
+
+All template parameter names for this class template are defined in the
+`boost::automata::keyword` namespace.
+[endsect] [/ Template Parameters]
+
+[section:model_of Model of]
+ * __Automaton__
+ * __Discrete_Automaton__ if the return type of the `_BaseGenerator`
+ template-argument type models the __Discrete_Automaton_Base__ concept
+ * __Input_Enumerable_Automaton__ if the return type of the `_BaseGenerator`
+ template-argument type models the __Input_Enumerable_Automaton_Base__
+ concept
+ * __Automaton_With_State_Register__ if the `_Function` template-argument
+ type models the __State_Register_Transition_Function__ concept
+ * __DPDA__ if the `_BaseGenerator` template-argument type evaluates to
+ __dpda_generator__ and the `_Function` template-argument type models the
+ __DPDA_Transition_Function__ concept
+ * __DFA__ if the `_BaseGenerator` template-argument type evaluates to
+ __dfa_generator__ and the `_Function` template-argument type models the
+ __DFA_Transition_Function__ concept
+ * __Extensible_Automaton__ if the `_Policies` template-argument type is a
+ non-__empty__ __Fusion_Forward_Sequence__ model
+ * __Undoable_Automaton__ if the `_isUndoable` template-argument type
+ evaluates to __mpl_true__
+[endsect]
+
+[section:public_bases Public Base Classes]
+The return type of the `_BaseGenerator` template-argument type.
+[endsect]
+
+[section Members]
+[table
+ [[Name][Expression][Description]]
+ [
+ [Transition function type]
+ [`transition_function`]
+ [Defined by the __Automaton__ concept.]
+ ]
+ [
+ [Observer map type]
+ [`observer_map`]
+ [Defined by the __Extensible_Automaton__ concept.]
+ ]
+ [
+ [Traits type]
+ [`traits`]
+ [Defined by the __Automaton__ concept.]
+ ]
+ [
+ [Default constructor]
+ [`automaton();`]
+ [
+ * Defined by the __Default_Constructible__ concept.
+ * Defined if and only if the return type of the `_BaseGenerator`
+ template-argument type defines its default constructor in
+ `public` or `protected` scope.
+ ]
+ ]
+ [
+ [Build Constructor]
+ [``
+ template <
+ typename A0
+ , typename A1
+ , typename A2
+ , typename A3
+ , typename A4
+ >
+ automaton(
+ A0 const&
+ , A1 const& = implementation_defined
+ , A2 const& = implementation_defined
+ , A3 const& = implementation_defined
+ , A4 const& = implementation_defined
+ );
+ ``]
+ [
+ Read the [link automata.reference.automaton.build_ctor_param
+ Build Constructor Parameters] section for parameter descriptions.
+ ]
+ ]
+ [
+ [Copy constructor]
+ [`automaton(automaton const&);`]
+ [
+ * Defined by the __Copy_Constructible__ concept.
+ * Defined if and only if the return type of the `_BaseGenerator`
+ template-argument type models the __Copy_Constructible__
+ concept, the return type of each element type of the `_Policies`
+ template-argument type models the __Copyable_Observer__ concept,
+ and the return type of the `_InputValidationPolicy`
+ template-argument type models the __Copyable_Observer__ concept.
+ ]
+ ]
+ [
+ [Assignment operator]
+ [`automaton& operator=(automaton const&);`]
+ [
+ * Defined by the __Assignable__ concept.
+ * Defined if and only if the return type of the `_BaseGenerator`
+ template-argument type models the __Assignable__ concept, the
+ return type of each element type of the `_Policies`
+ template-argument type models the __Assignable__ concept, and
+ the return type of the `_InputValidationPolicy` template-argument
+ type models the __Assignable__ concept.
+ ]
+ ]
+ [
+ [State assignment operator]
+ [`function_automaton& operator=(traits::state const&);`]
+ [Sets the [termlink source state] of this `automaton`.]
+ ]
+ [
+ [Function assignment operator]
+ [``
+ template <typename TFunction>
+ automaton& operator=(TFunction);
+ ``]
+ [
+ * Forwards to the transition function's assignment operator.
+ * Defined if and only if the previously mentioned operator is
+ defined and accepts the specified argument.
+ ]
+ ]
+ [
+ [Initialization]
+ [``
+ template <typename A0, typename A1>
+ void initialize(A0 const&, A1 const& = implementation_defined);
+ ``]
+ [
+ * Defined by the __Automaton__ concept.
+ * Read the [link automata.reference.automaton.init_param
+ Initialization Parameters] section for parameter descriptions.
+ ]
+ ]
+ [
+ [Resetting]
+ [`void reset();`]
+ [
+ * Defined by the __Automaton__ concept.
+ * If the underlying observer map is non-__empty__, then this
+ `automaton` will invoke each observer's `on_reset()` method.
+ ]
+ ]
+ [
+ [Transition function accessor]
+ [`transition_function const& get_transition_function() const;`]
+ [Defined by the __Automaton__ concept.]
+ ]
+ [
+ [Observer map accessor]
+ [`observer_map const& get_observer_map() const;`]
+ [Defined by the __Extensible_Automaton__ concept.]
+ ]
+ [
+ [Input processing]
+ [`template <typename Input> bool operator()(Input const&);`]
+ [
+ * Defined by the __Automaton__ concept.
+ * If the underlying observer map is non-__empty__, then this
+ `automaton` will perform one of the following actions:
+ * Forward the input to each observer's `on_invalid_input()`
+ method if the underlying input validator marks the input as
+ invalid.
+ * Forward the input to each observer's `on_accept_input()`
+ method if the `automaton` type is a __Discrete_Automaton__
+ and the nontrivial input check returns `true`, or if the
+ `automaton` type does *not* model the __Discrete_Automaton__
+ concept and the input processing implementation returns `true`.
+ * Forward the input to each observer's `on_reject_input()`
+ method if the `automaton` type is a __Discrete_Automaton__
+ and the nontrivial input check returns `false`, or if the
+ `automaton` type does *not* model the __Discrete_Automaton__
+ concept and the input processing implementation returns
+ `false`.
+ ]
+ ]
+ [
+ [Undo operation]
+ [`void undo();`]
+ [
+ * Defined by the __Undoable_Automaton__ concept.
+ * Defined if and only if the type of this `automaton` has been
+ configured to model the __Undoable_Automaton__ concept.
+ * If the underlying observer map is non-__empty__, then:
+ # If the operation succeeds in restoring this `automaton` to the
+ most recent snapshot, then it will invoke each observer's
+ `on_accept_undo()` method.
+ # Otherwise, the automaton will invoke each observer's
+ `on_reject_undo()` method.
+ ]
+ ]
+ [
+ [Undo ability check]
+ [`bool can_undo() const;`]
+ [
+ * Defined by the __Undoable_Automaton__ concept.
+ * Defined if and only if the type of this `automaton` has been
+ configured to model the __Undoable_Automaton__ concept.
+ ]
+ ]
+ [
+ [Undo limit access]
+ [`std::size_t get_undo_limit() const;`]
+ [
+ * Defined by the __Undoable_Automaton__ concept.
+ * Defined if and only if the type of this `automaton` has been
+ configured to model the __Undoable_Automaton__ concept.
+ ]
+ ]
+]
+[endsect] [/ Members]
+
+[section:build_ctor_param Build Constructor Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`_builder`]
+ [
+ A function object used to initialize the underlying transition
+ function.
+ ]
+ [
+ * If the `_Policies` template-argument type is non-__empty__, then
+ the data type must model the __Extensible_Automaton_Builder__
+ concept; otherwise, the data type must model the
+ __Automaton_Builder__ concept.
+ * The transition function must be a valid argument.
+ ]
+ []
+ ]
+ [
+ [`_policies`]
+ [
+ A heterogeneous container of policies that this `automaton` will
+ enact. If this container is non-__empty__, then the automaton
+ will transform each policy type into its metafunction class return
+ type, create an instance of that return type as an __Observer__,
+ and associate the policy type with the observer in the underlying
+ observer map. If this parameter is specified, then each observer's
+ build constructor will be invoked; otherwise, each observer's
+ subject-policy constructor will be invoked.
+ ]
+ [
+ The data type must be the same as the `_Policies` template-argument
+ type.
+ ]
+ [
+ A default-constructed instance of the `_Policies` template-argument
+ type.
+ ]
+ ]
+ [
+ [`_input_validation_policy`]
+ [
+ This `automaton` will transform the `_InputValidationPolicy`
+ template-argument type into its metafunction class return type and
+ create an instance of that return type as an
+ __Input_Validator__, which it will use for input validation. If
+ this parameter is specified, then the input validator's build
+ constructor will be invoked; otherwise, the input validator's
+ subject-policy constructor will be invoked.
+ ]
+ [
+ The data type must be the same as the `_InputValidationPolicy`
+ template-argument type.
+ ]
+ [
+ A default-constructed instance of the `_InputValidationPolicy`
+ template-argument type.
+ ]
+ ]
+ [
+ [`_source_state`]
+ [The [termlink source state] of this `automaton`.]
+ [The data type must be convertible to `traits::state`.]
+ [`traits::state()`]
+ ]
+ [
+ [`_undo_limit`]
+ [
+ The number of consecutive times that the `undo()` operation can be
+ carried out on this `automaton`.
+ ]
+ [
+ * The data type must be a primitive integral type.
+ * The type of this `automaton` must be configured to fulfill the
+ __Undoable_Automaton__ concept.
+ ]
+ [`std::size_t()`]
+ ]
+]
+
+You can __name_each_parameter__ when you invoke this constructor. Assume
+that the following function is defined:
+
+``
+void foo(_matrix_transition_function_<_ublas_matrix_<std::size_t> >&);
+``
+
+Continuing the [link automata.reference.automaton.tpl_param type definitions
+example], the following statements are semantically equivalent:
+
+``
+DFA1
+ dfa1(
+ foo
+ , _fusion_nil_()
+ , _default_input_validation_policy_()
+ , 18
+ , 32
+ );
+DFA2
+ dfa2(
+ foo
+ , [*_source_state] = 18
+ , [*_undo_limit] = 32
+ );
+DFA3
+ dfa3(
+ [*_undo_limit] = 32
+ , [*_builder] = foo
+ , [*_source_state] = 18
+ );
+``
+
+The last two instructions have the added benefit of not having to specify the
+default values of the `_policies` and `_input_validation_policy` parameters.
+
+All parameter names for this operation are defined in the
+`boost::automata::keyword` namespace.
+[endsect] [/ Build Constructor Parameters]
+
+[section:init_param Initialization Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`_builder`]
+ [
+ A function object used to initialize the underlying transition
+ function.
+ ]
+ [
+ * If the `_Policies` template-argument type is non-__empty__, then
+ the data type must model the __Extensible_Automaton_Builder__
+ concept; otherwise, the data type must model the
+ __Automaton_Builder__ concept.
+ * The transition function must be a valid argument.
+ ]
+ []
+ ]
+ [
+ [`_source_state`]
+ [The [termlink source state] of this `automaton`.]
+ [The data type must be convertible to `traits::state`.]
+ [`traits::state()`]
+ ]
+]
+
+You can __name_each_parameter__ when you invoke the `initialize()`
+method. All parameter names for this operation are defined in the
+`boost::automata::keyword` namespace.
+[endsect]
+
+[endsect] [/ automaton]
+

Added: sandbox/automata/libs/automata/doc/ref_builder.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/ref_builder.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,49 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:builder_from_graph `builder_from_graph`]
+
+[section Synopsis]
+[reference__builder_from_graph]
+[endsect]
+
+[section Description]
+In most literature that deals with __automata_theory__, graphs are used to
+represent [termlink transition functions]. This class template enables
+transition functions to be built via __BGL__ algorithms. The type of
+transition function that can be built depends on how a particular
+`builder_from_graph` and its supporting data structures are declared and
+defined.
+[endsect]
+
+[endsect] [/ builder_from_graph]
+
+[section:single_final_state_bfg `single_final_state_builder_from_graph`]
+
+[section Synopsis]
+[reference__single_final_state_builder_from_graph]
+[endsect]
+
+[endsect] [/ single_final_state_builder_from_graph]
+
+[section:multi_final_states_bfg `multiple_final_states_builder_from_graph`]
+
+[section Synopsis]
+[reference__multiple_final_states_builder_from_graph]
+[endsect]
+
+[endsect] [/ multiple_final_states_builder_from_graph]
+
+[section:function_builder `function_builder`]
+
+[section Synopsis]
+[reference__function_builder]
+[endsect]
+
+[endsect] [/ function_builder]
+

Added: sandbox/automata/libs/automata/doc/ref_function_automaton.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/ref_function_automaton.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,464 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:function_automaton `function_automaton`]
+
+[section Synopsis]
+[reference__function_automaton]
+[endsect]
+
+[section Description]
+This __Automaton__ model uses plain-vanilla __Binary_Functions__ rather
+than specific __Transition_Functions__ for transitioning between states;
+otherwise, it maintains much of the flexibility of the __automaton__ class
+template.
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_function_automaton_hpp__>
+``
+[endsect]
+
+[section:tpl_param Template Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [Function]
+ [
+ The type of the underlying function that this `function_automaton`
+ will treat as its transition function.
+ ]
+ [
+ * It must model the __Binary_Function__ concept.
+ * One of its argument types must be convertible to the return type.
+ ]
+ []
+ ]
+ [
+ [`_Policies`]
+ [
+ The type of a heterogeneous container of policies that this
+ `function_automaton` will enact.
+ ]
+ [
+ * It must model the __Fusion_Forward_Sequence__ concept.
+ * Each of its element types must model the
+ __Unary_Metafunction_Class__ concept.
+ * The return type of the `_BaseGenerator` template-argument type
+ must be a valid argument for each element type.
+ * If the `_IsUndoable` template-argument type evaluates to
+ __mpl_true__, then the return type of each element type must
+ model the __Undoable_Automaton_Observer__ concept; otherwise,
+ the return type of each element type must model the
+ __Automaton_Observer__ concept.
+ ]
+ [__fusion_nil__]
+ ]
+ [
+ [`_InputValidationPolicy`]
+ [
+ The type that determines how this `function_automaton` will
+ validate its inputs.
+ ]
+ [
+ * It must model the __Unary_Metafunction_Class__ concept.
+ * The return type of the `_BaseGenerator` template-argument type
+ must be a valid argument to this type.
+ * The return type must model the __Input_Validator__ concept.
+ ]
+ [__default_input_validation_policy__]
+ ]
+ [
+ [`_IsUndoable`]
+ [
+ The type that determines whether or not this `function_automaton`
+ type will model the __Undoable_Automaton__ concept.
+ ]
+ [It must model the __Boolean_Integral_Constant__ concept.]
+ [__mpl_false__]
+ ]
+]
+
+You can use the parameter names as __template_keywords__. For example,
+assume that the following function is defined:
+
+[example__ublas_product__function]
+
+The following type definitions are semantically equivalent:
+
+``
+typedef function_automaton<
+ BOOST_TYPEOF(ublas_product)
+ , _fusion_nil_
+ , _default_input_validation_policy_
+ , _mpl_true_
+ >
+ FA1;
+typedef function_automaton<
+ BOOST_TYPEOF(ublas_product)
+ , [*_IsUndoable]<_mpl_true_>
+ >
+ FA2;
+typedef function_automaton<
+ [*_IsUndoable]<_mpl_true_>
+ , [*_Function]<BOOST_TYPEOF(ublas_product)>
+ >
+ FA3;
+``
+
+The last two definitions have the added benefit of not having to specify the
+default types of the `_Policies` and `_InputValidationPolicy` template
+parameters.
+
+All template parameter names for this class template are defined in the
+`boost::automata::keyword` namespace.
+[endsect] [/ Template Parameters]
+
+[section:model_of Model of]
+ * __Automaton__
+ * __Automaton_With_State_Register__ if the `_Function` template-argument
+ type models the __State_Register_Transition_Function__ concept
+ * __Extensible_Automaton__ if the `_Policies` template-argument type is a
+ non-__empty__ __Fusion_Forward_Sequence__ model
+ * __Undoable_Automaton__ if the `_isUndoable` template-argument type
+ evaluates to __mpl_true__
+[endsect]
+
+[section:public_bases Public Base Classes]
+The return type of __deterministic_generator__ when passed in the type
+[^_adaptor_transition_function_<_Function>].
+[endsect]
+
+[section Members]
+[table
+ [[Name][Expression][Description]]
+ [
+ [Transition function type]
+ [`transition_function`]
+ [Defined by the __Automaton__ concept.]
+ ]
+ [
+ [Observer map type]
+ [`observer_map`]
+ [Defined by the __Extensible_Automaton__ concept.]
+ ]
+ [
+ [Traits type]
+ [`traits`]
+ [Defined by the __Automaton__ concept.]
+ ]
+ [
+ [Default constructor]
+ [`function_automaton();`]
+ [Defined by the __Default_Constructible__ concept.]
+ ]
+ [
+ [Build Constructor]
+ [``
+ template <
+ typename A0
+ , typename A1
+ , typename A2
+ , typename A3
+ , typename A4
+ >
+ function_automaton(
+ A0 const&
+ , A1 const& = implementation_defined
+ , A2 const& = implementation_defined
+ , A3 const& = implementation_defined
+ , A4 const& = implementation_defined
+ );
+ ``]
+ [
+ Read the
+ [link automata.reference.function_automaton.build_ctor_param
+ Build Constructor Parameters] section for parameter descriptions.
+ ]
+ ]
+ [
+ [Copy constructor]
+ [`function_automaton(function_automaton const&);`]
+ [
+ * Defined by the __Copy_Constructible__ concept.
+ * Defined if and only if the return type of each element type
+ of the `_Policies` template-argument type models the
+ __Copyable_Observer__ concept, and the return type of the
+ `_InputValidationPolicy` template-argument type models the
+ __Copyable_Observer__ concept.
+ ]
+ ]
+ [
+ [Assignment operator]
+ [`function_automaton& operator=(function_automaton const&);`]
+ [
+ * Defined by the __Assignable__ concept.
+ * Defined if and only if the return type of each element type of the
+ `_Policies` template-argument type models the __Assignable__
+ concept, and the return type of the `_InputValidationPolicy`
+ template-argument type models the __Assignable__ concept.
+ ]
+ ]
+ [
+ [State assignment operator]
+ [`function_automaton& operator=(traits::state const&);`]
+ [Sets the [termlink source state] of this `function_automaton`.]
+ ]
+ [
+ [Function assignment operator]
+ [``
+ template <typename TFunction>
+ function_automaton& operator=(TFunction);
+ ``]
+ [
+ * Forwards to the transition function's assignment operator.
+ * Defined if and only if the previously mentioned operator is
+ defined and accepts the specified argument.
+ ]
+ ]
+ [
+ [Initialization]
+ [``
+ template <typename A0, typename A1>
+ void initialize(A0 const&, A1 const& = implementation_defined);
+ ``]
+ [
+ * Defined by the __Automaton__ concept.
+ * Read the [link automata.reference.function_automaton.init_param
+ Initialization Parameters] section for parameter descriptions.
+ ]
+ ]
+ [
+ [Resetting]
+ [`void reset();`]
+ [
+ * Defined by the __Automaton__ concept.
+ * If the underlying observer map is non-__empty__, then this
+ `function_automaton` will invoke each observer's `on_reset()`
+ method.
+ ]
+ ]
+ [
+ [Transition function accessor]
+ [`transition_function const& get_transition_function() const;`]
+ [Defined by the __Automaton__ concept.]
+ ]
+ [
+ [Observer map accessor]
+ [`observer_map const& get_observer_map() const;`]
+ [Defined by the __Extensible_Automaton__ concept.]
+ ]
+ [
+ [Input processing]
+ [`template <typename Input> bool operator()(Input const&);`]
+ [
+ * Defined by the __Automaton__ concept.
+ * If the underlying observer map is non-__empty__, then this
+ `function_automaton` will perform one of the following actions:
+ * Forward the input to each observer's `on_invalid_input()`
+ method if the underlying input validator marks the input as
+ invalid.
+ * Forward the input to each observer's `on_accept_input()`
+ method if the `function_automaton` type is a
+ __Discrete_Automaton__ and the nontrivial input check
+ returns `true`, or if the `function_automaton` type does *not*
+ model the __Discrete_Automaton__ concept and the input
+ processing implementation returns `true`.
+ * Forward the input to each observer's `on_reject_input()`
+ method if the `function_automaton` type is a
+ __Discrete_Automaton__ and the nontrivial input check
+ returns `false`, or if the `function_automaton` type does *not*
+ model the __Discrete_Automaton__ concept and the input
+ processing implementation returns `false`.
+ ]
+ ]
+ [
+ [Undo operation]
+ [`void undo();`]
+ [
+ * Defined by the __Undoable_Automaton__ concept.
+ * Defined if and only if the type of this `function_automaton` has
+ been configured to model the __Undoable_Automaton__ concept.
+ * If the underlying observer map is non-__empty__, then:
+ # If the operation succeeds in restoring this
+ `function_automaton` to the most recent snapshot, then it will
+ invoke each observer's `on_accept_undo()` method.
+ # Otherwise, the `function_automaton` will invoke each observer's
+ `on_reject_undo()` method.
+ ]
+ ]
+ [
+ [Undo ability check]
+ [`bool can_undo() const;`]
+ [
+ * Defined by the __Undoable_Automaton__ concept.
+ * Defined if and only if the type of this `function_automaton` has
+ been configured to model the __Undoable_Automaton__ concept.
+ ]
+ ]
+ [
+ [Undo limit access]
+ [`std::size_t get_undo_limit() const;`]
+ [
+ * Defined by the __Undoable_Automaton__ concept.
+ * Defined if and only if the type of this `function_automaton` has
+ been configured to model the __Undoable_Automaton__ concept.
+ ]
+ ]
+]
+[endsect] [/ Members]
+
+[section:build_ctor_param Build Constructor Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`_function`]
+ [
+ A function object used to initialize the underlying transition
+ function.
+ ]
+ [
+ * If the `_Policies` template-argument type is non-__empty__, then
+ the data type must model the __Extensible_Automaton_Builder__
+ concept; otherwise, the data type must model the
+ __Automaton_Builder__ concept.
+ * The transition function must be a valid argument.
+ ]
+ []
+ ]
+ [
+ [`_policies`]
+ [
+ A heterogeneous container of policies that this
+ `function_automaton` will enact. If this container is
+ non-__empty__, then the automaton will transform each policy type
+ into its metafunction class return type, create an instance of that
+ return type as an __Observer__, and associate the policy type with
+ the observer in the underlying observer map. If this parameter is
+ specified, then each observer's build constructor will be invoked;
+ otherwise, each observer's subject-policy constructor will be
+ invoked.
+ ]
+ [
+ The data type must be the same as the `_Policies` template-argument
+ type.
+ ]
+ [
+ A default-constructed instance of the `_Policies` template-argument
+ type.
+ ]
+ ]
+ [
+ [`_input_validation_policy`]
+ [
+ This `function_automaton` will transform the
+ `_InputValidationPolicy` template-argument type into its
+ metafunction class return type and create an instance of that
+ return type as an __Input_Validator__, which it will use for
+ input validation. If this parameter is specified, then the input
+ validator's build constructor will be invoked; otherwise, the input
+ validator's subject-policy constructor will be invoked.
+ ]
+ [
+ The data type must be the same as the `_InputValidationPolicy`
+ template-argument type.
+ ]
+ [
+ A default-constructed instance of the `_InputValidationPolicy`
+ template-argument type.
+ ]
+ ]
+ [
+ [`_source_state`]
+ [The [termlink source state] of this `function_automaton`.]
+ [The data type must be convertible to `traits::state`.]
+ [`traits::state()`]
+ ]
+ [
+ [`_undo_limit`]
+ [
+ The number of consecutive times that the `undo()` operation can be
+ carried out on this `function_automaton`.
+ ]
+ [
+ * The data type must be a primitive integral type.
+ * The type of this `function_automaton` must be configured to fulfill
+ the __Undoable_Automaton__ concept.
+ ]
+ [`std::size_t()`]
+ ]
+]
+
+You can __name_each_parameter__ when you invoke this constructor. Continuing
+the [link automata.reference.function_automaton.tpl_param type definitions
+example], the following statements are semantically equivalent:
+
+``
+FA1
+ fa1(
+ ublas_product
+ , _fusion_nil_()
+ , _default_input_validation_policy_()
+ , 18
+ , 32
+ );
+FA2
+ fa2(
+ ublas_product
+ , [*_source_state] = 18
+ , [*_undo_limit] = 32
+ );
+FA3
+ fa3(
+ [*_undo_limit] = 32
+ , [*_function] = ublas_product
+ , [*_source_state] = 18
+ );
+``
+
+The last two instructions have the added benefit of not having to specify the
+default values of the `_policies` and `_input_validation_policy` parameters.
+
+All parameter names for this operation are defined in the
+`boost::automata::keyword` namespace.
+[endsect] [/ Build Constructor Parameters]
+
+[section:init_param Initialization Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`_builder`]
+ [
+ A function object used to initialize the underlying transition
+ function.
+ ]
+ [
+ * If the `_Policies` template-argument type is non-__empty__, then
+ the data type must model the __Extensible_Automaton_Builder__
+ concept; otherwise, the data type must model the
+ __Automaton_Builder__ concept.
+ * The transition function must be a valid argument.
+ ]
+ []
+ ]
+ [
+ [`_source_state`]
+ [The [termlink source state] of this `function_automaton`.]
+ [The data type must be convertible to `traits::state`.]
+ [`traits::state()`]
+ ]
+]
+
+You can __name_each_parameter__ when you invoke the `initialize()`
+method. All parameter names for this operation are defined in the
+`boost::automata::keyword` namespace.
+[endsect]
+
+[endsect] [/ function_automaton]
+

Added: sandbox/automata/libs/automata/doc/ref_generator.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/ref_generator.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,694 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:deterministic_generator `deterministic_generator`]
+
+[section Synopsis]
+[reference__deterministic_generator]
+[endsect]
+
+[section Description]
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_generator_deterministic_hpp__>
+``
+[endsect]
+
+[section:metafunc_class_param Metafunction Class Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`Function`]
+ [The transition function type of the return automaton base type.]
+ [
+ * It must model the __Transition_Function__ concept.
+ * The result type must model the __Assignable__ concept.
+ ]
+ []
+ ]
+]
+[endsect]
+
+[section:ret_type_desc Return Type Description]
+[endsect]
+
+[section:ret_type_model_of Return Type Model of]
+ * __Automaton_Base__
+ * __Copy_Constructible__
+ * __Assignable__
+[endsect]
+
+[section:ret_type_public_bases Return Type Public Base Classes]
+None.
+[endsect]
+
+[section:ret_type_members Return Type Members]
+[table
+ [[Name][Expression][Description][Visibility]]
+ [
+ [Tag type]
+ [`tag`]
+ [Defined by the __Automaton_Base__ concept.]
+ [`public`]
+ ]
+ [
+ [State type]
+ [`traits::state`]
+ [
+ * The type of an object that represents the state of this
+ __Automaton_Base__.
+ * Defined as the transition function's return type.
+ * Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept if the transition
+ function type models the __State_Register_Transition_Function__
+ concept.
+ ]
+ [`public`]
+ ]
+ [
+ [Default constructor]
+ [`type();`]
+ [
+ * Constructs an instance of this __Automaton_Base__ whose
+ [termlink current state] and [termlink source state] are
+ default-constructed.
+ * Enables the derived __automaton__ type to model the
+ __Default_Constructible__ concept.
+ ]
+ [`protected`]
+ ]
+ [
+ [Source state constructor]
+ [`type(traits::state const&);`]
+ [
+ * Constructs an instance of this __Automaton_Base__ whose
+ [termlink current state] is default-constructed and whose
+ [termlink source state] is set to the specified state.
+ * Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept if the transition
+ function type models the __State_Register_Transition_Function__
+ concept.
+ ]
+ [`protected`]
+ ]
+ [
+ [Copy constructor]
+ [`type(type const&);`]
+ [
+ * Constructs an instance of this __Automaton_Base__ whose
+ [termlink current state] and [termlink source state] are
+ the same as those of the instance passed in.
+ * Defined by the __Copy_Constructible__ concept.
+ ]
+ [`public`]
+ ]
+ [
+ [Assignment operator]
+ [`type& operator=(type const&);`]
+ [
+ * Sets the [termlink current state] and [termlink source state]
+ of this __Automaton_Base__ to those of the automaton passed in.
+ * Defined by the __Assignable__ concept.
+ ]
+ [`public`]
+ ]
+ [
+ [Source state initializer]
+ [`void initialize_impl(traits::state const&);`]
+ [
+ * Sets the [termlink source state] of this __Automaton_Base__ to
+ the specified state.
+ * Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept if the transition
+ function type models the __State_Register_Transition_Function__
+ concept.
+ ]
+ [`protected`]
+ ]
+ [
+ [Resetting implementation]
+ [`void reset_impl();`]
+ [
+ * Sets the [termlink current state] of this __Automaton_Base__ to the
+ [termlink source state].
+ * Defined by the __Automaton_Base__ concept.
+ ]
+ [`protected`]
+ ]
+ [
+ [Current state access]
+ [`traits::state const& get_current_state() const;`]
+ [
+ * Accesses the [termlink current state].
+ * Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept if the transition
+ function type models the __State_Register_Transition_Function__
+ concept.
+ ]
+ [`public`]
+ ]
+ [
+ [Source state access]
+ [`traits::state const& get_source_state() const;`]
+ [
+ * Accesses the [termlink source state].
+ * Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept if the transition
+ function type models the __State_Register_Transition_Function__
+ concept.
+ ]
+ [`public`]
+ ]
+]
+[endsect] [/ Return Type Members]
+
+[endsect] [/ deterministic_generator]
+
+[section:dpda_generator `dpda_generator`]
+
+[section Synopsis]
+[reference__dpda_generator]
+[endsect]
+
+[section Description]
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_generator_dpda_hpp__>
+``
+[endsect]
+
+[section:metafunc_class_param Metafunction Class Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`Function`]
+ [The transition function type of the return automaton base type.]
+ [It must model the __DPDA_Transition_Function__ concept.]
+ []
+ ]
+]
+[endsect]
+
+[section:ret_type_desc Return Type Description]
+[endsect]
+
+[section:ret_type_model_of Return Type Model of]
+ * __Input_Enumerable_Automaton_Base__
+ * __Copy_Constructible__
+ * __Assignable__
+[endsect]
+
+[section:ret_type_public_bases Return Type Public Base Classes]
+None.
+[endsect]
+
+[section:ret_type_members Return Type Members]
+[table
+ [[Name][Expression][Description][Visibility]]
+ [
+ [Tag type]
+ [`tag`]
+ [Defined by the __Input_Enumerable_Automaton_Base__ concept.]
+ [`public`]
+ ]
+ [
+ [Stack element type]
+ [`traits::stack_element`]
+ [Enables the derived __automaton__ type to model the __DPDA__ concept.]
+ [`public`]
+ ]
+ [
+ [Stack iterator type]
+ [`traits::stack_iterator`]
+ [Enables the derived __automaton__ type to model the __DPDA__ concept.]
+ [`public`]
+ ]
+ [
+ [State register value type]
+ [`traits::state`]
+ [
+ Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept.
+ ]
+ [`public`]
+ ]
+ [
+ [Default constructor]
+ [`type();`]
+ [
+ Enables the derived __automaton__ type to model the
+ __Default_Constructible__ concept.
+ ]
+ [`protected`]
+ ]
+ [
+ [Source state register value constructor]
+ [`type(traits::state const&);`]
+ [
+ Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept.
+ ]
+ [`protected`]
+ ]
+ [
+ [Copy constructor]
+ [`type(type const&);`]
+ [Defined by the __Copy_Constructible__ concept.]
+ [`public`]
+ ]
+ [
+ [Assignment operator]
+ [`type& operator=(type const&);`]
+ [Defined by the __Assignable__ concept.]
+ [`public`]
+ ]
+ [
+ [Source state register value initializer]
+ [`void initialize_impl(traits::state const&);`]
+ [
+ Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept.
+ ]
+ [`protected`]
+ ]
+ [
+ [Resetting implementation]
+ [`void reset_impl();`]
+ [Defined by the __Automaton_Base__ concept.]
+ [`protected`]
+ ]
+ [
+ [Nontrivial input check implementation]
+ [``
+ void
+ is_nontrivial_input_impl(
+ Function const&
+ , Function::input const&
+ ) const;
+ ``]
+ [Defined by the __Input_Enumerable_Automaton_Base__ concept.]
+ [`protected`]
+ ]
+ [
+ [Nontrivial input enumeration implementation]
+ [``
+ template <typename Iterator>
+ void make_nontrivial_inputs_impl(Function const&, Iterator) const;
+ ``]
+ [Defined by the __Input_Enumerable_Automaton_Base__ concept.]
+ [`protected`]
+ ]
+ [
+ [Input processing implementation]
+ [`bool process_input_impl(Function const&, Function::input const&);`]
+ [Defined by the __Automaton_Base__ concept.]
+ [`protected`]
+ ]
+ [
+ [Empty stack check]
+ [`bool has_empty_stack() const;`]
+ [Enables the derived __automaton__ type to model the __DPDA__ concept.]
+ [`public`]
+ ]
+ [
+ [Stack top access]
+ [`traits::stack_element const& get_stack_top() const;`]
+ [Enables the derived __automaton__ type to model the __DPDA__ concept.]
+ [`public`]
+ ]
+ [
+ [Beginning of stack range]
+ [`traits::stack_iterator const& get_stack_begin() const;`]
+ [Enables the derived __automaton__ type to model the __DPDA__ concept.]
+ [`public`]
+ ]
+ [
+ [End of stack range]
+ [`traits::stack_iterator const& get_stack_end() const;`]
+ [Enables the derived __automaton__ type to model the __DPDA__ concept.]
+ [`public`]
+ ]
+ [
+ [Current state register value access]
+ [`traits::state const& get_current_state() const;`]
+ [
+ Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept.
+ ]
+ [`public`]
+ ]
+ [
+ [Source state register value access]
+ [`traits::state const& get_source_state() const;`]
+ [
+ Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept.
+ ]
+ [`public`]
+ ]
+]
+[endsect] [/ Return Type Members]
+
+[endsect] [/ dpda_generator]
+
+[section:dfa_generator `dfa_generator`]
+
+[section Synopsis]
+[reference__dfa_generator]
+[endsect]
+
+[section Description]
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_generator_dfa_hpp__>
+``
+[endsect]
+
+[section:metafunc_class_param Metafunction Class Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`Function`]
+ [The transition function type of the return automaton base type.]
+ [It must model the __DFA_Transition_Function__ concept.]
+ []
+ ]
+]
+[endsect]
+
+[section:ret_type_desc Return Type Description]
+[endsect]
+
+[section:ret_type_model_of Return Type Model of]
+ * __Input_Enumerable_Automaton_Base__
+ * __Copy_Constructible__
+ * __Assignable__
+[endsect]
+
+[section:ret_type_public_bases Return Type Public Base Classes]
+None.
+[endsect]
+
+[section:ret_type_members Return Type Members]
+[table
+ [[Name][Expression][Description][Visibility]]
+ [
+ [Tag type]
+ [`tag`]
+ [Defined by the __Input_Enumerable_Automaton_Base__ concept.]
+ [`public`]
+ ]
+ [
+ [State register value type]
+ [`traits::state`]
+ [
+ Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept.
+ ]
+ [`public`]
+ ]
+ [
+ [Default constructor]
+ [`type();`]
+ [
+ Enables the derived __automaton__ type to model the
+ __Default_Constructible__ concept.
+ ]
+ [`protected`]
+ ]
+ [
+ [Source state register value constructor]
+ [`type(traits::state const&);`]
+ [
+ Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept.
+ ]
+ [`protected`]
+ ]
+ [
+ [Copy constructor]
+ [`type(type const&);`]
+ [Defined by the __Copy_Constructible__ concept.]
+ [`public`]
+ ]
+ [
+ [Assignment operator]
+ [`type& operator=(type const&);`]
+ [Defined by the __Assignable__ concept.]
+ [`public`]
+ ]
+ [
+ [Source state register value initializer]
+ [`void initialize_impl(traits::state const&);`]
+ [
+ Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept.
+ ]
+ [`protected`]
+ ]
+ [
+ [Resetting implementation]
+ [`void reset_impl();`]
+ [Defined by the __Automaton_Base__ concept.]
+ [`protected`]
+ ]
+ [
+ [Nontrivial input check implementation]
+ [``
+ void
+ is_nontrivial_input_impl(
+ Function const&
+ , Function::input const&
+ ) const;
+ ``]
+ [Defined by the __Input_Enumerable_Automaton_Base__ concept.]
+ [`protected`]
+ ]
+ [
+ [Nontrivial input enumeration implementation]
+ [``
+ template <typename Iterator>
+ void make_nontrivial_inputs_impl(Function const&, Iterator) const;
+ ``]
+ [Defined by the __Input_Enumerable_Automaton_Base__ concept.]
+ [`protected`]
+ ]
+ [
+ [Input processing implementation]
+ [`bool process_input_impl(Function const&, Function::input const&);`]
+ [Defined by the __Automaton_Base__ concept.]
+ [`protected`]
+ ]
+ [
+ [Current state register value access]
+ [`traits::state const& get_current_state() const;`]
+ [
+ Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept.
+ ]
+ [`public`]
+ ]
+ [
+ [Source state register value access]
+ [`traits::state const& get_source_state() const;`]
+ [
+ Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept.
+ ]
+ [`public`]
+ ]
+]
+[endsect] [/ Return Type Members]
+
+[endsect] [/ dfa_generator]
+
+[section:probabilistic_generator `probabilistic_generator`]
+
+[section Synopsis]
+[reference__probabilistic_generator]
+[endsect]
+
+[section Description]
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_generator_probabilistic_hpp__>
+``
+[endsect]
+
+[section:tpl_param Template Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`RNGEngine`]
+ [
+ The type of the underlying engine used to generate numbers.
+ ]
+ [It must model the __Uniform_Random_Number_Generator__ concept.]
+ []
+ ]
+]
+[endsect]
+
+[section:metafunc_class_param Metafunction Class Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`Function`]
+ [The transition function type of the return automaton base type.]
+ [
+ * It must model the __Probabilistic_Transition_Function__ concept.
+ * The result type must model the __Assignable__ concept.
+ ]
+ []
+ ]
+]
+[endsect]
+
+[section:ret_type_desc Return Type Description]
+[endsect]
+
+[section:ret_type_model_of Return Type Model of]
+ * __Automaton_Base__
+ * __Copy_Constructible__
+ * __Assignable__
+[endsect]
+
+[section:ret_type_public_bases Return Type Public Base Classes]
+None.
+[endsect]
+
+[section:ret_type_members Return Type Members]
+[table
+ [[Name][Expression][Description][Visibility]]
+ [
+ [Tag type]
+ [`tag`]
+ [Defined by the __Automaton_Base__ concept.]
+ [`public`]
+ ]
+ [
+ [State type]
+ [`traits::state`]
+ [
+ * The type of an object that represents the state of this
+ __Automaton_Base__.
+ * Defined as the transition function's return type.
+ * Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept if the transition
+ function type models the __State_Register_Transition_Function__
+ concept.
+ ]
+ [`public`]
+ ]
+ [
+ [Default constructor]
+ [`type();`]
+ [
+ * Constructs an instance of this __Automaton_Base__ whose
+ [termlink current state] and [termlink source state] are
+ default-constructed.
+ * Enables the derived __automaton__ type to model the
+ __Default_Constructible__ concept.
+ ]
+ [`protected`]
+ ]
+ [
+ [Source state constructor]
+ [`type(traits::state const&);`]
+ [
+ * Constructs an instance of this __Automaton_Base__ whose
+ [termlink current state] is default-constructed and whose
+ [termlink source state] is set to the specified state.
+ * Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept if the transition
+ function type models the __State_Register_Transition_Function__
+ concept.
+ ]
+ [`protected`]
+ ]
+ [
+ [Copy constructor]
+ [`type(type const&);`]
+ [
+ * Constructs an instance of this __Automaton_Base__ whose
+ [termlink current state] and [termlink source state] are
+ the same as those of the instance passed in.
+ * Defined by the __Copy_Constructible__ concept.
+ ]
+ [`public`]
+ ]
+ [
+ [Assignment operator]
+ [`type& operator=(type const&);`]
+ [
+ * Sets the [termlink current state] and [termlink source state]
+ of this __Automaton_Base__ to those of the automaton passed in.
+ * Defined by the __Assignable__ concept.
+ ]
+ [`public`]
+ ]
+ [
+ [Source state initializer]
+ [`void initialize_impl(traits::state const&);`]
+ [
+ * Sets the [termlink source state] of this __Automaton_Base__ to
+ the specified state.
+ * Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept if the transition
+ function type models the __State_Register_Transition_Function__
+ concept.
+ ]
+ [`protected`]
+ ]
+ [
+ [Resetting implementation]
+ [`void reset_impl();`]
+ [
+ * Sets the [termlink current state] of this __Automaton_Base__ to the
+ [termlink source state].
+ * Defined by the __Automaton_Base__ concept.
+ ]
+ [`protected`]
+ ]
+ [
+ [Current state access]
+ [`traits::state const& get_current_state() const;`]
+ [
+ * Accesses the [termlink current state].
+ * Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept if the transition
+ function type models the __State_Register_Transition_Function__
+ concept.
+ ]
+ [`public`]
+ ]
+ [
+ [Source state access]
+ [`traits::state const& get_source_state() const;`]
+ [
+ * Accesses the [termlink source state].
+ * Enables the derived __automaton__ type to model the
+ __Automaton_With_State_Register__ concept if the transition
+ function type models the __State_Register_Transition_Function__
+ concept.
+ ]
+ [`public`]
+ ]
+]
+[endsect] [/ Return Type Members]
+
+[endsect] [/ probabilistic_generator]
+

Added: sandbox/automata/libs/automata/doc/ref_input_rule.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/ref_input_rule.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,86 @@
+[/=============================================================================
+ Copyright (C) 2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:cellular_graph_input_rule `cellular_graph_input_rule`]
+
+[section Synopsis]
+[reference__cellular_graph_input_rule]
+[endsect]
+
+[section Description]
+
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_input_rule_cellular_graph_hpp__>
+``
+[endsect]
+
+[section:tpl_param Template Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`Graph`]
+ [
+ The type of the underlying graph whose vertices the input property
+ map will associate with .
+ ]
+ [
+ It must model the __Graph__ concept.
+ ]
+ []
+ ]
+]
+[endsect]
+
+
+
+[endsect] [/ cellular_graph_input_rule]
+
+[section:wolfram_code_input_rule `wolfram_code_input_rule`]
+
+[section Synopsis]
+[reference__wolfram_code_input_rule]
+[endsect]
+
+[section Description]
+
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_input_rule_wolfram_code_hpp__>
+``
+[endsect]
+
+[section:tpl_param Template Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`Function`]
+ [
+ The type of the underlying function that this transition function
+ forwards to.
+ ]
+ [
+ * It must model either the __Unary_Function__ concept or the
+ __Binary_Function__ concept.
+ * If it models the __Binary_Function__ concept, then the data type of
+ at least one of its arguments must be the same as the return data
+ type.
+ ]
+ []
+ ]
+]
+[endsect]
+
+
+
+[endsect] [/ wolfram_code_input_rule]
+

Added: sandbox/automata/libs/automata/doc/ref_observer.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/ref_observer.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,182 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:base_observer `base_observer`]
+
+[section Synopsis]
+[reference__base_observer]
+[endsect]
+
+[section Description]
+This convenient base class no-ops all the methods that __Observer__ concept
+models must implement but may never use. It also stores an immutable view of
+the subject automaton so that derived classes do not need to do so.
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_observer_base_hpp__>
+``
+[endsect]
+
+[section Example]
+See the tutorial on __t_building_your_own_automata_types__.
+[endsect]
+
+[section:tpl_param Template Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`SubjectAutomaton`]
+ [
+ The base type of the subject automaton. Classes derived
+ from `base_observer` are typically the return types of
+ __Unary_Metafunction_Classes__ meant to be used as
+ __t_policies__, so a derived class can simply pass in
+ the argument type upon inheritance.
+ ]
+ []
+ []
+ ]
+]
+[endsect]
+
+[section:model_of Model of]
+N/A
+[endsect]
+
+[section:public_bases Public Base Classes]
+None.
+[endsect]
+
+[section Members]
+[table
+ [[Name][Expression][Description][Scope]]
+ [
+ [Subject constructor]
+ [`explicit base_observer(SubjectAutomaton const&);`]
+ [
+ When implementing any constructors in the derived class--including
+ the canonical copy constructor--invoke this constructor in the
+ initializer list. For the canonical copy constructor, pass in the
+ subject automaton of the observer being copied.
+ ]
+ [`protected`]
+ ]
+ [
+ [Initialization notification]
+ [``
+ template <typename Builder>
+ void on_initialize(Builder const&);
+ ``]
+ [
+ Overwrite this method template in the derived class to execute code
+ after the subject automaton has been initialized.
+ ]
+ [`public`]
+ ]
+ [
+ [Reset notification]
+ [`void on_reset();`]
+ [
+ Overwrite this method template in the derived class to execute code
+ after the subject automaton has been reset.
+ ]
+ [`public`]
+ ]
+ [
+ [Input acceptance notification]
+ [`void on_accept_input(SubjectAutomaton::input const&);`]
+ [
+ Overwrite this method in the derived class to handle inputs that
+ the subject automaton has successfully processed.
+ ]
+ [`public`]
+ ]
+ [
+ [Input rejection notification]
+ [`void on_reject_input(SubjectAutomaton::input const&);`]
+ [
+ Overwrite this method in the derived class to handle inputs that
+ the subject automaton has failed to process.
+ ]
+ [`public`]
+ ]
+ [
+ [Input invalidation notification]
+ [`void on_invalid_input(SubjectAutomaton::input const&);`]
+ [Overwrite this method in the derived class to handle invalid inputs.]
+ [`public`]
+ ]
+ [
+ [Undo acceptance notification]
+ [`void on_accept_undo();`]
+ [
+ Overwrite this method template in the derived class to execute code
+ after the subject automaton has performed an undo operation.
+ ]
+ [`public`]
+ ]
+ [
+ [Undo rejection notification]
+ [`void on_reject_undo();`]
+ [
+ Overwrite this method template in the derived class to execute code
+ after the subject automaton has rejected an undo request.
+ ]
+ [`public`]
+ ]
+ [
+ [Subject automaton accessor]
+ [`SubjectAutomaton const& get_subject_automaton() const;`]
+ [Returns an immutable view of the subject automaton.]
+ [`protected`]
+ ]
+]
+[endsect] [/ Members]
+
+[endsect] [/ base_observer]
+
+[section:full_noop_observer `full_noop_observer`]
+
+[section Synopsis]
+[reference__full_noop_observer]
+[endsect]
+
+[section Description]
+This convenient base class no-ops all the methods that __Observer__ concept
+models must implement but may never use. It also stores an immutable view of
+the subject automaton so that derived classes do not need to do so.
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_observer_full_noop_hpp__>
+``
+[endsect]
+
+[endsect] [/ full_noop_observer]
+
+[section:output_observer `output_observer`]
+
+[section Synopsis]
+[reference__output_observer]
+[endsect]
+
+[section Description]
+This class template .
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_observer_output_hpp__>
+``
+[endsect]
+
+[endsect] [/ output_observer]
+

Added: sandbox/automata/libs/automata/doc/ref_policy.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/ref_policy.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,284 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:single_final_state_policy `single_final_state_policy`]
+
+[section Synopsis]
+[reference__single_final_state_policy]
+[endsect]
+
+[section Description]
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_policy_single_final_state__>
+``
+[endsect]
+
+[section Example]
+See the [link automata.tutorials.observer_policies.final_state Final-State
+Policies section] of the __Observer_Policies_tutorial__.
+[endsect]
+
+[section:tpl_param Template Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`Uid`]
+ [
+ A primitive integral constant that uniquely identifies this
+ template instantiation.
+ ]
+ []
+ [`0UL`]
+ ]
+]
+[endsect]
+
+[section:metafunc_class_param Metafunction Class Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`SubjectAutomaton`]
+ [The base type of the subject automaton.]
+ [
+ * It must model the __Automaton_Base__ concept.
+ * It must implement [termlink current state] access. See the
+ __Automaton_With_State_Register__ concept.
+ ]
+ []
+ ]
+]
+[endsect]
+
+[section:ret_type_desc Return Type Description]
+[endsect]
+
+[section:ret_type_model_of Return Type Model of]
+__Undoable_Automaton_Observer__
+[endsect]
+
+[section:ret_type_public_bases Return Type Public Base Classes]
+__base_observer__
+[endsect]
+
+[section:ret_type_members Return Type Members]
+[table
+ [[Name][Expression][Description][Where defined]]
+ [
+ [Build constructor]
+ [``
+ template <typename Builder>
+ type(
+ Builder const& builder
+ , single_final_state_policy const& policy
+ , SubjectAutomaton const& automaton
+ );
+ ``]
+ [
+ # Constructs this observer and associates it with the specified
+ subject automaton.
+ # Requires the `Builder` type to model the
+ __Extensible_Automaton_Builder__ concept.
+ # Requires the builder's observer builder map to associate the
+ type `single_final_state_key<Uid>` with a valid object.
+ # Requires the type of this object to implement a `get_final_state()`
+ method whose return type is convertible to the [termlink state
+ register] value type of the subject automaton.
+ # Stores the return value of the object's `get_final_state()`
+ method. The boolean conversion operator will compare this value
+ with the subject automaton's [termlink current state].
+ ]
+ [__Observer__]
+ ]
+ [
+ [Observer-copy constructor]
+ [`type(type const& copy, SubjectAutomaton const& automaton);`]
+ [
+ Constructs this observer, associates it with the specified
+ automaton, and copies the [termlink state register] value from the
+ other observer.
+ ]
+ [__Copyable_Observer__]
+ ]
+ [
+ [Copy constructor]
+ [`type(type const& copy);`]
+ []
+ [__Copy_Constructible__]
+ ]
+ [
+ [Assignment operator]
+ [`type& operator=(type const& copy);`]
+ []
+ [__Assignable__]
+ ]
+ [
+ [Initialization notification]
+ [``
+ template <typename Builder>
+ void on_initialize(Builder const& builder);
+ ``]
+ [
+ # Requires the `Builder` type to model the
+ __Extensible_Automaton_Builder__ concept.
+ # Requires the builder's observer builder map to associate the
+ type `single_final_state_key<Uid>` with a valid object.
+ # Requires the type of this object to implement a `get_final_state()`
+ method whose return type is convertible to the [termlink state
+ register] value type of the subject automaton.
+ # Stores the return value of the object's `get_final_state()`
+ method. The boolean conversion operator will compare this value
+ with the subject automaton's [termlink current state].
+ ]
+ [__Observer__]
+ ]
+ [
+ [Boolean conversion operator]
+ [`operator bool() const;`]
+ [
+ Returns the result of the __is_at_final_state__ function
+ template using the observers' subject automaton, its transition
+ function tag type, and the [termlink state register] value stored
+ in this observer.
+ ]
+ [`type`]
+ ]
+]
+[endsect] [/ Return Type Members]
+
+[endsect] [/ single_final_state_policy]
+
+[section:is_at_final_state `is_at_final_state`]
+
+[section Prototype]
+[reference__is_at_final_state]
+[endsect]
+
+[section Description]
+This function template determines whether or not the specified automaton is at
+the specified [termlink final state].
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_policy_single_final_state__>
+``
+[endsect]
+
+[section:type_reqs Type Requirements]
+ * The `SubjectAutomaton` type must model the __Automaton_Base__ concept.
+ * The `SubjectAutomaton` type must implement [termlink current state]
+ access. See the __Automaton_With_State_Register__ concept.
+[endsect]
+
+[section Preconditions]
+[endsect]
+
+[section Complexity]
+[endsect]
+
+[endsect] [/ is_at_final_state]
+
+[section:parall_final_states_policy `parallel_final_states_policy`]
+
+[section Synopsis]
+[reference__parallel_final_states_policy]
+[endsect]
+
+[endsect] [/ parallel_final_states_policy]
+
+[section:has_visited_any_state `has_visited_any_state`]
+
+[section Prototype]
+[reference__has_visited_any_state]
+[endsect]
+
+[endsect] [/ has_visited_any_state]
+
+[section:serial_final_states_policy `serial_final_states_policy`]
+
+[section Synopsis]
+[reference__serial_final_states_policy]
+[endsect]
+
+[endsect] [/ serial_final_states_policy]
+
+[section:has_no_unvisited_states `has_no_unvisited_states`]
+
+[section Prototype]
+[reference__has_no_unvisited_states]
+[endsect]
+
+[endsect] [/ has_no_unvisited_states]
+
+[section:bool_insertion_policy `bool_insertion_policy`]
+
+[section Synopsis]
+[reference__bool_insertion_policy]
+[endsect]
+
+[endsect] [/ bool_insertion_policy]
+
+[section:dpda_insertion_policy `dpda_insertion_policy`]
+
+[section Synopsis]
+[reference__dpda_insertion_policy]
+[endsect]
+
+[endsect] [/ dpda_insertion_policy]
+
+[section:dfa_insertion_policy `dfa_insertion_policy`]
+
+[section Synopsis]
+[reference__dfa_insertion_policy]
+[endsect]
+
+[endsect] [/ dfa_insertion_policy]
+
+[section:mdp_best_input_policy `mdp_best_input_policy`]
+
+[section Prototype]
+[reference__mdp_best_input_policy]
+[endsect]
+
+[endsect] [/ mdp_best_input_policy]
+
+[section:moore_output_policy `moore_output_policy`]
+
+[section Prototype]
+[reference__moore_output_policy]
+[endsect]
+
+[endsect] [/ moore_output_policy]
+
+[section:mealy_output_policy `mealy_output_policy`]
+
+[section Prototype]
+[reference__mealy_output_policy]
+[endsect]
+
+[endsect] [/ mealy_output_policy]
+
+[section:input_valid_policy `input_validation_policy`]
+
+[section Synopsis]
+[reference__input_validation_policy]
+[endsect]
+
+[endsect] [/ input_validation_policy]
+
+[section:def_input_valid_policy `default_input_validation_policy`]
+
+[section Synopsis]
+[reference__default_input_validation_policy]
+[endsect]
+
+[endsect] [/ default_input_validation_policy]
+

Added: sandbox/automata/libs/automata/doc/ref_transition_function.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/ref_transition_function.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,1720 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:adaptor_trans_func `adaptor_transition_function`]
+
+[section Synopsis]
+[reference__adaptor_transition_function]
+[endsect]
+
+[section Description]
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_transition_function_adaptor_hpp__>
+``
+[endsect]
+
+[section:tpl_param Template Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`Function`]
+ [
+ The type of the underlying function that this transition function
+ forwards to.
+ ]
+ [
+ * It must model either the __Unary_Function__ concept or the
+ __Binary_Function__ concept.
+ * If it models the __Binary_Function__ concept, then the data type of
+ at least one of its arguments must be the same as the return data
+ type.
+ ]
+ []
+ ]
+]
+[endsect]
+
+[section:model_of Model of]
+ * __State_Register_Transition_Function__ if the state type is the same as
+ `std::size_t`, __Transition_Function__ otherwise
+ * __Adaptable_Unary_Function__ if `Function` models the __Unary_Function__
+ concept.
+ * __Adaptable_Binary_Function__ if `Function` models the __Binary_Function__
+ concept.
+ * __Default_Constructible__
+ * __Copy_Constructible__
+ * __Assignable__
+ * __Equality_Comparable__
+[endsect]
+
+[section:public_bases Public Base Classes]
+None.
+[endsect]
+
+[section Members]
+[table
+ [[Name][Expression][Description][When defined]]
+ [
+ [Tag type]
+ [`tag`]
+ [Defined by the __Transition_Function__ concept.]
+ [Always.]
+ ]
+ [
+ [Result type]
+ [`result_type`]
+ [Same as the return data type of the underlying function.]
+ [Always.]
+ ]
+ [
+ [State type]
+ [`state`]
+ [Same as the result type.]
+ [Always.]
+ ]
+ [
+ [Input type]
+ [`input`]
+ [
+ The data type of the argument to the underlying function that is
+ not a state. It may be the same as the state type.
+ ]
+ [Always.]
+ ]
+ [
+ [Argument type]
+ [`argument_type`]
+ [Same as the input type.]
+ [When `Function` models the __Unary_Function__ concept.]
+ ]
+ [
+ [First argument type]
+ [`first_argument_type`]
+ [Same as the state type.]
+ [When `Function` models the __Binary_Function__ concept.]
+ ]
+ [
+ [Second argument type]
+ [`second_argument_type`]
+ [Same as the input type.]
+ [When `Function` models the __Binary_Function__ concept.]
+ ]
+ [
+ [Default constructor]
+ [`adaptor_transition_function();`]
+ [Defined by the __Default_Constructible__ concept.]
+ [Always.]
+ ]
+ [
+ [Function conversion constructor]
+ [``
+ template <typename TFunction>
+ adaptor_transition_function(TFunction);
+ ``]
+ []
+ [Always.]
+ ]
+ [
+ [Copy constructor]
+ [`adaptor_transition_function(adaptor_transition_function const&);`]
+ [Defined by the __Copy_Constructible__ concept.]
+ [Always.]
+ ]
+ [
+ [Assignment operator]
+ [``
+ adaptor_transition_function&
+ operator=(adaptor_transition_function const&);
+ ``]
+ [Defined by the __Assignable__ concept.]
+ [Always.]
+ ]
+ [
+ [Function assignment operator]
+ [``
+ template <typename TFunction>
+ adaptor_transition_function& operator=(TFunction function);
+ ``]
+ []
+ [Always.]
+ ]
+ [
+ [Input recognition]
+ [`bool recognizes_input(input const&) const;`]
+ [
+ * Defined by the __Transition_Function__ concept.
+ * If an underlying input recognition function exists, forwards the
+ argument to that function and returns its result; returns `true`
+ otherwise.
+ ]
+ [Always.]
+ ]
+ [
+ [State recognition]
+ [`bool recognizes_state(state const&) const;`]
+ [
+ If an underlying state recognition function exists, forwards the
+ argument to that function and returns its result; returns `true`
+ otherwise.
+ ]
+ [When `Function` models the __Binary_Function__ concept.]
+ ]
+ [
+ [Unary function call]
+ [`result_type operator()(argument_type const&) const;`]
+ [
+ Forwards the arguments to the underlying function and returns the
+ result of that function.
+ ]
+ [When `Function` models the __Unary_Function__ concept.]
+ ]
+ [
+ [Binary function call]
+ [``
+ result_type
+ operator()(
+ first_argument_type const&
+ , second_argument_type const&
+ ) const;
+ ``]
+ [
+ Forwards the arguments to the underlying function and returns the
+ result of that function.
+ ]
+ [When `Function` models the __Binary_Function__ concept.]
+ ]
+ [
+ [Input recognizer setting]
+ [``
+ template <typename InputRecognizer>
+ void set_input_recognizer(InputRecognizer);
+ ``]
+ [
+ Sets this `adaptor_transition_function` to use the specified
+ function as the underlying input recognizer.
+ ]
+ [Always.]
+ ]
+ [
+ [State recognizer setting]
+ [``
+ template <typename StateRecognizer>
+ void set_state_recognizer(StateRecognizer);
+ ``]
+ [
+ Sets this `adaptor_transition_function` to use the specified
+ function as the underlying state recognizer.
+ ]
+ [When `Function` models the __Binary_Function__ concept.]
+ ]
+]
+[endsect] [/ Members]
+
+[section:non_members Non-members]
+[table
+ [[Name][Expression][Description]]
+ [
+ [Equality]
+ [``
+ template <typename Function1, typename Function2>
+ bool
+ operator==(
+ adaptor_transition_function<Function1> const&
+ , adaptor_transition_function<Function2> const&
+ );
+ ``]
+ [
+ * Defined by the __Equality_Comparable__ concept.
+ * Returns `true` if and only if the underlying functions are equal.
+ ]
+ ]
+ [
+ [Inequality]
+ [``
+ template <typename Function1, typename Function2>
+ bool
+ operator!=(
+ adaptor_transition_function<Function1> const&
+ , adaptor_transition_function<Function2> const&
+ );
+ ``]
+ [
+ * Defined by the __Equality_Comparable__ concept.
+ * Returns `true` if and only if the underlying functions are *not*
+ equal.
+ ]
+ ]
+]
+[endsect]
+
+[endsect] [/ adaptor_transition_function]
+
+[section:dpda_trans_func `dpda_transition_function`]
+
+[section Synopsis]
+[reference__dpda_transition_function]
+[endsect]
+
+[section Description]
+Straightforward implementation of a __DPDA_Transition_Function__.
+
+[important
+ This component depends on __Boost_Type_Traits_Operators__, which has been
+ recently accepted into Boost but is currently not part of an official
+ release. For now, you must perform a Subversion checkout from the
+ __SVN_Trac__.
+]
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_transition_function_dpda_hpp__>
+``
+[endsect]
+
+[section:tpl_param Template Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`_StackElement`]
+ [The stack element type of this transition function.]
+ []
+ []
+ ]
+ [
+ [`_Input`]
+ [The input type of this transition function.]
+ []
+ []
+ ]
+ [
+ [`_AssociativeContainerSelector`]
+ [
+ The type that determines the internal map types whose mapped types
+ are the same as the result map type.
+ ]
+ [
+ * It must be either `mapS`, `unordered_mapS`, or `hash_mapS` (if
+ available).
+ * If this type is `mapS`, then the `_Input` and `_StackElement` types
+ must fulfill the requirements imposed on the key type of
+ __std_map__.
+ * If this type is `unordered_mapS`, then the `_Input` and
+ `_StackElement` types must fulfill the requirements imposed on the
+ key type of __tr1_unordered_map__.
+ * If this type is `hash_mapS`, then the `_Input` and `_StackElement`
+ types must fulfill the requirements imposed on the key type of
+ __non_std_hash_map__.
+ ]
+ [`mapS`]
+ ]
+ [
+ [`_RandomAccessContainerSelector`]
+ [
+ The type that determines the internal container type whose element
+ type is that determined by the `_AssociativeContainerSelector`
+ type.
+ ]
+ [It must be either `vecS` or `dequeS`.]
+ [`vecS`]
+ ]
+]
+
+You can use the parameter names as __template_keywords__. For example, the
+following type definitions are semantically equivalent:
+
+``
+typedef dpda_transition_function<char,char,mapS,dequeS>
+ Function1;
+typedef dpda_transition_function<
+ char
+ , char
+ , [*_RandomAccessContainerSelector]<dequeS>
+ >
+ Function2;
+typedef dpda_transition_function<
+ [*_RandomAccessContainerSelector]<dequeS>
+ , [*_StackElement]<char>
+ , [*_Input]<char>
+ >
+ Function3;
+``
+
+The last two definitions have the added benefit of not having to specify the
+default type of the `_AssociativeContainerSelector` template parameter.
+
+All template parameter names for this class template are defined in the
+`boost::automata::keyword` namespace.
+[endsect] [/ Template Parameters]
+
+[section:model_of Model of]
+ * __DPDA_Transition_Function__
+ * __Default_Constructible__
+ * __Copy_Constructible__
+ * __Assignable__
+ * __Equality_Comparable__
+[endsect]
+
+[section:public_bases Public Base Classes]
+None.
+[endsect]
+
+[section Members]
+[table
+ [[Name][Expression][Where defined]]
+ [
+ [Tag type]
+ [`tag`]
+ [__Transition_Function__]
+ ]
+ [
+ [Input type]
+ [`input`]
+ [__Transition_Function__]
+ ]
+ [
+ [State register value type]
+ [`state`]
+ [__State_Register_Transition_Function__]
+ ]
+ [
+ [Stack element type]
+ [`stack_element`]
+ [__DPDA_Transition_Function__]
+ ]
+ [
+ [Stack sequence type]
+ [`stack_sequence`]
+ [__DPDA_Transition_Function__]
+ ]
+ [
+ [Stack iterator type]
+ [`stack_iterator`]
+ [__DPDA_Transition_Function__]
+ ]
+ [
+ [Optional stack element type]
+ [`optional_stack_element`]
+ [__DPDA_Transition_Function__]
+ ]
+ [
+ [Result map type]
+ [`result_map`]
+ [__DPDA_Transition_Function__]
+ ]
+ [
+ [Result type]
+ [`result_type`]
+ [__DPDA_Transition_Function__]
+ ]
+ [
+ [Default constructor]
+ [`dpda_transition_function();`]
+ [__Default_Constructible__]
+ ]
+ [
+ [Copy constructor]
+ [`dpda_transition_function(dpda_transition_function const&);`]
+ [__Copy_Constructible__]
+ ]
+ [
+ [Assignment operator]
+ [
+ `dpda_transition_function&
+ operator=(dpda_transition_function const&);`
+ ]
+ [__Assignable__]
+ ]
+ [
+ [Input recognition]
+ [`bool recognizes_input(input const&) const;`]
+ [__Transition_Function__]
+ ]
+ [
+ [State register value recognition]
+ [`bool recognizes_state(state const&) const;`]
+ [__State_Register_Transition_Function__]
+ ]
+ [
+ [Stack element recognition]
+ [`bool recognizes_stack_element(stack_element const&) const;`]
+ [__DPDA_Transition_Function__]
+ ]
+ [
+ [Binary function call]
+ [`result_type operator()(state const&, input const&) const;`]
+ [__DPDA_Transition_Function__]
+ ]
+ [
+ [Trinary function call]
+ [``
+ result_type
+ operator()(
+ state const&
+ , input const&
+ , stack_element const&
+ ) const;
+ ``]
+ [__DPDA_Transition_Function__]
+ ]
+ [
+ [Nontrivial input enumeration]
+ [``
+ template <typename Iterator>
+ void
+ make_nontrivial_inputs(
+ state const&
+ , stack_element const&
+ , Iterator
+ ) const;
+ ``]
+ [__DPDA_Transition_Function__]
+ ]
+ [
+ [Input-only nontrivial input enumeration]
+ [``
+ template <typename Iterator>
+ void make_nontrivial_inputs(state const&, Iterator) const;
+ ``]
+ [__DPDA_Transition_Function__]
+ ]
+ [
+ [Transition setting]
+ [``
+ void
+ set_transition(
+ state const&
+ , input const&
+ , stack_element const&
+ , result_map const&
+ );
+ implementation_defined
+ operator()(state const&, input const&, stack_element const&);
+ ``]
+ [__DPDA_Transition_Function__]
+ ]
+ [
+ [Input-only transition setting]
+ [``
+ void set_transition(state const&, input const&, result_map const&);
+ implementation_defined operator()(state const&, input const&);
+ ``]
+ [__DPDA_Transition_Function__]
+ ]
+ [
+ [Resetting]
+ [`void reset(std::size_t);`]
+ [__DPDA_Transition_Function__]
+ ]
+]
+[endsect] [/ Members]
+
+[section:non_members Non-members]
+[table
+ [[Name][Expression][Where defined]]
+ [
+ [Equality]
+ [``
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ , typename T6
+ , typename T7
+ >
+ bool
+ operator==(
+ dpda_transition_function<T0,T1,T2,T3> const&
+ , dpda_transition_function<T4,T5,T6,T7> const&
+ );
+ ``]
+ [__Equality_Comparable__]
+ ]
+ [
+ [Inequality]
+ [``
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ , typename T6
+ , typename T7
+ >
+ bool
+ operator!=(
+ dpda_transition_function<T0,T1,T2,T3> const&
+ , dpda_transition_function<T4,T5,T6,T7> const&
+ );
+ ``]
+ [__Equality_Comparable__]
+ ]
+]
+[endsect]
+
+[endsect] [/ dpda_transition_function]
+
+[section:matrix_trans_func `matrix_transition_function`]
+
+[section Synopsis]
+[reference__matrix_transition_function]
+[endsect]
+
+[section Description]
+Straightforward implementation of a __Tabular_Transition_Function__.
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_transition_function_matrix_hpp__>
+``
+[endsect]
+
+[section Example]
+The table below shows the output of a sample transition function.
+
+[table
+ [[Current State][Input]]
+ [[ ][0][1][2][3]]
+ [[ 0][1][1][2][0]]
+ [[ 1][1][2][0][1]]
+ [[ 2][2][2][2][3]]
+ [[ 3][3][3][3][3]]
+]
+
+The example below shows how to build the transition function above using this
+class template.
+
+[``
+ matrix_transition_function<_ublas_matrix_<std::size_t> > function;
+
+ function.reset(4, 4);
+ function.set_transition(0, 0, 1);
+ function.set_transition(0, 1, 1);
+ function.set_transition(0, 2, 2);
+ function(1, 1) = 2; // Same as function.set_transition(1, 1, 2);
+ function(1, 2) = 0;
+ function(2, 3) = 3;
+
+ // Output...
+``]
+
+In normal usage, the `reset()` and `set_transition()` methods are invoked by
+the function call operator of a custom __Automaton_Builder__, as shown in
+the __DFA_tutorial__ and in the __Observer_Policies_tutorial__.
+[endsect]
+
+[section:tpl_param Template Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`StateInputMatrix`]
+ [The type of the underlying table that this transition function uses.]
+ [It must model the __Transition_Function_Matrix__ concept.]
+ []
+ ]
+]
+[endsect]
+
+[section:model_of Model of]
+ * __Tabular_Transition_Function__
+ * __Default_Constructible__
+ * __Copy_Constructible__
+ * __Assignable__
+ * __Equality_Comparable__
+[endsect]
+
+[section:public_bases Public Base Classes]
+None.
+[endsect]
+
+[section Members]
+[table
+ [[Name][Expression][Where defined]]
+ [
+ [Tag type]
+ [`tag`]
+ [__Transition_Function__]
+ ]
+ [
+ [Input type]
+ [`input`]
+ [__Transition_Function__]
+ ]
+ [
+ [State register value type]
+ [`state`]
+ [__State_Register_Transition_Function__]
+ ]
+ [
+ [Result type]
+ [`result_type`]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [First argument type]
+ [`first_argument_type`]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Second argument type]
+ [`second_argument_type`]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Default constructor]
+ [`matrix_transition_function();`]
+ [__Default_Constructible__]
+ ]
+ [
+ [Copy constructor]
+ [`matrix_transition_function(matrix_transition_function const&);`]
+ [__Copy_Constructible__]
+ ]
+ [
+ [Assignment operator]
+ [
+ `matrix_transition_function&
+ operator=(matrix_transition_function const&);`
+ ]
+ [__Assignable__]
+ ]
+ [
+ [Input recognition]
+ [`bool recognizes_input(input const&) const;`]
+ [__Transition_Function__]
+ ]
+ [
+ [State register value recognition]
+ [`bool recognizes_state(state const&) const;`]
+ [__State_Register_Transition_Function__]
+ ]
+ [
+ [Function call]
+ [
+ `result_type
+ operator()(first_argument_type, second_argument_type) const;`
+ ]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Nontrivial input enumeration]
+ [``
+ template <typename Iterator>
+ void make_nontrivial_inputs(state const&, Iterator) const;
+ ``]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Transition setting]
+ [``
+ void
+ set_transition(
+ first_argument_type
+ , second_argument_type
+ , result_type
+ );
+ implementation_defined
+ operator()(first_argument_type, second_argument_type);
+ ``]
+ [__Tabular_Transition_Function__]
+ ]
+ [
+ [Resetting]
+ [`void reset(std::size_t, std::size_t);`]
+ [__Tabular_Transition_Function__]
+ ]
+]
+[endsect] [/ Members]
+
+[section:non_members Non-members]
+[table
+ [[Name][Expression][Where defined]]
+ [
+ [Equality]
+ [``
+ template <
+ typename StateInputMatrix
+ , typename OtherStateInputMatrix
+ >
+ bool
+ operator==(
+ matrix_transition_function<StateInputMatrix> const&
+ , matrix_transition_function<OtherStateInputMatrix> const&
+ );
+ ``]
+ [__Equality_Comparable__]
+ ]
+ [
+ [Inequality]
+ [``
+ template <
+ typename StateInputMatrix
+ , typename OtherStateInputMatrix
+ >
+ bool
+ operator!=(
+ matrix_transition_function<StateInputMatrix> const&
+ , matrix_transition_function<OtherStateInputMatrix> const&
+ );
+ ``]
+ [__Equality_Comparable__]
+ ]
+]
+[endsect]
+
+[endsect] [/ matrix_transition_function]
+
+[section:mapped_in_tab_trans_func `mapped_input_tabular_transition_function`]
+
+[section Synopsis]
+[reference__mapped_input_tabular_transition_function]
+[endsect]
+
+[section Description]
+Straightforward implementation of a
+__Mapped_Input_Tabular_Transition_Function__.
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_transition_function_mapped_input_tabular_hpp__>
+``
+[endsect]
+
+[section Example]
+The table below shows the output of a sample transition function.
+
+[table
+ [[Current State][Input]]
+ [[ ][alpha][beta][gamma][delta]]
+ [[ 0][1][1][2][0]]
+ [[ 1][1][2][0][1]]
+ [[ 2][2][2][2][3]]
+ [[ 3][3][3][3][3]]
+]
+
+The example below shows how to build the transition function above using this
+class template.
+
+[``
+ mapped_input_tabular_transition_function
+ _std_string_
+ , _matrix_transition_function_<_ublas_matrix_<std::size_t> >
+ > function;
+ _std_vector_<_std_string_> inputs;
+
+ inputs.push_back("alpha");
+ inputs.push_back("beta");
+ inputs.push_back("gamma");
+ inputs.push_back("delta");
+ function.reset(4, inputs);
+ function.set_transition(0, "alpha", 1);
+ function.set_transition(0, "beta", 1);
+ function.set_transition(0, "gamma", 2);
+ function(1, "beta") = 2; // Same as function.set_transition(1, "beta", 2);
+ function(1, "gamma") = 0;
+ function(2, "delta") = 3;
+
+ // Output...
+``]
+
+In normal usage, the `reset()` and `set_transition()` methods are invoked by
+the function call operator of a custom __Automaton_Builder__, as shown in
+the __DFA_tutorial__ and in the __Observer_Policies_tutorial__.
+[endsect]
+
+[section:tpl_param Template Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`_Input`]
+ [The input type of this transition function.]
+ []
+ []
+ ]
+ [
+ [`_Function`]
+ [The underlying tabular transition function.]
+ [It must model the __Tabular_Transition_Function__ concept.]
+ []
+ ]
+ [
+ [`_AssociativeContainerSelector`]
+ [
+ The type that determines the internal map type from the input type
+ to the state type.
+ ]
+ [
+ * It must be either `mapS`, `unordered_mapS`, or `hash_mapS` (if
+ available).
+ * If this type is `mapS`, then the `_Input` type must fulfill
+ the requirements imposed on the key type of __std_map__.
+ * If this type is `unordered_mapS`, then the `_Input` type
+ must fulfill the requirements imposed on the key type of
+ __tr1_unordered_map__.
+ * If this type is `hash_mapS`, then the `_Input` type must fulfill
+ the requirements imposed on the key type of __non_std_hash_map__.
+ ]
+ [`mapS`]
+ ]
+]
+
+You can use the parameter names as __template_keywords__. For example, the
+following type definitions are semantically equivalent:
+
+``
+typedef mapped_input_tabular_transition_function<
+ char
+ , _matrix_transition_function_<_ublas_matrix_<std::size_t> >
+ , unordered_mapS
+ >
+ Function1;
+typedef mapped_input_tabular_transition_function<
+ char
+ , _matrix_transition_function_<_ublas_matrix_<std::size_t> >
+ , [*_AssociativeContainerSelector]<unordered_mapS>
+ >
+ Function2;
+typedef mapped_input_tabular_transition_function<
+ [*_AssociativeContainerSelector]<unordered_mapS>
+ , [*_Function]<
+ _matrix_transition_function_<_ublas_matrix_<std::size_t> >
+ >
+ , [*_Input]<char>
+ >
+ Function3;
+``
+
+All template parameter names for this class template are defined in the
+`boost::automata::keyword` namespace.
+[endsect] [/ Template Parameters]
+
+[section:model_of Model of]
+ * __Mapped_Input_Tabular_Transition_Function__
+ * __Default_Constructible__
+ * __Copy_Constructible__
+ * __Assignable__
+ * __Equality_Comparable__
+[endsect]
+
+[section:public_bases Public Base Classes]
+None.
+[endsect]
+
+[section Members]
+[table
+ [[Name][Expression][Where defined]]
+ [
+ [Tag type]
+ [`tag`]
+ [__Transition_Function__]
+ ]
+ [
+ [Input type]
+ [`input`]
+ [__Transition_Function__]
+ ]
+ [
+ [State register value type]
+ [`state`]
+ [__State_Register_Transition_Function__]
+ ]
+ [
+ [Result type]
+ [`result_type`]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [First argument type]
+ [`first_argument_type`]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Second argument type]
+ [`second_argument_type`]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Default constructor]
+ [`mapped_input_tabular_transition_function();`]
+ [__Default_Constructible__]
+ ]
+ [
+ [Copy constructor]
+ [``
+ mapped_input_tabular_transition_function(
+ mapped_input_tabular_transition_function const&
+ );
+ ``]
+ [__Copy_Constructible__]
+ ]
+ [
+ [Assignment operator]
+ [
+ `mapped_input_tabular_transition_function&
+ operator=(mapped_input_tabular_transition_function const&);`
+ ]
+ [__Assignable__]
+ ]
+ [
+ [Input recognition]
+ [`bool recognizes_input(second_argument_type) const;`]
+ [__Transition_Function__]
+ ]
+ [
+ [State register value recognition]
+ [`bool recognizes_state(first_argument_type) const;`]
+ [__State_Register_Transition_Function__]
+ ]
+ [
+ [Function call]
+ [
+ `result_type
+ operator()(first_argument_type, second_argument_type) const;`
+ ]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Nontrivial input enumeration]
+ [``
+ template <typename Iterator>
+ void make_nontrivial_inputs(state const&, Iterator) const;
+ ``]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Transition setting]
+ [``
+ void
+ set_transition(
+ first_argument_type
+ , second_argument_type
+ , result_type
+ );
+ implementation_defined
+ operator()(first_argument_type, second_argument_type);
+ ``]
+ [__Mapped_Input_Tabular_Transition_Function__]
+ ]
+ [
+ [Resetting]
+ [``
+ template <typename Iterator>
+ void reset(std::size_t, Iterator, Iterator);
+ ``]
+ [__Mapped_Input_Tabular_Transition_Function__]
+ ]
+]
+[endsect] [/ Members]
+
+[section:non_members Non-members]
+[table
+ [[Name][Expression][Where defined]]
+ [
+ [Equality]
+ [``
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ >
+ bool
+ operator==(
+ mapped_input_tabular_transition_function<T0,T1,T2> const&
+ , mapped_input_tabular_transition_function<T3,T4,T5> const&
+ );
+ ``]
+ [__Equality_Comparable__]
+ ]
+ [
+ [Inequality]
+ [``
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ >
+ bool
+ operator!=(
+ mapped_input_tabular_transition_function<T0,T1,T2> const&
+ , mapped_input_tabular_transition_function<T3,T4,T5> const&
+ );
+ ``]
+ [__Equality_Comparable__]
+ ]
+]
+[endsect]
+
+[endsect] [/ mapped_input_tabular_transition_function]
+
+[section:mapped_in_trans_func `mapped_input_transition_function`]
+
+[section Synopsis]
+[reference__mapped_input_transition_function]
+[endsect]
+
+[section Description]
+Straightforward implementation of a __Mapped_Input_Transition_Function__.
+
+[important
+ This component depends on __Boost_Type_Traits_Operators__, which has been
+ recently accepted into Boost but is currently not part of an official
+ release. For now, you must perform a Subversion checkout from the
+ __SVN_Trac__.
+]
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_transition_function_mapped_input_hpp__>
+``
+[endsect]
+
+[section Example]
+The table below shows the output of a sample transition function.
+
+[table
+ [[Current State][Input]]
+ [[ ][alpha][beta][gamma][delta]]
+ [[ 0][1][1][2][0]]
+ [[ 1][1][2][0][1]]
+ [[ 2][2][2][2][3]]
+ [[ 3][3][3][3][3]]
+]
+
+The example below shows how to build the transition function above using this
+class template.
+
+[``
+ mapped_input_transition_function<_std_string_> function;
+
+ function.reset(4);
+ function.set_transition(0, "alpha", 1);
+ function.set_transition(0, "beta", 1);
+ function.set_transition(0, "gamma", 2);
+ function(1, "beta") = 2; // Same as function.set_transition(1, "beta", 2);
+ function(1, "gamma") = 0;
+ function(2, "delta") = 3;
+
+ // Output...
+``]
+
+In normal usage, the `reset()` and `set_transition()` methods are invoked by
+the function call operator of a custom __Automaton_Builder__, as shown in the
+__DFA_tutorial__ and in the __Observer_Policies_tutorial__.
+[endsect]
+
+[section:tpl_param Template Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`_Input`]
+ [The input type of this transition function.]
+ []
+ []
+ ]
+ [
+ [`_AssociativeContainerSelector`]
+ [
+ The type that determines the internal map type from the input type
+ to the state type.
+ ]
+ [
+ * It must be either `mapS`, `unordered_mapS`, or `hash_mapS` (if
+ available).
+ * If this type is `mapS`, then the `_Input` type must fulfill
+ the requirements imposed on the key type of __std_map__.
+ * If this type is `unordered_mapS`, then the `_Input` type
+ must fulfill the requirements imposed on the key type of
+ __tr1_unordered_map__.
+ * If this type is `hash_mapS`, then the `_Input` type must fulfill
+ the requirements imposed on the key type of __non_std_hash_map__.
+ ]
+ [`mapS`]
+ ]
+ [
+ [`_RandomAccessContainerSelector`]
+ [The type that determines the internal transition container type.]
+ [It must be either `vecS` or `dequeS`.]
+ [`vecS`]
+ ]
+]
+
+You can use the parameter names as __template_keywords__. For example, the
+following type definitions are semantically equivalent:
+
+``
+typedef mapped_input_transition_function<
+ char
+ , mapS
+ , dequeS
+ >
+ Function1;
+typedef mapped_input_transition_function<
+ char
+ , [*_RandomAccessContainerSelector]<dequeS>
+ >
+ Function2;
+typedef mapped_input_transition_function<
+ [*_RandomAccessContainerSelector]<dequeS>
+ , [*_Input]<char>
+ >
+ Function3;
+``
+
+The last two definitions have the added benefit of not having to specify the
+default type of the `_AssociativeContainerSelector` template parameter.
+
+All template parameter names for this class template are defined in the
+`boost::automata::keyword` namespace.
+[endsect] [/ Template Parameters]
+
+[section:model_of Model of]
+ * __Mapped_Input_Transition_Function__
+ * __Default_Constructible__
+ * __Copy_Constructible__
+ * __Assignable__
+ * __Equality_Comparable__
+[endsect]
+
+[section:public_bases Public Base Classes]
+None.
+[endsect]
+
+[section Members]
+[table
+ [[Name][Expression][Where defined]]
+ [
+ [Tag type]
+ [`tag`]
+ [__Transition_Function__]
+ ]
+ [
+ [Input type]
+ [`input`]
+ [__Transition_Function__]
+ ]
+ [
+ [State register value type]
+ [`state`]
+ [__State_Register_Transition_Function__]
+ ]
+ [
+ [Result type]
+ [`result_type`]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [First argument type]
+ [`first_argument_type`]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Second argument type]
+ [`second_argument_type`]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Default constructor]
+ [`mapped_input_transition_function();`]
+ [__Default_Constructible__]
+ ]
+ [
+ [Copy constructor]
+ [``
+ mapped_input_transition_function(
+ mapped_input_transition_function const&
+ );
+ ``]
+ [__Copy_Constructible__]
+ ]
+ [
+ [Assignment operator]
+ [
+ `mapped_input_transition_function&
+ operator=(mapped_input_transition_function const&);`
+ ]
+ [__Assignable__]
+ ]
+ [
+ [Input recognition]
+ [`bool recognizes_input(second_argument_type) const;`]
+ [__Transition_Function__]
+ ]
+ [
+ [State register value recognition]
+ [`bool recognizes_state(first_argument_type) const;`]
+ [__State_Register_Transition_Function__]
+ ]
+ [
+ [Function call]
+ [
+ `result_type
+ operator()(first_argument_type, second_argument_type) const;`
+ ]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Nontrivial input enumeration]
+ [``
+ template <typename Iterator>
+ void make_nontrivial_inputs(state const&, Iterator) const;
+ ``]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Transition setting]
+ [``
+ void
+ set_transition(
+ first_argument_type
+ , second_argument_type
+ , result_type
+ );
+ implementation_defined
+ operator()(first_argument_type, second_argument_type);
+ ``]
+ [__Mapped_Input_Transition_Function__]
+ ]
+ [
+ [Resetting]
+ [`void reset(std::size_t);`]
+ [__Mapped_Input_Transition_Function__]
+ ]
+]
+[endsect] [/ Members]
+
+[section:non_members Non-members]
+[table
+ [[Name][Expression][Where defined]]
+ [
+ [Equality]
+ [``
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ >
+ bool
+ operator==(
+ mapped_input_transition_function<T0,T1,T2> const&
+ , mapped_input_transition_function<T3,T4,T5> const&
+ );
+ ``]
+ [__Equality_Comparable__]
+ ]
+ [
+ [Inequality]
+ [``
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ >
+ bool
+ operator!=(
+ mapped_input_transition_function<T0,T1,T2> const&
+ , mapped_input_transition_function<T3,T4,T5> const&
+ );
+ ``]
+ [__Equality_Comparable__]
+ ]
+]
+[endsect] [/ Non-members]
+
+[endsect] [/ mapped_input_transition_function]
+
+[section:next_state_trans_func `next_state_transition_function`]
+
+[section Synopsis]
+[reference__next_state_transition_function]
+[endsect]
+
+[section Description]
+Straightforward implementation of a __Next_State_Transition_Function__.
+
+[important
+ This component depends on __Boost_Type_Traits_Operators__, which has been
+ recently accepted into Boost but is currently not part of an official
+ release. For now, you must perform a Subversion checkout from the
+ __SVN_Trac__.
+]
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_transition_function_next_state_hpp__>
+``
+[endsect]
+
+[section Example]
+The table below shows the output of a sample transition function.
+
+[table
+ [[Current State][Valid Next States]]
+ [[ 0][1][2][4]]
+ [[ 1][0][2][3]]
+ [[ 2][3][4]]
+ [[ 3][0][1][2]]
+ [[ 4][0][3][5]]
+ [[ 5][]]
+]
+
+The example below shows how to build the transition function above using this
+class template.
+
+[``
+ next_state_transition_function<> function;
+
+ function.reset(6);
+ function.add_transition(0, 1);
+ function.add_transition(0, 2);
+ function.add_transition(0, 4);
+ function.add_transition(1, 0);
+ function.add_transition(1, 2);
+ function.add_transition(1, 3);
+ function(2) += 3; // Same as function.add_transition(2, 3);
+ function(2) += 4;
+ function(3) += 0;
+ function(3) += 1;
+ function(3) += 2;
+ function(4) += 0;
+ function(4) += 3;
+ function(4) += 5;
+
+ // Output...
+``]
+
+In normal usage, the `reset()` and `add_transition()` methods are invoked by
+the function call operator of a custom __Automaton_Builder__, as shown in the
+__DFA_tutorial__ and in the __Observer_Policies_tutorial__.
+[endsect]
+
+[section:tpl_param Template Parameters]
+[table
+ [[Parameter][Description][Requirements][Default]]
+ [
+ [`_AssociativeContainerSelector`]
+ [The type that determines the internal input set type.]
+ [
+ It must be either `setS`, `unordered_setS`, or `hash_setS` (if
+ available).
+ ]
+ [`setS`]
+ ]
+ [
+ [`_RandomAccessContainerSelector`]
+ [The type that determines the internal transition container type.]
+ [It must be either `vecS` or `dequeS`.]
+ [`vecS`]
+ ]
+]
+
+You can use the parameter names as __template_keywords__. All template
+parameter names for this class template are defined in the
+`boost::automata::keyword` namespace.
+[endsect]
+
+[section Model of]
+ * __Next_State_Transition_Function__
+ * __Adaptable_Binary_Function__
+ * __Default_Constructible__
+ * __Copy_Constructible__
+ * __Assignable__
+ * __Equality_Comparable__
+[endsect]
+
+[section Public Base Classes]
+None.
+[endsect]
+
+[section Members]
+[table
+ [[Name][Expression][Where defined]]
+ [
+ [Tag type]
+ [`tag`]
+ [__Transition_Function__]
+ ]
+ [
+ [Input type]
+ [`input`]
+ [__Transition_Function__]
+ ]
+ [
+ [State register value type]
+ [`state`]
+ [__State_Register_Transition_Function__]
+ ]
+ [
+ [Result type]
+ [`result_type`]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [First argument type]
+ [`first_argument_type`]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Second argument type]
+ [`second_argument_type`]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Default constructor]
+ [`next_state_transition_function();`]
+ [__Default_Constructible__]
+ ]
+ [
+ [Copy constructor]
+ [``
+ next_state_transition_function(
+ next_state_transition_function const&
+ );
+ ``]
+ [__Copy_Constructible__]
+ ]
+ [
+ [Assignment operator]
+ [
+ `next_state_transition_function&
+ operator=(next_state_transition_function const&);`
+ ]
+ [__Assignable__]
+ ]
+ [
+ [Input recognition]
+ [`bool recognizes_input(second_argument_type) const;`]
+ [__Transition_Function__]
+ ]
+ [
+ [State register value recognition]
+ [`bool recognizes_state(first_argument_type) const;`]
+ [__State_Register_Transition_Function__]
+ ]
+ [
+ [Function call]
+ [
+ `result_type
+ operator()(first_argument_type, second_argument_type) const;`
+ ]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Nontrivial input enumeration]
+ [``
+ template <typename Inputs>
+ void make_nontrivial_inputs(state const&, Inputs&) const;
+ ``]
+ [__DFA_Transition_Function__]
+ ]
+ [
+ [Transition setting]
+ [``
+ void add_transition(first_argument_type, second_argument_type);
+ implementation_defined operator()(first_argument_type);
+ ``]
+ [__Next_State_Transition_Function__]
+ ]
+ [
+ [Resetting]
+ [`void reset(std::size_t);`]
+ [__Next_State_Transition_Function__]
+ ]
+]
+[endsect] [/ Members]
+
+[section:non_members Non-members]
+[table
+ [[Name][Expression][Where defined]]
+ [
+ [Equality]
+ [``
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ >
+ bool
+ operator==(
+ next_state_transition_function<T0,T1> const&
+ , next_state_transition_function<T2,T3> const&
+ );
+ ``]
+ [__Equality_Comparable__]
+ ]
+ [
+ [Inequality]
+ [``
+ template <
+ typename T0
+ , typename T1
+ , typename T2
+ , typename T3
+ , typename T4
+ , typename T5
+ >
+ bool
+ operator!=(
+ next_state_transition_function<T0,T1> const&
+ , next_state_transition_function<T2,T3> const&
+ );
+ ``]
+ [__Equality_Comparable__]
+ ]
+]
+[endsect]
+
+[endsect] [/ next_state_transition_function]
+
+[section:dt_explicit_trans_func `decision_tree_explicit_transition_function`]
+
+[section Synopsis]
+[reference__decision_tree_explicit_transition_function]
+[endsect]
+
+[section Description]
+
+[important
+ This component depends on __Boost_Tree_Node__, which is not yet a part of
+ Boost. For now, you must perform a Subversion checkout from the
+ __SVN_Trac__.
+]
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_transition_function_decision_tree_hpp__>
+``
+[endsect]
+
+[endsect] [/ decision_tree_explicit_transition_function]
+
+[section:input_rule_trans_func `input_rule_transition_function`]
+
+[section Synopsis]
+[reference__input_rule_transition_function]
+[endsect]
+
+[section Description]
+
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_transition_function_input_rule_hpp__>
+``
+[endsect]
+
+[endsect] [/ input_rule_transition_function]
+
+[section:ttl_bool_cell_trans_func `totalistic_boolean_cell_transition_function`]
+
+[section Synopsis]
+[reference__totalistic_boolean_cell_transition_function]
+[endsect]
+
+[section Description]
+
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_transition_function_totalistic_boolean_cell_hpp__>
+``
+[endsect]
+
+[endsect] [/ totalistic_boolean_cell_transition_function]
+
+[section:ttl_dt_cell_trans_func `totalistic_dt_cell_transition_function`]
+
+[section Synopsis]
+[reference__totalistic_dt_cell_transition_function]
+[endsect]
+
+[section Description]
+
+[important
+ This component depends on __Boost_Tree_Node__, which is not yet a part of
+ Boost. For now, you must perform a Subversion checkout from the
+ __SVN_Trac__.
+]
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_transition_function_totalistic_dt_cell_hpp__>
+``
+[endsect]
+
+[endsect] [/ totalistic_dt_cell_transition_function]
+
+[section:mdp_mapped_input_trans_func `mdp_mapped_input_transition_function`]
+
+[section Synopsis]
+[reference__mdp_mapped_input_transition_function]
+[endsect]
+
+[section Description]
+
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_transition_function_mdp_mapped_input_hpp__>
+``
+[endsect]
+
+[endsect] [/ mdp_mapped_input_transition_function]
+
+[section:decision_tree_trans_func `decision_tree_transition_function`]
+
+[section Synopsis]
+[reference__decision_tree_transition_function]
+[endsect]
+
+[section Description]
+
+[important
+ This component depends on __Boost_Tree_Node__, which is not yet a part of
+ Boost. For now, you must perform a Subversion checkout from the
+ __SVN_Trac__.
+]
+[endsect]
+
+[section:definition Where defined]
+``
+#include <__boost_automata_transition_function_decision_tree_hpp__>
+``
+[endsect]
+
+[endsect] [/ decision_tree_transition_function]
+

Added: sandbox/automata/libs/automata/doc/reference.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/reference.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,53 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section Reference]
+
+[include ref_automaton.qbk]
+[include ref_function_automaton.qbk]
+[include ref_generator.qbk]
+[include ref_transition_function.qbk]
+[include ref_input_rule.qbk]
+[include ref_observer.qbk]
+[include ref_policy.qbk]
+[include ref_builder.qbk]
+
+ * __automaton__
+ * __function_automaton__
+ * __deterministic_generator__
+ * __adaptor_transition_function__
+ * __dpda_generator__
+ * __dpda_transition_function__
+ * __dfa_generator__
+ * __matrix_transition_function__
+ * __mapped_input_tabular_transition_function__
+ * __mapped_input_transition_function__
+ * __next_state_transition_function__
+ * __input_rule_transition_function__
+ * __wolfram_code_input_rule__
+ * __cellular_graph_input_rule__
+ * __conway_vertex_transition_function__
+ * __base_observer__
+ * __single_final_state_policy__
+ * __is_at_final_state__
+ * __parallel_final_states_policy__
+ * __has_visited_any_state__
+ * __serial_final_states_policy__
+ * __has_no_unvisited_states__
+ * __bool_insertion_policy__
+ * __dpda_insertion_policy__
+ * __dfa_insertion_policy__
+ * __input_validation_policy__
+ * __default_input_validation_policy__
+ * __builder_from_graph__
+ * __single_final_state_builder_from_graph__
+ * __multiple_final_states_builder_from_graph__
+ * __function_builder__
+
+[endsect] [/ Reference]
+

Added: sandbox/automata/libs/automata/doc/tut_basics.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/tut_basics.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,135 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:basics Tutorial: Basics]
+The classical application for automata is
+[@http://en.wikipedia.org/wiki/Syntax_analysis syntax analysis], of which step
+one is scanning. In this example, we will implement a minimal
+[@http://en.wikipedia.org/wiki/Lexical_analysis scanner] for several
+[@http://en.wikipedia.org/wiki/Context-free_language context-free
+languages]. A *minimal scanner* simply accepts a sequence of [termlink input
+symbols] if and only if that sequence is part of the language for which the
+scanner is implemented.
+
+Each context-free language can be formulated in terms of a corresponding
+[@http://en.wikipedia.org/wiki/Context-free_grammar context-free grammar]. The
+following grammars will generate our example languages (0 denotes the empty
+string):
+
+[*Grammar 1]
+[pre S --> aSb | 0]
+
+[*Grammar 2]
+[pre S --> x | y | z | S+S | S-S | S*S | S/S | (S)]
+
+[*Grammar 3]
+[pre S --> aSc | B
+B --> bBc | 0]
+
+Each string in the language generated by the first grammar can have any number
+of `'a'`s followed by the same number of `'b'`s. Each string in the language
+generated by the second grammar must be an infix arithmetic expression over the
+variables `'x'`, `'y'`, and `'z'`. Each string in the language generated by
+the third grammar can have any number of `'a'`s followed by any number of
+`'b'`s, as long as the number of following `'c'`s is equal to the sum of the
+number of `'a'`s and the number of `'b'`s.
+
+The scanner type that is compatible with all of these languages is the
+__DPDA__. Our objective is to be able to use the DPDA to accept or reject
+a given word, as the following routine does:
+
+[test__accept__function_template]
+
+The automaton processes each input letter via its function call
+operator. This operator must return true at all times, and the DPDA's stack
+must be empty, in order for the routine to accept the word. As soon as the
+automaton rejects an input letter, the routine rejects the entire word.
+
+[heading Recipe]
+An automaton is nothing without a [termlink transition function]. The first
+thing we need is a type definition that uses the __dpda_transition_function__
+class template.
+
+[test__dpda_trans_func__typedef]
+
+The ability to initialize a __DPDA__ will be provided by several functions
+that model the __Automaton_Builder__ concept. Each of these functions takes
+in a single argument: a reference to a transition function object. For the
+language generated by the first example grammar, we have:
+
+[test__dpda_build1__function]
+
+The overall [termlink current state] of a [termlink pushdown automaton] is the
+combination of the contents of its stack, if any, and the current value of its
+[termlink state register]. When the pushdown automaton is initialized or
+reset, its stack is emptied and its state register is set to zero by default.
+
+ # The transition function's `reset()` member function call sets the finite
+ automaton component to recognize two state register values--0 and 1--and
+ removes all transitions previously added.
+ # The first `set_transition()` call means: if the current state register
+ value is 0 and the next input symbol is an `\'a\'`, then don\'t pop
+ anything from the stack, push an `\'S\'` onto the stack, and maintain the
+ current state register value.
+ # The second and third `set_transition()` calls mean: if the next input
+ symbol is a `\'b\'` and the top of the stack is an `\'S\'`, then pop from
+ the stack, don't push anything onto the stack, and set the state register
+ value to 1. Two calls are required because there are two valid state
+ register values.
+
+For the language generated by the second example grammar, we have:
+
+[test__dpda_build2__function]
+
+For illustration, let's focus on the first pair of statements after the
+`reset()` call, reproduced here:
+
+``
+ function.set_transition(0, '(', r0S);
+ function.set_transition(0, '(', 'A', r0S);
+``
+
+In all cases, the transition represented by the statement /with the stack
+symbol to be popped/ takes precedence over the statement without one,
+regardless of the order of the statements in the code; e.g. if the current
+state register value is 0, the input symbol is the open parenthesis `'('`, and
+the letter `'A'` is at the top of the stack, then the stack will be popped
+before the letter `'S'` is pushed onto it. The three pairs of
+`set_transition()` calls that follow will abide by the same precedence rules.
+
+For the language generated by the third example grammar, we have:
+
+[test__dpda_build3__function]
+
+We can now test our word accepting routine. Each build function can be passed
+to the automaton's constructor or to its `initialize()` method.
+
+[test__basics__case]
+
+You may be wondering why we need to instantiate an __automaton__ with a
+separate __dpda_generator__ and __dpda_transition_function__ instead of
+obtaining a DPDA type immediately. This is because the __automaton__ class
+template also combines other common functionality that we will see in action in
+the __Observer_Policies_tutorial__ and the
+__Input_Validation_and_Undoable_Automata_tutorial__. In fact, the
+__automaton__ class template is the primary front end of this library;
+almost all other components work together through it, within certain
+constraints.
+
+The complete working program for this tutorial is contained in four files:
+
+ * __test_dpda_builder_hpp__
+ * __test_dpda_builder_cpp__
+ * __test_basics_hpp__
+ * __test_basics_cpp__
+
+[important
+ __Build__ __Boost_Test__ before you attempt to compile the program.
+]
+[endsect] [/ Tutorial: Basics]
+

Added: sandbox/automata/libs/automata/doc/tut_builders.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/tut_builders.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,86 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:builders Tutorial: Automata Builders]
+The greatest strength of a *dynamic* automaton lies in its transition
+function's ability to be *algorithmically* computed (i.e. built by some other
+routine). Applications that require state machines to be run in structured but
+dynamic layouts (e.g. [@http://en.wikipedia.org/wiki/Formal_language
+formal-language] acceptors, __t_random_maze_situations__) benefit the most
+from this ability. The __Automaton_Builder__ concept allows an automaton and
+its underlying transition function to be built generically by any conforming
+algorithm.
+
+We will alter our __t_basic_test_program__ by removing our build functions and
+making use of the __builder_from_graph__ class template instead. Graphs are
+natural representations of automata and their transition functions, with
+each vertex mapping to a unique state and each edge mapping to a unique
+transition. This particular class template leverages the power of the
+__Boost_Graph_Library__ to build transition functions.
+
+First things first. Our automaton type definitions:
+
+[test__builder_from_graph__dpda_typedef]
+
+When a graph represents the [termlink transition function] of a [termlink
+DPDA], each vertex is associated with a unique [termlink state register
+value]. We associate each edge with a __fusion_map__ that contains three
+objects: an [termlink input symbol]; an optional symbol that, if present, must
+be popped from the stack in order for the transition to take place; and an
+optional symbol to be pushed onto the stack as a result of the transition. The
+graph is usually directed because the transitions are one-way.
+
+[test__builder_from_graph__graph_typedef]
+
+For the __builder_from_graph__ to be able to do its work, the input
+graph must possess certain __property_maps__, which can be accessed via
+__property_tags__. We could use any of the tag types that the BGL predefines,
+but one of the property maps will be an edge input map, and none of the BGL
+tag types have a name that would easily identify such a property map. So, we
+use one provided by this library, called `edge_input_t`.
+
+[test__builder_from_graph__builder_typedef]
+
+Next, we extract the functionality from our old build functions. The
+__fusion_map__ constructor can take in the __fusion_pair__ objects to
+be added. In turn, we use the __fusion_make_pair__ function template to
+associate the key type with the appropriate symbol inside the map. Right now,
+we'll handle the first example grammar: `S --> aSb | 0`.
+
+[test__builder_from_graph__case0_edge_inputs]
+
+We can construct our graph with the number of vertices that we need, but we
+need to add the edges individually. Upon the successful addition of an edge,
+we associate it with the proper edge input symbols. Note that we access our
+edge input map using the `edge_input` identifier. Its name is that of the tag
+type, but without the `_t` suffix, as per BGL conventions.
+
+[test__builder_from_graph__case0_graph]
+
+For a DPDA, a minimal __builder_from_graph__ object is constructed using a
+graph, a vertex state map, and an edge input map. Since our DPDA doesn't enact
+any __t_policies__, this setup is good enough:
+
+[test__builder_from_graph__case0_dpda]
+
+Finally, we test our word-accepting automaton.
+
+[test__builder_from_graph__case0_run]
+
+The complete working program for this tutorial is contained in
+__test_builder_from_graph_cpp__.
+
+[important
+ __Build__ __Boost_Test__ before you attempt to compile the program.
+]
+
+[note
+ You do *not* need to __build__ the __Boost_Graph_Library__.
+]
+[endsect] [/ Tutorial: Automata Builders]
+

Added: sandbox/automata/libs/automata/doc/tut_byo_automata.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/tut_byo_automata.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,400 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:byo_automata Tutorial: Building Your Own Automata]
+Boost.Automata is also a /framework/ in which you can build your own
+dynamically configurable state machine types. Here, we will concentrate on
+building the data structures necessary to run an
+[@http://en.wikipedia.org/wiki/Artificial_neural_network artificial neural
+network]. While more traditional automata cannot execute transitions that are
+not explicitly defined by their transition functions, neural networks can infer
+such transitions based on the ones that /are/ specified, or in this context,
+*learned*. The trade-off is that a neural network can make mistakes if it has
+not been sufficiently trained.
+
+Suppose that our job is to develop a grizzly bear hunting AI. Our neural
+network, representing the hunter, must take several criteria into account: his
+own health, whether or not he has a knife, whether or not he has a rifle, and
+the number of bears in the area. Based on these criteria, the hunter must
+either hunt for a bear, run away, wander around (in search of a weapon dropped
+by a fellow hunter), or hide; these actions comprise the possible states of our
+neural network.
+
+__neural_network_mystery__ [/ What should the hunter do?]
+
+The [@http://en.wikipedia.org/wiki/Artificial_neuron neuron] is the basic
+building block of all neural networks. It accumulates its inputs into a
+[@http://en.wikipedia.org/wiki/Weight_function weighted sum], then passes
+the result to an *activation function* (usually the
+[@http://en.wikipedia.org/wiki/Sigmoid_function sigmoid function], but can be
+any function that is [@http://en.wikipedia.org/wiki/Monotonic_function
+monotonic]) which calculates the neuron's output.
+
+__neuron__ [/ The anatomy of a neuron]
+
+Within a single layer, each neuron takes in the same collection of inputs but
+applies a separate weight to each input. The collection of outputs that the
+neurons in this layer produce becomes the collection of inputs consumed by the
+neurons in the next layer. In the first layer, each input represents a
+criterion that the hunter must take into account. In the last layer, each
+output corresponds to a possible state or action; the output with the strongest
+signal determines what the hunter will actually do.
+
+__neural_network_layout__ [/ A neural network representing the hunter]
+
+During the learning phase, a basic neural network implementation runs through
+several cycles of [@http://en.wikipedia.org/wiki/Feed-forward feed-forward] and
+[@http://en.wikipedia.org/wiki/Backpropagation back-propagation], which are the
+neural network equivalents of trial and error, respectively. In the
+feed-forward stage, the neural network will take an input sample and calculate
+its output as it would during the simulation phase. In the back-propagation
+stage, the neural network will compare its results with the desired output and
+adjust all its neurons' weights and bias inputs accordingly, so that the output
+of succeeding trials will match the desired output as closely as possible.
+
+We'll be writing plenty of modular code this time around, so we should be
+organized about it. Our custom classes and functions will reside in the
+`example` namespace and, for the most part, will be defined in separate
+header files (and only header files, to maintain readability).
+
+[section:generator The `neural_network_generator` Class]
+We'll start with a __Unary_Metafunction_Class__: a class with a nested,
+parameterized `apply` class that takes in a single template parameter. In
+a binary metafunction class, the `apply` type would take in two template
+parameters; in a trinary metafunction class, three; and so on. The `apply`
+class template, in turn, contains either a nested class or a type definition
+called `type`, which is the result of *invoking* a metafunction class. In
+our case, the `type` class must model the __Automaton_Base__ concept. The
+__t_section_on_transition_functions__ will explain the reason for all these
+requirements.
+
+Metafunctions and metafunction classes are also known as *type generators*;
+hence, the name of our metafunction class shall be `neural_network_generator`.
+
+[example__neural_network_generator__preamble]
+
+The `tag` type definition is required by the __Automaton_Base__ concept to
+either be or inherit from `automaton_base_tag`. We do not use
+`discrete_automaton_base_tag` or any other derived type because we will not
+implement an `is_nontrivial_input()` member function, so our class cannot model
+the __Discrete_Automaton_Base__ concept or any of its refinements.
+
+The following nested class definition contains those types that are specific to
+a neural network automaton type. Should we ever design a *Neural Network*
+concept that is a refinement of the __Automaton__ concept, we would place
+the requirements for these types in our concept design.
+
+[example__neural_network_generator__traits]
+
+The first `private` code section defines the requirements that transition
+function type must fulfill, as well as the data members that a neural network
+automaton would need (other than the transition function). The requirements
+come in the form of [@boost:/libs/concept_check/concept_check.htm concept
+checking] and [@boost:/dock/html/boost_staticassert.html static assertions], so
+that we can safely make some assumptions about the presence and characteristics
+of the transition function's associated types and expressions. Moreover, these
+assertions are tested at compile-time rather than at runtime; the sooner we
+find any broken code, the better off we are when we fix them.
+
+[example__neural_network_generator__private]
+
+Because the `output` type is a __Sequence__, we can assume that the
+`_current_output` data member has a fill constructor; for our example, we also
+assume that the transition function type defines the number of output neurons
+as a static constant called `state_count`. Since our transition function type
+fulfills the __State_Register_Transition_Function__ concept, we should go ahead
+and make our automaton type fulfill the __Automaton_With_State_Register__
+concept by initializing the source state to zero.
+
+[example__neural_network_generator__ctors]
+
+The `process_input_impl()` method is invoked by the __automaton__ function
+call operator and handles the automaton's basic input processing. The
+transition function object cannot be modified at this point. Here, we let the
+transition function handle implementation of the feed-forward stage up to the
+point where the neurons in the last layer calculate their outputs. Note that
+the __State_Register_Transition_Function__ concept does /not/ require the
+transition function type to overload the function call operator in any way;
+instead, in our case, we assume that it implements a `feed_forward()` member
+function that accepts an immutable `input` object and a mutable `output` object
+as its arguments.
+
+[example__neural_network_generator__input_start]
+
+After that, our automaton will take over and determine the appropriate state
+according to which output has the highest value.
+
+[example__neural_network_generator__input_max]
+
+Finally, we notify all __Automaton_Observers__ associated with the enclosing
+automaton that our input processing function has accepted the specified input,
+since we assume that any valid input will change the internal state.
+
+[example__neural_network_generator__input_return]
+
+Naturally, we should define methods that provide read-only access to our
+data. The __automaton__ class template will actually inherit this part
+of our interface.
+
+[example__neural_network_generator__accessors]
+
+[endsect] [/ The `neural_network_generator` class]
+
+[section:transition_function The `neural_network_transition_function` Class]
+All __Transition_Function__ models must possess a `tag` type definition so
+that __Automaton_Builder__ models can tell whether or not they are building
+the right type of transition function. The refinement of the
+__Transition_Function__ concept that a type actually models will determine
+what its `tag` type should be. In our case, we'll go ahead and use a custom
+type.
+
+[example__neural_network_trans_func__tag]
+
+The first thing we need to do with our `neural_network_transition_function`
+class is to fulfill the type and variable requirements imposed by the
+[link automata.tutorials.byo_automata.generator `neural_network_generator`
+return type]. We choose __std_vector__ as our __Sequence__ type for both
+input and output. The `BOOST_STATIC_CONSTANT` macro declares compile-time
+`static const` variables for compilers that do not support regular declarations
+of such variables.
+
+An industrial-strength neural network implementation would define a neuron type
+that encapsulates the weights and bias variables. We elect not to do this here
+so that we can focus on more automaton-specific details.
+
+[example__neural_network_trans_func__class]
+
+All __Transition_Function__ types are required to implement a default
+constructor. This one resizes the weight matrices and bias containers based on
+the values of the `static const` variables we defined earlier so that other
+methods don't have to continually resize them.
+
+[example__neural_network_trans_func__ctor]
+
+Our transition function will ignore negative input values and any state
+register values at or above the number of possible actions.
+
+[example__neural_network_trans_func__recognize]
+
+One restriction with regard to the activation function that wasn't mentioned
+before is that it must be differentiable. The backpropagation phase uses this
+derivative function to compute the errors in the intermediate results. We
+implement both functions as `static` helper methods for simplicity; a more
+customizable approach would be to factor them out into separate functions or
+function objects and then to bring them in as __Boost_Function__ objects.
+
+[example__neural_network_trans_func__feed_forward_helpers]
+
+The `_feed_forward()` helper method computes the overall outputs for a single
+neuron layer. The `feed_forward()` method that our `neural_network_generator`
+return type actually requires will in turn use this helper method on each
+layer to compute the outputs of the entire network.
+
+Remember: transition functions are *not required* to output a next state.
+
+[example__neural_network_trans_func__feed_forward]
+
+So far, we've seen how our `neural_network_transition_function` carries out its
+work and what parts of its data we can access. We have not yet determined how
+this transition function can be built, i.e. how we can modify this data. By
+convention, the __Transition_Function__ models provided by Boost.Automata
+possess straightforward modifier methods akin to those of __STL__ containers,
+e.g. `reset()` or `set_transition()`. However, *convention* does not mean
+*requirement*: again, we opt for simplicity and boil everything down into a
+single `reset()` method to complete the `public` interface.
+
+The `_back_propagate()` helper method adjusts the weights and biases for a
+single neuron layer. It assumes that the errors were computed beforehand.
+
+[example__neural_network_trans_func__reset_helper]
+
+Now, for the `reset()` method: it's a member function template that takes in
+everything we need to perform neural network training. The input samples
+and their expected outputs are in separate containers. The `sample_count`
+parameter determines how many samples will be used to train the network; this
+value is independent of the total number of samples. The `learning_rate`
+parameter will be used by the `_back_propagate()` helper method.
+
+[example__neural_network_trans_func__reset]
+
+The weights and biases must be initialized to random values between -0.5 and
++0.5; we employ __Boost_Random__ for this purpose.
+
+[example__neural_network_trans_func__reset__init_rand_weights]
+
+Our helper methods place their results in containers that are passed in as
+output parameters. We define these containers to their correct sizes here,
+again so that they don't have to be continually resized later.
+
+[example__neural_network_trans_func__reset__init_outputs_errors]
+
+[link automata.tutorials.byo_automata As stated before], the learning phase
+consists of two stages: feed-forward and backpropagate. The helper methods
+simply the implementation of these stages.
+
+[example__neural_network_trans_func__reset__start_cycle]
+
+However, let's not forget to compute the errors in each neuron layer's outputs
+before using the `_back_propagate()` method.
+
+[example__neural_network_trans_func__reset__back_propagate]
+
+If the number of samples used to train the network exceeds the total number of
+samples (the normal case), then existing samples will be reused.
+
+[example__neural_network_trans_func__reset__end_cycle]
+[endsect] [/ The `neural_network_transition_function` Class]
+
+[section:make_samples The `make_samples` Function Template]
+This quick-and-dirty routine manufactures the input samples and their expected
+outputs that the [link automata.tutorials.byo_automata.transition_function
+`neural_network_transition_function::reset()` method] needs. In reality, this
+data would be loaded from files, runtime databases, etc.
+
+[example__neural_network_make_samples]
+[endsect]
+
+[section:builder The `neural_network_builder` Class Template]
+
+The component we're about to describe needs to be aware of the existence of
+the `neural_network_transition_function_tag` type. A forward declaration will
+suffice here.
+
+[example__neural_network_builder__fwd_decl]
+
+The `neural_network_builder` is known as a *template function object*, not
+because the type itself is a class template, but because its function call
+operator is templated. As the [link automata.tutorials.byo_automata.generator
+`neural_network_generator` return type] did, this operator assumes only certain
+facts about the type of function it takes in, namely that its tag type is the
+same as `neural_network_transition_function_tag` and that its `reset()` method
+can take in the same arguments that the
+[link automata.tutorials.byo_automata.transition_function
+`neural_network_transition_function::reset()` method] did.
+
+[example__neural_network_builder]
+[endsect]
+
+[section:policy The `neural_network_insertion_policy` Class Template]
+The __t_built_in_insertion_policies__ are, for the most part, compatible only
+with the built-in automata generators. Furthermore, they assume that the
+states and inputs themselves are sufficiently readable by humans and can
+therefore be sent directly to output streams. Our custom automaton expects the
+inputs and outputs to be simple containers of double-precision floating point
+numbers, which look meaningless without context. This application expects the
+`neural_network_insertion_policy` class template to provide that context by
+storing the actual names of the states and the inputs and sending them to the
+output stream whenever necessary.
+
+We refer to output streams as *insertion targets* because they are manipulated
+solely through the use of the insertion operator (`<<`). This class is
+templated so that any type for which the insertion operator is suitably
+overloaded can serve as an insertion target.
+
+[example__neural_network_policy]
+
+The __basic_format__ class template handles the dirty work of taking in the
+elements to be displayed via the modulus operator (`%`), then matching them
+with their respective tokens inside the underlying format string. Afterwards,
+__basic_format__ objects can be either sent directly to the output stream or
+converted to __std_string__ objects for further processing. Because we want
+to display the name of the input or state to which each value is attributed,
+we need a total of three __basic_format__ objects: one for displaying each
+input and its value, one for displaying each state and its value, and one for
+the overall state of the automaton.
+
+This helper method is in `private` scope because only nested classes will make
+use of it.
+
+[example__neural_network_policy__output_helper]
+
+The __automaton__ class template requires each policy type to be a
+__Unary_Metafunction_Class__ that takes in its own type (or, to be more
+accurate, a base type) and returns the corresponding __Automaton_Observer__
+model. Here, the return type inherits some convenient no-op methods from
+__full_noop_observer__ and maintains an instance of our policy type so that
+it can use our helper method.
+
+[example__neural_network_policy__return_type]
+
+The subject constructor is invoked on an observer whenever its subject
+automaton is created using its own build constructor.
+
+[example__neural_network_policy__return_type__subject_ctor]
+
+[warning
+ Do not invoke any of the subject automaton's member functions or variables
+ from within your observer's constructors!
+]
+
+The subject copy constructor enables the subject automaton to model the
+__Copy_Constructible__ concept if the user so desires.
+
+[example__neural_network_policy__return_type__subject_copy]
+
+[important
+ In the subject copy constructor, always take care to initialize the parent
+ __Observer__ with the subject automaton explicitly passed in, not that of
+ the observer to be copied.
+]
+
+The canonical copy constructor is actually required by the __Observer__
+concept, which is a refinement of the __Copy_Constructible__ concept, among
+other things.
+
+[example__neural_network_policy__return_type__copy_ctor]
+
+This assignment operator enables the subject automaton to model the
+__Assignable__ concept. However, because it doesn't really make sense to
+copy the contents of the policy objects, this operator essentially becomes a
+no-op.
+
+[example__neural_network_policy__return_type__assign_op]
+
+We are only interested in the state of our neural network as it processes each
+input. The __t_generator_type__ that we wrote assumes that all inputs should
+succeed, and we are not going to define any
+__t_input_validators_or_undo_capability__, so we need to overwrite only one
+function.
+
+[example__neural_network_policy__return_type__on_accept]
+[endsect] [/ The `neural_network_insertion_policy` Class Template]
+
+[section:main Putting It All Together]
+Now that we've defined our components, let's integrate them into the
+Boost.Automata framework. As usual, descriptive type definitions enhance
+the readability of our program.
+
+[example__neural_network__type_definitions]
+
+We have to load our training sets before we can do anything else.
+
+[example__neural_network__inputs_outputs]
+
+The names of the states and the inputs are stored in __array__ objects,
+which must be initialized through separate instructions. Otherwise, we can
+build our neural network automaton and its associated policies in one shot.
+
+[example__neural_network__automaton]
+
+Once our neural network is trained, running it is very simple.
+
+[example__neural_network__run]
+[endsect]
+
+The complete working program for this tutorial is contained in six files:
+
+ * __example_neural_network_generator_hpp__
+ * __example_neural_network_trans_func_hpp__
+ * __example_neural_network_make_samples_hpp__
+ * __example_neural_network_builder_hpp__
+ * __example_neural_network_policy_hpp__
+ * __example_neural_network_cpp__
+
+[endsect] [/ Tutorial: Building Your Own Automata]
+

Added: sandbox/automata/libs/automata/doc/tut_cellular_automata.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/tut_cellular_automata.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,129 @@
+[/=============================================================================
+ Copyright (C) 2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:cellular_automata Tutorial: Cellular Automata]
+
+[section:game_of_life Conway's Game of Life]
+__Conway_Game_of_Life__ is the premier example of a __cellular_automaton__. It
+operates under a simple rule: each dead cell becomes alive if it has exactly
+three live neighbors, and each live cell remains alive if it has two or three
+live neighbors. We can build a [termlink totalistic cellular automaton] that
+exhibits this behavior by defining a function that takes in an instance of a
+__totalistic_boolean_cell_transition_function__ and follows Conway's rule.
+
+[example__game_of_life__cell_function]
+
+Next, we define the types of the automaton cells, their graph layout, and the
+external property map that will bind them together. As long as the graph is
+mutable, it doesn't matter how else it is configured. The property map will
+serve as the state of our cellular automaton.
+
+[example__game_of_life__more_typedefs]
+
+The __cellular_graph_input_rule__ will refer to the graph layout to determine
+which cells are neighbors when it is used to update our automaton. Since
+neither the layout nor the input rule will change, they can be members of our
+singleton program.
+
+[example__game_of_life__program]
+
+For the sake of illustration, we want our program to start with a __glider__
+at the upper left corner. To accomplish this during construction of our
+automaton, we write an __Adaptable_Unary_Function__ that will build the
+starting state by forwarding it to a helper function, which will then build
+the individual cells, using the cell function we first wrote as well as some
+hardcoded data to represent our glider.
+
+[example__game_of_life__build_cells]
+
+The __moore_output_policy__ class template models the __Automaton_Observer__
+concept by providing a uniform way to handle all relevant events: it passes
+the subject automaton to our `output_cells` __Unary_Function__, which in turn
+forwards the [termlink current state] to a helper function that displays the
+individual cell states.
+
+[example__game_of_life__output]
+
+The __input_rule_transition_function__ must be configured so that the
+__cellular_graph_input_rule__ can modify the cell map in place. With that
+accomplished, our program can run the simulation.
+
+[example__game_of_life__run]
+
+If you run the program, you should see ASCII frames of the glider flying toward
+the lower right corner and then wrapping around back to its starting position
+in twenty-five iterations.
+
+The complete working program for this tutorial is contained in
+__example_game_of_life_cpp__.
+[endsect] [/ Conway's Game of Life]
+
+[section:wireworld Wireworld]
+__Wireworld__ is another example of a __cellular_automaton__. Machines of this
+type behave like animated circuit diagrams. This time around, there are four
+possible states for each cell instead of two, so we need a different type of
+transition function: the __totalistic_dt_cell_transition_function__. Its
+`add_transition()` method first takes in a symbol that will textually represent
+the cell's current state. Each succeeding line reads as follows:
+
+ * If the [termlink current state] is 'o', then the next state should be '+'.
+ * If the current state is '+', then the next state should be ' '.
+ * If the current state is ' ' and current state of one neighbor is 'o', then
+ the next state should be 'o'.
+ * If the current state is ' ' and two neighbors are at current state 'o',
+ then the next state should be 'o'.
+
+[example__wireworld__cell_function]
+
+Next, we define the types of the automaton cells, their graph layout, and the
+external property map that will bind them together. As long as the graph is
+mutable, it doesn't matter how else it is configured. The property map will
+serve as the state of our cellular automaton.
+
+[example__wireworld__more_typedefs]
+
+The __cellular_graph_input_rule__ will refer to the graph layout to determine
+which cells are neighbors when it is used to update our automaton. Since
+neither the layout nor the input rule will change, they can be members of our
+singleton program.
+
+[example__wireworld__program]
+
+For the sake of illustration, we want our program to animate a logic circuit of
+2 diodes. To accomplish this during construction of our automaton, we write an
+__Adaptable_Unary_Function__ that will build the starting state by forwarding
+it to a helper function, which will then build the individual cells, using the
+cell function we first wrote as well as some hardcoded data to represent our
+diode. A more robust cell-building function, of course, would perform this
+initialization with less pain, e.g. by reading from a file.
+
+[example__wireworld__build_cells]
+
+The __moore_output_policy__ class template models the __Automaton_Observer__
+concept by providing a uniform way to handle all relevant events: it passes
+the subject automaton to our `output_cells` __Unary_Function__, which in turn
+forwards the [termlink current state] to a helper function that displays the
+individual cell states.
+
+[example__wireworld__output]
+
+The __input_rule_transition_function__ must be configured so that the
+__cellular_graph_input_rule__ can modify the cell map in place. With that
+accomplished, our program can run the simulation.
+
+[example__wireworld__run]
+
+If you run the program, you should see ASCII frames of electrons passing
+through the top diode but not the bottom one.
+
+The complete working program for this tutorial is contained in
+__example_wireworld_cpp__.
+[endsect] [/ Wireworld]
+
+[endsect] [/ Tutorial: Cellular Automata]
+

Added: sandbox/automata/libs/automata/doc/tut_dfa.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/tut_dfa.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,161 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:dfa Tutorial: Deterministic Finite Automata]
+When the first template argument of an __automaton__ type instantiation is the
+__dfa_generator__ class and the second template argument models the
+__DFA_Transition_Function__ concept, the automaton type itself models the
+__DFA__ concept. However, there are many more ways to implement a transition
+function for a DFA than there are for a DPDA. Also, when describing DFA
+mechanics, the terms [termlink state] and [termlink state register value] are
+interchangeable; furthermore, the [termlink source state] has a value of zero
+by default.
+
+We start with the following type definitions:
+
+[test__dfa_trans_func__typedefs]
+
+[section:tabular Tabular Transition Functions]
+DFA transition functions are typically implemented in terms of tables or
+matrices. The table below shows the output of a sample transition function.
+
+[table
+ [[Current State][Input]]
+ [[ ][0][1][2][3]]
+ [[ 0][1][1][2][0]]
+ [[ 1][1][2][0][1]]
+ [[ 2][2][2][2][3]]
+ [[ 3][3][3][3][3]]
+]
+
+The __matrix_transition_function__ class template models the
+__Tabular_Transition_Function__ concept. Since it is used in the
+`Function0` type definition, we can write a function that models the
+__Automaton_Builder__ concept by taking in an object of this particular
+type. This function can reproduce the transition table like so:
+
+[test__dfa_build1__function]
+
+The `reset()` method call builds a transition table that recognizes 4 states
+(0 through 3) and 4 inputs (0 through 3). Until the next `set_transition()`
+method call, all transitions are set so that the next state will always be
+equal to the current state, i.e. the function call operator of an associated
+DFA will always return `false`. The three assignment calls also set
+transitions, but their syntax makes it clear that the transition function call
+operator should return the next state if invoked with the same arguments. The
+tradeoff is that the function assignment call creates a temporary object to
+provide its syntactic sugar, while the `set_transition()` method goes through
+no such hoops.
+
+We can now build and run our automaton:
+
+[test__matrix_dfa__case]
+[endsect]
+
+[section:mapped_input Mapped-Input Transition Functions]
+Human-readable transition tables do not normally use indices to represent
+inputs, however. The table below replaces the input indices with the actual
+symbols that they represent.
+
+[table
+ [[Current State][Input]]
+ [[ ][alpha][beta][gamma][delta]]
+ [[ 0][1][1][2][0]]
+ [[ 1][1][2][0][1]]
+ [[ 2][2][2][2][3]]
+ [[ 3][3][3][3][3]]
+]
+
+The __mapped_input_tabular_transition_function__ class template models the
+__Mapped_Input_Tabular_Transition_Function__ concept. As its name suggests,
+it requires a __Tabular_Transition_Function__ to run on top of. Since it is
+used in the `Function1` type definition, we can write a function that models
+the __Automaton_Builder__ concept by taking in an object of this particular
+type. This function can reproduce the human-readable transition table like so:
+
+[test__dfa_build2__function]
+
+This time, the `reset()` method call builds a transition table that recognizes
+4 states (0 through 3) and 4 inputs (`"alpha"`, `"beta"`, `"gamma"`, and
+`"delta"`). Aside from the different input type, the `set_transition()` and
+function assignment calls will work as before.
+
+We can now build and run our automaton:
+
+[test__mapped_input_tabular_dfa__case]
+
+The __mapped_input_transition_function__ class template models the
+__Mapped_Input_Transition_Function__ concept. It does not require a
+__Tabular_Transition_Function__, unlike the
+__mapped_input_tabular_transition_function__. Since it is used in the
+`Function2` type definition, we can write a function that models the
+__Automaton_Builder__ concept by taking in an object of this particular
+type. This function can reproduce the previous transition table like so:
+
+[test__dfa_build3__function]
+
+This time, the `reset()` method call builds a transition table that recognizes
+4 states (0 through 3). Each `set_transition()` and function assignment call
+will, in addition to specifying the next state for that particular input, add
+the input symbol to the set of recognized inputs if it is not already there.
+
+The tradeoff for not requiring a __Tabular_Transition_Function__ is that the
+__mapped_input_transition_function__ call operator is not as fast as that of
+the __mapped_input_tabular_transition_function__.
+
+We can now build and run our automaton:
+
+[test__mapped_input_dfa__case]
+[endsect]
+
+[section:next_state Next-State Transition Functions]
+For the times when the inputs are states themselves (or, more accurately,
+represent requests to set the DFA to the specified state), a *next-state
+transition function* will be more appropriate. The table below shows the
+output of one such transition function.
+
+[table
+ [[Current State][Valid Next States]]
+ [[ 0][1][2][4]]
+ [[ 1][0][2][3]]
+ [[ 2][3][4]]
+ [[ 3][0][1][2]]
+ [[ 4][0][3][5]]
+ [[ 5][]]
+]
+
+The __next_state_transition_function__ class template models the
+__Next_State_Transition_Function__ concept. Since it is used in the
+`Function3` type definition, we can write a function that models the
+__Automaton_Builder__ concept by taking in an object of this particular
+type. This function can reproduce the transition table like so:
+
+[test__dfa_build4__function]
+
+Notice that we now /add/ transitions rather than set them; since the next state
+serves as an input, the extra parameter becomes redundant. In this context,
+the function addition assignment syntax makes more sense than the regular
+function assignment syntax. The temporary-object tradeoff still applies,
+though.
+
+We can now build and run our automaton:
+
+[test__next_state_dfa__case]
+[endsect]
+
+The complete working program for this tutorial is contained in three files:
+
+ * __test_dfa_builder_hpp__
+ * __test_dfa_builder_cpp__
+ * __test_dfa_cpp__
+
+[important
+ __Build__ __Boost_Test__ before you attempt to compile the program.
+]
+[endsect] [/ Tutorial: Deterministic Finite Automata]
+

Added: sandbox/automata/libs/automata/doc/tut_func2a.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/tut_func2a.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,75 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:func2a Tutorial: From Function To Automaton]
+Converting an ordinary binary function to a transition function that
+Boost.Automata can use ought to be much more straightforward than defining a
+__Unary_Metafunction_Class__ and a wrapper __Transition_Function__ model,
+both of which the __automaton__ class template requires. Here, we take a
+detour to examine the more specialized __function_automaton__ and its
+relative syntactic appeal.
+
+Let's say that we want to create a [@http://en.wikipedia.org/wiki/Markov_chain
+Markov chain]. Its state type is a mathematical vector, and its transition
+function is a matrix-vector multiplication operator. Our binary function is a
+simple wrapper around __ublas_prod__.
+
+[example__ublas_product__function]
+
+We will use our Markov chain to study a simple weather model. The following
+values will form our matrix:
+
+ * A sunny day has a 90% chance of remaining sunny in the next day and a 10%
+ chance of becoming rainy in the next day.
+ * A rainy day has a 50% chance of becoming sunny in the next day and a 50%
+ chance of staying rainy in the next day.
+
+Thus, our state vector contains two elements: the chance that it is sunny
+today, and the chance that it is raining. Our source state indicates that it
+is definitely sunny on the first day. We want to verify that because our
+matrix is stochastic, the Markov chain will eventually reach a steady state.
+
+[example__markov_chain__setup]
+
+The __function_automaton__ class template requires a function type, which can
+be tricky to hand-code. With the advent of __Boost_Typeof__, this hand-coding
+is no longer a necessity. All we need to pass into the constructor are our
+binary function and the desired source state.
+
+[example__markov_chain__automaton]
+
+[note
+ __Boost_Parameter__ currently has
+ [@https://svn.boost.org/trac/boost/ticket/2793 trouble]
+ deducing arguments that resolve to functions. For now, you must pass the
+ function argument by name or by position--in this case, the first position.
+]
+
+[note
+ The reason we didn't use __ublas_prod__ directly is because it's actually
+ an overloaded function template. It becomes overly difficult just to pass
+ the appropriate function overload as an argument, let alone deduce the
+ correct type.
+]
+
+The program works as follows: it translates our current state vector to today's
+chances of rain or shine. Each positive integer we enter indicates the number
+of days that we want to look ahead, but we'll only get the results for the last
+day. The program ends when we enter an illegal value or a non-positive
+integer.
+
+[example__markov_chain__usage]
+
+Continuously entering positive integers will show that our Markov chain does
+indeed reach a steady state: all future days have an 83.33% chance of being
+sunny and a 16.67% chance of being rainy.
+
+The complete working program for this tutorial is contained in
+__example_markov_chain_cpp__.
+[endsect] [/ Tutorial: From Function To Automaton]
+

Added: sandbox/automata/libs/automata/doc/tut_input_rules.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/tut_input_rules.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,53 @@
+[/=============================================================================
+ Copyright (C) 2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:input_rules Tutorial: Input Rules]
+
+Using an __automaton__ to implement a __zero_player_game__--a machine whose
+next state is determined solely by its [termlink current state]--should be a
+trivial matter. Zero-player games tend to belong in families, however:
+conceptually, the [termlink transition function] of each family member is the
+only property that differs between them. None of the __Transition_Function__
+models can change behavior during input processing by the __automaton__ that
+owns them in this framework. Input rules provide the missing flexibility.
+
+Earlier tutorials have shown how __Automaton_Builders__ build
+__Transition_Functions__; this time, we see how they can also build state
+objects. The function that uses a random number generator will be used to
+initialize the __automaton__ for implementing __Rule_184__.
+
+[example__elementary_cellular_automaton__builders]
+
+The __wolfram_code_input_rule__ class template works on bidirectional models of
+the __Sequence__ concept such as __std_deque__. In turn, this class template
+models the __Input_Rule__ concept. Objects of such types can be passed in as
+inputs processed by any __automaton__ whose transition function type is
+a compatible __input_rule_transition_function__. This function delegates state
+transitions to the __Input_Rule__ object, which either modifies the current
+state in place or--in this case--returns the next state.
+
+[example__elementary_cellular_automaton__typedefs]
+
+Suceeding states will be displayed in each line. The output of each `run` call
+will look like either a growing triangle or a block that may be ragged on the
+right side.
+
+[example__elementary_cellular_automaton__run]
+
+The __wolfram_code_input_rule__ can be configured to transition state sequences
+according to rules named by the __Wolfram_code__. This program will output the
+results of applying __Rule_30__, __Rule_90__, Rule 124 (which is a mirror image
+of __Rule_110__) and __Rule_184__ to the __automaton__.
+
+[example__elementary_cellular_automaton__main]
+
+The complete working program for this tutorial is contained in
+__example_elem_cell_automaton_cpp__.
+
+[endsect] [/ Tutorial: Input Rules]
+

Added: sandbox/automata/libs/automata/doc/tut_observer_policies.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/tut_observer_policies.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,183 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:observer_policies Tutorial: Observer Policies]
+We build [termlink automata] to perform repetitive tasks for us, routines that
+either validate [termlink input symbols] or respond to changes in the [termlink
+states] of the automata. Some of these routines are often reused in different
+combinations by different types of automata. The Boost.Automata framework
+categorizes these routines according to the __Observer__ concept and its
+refinements. More specifically, the routines that respond to state changes are
+__Automaton_Observers__, while the ones that validate input symbols are
+__Input_Validators__.
+
+The __automaton__ class template binds itself to its observers at compile
+time, by way of *policies* enacted by the __automaton__ type. In general,
+a *policy* is a class type that, when passed as a template argument to a
+parameterized class type, determines a particular aspect of the paramterized
+type's overall behavior. This tutorial will focus on the policy classes and
+templates provided by Boost.Automata that bind the __automaton__ type to
+__Automaton_Observers__. The
+__Input_Validation_and_Undoable_Automata_tutorial__ will expand on the
+policy classes and templates that bind the __automaton__ type to
+__Input_Validators__.
+
+[section:final_state Final-State Policies]
+We will reuse the second and fourth examples from the __DFA_tutorial__. Here
+is a tabular representation of the second example's transition function.
+
+[table
+ [[Current State][Input]]
+ [[ ][alpha][beta][gamma][delta]]
+ [[ 0][1][1][2][0]]
+ [[ 1][1][2][0][1]]
+ [[ 2][2][2][2][3]]
+ [[ *3*][3][3][3][3]]
+]
+
+For this example, we will designate state 3 as the [termlink final state]. An
+automaton should stop processing inputs once it has reached a final state,
+e.g. so that an application can evaluate the inputs already processed. For
+the other example, we will designate states 2 and 5 as final states.
+
+[table
+ [[Current State][Valid Next States]]
+ [[ 0][1][2][4]]
+ [[ 1][0][2][3]]
+ [[ *2*][3][4]]
+ [[ 3][0][1][2]]
+ [[ 4][0][3][5]]
+ [[ *5*][]]
+]
+
+We will alter our __DFA_program__ to incorporate the final states previously
+mentioned. First, we will reuse the transition function types:
+
+[example__dfa_builder__function_types]
+
+Next, we will replace the build functions with a `sample_dfa_builder` functor
+class. Inside its body, we will define some __Observer_Builders__. (They
+don't /have/ to be nested; it's just that no one outside the
+`sample_dfa_builder` needs to know about them for this application to
+work.) __t_Automata_builders__ know only how to build __Automata__,
+not any __Automaton_Observers__ associated with them; hence, the need for
+__Observer_Builders__.
+
+[example__dfa_builder__class]
+
+The `get_final_state()` method is invoked by the return type of the
+__single_final_state_policy__ class template, while the
+`make_final_states()` member function template is invoked by the return type of
+the __parallel_final_states_policy__ class template.
+
+[example__dfa_builder__get_final_state]
+
+The `sample_dfa_builder::observer_builder_map` type definition binds the
+nested __Observer_Builders__ to their respective automaton policies. The
+`sample_dfa_builder` class needs only to store an instance of this type,
+initialize it in the constructor, and provide an appropriate accessor to
+it. The __single_final_state_policy__ template will look for an
+__Observer_Builder__ to which the `single_final_state_key<>` is mapped
+so that it can initialize exactly one final state, while the
+__parallel_final_states_policy__ class template will look for an
+__Observer_Builder__ to which the `multiple_final_states_key<>` is mapped
+so that it can initialize more than one final state.
+
+[example__dfa_builder__ctor__get_map]
+
+The function call operator implementations are the same as those of the build
+functions in the __DFA_tutorial__.
+
+[example__dfa_builder__call_ops]
+[endsect] [/ Final-State Policies]
+
+[section:insertion Insertion Policies]
+By default, the __automaton__ class template knows nothing about
+final states. We must pass in as an additional template argument a
+__Fusion_Forward_Sequence__ containing either a
+__single_final_state_policy__ to store exactly one final state or a
+__parallel_final_states_policy__ to store more than one. For our first
+example automaton, in addition to a __single_final_state_policy__, we will
+also define a couple of policies that control the automaton's console
+output. They are called *insertion policies* because each of the underlying
+classes used to present the actual output must overload the insertion operator
+(`<<`) to do its work.
+
+[example__dfa__policies_1]
+
+The odd-looking string literal is a __Boost_Format__ string that displays
+four elements: the name of the observer's function just invoked (represented
+by the `%1%` token), the resultant state of its subject automaton (`%2%`), the
+inputs that would cause the automaton to change from that state (`%3%`), and
+any input that was passed to the function (`%4%`). __Boost_Format__ strings
+enable the formatting of output stream data in much the same way that C-style
+format strings do for the other arguments that are passed to the `printf()`
+function or its ilk. One key difference is that __Boost_Format__ string
+arguments can be specified by position--which they are in this case--instead
+of by type (`%u`, `%s`, etc.); this greatly increases the flexibility of the
+output format, since otherwise the order of the elements is fixed. We cover
+__Boost_Format__ string processing when we show you how to
+__t_build_your_own_policy_types__.
+
+Each policy type must be a __Unary_Metafunction_Class__ whose return type
+models the __Automaton_Observer__ concept. The return type of the
+__dfa_insertion_policy__ class template is a type whose instances will present
+state and input information during initialization, resetting, and input
+processing of the automaton. The return type of the __bool_insertion_policy__
+class template is a type whose instances will check if an underlying policy
+that is also associated with the automaton--in this case, the
+__single_final_state_policy__--has flagged a certain condition as `true`; this
+check will also be performed--and its results displayed--during initialization,
+resetting, and input processing of the automaton. The __automaton__ class
+template will create __Automaton_Observers__ of these types and associate them
+with itself.
+
+[example__dfa__1]
+
+Here, the first __Boost_Format__ string will be used when the automaton
+reaches the final state. As long as it *doesn't*, the second string will be
+used. Both format strings take in a single element: the current state of the
+automaton.
+
+The inputs from __t_the_original_program__ will be processed in the same order
+by this automaton. The only differences are the absence of `BOOST_CHECK`
+statements and that the input processing statements to be executed after the
+`reset()` statement are "rolled" into a `while` loop. The
+__Automaton_Observer__ to which the __single_final_state_policy__ is mapped
+overloads the boolean conversion operator to return `true` if and only if the
+automaton's [termlink current state] is the same as the final state to which
+the policy is initialized; this overload enables an instance of the
+__Automaton_Observer__--accessed by giving __fusion_at_key__ the
+__single_final_state_policy__ type and the automaton's observer map
+instance--to appear in the `while` conditional expression. Lastly, the
+automaton will send the appropriate output to the console during the execution
+of each mutating method, thanks to the insertion policies enacted on it.
+
+[example__dfa__run_1]
+
+A __parallel_final_states_policy__ will be used to initialize the final
+states of the second automaton; otherwise, the setup is essentially the same.
+
+[example__dfa__2]
+
+As before, the inputs from __t_the_original_program__ will be processed in the
+same order by this automaton. The `BOOST_CHECK` statements are also omitted;
+instead, the insertion policies enacted on the automaton will cause it to send
+output to the console as each input is processed.
+
+[example__dfa__run_2]
+[endsect] [/ Insertion Policies]
+
+The complete working program for this tutorial is contained in three files:
+
+ * __example_dfa_builder_hpp__
+ * __example_dfa_builder_cpp__
+ * __example_dfa_cpp__
+
+[endsect] [/ Tutorial: Observer Policies]
+

Added: sandbox/automata/libs/automata/doc/tut_undo.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/tut_undo.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,174 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section:undo Tutorial: Input Validation and Undoable Automata]
+Unlike the [link automata.tutorials other tutorial programs] that come with
+[link automata Boost.Automata], this program will allow its user to interact
+with it through the console. The user will expect the program to exit
+gracefully--without uncaught exceptions or assertion failures--if he or she
+enters invalid input, e.g. a word or letter. The user will also expect to be
+able to undo any bad inputs that the program otherwise considers valid.
+
+[section:graph_algo Anatomy of a Graph Algorithm]
+First, we need to write a function that generates random mazes. A random maze
+can be thought of as the minimum spanning tree in an undirected graph with
+random weights. So, we start off our `make_maze()` function template by
+defining a random number generator that we can use.
+
+[example__make_maze__rng]
+
+Now, the incoming graph to be modified will most likely /not/ possess a
+random-weight property map: we need to build our minimum spanning tree off a
+utility graph, then copy the result over.
+
+[example__make_maze__util_type]
+
+An industrial-strength maze creation algorithm would take different layouts
+into consideration. To keep things simple, we will hard-code our layout to
+one level of 6 rows by 5 columns of cells, all of which are orthogonally
+adjacent to each other, though they will initially be separated by walls.
+
+__maze_before__ [/ A 6-by-5 labyrinth with all its cell walls]
+
+Next, we will set up our layout. The graph constructor will add thirty
+vertices upon execution. Then the `for` loops will add the orthogonal
+edges. Each edge will be assigned a random weight as it is added to the
+utility graph.
+
+[example__make_maze__util_graph]
+
+The __graph_kruskal_mst__ algorithm will basically knock down each wall
+inside our labyrinth until all cells are connected, meaning that for every pair
+of cells a path exists that will run uninterrupted.
+
+__maze_after__ [/ The labyrinth after enough cell walls are knocked down]
+
+The result will be stored as a container of edges.
+
+[example__make_maze__do_it]
+
+We finish our function template by building the structure of the input graph to
+match that of our spanning tree.
+
+[example__make_maze__finish]
+[endsect]
+
+[section:main The Main Program]
+Our maze creation algorithm expects the input graph to be undirected and empty,
+so that's what we'll start out with before calling it.
+
+[example__maze__make]
+
+The __Observer_Policies_tutorial__ shows us how to add [termlink final states]
+to an automaton, while the __Automata_Builders_tutorial__ shows us how to
+create an automaton from a __graph_adjacency_list__ representation. Now,
+instead of writing our own __Observer_Builder__, we will make use of the
+__single_final_state_builder_from_graph__ class template that this library
+provides by inserting into a __Fusion_Forward_Sequence__, then passing it as
+an additional argument to the __builder_from_graph__ class template.
+
+[example__maze__builder_type]
+
+The presence of the `_Policies` __named_template_parameter__
+tells the compiler to expect a __Fusion_Forward_Sequence__ of
+__Unary_Metafunction_Classes__ whose return types are __Observer_Builders__,
+instead of an edge input map type, as the third argument to the
+__builder_from_graph__ type definition. The classic alternative is to
+explicitly pass in the default __mpl_void__ type as the edge input map before
+passing in `BuilderPolicies`, which is more cumbersome:
+
+``
+ typedef _builder_from_graph_<
+ Graph
+ , _property_map_<Graph,vertex_index_t>::type
+ , _mpl_void_
+ , BuilderPolicies
+ >
+ Builder;
+``
+
+When constructing a `Builder` object, however, the `BuilderPolicies` object
+can be a __deduced_argument__--that is, an argument that is not explicitly
+named--where the compiler would normally expect an edge input map instance.
+
+[example__maze__builder]
+
+The above statement, which makes room 29 a final state, is definitely more
+convenient than either
+
+``
+ Builder
+ builder(
+ g
+ , get(_vertex_index_, g)
+ , _policies = BuilderPolicies(SingleFinalStateBuilder(vertex(29, g)))
+ );
+``
+
+where `_policies` is the corresponding __named_parameter__, or
+
+``
+ Builder
+ builder(
+ g
+ , get(_vertex_index_, g)
+ , _mpl_void_()
+ , BuilderPolicies(SingleFinalStateBuilder(vertex(29, g)))
+ );
+``
+
+Building the other policy types is pretty much the same as in the
+__Observer_Policies_tutorial__.
+
+[example__maze__policies]
+
+[heading More Policies]
+Recall that __t_two_of_our_program_requirements__ are to handle invalid inputs
+without asserting/throwing exceptions and to enable the user to undo any bad
+but valid inputs. An __input_validation_policy__ with default template
+arguments will satisfy the first requirement. Passing __mpl_true__ as the
+last template argument to the __automaton__ type definition will enable it
+to model the __Undoable_Automaton__ concept, thus satisfying the second
+requirement.
+
+[example__maze__type]
+
+Without specifying the `_undo_limit` argument, the program would allow the user
+to undo his or her actions until the automaton returns to the starting state.
+
+``
+ Maze maze(builder, maze_policies);
+``
+
+By specifying a non-zero `_undo_limit`, only that many consecutive `undo()`
+actions are possible at most; subsequent undo operations are ignored. For this
+application, the number of vertices in the maze graph is a reasonable limit.
+
+[example__maze__object]
+
+[note
+ If the state type of an __automaton__ is an integer, then the
+ constructor cannot deduce the `_undo_limit` argument: you must specify it
+ either by name or by position. The presence of the `_source_state`
+ parameter, though not required here, should illustrate why parameter
+ deduction is not possible.
+]
+
+The simulation driver code will execute until the user either reaches the goal
+room or enters some non-numeric input.
+
+[example__maze__run]
+[endsect] [/ The Main Program]
+
+The complete working program for this tutorial is contained in two files:
+
+ * __example_maze_hpp__
+ * __example_maze_cpp__
+
+[endsect] [/ Tutorial: Input Validation and Undoable Automata]
+

Added: sandbox/automata/libs/automata/doc/tutorials.qbk
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/doc/tutorials.qbk 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,45 @@
+[/=============================================================================
+ Copyright (C) 2007-2011 Cromwell D. Enage
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+=============================================================================/]
+
+[section Tutorials]
+You should study the following tutorials in order so that you can use
+Boost.Automata effectively. However, if you can't wait to check out the fun
+stuff, the last three tutorials feature a __t_maze_application__ and a
+__t_neural_network__, respectively.
+
+ # The __Basics_tutorial__ covers how to build the transition functions of
+ __pushdown_automata__ so that they can parse inputs properly.
+ # The __Deterministic_Finite_Automata_tutorial__ covers how to build several
+ types of __dfa__ transition functions.
+ # The __Function_to_Automaton_tutorial__ shows you how to convert an
+ ordinary function into an automaton.
+ # The __Automata_Builders_tutorial__ illustrates several different
+ algorithmic methods for building automata and their transition functions.
+ # The __Input_Rules_tutorial__ presents a facility for changing the behavior
+ of automata during state changes.
+ # The __Observer_Policies_tutorial__ describes how to attach almost any
+ combination of commonly used properties to any type of automaton.
+ # The __Input_Validation_and_Undoable_Automata_tutorial__ shows you how to
+ customize input validation and how to enable and configure the undo
+ functionality.
+ # Finally, the Boost.Automata framework allows you to [tutoriallink
+ byo_automata..build your own automata types] while still taking advantage
+ of the features that this library offers.
+
+[include tut_basics.qbk]
+[include tut_dfa.qbk]
+[include tut_func2a.qbk]
+[include tut_builders.qbk]
+[include tut_input_rules.qbk]
+[include tut_observer_policies.qbk]
+[include tut_cellular_automata.qbk]
+[include tut_undo.qbk]
+[include tut_byo_automata.qbk]
+
+[endsect] [/ Tutorials]
+

Added: sandbox/automata/libs/automata/example/decision_tree_agent.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/decision_tree_agent.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,187 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iostream>
+#include <algorithm>
+#include <string>
+#include <map>
+#include <boost/tr1/random.hpp>
+#include <boost/fusion/container/list/cons.hpp>
+#include <boost/automata/keys/common.hpp>
+#include <boost/automata/generator/probabilistic.hpp>
+#include <boost/automata/transition_function/decision_tree.hpp>
+#include <boost/automata/policy/mealy_output.hpp>
+#include <boost/automata/automaton.hpp>
+
+//[example__decision_tree
+typedef boost::automata::decision_tree_transition_function<
+ std::string
+ , std::string
+ >
+ DecisionTreeFunction;
+
+void initial_build(DecisionTreeFunction& function)
+{
+ function.set_examples()
+ ("Health", "Good")
+ ("Position", "Exposed")
+ ("Ammunition", "Low")
+ ["Run"]
+ ("Health", "Good")
+ ("Position", "Covered")
+ ("Ammunition", "Plentiful")
+ ["Attack"]
+ ("Health", "Bad")
+ ("Position", "Covered")
+ ("Ammunition", "Plentiful")
+ ["Attack"]
+ ("Health", "Good")
+ ("Position", "Covered")
+ ("Ammunition", "Low")
+ ["Defend"]
+ ("Health", "Bad")
+ ("Position", "Covered")
+ ("Ammunition", "Low")
+ ["Defend"]
+ ;
+}
+
+void incremental_build_1(DecisionTreeFunction& function)
+{
+ function.add_example()
+ ("Health", "Bad")
+ ("Position", "Exposed")
+ ("Ammunition", "Plentiful")
+ ["Defend"];
+}
+
+void incremental_build_2(DecisionTreeFunction& function)
+{
+ function.add_example()
+ ("Health", "Good")
+ ("Position", "Exposed")
+ ("Ammunition", "Plentiful")
+ ["Run"];
+}
+
+typedef std::map<std::string,std::string>
+ InputMap;
+
+void write_input(InputMap::value_type const& input_pair)
+{
+ std::cout << '(' << input_pair.first << ": " << input_pair.second << ") ";
+}
+
+struct decision_tree_output
+{
+ template <typename Agent>
+ void operator()(Agent const& agent, InputMap const& input_map) const
+ {
+ std::for_each(input_map.begin(), input_map.end(), write_input);
+ std::cout << "=> " << agent.get_current_state() << std::endl;
+ }
+};
+
+typedef boost::automata::automaton<
+ boost::automata::probabilistic_generator<std::tr1::mt19937>
+ , DecisionTreeFunction
+ , boost::fusion::cons<
+ boost::automata::mealy_output_policy<decision_tree_output>
+ >
+ >
+ DecisionTreeAgent;
+
+void run(DecisionTreeAgent& agent)
+{
+ InputMap input_map;
+
+ input_map["Health"] = "Good";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Health"] = "Bad";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Position"] = "Covered";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Position"] = "Exposed";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Health"] = "Good";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Position"] = "Covered";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map.erase("Health");
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Position"] = "Exposed";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Ammunition"] = "Low";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Ammunition"] = "Plentiful";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Position"] = "Covered";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Ammunition"] = "Low";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map.erase("Position");
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Ammunition"] = "Plentiful";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Health"] = "Good";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Health"] = "Bad";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Ammunition"] = "Low";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Health"] = "Good";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+
+ input_map["Health"] = "Bad";
+ input_map["Position"] = "Covered";
+ input_map["Ammunition"] = "Low";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Health"] = "Bad";
+ input_map["Position"] = "Covered";
+ input_map["Ammunition"] = "Plentiful";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Health"] = "Bad";
+ input_map["Position"] = "Exposed";
+ input_map["Ammunition"] = "Low";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Health"] = "Bad";
+ input_map["Position"] = "Exposed";
+ input_map["Ammunition"] = "Plentiful";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Health"] = "Good";
+ input_map["Position"] = "Covered";
+ input_map["Ammunition"] = "Low";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Health"] = "Good";
+ input_map["Position"] = "Covered";
+ input_map["Ammunition"] = "Plentiful";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Health"] = "Good";
+ input_map["Position"] = "Exposed";
+ input_map["Ammunition"] = "Low";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+ input_map["Health"] = "Good";
+ input_map["Position"] = "Exposed";
+ input_map["Ammunition"] = "Plentiful";
+ for (std::size_t i = 0; i < 10; ++i) agent(input_map);
+}
+
+int main()
+{
+ DecisionTreeAgent agent(initial_build);
+
+ std::cout << "Agent after learning first 5 examples..." << std::endl;
+ run(agent);
+ std::cout << std::endl << "After learning example 6..." << std::endl;
+ agent.initialize(incremental_build_1);
+ run(agent);
+ std::cout << std::endl << "After learning example 7..." << std::endl;
+ agent.initialize(incremental_build_2);
+ run(agent);
+
+ return 0;
+}
+//]
+

Added: sandbox/automata/libs/automata/example/dfa.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/dfa.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,146 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iterator>
+#include <iostream>
+#include <vector>
+#include <boost/fusion/container/list.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/automata/generator/dfa.hpp>
+#include <boost/automata/policy/single_final_state.hpp>
+#include <boost/automata/policy/parallel_final_states.hpp>
+#include <boost/automata/policy/bool_insertion.hpp>
+#include <boost/automata/policy/dfa_insertion.hpp>
+#include <boost/automata/automaton.hpp>
+#include "dfa_builder.hpp"
+
+//[example__dfa__policies_1
+using namespace boost;
+using namespace automata;
+using namespace keyword;
+
+int main()
+{
+ typedef dfa_insertion_policy<std::ostream,std::string>
+ OutputStreamPolicy1;
+ typedef dfa_insertion_policy<std::ostream,unsigned int>
+ OutputStreamPolicy2;
+
+ OutputStreamPolicy1 ostream_policy1(
+ std::cout
+ , "%1%(%4%): current state = %2%; nontrivial inputs = [%3%]"
+ , ','
+ );
+ OutputStreamPolicy2 ostream_policy2(
+ std::cout
+ , "%1%(%4%): current state = %2%; nontrivial inputs = [%3%]"
+ , ','
+ );
+
+ typedef bool_insertion_policy<std::ostream,single_final_state_policy<> >
+ SingleTargetPolicy;
+ typedef fusion::list<
+ single_final_state_policy<>
+ , OutputStreamPolicy1
+ , SingleTargetPolicy
+ >
+ Policies1;
+ //]
+ //[example__dfa__1
+ typedef automaton<dfa_generator,Function1,Policies1>
+ DFA1;
+
+ sample_dfa_builder
+ builder;
+ DFA1
+ dfa1(
+ builder
+ , Policies1(
+ single_final_state_policy<>()
+ , ostream_policy1
+ , SingleTargetPolicy(
+ std::cout
+ , "DFA1: %1% is a final state."
+ , "DFA1: %1% is not a final state."
+ )
+ )
+ );
+ //]
+
+ //[example__dfa__run_1
+ dfa1("alpha");
+ dfa1("gamma");
+ dfa1("beta");
+ dfa1("delta");
+ dfa1.reset();
+
+ std::vector<std::string> inputs;
+
+ while (
+ !fusion::at_key<single_final_state_policy<> >(dfa1.get_observer_map())
+ )
+ {
+ dfa1.make_nontrivial_inputs(
+ std::insert_iterator<std::vector<std::string> >(inputs, inputs.begin())
+ );
+
+ if (inputs.empty())
+ {
+ std::cout << "DFA1 final state unreachable." << std::endl;
+ break;
+ }
+
+ dfa1(inputs[0]);
+ inputs.clear();
+ }
+
+ std::cout << std::endl;
+ //]
+
+ //[example__dfa__2
+ typedef bool_insertion_policy<std::ostream,parallel_final_states_policy<> >
+ ParallelTargetPolicy;
+ typedef fusion::list<
+ parallel_final_states_policy<>
+ , OutputStreamPolicy2
+ , ParallelTargetPolicy
+ >
+ Policies2;
+ typedef automaton<dfa_generator,Function3,Policies2>
+ DFA2;
+
+ DFA2
+ dfa2(
+ builder
+ , Policies2(
+ parallel_final_states_policy<>()
+ , ostream_policy2
+ , ParallelTargetPolicy(
+ std::cout
+ , "DFA2: %1% is a final state."
+ , "DFA2: %1% is not a final state."
+ )
+ )
+ );
+ //]
+
+ //[example__dfa__run_2
+ dfa2(2);
+ dfa2(4);
+ dfa2(0);
+ dfa2(1);
+ dfa2(3);
+ dfa2(2);
+ dfa2(4);
+ dfa2(3);
+ dfa2(1);
+ dfa2(0);
+ dfa2(4);
+ dfa2(5);
+
+ return 0;
+}
+//]
+

Added: sandbox/automata/libs/automata/example/dfa_builder.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/dfa_builder.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,101 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <string>
+#include <vector>
+#include "dfa_builder.hpp"
+
+//[example__dfa_builder__get_final_state
+std::size_t
+ sample_dfa_builder::single_final_state_builder::get_final_state() const
+{
+ return 3;
+}
+//]
+
+//[example__dfa_builder__ctor__get_map
+sample_dfa_builder::sample_dfa_builder()
+ : _map(
+ boost::fusion::make_pair<
+ boost::automata::single_final_state_key<>
+ >(single_final_state_builder())
+ , boost::fusion::make_pair<
+ boost::automata::multiple_final_states_key<>
+ >(multiple_final_states_builder())
+ )
+{
+}
+
+sample_dfa_builder::observer_builder_map const&
+ sample_dfa_builder::get_observer_builder_map() const
+{
+ return _map;
+}
+//]
+
+//[example__dfa_builder__call_ops
+//<-
+void sample_dfa_builder::operator()(Function0& function) const
+{
+ function.reset(4, 4);
+ function.set_transition(0, 0, 1);
+ function.set_transition(0, 1, 1);
+ function.set_transition(0, 2, 2);
+ function(1, 1) = 2;
+ function(1, 2) = 0;
+ function(2, 3) = 3;
+}
+//->
+
+void sample_dfa_builder::operator()(Function1& function) const
+{
+ std::vector<std::string> inputs;
+ inputs.push_back("alpha");
+ inputs.push_back("beta");
+ inputs.push_back("gamma");
+ inputs.push_back("delta");
+
+ function.reset(4, inputs.begin(), inputs.end());
+ function.set_transition(0, "alpha", 1);
+ function.set_transition(0, "beta", 1);
+ function.set_transition(0, "gamma", 2);
+ function(1, "beta") = 2;
+ function(1, "gamma") = 0;
+ function(2, "delta") = 3;
+}
+
+//<-
+void sample_dfa_builder::operator()(Function2& function) const
+{
+ function.reset(4);
+ function.set_transition(0, "alpha", 1);
+ function.set_transition(0, "beta", 1);
+ function.set_transition(0, "gamma", 2);
+ function(1, "beta") = 2;
+ function(1, "gamma") = 0;
+ function(2, "delta") = 3;
+}
+//->
+
+void sample_dfa_builder::operator()(Function3& function) const
+{
+ function.reset(6);
+ function.add_transition(0, 1);
+ function.add_transition(0, 2);
+ function.add_transition(0, 4);
+ function.add_transition(1, 0);
+ function.add_transition(1, 2);
+ function.add_transition(1, 3);
+ function.add_transition(2, 3);
+ function(2) += 4;
+ function(3) += 0;
+ function(3) += 1;
+ function(3) += 2;
+ function(4) += 0;
+ function(4) += 3;
+ function(4) += 5;
+}
+//]
+

Added: sandbox/automata/libs/automata/example/dfa_builder.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/dfa_builder.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,86 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef LIBS_AUTOMATA_EXAMPLE_DFA_BUILDER_HPP_INCLUDED
+#define LIBS_AUTOMATA_EXAMPLE_DFA_BUILDER_HPP_INCLUDED
+
+#include <string>
+#include <boost/fusion/container/map.hpp>
+#include <boost/fusion/support/pair.hpp>
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/automata/keys/observer.hpp>
+#include <boost/automata/transition_function/matrix.hpp>
+#include <boost/automata/transition_function/mapped_input_tabular.hpp>
+#include <boost/automata/transition_function/mapped_input.hpp>
+#include <boost/automata/transition_function/next_state.hpp>
+
+//[example__dfa_builder__function_types
+typedef boost::automata::matrix_transition_function<
+ boost::numeric::ublas::matrix<std::size_t>
+ >
+ Function0;
+typedef boost::automata::mapped_input_tabular_transition_function<
+ std::string
+ , Function0
+ >
+ Function1;
+//<-
+typedef boost::automata::mapped_input_transition_function<std::string>
+ Function2;
+//->
+typedef boost::automata::next_state_transition_function<>
+ Function3;
+//]
+
+//[example__dfa_builder__class
+class sample_dfa_builder
+{
+ struct single_final_state_builder
+ {
+ std::size_t get_final_state() const;
+ };
+
+ struct multiple_final_states_builder
+ {
+ template <typename States>
+ void make_final_states(States& states) const
+ {
+ states.insert(2);
+ states.insert(5);
+ }
+ };
+
+ public:
+ typedef boost::fusion::map<
+ boost::fusion::pair<
+ boost::automata::single_final_state_key<>
+ , single_final_state_builder
+ >
+ , boost::fusion::pair<
+ boost::automata::multiple_final_states_key<>
+ , multiple_final_states_builder
+ >
+ >
+ observer_builder_map;
+
+ private:
+ observer_builder_map _map;
+
+ public:
+ sample_dfa_builder();
+ observer_builder_map const& get_observer_builder_map() const;
+ //<-
+ void operator()(Function0& function) const;
+ //->
+ void operator()(Function1& function) const;
+ //<-
+ void operator()(Function2& function) const;
+ //->
+ void operator()(Function3& function) const;
+};
+//]
+
+#endif // LIBS_AUTOMATA_EXAMPLE_DFA_BUILDER_HPP_INCLUDED
+

Added: sandbox/automata/libs/automata/example/dpda.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/dpda.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,90 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/fusion/container/list.hpp>
+#include <boost/automata/generator/dpda.hpp>
+#include <boost/automata/policy/dpda_insertion.hpp>
+#include <boost/automata/automaton.hpp>
+#include "../test/dpda_builder.hpp"
+#include "dpda.hpp"
+
+using namespace boost;
+using namespace automata;
+using namespace keyword;
+
+int main()
+{
+ typedef dpda_insertion_policy<std::ostream,char>
+ OutputStreamPolicy;
+ typedef fusion::list<OutputStreamPolicy>
+ Policies;
+
+ automaton<dpda_generator,Function,Policies>
+ dpda(
+ build1
+ , Policies(
+ OutputStreamPolicy(
+ std::cout
+ , "%1%(%5%): current state = %2%; stack = [%3%]; nontrivial inputs = [%4%]"
+ , ','
+ )
+ )
+ );
+
+ test(dpda, "aab");
+ std::cout << std::endl;
+ dpda.reset();
+ test(dpda, "aabb");
+ std::cout << std::endl;
+ dpda.reset();
+ test(dpda, "aabbb");
+ std::cout << std::endl;
+ dpda.reset();
+ test(dpda, "aaabbb");
+ std::cout << std::endl;
+
+ dpda.initialize(build2);
+
+ test(dpda, "x+y)");
+ std::cout << std::endl;
+ dpda.reset();
+ test(dpda, "(x+y");
+ std::cout << std::endl;
+ dpda.reset();
+ test(dpda, "xy+z");
+ std::cout << std::endl;
+ dpda.reset();
+ test(dpda, "x(y+z)");
+ std::cout << std::endl;
+ dpda.reset();
+ test(dpda, "(x+y)*x-z*y/(x+x)");
+ std::cout << std::endl;
+ dpda.reset();
+ test(dpda, "x/(y*(z-y)+x)");
+ std::cout << std::endl;
+
+ dpda.initialize(build3);
+
+ test(dpda, "aacc");
+ std::cout << std::endl;
+ dpda.reset();
+ test(dpda, "abc");
+ std::cout << std::endl;
+ dpda.reset();
+ test(dpda, "aabccc");
+ std::cout << std::endl;
+ dpda.reset();
+ test(dpda, "abbccc");
+ std::cout << std::endl;
+ dpda.reset();
+ test(dpda, "abbcccc");
+ std::cout << std::endl;
+ dpda.reset();
+ test(dpda, "bbbccc");
+ std::cout << std::endl;
+
+ return 0;
+}
+

Added: sandbox/automata/libs/automata/example/dpda.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/dpda.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,27 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef LIBS_AUTOMATA_EXAMPLE_DPDA_HPP_INCLUDED
+#define LIBS_AUTOMATA_EXAMPLE_DPDA_HPP_INCLUDED
+
+#include <iostream>
+#include <string>
+#include "../test/basics.hpp"
+
+template <typename DPDA>
+void test(DPDA& dpda, std::string const& word)
+{
+ if (accept(dpda, word))
+ {
+ std::cout << word << " accepted." << std::endl;
+ }
+ else
+ {
+ std::cout << word << " rejected." << std::endl;
+ }
+}
+
+#endif // LIBS_AUTOMATA_EXAMPLE_DPDA_HPP_INCLUDED
+

Added: sandbox/automata/libs/automata/example/elem_cell_automaton.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/elem_cell_automaton.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,134 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iostream>
+#include <algorithm>
+#include <iterator>
+#include <deque>
+#include <boost/range/algorithm/copy.hpp>
+#include <boost/range/algorithm/generate.hpp>
+#include <boost/tr1/random.hpp>
+#include <boost/automata/generator/deterministic.hpp>
+#include <boost/automata/transition_function/input_rule.hpp>
+#include <boost/automata/input_rule/wolfram_code.hpp>
+#include <boost/automata/automaton.hpp>
+
+//[example__elementary_cellular_automaton__builders
+typedef std::deque<unsigned char> State;
+
+void build_one(State& state)
+{
+ state.clear();
+ state.push_back('1');
+}
+
+void build_from_rng(State& state)
+{
+ typedef std::tr1::minstd_rand Engine;
+ typedef std::tr1::uniform_int<unsigned char> Distribution;
+
+ Engine engine;
+ std::tr1::variate_generator<Engine&,Distribution> cg(
+ engine
+ , Distribution('0', '1')
+ );
+
+ state.resize(64);
+ boost::range::generate(state, cg);
+}
+//]
+
+//[example__elementary_cellular_automaton__typedefs
+typedef boost::automata::wolfram_code_input_rule<unsigned char>
+ Rule;
+typedef boost::automata::automaton<
+ boost::automata::deterministic_generator
+ , boost::automata::input_rule_transition_function<State>
+ >
+ CA;
+//]
+
+//[example__elementary_cellular_automaton__run
+typedef std::ostream_iterator<unsigned char>
+ OutIterator;
+
+void
+ run(
+ CA& ca
+ , Rule const& rule
+ , OutIterator& out_itr
+ , std::size_t const count
+ , bool const triangle_format
+ )
+{
+ if (triangle_format)
+ {
+ std::fill_n(out_itr, count + 1, ' ');
+ }
+
+ boost::range::copy(ca.get_current_state(), out_itr);
+ std::cout << std::endl;
+
+ for (std::size_t i = 0; i < count; ++i)
+ {
+ ca(rule);
+
+ if (triangle_format)
+ {
+ std::fill_n(out_itr, count - i, ' ');
+ }
+
+ boost::range::copy(ca.get_current_state(), out_itr);
+ std::cout << std::endl;
+ }
+}
+//]
+
+//[example__elementary_cellular_automaton__main
+int main()
+{
+ Rule rule('0');
+ CA ca(build_one);
+ OutIterator out_itr(std::cout);
+
+ rule.add_association('0', '0', '1', '1');
+ rule.add_association('0', '1', '0', '1');
+ rule.add_association('0', '1', '1', '1');
+ rule.add_association('1', '0', '0', '1');
+ std::cout << "Rule 30:" << std::endl;
+ run(ca, rule, out_itr, 20, true);
+
+ rule.reset();
+ rule('0', '0', '1') = '1';
+ rule('0', '1', '1') = '1';
+ rule('1', '0', '0') = '1';
+ rule('1', '1', '0') = '1';
+ ca.reset();
+ std::cout << std::endl << "Rule 90:" << std::endl;
+ run(ca, rule, out_itr, 31, true);
+
+ rule.reset();
+ rule('0', '1', '0') = '1';
+ rule('1', '1', '0') = '1';
+ rule('0', '0', '1') = '1';
+ rule('1', '0', '1') = '1';
+ rule('0', '1', '1') = '1';
+ ca.reset();
+ std::cout << std::endl << "Rule 124:" << std::endl;
+ run(ca, rule, out_itr, 45, false);
+
+ rule.reset();
+ rule('0', '1', '1') = '1';
+ rule('1', '0', '0') = '1';
+ rule('1', '0', '1') = '1';
+ rule('1', '1', '1') = '1';
+ ca.initialize(build_from_rng);
+ std::cout << std::endl << "Rule 184:" << std::endl;
+ run(ca, rule, out_itr, 28, false);
+
+ return 0;
+}
+//]
+

Added: sandbox/automata/libs/automata/example/game_of_life.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/game_of_life.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,186 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_PARAMETER_MAX_ARITY 11
+
+#include <iostream>
+#include <boost/tr1/tuple.hpp>
+#include <boost/array.hpp>
+#include <boost/gil/utilities.hpp>
+#include <boost/fusion/container/list/cons.hpp>
+#include <boost/property_map/property_map.hpp>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/graph_selectors.hpp>
+#include <boost/graph/graph_traits.hpp>
+#include <boost/graph/properties.hpp>
+#include <boost/graph/vertex_property_map_gen.hpp>
+#include <boost/graph/basic_vert_insert_iterator.hpp>
+#include <boost/graph/basic_add_edge_function.hpp>
+#include <boost/graph/set_orthogonal_grid_layout.hpp>
+#include <boost/automata/generator/deterministic.hpp>
+#include <boost/automata/transition_function/totalistic_boolean_cell.hpp>
+#include <boost/automata/transition_function/input_rule.hpp>
+#include <boost/automata/input_rule/cellular_graph.hpp>
+#include <boost/automata/policy/moore_output.hpp>
+#include <boost/automata/automaton.hpp>
+
+//[example__game_of_life__cell_function
+typedef boost::automata::totalistic_boolean_cell_transition_function<>
+ CellFunction;
+
+void build_function(CellFunction& function)
+{
+ function |= 3;
+ function &= 2, 3;
+}
+//]
+
+//[example__game_of_life__more_typedefs
+typedef boost::adjacency_list<boost::multisetS,boost::listS,boost::undirectedS>
+ Graph;
+typedef boost::automata::automaton<
+ boost::automata::deterministic_generator
+ , CellFunction
+ >
+ Cell;
+typedef boost::vertex_property_map_gen<Graph,Cell>::type
+ CellMap;
+//]
+
+//[example__game_of_life__program
+class life_program
+{
+ static const std::size_t dim_size = 5;
+
+ Graph graph;
+ boost::automata::cellular_graph_input_rule<Graph> rule;
+
+ life_program() : graph(), rule(graph)
+ {
+ boost::array<bool,2> wraparound_policy = {{true, true}};
+
+ boost::set_orthogonal_grid_layout(
+ boost::basic_vertex_inserter(graph)
+ , boost::basic_2way_edge_adder(graph)
+ , boost::gil::point2<int>(dim_size, dim_size)
+ , boost::graph::keywords::_is_zeta = true
+ , boost::graph::keywords::_wraparound_policy = wraparound_policy
+ );
+ }
+
+ life_program(life_program const& copy);
+ life_program& operator=(life_program const& copy);
+ ~life_program() {}
+
+ public:
+ static life_program const& get_instance()
+ {
+ static life_program instance;
+ return instance;
+ }
+ //]
+
+ //[example__game_of_life__build_cells
+ void build_cells(CellMap& cell_map) const
+ {
+ boost::graph_traits<Graph>::vertex_iterator vi, vi_end;
+ int i = 0;
+
+ for (
+ std::tr1::tie(vi, vi_end) = boost::vertices(graph);
+ vi != vi_end;
+ ++vi
+ )
+ {
+ boost::put(
+ cell_map
+ , *vi
+ , Cell(
+ build_function
+ , (
+ (i == 0)
+ || (i == dim_size + 1)
+ || (i == dim_size + 2)
+ || (i == dim_size * 2)
+ || (i == dim_size * 2 + 1)
+ )
+ )
+ );
+ ++i;
+ }
+ }
+
+ struct cell_builder
+ {
+ typedef CellMap argument_type;
+ typedef void result_type;
+
+ result_type operator()(argument_type& cell_map) const
+ {
+ life_program::get_instance().build_cells(cell_map);
+ }
+ };
+ //]
+
+ //[example__game_of_life__output
+ private:
+ void output(CellMap const& cell_map) const
+ {
+ boost::graph_traits<Graph>::vertex_iterator vi, vi_end;
+ std::tr1::tie(vi, vi_end) = boost::vertices(graph);
+ std::cout << std::endl;
+
+ for (std::size_t y = 0; y < dim_size; ++y)
+ {
+ for (std::size_t x = 0; x < dim_size; ++x)
+ {
+ std::cout << (
+ boost::get(cell_map, *vi).get_current_state() ? '1' : '0'
+ );
+ ++vi;
+ }
+
+ std::cout << std::endl;
+ }
+ }
+
+ struct output_cells
+ {
+ template <typename SubjectAutomaton>
+ void operator()(SubjectAutomaton const& automaton) const
+ {
+ life_program::get_instance().output(automaton.get_current_state());
+ }
+ };
+ //]
+
+ //[example__game_of_life__run
+ public:
+ void run() const
+ {
+ CellMap start(graph);
+ boost::automata::automaton<
+ boost::automata::deterministic_generator
+ , boost::automata::input_rule_transition_function<CellMap,true>
+ , boost::fusion::cons<
+ boost::automata::moore_output_policy<output_cells>
+ >
+ > game_of_life(cell_builder(), start);
+ std::size_t iteration_count = dim_size * 4;
+
+ for (std::size_t i = 0; i < iteration_count; ++i)
+ {
+ game_of_life(rule);
+ }
+ }
+};
+
+int main()
+{
+ life_program::get_instance().run();
+ return 0;
+}
+//]
+

Added: sandbox/automata/libs/automata/example/markov_chain.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/markov_chain.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,83 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iostream>
+#include <boost/typeof/typeof.hpp>
+#include <boost/numeric/ublas/matrix_expression.hpp>
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/vector.hpp>
+#include <boost/automata/function_automaton.hpp>
+
+//[example__ublas_product__function
+using namespace boost;
+using namespace numeric;
+using namespace ublas;
+
+vector<double> ublas_product(vector<double> const& v, matrix<double> const& m)
+{
+ return prod(v, m);
+}
+//]
+
+//[example__markov_chain__setup
+int main()
+{
+ matrix<double> m(2, 2);
+
+ std::cout << "Chance that a sunny day will remain sunny tomorrow: ";
+ std::cout << (m(0, 0) = 0.9) << std::endl;
+ std::cout << "Chance that a sunny day will become rainy tomorrow: ";
+ std::cout << (m(0, 1) = 0.1) << std::endl;
+ std::cout << "Chance that a rainy day will become sunny tomorrow: ";
+ std::cout << (m(1, 0) = 0.5) << std::endl;
+ std::cout << "Chance that a rainy day will remain rainy tomorrow: ";
+ std::cout << (m(1, 1) = 0.5) << std::endl;
+
+ vector<double> v(2);
+
+ v(0) = 1.0;
+ v(1) = 0.0;
+ //]
+
+ //[example__markov_chain__automaton
+ typedef automata::function_automaton<BOOST_TYPEOF(ublas_product)>
+ MarkovChain;
+
+#ifdef __BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__
+ MarkovChain markov_chain(ublas_product, v);
+#else // !defined(__BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__)
+ MarkovChain markov_chain(v, ublas_product);
+#endif // __BOOST_AUTOMATA_NO_FUNC_PARAM_WKND__
+ //]
+
+ //[example__markov_chain__usage
+ int input;
+
+ for (;;)
+ {
+ std::cout << "Today\'s chances of sunshine: ";
+ std::cout << markov_chain.get_current_state()(0) << std::endl;
+ std::cout << "Today\'s chances of rain: ";
+ std::cout << markov_chain.get_current_state()(1) << std::endl;
+ std::cout << "Enter the number of days to look ahead: ";
+
+ if ((std::cin >> input) && (0 < input))
+ {
+ while (input--)
+ {
+ markov_chain(m);
+ }
+ }
+ else
+ {
+ std::cout << "Go bye-bye." << std::endl;
+ break;
+ }
+ }
+
+ return 0;
+}
+//]
+

Added: sandbox/automata/libs/automata/example/markov_decision_process.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/markov_decision_process.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,99 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iostream>
+#include <vector>
+#include <boost/tr1/random.hpp>
+#include <boost/assign/list_of.hpp>
+#include <boost/fusion/container/list.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/automata/generator/probabilistic.hpp>
+#include <boost/automata/transition_function/mdp_mapped_input.hpp>
+#include <boost/automata/policy/mdp_best_input.hpp>
+#include <boost/automata/policy/moore_output.hpp>
+#include <boost/automata/automaton.hpp>
+
+//[example__markov_decision_process__transition_function
+typedef boost::automata::mdp_mapped_input_transition_function<int>
+ MDPFunction;
+
+void build(MDPFunction& f)
+{
+ using boost::assign::pair_list_of;
+
+ f.reset(3);
+ f(0, 0) = pair_list_of(0, 0.5)(2, 0.5);
+ f(0, 1) = 2;
+ f(1, 0) = pair_list_of(0, 0.7)(1, 0.1)(2, 0.2);
+ f(1, 1) = pair_list_of(1, 0.95)(2, 0.05);
+ f(2, 0) = pair_list_of(0, 0.4)(2, 0.6);
+ f(2, 1) = pair_list_of(0, 0.3)(1, 0.3)(2, 0.4);
+}
+//]
+
+//[example__markov_decision_process__reward_function
+double reward(std::size_t current_state, int i, std::size_t next_state)
+{
+ if (next_state == 0)
+ {
+ if ((current_state == 1) && (i == 0))
+ {
+ return 5.0;
+ }
+
+ if ((current_state == 2) && (i == 1))
+ {
+ return -1.0;
+ }
+ }
+
+ return 0.0;
+}
+//]
+
+//[example__markov_decision_process__output_function
+typedef boost::automata::mdp_best_input_policy<int> BestInputPolicy;
+
+struct mdp_output
+{
+ template <typename SubjectAutomaton>
+ void operator()(SubjectAutomaton const& automaton) const
+ {
+ std::cout << "best_input[" << automaton.get_current_state() << "] = ";
+ std::cout << boost::fusion::at_key<BestInputPolicy>(
+ automaton.get_observer_map()
+ ).get_current_best() << std::endl;
+ }
+};
+//]
+
+//[example__markov_decision_process__main_program
+int main()
+{
+ typedef boost::fusion::list<
+ BestInputPolicy
+ , boost::automata::moore_output_policy<mdp_output>
+ >
+ Policies;
+
+ boost::automata::automaton<
+ boost::automata::probabilistic_generator<std::tr1::mt19937>
+ , MDPFunction
+ , Policies
+ > mdp(build, Policies(BestInputPolicy(reward, 0.8)));
+
+ for (std::size_t i = 0; i < 30; ++i)
+ {
+ mdp(
+ boost::fusion::at_key<BestInputPolicy>(
+ mdp.get_observer_map()
+ ).get_current_best()
+ );
+ }
+
+ return 0;
+}
+//]
+

Added: sandbox/automata/libs/automata/example/maze.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/maze.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,143 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iostream>
+#include <boost/property_map/property_map.hpp>
+#include <boost/graph/properties.hpp>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/graph_utility.hpp>
+#include <boost/fusion/container/list.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/automata/generator/dfa.hpp>
+#include <boost/automata/transition_function/next_state.hpp>
+#include <boost/automata/builder/from_graph/single_final_state.hpp>
+#include <boost/automata/builder/from_graph.hpp>
+#include <boost/automata/policy/single_final_state.hpp>
+#include <boost/automata/policy/bool_insertion.hpp>
+#include <boost/automata/policy/dfa_insertion.hpp>
+#include <boost/automata/policy/input_validation.hpp>
+#include <boost/automata/automaton.hpp>
+#include "maze.hpp"
+
+//[example__maze__make
+using namespace boost;
+using namespace automata;
+using namespace keyword;
+
+int main()
+{
+ typedef adjacency_list<vecS,vecS,undirectedS> Graph;
+
+ Graph g;
+
+ make_maze(g);
+ //]
+
+ //[example__maze__builder_type
+ typedef single_final_state_builder_from_graph<
+ graph_traits<Graph>::vertex_descriptor
+ >
+ SingleFinalStateBuilder;
+ typedef fusion::list<SingleFinalStateBuilder>
+ BuilderPolicies;
+ typedef builder_from_graph<
+ Graph
+ , property_map<Graph,vertex_index_t>::type
+ , _Policies<BuilderPolicies>
+ >
+ Builder;
+ //]
+
+ //[example__maze__builder
+ Builder
+ builder(
+ g
+ , get(vertex_index, g)
+ , BuilderPolicies(SingleFinalStateBuilder(vertex(29, g)))
+ );
+ //]
+
+ //[example__maze__policies
+ typedef dfa_insertion_policy<std::ostream,int>
+ OutputStreamPolicy;
+ typedef bool_insertion_policy<std::ostream,single_final_state_policy<> >
+ SingleTargetPolicy;
+ typedef fusion::list<
+ single_final_state_policy<>
+ , OutputStreamPolicy
+ , SingleTargetPolicy
+ >
+ MazePolicies;
+
+ MazePolicies
+ maze_policies(
+ single_final_state_policy<>()
+ , OutputStreamPolicy(
+ std::cout
+ , "%1%(%4%): current room = %2%; possible room changes are [%3%]"
+ , ','
+ )
+ , SingleTargetPolicy(
+ std::cout
+ , " Maze room %1% is the goal."
+ , " Maze room %1% is not yet the goal."
+ )
+ );
+ //]
+
+ //[example__maze__type
+ typedef automaton<
+ dfa_generator
+ , next_state_transition_function<>
+ , MazePolicies
+ , input_validation_policy<>
+ , mpl::true_ // Enable undo
+ >
+ Maze;
+ //]
+
+ //[example__maze__object
+ Maze
+ maze(
+ builder
+ , maze_policies
+ , _source_state = 0
+ , _undo_limit = num_vertices(g)
+ );
+ //]
+
+ //[example__maze__run
+ int input;
+
+ while (
+ !fusion::at_key<single_final_state_policy<> >(maze.get_observer_map())
+ )
+ {
+ print_graph(g);
+ std::cout << std::endl;
+ std::cout << "Enter next room (or negative integer to undo):";
+ std::cout << std::endl;
+
+ if (!(std::cin >> input))
+ {
+ std::cout << "Go bye-bye." << std::endl;
+ return 0;
+ }
+
+ if (input < 0)
+ {
+ maze.undo();
+ }
+ else
+ {
+ maze(input);
+ }
+ }
+
+ std::cout << "You have solved the maze. JOB WELL DONE!" << std::endl;
+ return 0;
+}
+//]
+

Added: sandbox/automata/libs/automata/example/maze.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/maze.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,126 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef LIBS_AUTOMATA_EXAMPLE_MAZE_HPP_INCLUDED
+#define LIBS_AUTOMATA_EXAMPLE_MAZE_HPP_INCLUDED
+
+#include <vector>
+#include <iterator>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/random/variate_generator.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <boost/property_map/property_map.hpp>
+#include <boost/graph/properties.hpp>
+#include <boost/graph/graph_traits.hpp>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/kruskal_min_spanning_tree.hpp>
+
+//[example__make_maze__rng
+template <typename Graph>
+void make_maze(Graph& g)
+{
+ boost::mt19937
+ rng_engine;
+ boost::uniform_int<std::size_t>
+ weight_range(1, 16384);
+ boost::variate_generator<boost::mt19937&,boost::uniform_int<std::size_t> >
+ random_weight(rng_engine, weight_range);
+ //]
+
+ //[example__make_maze__util_type
+ typedef boost::adjacency_list<
+ boost::vecS
+ , boost::vecS // Let the vertex_index_t property map be built-in.
+ , boost::undirectedS
+ , boost::no_property
+ , boost::property<boost::edge_weight_t,std::size_t>
+ >
+ UtilityGraph;
+ //]
+
+ //[example__make_maze__util_graph
+ UtilityGraph u_g(30);
+ boost::graph_traits<UtilityGraph>::edge_descriptor e;
+ bool b;
+
+ for (std::size_t r = 0; r < 30; r += 5)
+ {
+ for (std::size_t c = r + 4; r < c; --c)
+ {
+ boost::tie(e, b)
+ = boost::add_edge(
+ boost::vertex(c, u_g)
+ , boost::vertex(c - 1, u_g)
+ , u_g
+ );
+
+ if (b)
+ {
+ boost::put(
+ boost::get(boost::edge_weight, u_g)
+ , e
+ , random_weight()
+ );
+ }
+ }
+ }
+
+ for (std::size_t i = 0; i < 25; ++i)
+ {
+ boost::tie(e, b)
+ = boost::add_edge(
+ boost::vertex(i, u_g)
+ , boost::vertex(i + 5, u_g)
+ , u_g
+ );
+
+ if (b)
+ {
+ boost::put(
+ boost::get(boost::edge_weight, u_g)
+ , e
+ , random_weight()
+ );
+ }
+ }
+ //]
+
+ //[example__make_maze__do_it
+ std::vector<boost::graph_traits<UtilityGraph>::edge_descriptor> edges;
+ boost::kruskal_minimum_spanning_tree(u_g, std::back_inserter(edges));
+ //]
+
+ //[example__make_maze__finish
+ for (std::size_t i = 0; i < 30; ++i)
+ {
+ boost::add_vertex(g);
+ }
+
+ for (std::size_t i = 0; i < edges.size(); ++i)
+ {
+ boost::add_edge(
+ boost::vertex(
+ boost::get(
+ boost::get(boost::vertex_index, u_g)
+ , boost::source(edges[i], u_g)
+ )
+ , g
+ )
+ , boost::vertex(
+ boost::get(
+ boost::get(boost::vertex_index, u_g)
+ , boost::target(edges[i], u_g)
+ )
+ , g
+ )
+ , g
+ );
+ }
+}
+//]
+
+#endif // LIBS_AUTOMATA_EXAMPLE_MAZE_HPP_INCLUDED
+

Added: sandbox/automata/libs/automata/example/neural_network.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/neural_network.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,86 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iostream>
+#include <utility>
+#include <vector>
+#include <boost/array.hpp>
+#include <boost/foreach.hpp>
+#include <boost/fusion/container/list.hpp>
+#include <boost/automata/automaton.hpp>
+#include "neural_network_generator.hpp"
+#include "neural_network_trans_func.hpp"
+#include "neural_network_make_samples.hpp"
+#include "neural_network_builder.hpp"
+#include "neural_network_policy.hpp"
+
+//[example__neural_network__type_definitions
+using namespace boost;
+using namespace automata;
+using namespace example;
+
+int main()
+{
+ typedef array<char const*,neural_network_transition_function::state_count>
+ States;
+ typedef array<char const*,neural_network_transition_function::input_count>
+ InputNames;
+ typedef neural_network_insertion_policy<std::ostream,States,InputNames>
+ OutputStreamPolicy;
+ typedef fusion::list<OutputStreamPolicy>
+ NeuralNetworkPolicies;
+ typedef automaton<
+ neural_network_generator
+ , neural_network_transition_function
+ , NeuralNetworkPolicies
+ >
+ NeuralNetwork;
+ typedef std::vector<std::vector<double> >
+ Inputs;
+ typedef std::vector<NeuralNetwork::traits::output>
+ Outputs;
+ typedef neural_network_builder<Inputs,Outputs>
+ Builder;
+ //]
+
+ //[example__neural_network__inputs_outputs
+ Inputs inputs;
+ Outputs outputs;
+
+ make_samples(inputs, outputs);
+ //]
+
+ //[example__neural_network__automaton
+ States
+ states = {{"Hunt", "Run", "Wander", "Hide"}};
+ InputNames
+ input_names = {{"Health", "Has Knife", "Has Gun", "Bear Count"}};
+ NeuralNetwork
+ neural_network(
+ Builder(inputs, outputs, 100000, 0.2)
+ , NeuralNetworkPolicies(
+ OutputStreamPolicy(
+ std::cout
+ , states
+ , input_names
+ , "%1% vote = %2%"
+ , "%1% = %2%"
+ , "%1%.\n %2%.\n Current action = %3%."
+ , ", "
+ )
+ )
+ );
+ //]
+
+ //[example__neural_network__run
+ BOOST_FOREACH(std::vector<double> const& i, inputs)
+ {
+ neural_network(i);
+ }
+
+ return 0;
+}
+//]
+

Added: sandbox/automata/libs/automata/example/neural_network_builder.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/neural_network_builder.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,57 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef LIBS_AUTOMATA_EXAMPLE_NEURAL_NETWORK_BUILDER_HPP_INCLUDED
+#define LIBS_AUTOMATA_EXAMPLE_NEURAL_NETWORK_BUILDER_HPP_INCLUDED
+
+#include <vector>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+//[example__neural_network_builder__fwd_decl
+namespace example {
+
+ struct neural_network_transition_function_tag;
+ //]
+
+ //[example__neural_network_builder
+ template <typename Inputs, typename Outputs>
+ class neural_network_builder
+ {
+ Inputs const& _inputs;
+ Outputs const& _outputs;
+ double const _learning_rate;
+ std::size_t const _sample_count;
+
+ public:
+ neural_network_builder(
+ Inputs const& inputs
+ , Outputs const& outputs
+ , std::size_t const sample_count
+ , double const learning_rate
+ ) : _inputs(inputs)
+ , _outputs(outputs)
+ , _learning_rate(learning_rate)
+ , _sample_count(sample_count)
+ {
+ }
+
+ template <typename Function>
+ void operator()(Function& function) const
+ {
+ BOOST_STATIC_ASSERT((
+ boost::is_same<
+ typename Function::tag
+ , neural_network_transition_function_tag
+ >::value
+ ));
+ function.reset(_inputs, _outputs, _sample_count, _learning_rate);
+ }
+ };
+} // namespace example
+//]
+
+#endif // LIBS_AUTOMATA_EXAMPLE_NEURAL_NETWORK_BUILDER_HPP_INCLUDED
+

Added: sandbox/automata/libs/automata/example/neural_network_generator.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/neural_network_generator.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,119 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef LIBS_AUTOMATA_EXAMPLE_NEURAL_NETWORK_GENERATOR_HPP_INCLUDED
+#define LIBS_AUTOMATA_EXAMPLE_NEURAL_NETWORK_GENERATOR_HPP_INCLUDED
+
+#include <algorithm>
+#include <boost/concept_check.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/range.hpp>
+#include <boost/automata/tags/base.hpp>
+#include <boost/automata/concept_check.hpp>
+
+//[example__neural_network_generator__preamble
+namespace example {
+
+ struct neural_network_generator
+ {
+ template <typename Function>
+ struct apply
+ {
+ //]
+ //[example__neural_network_generator__concept_check
+ BOOST_CONCEPT_ASSERT((
+ boost::RandomAccessContainer<typename Function::input>
+ ));
+ BOOST_CONCEPT_ASSERT((
+ boost::Sequence<typename Function::input>
+ ));
+ BOOST_CONCEPT_ASSERT((
+ boost::automata::ConstrainedInputTransitionFunction<
+ Function
+ , typename Function::input
+ >
+ ));
+ BOOST_CONCEPT_ASSERT((
+ boost::automata::StateRegisterTransitionFunction<Function>
+ ));
+ //]
+
+ //[example__neural_network_generator__typedefs
+ class type
+ {
+ protected:
+ typedef boost::automata::automaton_base_tag tag;
+
+ struct traits
+ {
+ typedef typename Function::output output;
+ };
+ //]
+
+ //[example__neural_network_generator__private
+ private:
+ BOOST_STATIC_ASSERT((
+ boost::is_same<
+ typename Function::input
+ , typename traits::output
+ >::value
+ ));
+ BOOST_STATIC_ASSERT((
+ boost::is_same<
+ typename traits::output::value_type
+ , double
+ >::value
+ ));
+
+ typename traits::output _current_output;
+ //]
+
+ //[example__neural_network_generator__ctors
+ protected:
+ type() : _current_output(Function::state_count)
+ {
+ }
+ //]
+
+ //[example__neural_network_generator__input_start
+ bool
+ process_input_impl(
+ Function const& function
+ , typename Function::state& current_state
+ , typename Function::input const& in
+ )
+ {
+ function.feed_forward(in, _current_output);
+ //]
+ //[example__neural_network_generator__input_max
+ current_state = std::distance(
+ boost::begin(_current_output)
+ , std::max_element(
+ boost::begin(_current_output)
+ , boost::end(_current_output)
+ )
+ );
+ //]
+ //[example__neural_network_generator__input_return
+ return true;
+ }
+ //]
+
+ //[example__neural_network_generator__accessors
+ public:
+ inline typename traits::output const&
+ get_current_output() const
+ {
+ return _current_output;
+ }
+ };
+ };
+ };
+} // namespace example
+//]
+
+#endif // LIBS_AUTOMATA_EXAMPLE_NEURAL_NETWORK_GENERATOR_HPP_INCLUDED
+

Added: sandbox/automata/libs/automata/example/neural_network_make_samples.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/neural_network_make_samples.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,103 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef LIBS_AUTOMATA_EXAMPLE_NEURAL_NETWORK_BUILD_SAMPLES_HPP_INCLUDED
+#define LIBS_AUTOMATA_EXAMPLE_NEURAL_NETWORK_BUILD_SAMPLES_HPP_INCLUDED
+
+#include "neural_network_trans_func.hpp"
+
+//[example__neural_network_make_samples
+namespace example {
+
+ template <typename Inputs, typename Outputs>
+ void make_samples(Inputs& inputs, Outputs& outputs)
+ {
+ neural_network_transition_function::input
+ in(neural_network_transition_function::input_count);
+ neural_network_transition_function::output
+ out(neural_network_transition_function::state_count);
+
+ in[0] = 2.0; in[1] = 0.0; in[2] = 0.0; in[3] = 0.0;
+ out[0] = 0.0; out[1] = 0.0; out[2] = 1.0; out[3] = 0.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 2.0; in[1] = 0.0; in[2] = 0.0; in[3] = 1.0;
+ out[0] = 0.0; out[1] = 0.0; out[2] = 1.0; out[3] = 0.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+
+ // More samples pushed back ...
+ //<-
+ in[0] = 2.0; in[1] = 0.0; in[2] = 1.0; in[3] = 1.0;
+ out[0] = 1.0; out[1] = 0.0; out[2] = 0.0; out[3] = 0.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 2.0; in[1] = 0.0; in[2] = 1.0; in[3] = 2.0;
+ out[0] = 1.0; out[1] = 0.0; out[2] = 0.0; out[3] = 0.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 2.0; in[1] = 1.0; in[2] = 0.0; in[3] = 2.0;
+ out[0] = 0.0; out[1] = 0.0; out[2] = 0.0; out[3] = 1.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 2.0; in[1] = 1.0; in[2] = 0.0; in[3] = 1.0;
+ out[0] = 1.0; out[1] = 0.0; out[2] = 0.0; out[3] = 0.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 1.0; in[1] = 0.0; in[2] = 0.0; in[3] = 0.0;
+ out[0] = 0.0; out[1] = 0.0; out[2] = 1.0; out[3] = 0.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 1.0; in[1] = 0.0; in[2] = 0.0; in[3] = 1.0;
+ out[0] = 0.0; out[1] = 0.0; out[2] = 0.0; out[3] = 1.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 1.0; in[1] = 0.0; in[2] = 1.0; in[3] = 1.0;
+ out[0] = 1.0; out[1] = 0.0; out[2] = 0.0; out[3] = 0.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 1.0; in[1] = 0.0; in[2] = 1.0; in[3] = 2.0;
+ out[0] = 0.0; out[1] = 0.0; out[2] = 0.0; out[3] = 1.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 1.0; in[1] = 1.0; in[2] = 0.0; in[3] = 2.0;
+ out[0] = 0.0; out[1] = 0.0; out[2] = 0.0; out[3] = 1.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 1.0; in[1] = 1.0; in[2] = 0.0; in[3] = 1.0;
+ out[0] = 0.0; out[1] = 0.0; out[2] = 0.0; out[3] = 1.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 0.0; in[1] = 0.0; in[2] = 0.0; in[3] = 0.0;
+ out[0] = 0.0; out[1] = 0.0; out[2] = 1.0; out[3] = 0.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 0.0; in[1] = 0.0; in[2] = 0.0; in[3] = 1.0;
+ out[0] = 0.0; out[1] = 0.0; out[2] = 0.0; out[3] = 1.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 0.0; in[1] = 0.0; in[2] = 1.0; in[3] = 1.0;
+ out[0] = 0.0; out[1] = 0.0; out[2] = 0.0; out[3] = 1.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 0.0; in[1] = 0.0; in[2] = 1.0; in[3] = 2.0;
+ out[0] = 0.0; out[1] = 1.0; out[2] = 0.0; out[3] = 0.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 0.0; in[1] = 1.0; in[2] = 0.0; in[3] = 2.0;
+ out[0] = 0.0; out[1] = 1.0; out[2] = 0.0; out[3] = 0.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ in[0] = 0.0; in[1] = 1.0; in[2] = 0.0; in[3] = 1.0;
+ out[0] = 0.0; out[1] = 0.0; out[2] = 0.0; out[3] = 1.0;
+ inputs.push_back(in);
+ outputs.push_back(out);
+ //->
+ }
+} // namespace example
+//]
+
+#endif // build_samples
+

Added: sandbox/automata/libs/automata/example/neural_network_policy.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/neural_network_policy.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,178 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef LIBS_AUTOMATA_EXAMPLE_NEURAL_NETWORK_POLICY_HPP_INCLUDED
+#define LIBS_AUTOMATA_EXAMPLE_NEURAL_NETWORK_POLICY_HPP_INCLUDED
+
+#include <vector>
+#include <iosfwd>
+#include <sstream>
+#include <boost/format.hpp>
+#include <boost/automata/observer/full_noop.hpp>
+
+//[example__neural_network_policy
+namespace example {
+
+ template <
+ typename InsertionTarget
+ , typename States
+ , typename InputNames
+ , typename CharT = char
+ >
+ class neural_network_insertion_policy
+ {
+ InsertionTarget& _target;
+ States _states;
+ InputNames _input_names;
+ boost::basic_format<CharT> _states_format_string;
+ boost::basic_format<CharT> _inputs_format_string;
+ boost::basic_format<CharT> _nn_format_string;
+ CharT const* _element_delimiter;
+ //]
+
+ public:
+ neural_network_insertion_policy(
+ InsertionTarget& target
+ , States const& states
+ , InputNames const& input_names
+ , CharT const* states_format_string
+ , CharT const* inputs_format_string
+ , CharT const* nn_format_string
+ , CharT const* element_delimiter
+ ) : _target(target)
+ , _states(states)
+ , _input_names(input_names)
+ , _states_format_string(states_format_string)
+ , _inputs_format_string(inputs_format_string)
+ , _nn_format_string(nn_format_string)
+ , _element_delimiter(element_delimiter)
+ {
+ }
+
+ neural_network_insertion_policy(
+ neural_network_insertion_policy const& copy
+ ) : _target(copy._target)
+ , _states(copy._states)
+ , _input_names(copy._input_names)
+ , _states_format_string(copy._states_format_string)
+ , _inputs_format_string(copy._inputs_format_string)
+ , _nn_format_string(copy._nn_format_string)
+ , _element_delimiter(copy._element_delimiter)
+ {
+ }
+
+ //[example__neural_network_policy__output_helper
+ private:
+ template <typename SubjectAutomaton, typename Input>
+ void
+ _output(
+ SubjectAutomaton const& subject_automaton
+ , Input const& in
+ )
+ {
+ std::basic_ostringstream<CharT> inputs_stream;
+
+ for (std::size_t i = 0; i < in.size(); ++i)
+ {
+ if (i)
+ {
+ inputs_stream << _element_delimiter;
+ }
+
+ inputs_stream << (
+ _inputs_format_string
+ % _input_names[i]
+ % in[i]
+ );
+ }
+
+ std::basic_ostringstream<CharT> state_stream;
+ typename SubjectAutomaton::traits::output const&
+ output = subject_automaton.get_current_output();
+
+ for (std::size_t i = 0; i < output.size(); ++i)
+ {
+ if (i)
+ {
+ state_stream << _element_delimiter;
+ }
+
+ state_stream << _states_format_string % _states[i] % output[i];
+ }
+
+ _target << (
+ _nn_format_string
+ % inputs_stream.str().c_str()
+ % state_stream.str().c_str()
+ % _states[subject_automaton.get_current_state()]
+ ) << std::endl;
+ }
+ //]
+
+ //[example__neural_network_policy__return_type
+ public:
+ template <typename SubjectAutomaton>
+ struct apply
+ {
+ class type
+ : public boost::automata::full_noop_observer<SubjectAutomaton>
+ {
+ neural_network_insertion_policy _policy;
+ //]
+
+ //[example__neural_network_policy__return_type__subject_ctor
+ public:
+ type(
+ neural_network_insertion_policy const& policy
+ , SubjectAutomaton const& automaton
+ ) : boost::automata::full_noop_observer<SubjectAutomaton>(
+ automaton
+ )
+ , _policy(policy)
+ {
+ }
+ //]
+
+ //[example__neural_network_policy__return_type__subject_copy
+ type(type const& copy, SubjectAutomaton const& automaton)
+ : boost::automata::full_noop_observer<SubjectAutomaton>(
+ automaton
+ )
+ , _policy(copy._policy)
+ {
+ }
+ //]
+
+ //[example__neural_network_policy__return_type__copy_ctor
+ type(type const& copy)
+ : boost::automata::full_noop_observer<SubjectAutomaton>(
+ copy.get_subject_automaton()
+ )
+ , _policy(copy._policy)
+ {
+ }
+ //]
+
+ //[example__neural_network_policy__return_type__assign_op
+ type& operator=(type const& copy)
+ {
+ return *this;
+ }
+ //]
+
+ //[example__neural_network_policy__return_type__on_accept
+ template <typename Input>
+ void on_accept_input(Input const& in)
+ {
+ _policy._output(this->get_subject_automaton(), in);
+ }
+ };
+ };
+ };
+} // namespace example
+//]
+
+#endif // LIBS_AUTOMATA_EXAMPLE_NEURAL_NETWORK_POLICY_HPP_INCLUDED
+

Added: sandbox/automata/libs/automata/example/neural_network_trans_func.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/neural_network_trans_func.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,325 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef LIBS_AUTOMATA_EXAMPLE_NEURAL_NETWORK_TRANS_FUNC_HPP_INCLUDED
+#define LIBS_AUTOMATA_EXAMPLE_NEURAL_NETWORK_TRANS_FUNC_HPP_INCLUDED
+
+#include <ctime>
+#include <cmath>
+#include <vector>
+#include <algorithm>
+#include <boost/tr1/random.hpp>
+#include <boost/range/iterator.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/automata/tags/transition_function.hpp>
+
+//[example__neural_network_trans_func__tag
+namespace example {
+
+ struct neural_network_transition_function_tag
+ : boost::automata::constrained_input_transition_function_tag
+ , boost::automata::state_register_transition_function_tag
+ {
+ };
+ //]
+
+ //[example__neural_network_trans_func__class
+ class neural_network_transition_function
+ {
+ typedef boost::numeric::ublas::matrix<double> Weights;
+
+ public:
+ typedef neural_network_transition_function_tag tag;
+ typedef std::vector<double> input;
+ typedef input output;
+ typedef std::size_t state;
+
+ BOOST_STATIC_CONSTANT(unsigned long, input_count = 4);
+ BOOST_STATIC_CONSTANT(unsigned long, hidden_neuron_count = 3);
+ BOOST_STATIC_CONSTANT(unsigned long, state_count = 4);
+
+ private:
+ Weights _weights_input2hidden;
+ Weights _weights_hidden2output;
+ input _bias_1;
+ input _bias_2;
+ //]
+
+ //[example__neural_network_trans_func__ctor
+ public:
+ neural_network_transition_function()
+ : _weights_input2hidden(input_count, hidden_neuron_count)
+ , _weights_hidden2output(hidden_neuron_count, state_count)
+ , _bias_1(hidden_neuron_count)
+ , _bias_2(state_count)
+ {
+ }
+ //]
+
+ //[example__neural_network_trans_func__recognize
+ bool recognizes_input(input const& in) const
+ {
+ for (std::size_t i = 0; i < in.size(); ++i)
+ {
+ if (in[i] < 0.0)
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ inline bool recognizes_state(state const& s) const
+ {
+ return s < 4;
+ }
+
+ inline std::size_t get_state_count() const
+ {
+ return state_count;
+ }
+ //]
+
+ //[example__neural_network_trans_func__feed_forward_helpers
+ private:
+ static double _calculate_sigmoid(double const value)
+ {
+ using namespace std;
+ return 1.0 / (1.0 + exp(-value));
+ }
+
+ static double _calculate_sigmoid_derivative(double const value)
+ {
+ return value * (1.0 - value);
+ }
+ //]
+
+ //[example__neural_network_trans_func__feed_forward
+ template <typename Input, typename Bias, typename Output>
+ static void
+ _feed_forward(
+ Input const& dendrites
+ , Weights const& weights
+ , Bias const& bias
+ , Output& axons
+ )
+ {
+ for (std::size_t j = 0; j < axons.size(); ++j)
+ {
+ axons[j] = bias[j];
+
+ for (std::size_t i = 0; i < dendrites.size(); ++i)
+ {
+ axons[j] += dendrites[i] * weights(i, j);
+ }
+
+ axons[j] = _calculate_sigmoid(axons[j]);
+ }
+ }
+
+ public:
+ void feed_forward(input const& in, output& out) const
+ {
+ input hidden_layer(hidden_neuron_count);
+
+ _feed_forward(in, _weights_input2hidden, _bias_1, hidden_layer);
+ _feed_forward(hidden_layer, _weights_hidden2output, _bias_2, out);
+ }
+ //]
+
+ //[example__neural_network_trans_func__reset_helper
+ private:
+ template <typename Input, typename Output, typename Bias>
+ static void
+ _back_propagate(
+ Input const& dendrons
+ , Output const& error
+ , double const learning_rate
+ , Weights& weights
+ , Bias& bias
+ )
+ {
+ for (std::size_t j = 0; j < bias.size(); ++j)
+ {
+ for (std::size_t i = 0; i < dendrons.size(); ++i)
+ {
+ weights(i, j) += learning_rate * error[j] * dendrons[i];
+ }
+
+ bias[j] += learning_rate * error[j];
+ }
+ }
+ //]
+
+ //[example__neural_network_trans_func__reset
+ public:
+ template <typename Inputs, typename Outputs>
+ void
+ reset(
+ Inputs const& inputs
+ , Outputs const& outputs
+ , std::size_t sample_count
+ , double const learning_rate
+ )
+ {
+ //]
+ //[example__neural_network_trans_func__reset__init_rand_weights
+ typedef std::tr1::mt19937
+ RNGEngine;
+ typedef std::tr1::uniform_real<double>
+ RandomDistribution;
+ typedef std::tr1::variate_generator<RNGEngine,RandomDistribution>
+ RandomValue;
+
+ RNGEngine
+ rng_engine;
+ RandomValue
+ random_value(rng_engine, RandomDistribution(-0.5, 0.5));
+
+ using std::time;
+ rng_engine.seed(static_cast<unsigned int>(time(0)));
+
+ typename boost::range_iterator<typename Weights::array_type>::type
+ weight_itr = boost::begin(_weights_input2hidden.data());
+ typename boost::range_iterator<typename Weights::array_type>::type
+ weight_end = boost::end(_weights_input2hidden.data());
+
+ while (weight_itr != weight_end)
+ {
+ *weight_itr = random_value();
+ ++weight_itr;
+ }
+
+ typename input::iterator bias_itr = _bias_2.begin();
+ typename input::iterator bias_end = _bias_2.end();
+
+ while (bias_itr != bias_end)
+ {
+ *bias_itr = random_value();
+ ++bias_itr;
+ }
+
+ // Initalize more weightes and biases...
+ //]
+
+ weight_end = boost::end(_weights_hidden2output.data());
+
+ for (
+ weight_itr = boost::begin(_weights_hidden2output.data());
+ weight_itr != weight_end;
+ ++weight_itr
+ )
+ {
+ *weight_itr = random_value();
+ }
+
+ bias_end = _bias_1.end();
+
+ for (bias_itr = _bias_1.begin(); bias_itr != bias_end; ++bias_itr)
+ {
+ *bias_itr = random_value();
+ }
+
+ //[example__neural_network_trans_func__reset__init_outputs_errors
+ input hidden_layer(hidden_neuron_count);
+ output actual_output(state_count);
+ output output_error(state_count);
+ input hidden_layer_error(hidden_neuron_count);
+
+ typename boost::range_const_iterator<Inputs>::type const
+ inputs_begin = boost::begin(inputs);
+ typename boost::range_const_iterator<Inputs>::type const
+ inputs_end = boost::end(inputs);
+ typename boost::range_const_iterator<Outputs>::type const
+ outputs_begin = boost::begin(outputs);
+ typename boost::range_const_iterator<Inputs>::type
+ inputs_itr = inputs_begin;
+ typename boost::range_const_iterator<Outputs>::type
+ outputs_itr = outputs_begin;
+ //]
+
+ //[example__neural_network_trans_func__reset__start_cycle
+ while (sample_count)
+ {
+ input const& in = *inputs_itr;
+
+ _feed_forward(
+ in
+ , _weights_input2hidden
+ , _bias_1
+ , hidden_layer
+ );
+ _feed_forward(
+ hidden_layer
+ , _weights_hidden2output
+ , _bias_2
+ , actual_output
+ );
+ //]
+
+ //[example__neural_network_trans_func__reset__back_propagate
+ output const& target_output = *outputs_itr;
+
+ for (std::size_t i = 0; i < output_error.size(); ++i)
+ {
+ output_error[i]
+ = (target_output[i] - actual_output[i])
+ * _calculate_sigmoid_derivative(actual_output[i]);
+ }
+
+ for (std::size_t i = 0; i < hidden_layer_error.size(); ++i)
+ {
+ hidden_layer_error[i] = 0.0;
+
+ for (std::size_t j = 0; j < output_error.size(); ++j)
+ {
+ hidden_layer_error[i]
+ += output_error[j]
+ * _weights_hidden2output(i, j);
+ }
+
+ hidden_layer_error[i]
+ *= _calculate_sigmoid_derivative(hidden_layer[i]);
+ }
+
+ _back_propagate(
+ hidden_layer
+ , output_error
+ , learning_rate
+ , _weights_hidden2output
+ , _bias_2
+ );
+ _back_propagate(
+ in
+ , hidden_layer_error
+ , learning_rate
+ , _weights_input2hidden
+ , _bias_1
+ );
+ //]
+
+ //[example__neural_network_trans_func__reset__end_cycle
+ if (++inputs_itr == inputs_end)
+ {
+ inputs_itr = inputs_begin;
+ outputs_itr = outputs_begin;
+ }
+ else
+ {
+ ++outputs_itr;
+ }
+
+ --sample_count;
+ }
+ }
+ };
+} // namespace example
+//]
+
+#endif // LIBS_AUTOMATA_EXAMPLE_NEURAL_NETWORK_TRANS_FUNC_HPP_INCLUDED
+

Added: sandbox/automata/libs/automata/example/wireworld.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/example/wireworld.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,214 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_PARAMETER_MAX_ARITY 11
+
+#include <iostream>
+#include <boost/tr1/tuple.hpp>
+#include <boost/array.hpp>
+#include <boost/gil/utilities.hpp>
+#include <boost/fusion/container/list/cons.hpp>
+#include <boost/property_map/property_map.hpp>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/graph_selectors.hpp>
+#include <boost/graph/graph_traits.hpp>
+#include <boost/graph/properties.hpp>
+#include <boost/graph/vertex_property_map_gen.hpp>
+#include <boost/graph/basic_vert_insert_iterator.hpp>
+#include <boost/graph/basic_add_edge_function.hpp>
+#include <boost/graph/set_orthogonal_grid_layout.hpp>
+#include <boost/automata/generator/deterministic.hpp>
+#include <boost/automata/transition_function/totalistic_dt_cell.hpp>
+#include <boost/automata/transition_function/input_rule.hpp>
+#include <boost/automata/input_rule/cellular_graph.hpp>
+#include <boost/automata/policy/moore_output.hpp>
+#include <boost/automata/automaton.hpp>
+
+//[example__wireworld__cell_function
+typedef boost::automata::totalistic_dt_cell_transition_function<unsigned char>
+ CellFunction;
+
+void build_function(CellFunction& function)
+{
+ function.add_transitions('S')
+ ('S', 'o')['+']
+ ('S', '+')[' ']
+ ('S', ' ')('o', 1)['o']
+ ('S', ' ')('o', 2)['o']
+ ;
+}
+//]
+
+//[example__wireworld__more_typedefs
+typedef boost::adjacency_list<boost::multisetS,boost::listS,boost::undirectedS>
+ Graph;
+typedef boost::automata::automaton<
+ boost::automata::deterministic_generator
+ , CellFunction
+ >
+ Cell;
+typedef boost::vertex_property_map_gen<Graph,Cell>::type
+ CellMap;
+//]
+
+//[example__wireworld__program
+class wireworld_program
+{
+ static const std::size_t dim_size = 10;
+
+ Graph graph;
+ boost::automata::cellular_graph_input_rule<Graph> rule;
+
+ wireworld_program() : graph(), rule(graph)
+ {
+ boost::set_orthogonal_grid_layout(
+ boost::basic_vertex_inserter(graph)
+ , boost::basic_2way_edge_adder(graph)
+ , boost::gil::point2<int>(dim_size, dim_size)
+ , boost::graph::keywords::_is_zeta = true
+ );
+ }
+
+ wireworld_program(wireworld_program const& copy);
+ wireworld_program& operator=(wireworld_program const& copy);
+ ~wireworld_program() {}
+
+ public:
+ static wireworld_program const& get_instance()
+ {
+ static wireworld_program instance;
+ return instance;
+ }
+ //]
+
+ //[example__wireworld__build_cells
+ void build_cells(CellMap& cell_map) const
+ {
+ boost::graph_traits<Graph>::vertex_iterator vi, vi_end;
+ int i = 0;
+
+ for (
+ std::tr1::tie(vi, vi_end) = boost::vertices(graph);
+ vi != vi_end;
+ ++vi
+ )
+ {
+ boost::put(
+ cell_map
+ , *vi
+ , Cell(
+ build_function
+ , (
+ (
+ (i == dim_size + 4)
+ || (i == dim_size + 5)
+ || (i == dim_size * 2 + 3)
+ || (i == dim_size * 2 + 4)
+ || (i == dim_size * 2 + 6)
+ || (i == dim_size * 2 + 7)
+ || (i == dim_size * 2 + 8)
+ || (i == dim_size * 3 + 4)
+ || (i == dim_size * 3 + 5)
+ || (i == dim_size * 6 + 4)
+ || (i == dim_size * 6 + 5)
+ || (i == dim_size * 7 + 3)
+ || (i == dim_size * 7 + 5)
+ || (i == dim_size * 7 + 6)
+ || (i == dim_size * 7 + 7)
+ || (i == dim_size * 7 + 8)
+ || (i == dim_size * 8 + 4)
+ || (i == dim_size * 8 + 5)
+ )
+ ? ' '
+ : (
+ (i == dim_size * 2 + 2)
+ || (i == dim_size * 7 + 2)
+ )
+ ? 'o'
+ : (
+ (i == dim_size * 2 + 1)
+ || (i == dim_size * 7 + 1)
+ )
+ ? '+'
+ : '0'
+ )
+ )
+ );
+ ++i;
+ }
+ }
+
+ struct cell_builder
+ {
+ typedef CellMap argument_type;
+ typedef void result_type;
+
+ result_type operator()(argument_type& cell_map) const
+ {
+ wireworld_program::get_instance().build_cells(cell_map);
+ }
+ };
+ //]
+
+ //[example__wireworld__output
+ private:
+ void output(CellMap const& cell_map) const
+ {
+ boost::graph_traits<Graph>::vertex_iterator vi, vi_end;
+ std::tr1::tie(vi, vi_end) = boost::vertices(graph);
+ std::cout << std::endl;
+
+ for (std::size_t y = 0; y < dim_size; ++y)
+ {
+ for (std::size_t x = 0; x < dim_size; ++x)
+ {
+ std::cout << boost::get(cell_map, *vi).get_current_state();
+ ++vi;
+ }
+
+ std::cout << std::endl;
+ }
+ }
+
+ struct output_cells
+ {
+ template <typename SubjectAutomaton>
+ void operator()(SubjectAutomaton const& automaton) const
+ {
+ wireworld_program::get_instance().output(
+ automaton.get_current_state()
+ );
+ }
+ };
+ //]
+
+ //[example__wireworld__run
+ public:
+ void run() const
+ {
+ CellMap start(graph);
+ boost::automata::automaton<
+ boost::automata::deterministic_generator
+ , boost::automata::input_rule_transition_function<CellMap,true>
+ , boost::fusion::cons<
+ boost::automata::moore_output_policy<output_cells>
+ >
+ > wireworld(cell_builder(), start);
+ std::size_t iteration_count = dim_size - 2;
+
+ for (std::size_t i = 0; i < iteration_count; ++i)
+ {
+ wireworld(rule);
+ }
+ }
+};
+
+int main()
+{
+ wireworld_program::get_instance().run();
+ return 0;
+}
+//]
+

Added: sandbox/automata/libs/automata/index.html
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/index.html 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,12 @@
+<!-- Copyright David Abrahams 2005. Distributed under the Boost -->
+<!-- Software License, Version 1.0. (See accompanying -->
+<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
+<html>
+<head>
+<meta http-equiv="refresh" content="0; URL=doc/html/index.html">
+</head>
+<body>
+Automatically loading index page... if nothing happens, please go to
+doc/html/index.html.
+</body>
+</html>

Added: sandbox/automata/libs/automata/test/basics.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/test/basics.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,59 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/automata/generator/dpda.hpp>
+#include <boost/automata/automaton.hpp>
+#include "basics.hpp"
+#include "dpda_builder.hpp"
+
+//[test__basics__case
+using namespace boost;
+using namespace automata;
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+BOOST_AUTO_TEST_CASE(basics_test)
+{
+ automaton<dpda_generator,Function> dpda(build1);
+
+ BOOST_CHECK(!accept(dpda, "aab"));
+ dpda.reset();
+ BOOST_CHECK(accept(dpda, "aabb"));
+ dpda.reset();
+ BOOST_CHECK(!accept(dpda, "aabbb"));
+ dpda.reset();
+ BOOST_CHECK(accept(dpda, "aaabbb"));
+
+ dpda.initialize(build2);
+
+ BOOST_CHECK(!accept(dpda, "x+y)"));
+ dpda.reset();
+ BOOST_CHECK(!accept(dpda, "(x+y"));
+ dpda.reset();
+ BOOST_CHECK(!accept(dpda, "xy+z"));
+ dpda.reset();
+ BOOST_CHECK(!accept(dpda, "x(y+z)"));
+ dpda.reset();
+ BOOST_CHECK(accept(dpda, "(x+y)*x-z*y/(x+x)"));
+ dpda.reset();
+ BOOST_CHECK(accept(dpda, "x/(y*(z-y)+x)"));
+
+ dpda.initialize(build3);
+
+ BOOST_CHECK(accept(dpda, "aacc"));
+ dpda.reset();
+ BOOST_CHECK(!accept(dpda, "abc"));
+ dpda.reset();
+ BOOST_CHECK(accept(dpda, "aabccc"));
+ dpda.reset();
+ BOOST_CHECK(accept(dpda, "abbccc"));
+ dpda.reset();
+ BOOST_CHECK(!accept(dpda, "abbcccc"));
+ dpda.reset();
+ BOOST_CHECK(accept(dpda, "bbbccc"));
+}
+//]
+

Added: sandbox/automata/libs/automata/test/basics.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/test/basics.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,34 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef LIBS_AUTOMATA_TEST_BASICS_HPP_INCLUDED
+#define LIBS_AUTOMATA_TEST_BASICS_HPP_INCLUDED
+
+#include <string>
+
+//[test__accept__function_template
+template <typename DPDA>
+bool accept(DPDA& dpda, std::string const& word)
+{
+ std::size_t i = 0;
+
+ while (i < word.length())
+ {
+ if (dpda(word[i]))
+ {
+ ++i;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ return dpda.has_empty_stack();
+}
+//]
+
+#endif // LIBS_AUTOMATA_TEST_BASICS_HPP_INCLUDED
+

Added: sandbox/automata/libs/automata/test/builder_from_graph.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/test/builder_from_graph.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,397 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/fusion/support/pair.hpp>
+#include <boost/fusion/container/map.hpp>
+#include <boost/property_map/property_map.hpp>
+#include <boost/graph/properties.hpp>
+#include <boost/graph/graph_traits.hpp>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/automata/generator/dpda.hpp>
+#include <boost/automata/transition_function/dpda.hpp>
+#include <boost/automata/builder/from_graph.hpp>
+#include <boost/automata/automaton.hpp>
+#include "basics.hpp"
+
+//[test__builder_from_graph__dpda_typedef
+using namespace boost;
+using namespace automata;
+
+typedef dpda_transition_function<char,char>
+ Function;
+typedef automaton<dpda_generator,Function>
+ DPDA;
+//]
+
+//[test__builder_from_graph__graph_typedef
+using namespace fusion;
+
+typedef map<
+ pair<input_symbol_key,Function::input>
+ , pair<pop_from_stack_key,Function::optional_stack_element>
+ , pair<push_to_stack_key,Function::optional_stack_element>
+ >
+ EdgeInput;
+typedef adjacency_list<
+ vecS
+ , vecS // Let the vertex_index_t property map be built-in.
+ , directedS
+ , no_property
+ , property<edge_input_t,EdgeInput>
+ >
+ Graph;
+//]
+
+//[test__builder_from_graph__builder_typedef
+typedef builder_from_graph<
+ Graph
+ , property_map<Graph,vertex_index_t>::type
+ , property_map<Graph,edge_input_t>::type
+ >
+ Builder;
+//]
+
+//[test__builder_from_graph__case0_edge_inputs
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+BOOST_AUTO_TEST_CASE(builder_from_graph_test0)
+{
+ Function::optional_stack_element
+ N;
+ Function::optional_stack_element
+ S('S');
+ EdgeInput
+ i0(
+ make_pair<input_symbol_key>('a')
+ , make_pair<pop_from_stack_key>(N)
+ , make_pair<push_to_stack_key>(S)
+ );
+ EdgeInput
+ i1(
+ make_pair<input_symbol_key>('b')
+ , make_pair<pop_from_stack_key>(S)
+ , make_pair<push_to_stack_key>(N)
+ );
+ //]
+
+ //[test__builder_from_graph__case0_graph
+ Graph g(2);
+ graph_traits<Graph>::edge_descriptor e;
+ bool b;
+
+ boost::tie(e, b) = add_edge(vertex(0, g), vertex(0, g), g);
+ if (b) put(get(edge_input, g), e, i0);
+ boost::tie(e, b) = add_edge(vertex(0, g), vertex(1, g), g);
+ if (b) put(get(edge_input, g), e, i1);
+ boost::tie(e, b) = add_edge(vertex(1, g), vertex(1, g), g);
+ if (b) put(get(edge_input, g), e, i1);
+ //]
+
+ //[test__builder_from_graph__case0_dpda
+ DPDA dpda(Builder(g, get(vertex_index, g), get(edge_input, g)));
+ //]
+
+ //[test__builder_from_graph__case0_run
+ BOOST_CHECK(!accept(dpda, "aab"));
+ dpda.reset();
+ BOOST_CHECK(accept(dpda, "aabb"));
+ dpda.reset();
+ BOOST_CHECK(!accept(dpda, "aabbb"));
+ dpda.reset();
+ BOOST_CHECK(accept(dpda, "aaabbb"));
+}
+//]
+
+//[test__builder_from_graph__case1
+BOOST_AUTO_TEST_CASE(builder_from_graph_test1)
+{
+ Function::optional_stack_element N;
+ Function::optional_stack_element S('S');
+ Function::optional_stack_element A('A');
+ Graph g(2);
+ graph_traits<Graph>::edge_descriptor e;
+ bool b;
+
+ boost::tie(e, b) = add_edge(vertex(0, g), vertex(0, g), g);
+
+ if (b)
+ {
+ put(
+ get(edge_input, g)
+ , e
+ , EdgeInput(
+ make_pair<input_symbol_key>('(')
+ , make_pair<pop_from_stack_key>(N)
+ , make_pair<push_to_stack_key>(S)
+ )
+ );
+ }
+
+ boost::tie(e, b) = add_edge(vertex(0, g), vertex(0, g), g);
+
+ if (b)
+ {
+ put(
+ get(edge_input, g)
+ , e
+ , EdgeInput(
+ make_pair<input_symbol_key>('(')
+ , make_pair<pop_from_stack_key>(A)
+ , make_pair<push_to_stack_key>(S)
+ )
+ );
+ }
+
+ boost::tie(e, b) = add_edge(vertex(0, g), vertex(1, g), g);
+
+ if (b)
+ {
+ put(
+ get(edge_input, g)
+ , e
+ , EdgeInput(
+ make_pair<input_symbol_key>('x')
+ , make_pair<pop_from_stack_key>(N)
+ , make_pair<push_to_stack_key>(N)
+ )
+ );
+ }
+
+ boost::tie(e, b) = add_edge(vertex(0, g), vertex(1, g), g);
+
+ if (b)
+ {
+ put(
+ get(edge_input, g)
+ , e
+ , EdgeInput(
+ make_pair<input_symbol_key>('x')
+ , make_pair<pop_from_stack_key>(A)
+ , make_pair<push_to_stack_key>(N)
+ )
+ );
+ }
+
+ boost::tie(e, b) = add_edge(vertex(0, g), vertex(1, g), g);
+
+ if (b)
+ {
+ put(
+ get(edge_input, g)
+ , e
+ , EdgeInput(
+ make_pair<input_symbol_key>('y')
+ , make_pair<pop_from_stack_key>(N)
+ , make_pair<push_to_stack_key>(N)
+ )
+ );
+ }
+
+ boost::tie(e, b) = add_edge(vertex(0, g), vertex(1, g), g);
+
+ if (b)
+ {
+ put(
+ get(edge_input, g)
+ , e
+ , EdgeInput(
+ make_pair<input_symbol_key>('y')
+ , make_pair<pop_from_stack_key>(A)
+ , make_pair<push_to_stack_key>(N)
+ )
+ );
+ }
+
+ boost::tie(e, b) = add_edge(vertex(0, g), vertex(1, g), g);
+
+ if (b)
+ {
+ put(
+ get(edge_input, g)
+ , e
+ , EdgeInput(
+ make_pair<input_symbol_key>('z')
+ , make_pair<pop_from_stack_key>(N)
+ , make_pair<push_to_stack_key>(N)
+ )
+ );
+ }
+
+ boost::tie(e, b) = add_edge(vertex(0, g), vertex(1, g), g);
+
+ if (b)
+ {
+ put(
+ get(edge_input, g)
+ , e
+ , EdgeInput(
+ make_pair<input_symbol_key>('z')
+ , make_pair<pop_from_stack_key>(A)
+ , make_pair<push_to_stack_key>(N)
+ )
+ );
+ }
+
+ boost::tie(e, b) = add_edge(vertex(1, g), vertex(1, g), g);
+
+ if (b)
+ {
+ put(
+ get(edge_input, g)
+ , e
+ , EdgeInput(
+ make_pair<input_symbol_key>(')')
+ , make_pair<pop_from_stack_key>(S)
+ , make_pair<push_to_stack_key>(N)
+ )
+ );
+ }
+
+ boost::tie(e, b) = add_edge(vertex(1, g), vertex(0, g), g);
+
+ if (b)
+ {
+ put(
+ get(edge_input, g)
+ , e
+ , EdgeInput(
+ make_pair<input_symbol_key>('+')
+ , make_pair<pop_from_stack_key>(N)
+ , make_pair<push_to_stack_key>(A)
+ )
+ );
+ }
+
+ boost::tie(e, b) = add_edge(vertex(1, g), vertex(0, g), g);
+
+ if (b)
+ {
+ put(
+ get(edge_input, g)
+ , e
+ , EdgeInput(
+ make_pair<input_symbol_key>('-')
+ , make_pair<pop_from_stack_key>(N)
+ , make_pair<push_to_stack_key>(A)
+ )
+ );
+ }
+
+ boost::tie(e, b) = add_edge(vertex(1, g), vertex(0, g), g);
+
+ if (b)
+ {
+ put(
+ get(edge_input, g)
+ , e
+ , EdgeInput(
+ make_pair<input_symbol_key>('*')
+ , make_pair<pop_from_stack_key>(N)
+ , make_pair<push_to_stack_key>(A)
+ )
+ );
+ }
+
+ boost::tie(e, b) = add_edge(vertex(1, g), vertex(0, g), g);
+
+ if (b)
+ {
+ put(
+ get(edge_input, g)
+ , e
+ , EdgeInput(
+ make_pair<input_symbol_key>('/')
+ , make_pair<pop_from_stack_key>(N)
+ , make_pair<push_to_stack_key>(A)
+ )
+ );
+ }
+
+ DPDA dpda(Builder(get(edge_input, g), g, get(vertex_index, g)));
+
+ BOOST_CHECK(!accept(dpda, "x+y)"));
+ dpda.reset();
+ BOOST_CHECK(!accept(dpda, "(x+y"));
+ dpda.reset();
+ BOOST_CHECK(!accept(dpda, "xy+z"));
+ dpda.reset();
+ BOOST_CHECK(!accept(dpda, "x(y+z)"));
+ dpda.reset();
+ BOOST_CHECK(accept(dpda, "(x+y)*x-z*y/(x+x)"));
+ dpda.reset();
+ BOOST_CHECK(accept(dpda, "x/(y*(z-y)+x)"));
+}
+//]
+
+//[test__builder_from_graph__case2
+BOOST_AUTO_TEST_CASE(builder_from_graph_test2)
+{
+ Function::optional_stack_element
+ N;
+ Function::optional_stack_element
+ S('S');
+ Function::optional_stack_element
+ B('B');
+ EdgeInput
+ iaNS(
+ make_pair<input_symbol_key>('a')
+ , make_pair<pop_from_stack_key>(N)
+ , make_pair<push_to_stack_key>(S)
+ );
+ EdgeInput
+ ibNB(
+ make_pair<input_symbol_key>('b')
+ , make_pair<pop_from_stack_key>(N)
+ , make_pair<push_to_stack_key>(B)
+ );
+ EdgeInput
+ icSN(
+ make_pair<input_symbol_key>('c')
+ , make_pair<pop_from_stack_key>(S)
+ , make_pair<push_to_stack_key>(N)
+ );
+ EdgeInput
+ icBN(
+ make_pair<input_symbol_key>('c')
+ , make_pair<pop_from_stack_key>(B)
+ , make_pair<push_to_stack_key>(N)
+ );
+
+ Graph g(3);
+ graph_traits<Graph>::edge_descriptor e;
+ bool b;
+
+ boost::tie(e, b) = add_edge(vertex(0, g), vertex(0, g), g);
+ if (b) put(get(edge_input, g), e, iaNS);
+ boost::tie(e, b) = add_edge(vertex(0, g), vertex(1, g), g);
+ if (b) put(get(edge_input, g), e, ibNB);
+ boost::tie(e, b) = add_edge(vertex(0, g), vertex(2, g), g);
+ if (b) put(get(edge_input, g), e, icSN);
+ boost::tie(e, b) = add_edge(vertex(1, g), vertex(1, g), g);
+ if (b) put(get(edge_input, g), e, ibNB);
+ boost::tie(e, b) = add_edge(vertex(1, g), vertex(2, g), g);
+ if (b) put(get(edge_input, g), e, icBN);
+ boost::tie(e, b) = add_edge(vertex(2, g), vertex(2, g), g);
+ if (b) put(get(edge_input, g), e, icSN);
+ boost::tie(e, b) = add_edge(vertex(2, g), vertex(2, g), g);
+ if (b) put(get(edge_input, g), e, icBN);
+
+ DPDA dpda(Builder(get(vertex_index, g), get(edge_input, g), g));
+
+ BOOST_CHECK(accept(dpda, "aacc"));
+ dpda.reset();
+ BOOST_CHECK(!accept(dpda, "abc"));
+ dpda.reset();
+ BOOST_CHECK(accept(dpda, "aabccc"));
+ dpda.reset();
+ BOOST_CHECK(accept(dpda, "abbccc"));
+ dpda.reset();
+ BOOST_CHECK(!accept(dpda, "abbcccc"));
+ dpda.reset();
+ BOOST_CHECK(accept(dpda, "bbbccc"));
+}
+//]
+

Added: sandbox/automata/libs/automata/test/dfa.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/test/dfa.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,271 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iterator>
+#include <set>
+#include <boost/automata/generator/dfa.hpp>
+#include <boost/automata/automaton.hpp>
+#include "dfa_builder.hpp"
+
+//[test__matrix_dfa__case
+using namespace boost;
+using namespace automata;
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+BOOST_AUTO_TEST_CASE(matrix_transition_function_test)
+{
+ typedef automaton<dfa_generator,Function0> DFA0;
+
+ DFA0 dfa0(build1);
+
+ BOOST_CHECK(dfa0.get_current_state() == 0);
+ BOOST_CHECK(dfa0(0));
+ BOOST_CHECK(dfa0.get_current_state() == 1);
+ BOOST_CHECK(dfa0(2));
+ BOOST_CHECK(dfa0.get_current_state() == 0);
+ BOOST_CHECK(dfa0(1));
+ BOOST_CHECK(dfa0.get_current_state() == 1);
+ BOOST_CHECK(!dfa0(3));
+ BOOST_CHECK(dfa0.get_current_state() == 1);
+ dfa0.reset();
+ BOOST_CHECK(dfa0.get_current_state() == 0);
+
+ std::set<unsigned int> inputs_0;
+ DFA0::transition_function const& f0 = dfa0.get_transition_function();
+ std::insert_iterator<std::set<unsigned int> > itr(
+ inputs_0
+ , inputs_0.begin()
+ );
+
+ dfa0.make_nontrivial_inputs(itr);
+ BOOST_CHECK(inputs_0.size() == 3);
+ BOOST_CHECK(inputs_0.find(0) != inputs_0.end());
+ BOOST_CHECK(f0(dfa0.get_current_state(), 0) == 1);
+ BOOST_CHECK(inputs_0.find(1) != inputs_0.end());
+ BOOST_CHECK(f0(dfa0.get_current_state(), 1) == 1);
+ BOOST_CHECK(inputs_0.find(2) != inputs_0.end());
+ BOOST_CHECK(f0(dfa0.get_current_state(), 2) == 2);
+ BOOST_CHECK(inputs_0.find(3) == inputs_0.end());
+ BOOST_CHECK(f0(dfa0.get_current_state(), 3) == 0);
+ inputs_0.clear();
+ BOOST_CHECK(dfa0(0));
+ BOOST_CHECK(dfa0.get_current_state() == 1);
+
+ // . . .
+ //<-
+ dfa0.make_nontrivial_inputs(itr);
+ BOOST_CHECK(inputs_0.size() == 2);
+ BOOST_CHECK(inputs_0.find(0) == inputs_0.end());
+ BOOST_CHECK(f0(dfa0.get_current_state(), 0) == 1);
+ BOOST_CHECK(inputs_0.find(1) != inputs_0.end());
+ BOOST_CHECK(f0(dfa0.get_current_state(), 1) == 2);
+ BOOST_CHECK(inputs_0.find(2) != inputs_0.end());
+ BOOST_CHECK(f0(dfa0.get_current_state(), 2) == 0);
+ BOOST_CHECK(inputs_0.find(3) == inputs_0.end());
+ BOOST_CHECK(f0(dfa0.get_current_state(), 3) == 1);
+ inputs_0.clear();
+ BOOST_CHECK(dfa0(1));
+ BOOST_CHECK(dfa0.get_current_state() == 2);
+
+ dfa0.make_nontrivial_inputs(itr);
+ BOOST_CHECK(inputs_0.size() == 1);
+ BOOST_CHECK(inputs_0.find(0) == inputs_0.end());
+ BOOST_CHECK(f0(dfa0.get_current_state(), 0) == 2);
+ BOOST_CHECK(inputs_0.find(1) == inputs_0.end());
+ BOOST_CHECK(f0(dfa0.get_current_state(), 1) == 2);
+ BOOST_CHECK(inputs_0.find(2) == inputs_0.end());
+ BOOST_CHECK(f0(dfa0.get_current_state(), 2) == 2);
+ BOOST_CHECK(inputs_0.find(3) != inputs_0.end());
+ BOOST_CHECK(f0(dfa0.get_current_state(), 3) == 3);
+ inputs_0.clear();
+ BOOST_CHECK(dfa0(3));
+ BOOST_CHECK(dfa0.get_current_state() == 3);
+ //->
+}
+//]
+
+//[test__mapped_input_tabular_dfa__case
+BOOST_AUTO_TEST_CASE(mapped_input_tabular_transition_function_test)
+{
+ typedef automaton<dfa_generator,Function1> DFA1;
+
+ DFA1 dfa1(build2);
+
+ BOOST_CHECK(dfa1.get_current_state() == 0);
+ BOOST_CHECK(dfa1("alpha"));
+ BOOST_CHECK(dfa1.get_current_state() == 1);
+ BOOST_CHECK(dfa1("gamma"));
+ BOOST_CHECK(dfa1.get_current_state() == 0);
+ BOOST_CHECK(dfa1("beta"));
+ BOOST_CHECK(dfa1.get_current_state() == 1);
+ BOOST_CHECK(!dfa1("delta"));
+ BOOST_CHECK(dfa1.get_current_state() == 1);
+ dfa1.reset();
+ BOOST_CHECK(dfa1.get_current_state() == 0);
+
+ std::set<std::string> inputs_1;
+ DFA1::transition_function const& f1 = dfa1.get_transition_function();
+ std::insert_iterator<std::set<std::string> > itr(
+ inputs_1
+ , inputs_1.begin()
+ );
+
+ dfa1.make_nontrivial_inputs(itr);
+ BOOST_CHECK(inputs_1.size() == 3);
+ BOOST_CHECK(inputs_1.find("alpha") != inputs_1.end());
+ BOOST_CHECK(f1(dfa1.get_current_state(), "alpha") == 1);
+ BOOST_CHECK(inputs_1.find("beta") != inputs_1.end());
+ BOOST_CHECK(f1(dfa1.get_current_state(), "beta") == 1);
+ BOOST_CHECK(inputs_1.find("gamma") != inputs_1.end());
+ BOOST_CHECK(f1(dfa1.get_current_state(), "gamma") == 2);
+ BOOST_CHECK(inputs_1.find("delta") == inputs_1.end());
+ BOOST_CHECK(f1(dfa1.get_current_state(), "delta") == 0);
+ inputs_1.clear();
+ BOOST_CHECK(dfa1("alpha"));
+ BOOST_CHECK(dfa1.get_current_state() == 1);
+
+ // . . .
+ //<-
+ dfa1.make_nontrivial_inputs(itr);
+ BOOST_CHECK(inputs_1.size() == 2);
+ BOOST_CHECK(inputs_1.find("alpha") == inputs_1.end());
+ BOOST_CHECK(f1(dfa1.get_current_state(), "alpha") == 1);
+ BOOST_CHECK(inputs_1.find("beta") != inputs_1.end());
+ BOOST_CHECK(f1(dfa1.get_current_state(), "beta") == 2);
+ BOOST_CHECK(inputs_1.find("gamma") != inputs_1.end());
+ BOOST_CHECK(f1(dfa1.get_current_state(), "gamma") == 0);
+ BOOST_CHECK(inputs_1.find("delta") == inputs_1.end());
+ BOOST_CHECK(f1(dfa1.get_current_state(), "delta") == 1);
+ inputs_1.clear();
+ BOOST_CHECK(dfa1("beta"));
+ BOOST_CHECK(dfa1.get_current_state() == 2);
+
+ dfa1.make_nontrivial_inputs(itr);
+ BOOST_CHECK(inputs_1.size() == 1);
+ BOOST_CHECK(inputs_1.find("alpha") == inputs_1.end());
+ BOOST_CHECK(f1(dfa1.get_current_state(), "alpha") == 2);
+ BOOST_CHECK(inputs_1.find("beta") == inputs_1.end());
+ BOOST_CHECK(f1(dfa1.get_current_state(), "beta") == 2);
+ BOOST_CHECK(inputs_1.find("gamma") == inputs_1.end());
+ BOOST_CHECK(f1(dfa1.get_current_state(), "gamma") == 2);
+ BOOST_CHECK(inputs_1.find("delta") != inputs_1.end());
+ BOOST_CHECK(f1(dfa1.get_current_state(), "delta") == 3);
+ inputs_1.clear();
+ BOOST_CHECK(dfa1("delta"));
+ BOOST_CHECK(dfa1.get_current_state() == 3);
+ //->
+}
+//]
+
+//[test__mapped_input_dfa__case
+BOOST_AUTO_TEST_CASE(mapped_input_transition_function_test)
+{
+ typedef automaton<dfa_generator,Function2> DFA2;
+
+ DFA2 dfa2(build3);
+
+ BOOST_CHECK(dfa2.get_current_state() == 0);
+ BOOST_CHECK(dfa2("alpha"));
+ BOOST_CHECK(dfa2.get_current_state() == 1);
+ BOOST_CHECK(dfa2("gamma"));
+ BOOST_CHECK(dfa2.get_current_state() == 0);
+ BOOST_CHECK(dfa2("beta"));
+ BOOST_CHECK(dfa2.get_current_state() == 1);
+ BOOST_CHECK(!dfa2("delta"));
+ BOOST_CHECK(dfa2.get_current_state() == 1);
+ dfa2.reset();
+ BOOST_CHECK(dfa2.get_current_state() == 0);
+
+ std::set<std::string> inputs_2;
+ DFA2::transition_function const& f2 = dfa2.get_transition_function();
+ std::insert_iterator<std::set<std::string> > itr(
+ inputs_2
+ , inputs_2.begin()
+ );
+
+ dfa2.make_nontrivial_inputs(itr);
+ BOOST_CHECK(inputs_2.size() == 3);
+ BOOST_CHECK(inputs_2.find("alpha") != inputs_2.end());
+ BOOST_CHECK(f2(dfa2.get_current_state(), "alpha") == 1);
+ BOOST_CHECK(inputs_2.find("beta") != inputs_2.end());
+ BOOST_CHECK(f2(dfa2.get_current_state(), "beta") == 1);
+ BOOST_CHECK(inputs_2.find("gamma") != inputs_2.end());
+ BOOST_CHECK(f2(dfa2.get_current_state(), "gamma") == 2);
+ BOOST_CHECK(inputs_2.find("delta") == inputs_2.end());
+ BOOST_CHECK(f2(dfa2.get_current_state(), "delta") == 0);
+ inputs_2.clear();
+ BOOST_CHECK(dfa2("alpha"));
+ BOOST_CHECK(dfa2.get_current_state() == 1);
+
+ // . . .
+ //<-
+ dfa2.make_nontrivial_inputs(itr);
+ BOOST_CHECK(inputs_2.size() == 2);
+ BOOST_CHECK(inputs_2.find("alpha") == inputs_2.end());
+ BOOST_CHECK(f2(dfa2.get_current_state(), "alpha") == 1);
+ BOOST_CHECK(inputs_2.find("beta") != inputs_2.end());
+ BOOST_CHECK(f2(dfa2.get_current_state(), "beta") == 2);
+ BOOST_CHECK(inputs_2.find("gamma") != inputs_2.end());
+ BOOST_CHECK(f2(dfa2.get_current_state(), "gamma") == 0);
+ BOOST_CHECK(inputs_2.find("delta") == inputs_2.end());
+ BOOST_CHECK(f2(dfa2.get_current_state(), "delta") == 1);
+ inputs_2.clear();
+ BOOST_CHECK(dfa2("beta"));
+ BOOST_CHECK(dfa2.get_current_state() == 2);
+
+ dfa2.make_nontrivial_inputs(itr);
+ BOOST_CHECK(inputs_2.size() == 1);
+ BOOST_CHECK(inputs_2.find("alpha") == inputs_2.end());
+ BOOST_CHECK(f2(dfa2.get_current_state(), "alpha") == 2);
+ BOOST_CHECK(inputs_2.find("beta") == inputs_2.end());
+ BOOST_CHECK(f2(dfa2.get_current_state(), "beta") == 2);
+ BOOST_CHECK(inputs_2.find("gamma") == inputs_2.end());
+ BOOST_CHECK(f2(dfa2.get_current_state(), "gamma") == 2);
+ BOOST_CHECK(inputs_2.find("delta") != inputs_2.end());
+ BOOST_CHECK(f2(dfa2.get_current_state(), "delta") == 3);
+ inputs_2.clear();
+ BOOST_CHECK(dfa2("delta"));
+ BOOST_CHECK(dfa2.get_current_state() == 3);
+ //->
+}
+//]
+
+//[test__next_state_dfa__case
+BOOST_AUTO_TEST_CASE(next_state_transition_function_test)
+{
+ typedef automaton<dfa_generator,Function3> DFA3;
+
+ DFA3 dfa3(build4);
+
+ BOOST_CHECK(dfa3.get_current_state() == 0);
+ BOOST_CHECK(dfa3(2));
+ BOOST_CHECK(dfa3.get_current_state() == 2);
+ BOOST_CHECK(dfa3(4));
+ BOOST_CHECK(dfa3.get_current_state() == 4);
+ BOOST_CHECK(dfa3(0));
+ BOOST_CHECK(dfa3.get_current_state() == 0);
+ BOOST_CHECK(dfa3(1));
+ BOOST_CHECK(dfa3.get_current_state() == 1);
+ BOOST_CHECK(dfa3(3));
+ BOOST_CHECK(dfa3.get_current_state() == 3);
+ BOOST_CHECK(dfa3(2));
+ BOOST_CHECK(dfa3.get_current_state() == 2);
+ BOOST_CHECK(dfa3(4));
+ BOOST_CHECK(dfa3.get_current_state() == 4);
+ BOOST_CHECK(dfa3(3));
+ BOOST_CHECK(dfa3.get_current_state() == 3);
+ BOOST_CHECK(dfa3(1));
+ BOOST_CHECK(dfa3.get_current_state() == 1);
+ BOOST_CHECK(dfa3(0));
+ BOOST_CHECK(dfa3.get_current_state() == 0);
+ BOOST_CHECK(dfa3(4));
+ BOOST_CHECK(dfa3.get_current_state() == 4);
+ BOOST_CHECK(dfa3(5));
+ BOOST_CHECK(dfa3.get_current_state() == 5);
+}
+//]
+

Added: sandbox/automata/libs/automata/test/dfa_builder.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/test/dfa_builder.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,75 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <string>
+#include <vector>
+#include "dfa_builder.hpp"
+
+//[test__dfa_build1__function
+void build1(Function0& function)
+{
+ function.reset(4, 4);
+ function.set_transition(0, 0, 1);
+ function.set_transition(0, 1, 1);
+ function.set_transition(0, 2, 2);
+ function(1, 1) = 2;
+ function(1, 2) = 0;
+ function(2, 3) = 3;
+}
+//]
+
+//[test__dfa_build2__function
+void build2(Function1& function)
+{
+ std::vector<std::string> inputs;
+ inputs.push_back("alpha");
+ inputs.push_back("beta");
+ inputs.push_back("gamma");
+ inputs.push_back("delta");
+
+ function.reset(4, inputs.begin(), inputs.end());
+ function.set_transition(0, "alpha", 1);
+ function.set_transition(0, "beta", 1);
+ function.set_transition(0, "gamma", 2);
+ function(1, "beta") = 2;
+ function(1, "gamma") = 0;
+ function(2, "delta") = 3;
+}
+//]
+
+//[test__dfa_build3__function
+void build3(Function2& function)
+{
+ function.reset(4);
+ function.set_transition(0, "alpha", 1);
+ function.set_transition(0, "beta", 1);
+ function.set_transition(0, "gamma", 2);
+ function(1, "beta") = 2;
+ function(1, "gamma") = 0;
+ function(2, "delta") = 3;
+}
+//]
+
+//[test__dfa_build4__function
+void build4(Function3& function)
+{
+ function.reset(6);
+ function.add_transition(0, 1);
+ function.add_transition(0, 2);
+ function.add_transition(0, 4);
+ function.add_transition(1, 0);
+ function.add_transition(1, 2);
+ function.add_transition(1, 3);
+ function.add_transition(2, 3);
+ function(2) += 4;
+ function(3) += 0;
+ function(3) += 1;
+ function(3) += 2;
+ function(4) += 0;
+ function(4) += 3;
+ function(4) += 5;
+}
+//]
+

Added: sandbox/automata/libs/automata/test/dfa_builder.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/test/dfa_builder.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,38 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef LIBS_AUTOMATA_TEST_DFA_BUILDER_HPP_INCLUDED
+#define LIBS_AUTOMATA_TEST_DFA_BUILDER_HPP_INCLUDED
+
+#include <string>
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/automata/transition_function/matrix.hpp>
+#include <boost/automata/transition_function/mapped_input_tabular.hpp>
+#include <boost/automata/transition_function/mapped_input.hpp>
+#include <boost/automata/transition_function/next_state.hpp>
+
+//[test__dfa_trans_func__typedefs
+typedef boost::automata::matrix_transition_function<
+ boost::numeric::ublas::matrix<std::size_t>
+ >
+ Function0;
+typedef boost::automata::mapped_input_tabular_transition_function<
+ std::string
+ , Function0
+ >
+ Function1;
+typedef boost::automata::mapped_input_transition_function<std::string>
+ Function2;
+typedef boost::automata::next_state_transition_function<>
+ Function3;
+//]
+
+void build1(Function0& function);
+void build2(Function1& function);
+void build3(Function2& function);
+void build4(Function3& function);
+
+#endif // LIBS_AUTOMATA_TEST_DFA_BUILDER_HPP_INCLUDED
+

Added: sandbox/automata/libs/automata/test/dpda.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/test/dpda.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,135 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/automata/generator/dpda.hpp>
+#include <boost/automata/automaton.hpp>
+#include "dpda_builder.hpp"
+
+using namespace boost;
+using namespace automata;
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+BOOST_AUTO_TEST_CASE(dpda_test)
+{
+ automaton<dpda_generator,Function> dpda(build1);
+
+ BOOST_CHECK(dpda('a'));
+ BOOST_CHECK(dpda('a'));
+ BOOST_CHECK(dpda('b'));
+ BOOST_CHECK(!dpda.has_empty_stack());
+ BOOST_CHECK(dpda('b'));
+ BOOST_CHECK(dpda.has_empty_stack());
+ BOOST_CHECK(!dpda('b'));
+
+ dpda.reset();
+
+ BOOST_CHECK(dpda('a'));
+ BOOST_CHECK(dpda('a'));
+ BOOST_CHECK(dpda('a'));
+ BOOST_CHECK(dpda('b'));
+ BOOST_CHECK(dpda('b'));
+ BOOST_CHECK(dpda('b'));
+ BOOST_CHECK(dpda.has_empty_stack());
+
+ dpda.initialize(build2);
+
+ BOOST_CHECK(dpda('x'));
+ BOOST_CHECK(!dpda('y'));
+ BOOST_CHECK(!dpda('('));
+ BOOST_CHECK(dpda('+'));
+ BOOST_CHECK(dpda('y'));
+ BOOST_CHECK(dpda.has_empty_stack());
+ BOOST_CHECK(!dpda(')'));
+
+ dpda.reset();
+
+ BOOST_CHECK(dpda('('));
+ BOOST_CHECK(dpda('x'));
+ BOOST_CHECK(dpda('+'));
+ BOOST_CHECK(dpda('y'));
+ BOOST_CHECK(!dpda.has_empty_stack());
+ BOOST_CHECK(dpda(')'));
+ BOOST_CHECK(dpda('*'));
+ BOOST_CHECK(dpda('x'));
+ BOOST_CHECK(dpda('-'));
+ BOOST_CHECK(dpda('z'));
+ BOOST_CHECK(dpda('*'));
+ BOOST_CHECK(dpda('y'));
+ BOOST_CHECK(dpda('/'));
+ BOOST_CHECK(dpda('('));
+ BOOST_CHECK(dpda('x'));
+ BOOST_CHECK(dpda('+'));
+ BOOST_CHECK(dpda('x'));
+ BOOST_CHECK(dpda(')'));
+ BOOST_CHECK(dpda.has_empty_stack());
+
+ dpda.reset();
+
+ BOOST_CHECK(dpda('x'));
+ BOOST_CHECK(dpda('/'));
+ BOOST_CHECK(dpda('('));
+ BOOST_CHECK(dpda('y'));
+ BOOST_CHECK(dpda('*'));
+ BOOST_CHECK(dpda('('));
+ BOOST_CHECK(dpda('z'));
+ BOOST_CHECK(dpda('-'));
+ BOOST_CHECK(dpda('y'));
+ BOOST_CHECK(dpda(')'));
+ BOOST_CHECK(dpda('+'));
+ BOOST_CHECK(dpda('x'));
+ BOOST_CHECK(dpda(')'));
+ BOOST_CHECK(dpda.has_empty_stack());
+
+ dpda.initialize(build3);
+
+ BOOST_CHECK(dpda('a'));
+ BOOST_CHECK(dpda('a'));
+ BOOST_CHECK(dpda('c'));
+ BOOST_CHECK(dpda('c'));
+ BOOST_CHECK(dpda.has_empty_stack());
+
+ dpda.reset();
+
+ BOOST_CHECK(dpda('a'));
+ BOOST_CHECK(dpda('b'));
+ BOOST_CHECK(dpda('c'));
+ BOOST_CHECK(!dpda.has_empty_stack());
+ BOOST_CHECK(dpda('c'));
+ BOOST_CHECK(dpda.has_empty_stack());
+
+ dpda.reset();
+
+ BOOST_CHECK(dpda('a'));
+ BOOST_CHECK(dpda('a'));
+ BOOST_CHECK(dpda('b'));
+ BOOST_CHECK(dpda('c'));
+ BOOST_CHECK(dpda('c'));
+ BOOST_CHECK(dpda('c'));
+ BOOST_CHECK(dpda.has_empty_stack());
+
+ dpda.reset();
+
+ BOOST_CHECK(dpda('a'));
+ BOOST_CHECK(dpda('b'));
+ BOOST_CHECK(dpda('b'));
+ BOOST_CHECK(dpda('c'));
+ BOOST_CHECK(dpda('c'));
+ BOOST_CHECK(dpda('c'));
+ BOOST_CHECK(dpda.has_empty_stack());
+ BOOST_CHECK(!dpda('c'));
+
+ dpda.reset();
+
+ BOOST_CHECK(dpda('b'));
+ BOOST_CHECK(dpda('b'));
+ BOOST_CHECK(dpda('b'));
+ BOOST_CHECK(dpda('c'));
+ BOOST_CHECK(dpda('c'));
+ BOOST_CHECK(dpda('c'));
+ BOOST_CHECK(dpda.has_empty_stack());
+}
+

Added: sandbox/automata/libs/automata/test/dpda_builder.cpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/test/dpda_builder.cpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,111 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/fusion/support/pair.hpp>
+#include "dpda_builder.hpp"
+
+//[test__dpda_build1__function
+void build1(Function& function)
+{
+ Function::optional_stack_element
+ N;
+ Function::optional_stack_element
+ S('S');
+ Function::result_map
+ r0(
+ boost::fusion::make_pair<boost::automata::next_state_key>(0)
+ , boost::fusion::make_pair<boost::automata::push_to_stack_key>(S)
+ );
+ Function::result_map
+ r1(
+ boost::fusion::make_pair<boost::automata::next_state_key>(1)
+ , boost::fusion::make_pair<boost::automata::push_to_stack_key>(N)
+ );
+
+ function.reset(2);
+ function.set_transition(0, 'a', r0);
+ function.set_transition(0, 'b', 'S', r1);
+ function.set_transition(1, 'b', 'S', r1);
+}
+//]
+
+//[test__dpda_build2__function
+void build2(Function& function)
+{
+ Function::optional_stack_element
+ N;
+ Function::optional_stack_element
+ S('S');
+ Function::optional_stack_element
+ A('A');
+ Function::result_map
+ r0S(
+ boost::fusion::make_pair<boost::automata::next_state_key>(0)
+ , boost::fusion::make_pair<boost::automata::push_to_stack_key>(S)
+ );
+ Function::result_map
+ r0A(
+ boost::fusion::make_pair<boost::automata::next_state_key>(0)
+ , boost::fusion::make_pair<boost::automata::push_to_stack_key>(A)
+ );
+ Function::result_map
+ r1N(
+ boost::fusion::make_pair<boost::automata::next_state_key>(1)
+ , boost::fusion::make_pair<boost::automata::push_to_stack_key>(N)
+ );
+
+ function.reset(2);
+ function.set_transition(0, '(', r0S);
+ function.set_transition(0, '(', 'A', r0S);
+ function.set_transition(0, 'x', r1N);
+ function.set_transition(0, 'x', 'A', r1N);
+ function.set_transition(0, 'y', r1N);
+ function.set_transition(0, 'y', 'A', r1N);
+ function.set_transition(0, 'z', r1N);
+ function.set_transition(0, 'z', 'A', r1N);
+ function.set_transition(1, ')', 'S', r1N);
+ function.set_transition(1, '+', r0A);
+ function.set_transition(1, '-', r0A);
+ function.set_transition(1, '*', r0A);
+ function.set_transition(1, '/', r0A);
+}
+//]
+
+//[test__dpda_build3__function
+void build3(Function& function)
+{
+ Function::optional_stack_element
+ N;
+ Function::optional_stack_element
+ S('S');
+ Function::optional_stack_element
+ B('B');
+ Function::result_map
+ r0S(
+ boost::fusion::make_pair<boost::automata::next_state_key>(0)
+ , boost::fusion::make_pair<boost::automata::push_to_stack_key>(S)
+ );
+ Function::result_map
+ r1B(
+ boost::fusion::make_pair<boost::automata::next_state_key>(1)
+ , boost::fusion::make_pair<boost::automata::push_to_stack_key>(B)
+ );
+ Function::result_map
+ r2N(
+ boost::fusion::make_pair<boost::automata::next_state_key>(2)
+ , boost::fusion::make_pair<boost::automata::push_to_stack_key>(N)
+ );
+
+ function.reset(3);
+ function(0, 'a') = r0S;
+ function(0, 'b') = r1B;
+ function(0, 'c', 'S') = r2N;
+ function(1, 'b') = r1B;
+ function(1, 'c', 'B') = r2N;
+ function(2, 'c', 'S') = r2N;
+ function(2, 'c', 'B') = r2N;
+}
+//]
+

Added: sandbox/automata/libs/automata/test/dpda_builder.hpp
==============================================================================
--- (empty file)
+++ sandbox/automata/libs/automata/test/dpda_builder.hpp 2011-09-21 13:16:03 EDT (Wed, 21 Sep 2011)
@@ -0,0 +1,21 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef LIBS_AUTOMATA_TEST_DPDA_BUILDER_HPP_INCLUDED
+#define LIBS_AUTOMATA_TEST_DPDA_BUILDER_HPP_INCLUDED
+
+#include <boost/automata/transition_function/dpda.hpp>
+
+//[test__dpda_trans_func__typedef
+typedef boost::automata::dpda_transition_function<char,char>
+ Function;
+//]
+
+void build1(Function& function);
+void build2(Function& function);
+void build3(Function& function);
+
+#endif // LIBS_AUTOMATA_TEST_DPDA_BUILDER_HPP_INCLUDED
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk