+ +A key part of the |Cyclus| agent and module development infrastructure is +a |Cyclus|-aware C++ preprocessor called |cycpp|. This preprocessor +inspects the agents that you write and then - based on the directives you +have given it - generates code that conforms to the |cyclus| agent API. +This allows you to focus on coding up the desired agent behavior rather +than worrying about the tedious and error-prone process of making your +agents conform to the |Cyclus| kernel. + +Before we continue there are a couple of noteworthy points about |cycpp|: + +* Even when using the preprocessor, agents are still completely valid C++ + and may be compiled without running |cycpp| - though they probably + won't do the correct thing in a simulation. +* If your module is compiled with the CMake macros found in UseCyclus, + |cycpp| is run automatically for you on all relevant files. + +Without further ado, let's dive in! + +.. raw:: html + + | + +.. image:: ../astatic/pennyfarthing-jack.jpg + :align: center + :width: 300px + +.. raw:: html + + |
+
+The ```` argument may be any valid Python code. A non-trivial example,
+
+**Exec example:**
+
+.. code-block:: c++
+
+ #pragma cyclus exec from math import pi
+ #pragma cyclus exec r = 10
+
+ #pragma cyclus var {"default": 2*pi*r}
+ float circumfrence;
+
+One possible use for this is to keep all state variable annotations in a
+separate sidecar ``*.py`` file and then import and use them rather than
+cluttering up the C++ source code. Such decisions are up to the style of the
+developer.
+
+Code Generation Directives
+---------------------------
+
+Once all of the annotations have been accumulated, the preprocessor takes
+*another* pass through the code. This time it ignores the annotations
+directives and injects C++ code anytime it sees a valid code generation
+directive.
+
+The simplest and most powerful of the code generators is known as **the prime
+directive**. This engages all possible code generation routines and must live
+within the public part of the class declaration.
+
+**The prime directive:**
+
+.. code-block:: c++
+
+ #pragma cyclus
+
+Unless you are doing something fancy such as manually writing any of the agent
+member functions that |cycpp| generates, the prime directive should be all that
+you ever need. For example, an agent that does nothing and has no state variables
+would be completely defined by the following thanks to the prime directive:
+
+**The prime directive example:**
+
+.. code-block:: c++
+
+ class DoNothingCongress : public cyclus::Institution {
+ public:
+ DoNothingCongress(cyclus::Context* ctx) {};
+ virtual ~DoNothingCongress() {};
+
+ #pragma cyclus
+ };
+
+.. raw:: html
+
+
+
+--------------
+
+For the times when you wish to break the prime directive, you may drill down
+into more specific code generation routines. These fit into three broad
+categories:
+
+1. **Declaration (decl) directives**,
+2. **Definition (def) directives**, and
+3. **Implementation (impl) directives**.
+
+The ``decl`` directives generate only the member function declaration and must
+be used from within the public part of the agent's class declaration. The
+``def`` generate the member function definition in its entirety including the
+function signature. These may be used either in the class declaration or in
+the source file (``*.cc``, ``*.cpp``, etc.). The ``impl`` directives generate
+only the body of the member function, leaving off the function signature.
+These are useful for intercepting default behavior while still benefiting from
+code generation. These must be called from with the appropriate function
+body.
+
+The signature for the targeted code generation directives is as follows:
+
+**Targeted code generation directive signatures:**
+
+.. code-block:: c++
+
+ #pragma cyclus [ []]
+
+The first argument must be one of ``decl``, ``def``, or ``impl``, which
+determines the kind of code generation that will be performed. The second,
+optional ```` argument is the member function name that code should be
+generated for. The third and final and optional ```` argument is the
+agent name to code generate for. This argument is useful in the face of
+ambiguous or absent C++ scope. The ```` argument must be present if
+```` needs to be specified.
+
+In the absence of optional arguments there are only:
+
+.. code-block:: c++
+
+ #pragma cyclus decl
+ #pragma cyclus def
+
+These generate all of the member function declarations and definitions,
+respectively. Note that there is no corresponding ``#pragma cyclus impl``
+because function bodies cannot be strung together without the corresponding
+signatures encapsulating them.
+
+When the ```` argument is provided the directive generates only the
+definition, declaration, or implementation for the given agent API function.
+For example the following would generate the definition for the ``schema()``
+function.
+
+.. code-block:: c++
+
+ #pragma cyclus def schema
+
+:ref:`cycpp-table-3` contains a listing of all available function flags and their
+associated C++ information.
+
+.. rst-class:: centered
+
+.. _cycpp-table-3:
+
+.. table:: **Table III.** Member Function Flags and Their C++ Signatures
+ :widths: 1 6 3
+ :column-alignment: left left left
+ :column-wrapping: true true true
+ :column-dividers: none single single none
+
+ ============ ========================================= =======================
+ func C++ Signature Return Type
+ ============ ========================================= =======================
+ clone ``Clone()`` ``cyclus::Agent*``
+ initfromcopy ``InitFrom(MyAgent* m)`` ``void``
+ initfromdb ``InitFrom(cyclus::QueryableBackend* b)`` ``void``
+ infiletodb ``InfileToDb(cyclus::InfileTree* tree, ``void``
+ cyclus::DbInit di)``
+ schema ``schema()`` ``std::string``
+ annotations ``annotations()`` ``Json::Value``
+ snapshot ``Snapshot(cyclus::DbInit di)`` ``void``
+ snapshotinv ``SnapshotInv()`` ``cyclus::Inventories``
+ initinv ``InitInv(cyclus::Inventories& inv)`` ``void``
+ ============ ========================================= =======================
+
+.. raw:: html
+
+
+
+--------------
+
+Lastly, the agent's classname may be optionally passed the to the directive.
+This is most useful in source files for the definition directives. This is
+because such directives typically lack the needed class scope. For example,
+for the snapshot definition of ``MyAgent`` living in ``mynamespace`` we would
+use:
+
+.. code-block:: c++
+
+ #pragma cyclus def snapshot mynamespace::MyAgent
+
+Putting It Together
+--------------------
+
+|Cyclus| agents are written by declaring certain member variables to be
+**state variables**. This means that they *define* the conditions of the
+agent at the start of every time step. State variables are automatically are
+saved and loaded to the database as well a dictating other important
+interactions with the kernel.
+
+The preprocessor will generate the desired implementation of key member
+functions for your agent. The easiest way to obtain these is through the
+prime directive.
+
+As a simple example, consider a reactor model that has three state variables:
+a flux, a power level, and a flag for whether it is shutdown or not.
+This could be implemented as follows:
+
+.. code-block:: c++
+
+ class Reactor : public cyclus::Facility {
+ public:
+ Reactor(cyclus::Context* ctx) {};
+ virtual ~Reactor() {};
+
+ #pragma cyclus
+
+ private:
+ #pragma cyclus var {'default': 4e14, \
+ 'doc': 'the core-average flux', \
+ 'units': 'n/cm2/2'}
+ double flux;
+
+ #pragma cyclus var {'default': 1000, 'units': 'MWe'}
+ float power;
+
+ #pragma cyclus var {'doc': 'Are we operating?'}
+ bool shutdown;
+ };
+
+Note that the state variables may be private or protected if desired.
+Furthermore annotations may be broken up over many lines using trailing
+backslashes to make the code more readable. It remains up to you - the module
+developer - to implement the desired behavior and logic in the ``Tick()`` and
+``Tock()`` member functions. Fancier tricks are available as needed but this
+is the essence of how to write |cyclus| agents.
+
+Abusing the |Cyclus| Preprocessor
+==================================
+Now that you know how to use |cycpp|, it is useful to know about some of the
+more advanced features and how they can be leveraged.
+
+Scope and Annotations
+-------------------------
+
+Annotations dictionaries retain the C++ scope that they are defined in even
+though they are written in Python. This allows state variables to refer to
+the annotations for previously declared state variables. Since the scope is
+retained, this allows annotations to refer to each other across agent/class
+and namespace boundaries.
+
+Because the annotations are dictionaries, the scoping is performed with the
+Python scoping operator (``.``) rather than the C++ scoping operator (``::``).
+For example, consider the case where we have a ``Spy`` class that lives in the
+``mi6`` namespace. Also in the namespace is the spy's ``Friend``.
+Furthermore, somewhere out in global scope lives the Spy's arch-nemesis class
+``Enemy``.
+
+The first rule of scoping is that two state variables on the same class
+share the same scope. Thus they can directly refer to each other.
+
+.. code-block:: c++
+
+ namespace mi6 {
+ class Spy {
+ #pragma cyclus var {"default": 7}
+ int id;
+
+ #pragma cyclus var {"default": "James Bond, {0:0>3}".format(id['default'])}
+ std::string name;
+ };
+ }; // namespace mi6
+
+In the above, ``id`` is used to help define the annotations for ``name``.
+Note that from within the annotations, other state variables are the annotation
+dictionary that was previously defined. They fo not take on the C++ default value.
+This is why we could look up ``id['default']``.
+
+The second rule of scoping is that you are allowed to look into the annotations
+of other classes. However, to do so you must specifiy the class you are looking
+into. Looking at our spy's friend
+
+.. code-block:: c++
+
+ namespace mi6 {
+ class Friend {
+ #pragma cyclus var {"doc": "Normally helps {0}".format(Spy.name['default'])}
+ std::string help_first;
+ };
+ }; // namespace mi6
+
+Here, to access the annotations for Spy's name we had to use ``Spy.name``,
+drilling into the Spy class. Inspecting in this way is not limited by C++
+access control (public, private, or protected).
+
+Lastly, if the agent we are trying to inspect lives in a completely different
+namespace, we must first drill into that namespace. For example, the spy's
+main enemy is not part of ``mi6``. Thus to access the spy's name annotations,
+the enemy must write ``mi6.Spy.name``. For example:
+
+.. code-block:: c++
+
+ class Enemy {
+ #pragma cyclus var {'default': mi6.Spy.name['default']}
+ std::string nemesis;
+ };
+
+
+Inventories
+------------
+In addition to the normal :doc:`dbtypes`, state variables may also be declared
+with the ``cyclus::Inventories`` type. This is a special |cyclus| typedef
+of ``std::map >`` that enables the
+storing of an arbitrary of resources (map values) by the associated commodity
+(map key). While the concept of a resource inventory may be implemented in many
+ways, the advantage in using the ``cyclus::Inventories`` is that the |Cyclus|
+kernel knows how to save and load this type as well as represent it in RNG.
+Inventories may be used as normal state variables. For example:
+
+.. code-block:: c++
+
+ #pragma cyclus var {'doc': 'my stocks'}
+ cyclus::Inventories invs;
+
+It is therefore *hightly* recommended that you store resources in this
+data structure.
+
+State Variable Code Generation Overrides
+-----------------------------------------
+A powerful feature of most of the code generation directives is that the
+C++ code that is created for a state variable may be optionally replaced with a
+code snippet writing in the annotations. This allows you to selectively
+define the C++ behavior without the need to fully rewrite the member function.
+
+A potential use case is to provide a custom schema while still utilizing all other
+parts of |cycpp|. For example:
+
+.. code-block:: c++
+
+ #pragma cyclus var {'schema': 'Famcy RNG here '}
+ std::set fibonacci;
+
+This will override the schema only for the Fibonacci state variable. For a
+listing of all code generation functions that may be overridden, please see
+:ref:`cycpp-table-1`.
+
+Implementation Hacks
+---------------------
+
+The ``impl`` code generation directives exist primarily to be abused. Unlike
+the ``def`` directives, the implementation directives do not include the
+function signature or return statement. The downside of this is that you must
+provide the function signature and the return value yourself. The upside is
+that you may perform any operation before & after the directive!
+
+For example, suppose that we wanted to make sure that the flux state variable
+on the Reactor agent is always snapshotted to the database as the value 42.
+However, we did not want to permanently alter the value of this variable.
+This could be achieved through the following pattern:
+
+.. code-block:: c++
+
+ void Reactor::Snapshot(cyclus::DbInit di) {
+ double real_flux = flux; // copy the existing flux value.
+ flux = 42; // set the value to wat we want temporarily
+
+ // fill in the code generated implementation of Shapshop()
+ #prama cyclus impl snapshot Reactor
+
+ flux = real_flux; // reset the flux
+ }
+
+There are likely much more legitimate uses for this feature. For a complete
+listing of the member function information, please see :ref:`cycpp-table-3`.
+
+Custom Schema & Initialization
+------------------------------
+Suppose that you would like for the schema for a state variable to be different
+than the default behavior provided by |cycpp|. Or perhaps you would like more
+sophisticated input validation than can is provided by XML and RelaxNG for a
+state variable. This may be easily done by supplying the state variable annotation
+keys ``schema`` and ``infiletodb``. These allow you to inject code snippets
+pertaining to the state variable without interfering with the rest of the
+code generation.
+
+For example, let's say that we have an integer state variable called
+``material_identifier`` that we know always should be even. This name is
+a bit long to make users type in, so we would prefer to expose this in the
+input file as ``matid``. The RNG snippet that you would use for the ``schema``
+is thus:
+
+.. code-block:: python
+
+ {'schema': '' \
+ ' ' \
+ ' '}
+
+You can change the data type or any other valid RNG here.
+
+.. note:: Whenever a state variable name is changed in the ``schema``, you
+ must supply an accompanying ``infiletodb``.
+
+Providing a custom ``infiletodb`` is slightly more complicated because you
+must give C++ snippets for reading from the input file and for persisting to
+the database. The value for ``infiletodb`` is thus not a simple string
+but a dict that has ``read`` and ``write`` keys. Continuing with the
+example we can ensure that ``matid`` is even after it has been read in.
+Here, we do not change the name of the state variable on the agent in
+memory or in the database.
+
+.. code-block:: python
+
+ {'infiletodb': { \
+ 'read': 'material_identifier = cyclus::Query(tree, "matid");\n' \
+ 'if (material_identifier%2 == 1)\n' \
+ ' material_identifier++;\n', \
+ 'write': '->AddVal("material_identifier", material_identifier)\n' \
+ }}
+
+For more examples and explanation of what the ``InfileToDb()`` function
+does please refer to other code generated samples and refer to other parts
+of the documentation.
+Pulling this all together, we can write our custom schema and initialization
+as follows:
+
+.. code-block:: c++
+
+ #pragma cyclus var {'schema': '' \
+ ' ' \
+ ' ', \
+ 'infiletodb': { \
+ 'read': 'material_identifier = cyclus::Query(tree, "matid");\n' \
+ 'if (material_identifier%2 == 1)\n' \
+ ' material_identifier++;\n', \
+ 'write': '->AddVal("material_identifier", material_identifier)\n' \
+ }\
+ }
+ int material_identifier;
+
+Other state variable annotation keys allow you to provide code snippets
+in much the same way.
+
diff --git a/_sources/arche/dbtypes.rst.txt b/_sources/arche/dbtypes.rst.txt
new file mode 100755
index 000000000..c69d55872
--- /dev/null
+++ b/_sources/arche/dbtypes.rst.txt
@@ -0,0 +1,160 @@
+.. _dbtypes:
+
+Database Types
+==============
+
+Here is a listing of all supported data types that the various backends have
+implemented, by |cyclus| version number. If your agents need a type that is not
+yet supported, please let us know and we'll get to it as soon as possible!
+
+**Description of fields:**
+
+:id: enum identifier (value) for database type in the ``cyclus::DbTypes`` enum.
+:name: enum name for database type in the ``cyclus::DbTypes`` enum.
+:C++ type: the cooresponding C++ type.
+:shape rank: the maximum rank (length) of the ``shape`` vector.
+:backend: the database backend type.
+:version: the |cyclus| version.
+:supported: flag for if the backend supported this type in this release.
+
+.. raw:: html
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/_sources/arche/decay.rst.txt b/_sources/arche/decay.rst.txt
new file mode 100755
index 000000000..e593bbe58
--- /dev/null
+++ b/_sources/arche/decay.rst.txt
@@ -0,0 +1,126 @@
+.. summary Documentation for the |Cyclus| Decay Method
+
+Radioactive Decay in |Cyclus|
+=============================
+.. warning:: Decay in |cyclus| is experimental.
+
+Radioactive decay of a group of isotopes over time can be described by the
+following first order differential equation:
+
+.. math::
+
+ \frac{d}{dt}\mathbf{N(\mathit{t})}=\textrm{A}\: \mathbf{N(\mathit{t})}
+
+where the vector `N(t)` contains the number density of all the
+isotopes being considered at time `t`, and A is called the decay
+matrix. The solution to this differential equation can be expressed in terms
+of a matrix exponential:
+
+.. math::
+
+ \mathbf{N(\mathit{to+\Delta t})}=e^{\Delta t \textrm{A}}\: \mathbf{N(\mathit{to})}
+
+The decay method currently implemented in |cyclus| computes this matrix
+exponential solution at any given time using a series approximation known as
+the Uniformization Method. This implementation was written by Kerry Dunn, and
+is explained in more detail below.
+
+The Uniformization Method
+-------------------------
+The Uniformization Method is essentially a modification of the truncated Taylor
+Series expansion of the matrix exponential solution, which can be described by
+the following summation:
+
+.. math::
+
+ \mathbf{N(\mathit{to+\Delta t})}\approx \sum_{k=0}^{p}\frac{\left (\Delta t \right )^k}{k!}\: \textrm{A}^k\: \mathbf{N(\mathit{to})}
+
+The primary disadvantage of using this Taylor Series expansion to compute the
+matrix exponential solution is that it can be subject to cancellation error as
+a result of summing terms with alternating signs. These terms with alternating
+signs occur because the diagonal elements in the decay matrix that represent
+the decay constants are all negative. Therefore, in order to eliminate the
+potential for cancellation error, the decay matrix must be modified so that it
+no longer contains these negative elements. This modification process is known
+as the uniformization technique.
+
+The first step in applying the uniformization technique is to define
+`alpha` to be equal to the absolute value of the maximum diagonal
+element of `A`:
+
+.. math::
+
+ \alpha=max_i\left | {a_i}_i \right |
+
+Then, given `alpha`, the next step is to redefine the matrix
+exponential solution using a different matrix `P`:
+
+.. math::
+
+ \textrm{P}=\frac{1}{\alpha}\textrm{A}+\textrm{I}
+
+where I is the identity matrix. Note that `P` is completely non-negative, so a
+Taylor Series expansion of this matrix exponential is not subject to the same
+cancellation error that occurs with the original decay matrix. By replacing `A`
+with `P`, the matrix exponential solution can now be expressed by the following
+summation:
+
+.. math::
+
+ \mathbf{N(\mathit{to+\Delta t})}=e^{-\alpha \Delta t}\: e^{\Delta t (\alpha \textrm{P})}\: \mathbf{N(\mathit{to})}\approx e^{-\alpha \Delta t}\sum_{k=0}^{p}\frac{\left (\Delta t \right )^k}{k!}\: (\alpha \textrm{P})^k\: \mathbf{N(\mathit{to})}
+
+Note that this modified Taylor Series expansion can also be expressed in terms
+of the original matrix A by substituting the definition for `P`:
+
+.. math::
+
+ \mathbf{N(\mathit{to+\Delta t})}\approx e^{-\alpha\Delta t}\sum_{k=0}^{p}\frac{\left (\Delta t \right )^k}{k!}\: (\textrm{A}+\alpha \textrm{I})^k\: \mathbf{N(\mathit{to})}
+
+
+Implementation in |Cyclus|
+--------------------------
+
+Adding New Isotopes
+-------------------
+
+Limitations
++++++++++++
+
+When adding a new isotope, the most important thing to take into account is its
+half-life or decay constant. The isotope with the smallest half-life, or
+largest decay constant, will be the limiting factor for the time scale over
+which |cyclus| can decay _all_ materials in one step. This occurs because the
+Uniformization Method requires the computation of an exponential term, which is
+limited by the size of a long double on the system being used to run |cyclus|.
+To determine the maximum time scale that will be valid for a particular group
+of isotopes, the following equation can be used:
+
+.. math::
+
+ {t_{max} = \frac{ln(\textrm{LDBL\_MAX})}{min(\lambda)}}
+
+where `LDBL_MAX` is the size of a long double and :math:`\lambda` is the
+largest decay constant of the group of isotopes being considered.
+
+As an example, suppose that the isotope with the smallest half-life being
+considered is Cm-232. This particular isotope has a decay constant of 1.5532
+nuclei per year. If the size of a long double is limited to LDBL_MAX =
+1.18973e+4932, then all materials can only be decayed for a maximum of 7311
+years. Adding any isotopes with a half-life smaller than Cm-232 would result
+in an even lower maximum time scale.
+
+References
+----------
+
+#. Cleve Moler and Charles van Loan, "Nineteen Dubious Ways to Compute the
+ Exponential of a Matrix, Twenty-Five Years Later," *SIAM Review*, *45*,
+ 3-49 (2003)
+
+#. Erwin Muller, Frederik Reitsma and Paulus P. Kruger, "A Stable Nuclide
+ Transmutation Procedure Free of Numerical Roundoff," *PHYSOR 2006*, September
+ 10-14, Vancouver, Canada (2006)
+
+#. R. B. Sidje and W. J. Stewart, "A numerical study of large sparse matrix
+ exponentials arising in Markov chains," *Computational Statistics & Data
+ Analysis*, *29*, 345-368 (1999)
+
diff --git a/_sources/arche/dre.rst.txt b/_sources/arche/dre.rst.txt
new file mode 100755
index 000000000..b85c7d138
--- /dev/null
+++ b/_sources/arche/dre.rst.txt
@@ -0,0 +1,815 @@
+.. _dre:
+
+Dynamic Resource Exchange
+=========================
+The Dynamic Resource Exchange (DRE) is the heart of a |cyclus| simulation time
+step. Every ``Trader`` that is registered with the ``Context``
+is automatically included in the exchange. |cyclus| agents can either implement
+the ``Trader`` interface as a mixin or can be composed of one or more
+traders. Note that the ``Facility`` class derives the
+``Trader`` interface, and therefore all agents that derive from
+``Facility`` are also traders.
+
+On each time step, there is a separate ``ResourceExchange``
+instance for each concrete ``Resource`` (i.e. ``Materials`` and ``Products``) of which
+the kernel is aware. For example, there is an exchange for ``Material``
+resources and another for ``Product`` resources.
+
+The DRE is comprised of five phases which execure in series:
+
+* :ref:`rfb`
+* :ref:`rrfb`
+* :ref:`adj`
+* :ref:`solve`
+* :ref:`trade`
+* :ref:`examples`
+
+.. _rfb:
+
+Request For Bids Phase
+----------------------
+In the Request for Bids (RFB) phase, the exchange queries all registered traders
+regarding their demand for a given resource type. Querying is provided through
+the ``Trader`` interface's "get requests" for a given resource type,
+e.g., ``GetMatlRequests()`` (C++) or ``get_material_requests()`` (Python) functions.
+
+Requests are modeled as collections of ``RequestPortfolio`` instances, where each
+portfolio includes a collection of ``Request`` objects and a collection of
+``CapacityConstraint`` objects. A portfolio is sufficiently met if one or more
+of its constituent requests are met and all of its constraints are satisfied.
+
+A request provides a target resource, a commodity, and a preference for that
+commodity-resource combination. A constraint provides a constraining value and a
+conversion function that can convert a potential resource into the units of the
+capacity (see :ref:`rrfb` for a more detailed example).
+
+For example, consider a facility of type ``FooFac`` that needs 10 kg fuel,
+where the fuel is represented by a ``Material`` resource. It knows of two commodities in
+the simulation that meet its demand, ``FuelA`` and ``FuelB``, and it prefers
+``FuelA`` over ``FuelB``. A valid get material request implementation would then
+be:
+
+**C++:**
+
+.. code-block:: c++
+
+ virtual std::set::Ptr> FooFac::GetMatlRequests() {
+ using cyclus::RequestPortfolio;
+ using cyclus::Material;
+ using cyclus::CapacityConstraint;
+
+ double request_qty = 10; // kg
+ std::string recipeA = "recipeA";
+ std::string commoda = "FuelA";
+ Material::Ptr targetA = Material::CreateUntracked(request_qty,
+ context()->GetRecipe(recipeA));
+
+ std::string recipeB = "recipeB";
+ std::string commodB = "FuelB";
+ Material::Ptr targetB = Material::CreateUntracked(request_qty,
+ context()->GetRecipe(recipeB));
+
+ CapacityConstraint cc(request_qty);
+
+ RequestPortfolio::Ptr port(new RequestPortfolio());
+ port->AddRequest(targeta, this, commodA);
+ port->AddRequest(targetb, this, commodB);
+ port->AddConstraint(cc);
+
+ std::set::Ptr> ports();
+ ports.insert(port);
+ return ports;
+
+ // In this example, both the FuelA and FuelB commodities can meet the
+ // material request, but FuelA is preferred. So we define a preference
+ // for each commodity as the fourth argument in the function.
+ // The larger the preference value, the more the commodity is preferred.
+ // The fifth argument here is if the request is exclusive:
+ std::set::Ptr> ports;
+ RequestPortfolio::Ptr port(new RequestPortfolio());
+
+ double prefA = 2;
+ double prefB = 1;
+ Request* r1 = port->AddRequest(targeta, this, commodA, prefA, true);
+ Request* r2 = port->AddRequest(targetb, this, commodB, prefB, true);
+
+ // Additionally, we can create a vector of requests that are mutual:
+ std::vector*> mreqs;
+ mreqs = {r1, r2};
+ port->AddMutualReqs(mreqs);
+ ports.insert(port);
+ return ports;
+ }
+
+**Python:**
+
+.. code-block:: python
+
+ import cyclus.typesystem as ts
+
+ def get_material_requests(self):
+ request_qty = 10.0 # kg
+ # Material Target A
+ recipe_a = self.context().get_recipe("recipeA")
+ target_a = ts.Material.create_untracked(request_qty, recipe_a)
+ # Material Target B
+ recipe_b = self.context().get_recipe("recipeB")
+ target_b = ts.Material.create_untracked(request_qty, recipe_b)
+ # commodity mapping to request target
+ commods = {"FuelA": target_a, "FuelB": target_b}
+
+ # The Python interface allow you to return a few different structures,
+ # depending on your needs. In its simplest form, if you do not not have
+ # any capacity constraints, you can just return the commodity mapping!
+ return commods
+
+ # If you do have a capacity constraint, you need to provide a portfolio
+ # dict. This is simply a dict with two keys: "commodities" and "constraints".
+ # The "commodities" value is the same as above. The "constraints" value is
+ # either a float or an iterable of floats.
+ # single constraint:
+ port = {"commodities": commods, "constraints": request_qty}
+ return port
+ # many constraints:
+ port = {"commodities": commods, "constraints": [request_qty, request_qty*2]}
+ return port
+
+ # In this example, both the FuelA and FuelB commodities can meet the
+ # material request, but FuelA is preferred. So we define a preference
+ # for each commodity. The larger the preference value, the
+ # more the commodity is preferred. Placing the dictionaries in
+ # a list makes them mutual requests:
+ commods = [{"FuelA": target_a, "preference":2},
+ {"FuelB": target_b, "preference":1}]
+ port = {"commodities":commods, "constraints":request_qty}
+
+ # If you want the requests to be exclusive, then you have to indicate
+ # that:
+ commods = [{"FuelA": target_a, "preference":2, "exclusive":True},
+ {"FuelB": target_b, "preference":1, "exclusive":True}]
+ port = {"commodities":commods, "constraints":request_qty}
+
+ # lastly, if you need to return many portfolios, simply return a list of
+ # portfolio dictionaries! The "preference" and "exclusive" keys are optional
+ ports = [{"commodities": [{"FuelA": target_a, "preference": 2, "exclusive": True}],
+ "constraints": request_qty},
+ {"commodities": [{"FuelB": target_b, "preference": 1, "exclusive": True}],
+ "constraints": request_qty}]
+ return ports
+
+
+.. _rrfb:
+
+Response to Request For Bids Phase
+----------------------------------
+In the Response to Request for Bids (RRFB) phase, the exchange queries all
+registered traders regarding their supply for a given resource type. Querying is
+provided through the ``Trader`` interface's "get bids" for a given
+resource type, e.g. ``GetMatlBids()`` (C++) or ``get_material_bids()`` (Python).
+
+Bids are modeled as collections of ``BidPortfolio``, where each
+portfolio includes a collection of ``Bid`` objects and a collection of
+``CapacityConstraint`` objectss. A portfolio is not violated if any of its
+constituent bids are connected to their requests and all of its constraints are
+satisfied.
+
+A bid is comprised of a request to which it is responding and a resource that it is
+offering in response to the request.
+
+Black Box Examples
+++++++++++++++++++
+Consider a facility of type ``FooFac`` that has 10 kg of fuel of commodity type
+``FuelA`` that it can provide. Furthermore, consider that its capacity to
+fulfill orders is constrained by the total amount of a given nuclide. A valid
+get material bids implementation would then be:
+
+**C++:**
+
+.. code-block:: c++
+
+ class NucConverter : public cyclus::Converter {
+ public:
+ NucConverter(int nuc) : nuc_(nuc) {};
+
+ virtual double convert(cyclus::Material::Ptr m, cyclus::Arc const * a = NULL,
+ cyclus::ExchangeTranslationContext const * ctx = NULL) const {
+ cyclus::MatQuery mq(m);
+ return mq.mass(nuc_);
+ }
+
+ private:
+ int nuc_;
+ };
+
+ virtual std::set::Ptr> FooFac::GetMatlBids(
+ cyclus::CommodMap::type& commod_requests) {
+ using cyclus::BidPortfolio;
+ using cyclus::CapacityConstraint;
+ using cyclus::Converter;
+ using cyclus::Material;
+ using cyclus::Request;
+
+ // respond to all requests of my commodity
+ std::string my_commodity = "FuelA";
+ BidPortfolio::Ptr port(new BidPortfolio());
+ std::vector*>& requests = commod_requests[my_commdoity];
+ std::vector*>::iterator it;
+ for (it = requests.begin(); it != requests.end(); ++it) {
+ std::string recipe = "recipe";
+ std::string commod = "Fuel";
+ for (it = requests.begin(); it != requests.end(); ++it) {
+ Material::Ptr offer = Material::CreateUntracked(request_qty,
+ context()->GetRecipe(recipe));
+ port->AddBid(*it, offer, this);
+ }
+ }
+
+ // add a custom constraint for Pu-239
+ int pu = 932390000; // Pu-239
+ Converter::Ptr conv(new NucConverter(pu));
+ double max_pu = 8.0; // 1 Signifigant Quantity of Pu-239
+ CapacityConstraint constr(max_pu, conv);
+ port->AddConstraint(constr);
+
+ std::set::Ptr> ports;
+ ports.insert(port);
+ return ports;
+ }
+
+
+**Python:**
+
+.. code-block:: python
+
+ # Note that the Python interface does not yet support custom constraint functions.
+ # these are fairly rare in practice and is a forth coming feature.
+ import cyclus.typesystem as ts
+
+ def get_material_bids(self, requests):
+ """This function takes as input a requests dictionary, which maps
+ commodity names to tuples of Request instances. For example::
+
+ requests = {
+ "FuelA": (MaterialRequest1, MaterialRequest2),
+ "FuelB": (MaterialRequest3, MaterialRequest4),
+ }
+
+ For more information on MaterialRequests and ProductRequests, please see
+ the cyclus.typesystem docs.
+ """
+ # Like with get_material_requests(), many potential bid structures can be returned
+ # depending on you need. If the commodity that you trade in wasn't requested this
+ # time step, you can just return None.
+ if 'FuelA' not in requests:
+ return
+
+ # Alternitavely, you may return a bid portfolio. Let's start by constructing the
+ # bids. If you don't want to offer a bid that is different than the request,
+ # you can just provide the requests. The bids are then a list of the request objects
+ reqs = requests['FuelA']
+ bids = [req for req in reqs]
+ # Or if you do want to offer something different than the request, the bids list
+ # list contains dictionaries with "request" and "offer" keys
+ recipe_comp = self.context.get_recipe(self.recipe_name)
+ bids = []
+ for req in reqs:
+ qty = min(req.target.quantity, self.capacity)
+ mat = ts.Material.create_untracked(qty, recipe_comp)
+ bids.append({'request': req, 'offer': mat})
+ # now that we have the bids, we can add this to a bid portfolio dict, which
+ # contains a "bids" key.
+ port = {"bids": bids}
+ return port
+
+ # if you need to add capcity constraint(s), also include a "constraints" key
+ # in the bids portfolio dict.
+ port = {"bids": bids, "constraints": self.capacity}
+ return port
+
+ # Of course you may also return many bid portfolios by putting the many
+ # dicts in the above form in a list.
+ ports = [{"bids": bids[::2], "constraints": self.capacity},
+ {"bids": bids[1::2], "constraints": self.capacity}]
+ return ports
+
+
+White Box Examples
++++++++++++++++++++
+Consider a case where a facility's bid depends on the type of the requester's
+``Agent``, and the bidder determines its offer based on the requester's
+interface:
+
+**C++:**
+
+.. code-block:: c++
+
+ cyclus::Material::Ptr FooFac::SpecialFooOffer() {
+ std::string recipe = "recipe";
+ double quantity = 10;
+ Material::Ptr target = Material::CreateUntracked(quantity,
+ context()->GetRecipe(recipe));
+ return target;
+ };
+
+ virtual std::set::Ptr> FooFac::GetMatlBids(
+ cyclus::CommodMap::type& commod_requests) {
+ using cyclus::BidPortfolio;
+ using cyclus::Material;
+ using cyclus::Request;
+
+ // respond to all requests of my commodity
+ std::string my_commodity = "FuelA";
+ BidPortfolio::Ptr port(new BidPortfolio());
+ std::vector*>& requests = commod_requests[my_commdoity];
+ std::vector*>::iterator it;
+ for (it = requests.begin(); it != requests.end(); ++it) {
+ Material::Ptr offer;
+ Agent* agent = it->requester();
+ FooFac* cast = dynamic_cast(agent);
+ if (cast != NULL) {
+ offer = cast->SpecialFooOffer(); // get a special response that the requester wants
+ } else {
+ double qty = it->quantity();
+ std::string recipe = "some_other_recipe";
+ Material::Ptr offer = Material::CreateUntracked(qty, context()->GetRecipe(recipe));
+ }
+ port->AddBid(*it, offer, this);
+ }
+
+ std::set::Ptr> ports;
+ ports.insert(port);
+ return ports;
+ }
+
+
+**Python:**
+
+.. code-block:: python
+
+ import cyclus.typesystem as ts
+
+ def special_foo_offer(self):
+ recipe = self.context.get_recipe("recipe")
+ target = ts.Material.create_untracked(10, recipe)
+ return target
+
+ def get_material_bids(self, requests):
+ reqs = requests["FuelA"]
+ bids = []
+ for req in reqs:
+ if isinstance(req.requester, FooFac):
+ offer = self.special_foo_offer()
+ else:
+ qty = req.quantity
+ recipe = self.context.get_recipe("some_other_recipe")
+ offer = ts.Material.create_untracked(qty, recipe)
+ bids.append(req)
+ return {"bids": bids}
+
+
+.. _adj:
+
+Preference Adjustment Phase
+---------------------------
+In the Preference Adjustment (PA) phase, requesters are allowed to view which
+bids were matched to their requests, and adjust their preference for the given
+bid-request pairing. Querying is provided through the ``Agent`` interface, so all cyclus
+archetypes may adjust preferences. The "adjust prefs: functions are based on a given resource
+type, e.g. ``AdjustMaterialPrefs`` (C++) or ``adjust_material_prefs()`` (Python).
+
+Preferences are used by resource exchange solvers to inform their solution
+method. The default preference for all bids is zero. Agents will only utilize
+the PA phase if there is a reason to update preferences over the default
+provided in their original request.
+
+Preferences can be adjusted by both the original ``Trader`` placing
+requests as well as any parent ``Agent`` instances, with the trader adjusting
+first and the most senior parent adjusting last. In the supported
+Region-Institution-Facility agent relationship, Facilities adjust first,
+followed by Institution and Region parent agents. The calling chain is shown in
+Figure 1, with the orange box representing a call through the ``Trader``
+interface and a green box representing the ``Agent`` interface.
+
+.. figure:: dre-1.svg
+ :align: center
+ :height: 500
+
+ **Figure 1:** R-I-F Preference Adjustment Call Chain
+
+.. blockdiag code below
+
+ http://interactive.blockdiag.com/?compression=deflate&src=eJxtjTELAjEMRvf7FeEmHQQdDofqKriKu9Q2tMHSHDGHiNx_t1cVRBzz8j3eObG7eLIBHg0AC2FWq8QZttCzqFjS8sjs8XQjr7HwVbc0HxaRQtQC193EDhgmd7OAfb4q6aDvs91ZR4n0DrOjWI8yb01ThCA89LUN_zaFjz8rx4mlBIMg5kpeUfOdNFUcn5VaRHw
+
+ blockdiag {
+ orientation = portrait
+ node_width = 150;
+ node_height = 75;
+ Region <- Institution <- "Facility (Trader)";
+
+ group {
+ "Facility (Trader)"
+ }
+ group {
+ color = green
+ Region; Institution;
+ }
+ }
+
+
+Black Box Examples
+++++++++++++++++++
+For example, suppose that an agent prefers potential trades in which the bidder
+has the same parent agent as it does. A valid adjust material preferences implementation
+would then be:
+
+**C++:**
+
+.. code-block:: c++
+
+ virtual void FooFac::AdjustMatlPrefs(cyclus::PrefMap::type& prefs) {
+ cyclus::PrefMap::type::iterator pmit;
+ for (pmit = prefs.begin(); pmit != prefs.end(); ++pmit) {
+ std::map*, double>::iterator mit;
+ Request* req = pmit->first;
+ for (mit = pmit->second.begin(); mit != pmit->second.end(); ++mit) {
+ Bid* bid = mit->first;
+ if (parent() == bid->bidder()->manager()->parent())
+ mit->second += 1; // bump pref if parents are equal
+ }
+ }
+ }
+
+
+**Python:**
+
+.. code-block:: python
+
+ def adjust_material_prefs(self, prefs):
+ """The adjustment methods have a single argument which is a prefernce dictionary.
+ It maps (Request, Bid) tuples to float valued prefernces. For example::
+
+ prefs = {
+ (Request1, Bid1): 1.0,
+ (Request1, Bid2): 2.0,
+ (Request2, Bid3): 1.0,
+ }
+
+ This function may return None or a dictionary of the same form. Note that the
+ return value does not need to have all of the same keys as were passed in. Rather,
+ it can return only those request-bid pairs that it actually wants to update.
+ """
+ # If you don't want to do any prefernce adjustment, just return None.
+ return None
+
+ # Otherwise we can loop though and update those that matter.
+ updates = {}
+ for (req, bid), pref in prefs.items():
+ # favor bids if the parents are the same
+ if self.parent_id == bid.bidder.parent_id:
+ updates[req, bid] = pref + 1.0
+ return updates
+
+
+Alternatively, an ``Institution`` managing a ``Facility`` could
+adjust preferences as follows:
+
+**C++:**
+
+.. code-block:: c++
+
+ virtual void FooInst::AdjustMatlPrefs(cyclus::PrefMap::type& prefs) {
+ cyclus::PrefMap::type::iterator pmit;
+ for (pmit = prefs.begin(); pmit != prefs.end(); ++pmit) {
+ std::map*, double>::iterator mit;
+ Request* req = pmit->first;
+ for (mit = pmit->second.begin(); mit != pmit->second.end(); ++mit) {
+ Bid* bid = mit->first;
+ Agent* you = bid->bidder()->manager()->parent();
+ Agent* me = this;
+ if (me == you)
+ mit->second += 1; // bump pref if the parent is me (institutions are equal)
+ }
+ }
+ }
+
+
+**Python:**
+
+.. code-block:: python
+
+ def adjust_material_prefs(self, prefs):
+ updates = {}
+ for (req, bid), pref in prefs.items():
+ if self.id == bid.bidder.parent_id:
+ updates[req, bid] = pref + 1.0
+ return updates
+
+
+Finally, a ``Region`` managing a ``Institution`` could adjust
+preferences as
+
+**C++:**
+
+.. code-block:: c++
+
+ virtual void FooRegion::AdjustMatlPrefs(cyclus::PrefMap::type& prefs) {
+ cyclus::PrefMap::type::iterator pmit;
+ for (pmit = prefs.begin(); pmit != prefs.end(); ++pmit) {
+ std::map*, double>::iterator mit;
+ Request* req = pmit->first;
+ for (mit = pmit->second.begin(); mit != pmit->second.end(); ++mit) {
+ Bid* bid = mit->first;
+ Agent* you = bid->bidder()->manager()->parent()->parent();
+ Agent* me = this;
+ if (me == you)
+ mit->second += 1; // bump pref if the grandparent is me (regions are equal)
+ }
+ }
+ }
+
+
+**Python:**
+
+.. code-block:: python
+
+ def adjust_material_prefs(self, prefs):
+ updates = {}
+ for (req, bid), pref in prefs.items():
+ if self.id == bid.bidder.parent.parent_id:
+ updates[req, bid] = pref + 1.0
+ return updates
+
+
+
+White Box Examples
+++++++++++++++++++
+Consider a scenario in which preferences will only be adjusted if the requester
+and bidder are of the same type:
+
+**C++:**
+
+.. code-block:: c++
+
+ virtual void FooFac::AdjustMatlPrefs(cyclus::PrefMap::type& prefs) {
+ cyclus::PrefMap::type::iterator pmit;
+ for (pmit = prefs.begin(); pmit != prefs.end(); ++pmit) {
+ Request* req = pmit->first;
+ FooFac* cast = dynamic_cast(req->requester()->manager());
+ if (cast != NULL) {
+ for (mit = pmit->second.begin(); mit != pmit->second.end(); ++mit) {
+ mit->second = pref + 10; // we like this trader!
+ }
+ }
+ }
+ }
+
+
+**Python:**
+
+.. code-block:: python
+
+ def adjust_material_prefs(self, prefs):
+ updates = {}
+ for (req, bid), pref in prefs.items():
+ if not isinstance(req.requester, FooFac):
+ continue
+ updates[req, bid] = pref + 10.0 # we like this trader
+ return updates
+
+
+.. _solve:
+
+Solution Phase
+--------------
+The Solution Phase is straightforward from a module developer point of
+view. Given requests, bids for those requests, and preferences for each
+request-bid pairing, a ``ExchangeSolver`` selects request-bid pairs to
+satisfy and the quantity each resource to assign to each satisfied request-bid
+pairing. The solution times and actual pairings will depend on the concrete
+solver that is employed by the |cyclus| kernel.
+
+.. _trade:
+
+Trade Execution Phase
+---------------------
+When satisfactory request-bid pairings are determined, a final communication is
+executed for each bidder and requester during the Trade Execution Phase. Bidders
+are notified of their winning bids through the ``Trader`` "get trades"
+functions (e.g. ``GetMatlTrades()`` in C++ and ``get_material_trades()`` in Python),
+and requesters are provided their
+satisfied requests through the ``Trader`` "accept trades"
+functions (e.g. ``AcceptMatlTrades()`` in C++ and ``accept_material_trades()`` in Python).
+
+By convention in C++, traders can implement a ``TradeResponse()`` function that provides a
+``Material::Ptr`` given a ``Trade``. It can then implement its
+Trader interface as follows:
+
+**C++:**
+
+.. code-block:: c++
+
+ void FooFac::GetMatlTrades(const std::vector< cyclus::Trade >& trades,
+ std::vector, cyclus::Material::Ptr> >& responses) {
+ using cyclus::Material;
+ using cyclus::Trade;
+
+ std::vector< Trade >::const_iterator it;
+ for (it = trades.begin(); it != trades.end(); ++it) {
+ Material::Ptr mat = it->bid->offer();
+ Material::Ptr response = TradeResponse(mat);
+ responses.push_back(std::make_pair(*it, response));
+ }
+ }
+
+**Python:**
+
+.. code-block:: python
+
+ import cyclus.typesystem as ts
+
+ def get_material_trades(self, trades):
+ """In Python, the get trades functions take a single trades aregument and
+ should return a responses dict. The trades is list of Trade objects, see the
+ cyclus.typesystem docs for more information.
+
+ The reponses should be a dict whose keys are these trades and whose values
+ are tracked resource instances. For example, Materials.
+ """
+ # here we respond with what the trade request was.
+ responses = {}
+ for trade in trades:
+ mat = ts.Material.create(self, trade.amt, trade.request.target.comp())
+ responses[trade] = mat
+ return responses
+
+
+Similarly, Traders can implement an "accept trade" function that accepts a
+the resources from a ``Trade``. It can then implement its
+Trader interface as follows:
+
+**C++:**
+
+.. code-block:: c++
+
+ void FooFac::AcceptMatlTrades(const std::vector< std::pair, cyclus::Material::Ptr> >& responses) {
+ std::vector< std::pair, cyclus::Material::Ptr> >::const_iterator it;
+ for (it = responses.begin(); it != responses.end(); ++it) {
+ AcceptTrade(it->second);
+ }
+ }
+
+
+**Python:**
+
+.. code-block:: python
+
+ def accept_material_trades(self, responses):
+ """In the Python interface, this accepts a responses dict that has the same format as
+ the responses returned from get_material_trades() above. That is, responses maps
+ Trades to Materials. This function is responsible for storing these traded materails
+ somewhere in the agent's inventories. This is the end of the dynamic resource
+ exchange and so this function shouldn't return anything.
+ """
+ for mat in responses.values():
+ self.inventory.push(mat)
+
+
+The implementation logic for each of these functions is determined by how each
+individual agent handles their resource inventories. Accordingly, their
+implementation will be unique to each agent. Some initial examples can be found
+in the ``Source`` and ``Sink`` agents, where ``Source``
+implements ``GetMatlTrades()`` or ``get_material_trades()`` as a bidder and ``Sink``
+implements ``AcceptMatlTrades()`` or ``accept_material_trades()`` as a requester.
+
+.. _examples:
+
+Examples
+--------
+
+Mixin-based Trader Behavior [C++]
++++++++++++++++++++++++++++++++++
+
+.. note:: The Python interface can easily handle mix-in behavior for
+ Python agents via subclassing and using ``super()`` on any agent.
+
+Trader behavior can be specialized based on mixins that an archetype uses. For
+example, consider an interface that helps determines preferences based on
+the equality of the parent of a ``cyclus::Agent``.
+
+.. code-block:: c++
+
+ class PrefGetter {
+ public:
+ double GetPref(cyclus::Agent* mine, cyclus::Agent* yours) {
+ return (mine == yours) ? 1 : 0.5;
+ }
+ };
+
+A trader who then wants behavior based on whether a bidder's manager inherits
+from ``PrefGetter`` can then implement its preference adjustment as follows:
+
+.. code-block:: c++
+
+ virtual void FooFac::AdjustMatlPrefs(cyclus::PrefMap::type& prefs) {
+ cyclus::PrefMap::type::iterator pmit;
+ for (pmit = prefs.begin(); pmit != prefs.end(); ++pmit) {
+ std::map*, double>::iterator mit;
+ Request* req = pmit->first;
+ cyclus::Agent* reqagent = req->requester()->manager();
+ for (mit = pmit->second.begin(); mit != pmit->second.end(); ++mit) {
+ Bid* bid = mit->first;
+ cyclus::Agent* bidagent = bid->bidder()->manager();
+ PrefGetter* pg_cast = dynamic_cast(bidagent);
+ if (pg_cast != NULL) {
+ // special behavior for the mixin
+ mit->second = cast->GetPref(reqagent->parent(),
+ bidagent->parent());
+ } else {
+ mit->second = 0; // choose any (reasonable) default behavior
+ }
+ }
+ }
+ }
+
+.. warning::
+
+ Using a dynamic-checking approach will limit the interoperability of your
+ archetype with others. Some mixins are provided by the |Cyclus| kernel in its
+ :ref:`toolkit `, which is part of the core library.
+
+.. warning::
+
+ Using a mixin-based approach will require special implementation of restart
+ related functions *if* the mixin has state associated with it (i.e., members
+ that are initialized from an input file and/or stored from timestep to
+ timestep). For further reading, see the ``pragma cyclus impl`` directive in
+ :ref:`cycpp`.
+
+.. _white_box:
+
+Non-Black Box Behavior [C++]
+++++++++++++++++++++++++++++
+
+.. note:: The Python interface can trivially handle non-black box behavior for
+ Python agents by using ``isinstance()`` on any agent.
+
+Cyclus provides a simulation framework that supports black-box entity
+interaction, i.e., any entity in the simulation can interact with any other
+entity through its ``Agent`` interface. However, there is nothing
+stopping an archetype developer from implementing logic that is specific to a
+implemented archetype.
+
+For example, take a facility that informs a trader what composition of material
+it wants given another facility's inventory.
+
+.. code-block:: c++
+
+ class TradeInformer: public cyclus::Facility {
+ public:
+ #pragma cyclus
+
+ cyclus::Material::Ptr IdealMatl(const cyclus::toolkit::ResBuf& buffer) {
+ // provide whatever implementation is desired
+ }
+ };
+
+A provider of material can then implement its ``GetMatlBids`` as follows:
+
+.. code-block:: c++
+
+ virtual std::set::Ptr>
+ FooFac::GetMatlBids(
+ cyclus::CommodMap::type& commod_requests) {
+ using cyclus::BidPortfolio;
+ using cyclus::Material;
+ using cyclus::Request;
+ using cyclus::Agent;
+
+ // respond to all requests of my commodity
+ std::string my_commodity = "FuelA";
+ BidPortfolio::Ptr port(new BidPortfolio());
+ std::vector*>& requests = commod_requests[my_commodity];
+ std::vector*>::iterator it;
+ for (it = requests.begin(); it != requests.end(); ++it) {
+ Material::Ptr offer;
+ Agent* agent = it->requester();
+ TradeInformer* cast = dynamic_cast(agent);
+ if (cast != NULL) {
+ offer = cast->IdealMatl(inventory); // inventory is a state variable ResBuf
+ } else {
+ double qty = it->quantity();
+ std::string recipe = "recipe";
+ Material::Ptr offer = Material::CreateUntracked(qty, context()->GetRecipe(recipe));
+ }
+ port->AddBid(*it, offer, this);
+ }
+
+ std::set::Ptr> ports;
+ ports.insert(port);
+ return ports;
+ }
+
+Further Reading
+---------------
+For a more in depth (and historical) discussion, see `CEP 18
+`_.
diff --git a/_sources/arche/dynamic_loading.rst.txt b/_sources/arche/dynamic_loading.rst.txt
new file mode 100755
index 000000000..4220f94b1
--- /dev/null
+++ b/_sources/arche/dynamic_loading.rst.txt
@@ -0,0 +1,18 @@
+.. _dynamic_loading:
+
+Dynamic Loading Overview
+==========================
+
+*Dynamic loading* is a term used to describe the action of loading
+libraries at run time. This implies that knowledge of the structure
+of the classes in these libraries is not known at compile time to
+the executing program. In Linux, these libraries are denoted by the
+suffix '.so', in Windows, '.dll', and in OSX, '.dylib'.
+
+In |cyclus|, every *module* is dynamically loaded. Modules include one or more
+*agents*. Python moduels that contain archetypes are loaded dynamically by
+|cyclus|'s loading system, which itself call out to Python's import mechanism.
+
+The internal process used by the |cyclus| core is very close to that
+described in this
+`article `_.
diff --git a/_sources/arche/errors.rst.txt b/_sources/arche/errors.rst.txt
new file mode 100755
index 000000000..9d17ef2cc
--- /dev/null
+++ b/_sources/arche/errors.rst.txt
@@ -0,0 +1,148 @@
+Errors and Warnings [C++]
+=========================
+Module developers may also leverage the |Cyclus| error and warning system
+within the code that they write. These are useful for failing gracefully from
+undefined behavior or to signal that code is still experimental and under
+development.
+
+.. note:: Python agents should just use the Python error and warning system.
+
+Errors
+------
+
+|Cyclus| uses `standard C++ execptions
+ `_ to throw and catch
+errors. However, whenever you ``#include "cyclus.h"`` or ``#include
+"error.h"`` you have access to a suite of exceptions that the kernel itself
+knows about. :ref:`errors-table-1` displays all of the |Cyclus| errors which
+live within the ``cyclus`` namespace and subclass from ``std::exception``.
+
+.. rst-class:: centered
+
+.. _errors-table-1:
+
+.. table:: **Table I.** Cyclus Error Classes
+ :widths: 1 9
+ :column-alignment: left left
+ :column-wrapping: true true
+ :column-dividers: none single none
+
+ =============== ==============================================================
+ Error Description
+ =============== ==============================================================
+ Error Base error for |Cyclus|.
+ ValueError For values that are too big, too small, etc.
+ KeyError For failed retrieval/insertion of key-based data into/from
+ data structures.
+ StateError For failed object state expectations.
+ IOError For failed reading/writing to files, network connections, etc.
+ CastError For failed casts that shouldn't.
+ ValidationError For validating files received via I/O or for indicating that
+ the software has not been properly benchmarked.
+ =============== ==============================================================
+
+.. raw:: html
+
+
+
+For example, if a reactor finds itself with a negative flux in its ``Tock()``
+function then it could choose to throw either a ValueError or a StateError.
+If the flux happened to be a state variable a StateError would be more
+appropriate. This would be implemented as follows:
+
+**Error example:**
+
+.. code-block:: c++
+
+ void Reactor::Tock(int time) {
+ if (flux < 0.0)
+ throw cyclus::StateError("negative fluxes are impossible!");
+ }
+
+Warnings
+--------
+
+Along with errors, there are corresponding non-terminal warning messages that
+modules may issue. These print messages to ``sdterr`` along with the kind of
+warning that was given. All warnings are issued through the
+``cyclus::Warn()`` function. This functions is templated on the
+``cyclus::Warnings`` enum whose values and meanings may be seen in
+:ref:`errors-table-2`.
+
+.. rst-class:: centered
+
+.. _errors-table-2:
+
+.. table:: **Table II.** Cyclus Warnings
+ :widths: 3 7
+ :column-alignment: left left
+ :column-wrapping: true true
+ :column-dividers: none single none
+
+ =========================== =================================================
+ Warnings Description
+ =========================== =================================================
+ WARNING Basic warning for |Cyclus|.
+ VALUE_WARNING For values that are too big, too small, etc.
+ KEY_WARNING For unexpected retrieval/insertion of key-based
+ data into/from data structures.
+ STATE_WARNING For unexpected object state.
+ IO_WARNING For unexpected reading/writing to files, network
+ connections, etc.
+ CAST_WARNING For unexpected casts.
+ VALIDATION_WARNING For validating files received via I/O or for
+ indicating that the software has not been
+ properly benchmarked.
+ DEPRECATION_WARNING For features, behaviors, or APIs that are no
+ longer supported. Expect removal in future
+ releases.
+ PENDING_DEPRECATION_WARNING For features, behaviors, or APIs that are
+ candidates for future deprecation.
+ EXPERIMENTAL_WARNING For features, behaviors, or APIs that are not
+ considered stable. Reasons for instability may
+ include a lack of benchmarking, uncertainty about
+ future needs, or known future API changes.
+ =========================== =================================================
+
+.. raw:: html
+
+
+
+Revisiting the reactor error example from above, we could have issued a
+warning instead.
+
+**Warning example:**
+
+.. code-block:: c++
+
+ void Reactor::Tock(int time) {
+ if (flux < 0.0)
+ cyclus::Warn("negative fluxes are impossible!");
+ }
+
+Warnings have a number of advantages over errors. The first is that since
+they do not stop the process they are fast to issue. They are also a great way
+for communicating with users the expectations of using your module.
+
+Warnings also have two command line options that users can provide which
+modify their behavior. The first is ``--warn-limit``. This changes the
+maximum number of times a warning of each kind will be issued before further
+warnings are suppressed. This defaults to 1. A value of zero means to
+suppress all warnings and a very large number will print them all. For
+example, if the user wished to print the first 42 warnings of each kind they
+would call |cyclus| as follows:
+
+.. code-block:: bash
+
+ $ cyclus --warn-limit 42 ...
+
+The second command line argument that alters warning behavior is
+``--warn-as-error``. This turns all warnings into corresponding error types
+and throws the error. This is useful for ensuring that only stable code is
+executed or to help uncover what is causing a warning to be thrown. It takes
+no arguments:
+
+.. code-block:: bash
+
+ $ cyclus --warn-as-error ...
+
diff --git a/_sources/arche/hello_world_cpp.rst.txt b/_sources/arche/hello_world_cpp.rst.txt
new file mode 100755
index 000000000..33b887a44
--- /dev/null
+++ b/_sources/arche/hello_world_cpp.rst.txt
@@ -0,0 +1,130 @@
+.. _hello_world_cpp:
+
+Hello, Cyclus! [C++]
+====================
+This pages walks you through a very simple hello world example using
+|cyclus| agents. First make sure that you have the dependencies installed,
+namely |Cyclus|, CMake, and a recent version of Python (2.7 or 3.3+).
+
+First, you need to get the ``cycstub`` code. Cycstub is a skeleton code base
+that you can use to quick-start new |cyclus| module development projects.
+You can grab cycstub either by using git to
+`clone the repository `_ or by
+`downloading the zip file `_.
+Let's put this code in a ``tutorial`` directory and go into it.
+
+**Getting cycstub via git:**
+
+.. code-block:: bash
+
+ $ git clone https://github.com/cyclus/cycstub.git tutorial
+ $ cd tutorial
+
+**Getting cycstub via zip:**
+
+.. code-block:: bash
+
+ $ curl -L https://api.github.com/repos/cyclus/cycstub/zipball > tutorial.zip
+ $ unzip tutorial.zip
+ $ mv cyclus-cycstub-* tutorial
+ $ cd tutorial
+
+------------
+
+Since cycstub is a template project everything is named ``stub``. We need to
+change this to reflect the name we want our new project to be called -
+``tutorial`` here. Cycstub comes with a renaming tool to do just this! From
+the command line, run Python in the following way:
+
+.. code-block:: bash
+
+ tutorial $ python rename.py tutorial
+
+------------
+
+Let's now change the behavior of the TutorialFacility's ``Tick()`` &
+``Tock()`` member functions to print "Hello" and "World" respectively. To do
+this, please open up the :file:`src/tutorial_facility.cc` file in your
+favorite text editor (vim, emacs, gedit, `notepad++ `_).
+Change the original functions to look like:
+
+**Original Tick() and Tock() in src/tutorial_facility.cc:**
+
+.. code-block:: c++
+
+ void TutorialFacility::Tick() {}
+
+ void TutorialFacility::Tock() {}
+
+**New Tick() and Tock() in src/tutorial_facility.cc:**
+
+.. code-block:: c++
+
+ void TutorialFacility::Tick() {std::cout << "Hello, ";}
+
+ void TutorialFacility::Tock() {std::cout << "World!\n";}
+
+------------
+
+Now that we have altered the behavior of the TutorialFacility, let's compile and
+install the ``tutorial`` project. This done with the install.py script.
+The install script puts the project into your cyclus userspace,
+``${HOME}/.local/lib/cyclus``.
+
+.. code-block:: bash
+
+ tutorial $ python install.py
+
+------------
+
+Let's run |cyclus| with the TutorialFacility! In the input directory there is
+an :file:`example.xml`. Running |cyclus| on this file with the command
+``cyclus input/example.xml`` should produce the following output.
+
+.. code-block:: bash
+
+ tutorial $ cyclus input/example.xml
+ :
+ .CL:CC CC _Q _Q _Q_Q _Q _Q _Q
+ CC;CCCCCCCC:C; /_\) /_\)/_/\\) /_\) /_\) /_\)
+ CCCCCCCCCCCCCl __O|/O___O|/O_OO|/O__O|/O__O|/O____________O|/O__
+ CCCCCCf iCCCLCC /////////////////////////////////////////////////
+ iCCCt ;;;;;. CCCC
+ CCCC ;;;;;;;;;. CClL. c
+ CCCC ,;; ;;: CCCC ; : CCCCi
+ CCC ;; ;; CC ;;: CCC` `C;
+ lCCC ;; CCCC ;;;: :CC .;;. C; ; : ; :;;
+ CCCC ;. CCCC ;;;, CC ; ; Ci ; : ; : ;
+ iCC :; CC ;;;, ;C ; CC ; : ; .
+ CCCi ;; CCC ;;;. .C ; tf ; : ; ;.
+ CCC ;; CCC ;;;;;;; fC : lC ; : ; ;:
+ iCf ;; CC :;;: tC ; CC ; : ; ;
+ fCCC :; LCCf ;;;: LC :. ,: C ; ; ; ; ;
+ CCCC ;; CCCC ;;;: CCi `;;` CC. ;;;; :;.;. ; ,;
+ CCl ;; CC ;;;; CCC CCL
+ tCCC ;; ;; CCCL ;;; tCCCCC.
+ CCCC ;; :;; CCCCf ; ,L
+ lCCC ;;;;;; CCCL
+ CCCCCC :;; fCCCCC
+ . CCCC CCCC .
+ .CCCCCCCCCCCCCi
+ iCCCCCLCf
+ . C. ,
+ :
+ Hello, World!
+ Hello, World!
+ Hello, World!
+ Hello, World!
+ Hello, World!
+ Hello, World!
+ Hello, World!
+ Hello, World!
+ Hello, World!
+ Hello, World!
+
+ Status: Cyclus run successful!
+ Output location: cyclus.sqlite
+ Simulation ID: 0ae730e0-a9a8-4576-afaa-d1db6399d5a2
+
+If you look in the input file you'll see that the simulation duration was set
+to 10. This is why "Hello, World!" is printed ten times.
diff --git a/_sources/arche/hello_world_py.rst.txt b/_sources/arche/hello_world_py.rst.txt
new file mode 100755
index 000000000..2e6c4a2dd
--- /dev/null
+++ b/_sources/arche/hello_world_py.rst.txt
@@ -0,0 +1,130 @@
+.. _hello_world_py:
+
+Hello, Cyclus! [Python]
+=======================
+This pages walks you through a very simple hello world example using
+|cyclus| agents. First make sure that you have the dependencies installed,
+namely |Cyclus| and a recent version of Python (2.7 or 3.5+).
+
+|Cyclus| can read agents from any normal python package and module. If you are unsure of
+how to start and install a Python project, please see the Python documentation. There are
+also many high-quality guides and tools online. Here, we will assume that there is a
+project called ``proj`` that has a module called ``agents`` that contains an archetype
+class called ``MyFacility``.
+
+To start writing ``MyFacility``, open up ``agents.py``, import ``cyclus.agents``,
+anf write the following:
+
+**proj/agents.py:**
+
+.. code-block:: Python
+
+ from cyclus.agents import Facility
+
+ class MyFacility(Facility):
+ """My first Cyclus archetype!"""
+
+
+And that is it! The above is a fully-functional |Cyclus| facility.
+
+------------
+
+Let's now change the behavior of the ``MyFacility``'s ``tick()`` and
+``tock()`` methods to print "Hello" and "World" respectively.
+
+**proj/agents.py:**
+
+.. code-block:: Python
+
+ from cyclus.agents import Facility
+
+ class MyFacility(Facility):
+ """My first Cyclus archetype!"""
+
+ def tick(self):
+ print("Hello,")
+
+ def tock(self):
+ print("World!")
+
+
+Now that we have altered the behavior of ``MyFacility``, reinstall the project
+so that it is available to cyclus.
+
+------------
+
+You can refer to this facility in a |cyclus| input file by using the Python package and
+module name in the lib section of the archetypes spec, like you would write it if you
+were importing a module. The class name goes in the
+name section of the spec.
+
+.. code-block:: xml
+
+
+ proj.agents MyFacility
+
+
+------------
+
+Let's run |cyclus| with this example! In the input directory there is
+an :file:`example.xml`. First modify it to point to the archetype we just wrote.
+Running |cyclus| on this file with the command
+``cyclus input/example.xml`` should produce the following output.
+
+.. code-block:: bash
+
+ tutorial $ cyclus input/example.xml
+ :
+ .CL:CC CC _Q _Q _Q_Q _Q _Q _Q
+ CC;CCCCCCCC:C; /_\) /_\)/_/\\) /_\) /_\) /_\)
+ CCCCCCCCCCCCCl __O|/O___O|/O_OO|/O__O|/O__O|/O____________O|/O__
+ CCCCCCf iCCCLCC /////////////////////////////////////////////////
+ iCCCt ;;;;;. CCCC
+ CCCC ;;;;;;;;;. CClL. c
+ CCCC ,;; ;;: CCCC ; : CCCCi
+ CCC ;; ;; CC ;;: CCC` `C;
+ lCCC ;; CCCC ;;;: :CC .;;. C; ; : ; :;;
+ CCCC ;. CCCC ;;;, CC ; ; Ci ; : ; : ;
+ iCC :; CC ;;;, ;C ; CC ; : ; .
+ CCCi ;; CCC ;;;. .C ; tf ; : ; ;.
+ CCC ;; CCC ;;;;;;; fC : lC ; : ; ;:
+ iCf ;; CC :;;: tC ; CC ; : ; ;
+ fCCC :; LCCf ;;;: LC :. ,: C ; ; ; ; ;
+ CCCC ;; CCCC ;;;: CCi `;;` CC. ;;;; :;.;. ; ,;
+ CCl ;; CC ;;;; CCC CCL
+ tCCC ;; ;; CCCL ;;; tCCCCC.
+ CCCC ;; :;; CCCCf ; ,L
+ lCCC ;;;;;; CCCL
+ CCCCCC :;; fCCCCC
+ . CCCC CCCC .
+ .CCCCCCCCCCCCCi
+ iCCCCCLCf
+ . C. ,
+ :
+ Hello,
+ World!
+ Hello,
+ World!
+ Hello,
+ World!
+ Hello,
+ World!
+ Hello,
+ World!
+ Hello,
+ World!
+ Hello,
+ World!
+ Hello,
+ World!
+ Hello,
+ World!
+ Hello,
+ World!
+
+ Status: Cyclus run successful!
+ Output location: cyclus.sqlite
+ Simulation ID: 0ae730e0-a9a8-4576-afaa-d1db6399d5a2
+
+If you look in the input file you'll see that the simulation duration was set
+to 10. This is why "Hello, World!" is printed ten times.
diff --git a/_sources/arche/index.rst.txt b/_sources/arche/index.rst.txt
new file mode 100755
index 000000000..62cce1128
--- /dev/null
+++ b/_sources/arche/index.rst.txt
@@ -0,0 +1,123 @@
+|Cyclus| Archetype Developer Guide
+===================================
+
+.. raw:: html
+
+
+
+
+.. image:: /astatic/antipode-bike.jpg
+ :align: center
+ :width: 300px
+ :alt: http://www.polyvore.com/cgi/img-thing?.out=jpg&size=l&tid=9361427
+
+.. raw:: html
+
+
+
+Welcome!
+
+You are here because you have made (or are making) the transition from wanting
+to run simulations to wanting to dig in and start dictating agent logic and
+behavior on a more fundamental level. Perhaps existing archetypes are
+insufficient for your needs, perhaps you are curious as to how it all works, or
+are a devilishly handsome thrill-seeker. Whatever your reasons, you have come
+to the right place!
+
+This guide assumes that you have |cyclus| installed, are familiar with running
+simulations and understand user-level concepts.
+
+To get started please follow the instructions in :doc:`hello_world_cpp`.
+
+.. raw:: html
+
+
+
+
+Installation
+-------------
+
+.. toctree::
+ :maxdepth: 1
+
+ ../user/install
+
+Hello World
+-----------------
+
+.. toctree::
+ :maxdepth: 1
+
+ hello_world_cpp
+ tour_cpp
+ hello_world_py
+
+
+Writing Agents & Modules
+------------------------
+
+Tutorial
+++++++++
+
+.. toctree::
+ :maxdepth: 1
+
+ tutorial_cpp/index
+ tutorial_py/index
+
+Building, Installing and Testing [C++]
+++++++++++++++++++++++++++++++++++++++
+
+.. toctree::
+ :maxdepth: 1
+
+ cmake
+ cycpp
+ testing
+
+Interfacing with the |Cyclus| Kernel
+++++++++++++++++++++++++++++++++++++
+
+.. toctree::
+ :maxdepth: 1
+
+ timestep
+ resources
+ dre
+ dbtypes
+ custom_tables
+ errors
+ logger
+ cli
+
+A Word About Style
+++++++++++++++++++
+Having a consistent style in your code is important. Python has a great style
+guide encapsulated in `PEP8 `_. As
+our code base is mostly C++, the kernel development team follows the `Google C++
+Style Guide `_
+(GCSG) as closely as possible, and we invite you to as well! A notable (and
+required) exception to the GCSG used in |Cyclus| and Cycamore :term:`archetypes
+` is the use of preprocessor-aware private member variables without a
+trailing underscore, due to consistency requirements across input files,
+implementation, and databases. Happy (well-styled) coding!
+
+Under the Hood
+------------------------------
+
+.. toctree::
+ :maxdepth: 1
+
+ sim_init
+ dynamic_loading
+ decay
+.. cyclus_env
+.. materials_and_isotopes
+
+|Cyclus| Toolkit
+----------------
+
+.. toctree::
+ :maxdepth: 1
+
+ toolkit
diff --git a/_sources/arche/logger.rst.txt b/_sources/arche/logger.rst.txt
new file mode 100755
index 000000000..487d4bca7
--- /dev/null
+++ b/_sources/arche/logger.rst.txt
@@ -0,0 +1,96 @@
+.. _logging:
+
+Logging
+=======================
+
+.. code-block:: bash
+
+ LOG(LogLevel level, std::string prefix)
+
+Built-in logging functionality has been provided to aid debugging. To use the
+logger, you must include the *Logger.h* header file. `std::cout` statements
+should be generally avoided. The `LOG(level, prefix)` macro should be used
+for all logging/debugging needs. The LOG macro uses the Logger class to
+provide this functionality. The Logger class should generally not be accessed
+directly. The macro returns a string stream object that can be used exactly
+as `std::cout` for printing output. Streamed in content is flushed to stdout
+as soon as execution passes beyond the terminating semi-colon of the log
+statement.
+
+A brief description of when to use which log level is given with the LogLevel
+enum doxygen documentation. The following is a summary:
+
+ * LEV_ERROR: Use for errors that require model code or input file
+ modification/fixing (use extremely sparingly)
+
+ * LEV_WARN: Use to report questionable simulation state (use extremely
+ sparingly)
+
+ * LEV_INFO1: Information helpful for simulation users and developers alike -
+ least verbose.
+
+ * LEV_INFO[2, 3, 4]
+
+ * LEV_INFO5: Information helpful for simulation users and developers alike -
+ most verbose.
+
+ * LEV_DEBUG1: debugging information - least verbose
+
+ * LEV_DEBUG[2, 3, 4]
+
+ * LEV_DEBUG5: debugging information - most verbose
+
+Developers working on agents set the LOG prefix argument to a unique
+archetype/agent-specific identifier (up to 6 characters long). This will allow
+developers to more easily filter the logger output in order to isolate
+information most relevant to their work.
+
+This macro does a check on the given LogLevel 'level' argument; if the
+specified level is not higher than or equal to the report-level cutoff, the
+macro does nothing, limiting the performance impact of logging statements.
+
+.. warning::
+
+ Do NOT place any state-changing expressions with the LOG
+ macro as they may not run if the report level excludes the specified LogLevel.
+
+.. note:: The Python interface should use the Python standard library logging system.
+
+Examples
+--------
+
+.. code-block:: cpp
+
+ #include "Logger.h"
+
+ void myfunc() {
+
+ LOG(LEV_ERROR, "prefix") << "This is my error statement. "
+ << "and more info...";
+
+ LOG(LEV_DEBUG2, "prefix") << "This is my first debug statement. "
+ << "and more info...";
+ LOG(LEV_DEBUG1, "prefix") << "This is another debug statement. "
+ << "and more info...";
+ }
+
+The command-line specified verbosity is used to determine the logger
+report-cutoff. Available levels are described in the LogLevel enum. In the
+above example if the command line verbosity were set to *LEV_DEBUG1*, the
+first and third statements would print, while the second would not. Output
+would be something like this::
+
+ ERROR (prefix): This is my error statement. and more info...
+ DEBUG1(prefix): This is another debug statement. and more info...
+
+Any expression placed with a log statement that is not printed will not be
+executed. An example of what NOT to do follows:
+
+.. code-block:: cpp
+
+ LOG(LEV_DEBUG2, "module name") << "The expression myobject.setName(newname): "
+ << myobject.setName(newname)
+ << " might not ever execute"
+ << " depending on the verbosity level.";
+
+
diff --git a/_sources/arche/resources.rst.txt b/_sources/arche/resources.rst.txt
new file mode 100755
index 000000000..cf3ff36f4
--- /dev/null
+++ b/_sources/arche/resources.rst.txt
@@ -0,0 +1,392 @@
+Resources
+==========
+
+One of the defining features of |Cyclus| among other fuel cycle simulators is
+the treatment of resources/materials as discrete, quantized objects that can
+be traded and tracked throughout the simulation.
+
+A primary motivation for discrete and quantized materials is the ability to
+study the flow of material and the attribution of those materials through
+prior ownership. One example is that of a nuclear fuel assembly. A nuclear
+fuel assembly for a given reactor has a clear definition of material
+properties (including mass) can be treated as a single unit.
+
+The |Cyclus| core provides two types of Resources that can be used/manipulated
+by agents:
+
+* Material - a generic material object comprised of a mass and nuclide
+ composition.
+
+* Product - a general resource comprised of a quantity of a custom specified
+ quality/units.
+
+Conceptually, a resource can be anything that might be an interesting traded
+item (e.g., electricity, money, or workers). By default, all changes to
+resource objects (including creation) are tracked and recorded in the
+database. Because of this, agents should handle resources carefully. For
+more details about this, see :ref:`tracked-untracked`.
+
+In C++, all resource objects are created and managed as pointer types. For
+convenience, each of the classes related to resources have a special pointer
+type defined. In Python, they each have their own class that this available
+in the ``cyclus.typesystem`` module.
+
+**C++:**
+
+.. code-block:: c++
+
+ cyclus::Resource::Ptr r;
+ cyclus::Product::Ptr p;
+ cyclus::Material::Ptr m;
+
+**Python:**
+
+.. code-block:: python
+
+ import cyclus.typesystem as ts
+ ts.Resource
+ ts.Product
+ ts.Material
+
+These pointer types should be always be used instead of plain class instances
+or raw pointers. The following sections describe basic creation and
+manipulation of resource objects. The |Cyclus| kernel deals with resources in
+terms of the ``cyclus::Resource`` superclass. So it will sometimes be
+necessary to cast down to the appropriate resource subclass. |Cyclus| provides
+an overloaded ResCast function for casting convenience:
+
+**C++:**
+
+.. code-block:: c++
+
+ // r is a Material object stored in a cyclus::Resource::Ptr var
+ cyclus::Material::Ptr m = cyclus::ResCast(r);
+
+ // ResCast works on vectors too
+ std::vector rs;
+ ...
+ std::vector ps = cyclus::ResCast(rs);
+
+In Python, the situation is much simpler and you should only need to use ``Product`` and
+``Material`` directly. They both inherit from ``Resource``.
+
+
+Product Resources
+-------------------
+
+Products in |Cyclus| have a quantity (no particular units) and a quality.
+The quality is a ``std::string`` (C++) or ``str`` (Python) that describes what
+the product is. A product's quality might be "apples", "kg apples", etc. Product
+resources with different qualities may NOT be combined together.
+
+There are 3 basic operations that can be performed on product resources
+(examples follow):
+
+* Create
+* Extract
+* Absorb
+
+**C++:**
+
+.. code-block:: c++
+
+ // create a "grapes" product holding 100 grapes.
+ cyclus::Product::Ptr p1 = cyclus::Product::Create(this, 100, "grapes");
+
+ // extract 7 grapes from p1
+ cyclus::Product::Ptr p2 = p1->Extract(7);
+ // p1 now has 93 grapes
+
+ // combine p2 back into p1
+ p1->Absorb(p2);
+ // p2 now has 0 grapes. p1 has 100 grapes.
+
+
+**Python:**
+
+.. code-block:: python
+
+ # create a "grapes" product holding 100 grapes.
+ p1 = ts.Product.create(100, "grapes")
+
+ # extract 7 grapes from p1
+ p2 = p1.extract(7)
+ # p1 now has 93 grapes
+
+ # combine p2 back into p1
+ p1.absorb(p2)
+ # p2 now has 0 grapes. p1 has 100 grapes.
+
+
+Material Resources
+-------------------
+Materials in |Cyclus| have a mass and an associated nuclide composition. The
+composition is represented by a ``cyclus::Composition`` object (C++) or dict of
+nuclide keys (str or int), float values (Python). Material
+quantity is always represented in units of kg. Agents can either create a
+composition manually (see the *Compositions* section below) or acquire one from
+their Context which holds all recipes defined as part of the
+simulation input.
+
+There are 4 basic operations that can be performed on material resources
+(examples follow):
+
+* Create
+* Extract [Qty/Comp]
+* Absorb
+* Transmute
+* Decay (EXPERIMENTAL) - which is a special case of the Transmute operation
+
+**C++:**
+
+.. code-block:: c++
+
+ cyclus::Composition::Ptr c1 = context()->GetRecipe("nat_u");
+ cyclus::Composition::Ptr c2 = context()->GetRecipe("enriched_u");
+
+ // create a 100 kg material from the nat_u recipe defined in the input file
+ cyclus::Material::Ptr m1 = cyclus::Material::Create(this, 100, c1);
+
+ // extract 1 kg of enriched U from m1
+ cyclus::Material::Ptr m2 = m1->ExtractComp(1, c2);
+ // mass of m1 is now 99 kg and its composition has changed
+
+ // extract 1 kg from m1 of whatever composition it is
+ cyclus::Material::Ptr m3 = m1->ExtractQty(1);
+ // mass of m1 is now 98 kg and its composition. m1 and m3 have the same composition
+
+ // combine m2 and m3 back into m1
+ m1->Absorb(m2);
+ m1->Absorb(m3);
+ // m2 and m3 now have mass 0 kg. m1 has mass 100 kg with its original nat_u composition
+
+ // decay composition m1 up to the current time step (EXPERIMENTAL)
+ m1->Decay(); // EXPERIMENTAL
+
+**Python:**
+
+.. code-block:: python
+
+ c1 = self.context.get_recipe("nat_u")
+ c2 = self.context.get_recipe("enriched_u")
+
+ # create a 100 kg material from the nat_u recipe defined in the input file
+ m1 = ts.Material.create(self, 100, c1)
+
+ # extract 1 kg of enriched U from m1
+ m2 = m1.extract_comp(1, c2)
+ # mass of m1 is now 99 kg and its composition has changed
+
+ # extract 1 kg from m1 of whatever composition it is
+ m3 = m1.ExtractQty(1)
+ # mass of m1 is now 98 kg and its composition. m1 and m3 have the same composition
+
+ # combine m2 and m3 back into m1
+ m1.absorb(m2)
+ m1.absorb(m3)
+ # m2 and m3 now have mass 0 kg. m1 has mass 100 kg with its original nat_u composition
+
+ # decay composition m1 up to the current time step (EXPERIMENTAL)
+ m1.decay() # EXPERIMENTAL
+
+
+.. warning::
+
+ Decay functionality as currently implemented is experimental and may not
+ be correct.
+
+Compositions in C++
+++++++++++++++++++++
+
+A ``cyclus::Composition`` is a massless, immutable nuclide composition.
+Because it is immutable, a mutable ``cyclus::CompMap`` must be populated in
+order to create a composition:
+
+**C++:**
+
+.. code-block:: c++
+
+ cyclus::CompMap m;
+ m[922350000] = 5;
+ m[922380000] = 95;
+
+ // 5% U235, 95% U238 by mass
+ cyclus::Composition::Ptr c1 = cyclus::Composition::CreateFromMass(m);
+
+ // 5% U235, 95% U238 by atom fraction
+ cyclus::Composition::Ptr c2 = cyclus::Composition::CreateFromAtom(m);
+
+Note that the ``cyclus::CompMap`` above has no notion of mass. Only the
+relative nuclide ratios matter. Also notable is that ``c1`` and ``c2`` in the
+above example have different compositions.
+
+Because compositions are immutable, it is desirable for performance and
+database space reasons to avoid as much as possible creating multiple
+compositions from equivalent ``cyclus::CompMap`` objects. Reusing
+``cyclus::Composition`` objects helps avoid duplicate records in the
+database and redundant decay calculations.
+
+
+Compositions in Python
++++++++++++++++++++++++
+Compositions in Python are much simplier than in C++. They are represented by a simple
+dict of nuclides to values. When a Material is created, you have to declare whether
+the composition has a mass or atom basis. By default it has a mass basis, though
+you may pass in the string ``"atom"`` to obtain an atom basis.
+
+**Python:**
+
+.. code-block:: python
+
+ # 5% U235, 95% U238 by mass
+ m = {922350000: 5, 922380000: 95}
+ mat_mass = ts.Material.create_untracked(10, m)
+
+ # 5% U235, 95% U238 by atom fraction
+ a = {"U235": 5, "U238": 95}
+ mat_atom = ts.Material.create_untracked(10, a, basis="atom")
+
+
+.. _resource-ids:
+
+Resource IDs
+---------------
+Every resource object has 3 different IDs. One of them, the ``qual_id``, is
+generally not of use to agent developers and can be ignored. The other two
+serve two different purposes, and it is important to understand their
+difference:
+
+* ``state_id``: A unique identifier associated with the entire state of the
+ resource object. Any time a resource's state changes in any way (mass,
+ composition, etc.) this ID will be updated to a new, unique value
+ associated with the new state. When recording resource-related information
+ to the database in custom tables, this ID should generally be used.
+
+* ``obj_id``: A unique identifier associated with the resource object
+ instance. This ID does not ever change for the life of a resource instance.
+ Only newly created resource objects get new obj_id's. This ID should be
+ used when using resources as std::map keys and in other data structures when
+ resource objects need to be associated with some other information.
+
+Here are some examples of how these IDs work:
+
+**C++:**
+
+.. code-block:: c++
+
+ cyclus::Product::Ptr p1 = cyclus::Product::Create(this, 10, "bananas");
+ // p1 gets new separate state_id and obj_id
+
+ cyclus::Product::Ptr p2 = p1->ExtractQty(3);
+ // p1 gets new state_id and keeps same obj_id
+ // p2 gets new separate state_id and obj_id
+
+ p1->Absorb(p2);
+ // p1 gets new state_id and keeps same obj_id
+ // p2 gets new state_id and keeps same obj_id
+
+ cyclus::Product::Ptr p1_dup = p1;
+ // no new resource object is created, p1 and p1_dup point to same resource object
+ // p1 keeps same state_id and same obj_id
+ // p1 and p1_dup have idential state_id's
+ // p1 and p1_dup have idential obj_id's
+
+ // want to associate some label with resource objects? - use the obj_id:
+ std::map rsrc_labels;
+ rsrc_labels[p1->obj_id()] = "fruit";
+ rsrc_labels[p2->obj_id()] = "fruit";
+ ...
+
+**Python:**
+
+.. code-block:: python
+
+ # p1 gets new separate state_id and obj_id
+ p1 = ts.Product.create(self, 10, "bananas")
+
+ # p1 gets new state_id and keeps same obj_id
+ # p2 gets new separate state_id and obj_id
+ p2 = p1.extract_qty(3)
+
+ # p1 gets new state_id and keeps same obj_id
+ # p2 gets new state_id and keeps same obj_id
+ p1.absorb(p2)
+
+ # no new resource object is created, p1 and p1_dup point to same resource object.
+ # In Python this is just an increase in the refcount anyway.
+ # p1 keeps same state_id and same obj_id
+ # p1 and p1_dup have idential state_id's
+ # p1 and p1_dup have idential obj_id's
+ p1_dup = p1
+
+ # want to associate some label with resource objects? Use the obj_id.
+ rsrc_labels = {}
+ rsrc_labels[p1.obj_id] = "fruit"
+ rsrc_labels[p2.obj_id] = "fruit"
+ ...
+
+.. warning::
+
+ When associating information with resources like the ``rsrc_labels``
+ example above, you should **NEVER** use pointers (e.g.
+ ``std::map``). Pointers are unstable
+ and change across simulation snapshot+restart.
+
+
+.. _tracked-untracked:
+
+Tracked and Untracked Resources
+---------------------------------
+All changes to normal resource objects (including creation, splitting,
+trasmutation, etc.) are tracked and recorded in the database. By default, all
+resources are **tracked resources**. Because of this, agents should handle
+resources carefully, being conscious of mass conservation among other things.
+Anything done with resources is recorded in the database as having *actually*
+happened in the simulation. If a new resource is created, it is instantly
+recorded in the database as being a part of an agent's real/actual inventory.
+Placeholder or "dummy" resources can also be created if necessary. No
+information about these resources is recorded in the simulation database and
+they are referred to as **untracked resources**. An agent's most common (and
+likely only) need for untracked resources occurs when communicating details
+about a desired/available resources for requests/bids during resource
+exchange. Here untracked resources fulfill a communication roll only.
+
+Just like the functions for creating trakced resources, there are
+corresponding function for creating both untracked materials and untracked
+products:
+
+**C++:**
+
+.. code-block:: c++
+
+ cyclus::Composition::Ptr c = context()->GetRecipe("enriched_u");
+
+ // create an untracked 100 kg material from c (the enriched_u recipe)
+ cyclus::Material::Ptr m1 = cyclus::Material::CreateUntracked(100, c);
+
+ // create an untracked "grapes" product holding 100 grapes.
+ cyclus::Product::Ptr p1 = cyclus::Product::CreateUntracked(100, "grapes");
+
+ // nothing about m1 and p1 will ever be recorded in the output data.
+
+
+**Python:**
+
+.. code-block:: python
+
+ c = self.context.get_recipe("enriched_u")
+
+ # create an untracked 100 kg material from c (the enriched_u recipe)
+ m1 = ts.Material.create_untracked(100, c)
+
+ # create an untracked "grapes" product holding 100 grapes.
+ p1 = ts.Product.create_untracked(100, "grapes")
+
+ # nothing about m1 and p1 will ever be recorded in the output data.
+
+.. warning::
+
+ When a need for placeholder, dummy, or otherwise untracked
+ resource arises, use "untracked" resources. Do NOT create tracked
+ resources to use in resource exchange requests and bids.
+
diff --git a/_sources/arche/sim_init.rst.txt b/_sources/arche/sim_init.rst.txt
new file mode 100755
index 000000000..c9e09d0de
--- /dev/null
+++ b/_sources/arche/sim_init.rst.txt
@@ -0,0 +1,42 @@
+Initialization and Restart
+============================
+|Cyclus| has built-in functionality for simulation snapshotting and restart.
+All simulations are initialized from the database. In order to support
+running from XML input files, the |Cyclus| kernel translates the input file
+contents into the database and then initializes the simulation from the
+database. In order for this to work correctly, agents must be able to record
+the entirety of their internal state to the database and able to restore that
+state exactly. The ``cyclus::Agent`` class provides a group of functions in
+support of this functionality that must all be implemented carefully and
+consistently. If possible, the :doc:`Cyclus preprocessor ` should be
+used to automate the generation of code for the following functions:
+
+.. code-block:: c++
+
+ void InfileToDb(InfileTree* tree, DbInit di);
+ void InitFrom(cyclus::QueryableBackend*);
+ void InitInv(cyclus::Inventories& invs);
+ cyclus::Inventories SnapshotInv();
+ void Snapshot(cyclus::Agent*);
+ std::string schema();
+ Json::Value annotations();
+ cyclus::Agent* Clone();
+ void InitFrom(cyclus::Agent*);
+
+When the preprocessor isn't sufficient, read the `API documents
+`_ for the functions
+listed above VERY CAREFULLY. There are also a few other functions related to
+initialization that are important to understand well:
+
+.. code-block:: c++
+
+ void Build(cyclus::Agent* parent);
+ void EnterNotify();
+ void BuildNotify(cyclus::Agent* child);
+ void Decommission(cyclus::Agent* child);
+
+.. warning::
+
+ The functions mentioned on this page (except ``void InitFrom(cyclus::Agent*)``)
+ should NEVER be invoked directly by agents.
+
diff --git a/_sources/arche/testing.rst.txt b/_sources/arche/testing.rst.txt
new file mode 100755
index 000000000..49aed51c5
--- /dev/null
+++ b/_sources/arche/testing.rst.txt
@@ -0,0 +1,373 @@
+
+.. _testing:
+
+Testing and Debugging Archetypes
+================================
+
+Overview
+--------
+
+Writing `unit tests `_ for your
+module is a prerequisite for its addition to any |cyclus| library, but it's
+really a `good idea anyway
+`_.
+
+|cyclus| makes use of the `Google Test
+ `_ framework. The `primer
+`_ is recommended as an
+introduction to the fundamental concepts of unit testing with Google Test.
+Seriously, if you're unfamiliar with unit testing or Google Test, check out
+the primer.
+
+Unit Tests Out of the Box
+-------------------------
+
+The |cyclus| dev team provides a number of unit tests for free (as in
+beer). Really! You can unit test your :term:`archetype` immediately to confirm
+some basic functionality with the :term:`cyclus kernel`. We provide basic unit
+tests for any class that inherits from one of:
+
+* ``cyclus::Agent``
+* ``cyclus::Facility``
+* ``cyclus::Institution``
+* ``cyclus::Region``
+
+Note that ``cyclus::Agent`` is the base class for any object that acts as an
+:term:`agent` in the simulation, so every archetype can invoke those unit tests.
+
+In order to get the provided unit tests in your archetype's tests, a few extra
+lines must be added to your ``*_tests.cc`` file. For instance, the
+``TutorialFacility`` in the :ref:`hello_world_cpp` example with the file structure
+outline in :ref:`cmake_build` adds the following lines to
+``tutorial_facility_tests.cc`` to get all of the free ``cyclus::Agent`` and
+``cyclus::Facility`` unit tests: ::
+
+ #include "tutorial_facility.h"
+ #include "facility_tests.h"
+ #include "agent_tests.h"
+
+ #ifndef CYCLUS_AGENT_TESTS_CONNECTED
+ int ConnectAgentTests();
+ static int cyclus_agent_tests_connected = ConnectAgentTests();
+ #define CYCLUS_AGENT_TESTS_CONNECTED cyclus_agent_tests_connected
+ #endif // CYCLUS_AGENT_TESTS_CONNECTED
+
+ cyclus::Agent* TutorialFacilityConstructor(cyclus::Context* ctx) {
+ return new TutorialFacility(ctx);
+ }
+
+ INSTANTIATE_TEST_CASE_P(TutorialFac, FacilityTests,
+ ::testing::Values(&TutorialFacilityConstructor));
+
+ INSTANTIATE_TEST_CASE_P(TutorialFac, AgentTests,
+ ::testing::Values(&TutorialFacilityConstructor));
+
+The above lines can be specialized to your case by replacing ``TutorialFac`` with
+an appropriate moniker (anything that uniquely identifies your unit test
+name). Also, if you're subclassing from ``cyclus::Institution`` or
+``cyclus::Region``, replace all instances of facility in the above example with
+the institution or region, respectively.
+
+Unit Test Example
+-----------------
+
+Now we will provide an example of a very simple :term:`archetype` that keeps
+track of how many :term:`ticks ` it has experienced. We'll call it
+``TickTracker``.
+
+This tutorial assumes that you have a directory setup like that described in
+:ref:`hello_world_cpp`, namely that there is a `src` directory in which
+:term:`archetype` source files are housed and a `install.py` file that will
+install them on your system.
+
+Make a file called ``tick_tracker.h`` in the ``src`` directory that has the
+following lines:
+
+.. code-block:: cpp
+
+ #include "cyclus.h"
+
+ class TickTracker : public cyclus::Facility {
+ public:
+ TickTracker(cyclus::Context* ctx);
+
+ #pragma cyclus
+
+ /// increments n_ticks
+ virtual void Tick();
+
+ /// no-op
+ virtual void Tock() {};
+
+ /// query now many ticks the agent has experienced
+ inline int n_ticks() const {return n_ticks_;}
+
+ private:
+ int n_ticks_;
+ };
+
+Next, make a file called ``tick_tracker.cc`` in the ``src`` directory that has the
+following lines:
+
+.. code-block:: cpp
+
+ #include "tick_tracker.h"
+
+ // we have to call the base cyclus::Facility class' constructor
+ // with a context argument
+ TickTracker::TickTracker(cyclus::Context* ctx) : n_ticks_(0), cyclus::Facility(ctx) {};
+
+ // tick experienced!
+ void TickTracker::Tick() {n_ticks_++;}
+
+Now, make a file called ``tick_tracker_tests.cc`` in the ``src`` directory that
+has the following lines:
+
+.. code-block:: cpp
+
+ // gtest deps
+ #include
+
+ // cyclus deps
+ #include "facility_tests.h"
+ #include "agent_tests.h"
+ #include "test_context.h"
+
+ // our deps
+ #include "tick_tracker.h"
+
+ // write a unit test of our own
+ TEST(TickTracker, track_ticks) {
+ cyclus::TestContext ctx;
+ TickTracker fac(ctx.get());
+ EXPECT_EQ(0, fac.n_ticks());
+ fac.Tick();
+ EXPECT_EQ(1, fac.n_ticks());
+ fac.Tick();
+ EXPECT_EQ(2, fac.n_ticks());
+ }
+
+ // get all the basic unit tests
+ #ifndef CYCLUS_AGENT_TESTS_CONNECTED
+ int ConnectAgentTests();
+ static int cyclus_agent_tests_connected = ConnectAgentTests();
+ #define CYCLUS_AGENT_TESTS_CONNECTED cyclus_agent_tests_connected
+ #endif // CYCLUS_AGENT_TESTS_CONNECTED
+
+ cyclus::Agent* TickTrackerConstructor(cyclus::Context* ctx) {
+ return new TickTracker(ctx);
+ }
+
+ INSTANTIATE_TEST_CASE_P(TicTrac, FacilityTests,
+ ::testing::Values(&TickTrackerConstructor));
+
+ INSTANTIATE_TEST_CASE_P(TicTrac, AgentTests,
+ ::testing::Values(&TickTrackerConstructor));
+
+Add the following lines to the ``src/CMakeLists.txt`` file: ::
+
+ INSTALL_CYCLUS_STANDALONE("TickTracker" "tick_tracker" "tutorial")
+
+Now we're ready to install the ``TickTracker`` module and run its tests. If you
+haven't already, now is a good time to add the ``$CYCLUS_INSTALL_PATH`` to your
+``PATH`` environment variable (|cyclus|' ``install.py`` defaults to
+``~/.local``). Next, from your top level directory (where your ``install.py``
+file is), run:
+
+.. code-block:: bash
+
+ $ ./install.py
+ $ TickTracker_unit_tests
+
+Which results in: ::
+
+ [==========] Running 8 tests from 3 test cases.
+ [----------] Global test environment set-up.
+ [----------] 1 test from TickTracker
+ [ RUN ] TickTracker.track_ticks
+ [ OK ] TickTracker.track_ticks (19 ms)
+ [----------] 1 test from TickTracker (20 ms total)
+
+ [----------] 5 tests from TicTrac/AgentTests
+ [ RUN ] TicTrac/AgentTests.Clone/0
+ [ OK ] TicTrac/AgentTests.Clone/0 (8 ms)
+ [ RUN ] TicTrac/AgentTests.Print/0
+ [ OK ] TicTrac/AgentTests.Print/0 (9 ms)
+ [ RUN ] TicTrac/AgentTests.Schema/0
+ [ OK ] TicTrac/AgentTests.Schema/0 (9 ms)
+ [ RUN ] TicTrac/AgentTests.Annotations/0
+ [ OK ] TicTrac/AgentTests.Annotations/0 (15 ms)
+ [ RUN ] TicTrac/AgentTests.GetAgentType/0
+ [ OK ] TicTrac/AgentTests.GetAgentType/0 (8 ms)
+ [----------] 5 tests from TicTrac/AgentTests (49 ms total)
+
+ [----------] 2 tests from TicTrac/FacilityTests
+ [ RUN ] TicTrac/FacilityTests.Tick/0
+ [ OK ] TicTrac/FacilityTests.Tick/0 (9 ms)
+ [ RUN ] TicTrac/FacilityTests.Tock/0
+ [ OK ] TicTrac/FacilityTests.Tock/0 (8 ms)
+ [----------] 2 tests from TicTrac/FacilityTests (17 ms total)
+
+ [----------] Global test environment tear-down
+ [==========] 8 tests from 3 test cases ran. (86 ms total)
+ [ PASSED ] 8 tests.
+
+Testing Resource Exchange
+--------------------------
+
+One of the most important things to test is your archetype's resource exchange
+behavior. Does it request/receive the right kinds of material? Does it offer/sell
+resources at the right time? One of the best ways to test this is to actually
+run a simulation with your archetype. Cyclus comes with a mock simulation
+environment that makes it easy to write these kinds of tests in a way that
+works well with gtest.
+
+``MockSim`` is a helper for running full simulations entirely in-code without
+having to deal with input files, output database files, and other pieces of
+the full Cyclus stack. All you have to do is initialize a MockSim indicating
+the archetype you want to test and the simulation duration. Then add any
+number of sources and/or sinks to transact with your agent. They can have
+specific recipes (or not) and their deployment and lifetime (before
+decommissioning) can be specified too. Here is an example using the
+agents:Source archetype in Cyclus as the tested agent:
+
+.. code-block:: c++
+
+ // Define a composition to use as a simulation recipe.
+ cyclus::CompMap m;
+ m[922350000] = .05;
+ m[922380000] = .95;
+ cyclus::Composition::Ptr fresh = cyclus::Composition::CreateFromMass(m);
+
+ // Define our archetype xml configuration.
+ // This is the info that goes
+ // "<[archetype-name]>here[archetype-name]> "
+ // in the input file.
+ std::string config =
+ "enriched_u "
+ "fresh_fuel "
+ "10 ";
+
+ // Create and run a 10 time step mock simulation
+ int dur = 10;
+ cyclus::MockSim sim(cyclus::AgentSpec(":agents:Source"), config, dur);
+ sim.AddRecipe("fresh_fuel", fresh); // with one composition recipe
+ sim.AddSink("enriched_u") // and one sink facility
+ .recipe("fresh_fuel") // requesting a particular recipe
+ .capacity(5) // with a 5 kg per time step receiving limit
+ .Finalize(); // (don't forget to call this for each source/sink you add)
+
+ sim.AddSink("enriched_u") // And another sink facility
+ // requesting no particular recipe
+ // and with infinite capacity
+ .start(3) // that isn't built until the 3rd timestep.
+ .Finalize();
+ int agent_id = sim.Run(); // capture the ID of the agent being tested
+
+The parameters that can be set (or not) for each source/sink are:
+
+* ``recipe(std::string r)``: The recipe to request/provide. Default is none -
+ sources provide requested material, sinks take anything.
+
+* ``capacity(double cap)``: The per time step throughput/capacity limit for
+ the source/sink. Default is infinite.
+
+* ``start(int t)``: Time the source/sink is initially built. Default is time
+ step zero.
+
+* ``lifetime(int)``: The number of time steps the source/sink is deployed
+ until automatic decommissioning. Default is infinite (never decommissioned).
+
+For more details, you can read the `MockSim API docs `_.
+Querying simulation results can be accomplished by getting a reference to the
+in-memory database generated. Not all data that is present in normal
+full-stack simulations is available. However, most of the key core tables are
+fully available. Namely the Transactions, Composition, Resources,
+ResCreators, AgentEntry, and AgentExit tables are available. Any
+custom-tables created by the tested archetype will also be available. Here is
+a sample query and test you might write using the gtest framework:
+
+.. code-block:: c++
+
+ // return all transactions where our source facility is the sender
+ std::vector conds;
+ conds.push_back("SenderId", "==", agent_id);
+ cyclus::QueryResult qr = sim.db().Query("Transactions", &conds);
+ int n_trans = qr.rows.size();
+ EXPECT_EQ(10, n_trans) << "expected 10 transactions, got " << n_trans;
+
+ // reconstruct the material object for the first transaction
+ int res_id = qr.GetVal("ResourceId", 0);
+ cyclus::Material::Ptr m = sim.GetMaterial(res_id);
+ EXPECT_DOUBLE_EQ(10, m->quantity());
+
+ // confirm composition is as expected
+ cyclus::toolkit::MatQuery mq(m);
+ EXPECT_DOUBLE_EQ(0.5, mq.mass(922350000));
+ EXPECT_DOUBLE_EQ(9.5, mq.mass(922380000));
+
+You can read API documentation for the `queryable database
+`_ and
+`query results
+`_ for more
+details.
+
+Debugging
+----------
+
+If exceptions are being thrown when you try to use your archetype in
+simulations, you can turn off Cyclus' main exception handling/catching by
+setting the environment variable ``CYCLUS_NO_CATCH=1`` when you run cyclus.
+This will prevent exceptions from being caught resulting in a core-dump. You
+can then use a debugger (e.g. gdb or lldb) to run the failing simulation and
+investigate the source of the crash in more detail. Something like this:
+
+.. code-block:: bash
+
+ $ CYCLUS_NO_CATCH=1 gdb --args cyclus my-failing-sim.xml
+
+ GNU gdb (GDB) 7.11
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ ...
+ (gdb) run
+ ...
+
+Cyclus has the ability to dump extra information about a simulation run's
+resource exchange into the database. This information can be
+particularly helpful for debugging and verifying your archetype's behavior
+with respect to resource exchange. To turn on this debugging, simply run
+cyclus with the environment variable ``CYCLUS_DEBUG_DRE`` set to any non-empty
+value:
+
+.. code-block:: bash
+
+ $ CYCLUS_DEBUG_DRE=1 cyclus my-sim.xml
+
+The database will then contain two extra tables with several columns each:
+
+* **DebugRequests**: record of every resource request made in the simulation.
+
+ - ``SimId``: simulation UUID
+ - ``Time``: time step of the request
+ - ``ReqId``, simulation-unique identifier for this request
+ - ``RequesterID``: ID of the requesting agent
+ - ``Commodity``: the commodity of the request
+ - ``Preference``: agent's preference for this particular request
+ - ``Exclusive``: true (non-zero) if this request is all-or-nothing (integral)
+ - ``ResType``: resource type (e.g. "Material", "Product")
+ - ``Quantity``: amount of the request
+ - ``ResUnits``: units of the request (e.g. kg)
+
+* **DebugBids**: record of every resource bid made in the simulation.
+
+ - ``SimId``: simulation UUID
+ - ``ReqId``: simulation-unique identifier for the bid's request
+ - ``BidderId``: ID of the the bidding agent
+ - ``BidQuantity``: amount of thd bid
+ - ``Exclusive``: true(non-zero) if this request is all-or-nothing (integral)
+
+Note that some information about bids can be inferred from corresponding
+requests. A bid's time, commodity, resource type, and units are all identical
+to those of the corresponding request.
+
+
diff --git a/_sources/arche/timestep.rst.txt b/_sources/arche/timestep.rst.txt
new file mode 100755
index 000000000..cfc7fd2a6
--- /dev/null
+++ b/_sources/arche/timestep.rst.txt
@@ -0,0 +1,145 @@
+Time Step Execution
+===================
+
+A |cyclus| simulation is composed of discrete time steps, and each time step is
+subdivided into phases. Phases come in two flavors: kernel phases and agent
+phases. Kernel phases include actions that have either been registered to occur
+with the |cyclus| kernel (e.g., building a new facility agent) or are driven by
+the |cyclus| kernel (e.g., the Resource Exchange). Agent phases are points
+within a given time step that allow agents to query the current simulation
+environment and perform any agent-specific actions, such as scheduling a new
+agent to be built or scheduling a current agent to be decommissioned.
+
+The list of phases in order is:
+
+* :ref:`build` (kernel)
+* :ref:`tick` (agent)
+* :ref:`exchng` (kernel)
+* :ref:`tock` (agent)
+* :ref:`decom` (kernel)
+
+Agent phases are invoked using a method call of the same name, e.g.,
+
+**C++:**
+
+.. code-block:: c++
+
+ virtual void MyAgent::Tick() {
+ // perform agent-phase Tick's work
+ }
+
+**Python:**
+
+.. code-block:: python
+
+ def tick(self):
+ # perform agent-phase tick's work, no return value
+
+Importantly, the order in which agents' agent-phase methods are invoked is *not
+guaranteed*. In other words, the execution of any given phase is conceptually
+occurring *simultaneously among agents*.
+
+The duration of a time step can be set to custom values by users when running
+simulations. Archetypes must be coded with this in mind. One easy method for
+supporting arbitrary time step duration is to make all time-related quantities
+and configuration in the archetype operate on a per-time-step basis (e.g.
+reactor cycle length measured in time steps instead of days or months). If
+archetypes do have constraints on the time step duration (e.g. they only
+support approximately 1-month time steps), then they should throw an
+exception as early as possible (i.e. in their constructor). The time step
+duration can be queried from an the simulation context:
+
+**C++:**
+
+.. code-block:: c++
+
+ virtual void MyAgent::Tick() {
+ ...
+ double discharge_qty = discharge_rate * context()->dt();
+ ...
+ }
+
+**Python:**
+
+.. code-block:: python
+
+ def tick(self):
+ ...
+ discharge_qty = self.discharge_rate * self.context.dt
+ ...
+
+.. _build:
+
+Build Phase
+-----------
+
+In the Build phase, agents that have been scheduled to be built are entered into
+the simulation. The entry process includes creating the agent (cloning from a
+:term:`prototype`), connecting it with the :term:`parent agent` that originally
+registered the build, and calling its ``Build`` virtual member function. The
+parent is informed that a new child has been built via the ``cyclus::Agent``'s
+``BuildNotify`` member function.
+
+Future builds can be scheduled by any :term:`agent` using the
+``cyclus::Context``'s ``SchedBuild`` member function. A build cannot be
+scheduled for the current time step, but a build can be scheduled for any
+future time step.
+
+.. _tick:
+
+Tick Phase
+----------
+
+The Tick phase allows agents to analyze the current status of the simulation
+(e.g., the current number of built facilities) and perform any actions they so
+choose *before* the execution of the Resource Exchange. For example, an agent
+could schedule to build a new child agent or perform some process on its
+available inventory of resources.
+
+.. _exchng:
+
+Dynamic Resource Exchange Phase
+-------------------------------
+
+The Dynamic Resource Exchange phase is a :term:`kernel phase` in which the
+supply and demand of resources is queried, solved, and the trading thereof is
+executed. The supply and demand of each concrete resource type
+(e.g. ``cyclus::Material`` and ``cyclus::Product``) are solved for
+independently. A full discussion of this phase is provided in :ref:`dre`.
+
+.. _tock:
+
+Tock Phase
+----------
+
+The Tock phase allows agents to analyze the current status of the simulation
+(e.g., the current number of built facilities) and perform any actions they so
+choose *after* the execution of the Resource Exchange. For example, an agent
+could schedule to decommission a child agent or perform some process on its
+available inventory of resources.
+
+.. _decom:
+
+Decommission Phase
+------------------
+
+In the Decommission phase, agents that have been scheduled to be decommissioned
+are removed from the simulation. The removal process includes informing the
+:term:`parent agent` that one of its children is being decommissioned and
+calling the child agent's ``Decommission`` function. The parent is informed that
+a child is being decommissioned via the ``cyclus::Agent``'s ``DecomNotify``
+member function.
+
+Future decommissions can be scheduled by any :term:`agent` using the
+``cyclus::Context``'s ``SchedDecom`` member function. A decommission can be
+scheduled for the current time step or any future time step.
+
+Decommissioning occurs at the end of a time step. Therefore, an agent with a lifetime
+of 1 would be decommissioned on the same time step it was built. The lifetime of an
+agent can be back calculated by `1+exit_time-start_time`.
+
+Further Reading
+---------------
+
+For a more in depth (and historical) discussion, see `CEP 20
+`_.
diff --git a/_sources/arche/toolkit.rst.txt b/_sources/arche/toolkit.rst.txt
new file mode 100755
index 000000000..5194c28ec
--- /dev/null
+++ b/_sources/arche/toolkit.rst.txt
@@ -0,0 +1,173 @@
+.. _toolkit:
+
+The (Experimental) Cyclus Toolkit
+=================================
+Currently in an experimental state, the |cyclus| toolkit aims to provide
+functionality relevant to a variety of :term:`archetypes ` that do
+not belong strictly in the :term:`cyclus kernel`.
+
+ResourceBuff
+++++++++++++
+.. warning::
+
+ ResourceBuff will soon be deprecated in favor of ``ResBuf``.
+
+The ``cyclus::toolkit::ResourceBuff`` (C++) or ``cyclus.typesystem.ResourceBuff`` (Python)
+class provides provides a canonical
+methodology for dealing with collections of ``Resources``.
+:term:`Archetypes ` in both |cyclus| and Cycamore make use of this
+class. ``ResourceBuffs`` are usually used as member variables of
+archetypes. The |Cyclus| preprocessor (C++) or |Cyclus| agents (Python) have special
+handling for ``ResourceBuff``
+as it can generate all needed code for proper persistence and intiialization
+of the buffer. For this to work, you must annotate the buffer member variable
+with a Cyclus pre-processor :ref:`pragma ` (C++) or have a
+special ``ResourceBuffInv`` class attribute (Python) in one of the
+following ways:
+
+**C++:**
+
+.. code-block:: c++
+
+ // Option 1: minimum required annotation
+ #pragma cyclus var {}
+ cyclus::toolkit::ResourceBuff mybuf;
+
+ // Option 2: you can set a specify buffer capacity
+ #pragma cyclus var {'capacity': 245.6}
+ cyclus::toolkit::ResourceBuff mybuf;
+
+ // Option 3: you can reference another annotated member variable's value
+ // as the capacity
+ #pragma cyclus var {}
+ double buf_cap;
+ #pragma cyclus var {'capacity': 'buf_cap'}
+ cyclus::toolkit::ResourceBuff mybuf;
+
+**Python:**
+
+.. code-block:: python
+
+ from cyclus.agents import Facility
+ import cyclus.typesystem as ts
+
+ class MyFacility(Facility):
+ # Option 1: minimum required class attribute
+ mybuf = ts.ResourceBuffInv()
+
+ # Option 2: you can set a specify buffer capacity
+ mybuf = ts.ResourceBuffInv(capacity=245.6)
+
+ # Option 3: you can reference another annotated member variable's value
+ # as the capacity
+ buf_cap = ts.Double()
+ mybuf = ts.ResourceBuffInv(capacity='buf_cap')
+
+You can read the `ResourceBuff API documentation
+`_ for
+more details on how to use the buffer.
+
+ResBuf
+++++++++++++
+The ``cyclus::toolkit::ResBuf`` (C++) or ``cyclus.typesystem.ResBuf`` (Python) class
+provides provides a canonical
+methodology for dealing with collections of Resources. ``ResBufs``
+are usually used as member variables of archetypes. The Cyclus preprocessor
+has special handling for ``ResBuf`` as it can generate all needed code
+for proper persistence and intiialization of the buffer. For this to work,
+you must annotate the buffer member variable with a Cyclus pre-processor
+:ref:`pragma ` (C++) or set a class attribute (Python)
+in one of the following ways:
+
+**C++:**
+
+.. code-block:: c++
+
+ // Option 1: minimum required annotation
+ #pragma cyclus var {}
+ cyclus::toolkit::ResBuf mybuf;
+
+ // Option 2: you can set a specify buffer capacity
+ #pragma cyclus var {'capacity': 245.6}
+ cyclus::toolkit::ResBuf mybuf;
+
+ // Option 3: you can reference another annotated member variable's value
+ // as the capacity
+ #pragma cyclus var {}
+ double buf_cap;
+ #pragma cyclus var {'capacity': 'buf_cap'}
+ cyclus::toolkit::ResBuf mybuf;
+
+**Python:**
+
+.. code-block:: python
+
+ from cyclus.agents import Facility
+ import cyclus.typesystem as ts
+
+ class MyFacility(Facility):
+ # Option 1: minimum required annotation
+ mybuf = ts.ResBufMaterialInv()
+
+ # Option 2: you can set a specify buffer capacity
+ mybuf = ts.ResBufMaterialInv(capacity=245.6)
+
+ # Option 3: you can reference another annotated member variable's value
+ # as the capacity
+ buf_cap = ts.Double()
+ mybuf = ts.ResBufMaterialInv(capacity='buf_cap')
+
+You can read the `ResBuf API documentation
+`_ for
+more details on how to use the buffer.
+
+MatQuery [C++]
+++++++++++++++
+The ``cyclus::toolkit::MatQuery`` class provides some easy-to-use functions that
+interrogate the ``cyclus::Material`` object. For example, one can query the mass
+or number of moles of a given nuclide.
+
+Enrichment [C++]
+++++++++++++++++
+A number of functions are provided in ``toolkit/enrichment.h`` that assist in
+enrichment-related calculations. Some highlights include a representation of
+uranium assays in ``cyclus::toolkit::Assays``, as well as functions to calculate
+feed, tails, and SWU quantity requirements.
+
+Commodity Recipe Context [C++]
++++++++++++++++++++++++++++++++
+The ``cyclus::toolkit::CommodityRecipeContext`` class provides a mapping between
+commodities and recipes that can be updated as a simulation progresses.
+
+Symbolic Functions [C++]
+++++++++++++++++++++++++
+The ``cyclus::toolkit::SymbolicFunction`` class and its derivatives provide an
+object-oriented hierarchy to represent symbolic functions. Factory methods are
+provided by the ``cyclus::toolkit::SymbFunctionFactory`` class.
+
+Agent Managed Classes [C++]
++++++++++++++++++++++++++++
+There are a number of interfaces provided in the |cyclus| toolkit that can be
+used as either as `mixins `_ or as
+composable, agent-managed state variables:
+
+* ``cyclus::toolkit::Builder``: an interface for adding information about agents
+ that can be built by the manager
+
+* ``cyclus::toolkit::BuildingManager``: an interface for making build decisions
+ based on supply, demand, and agents that can be built
+
+* ``cyclus::toolkit::CommodityProducer``: an interface for adding information
+ about commodities that can be produced by the manager
+
+* ``cyclus::toolkit::CommodityProducerManager``: an interface that allows an
+ agent to query a collection of ``cyclus::toolkit::CommodityProducers``
+
+* ``cyclus::toolkit::SupplyDemandManager``: an interface for querying the supply
+ and demand on commodities
+
+Geographic Informasion System (GIS) Class [C++]
++++++++++++++++++++++++++++++++++++++++++++++++
+ The ``cyclus::toolkit::GIS`` class provide an option to add geographic coordinates
+ of its friend classes. Haversine distance calculations between two facilities or
+ agents with GIS coordinates can be performed as well.
diff --git a/_sources/arche/tour_cpp.rst.txt b/_sources/arche/tour_cpp.rst.txt
new file mode 100755
index 000000000..a0ce51194
--- /dev/null
+++ b/_sources/arche/tour_cpp.rst.txt
@@ -0,0 +1,163 @@
+A Tour of Cycstub
+=================
+
+This section will walk through the source files of the stub :term:`archetypes
+` in `Cycstub `_. Cycstub provides
+three stub archetypes:
+
+* ``StubFacility``
+* ``StubInstitution``
+* ``StubRegion``
+
+We will walk through ``StubFacility``\ 's source specifically because its the
+most complicated of the three. Before we begin, though, let's get a fresh copy
+of Cycstub (or follow along on the `website
+`_).
+
+**Getting cycstub via git:**
+
+.. code-block:: bash
+
+ $ git clone https://github.com/cyclus/cycstub.git
+ $ cd cycstub
+
+**Getting cycstub via zip:**
+
+.. code-block:: bash
+
+ $ curl -L https://api.github.com/repos/cyclus/cycstub/zipball > cycstub.zip
+ $ unzip cycstub.zip
+ $ mv cyclus-cycstub-* cycstub
+ $ cd cycstub
+
+Feel free to ``rm`` the cycstub directory when we're done (you can always get it
+back!).
+
+StubFacility
+------------
+
+The ``StubFacility`` provides the minimal interface that an :term:`archetype`
+that derives from ``cyclus::Facility`` must provide. We'll go through both the
+header (``h``) and implementation (``cc``) files in conjunction, starting at the
+top.
+
+``stub_facility.h`` has a single |cyclus|-based include
+
+.. code-block:: cpp
+
+ #include "cyclus.h"
+
+which includes most :term:`cyclus kernel` headers as a convenience for new
+:term:`archetype developers `. You're more than welcome to
+include the specific kernel headers you need if you require a smaller
+executable.
+
+Moving on in the header file we come to the class declaration
+
+.. code-block:: cpp
+
+ class StubFacility : public cyclus::Facility {
+
+which simply states that the ``StubFacility`` inherits from ``cyclus::Facility``.
+
+We then come to the constructor declaration
+
+.. code-block:: cpp
+
+ explicit StubFacility(cyclus::Context* ctx);
+
+and implementation
+
+.. code-block:: cpp
+
+ StubFacility::StubFacility(cyclus::Context* ctx)
+ : cyclus::Facility(ctx) {};
+
+The constructor takes a single ``cyclus::Context`` argument. The :term:`context`
+is the mechanism by which :term:`agents ` can query and otherwise
+communicate with the simulation environment. Because the base ``cyclus::Agent``
+class requires a ``cyclus::Context`` argument in its constructor, all derived
+classes must pass the argument down its constructor chain, as ``StubFacility``
+does with its ``cyclus::Facility`` constructor above.
+
+Continuing with the header file, we next come to **the prime directive**
+
+.. code-block:: c++
+
+ #pragma cyclus
+
+In short, the prime directive allows an archetype developer to use the |cyclus|
+preprocessor to autogenerate many member functions that are required for
+|cyclus| features related to initialization and restart capabilities. For a
+further explanation, see :ref:`cycpp`.
+
+The next line in ``stub_facility.h`` is also related to the preprocessor's
+ability to help automate some documentation:
+
+.. code-block:: c++
+
+ #pragma cyclus note {"doc": "A stub facility is provided as a skeleton " \
+ "for the design of new facility agents."}
+
+Again, ``#pragma cyclus note`` is explained further in :ref:`cycpp`.
+
+Continuing along, we reach the final three member functions, each of which are
+defined on the base ``cyclus::Agent`` class and are overrode by the
+``StubFacility``.
+
+str
++++
+
+The declaration
+
+.. code-block:: c++
+
+ virtual std::string str();
+
+and implementation
+
+.. code-block:: c++
+
+ std::string StubFacility::str() {
+ return Facility::str();
+ }
+
+of the ``str`` method allows the ``StubFacility`` to customize its string
+representation, which is printed at a variety of ``cyclus::Logger`` logging
+levels, which is explained further in :doc:`/arche/logger`.
+
+Tick
+++++
+
+The declaration
+
+.. code-block:: c++
+
+ virtual void Tick();
+
+and implementation
+
+.. code-block:: c++
+
+ void StubFacility::Tick() {}
+
+of the ``Tick`` member function allows the ``StubFacility`` to act during the
+:term:`tick` :term:`agent phase`.
+
+Tock
+++++
+
+The declaration
+
+.. code-block:: c++
+
+ virtual void Tock();
+
+and implementation
+
+.. code-block:: c++
+
+ void StubFacility::Tock() {}
+
+of the ``Tock`` member function allows the ``StubFacility`` to act during the
+:term:`tock` :term:`agent phase`.
diff --git a/_sources/arche/tutorial_cpp/cyclist.rst.txt b/_sources/arche/tutorial_cpp/cyclist.rst.txt
new file mode 100755
index 000000000..1a9327844
--- /dev/null
+++ b/_sources/arche/tutorial_cpp/cyclist.rst.txt
@@ -0,0 +1,5 @@
+
+Using the Cyclus GUI (Cyclist) with Your New Archetype
+==========================================================
+
+foo
\ No newline at end of file
diff --git a/_sources/arche/tutorial_cpp/dre.rst.txt b/_sources/arche/tutorial_cpp/dre.rst.txt
new file mode 100755
index 000000000..33511fe47
--- /dev/null
+++ b/_sources/arche/tutorial_cpp/dre.rst.txt
@@ -0,0 +1,5 @@
+
+More Dynamic Resource Exchange Detail
+=======================================
+
+foo
\ No newline at end of file
diff --git a/_sources/arche/tutorial_cpp/index.rst.txt b/_sources/arche/tutorial_cpp/index.rst.txt
new file mode 100755
index 000000000..9b73e9bb0
--- /dev/null
+++ b/_sources/arche/tutorial_cpp/index.rst.txt
@@ -0,0 +1,43 @@
+Archetype Development Tutorial [C++]
+====================================
+In this tutorial, we will work through a number of steps for creating a
+Facility archetype for Cyclus. This tutorial assumes that the learner is
+already reasonably familiar with programming in C++ and with the primary
+vocabulary of Cyclus. We also assume that the learner has a Github account.
+
+Overview
+---------
+
+Through this tutorial, we will transform a copy of the Cycstub repository into
+an open source Cyclus archetype module that includes an archetype to simulate
+a very simple interim storage facility, named "Storage". Ultimately, this
+facility will have the following characteristics, all definable by the user:
+
+* a fixed rate at which it can transfer material
+* a minimum time that material stays in storage
+* a fixed storage capacity
+
+This tutorial has the following steps:
+
+.. toctree::
+ :maxdepth: 1
+
+ setup
+ state_var
+ toolkit
+ testing
+ input_files
+
+.. Given enough time, the following extra topics may be covered:
+
+.. toctree::
+ :maxdepth: 1
+
+.. cyclist
+.. dre
+
+.. note::
+
+ If you ever see an error like ``ERROR(core ):SQL error [INSERT INTO
+ AgentState...`` simply remove the output database with ``$ rm
+ cyclus.sqlite`` and rerun the simulation
diff --git a/_sources/arche/tutorial_cpp/input_files.rst.txt b/_sources/arche/tutorial_cpp/input_files.rst.txt
new file mode 100755
index 000000000..2562274f1
--- /dev/null
+++ b/_sources/arche/tutorial_cpp/input_files.rst.txt
@@ -0,0 +1,314 @@
+
+Making Input Files
+===============================
+
+In this lesson, we will:
+
+1. Make a basic input file
+2. Run the file and analyze output
+3. Make a more interesting input file
+4. Run the file and analyze output
+
+Overview
+----------
+
+Cyclus uses XML as its input file format, and there is an extensive guide to
+making input files on the `website
+`_. Rather than getting into the
+details of how to write input files, this lesson will focus instead on the
+minimum information needed to get up and running with the Storage archetype.
+
+Make a Basic Input File
+-----------------------
+
+The goal of this basic input file is to create the following facility set up.
+
+.. figure:: simple_cycle.svg
+ :width: 80 %
+ :align: center
+
+ **Figure:** The target "cycle".
+
+Let's start with very simple dynamics, where the ``Source`` can send one unit of
+fuel per time step, the ``Sink`` can take one unit of fuel per time step, and
+the ``Storage`` stores fuel for one time step.
+
+First, make a new input file
+
+.. code-block:: console
+
+ $ cp input/storage.xml input/basic.xml
+
+and open it with your favorite text editor.
+
+Add a Recipe
++++++++++++++
+
+In this example, material is being transferred between facilities. As in real
+life, in Cyclus, material must have some composition. For this example, we can
+use an LEU-like composition.
+
+Add the following lines to the bottom of the input file (but before the close
+tag )
+
+.. code-block:: xml
+
+
+ LEU
+ mass
+
+ U235
+ 5
+
+
+ U238
+ 95
+
+
+
+Adding New Archetypes
++++++++++++++++++++++
+
+We need to add a ``Source`` archetype and a ``Sink`` archetype, which we can
+find in the ``agents`` library of Cyclus. To do so, add the following lines to
+the `` `` block of your input file.
+
+.. code-block:: xml
+
+ agents Source
+ agents Sink
+
+The full block should now look like
+
+.. code-block:: xml
+
+
+ tutorial Storage Storage
+ tutorial TutorialRegion TutorialRegion
+ tutorial TutorialInst TutorialInst
+ agents Source
+ agents Sink
+
+
+Adding Prototypes
++++++++++++++++++
+
+A configured archetype is called a *prototype* in Cyclus parlance. You can read
+how to on the :ref:`cyclus_archetypes` and :ref:`cycamore_archetypes`
+pages.
+
+Source
+~~~~~~~~~~
+
+Beginning with the Cyclus `Source
+`_, you must, at
+minimum, supply an entry for `` `` and `` ``. This prototype
+will also include a `` `` entry. In this example, you want the
+source facility to supply one unit of fuel per time step and you want it to be
+connected to the ``incommod`` of the Storage prototype. Finally, let's name the
+Source "FuelSource".
+
+Accordingly, add the following lines after the Storage prototype
+
+.. code-block:: xml
+
+
+ FuelSource
+
+
+
+
+
+Sink
+~~~~~~~~~~
+
+Similarly, the Cyclus `Sink
+`_, you must, at
+minimum, supply an entry in the `` `` tag and a `` ``. We
+want a similar structure to the Source prototype, i.e., connection to the
+Storage prototype and a demand for one unit of fuel per time step. We can also
+name this Sink prototype "FuelSink".
+
+Accordingly, add the following lines after the Storage prototype
+
+.. code-block:: xml
+
+
+ FuelSink
+
+
+ 1
+
+ stored_fuel
+
+
+
+
+
+Storage
+~~~~~~~~~
+
+The Storage prototype is fine as it is. If you don't like the name
+``OneFacility``, however, you are free to replace it with something more fitting
+like ``FuelStorage``.
+
+.. warning::
+
+ Make sure to replace ``OneFacility`` everywhere though!
+
+Region & Institution
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Deployment for facility agents must be declared in the input file. In order for
+our source and sink to be deployed at the beginning of the simulation, they must
+be added to the `` ``. Accordingly, add the following lines
+below the ``OneFacility`` entry. Note that order here does not matter.
+
+.. code-block:: xml
+
+
+ FuelSink
+ 1
+
+
+ FuelSource
+ 1
+
+
+So now, the full region and institution configuration should look something like
+
+.. code-block:: xml
+
+
+
+ OneRegion
+
+
+
+
+ OneInst
+
+
+ OneFacility
+ 1
+
+
+ FuelSink
+ 1
+
+
+ FuelSource
+ 1
+
+
+
+
+
+
+
+
+Run the Basic File
+--------------------
+
+Run the file with a slightly higher verbosity
+
+.. code-block:: console
+
+ $ cyclus -v 4 input/basic.xml
+
+.. note::
+
+ You'll get more helpful information for this run by upping the verbosity
+ from ``3`` to ``4``.
+
+What output do you see? Are things working as expected?
+
+You should see something like the following for a single time step
+
+.. code-block:: console
+
+ INFO1(core ):Current time: 5
+ INFO2(core ): Beginning Tick for time: 5
+ INFO2(Storag): Quantity to be requested: 7 kg.
+ INFO2(Storag): Quantity to be offered: 1 kg.
+ INFO3(Sink ): FuelSink will request 1 kg of stored_fuel.
+ INFO3(Source): FuelSource will offer 1 kg of fuel.
+ INFO2(core ): Beginning DRE for time: 5
+ INFO3(buypol): policy input (agent OneFacility-12): requesting 7 kg via 1 request(s)
+ INFO3(buypol): - one 7 kg request of fuel
+ INFO3(selpol): policy output (agent OneFacility-12): bidding out 1 kg
+ INFO3(selpol): - bid 1 kg on a request for stored_fuel
+ INFO3(selpol): policy output (agent OneFacility-12): sending 1 kg of stored_fuel
+ INFO3(buypol): policy input (agent OneFacility-12): got 1 kg of fuel
+ INFO2(core ): Beginning Tock for time: 5
+ INFO2(Storag): The total inventory at time 5 is 1 kg of material.
+ INFO3(Sink ): FuelSink is holding 5 units of material at the close of month 5.
+
+
+Make a More Interesting Input File
+-------------------------------------
+
+The previous scenario employed very simple dynamics. A unit of material was sent
+from the Source to Storage every time step. After the first time step, a unit of
+material was also sent from Storage to the Sink every time step, having been
+stored for the interim period.
+
+This consistent flow occurred because, given the storage time :math:`t_s`,
+capacity :math:`c`, and throughput :math:`\tau`, the following relation is true
+
+.. math::
+
+ t_s < min(c, \tau)
+
+What happens when :math:`t_s > min(c, \tau)`? Let's find out!
+
+First, make a new input file
+
+.. code-block:: console
+
+ $ cp input/basic.xml input/interesting.xml
+
+and open it with your favorite text editor.
+
+Update the Storage config block to look like
+
+.. code-block:: xml
+
+
+
+ 10
+ 5
+ fuel
+ stored_fuel
+ 2
+
+
+
+Note that now we have :math:`t_s = 5` and :math:`c = 2`.
+
+Run the Interesting File
+--------------------------
+
+Run the file
+
+.. code-block:: console
+
+ $ cyclus -v 4 input/interesting.xml
+
+Exercise
++++++++++
+
+Answer the following questions
+
+- When do trades occur? Why?
+- How much material is in the Sink at the end of the simulation? Why?
+
+Exercise
++++++++++
+
+Play with the all of the simulation parameters and get a feel for the various
+dynamics of this scenario.
\ No newline at end of file
diff --git a/_sources/arche/tutorial_cpp/setup.rst.txt b/_sources/arche/tutorial_cpp/setup.rst.txt
new file mode 100755
index 000000000..dc7a3f71d
--- /dev/null
+++ b/_sources/arche/tutorial_cpp/setup.rst.txt
@@ -0,0 +1,134 @@
+Setup a New Project Based on Cycstub
+==============================================
+
+In this lesson, we will:
+
+1. Do the tasks the the Cyclus Archetype Hello World!
+2. Clean up the file system for the single storage facility
+3. Install the storage facility
+4. Run an input file that uses the new storage facility
+
+Follow the Hello Cyclus! Instructions
+---------------------------------------------------
+
+Follow all of the steps of :ref:`hello_world_cpp`.
+
+Make a Storage Facility
+------------------------------------------
+
+Next, make a new facility by copying the facility archetype from the Hello World! tutorial.
+
+Start by making sure you are in the correct directory
+
+.. code-block:: console
+
+ $ cd ~/tutorial
+
+Then make the new archetype, updating all the files as needed
+
+.. note::
+
+ If you are on a Mac, replace all instances of ``sed -i`` with ``sed -i ''``.
+
+.. code-block:: console
+
+ $ for file in `ls src/tutorial_facility*`; do cp "${file}" "${file/tutorial_facility/storage}"; done
+ $ sed -i "s/tutorial_facility/storage/g" src/storage*
+ $ sed -i "s/TutorialFacility/Storage/g" src/storage*
+ $ sed -i "s/TUTORIAL_FACILITY/STORAGE/g" src/storage*
+
+Finally, open -``src/CMakeLists.txt`` with your favorite text editor and add the
+following line to the end of it
+
+.. code-block:: bash
+
+ install_cyclus_standalone("Storage" "storage" "tutorial")
+
+
+Install and Test
+----------------------------------
+
+Install the tutorial project
+
+.. code-block:: console
+
+ $ ./install.py
+
+Run the unit tests
+
+.. code-block:: console
+
+ $ Storage_unit_tests
+
+Make a new input file that is a copy of the test input file
+
+.. code-block:: console
+
+ $ cp input/example.xml input/storage.xml
+
+Then change every instance of ``TutorialFacility`` with ``Storage``. This can be
+done by hand or on the command line with
+
+.. code-block:: console
+
+ $ sed -i "s/TutorialFacility/Storage/g" input/storage.xml
+
+Test the input file by running Cyclus
+
+.. code-block:: console
+
+ $ cyclus -v 2 input/storage.xml
+ :
+ .CL:CC CC _Q _Q _Q_Q _Q _Q _Q
+ CC;CCCCCCCC:C; /_\) /_\)/_/\\) /_\) /_\) /_\)
+ CCCCCCCCCCCCCl __O|/O___O|/O_OO|/O__O|/O__O|/O____________O|/O__
+ CCCCCCf iCCCLCC /////////////////////////////////////////////////
+ iCCCt ;;;;;. CCCC
+ CCCC ;;;;;;;;;. CClL. c
+ CCCC ,;; ;;: CCCC ; : CCCCi
+ CCC ;; ;; CC ;;: CCC` `C;
+ lCCC ;; CCCC ;;;: :CC .;;. C; ; : ; :;;
+ CCCC ;. CCCC ;;;, CC ; ; Ci ; : ; : ;
+ iCC :; CC ;;;, ;C ; CC ; : ; .
+ CCCi ;; CCC ;;;. .C ; tf ; : ; ;.
+ CCC ;; CCC ;;;;;;; fC : lC ; : ; ;:
+ iCf ;; CC :;;: tC ; CC ; : ; ;
+ fCCC :; LCCf ;;;: LC :. ,: C ; ; ; ; ;
+ CCCC ;; CCCC ;;;: CCi `;;` CC. ;;;; :;.;. ; ,;
+ CCl ;; CC ;;;; CCC CCL
+ tCCC ;; ;; CCCL ;;; tCCCCC.
+ CCCC ;; :;; CCCCf ; ,L
+ lCCC ;;;;;; CCCL
+ CCCCCC :;; fCCCCC
+ . CCCC CCCC .
+ .CCCCCCCCCCCCCi
+ iCCCCCLCf
+ . C. ,
+ :
+ INFO1(core ):Simulation set to run from start=0 to end=10
+ INFO1(core ):Beginning simulation
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+
+ Status: Cyclus run successful!
+ Output location: cyclus.sqlite
+ Simulation ID: 9f15b93c-9ab2-49bb-a14f-fef872e64ce8
+
diff --git a/_sources/arche/tutorial_cpp/state_var.rst.txt b/_sources/arche/tutorial_cpp/state_var.rst.txt
new file mode 100755
index 000000000..78acfb0ab
--- /dev/null
+++ b/_sources/arche/tutorial_cpp/state_var.rst.txt
@@ -0,0 +1,210 @@
+Adding State Variables
+=======================
+
+In this lesson, we will:
+
+1. Add the necessary state variables to define this facility using the Cyclus
+ ``#pragma`` directives
+2. Build and install the updated module
+3. Modify the sample input file to include these variables
+
+Add State Variables with Cyclus #pragma
+----------------------------------------------
+
+The Cyclus preprocessor provides a ``#pragma`` that defines variables to
+be part of the set of state variables and allows convenient annotations.
+
+First, we'll add the maximum monthly transfer capacity, called ``throughput``.
+Open the file ``src/storage.h`` in your text editor.
+
+Immediately after the declaration of ``Tock()``, add the following:
+
+.. code-block:: c++
+
+ #pragma cyclus var { \
+ "doc": "Maximum amount of material that can be transferred in or out each time step", \
+ "tooltip": "Maximum amount of material that can be transferred in or out each time step", \
+ "units": "kg", \
+ "uilabel": "Maximum Throughput" \
+ }
+ double throughput;
+
+Now, we'll add variables for the minimum amount of time that material is
+stored and the input/output commodity names.
+
+.. code-block:: c++
+
+ #pragma cyclus var { \
+ "doc": "Minimum amount of time material must be stored", \
+ "tooltip": "Minimum amount of time material must be stored", \
+ "units": "months", \
+ "uilabel": "Storage Time" \
+ }
+ int storage_time;
+
+ #pragma cyclus var { \
+ "tooltip": "Storage input commodity", \
+ "doc": "Input commodity on which Storage requests material.", \
+ "uilabel": "Input Commodity", \
+ "uitype": "incommodity", \
+ }
+ std::string incommod;
+
+ #pragma cyclus var { \
+ "tooltip": "Storage output commodity", \
+ "doc": "Output commodity on which Storage offers material.", \
+ "uilabel": "Output Commodity", \
+ "uitype": "outcommodity", \
+ }
+ std::string outcommod;
+
+Build and Install the Modified Module
+---------------------------------------
+
+To rebuild, reinstall, and test this module, just issue the same command as before:
+
+.. code-block:: console
+
+ $ ./install.py
+ $ Storage_unit_tests
+
+Modify the Input File
+-------------------------
+
+If you try to run the same input file with your modified module, you will get
+errors because the sample input file no longer includes the necessary pieces
+to define your module. It is missing the new variables. Try it:
+
+.. code-block:: console
+
+ $ cyclus -v 2 input/storage.xml
+ :
+ .CL:CC CC _Q _Q _Q_Q _Q _Q _Q
+ CC;CCCCCCCC:C; /_\) /_\)/_/\\) /_\) /_\) /_\)
+ CCCCCCCCCCCCCl __O|/O___O|/O_OO|/O__O|/O__O|/O____________O|/O__
+ CCCCCCf iCCCLCC /////////////////////////////////////////////////
+ iCCCt ;;;;;. CCCC
+ CCCC ;;;;;;;;;. CClL. c
+ CCCC ,;; ;;: CCCC ; : CCCCi
+ CCC ;; ;; CC ;;: CCC` `C;
+ lCCC ;; CCCC ;;;: :CC .;;. C; ; : ; :;;
+ CCCC ;. CCCC ;;;, CC ; ; Ci ; : ; : ;
+ iCC :; CC ;;;, ;C ; CC ; : ; .
+ CCCi ;; CCC ;;;. .C ; tf ; : ; ;.
+ CCC ;; CCC ;;;;;;; fC : lC ; : ; ;:
+ iCf ;; CC :;;: tC ; CC ; : ; ;
+ fCCC :; LCCf ;;;: LC :. ,: C ; ; ; ; ;
+ CCCC ;; CCCC ;;;: CCi `;;` CC. ;;;; :;.;. ; ,;
+ CCl ;; CC ;;;; CCC CCL
+ tCCC ;; ;; CCCL ;;; tCCCCC.
+ CCCC ;; :;; CCCCf ; ,L
+ lCCC ;;;;;; CCCL
+ CCCCCC :;; fCCCCC
+ . CCCC CCCC .
+ .CCCCCCCCCCCCCi
+ iCCCCCLCf
+ . C. ,
+ :
+ Entity: line 17: element Storage: Relax-NG validity error : Expecting an element throughput, got nothing
+ Entity: line 17: element Storage: Relax-NG validity error : Invalid sequence in interleave
+ Entity: line 17: element Storage: Relax-NG validity error : Element Storage failed to validate content
+ ERROR(core ):Document failed schema validation
+
+The simulation now fails because it does not match the schema. You can view the schema with
+
+.. code-block:: console
+
+ $ cyclus --agent-schema tutorial:Storage:Storage
+
+Notice that you were able to take advantage of the input file validation simply by using the ``#pragma``.
+
+Our failed cyclus simulation produced an output file that will need to be deleted.
+
+.. code-block:: console
+
+ $ rm cyclus.sqlite
+
+Now, we'll change that input file. Open the file ``input/storage.xml`` in
+your text editor, and find the prototype configuration for the single facility
+named "OneFacility" that looks like this.
+
+.. code-block:: xml
+
+
+ OneFacility
+
+
+
+
+
+We need to replace the ```` element with this:
+
+.. code-block:: xml
+
+
+
+ 10
+ 1
+ fuel
+ stored_fuel
+
+
+
+Now we can try it again:
+
+.. code-block:: console
+
+ $ cyclus -v 2 input/storage.xml
+ :
+ .CL:CC CC _Q _Q _Q_Q _Q _Q _Q
+ CC;CCCCCCCC:C; /_\) /_\)/_/\\) /_\) /_\) /_\)
+ CCCCCCCCCCCCCl __O|/O___O|/O_OO|/O__O|/O__O|/O____________O|/O__
+ CCCCCCf iCCCLCC /////////////////////////////////////////////////
+ iCCCt ;;;;;. CCCC
+ CCCC ;;;;;;;;;. CClL. c
+ CCCC ,;; ;;: CCCC ; : CCCCi
+ CCC ;; ;; CC ;;: CCC` `C;
+ lCCC ;; CCCC ;;;: :CC .;;. C; ; : ; :;;
+ CCCC ;. CCCC ;;;, CC ; ; Ci ; : ; : ;
+ iCC :; CC ;;;, ;C ; CC ; : ; .
+ CCCi ;; CCC ;;;. .C ; tf ; : ; ;.
+ CCC ;; CCC ;;;;;;; fC : lC ; : ; ;:
+ iCf ;; CC :;;: tC ; CC ; : ; ;
+ fCCC :; LCCf ;;;: LC :. ,: C ; ; ; ; ;
+ CCCC ;; CCCC ;;;: CCi `;;` CC. ;;;; :;.;. ; ,;
+ CCl ;; CC ;;;; CCC CCL
+ tCCC ;; ;; CCCL ;;; tCCCCC.
+ CCCC ;; :;; CCCCf ; ,L
+ lCCC ;;;;;; CCCL
+ CCCCCC :;; fCCCCC
+ . CCCC CCCC .
+ .CCCCCCCCCCCCCi
+ iCCCCCLCf
+ . C. ,
+ :
+ INFO1(core ):Simulation set to run from start=0 to end=10
+ INFO1(core ):Beginning simulation
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+
+ Status: Cyclus run successful!
+ Output location: cyclus.sqlite
+ Simulation ID: 9f15b93c-9ab2-49bb-a14f-fef872e64ce8
diff --git a/_sources/arche/tutorial_cpp/testing.rst.txt b/_sources/arche/tutorial_cpp/testing.rst.txt
new file mode 100755
index 000000000..ca6cf9304
--- /dev/null
+++ b/_sources/arche/tutorial_cpp/testing.rst.txt
@@ -0,0 +1,135 @@
+
+Adding a Test
+================
+
+In this lesson we will
+
+1. Write a unit test for the Storage archetype
+
+Overview
+--------
+
+Testing code is a fundamental `best practice
+ `_ of writing any kind of
+software. While there are technically a few different `varieties
+`_ of tests, this
+lesson focuses on *unit tests*.
+
+Add a Test
+-----------
+
+Cyclus uses the `GoogleTest `_
+testing framework. Using the stubs, Cyclus automatically provides you with some
+basic archetype unit tests, specifically those that are in
+
+.. code-block:: console
+
+ $ Storage_unit_tests
+ ...
+ [----------] 8 tests from TutorialFac/AgentTests
+ ...
+ [----------] 8 tests from TutorialFac/AgentTests (114 ms total)
+
+ [----------] 3 tests from TutorialFac/FacilityTests
+ ...
+ [----------] 3 tests from TutorialFac/FacilityTests (44 ms total)
+ ...
+
+The goal of any good unit test is to define an initial state and expected final
+state and then call a function and confirm that the observed final state matches
+the expected final state. For the Storage facility, one such state transition is
+as follows
+
+- **Initial State**: There is material in the ``input`` buffer
+- **Function Call**: ``Tock()``
+- **Expected Final State**: The ``input`` buffer is empty and the inventory buffer
+ has increase by the same amount
+
+Begin by opening the file ``src/storage_tests.cc`` in your favorite text editor
+and find the test for the ``Tock()`` function. It should look something like
+
+.. code-block:: c++
+
+ TEST_F(StorageTest, Tock) {
+ EXPECT_NO_THROW(facility->Tock());
+ // Test Storage specific behaviors of the Tock function here
+ }
+
+You can set up the initial state by pushing a ``Material`` object to the
+``input`` buffer. An easy way to make a ``Material`` object is to use the
+``NewBlankMaterial()`` API.
+
+Add the following lines before the ``Tock()`` function call in the test
+
+.. code-block:: c++
+
+ double qty = 42;
+ facility->input.Push(cyclus::NewBlankMaterial(qty));
+
+You can then test the test's initial condition
+
+.. code-block:: c++
+
+ EXPECT_DOUBLE_EQ(facility->input.quantity(), qty);
+ EXPECT_DOUBLE_EQ(facility->inventory.quantity(), 0);
+
+Then execute the Tock:
+
+.. code-block:: c++
+
+ EXPECT_NO_THROW(facility->Tock());
+
+Next, add the test for the final state after the call to ``Tock()``
+
+.. code-block:: c++
+
+ EXPECT_DOUBLE_EQ(facility->input.quantity(), 0);
+ EXPECT_DOUBLE_EQ(facility->inventory.quantity(), qty);
+
+Now your test should look like
+
+.. code-block:: c++
+
+ TEST_F(StorageTest, Tock) {
+ double qty = 42;
+ facility->input.Push(cyclus::NewBlankMaterial(qty));
+ EXPECT_DOUBLE_EQ(facility->input.quantity(), qty);
+ EXPECT_DOUBLE_EQ(facility->inventory.quantity(), 0);
+ EXPECT_NO_THROW(facility->Tock());
+ EXPECT_DOUBLE_EQ(facility->input.quantity(), 0);
+ EXPECT_DOUBLE_EQ(facility->inventory.quantity(), qty);
+ }
+
+Finally, build and test, same as it ever was
+
+.. code-block:: console
+
+ $ ./install.py
+ $ Storage_unit_tests
+
+Exercise
+---------
+
+Can you come up with another unit test?
+
+.. note::
+
+ The ``Tock()`` test did not depend on any particular state. We always expect
+ the input-to-inventory transfer to take place, no matter what. Is that true
+ for your test?
+
+
+Further Reading
+----------------
+
+After unit tests, the next step to take is testing your archetype in an actual
+simulation. You can find more on the :ref:`testing` page.
+
+One of the best ways to learn is by example. The Cycamore repository has
+`examples of running regression tests `_
+that include the full execution stack -- read an input file,
+run a simulation, and test an output file. There are also `examples of integration tests
+`_
+that utilize the new `MockSim
+`_
+testing feature in Cyclus.
diff --git a/_sources/arche/tutorial_cpp/toolkit.rst.txt b/_sources/arche/tutorial_cpp/toolkit.rst.txt
new file mode 100755
index 000000000..b876e81d8
--- /dev/null
+++ b/_sources/arche/tutorial_cpp/toolkit.rst.txt
@@ -0,0 +1,732 @@
+Adding Buffers and Policies from the Toolkit
+=================================================
+
+In this lesson, we will:
+
+1. Add ResBufs to track material inventories
+2. Add Policies to manage the trading of material
+3. Add inventory management logic
+4. Change our log information to show the info about the inventories
+5. Add a notion of total storage capacity
+
+Overview
+--------------
+
+Cyclus has a growing Toolkit of standard patterns that can be used by
+archetype developers. There are many advantages to using the Toolkit patterns
+rather than developing similar functionality yourself, typical of most code
+reuse situations:
+
+* robustness - Toolkit patterns have been subjected to the Cyclus QA process
+* time savings - It will take less time to learn how to use a Toolkit than it takes to develop your own
+* improvements - You can benefit immediately from any improvements in the performance of the Toolkit pattern
+
+Code reuse is a critical best practice in all software development.
+
+One of the Toolkit patterns is a ``ResBuf``, providing a way to track an
+inventory of ``Resource`` objects. There are also ``MatlBuyPolicy`` and
+``MatlSellPolicy`` for managing the trading of ``Material`` objects.
+
+Add State Variables, Buffers, and Policies
+------------------------------------------
+
+All state variable additions should be included in ``src/storage.h`` below the
+other state variables added previously.
+
+ A ``ResBuf`` is available as a data type for another state variable, so we
+ simply have to add the following:
+
+.. code-block:: c++
+
+ /// this facility holds material in storage.
+ #pragma cyclus var {}
+ cyclus::toolkit::ResBuf inventory;
+
+This creates a state variable named ``inventory`` that is based on the
+``cyclus::toolkit::ResBuf`` class. We'll explain how buffers and policies
+work in just a moment. A ResBuf object has special handling by the
+preprocessor, so it will not appear in the schema and therefore will not
+appear in the Cycic UI either.
+
+Next, add two additional buffers
+
+.. code-block:: c++
+
+ /// a buffer for incoming material
+ #pragma cyclus var {}
+ cyclus::toolkit::ResBuf input;
+
+ /// a buffer for outgoing material
+ #pragma cyclus var {}
+ cyclus::toolkit::ResBuf output;
+
+Now add the policies. Policies do not require any special handling, and
+thus do not need a pragma
+
+.. code-block:: c++
+
+ /// a policy for requesting material
+ cyclus::toolkit::MatlBuyPolicy buy_policy;
+
+ /// a policy for sending material
+ cyclus::toolkit::MatlSellPolicy sell_policy;
+
+There needs to be a mechansim for keeping track of when materials enter the
+inventory. In order to utilize Cyclus' sophisticated restart capability, we must
+choose a data structure that is compatible with the at least one of the Cyclus
+output databases (see :ref:`dbtypes`). Given that requirement, an appropriate
+data structure is a `list
+ `_. Accordingly, add the
+following
+
+.. code-block:: c++
+
+ /// list for material entry times, providing a default lets this variable be
+ /// optional in an input file
+ #pragma cyclus var { \
+ "default": [] \
+ }
+ std::list entry_times;
+
+This requires another header file, so at the top of the storage.h file, after
+``#include ``, add another include
+
+.. code-block:: c++
+
+ #include
+
+Finally, check that everything works by installing and testing
+
+.. code-block:: console
+
+ $ ./install.py
+ $ Storage_unit_tests
+
+You can also confirm that everything still works with running the simulation:
+
+.. code-block:: console
+
+ $ cyclus -v 3 input/storage.xml
+ :
+ .CL:CC CC _Q _Q _Q_Q _Q _Q _Q
+ CC;CCCCCCCC:C; /_\) /_\)/_/\\) /_\) /_\) /_\)
+ CCCCCCCCCCCCCl __O|/O___O|/O_OO|/O__O|/O__O|/O____________O|/O__
+ CCCCCCf iCCCLCC /////////////////////////////////////////////////
+ iCCCt ;;;;;. CCCC
+ CCCC ;;;;;;;;;. CClL. c
+ CCCC ,;; ;;: CCCC ; : CCCCi
+ CCC ;; ;; CC ;;: CCC` `C;
+ lCCC ;; CCCC ;;;: :CC .;;. C; ; : ; :;;
+ CCCC ;. CCCC ;;;, CC ; ; Ci ; : ; : ;
+ iCC :; CC ;;;, ;C ; CC ; : ; .
+ CCCi ;; CCC ;;;. .C ; tf ; : ; ;.
+ CCC ;; CCC ;;;;;;; fC : lC ; : ; ;:
+ iCf ;; CC :;;: tC ; CC ; : ; ;
+ fCCC :; LCCf ;;;: LC :. ,: C ; ; ; ; ;
+ CCCC ;; CCCC ;;;: CCi `;;` CC. ;;;; :;.;. ; ,;
+ CCl ;; CC ;;;; CCC CCL
+ tCCC ;; ;; CCCL ;;; tCCCCC.
+ CCCC ;; :;; CCCCf ; ,L
+ lCCC ;;;;;; CCCL
+ CCCCCC :;; fCCCCC
+ . CCCC CCCC .
+ .CCCCCCCCCCCCCi
+ iCCCCCLCf
+ . C. ,
+ :
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: MatlBuyPolicy is experimental and its API may be subject to change
+ Experimental Warning: MatlSellPolicy is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: MatlBuyPolicy is experimental and its API may be subject to change
+ Experimental Warning: MatlSellPolicy is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: MatlBuyPolicy is experimental and its API may be subject to change
+ Experimental Warning: MatlSellPolicy is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: MatlBuyPolicy is experimental and its API may be subject to change
+ Experimental Warning: MatlSellPolicy is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: MatlBuyPolicy is experimental and its API may be subject to change
+ Experimental Warning: MatlSellPolicy is experimental and its API may be subject to change
+ INFO1(core ):Simulation set to run from start=0 to end=10
+ INFO1(core ):Beginning simulation
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+
+ Status: Cyclus run successful!
+ Output location: cyclus.sqlite
+ Simulation ID: 9f15b93c-9ab2-49bb-a14f-fef872e64ce8
+
+
+Add Implementation Logic
+-----------------------------
+
+The goal of a storage facility is to ask for material up to some limit, store it
+for an amount of time, and then send it on to any interested parties. This can
+be implemented in Cyclus by utilizing the Toolkit objects stated above. The buy
+and sell policies will automatically fill and empty the input and output
+buffers, respectively. A concept of material flow through the facility is
+shown below.
+
+.. figure:: storage_diagram.svg
+ :width: 75 %
+ :align: center
+
+ **Figure:** Material flow through a Storage facility. Green arrows occur
+ **before** the DRE (during the Tick). Yellow arrows occur during the
+ DRE. Brown arrows occur **after** the DRE (during the Tock).
+
+Connect Buffers and Policies
+++++++++++++++++++++++++++++++++
+
+In order for policies to be utilized, they must be connected to their respective
+buffers. The storage facility would like them always connected; accordingly,
+that operation should happen at the time when the facility enters a
+simulation. The kernel will let agents know that they are entering a simulation
+via the ``EnterNotify()`` function.
+
+Add the following to ``src/storage.h`` before the ``Tick()`` function
+
+.. code-block:: c++
+
+ /// set up policies and buffers
+ virtual void EnterNotify();
+
+And add the following to ``src/storage.cc`` before the ``Tick()`` function
+
+.. code-block:: c++
+
+ void Storage::EnterNotify() {
+ cyclus::Facility::EnterNotify(); // call base function first
+ buy_policy.Init(this, &input, std::string("input"), throughput).Set(incommod).Start();
+ sell_policy.Init(this, &output, std::string("output"), throughput).Set(outcommod).Start();
+ }
+
+Buffer Transfer Logic
+++++++++++++++++++++++++++++++++
+
+The job of the ``Storage`` archetype developer is to determine and implement
+the logic related to transfering material between the input and output buffers
+and the middle inventory buffer. Two rules govern buffer transfer logic
+in this model:
+
+1. All material in the input buffer is transferred to the inventory buffer
+2. Material in the inventory buffer that has been stored for long enough is
+ transferred to the output buffer
+
+Because the input buffer transfer should occur *after* the DRE, it must happen
+in the ``Tock()`` method. Similarly, because the output buffer transfer should
+occur *before* the DRE, it must happen in the ``Tick()`` method. For each
+transfer, care must be taken to update the ``entry_times`` list appropriately.
+
+The input buffer transfer requires the following operation for each object in
+the buffer:
+
+1. *Pop* the object from the input buffer
+2. *Push* the object to the inventory buffer
+3. *Push* the current time to the ``entry_times``
+
+In order to implement this, replace the current ``Tock()`` implementation in
+``src/storage.cc`` with
+
+.. code-block:: c++
+
+ void Storage::Tock() {
+ int t = context()->time();
+ while (!input.empty()) {
+ inventory.Push(input.Pop());
+ entry_times.push_back(t);
+ }
+ }
+
+The output buffer transfer requires the following operation so long as the
+condition in 1. is met:
+
+1. Check whether enough time has passed since the time at the front of
+ ``entry_times`` *and* the inventory is not empty. If so:
+2. *Pop* an object from the inventory buffer
+3. *Push* that object to the output buffer
+4. *Pop* a time from the ``entry_times``
+
+In order to implement this, replace the current ``Tick()`` implementation in
+``src/storage.cc`` with
+
+.. code-block:: c++
+
+ void Storage::Tick() {
+ int finished_storing = context()->time() - storage_time;
+ while (!inventory.empty() && entry_times.front() <= finished_storing) {
+ output.Push(inventory.Pop());
+ entry_times.pop_front();
+ }
+ }
+
+
+Build and Test
+++++++++++++++++++++++++++++++++
+
+Same as it ever was
+
+.. code-block:: console
+
+ $ ./install.py
+ $ Storage_unit_tests
+
+Add Some Logging
+---------------------------------------------
+
+Now that all of the required logic is there, it would be nice to know some
+information about what is happening to a facility during a simulation. This is
+accomplished in Cyclus through :ref:`logging`, which is implemented as a stream
+operation.
+
+Information about the current inventory can be added by updating the ``Tock()``
+function (after any pushing/popping) with
+
+.. code-block:: c++
+
+ LOG(cyclus::LEV_INFO2, "Storage") << "The total inventory at time "
+ << t << " is "
+ << inventory.quantity() + output.quantity()
+ << " kg.";
+
+After updating the function should look something like
+
+.. code-block:: c++
+
+ void Storage::Tock() {
+ int t = context()->time();
+ while (!input.empty()) {
+ inventory.Push(input.Pop());
+ entry_times.push_back(t);
+ }
+
+ LOG(cyclus::LEV_INFO2, "Storage") << "The total inventory at time "
+ << t << " is "
+ << inventory.quantity() + output.quantity()
+ << " kg.";
+ }
+
+Notice that this uses the built in ``quantity()`` method of a ResBuf
+object and that both the ``inventory`` and ``output`` buffers are queried. While
+the implementation logic requires multiple buffers, the model assumes the
+facility acts as a single cohesive unit.
+
+You can also add information about the quantity of material that will be
+requested and offered. Since this information is important to know *before* the
+DRE, it goes in the ``Tick()``
+
+.. code-block:: c++
+
+ LOG(cyclus::LEV_INFO2, "Storage") << "Quantity to be requested: " << buy_policy.TotalQty() << " kg.";
+ LOG(cyclus::LEV_INFO2, "Storage") << "Quantity to be offered: " << sell_policy.Limit() << " kg.";
+
+After updating the function should look something like
+
+.. code-block:: c++
+
+ void Storage::Tick() {
+ int finished_storing = context()->time() - storage_time;
+ while (!inventory.empty() && entry_times.front() <= finished_storing) {
+ output.Push(inventory.Pop());
+ entry_times.pop_front();
+ }
+
+ LOG(cyclus::LEV_INFO2, "Storage") << "Quantity to be requested: " << buy_policy.TotalQty() << " kg.";
+ LOG(cyclus::LEV_INFO2, "Storage") << "Quantity to be offered: " << sell_policy.Limit() << " kg.";
+ }
+
+
+To see the logging output, build and rerun the simulation
+
+.. note::
+
+ Increase the verbosity from ``2`` to ``3``.
+
+.. code-block:: console
+
+ $ ./install.py
+ $ cyclus -v 3 input/storage.xml
+ :
+ .CL:CC CC _Q _Q _Q_Q _Q _Q _Q
+ CC;CCCCCCCC:C; /_\) /_\)/_/\\) /_\) /_\) /_\)
+ CCCCCCCCCCCCCl __O|/O___O|/O_OO|/O__O|/O__O|/O____________O|/O__
+ CCCCCCf iCCCLCC /////////////////////////////////////////////////
+ iCCCt ;;;;;. CCCC
+ CCCC ;;;;;;;;;. CClL. c
+ CCCC ,;; ;;: CCCC ; : CCCCi
+ CCC ;; ;; CC ;;: CCC` `C;
+ lCCC ;; CCCC ;;;: :CC .;;. C; ; : ; :;;
+ CCCC ;. CCCC ;;;, CC ; ; Ci ; : ; : ;
+ iCC :; CC ;;;, ;C ; CC ; : ; .
+ CCCi ;; CCC ;;;. .C ; tf ; : ; ;.
+ CCC ;; CCC ;;;;;;; fC : lC ; : ; ;:
+ iCf ;; CC :;;: tC ; CC ; : ; ;
+ fCCC :; LCCf ;;;: LC :. ,: C ; ; ; ; ;
+ CCCC ;; CCCC ;;;: CCi `;;` CC. ;;;; :;.;. ; ,;
+ CCl ;; CC ;;;; CCC CCL
+ tCCC ;; ;; CCCL ;;; tCCCCC.
+ CCCC ;; :;; CCCCf ; ,L
+ lCCC ;;;;;; CCCL
+ CCCCCC :;; fCCCCC
+ . CCCC CCCC .
+ .CCCCCCCCCCCCCi
+ iCCCCCLCf
+ . C. ,
+ :
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: MatlBuyPolicy is experimental and its API may be subject to change
+ Experimental Warning: MatlSellPolicy is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: MatlBuyPolicy is experimental and its API may be subject to change
+ Experimental Warning: MatlSellPolicy is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: MatlBuyPolicy is experimental and its API may be subject to change
+ Experimental Warning: MatlSellPolicy is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: MatlBuyPolicy is experimental and its API may be subject to change
+ Experimental Warning: MatlSellPolicy is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: MatlBuyPolicy is experimental and its API may be subject to change
+ Experimental Warning: MatlSellPolicy is experimental and its API may be subject to change
+ INFO1(core ):Simulation set to run from start=0 to end=10
+ INFO1(core ):Beginning simulation
+ INFO1(core ):Current time: 0
+ INFO2(core ): Beginning Tick for time: 0
+ INFO2(Storag): Quantity to be requested: 10 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 0
+ INFO2(core ): Beginning Tock for time: 0
+ INFO2(Storag): The total inventory at time 0 is 0 kg of material.
+ INFO1(core ):Current time: 1
+ INFO2(core ): Beginning Tick for time: 1
+ INFO2(Storag): Quantity to be requested: 10 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 1
+ INFO2(core ): Beginning Tock for time: 1
+ INFO2(Storag): The total inventory at time 1 is 0 kg of material.
+ INFO1(core ):Current time: 2
+ INFO2(core ): Beginning Tick for time: 2
+ INFO2(Storag): Quantity to be requested: 10 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 2
+ INFO2(core ): Beginning Tock for time: 2
+ INFO2(Storag): The total inventory at time 2 is 0 kg of material.
+ INFO1(core ):Current time: 3
+ INFO2(core ): Beginning Tick for time: 3
+ INFO2(Storag): Quantity to be requested: 10 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 3
+ INFO2(core ): Beginning Tock for time: 3
+ INFO2(Storag): The total inventory at time 3 is 0 kg of material.
+ INFO1(core ):Current time: 4
+ INFO2(core ): Beginning Tick for time: 4
+ INFO2(Storag): Quantity to be requested: 10 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 4
+ INFO2(core ): Beginning Tock for time: 4
+ INFO2(Storag): The total inventory at time 4 is 0 kg of material.
+ INFO1(core ):Current time: 5
+ INFO2(core ): Beginning Tick for time: 5
+ INFO2(Storag): Quantity to be requested: 10 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 5
+ INFO2(core ): Beginning Tock for time: 5
+ INFO2(Storag): The total inventory at time 5 is 0 kg of material.
+ INFO1(core ):Current time: 6
+ INFO2(core ): Beginning Tick for time: 6
+ INFO2(Storag): Quantity to be requested: 10 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 6
+ INFO2(core ): Beginning Tock for time: 6
+ INFO2(Storag): The total inventory at time 6 is 0 kg of material.
+ INFO1(core ):Current time: 7
+ INFO2(core ): Beginning Tick for time: 7
+ INFO2(Storag): Quantity to be requested: 10 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 7
+ INFO2(core ): Beginning Tock for time: 7
+ INFO2(Storag): The total inventory at time 7 is 0 kg of material.
+ INFO1(core ):Current time: 8
+ INFO2(core ): Beginning Tick for time: 8
+ INFO2(Storag): Quantity to be requested: 10 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 8
+ INFO2(core ): Beginning Tock for time: 8
+ INFO2(Storag): The total inventory at time 8 is 0 kg of material.
+ INFO1(core ):Current time: 9
+ INFO2(core ): Beginning Tick for time: 9
+ INFO2(Storag): Quantity to be requested: 10 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 9
+ INFO2(core ): Beginning Tock for time: 9
+ INFO2(Storag): The total inventory at time 9 is 0 kg of material.
+
+ Status: Cyclus run successful!
+ Output location: cyclus.sqlite
+ Simulation ID: 747f6c86-fce8-49be-8c57-8bb38e11761a
+
+Add a State Variable to Define Storage Capcity
+-------------------------------------------------------------
+
+A natural extension for the current storage facility implementation is to have a
+maximum storage capacity. To do so, first add a capacity state variable to
+storage.h . If you still want the input file to work, you have to provide a
+``default`` key in the pragma data structure. A sufficiently large value will
+do.
+
+.. code-block:: c++
+
+ #pragma cyclus var { \
+ 'doc': 'Maximum storage capacity (including all material in the facility)', \
+ 'tooltip': 'Maximum storage capacity', \
+ 'units': 'kg', \
+ 'default': 1e200, \
+ 'uilabel': 'Maximum Storage Capacity' \
+ }
+ double capacity;
+
+The required implementation is nontrivial. The goal of adding a capacity
+member is to guarantee that the amount of material in the facility never exceeds
+a certain value. The only way for material to enter the facility is through the
+``input`` ResBuff via the ``buy_policy``. The ``MatlBuyPolicy`` sets a maximum
+buy amount based on both its ``throughput`` and the ``capacity`` of the
+connected ``ResBuf``. Accordingly, you can update the ``input`` buffer's
+capacity before the DRE occurs to achieve this behavior.
+
+
+.. figure:: storage_capacity.svg
+ :align: center
+
+ **Figure:** Storage buffers between two time steps. The total capacity is
+ represented by the area of all three boxes. The ``input`` buffer's capacity
+ must be updated to reflect how much material is in both the ``inventory``
+ and ``output`` buffers. The colored arrows on the right match the material
+ flows in the previous figure.
+
+
+To do so, add the following line to the end of the ``Tick()`` function (in the
+implementation file), which updates capacity of the ``input`` through the
+``ResBuf`` ``capacity()`` API
+
+.. code-block:: c++
+
+ // only allow requests up to the storage capacity
+ input.capacity(capacity - inventory.quantity() - output.quantity());
+
+So the full ``Tick()`` function now looks like
+
+.. code-block:: c++
+
+ void Storage::Tick() {
+ int finished_storing = context()->time() - storage_time;
+ while (!inventory.empty() && entry_times.front() <= finished_storing) {
+ output.Push(inventory.Pop());
+ entry_times.pop_front();
+ }
+
+ // only allow requests up to the storage capacity
+ input.capacity(capacity - inventory.quantity() - output.quantity());
+
+ LOG(cyclus::LEV_INFO2, "Storage") << "Quantity to be requested: " << buy_policy.TotalQty() << " kg.";
+ LOG(cyclus::LEV_INFO2, "Storage") << "Quantity to be offered: " << sell_policy.Limit() << " kg.";
+ }
+
+
+Build and Test
+++++++++++++++++++++++++++++++++
+
+Same as it ever was
+
+.. code-block:: console
+
+ $ ./install.py
+ $ Storage_unit_tests
+
+Update Input File and Run
+++++++++++++++++++++++++++++++++
+
+You can test that your new capacity capability works by adding the following to
+the end of the ``config`` block for ``Storage`` (before the close tag
+) in ``input/storage.xml``
+
+.. code-block:: xml
+
+ 8
+
+Note that this capacity is smaller than the throughput! What do you think you
+will see in the output logs?
+
+Try it out (don't forget to delete the old sqlite file first):
+
+.. code-block:: console
+
+ $ rm cyclus.sqlite
+ $ cyclus -v 3 input/storage.xml
+ :
+ .CL:CC CC _Q _Q _Q_Q _Q _Q _Q
+ CC;CCCCCCCC:C; /_\) /_\)/_/\\) /_\) /_\) /_\)
+ CCCCCCCCCCCCCl __O|/O___O|/O_OO|/O__O|/O__O|/O____________O|/O__
+ CCCCCCf iCCCLCC /////////////////////////////////////////////////
+ iCCCt ;;;;;. CCCC
+ CCCC ;;;;;;;;;. CClL. c
+ CCCC ,;; ;;: CCCC ; : CCCCi
+ CCC ;; ;; CC ;;: CCC` `C;
+ lCCC ;; CCCC ;;;: :CC .;;. C; ; : ; :;;
+ CCCC ;. CCCC ;;;, CC ; ; Ci ; : ; : ;
+ iCC :; CC ;;;, ;C ; CC ; : ; .
+ CCCi ;; CCC ;;;. .C ; tf ; : ; ;.
+ CCC ;; CCC ;;;;;;; fC : lC ; : ; ;:
+ iCf ;; CC :;;: tC ; CC ; : ; ;
+ fCCC :; LCCf ;;;: LC :. ,: C ; ; ; ; ;
+ CCCC ;; CCCC ;;;: CCi `;;` CC. ;;;; :;.;. ; ,;
+ CCl ;; CC ;;;; CCC CCL
+ tCCC ;; ;; CCCL ;;; tCCCCC.
+ CCCC ;; :;; CCCCf ; ,L
+ lCCC ;;;;;; CCCL
+ CCCCCC :;; fCCCCC
+ . CCCC CCCC .
+ .CCCCCCCCCCCCCi
+ iCCCCCLCf
+ . C. ,
+ :
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: MatlBuyPolicy is experimental and its API may be subject to change
+ Experimental Warning: MatlSellPolicy is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: MatlBuyPolicy is experimental and its API may be subject to change
+ Experimental Warning: MatlSellPolicy is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: MatlBuyPolicy is experimental and its API may be subject to change
+ Experimental Warning: MatlSellPolicy is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: MatlBuyPolicy is experimental and its API may be subject to change
+ Experimental Warning: MatlSellPolicy is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: MatlBuyPolicy is experimental and its API may be subject to change
+ Experimental Warning: MatlSellPolicy is experimental and its API may be subject to change
+ INFO1(core ):Simulation set to run from start=0 to end=10
+ INFO1(core ):Beginning simulation
+ INFO1(core ):Current time: 0
+ INFO2(core ): Beginning Tick for time: 0
+ INFO2(Storag): Quantity to be requested: 8 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 0
+ INFO2(core ): Beginning Tock for time: 0
+ INFO2(Storag): The total inventory at time 0 is 0 kg of material.
+ INFO1(core ):Current time: 1
+ INFO2(core ): Beginning Tick for time: 1
+ INFO2(Storag): Quantity to be requested: 8 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 1
+ INFO2(core ): Beginning Tock for time: 1
+ INFO2(Storag): The total inventory at time 1 is 0 kg of material.
+ INFO1(core ):Current time: 2
+ INFO2(core ): Beginning Tick for time: 2
+ INFO2(Storag): Quantity to be requested: 8 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 2
+ INFO2(core ): Beginning Tock for time: 2
+ INFO2(Storag): The total inventory at time 2 is 0 kg of material.
+ INFO1(core ):Current time: 3
+ INFO2(core ): Beginning Tick for time: 3
+ INFO2(Storag): Quantity to be requested: 8 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 3
+ INFO2(core ): Beginning Tock for time: 3
+ INFO2(Storag): The total inventory at time 3 is 0 kg of material.
+ INFO1(core ):Current time: 4
+ INFO2(core ): Beginning Tick for time: 4
+ INFO2(Storag): Quantity to be requested: 8 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 4
+ INFO2(core ): Beginning Tock for time: 4
+ INFO2(Storag): The total inventory at time 4 is 0 kg of material.
+ INFO1(core ):Current time: 5
+ INFO2(core ): Beginning Tick for time: 5
+ INFO2(Storag): Quantity to be requested: 8 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 5
+ INFO2(core ): Beginning Tock for time: 5
+ INFO2(Storag): The total inventory at time 5 is 0 kg of material.
+ INFO1(core ):Current time: 6
+ INFO2(core ): Beginning Tick for time: 6
+ INFO2(Storag): Quantity to be requested: 8 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 6
+ INFO2(core ): Beginning Tock for time: 6
+ INFO2(Storag): The total inventory at time 6 is 0 kg of material.
+ INFO1(core ):Current time: 7
+ INFO2(core ): Beginning Tick for time: 7
+ INFO2(Storag): Quantity to be requested: 8 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 7
+ INFO2(core ): Beginning Tock for time: 7
+ INFO2(Storag): The total inventory at time 7 is 0 kg of material.
+ INFO1(core ):Current time: 8
+ INFO2(core ): Beginning Tick for time: 8
+ INFO2(Storag): Quantity to be requested: 8 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 8
+ INFO2(core ): Beginning Tock for time: 8
+ INFO2(Storag): The total inventory at time 8 is 0 kg of material.
+ INFO1(core ):Current time: 9
+ INFO2(core ): Beginning Tick for time: 9
+ INFO2(Storag): Quantity to be requested: 8 kg.
+ INFO2(Storag): Quantity to be offered: 0 kg.
+ INFO2(core ): Beginning DRE for time: 9
+ INFO2(core ): Beginning Tock for time: 9
+ INFO2(Storag): The total inventory at time 9 is 0 kg of material.
+
+ Status: Cyclus run successful!
+ Output location: cyclus.sqlite
+ Simulation ID: 1ce98e9b-bd89-402b-8bd6-c8266e293dba
diff --git a/_sources/arche/tutorial_py/index.rst.txt b/_sources/arche/tutorial_py/index.rst.txt
new file mode 100755
index 000000000..afd14b92a
--- /dev/null
+++ b/_sources/arche/tutorial_py/index.rst.txt
@@ -0,0 +1,28 @@
+Archetype Development Tutorial [Python]
+=======================================
+In this tutorial, we will work through a number of steps for creating a
+Facility archetype for Cyclus. This tutorial assumes that the learner is
+already reasonably familiar with programming in Python and with the primary
+vocabulary of Cyclus. We also assume that the learner has a Github account.
+
+Overview
+---------
+Through this tutorial, we will develop
+an open source Cyclus archetype module that includes an archetype to simulate
+a very simple interim storage facility, named ``Storage``. Ultimately, this
+facility will have the following characteristics, all definable by the user:
+
+* a fixed rate at which it can transfer material
+* a minimum time that material stays in storage
+* a fixed storage capacity
+
+This tutorial has the following steps:
+
+.. toctree::
+ :maxdepth: 1
+
+ setup
+ state_var
+ toolkit
+ testing
+ input_files
diff --git a/_sources/arche/tutorial_py/input_files.rst.txt b/_sources/arche/tutorial_py/input_files.rst.txt
new file mode 100755
index 000000000..65081a574
--- /dev/null
+++ b/_sources/arche/tutorial_py/input_files.rst.txt
@@ -0,0 +1,5 @@
+
+Making Input Files
+===============================
+Cyclus uses XML, JSON, or Python as its input file format, and there is an extensive guide to
+making input files on the `website `_.
diff --git a/_sources/arche/tutorial_py/setup.rst.txt b/_sources/arche/tutorial_py/setup.rst.txt
new file mode 100755
index 000000000..c175145a6
--- /dev/null
+++ b/_sources/arche/tutorial_py/setup.rst.txt
@@ -0,0 +1,170 @@
+Setup a New Project
+==============================================
+In this lesson, we will:
+
+1. Clean up the file system for the single storage facility
+2. Install the storage facility
+3. Run an input file that uses the new storage facility
+
+Make a New Project
+-------------------
+First let's start by making a tutorial example project with an ``agents.py`` file.
+
+.. code-block:: console
+
+ ~ $ mkdir -p tutorial/tut
+ ~ $ cd tutorial/tut
+ ~/tuorial/tut $ touch __init__.py agents.py
+
+
+Make a Storage Facility
+------------------------------------------
+Next, make a new facility by editing the ``agents.py`` file to look like the following:
+
+**~/tutorial/tut/agents.py:**
+
+.. code-block:: python
+
+ from cyclus.agents import Facility
+
+
+ class Storage(Facility):
+ """My storage facility."""
+
+ def tick(self):
+ print("Hello,")
+ print("World!")
+
+
+Install and Test
+----------------------------------
+To install the tutorial project, we'll need to have a ``setup.py`` file in the
+root tutorial directory. Create one that looks like:
+
+**~/tutorial/setup.py:**
+
+.. code-block:: python
+
+ #!/usr/bin/env python
+ from distutils.core import setup
+
+
+ VERSION = '0.0.1'
+ setup_kwargs = {
+ "version": VERSION,
+ "description": 'My Cyclus tutorial',
+ "author": 'Just Me',
+ }
+
+ if __name__ == '__main__':
+ setup(
+ name='tut',
+ packages=['tut'],
+ scripts=['xo'],
+ **setup_kwargs
+ )
+
+
+Now we can install the tutorial project via,
+
+.. code-block:: console
+
+ ~ $ cd tutorial
+ ~/tutorial $ python setup.py install --user
+
+
+Let's now make an example input file in a special ``input`` directory:
+
+.. code-block:: console
+
+ ~ $ cd tutorial
+ ~/tutorial $ mkdir -p input
+ ~/tutorial $ touch input/storage.py
+
+Now open up the ``input/storage.`` input file and edit it to look like:
+
+.. code-block:: python
+
+ SIMULATION = {
+ 'simulation': {
+ 'archetypes': {
+ 'spec': [
+ {'lib': 'tut.agents', 'name': 'Storage'},
+ {'lib': 'agents', 'name': 'NullInst'},
+ {'lib': 'agents', 'name': 'NullRegion'},
+ ],
+ },
+ 'control': {'duration': 10, 'startmonth': 1, 'startyear': 2000},
+ 'facility': {'config': {'Storage': None}, 'name': 'OneFacility'},
+ 'region': {
+ 'config': {'NullRegion': None},
+ 'institution': {
+ 'config': {'NullInst': None},
+ 'initialfacilitylist': {'entry': {'number': 1, 'prototype': 'OneFacility'},},
+ 'name': 'OneInst',
+ },
+ 'name': 'OneRegion',
+ },
+ },
+ }
+
+
+Test the input file by running |Cyclus|:
+
+.. code-block:: console
+
+ $ cyclus -v 2 input/storage.py
+ :
+ .CL:CC CC _Q _Q _Q_Q _Q _Q _Q
+ CC;CCCCCCCC:C; /_\) /_\)/_/\\) /_\) /_\) /_\)
+ CCCCCCCCCCCCCl __O|/O___O|/O_OO|/O__O|/O__O|/O____________O|/O__
+ CCCCCCf iCCCLCC /////////////////////////////////////////////////
+ iCCCt ;;;;;. CCCC
+ CCCC ;;;;;;;;;. CClL. c
+ CCCC ,;; ;;: CCCC ; : CCCCi
+ CCC ;; ;; CC ;;: CCC` `C;
+ lCCC ;; CCCC ;;;: :CC .;;. C; ; : ; :;;
+ CCCC ;. CCCC ;;;, CC ; ; Ci ; : ; : ;
+ iCC :; CC ;;;, ;C ; CC ; : ; .
+ CCCi ;; CCC ;;;. .C ; tf ; : ; ;.
+ CCC ;; CCC ;;;;;;; fC : lC ; : ; ;:
+ iCf ;; CC :;;: tC ; CC ; : ; ;
+ fCCC :; LCCf ;;;: LC :. ,: C ; ; ; ; ;
+ CCCC ;; CCCC ;;;: CCi `;;` CC. ;;;; :;.;. ; ,;
+ CCl ;; CC ;;;; CCC CCL
+ tCCC ;; ;; CCCL ;;; tCCCCC.
+ CCCC ;; :;; CCCCf ; ,L
+ lCCC ;;;;;; CCCL
+ CCCCCC :;; fCCCCC
+ . CCCC CCCC .
+ .CCCCCCCCCCCCCi
+ iCCCCCLCf
+ . C. ,
+ :
+ INFO1(core ):Simulation set to run from start=0 to end=10
+ INFO1(core ):Beginning simulation
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+
+ Status: Cyclus run successful!
+ Output location: cyclus.sqlite
+ Simulation ID: 9f15b93c-9ab2-49bb-a14f-fef872e64ce8
+
diff --git a/_sources/arche/tutorial_py/state_var.rst.txt b/_sources/arche/tutorial_py/state_var.rst.txt
new file mode 100755
index 000000000..2def677a4
--- /dev/null
+++ b/_sources/arche/tutorial_py/state_var.rst.txt
@@ -0,0 +1,228 @@
+Adding State Variables
+=======================
+In this lesson, we will:
+
+1. Add the necessary state variables to define the storage facility
+3. Modify the sample input file to include these variables
+
+Add State Variables
+----------------------------------------------
+The Cyclus Python interface preprocessor provides a ``typesystem`` module that help define
+variables that are state variables for an archetype. These state vars also allow convenient
+annotations.
+
+First, we'll add the maximum monthly transfer capacity, called ``throughput``.
+Open the file ``tutorial/tut/agents.py`` in your text editor.
+Immediately after the storage class name, add the following:
+
+**~/tutorial/tut/agents.py:**
+
+.. code-block:: python
+
+ from cyclus.agents import Facility
+ import cyclus.typesystem as ts
+
+
+ class Storage(Facility):
+ """My storage facility."""
+
+ # this declares throughput to be of type double for purposes of storage
+ # and user input
+ throughput = ts.Double(
+ doc="Maximum amount of material that can be transferred in or "
+ "out each time step",
+ tooltip="Maximum amount of material that can be transferred in "
+ "or out each time step",
+ units="kg",
+ uilabel="Maximum Throughput",
+ )
+
+ def tick(self):
+ print("Hello, World!")
+
+
+Now, we'll add variables for the minimum amount of time that material is
+stored and the input/output commodity names.
+
+**~/tutorial/tut/agents.py:**
+
+.. code-block:: python
+
+ class Storage(Facility):
+ """My storage facility."""
+ ...
+ storage_time = ts.Int(
+ doc="Minimum amount of time material must be stored",
+ tooltip="Minimum amount of time material must be stored",
+ units="months",
+ uilabel="Storage Time",
+ )
+ incommod = ts.String(
+ tooltip="Storage input commodity",
+ doc="Input commodity on which Storage requests material.",
+ uilabel="Input Commodity",
+ uitype="incommodity",
+ )
+ outcommod = ts.Int(
+ tooltip="Storage output commodity",
+ doc="Output commodity on which Storage offers material.",
+ uilabel="Output Commodity",
+ uitype="outcommodity",
+ )
+ ...
+
+Re-innstall the Modified Module
+---------------------------------------
+To reinstall this module, just issue the same ``setup.py`` command as before:
+
+.. code-block:: console
+
+ ~/tutorial $ python setup.py install --user
+
+
+Modify the Input File
+-------------------------
+If you try to run the same input file with your modified module, you will get
+errors because the sample input file no longer includes the necessary pieces
+to define your module. It is missing the new variables. Try it:
+
+.. code-block:: console
+
+ ~/tutorial $ cyclus -v 2 input/storage.py
+ :
+ .CL:CC CC _Q _Q _Q_Q _Q _Q _Q
+ CC;CCCCCCCC:C; /_\) /_\)/_/\\) /_\) /_\) /_\)
+ CCCCCCCCCCCCCl __O|/O___O|/O_OO|/O__O|/O__O|/O____________O|/O__
+ CCCCCCf iCCCLCC /////////////////////////////////////////////////
+ iCCCt ;;;;;. CCCC
+ CCCC ;;;;;;;;;. CClL. c
+ CCCC ,;; ;;: CCCC ; : CCCCi
+ CCC ;; ;; CC ;;: CCC` `C;
+ lCCC ;; CCCC ;;;: :CC .;;. C; ; : ; :;;
+ CCCC ;. CCCC ;;;, CC ; ; Ci ; : ; : ;
+ iCC :; CC ;;;, ;C ; CC ; : ; .
+ CCCi ;; CCC ;;;. .C ; tf ; : ; ;.
+ CCC ;; CCC ;;;;;;; fC : lC ; : ; ;:
+ iCf ;; CC :;;: tC ; CC ; : ; ;
+ fCCC :; LCCf ;;;: LC :. ,: C ; ; ; ; ;
+ CCCC ;; CCCC ;;;: CCi `;;` CC. ;;;; :;.;. ; ,;
+ CCl ;; CC ;;;; CCC CCL
+ tCCC ;; ;; CCCL ;;; tCCCCC.
+ CCCC ;; :;; CCCCf ; ,L
+ lCCC ;;;;;; CCCL
+ CCCCCC :;; fCCCCC
+ . CCCC CCCC .
+ .CCCCCCCCCCCCCi
+ iCCCCCLCf
+ . C. ,
+ :
+ Entity: line 17: element Storage: Relax-NG validity error : Expecting an element throughput, got nothing
+ Entity: line 17: element Storage: Relax-NG validity error : Invalid sequence in interleave
+ Entity: line 17: element Storage: Relax-NG validity error : Element Storage failed to validate content
+ ERROR(core ):Document failed schema validation
+
+The simulation now fails because it does not match the schema. You can view the schema with
+
+.. code-block:: console
+
+ ~/tutorial $ cyclus --agent-schema :tut.agents:Storage
+
+Notice that you were able to take advantage of the input file validation simply by using
+the special ``typesystem`` class attributes.
+
+Our failed cyclus simulation produced an output file that will need to be deleted.
+
+.. code-block:: console
+
+ ~/tutorial $ rm cyclus.sqlite
+
+Now, we'll change that input file. Open the file ``input/storage.py`` in
+your text editor, and find the prototype configuration for the single facility
+named "OneFacility" that looks like this.
+
+**~/tutorial/input/storage.py:**
+
+.. code-block:: python
+
+ {
+ # ...
+ 'facility': {'config': {'Storage': None}, 'name': 'OneFacility'}
+ # ...
+ }
+
+We need to replace the ```` element with this:
+
+**~/tutorial/input/storage.py:**
+
+.. code-block:: python
+
+ {
+ # ...
+ 'facility': {'config': {'Storage': {
+ 'throughput': 10,
+ 'storage_time': 1,
+ 'incommod': 'fuel',
+ 'outcommod': 'stored_fuel',
+ }},
+ 'name': 'OneFacility'}
+ # ...
+ }
+
+Now we can try it again:
+
+.. code-block:: console
+
+ ~/tutorial $ cyclus -v 2 input/storage.py
+ :
+ .CL:CC CC _Q _Q _Q_Q _Q _Q _Q
+ CC;CCCCCCCC:C; /_\) /_\)/_/\\) /_\) /_\) /_\)
+ CCCCCCCCCCCCCl __O|/O___O|/O_OO|/O__O|/O__O|/O____________O|/O__
+ CCCCCCf iCCCLCC /////////////////////////////////////////////////
+ iCCCt ;;;;;. CCCC
+ CCCC ;;;;;;;;;. CClL. c
+ CCCC ,;; ;;: CCCC ; : CCCCi
+ CCC ;; ;; CC ;;: CCC` `C;
+ lCCC ;; CCCC ;;;: :CC .;;. C; ; : ; :;;
+ CCCC ;. CCCC ;;;, CC ; ; Ci ; : ; : ;
+ iCC :; CC ;;;, ;C ; CC ; : ; .
+ CCCi ;; CCC ;;;. .C ; tf ; : ; ;.
+ CCC ;; CCC ;;;;;;; fC : lC ; : ; ;:
+ iCf ;; CC :;;: tC ; CC ; : ; ;
+ fCCC :; LCCf ;;;: LC :. ,: C ; ; ; ; ;
+ CCCC ;; CCCC ;;;: CCi `;;` CC. ;;;; :;.;. ; ,;
+ CCl ;; CC ;;;; CCC CCL
+ tCCC ;; ;; CCCL ;;; tCCCCC.
+ CCCC ;; :;; CCCCf ; ,L
+ lCCC ;;;;;; CCCL
+ CCCCCC :;; fCCCCC
+ . CCCC CCCC .
+ .CCCCCCCCCCCCCi
+ iCCCCCLCf
+ . C. ,
+ :
+ INFO1(core ):Simulation set to run from start=0 to end=10
+ INFO1(core ):Beginning simulation
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+
+ Status: Cyclus run successful!
+ Output location: cyclus.sqlite
+ Simulation ID: 9f15b93c-9ab2-49bb-a14f-fef872e64ce8
diff --git a/_sources/arche/tutorial_py/testing.rst.txt b/_sources/arche/tutorial_py/testing.rst.txt
new file mode 100755
index 000000000..688b997c1
--- /dev/null
+++ b/_sources/arche/tutorial_py/testing.rst.txt
@@ -0,0 +1,4 @@
+Adding a Test
+================
+Feel free to use pytest, nosetests, or your favorite Python testing framework to test your
+archetypes.
\ No newline at end of file
diff --git a/_sources/arche/tutorial_py/toolkit.rst.txt b/_sources/arche/tutorial_py/toolkit.rst.txt
new file mode 100755
index 000000000..eb0b4eed9
--- /dev/null
+++ b/_sources/arche/tutorial_py/toolkit.rst.txt
@@ -0,0 +1,329 @@
+Adding Resource Buffers
+=================================================
+In this lesson, we will:
+
+1. Add ResBufs to track material inventories
+2. Add a notion of total storage capacity
+
+Overview
+--------------
+Cyclus has a collection of standard patterns that can be used by
+archetype developers. There are many advantages to using the toolkit patterns
+rather than developing similar functionality yourself, typical of most code
+reuse situations:
+
+* robustness - toolkit patterns have been subjected to the Cyclus QA process
+* time savings - It will take less time to learn how to use a toolkit than it takes to develop your own
+* improvements - You can benefit immediately from any improvements in the performance of the toolkit pattern
+
+Code reuse is a critical best practice in all software development.
+
+One of the toolkit patterns is a ``ResBuf``, providing a way to track an
+inventory of ``Resource`` objects.
+
+Add State Variables and Resource Buffers
+------------------------------------------
+All state variable additions should be included in ``~/tutorial/tut/agents.py`` below the
+other state variables added previously in this tutorial.
+
+A ``ResBuf`` is available as a data type in the ``typesystem``. However, to use it
+as a state variable, so we instead have to use the ``ResBufMaterialInv`` or
+``RefBufProductInv`` classes. These inventories should be added below the other state
+variables we have already applied to the storage class.
+
+
+**~/tutorial/tut/agents.py:**
+
+.. code-block:: python
+
+ from cyclus.agents import Facility
+ import cyclus.typesystem as ts
+
+
+ class Storage(Facility):
+ """My storage facility."""
+ ...
+ # this facility holds material in storage.
+ inventory = ts.ResBufMaterialInv()
+
+
+This creates a state variable named ``inventory`` that is based on the
+``ResBuf`` class. We'll explain how buffers
+work in just a moment. A ResBuf object and its ``ts.Inventory`` state var has special
+handling by the Python ``Agent`` class from which ``Facility`` inherits. It will not appear
+in the schema.
+
+Next, add two additional buffers:
+
+**~/tutorial/tut/agents.py:**
+
+.. code-block:: python
+
+ class Storage(Facility):
+ """My storage facility."""
+ ...
+ # this facility holds material in storage.
+ inventory = ts.ResBufMaterialInv()
+ # a buffer for incoming material
+ input = ts.ResBufMaterialInv()
+ # a buffer for outgoing material
+ output = ts.ResBufMaterialInv()
+
+
+Finally, check that everything works by reinstalling like before.
+You can also confirm that everything still works with running the simulation:
+
+.. code-block:: console
+
+ ~/tutorial $ cyclus -v 3 input/storage.py
+ :
+ .CL:CC CC _Q _Q _Q_Q _Q _Q _Q
+ CC;CCCCCCCC:C; /_\) /_\)/_/\\) /_\) /_\) /_\)
+ CCCCCCCCCCCCCl __O|/O___O|/O_OO|/O__O|/O__O|/O____________O|/O__
+ CCCCCCf iCCCLCC /////////////////////////////////////////////////
+ iCCCt ;;;;;. CCCC
+ CCCC ;;;;;;;;;. CClL. c
+ CCCC ,;; ;;: CCCC ; : CCCCi
+ CCC ;; ;; CC ;;: CCC` `C;
+ lCCC ;; CCCC ;;;: :CC .;;. C; ; : ; :;;
+ CCCC ;. CCCC ;;;, CC ; ; Ci ; : ; : ;
+ iCC :; CC ;;;, ;C ; CC ; : ; .
+ CCCi ;; CCC ;;;. .C ; tf ; : ; ;.
+ CCC ;; CCC ;;;;;;; fC : lC ; : ; ;:
+ iCf ;; CC :;;: tC ; CC ; : ; ;
+ fCCC :; LCCf ;;;: LC :. ,: C ; ; ; ; ;
+ CCCC ;; CCCC ;;;: CCi `;;` CC. ;;;; :;.;. ; ,;
+ CCl ;; CC ;;;; CCC CCL
+ tCCC ;; ;; CCCL ;;; tCCCCC.
+ CCCC ;; :;; CCCCf ; ,L
+ lCCC ;;;;;; CCCL
+ CCCCCC :;; fCCCCC
+ . CCCC CCCC .
+ .CCCCCCCCCCCCCi
+ iCCCCCLCf
+ . C. ,
+ :
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ Experimental Warning: ResBuf is experimental and its API may be subject to change
+ INFO1(core ):Simulation set to run from start=0 to end=10
+ INFO1(core ):Beginning simulation
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+ INFO1(tutori):Hello
+ INFO1(tutori):World!
+
+ Status: Cyclus run successful!
+ Output location: cyclus.sqlite
+ Simulation ID: 9f15b93c-9ab2-49bb-a14f-fef872e64ce8
+
+
+Add Implementation Logic
+-----------------------------
+The goal of a storage facility is to ask for material up to some limit, store it
+for an amount of time, and then send it on to any interested parties. This can
+be implemented in Cyclus by utilizing the Toolkit objects stated above. The buy
+and sell policies will automatically fill and empty the input and output
+buffers, respectively. A concept of material flow through the facility is
+shown below.
+
+.. figure:: storage_diagram.svg
+ :width: 75 %
+ :align: center
+
+ **Figure:** Material flow through a Storage facility. Green arrows occur
+ **before** the DRE (during the Tick). Yellow arrows occur during the
+ DRE. Brown arrows occur **after** the DRE (during the Tock).
+
+
+Buffer Transfer Logic
+++++++++++++++++++++++++++++++++
+The job of the ``Storage`` archetype developer is to determine and implement
+the logic related to transferring material between the input and output buffers
+and the middle inventory buffer. Two rules govern buffer transfer logic
+in this model:
+
+1. All material in the input buffer is transferred to the inventory buffer
+2. Material in the inventory buffer that has been stored for long enough is
+ transferred to the output buffer
+
+Because the input buffer transfer should occur *after* the DRE, it must happen
+in the ``tock()`` method. Similarly, because the output buffer transfer should
+occur *before* the DRE, it must happen in the ``tick()`` method. For each
+transfer, care must be taken to update the ``entry_times`` list appropriately.
+
+The input buffer transfer requires the following operation for each object in
+the buffer:
+
+1. *Pop* the object from the input buffer
+2. *Push* the object to the inventory buffer
+3. *Push* the current time to the ``entry_times``
+
+In order to implement this, add or replace the current ``tock()`` implementation in
+``agents/py`` with:
+
+**~/tutorial/tut/agents.py:**
+
+.. code-block:: python
+
+ class Storage(Facility):
+ """My storage facility."""
+ ...
+ def __init__(self, ctx):
+ """Agents that have an init method must accept a context and must call super
+ first thing!
+ """
+ super().__init__(ctx)
+ self.entry_times = []
+
+ def tock(self):
+ t = self.context.time
+ while not self.input.empty():
+ self.inventory.push(self.input.pop())
+ entry_times.append(t)
+
+The output buffer transfer requires the following operation so long as the
+condition in 1. is met:
+
+1. Check whether enough time has passed since the time at the front of
+ ``entry_times`` *and* the inventory is not empty. If so:
+2. *pop()* an object from the inventory buffer
+3. *push()* that object to the output buffer
+4. *pop()* a time from the ``entry_times``
+
+In order to implement this, replace the current ``tick()`` implementation in
+``agents.py`` with
+
+**~/tutorial/tut/agents.py:**
+
+.. code-block:: python
+
+ class Storage(Facility):
+ """My storage facility."""
+ ...
+ def tick(self):
+ finished_storing = self.context.time - self.storage_time
+ while (not self.inventory.empty()) and (self.entry_times[0] <= finished_storing):
+ self.output.push(self.inventory.pop())
+ del self.entry_times[0]
+
+
+At this point, please feel free to reinstall and rerun.
+
+Add a State Variable to Define Storage Capcity
+-------------------------------------------------------------
+A natural extension for the current storage facility implementation is to have a
+maximum storage capacity. To do so, first add a capacity state variable to
+storage.h . If you still want the input file to work, you have to provide a
+``default`` key in the pragma data structure. A sufficiently large value will
+do.
+
+**~/tutorial/tut/agents.py:**
+
+.. code-block:: python
+
+ class Storage(Facility):
+ """My storage facility."""
+ ...
+ capacity = ts.Double(
+ doc='Maximum storage capacity (including all material in the facility)',
+ tooltip='Maximum storage capacity',
+ units='kg',
+ default=1e200,
+ uilabel='Maximum Storage Capacity',
+ )
+
+The required implementation is nontrivial. The goal of adding a capacity
+member is to guarantee that the amount of material in the facility never exceeds
+a certain value. The only way for material to enter the facility is through the
+``input`` ResBuff.
+
+.. figure:: storage_capacity.svg
+ :align: center
+
+ **Figure:** Storage buffers between two time steps. The total capacity is
+ represented by the area of all three boxes. The ``input`` buffer's capacity
+ must be updated to reflect how much material is in both the ``inventory``
+ and ``output`` buffers. The colored arrows on the right match the material
+ flows in the previous figure.
+
+
+To do so, add the following line to the end of the ``tick()`` function (in the
+implementation file), which updates capacity of the ``input`` through the
+``ResBuf`` ``capacity`` API.
+
+**~/tutorial/tut/agents.py:**
+
+.. code-block:: python
+
+ class Storage(Facility):
+ """My storage facility."""
+ ...
+ def tick(self):
+ finished_storing = self.context.time - self.storage_time
+ while (not self.inventory.empty()) and (self.entry_times[0] <= finished_storing):
+ self.output.push(self.inventory.pop())
+ del self.entry_times[0]
+ # only allow requests up to the storage capacity
+ self.input.capacity = self.capacity - self.inventory.quantity - self.output.quantity
+
+
+
+Update Input File and Run
+++++++++++++++++++++++++++++++++
+You can test that your new capacity capability works by adding the following to
+the end of the ``config`` block for ``Storage`` (before the close tag
+) in ``input/storage.py``
+
+
+**~/tutorial/input/storage.py:**
+
+.. code-block:: python
+
+ {
+ # ...
+ 'facility': {'config': {'Storage': {
+ 'throughput': 10,
+ 'storage_time': 1,
+ 'incommod': 'fuel',
+ 'outcommod': 'stored_fuel',
+ # capacity is optional since it has a default
+ 'capacity': 8,
+ }},
+ 'name': 'OneFacility'}
+ # ...
+ }
+
+
+Note that this capacity is smaller than the throughput! What do you think you
+will see in the output logs?
+
+Try it out (don't forget to delete the old sqlite file first)!
diff --git a/_sources/basics/acknowledgements.rst.txt b/_sources/basics/acknowledgements.rst.txt
new file mode 100755
index 000000000..9ce133383
--- /dev/null
+++ b/_sources/basics/acknowledgements.rst.txt
@@ -0,0 +1,27 @@
+|Cyclus| Funding and Support
+============================
+
+The development of the |Cyclus| core infrastructure has been supported
+by a number of programs and agencies.
+
+* U.S. Nuclear Regulatory Commission
+
+ * Faculty Development Program
+
+* Department of Energy Nuclear Energy University Program (NEUP)
+
+ * Fellowship program
+ * Research and Development program
+
+* University of Wisconsin-Madison Graduate School
+
+ * Graduate School Research program
+
+* Argonne National Laboratory
+
+ * Lab-grad program
+
+The |Cyclus| project benefits greatly from the computational resources of the
+University of Wisconsin-Madison's `Center for High Throughput Computing
+`_ and it's `BaTLab `_ build
+and test facility.
diff --git a/_sources/basics/concepts.rst.txt b/_sources/basics/concepts.rst.txt
new file mode 100755
index 000000000..8dae3b4db
--- /dev/null
+++ b/_sources/basics/concepts.rst.txt
@@ -0,0 +1,125 @@
+.. _basics-concepts:
+
+Fundamental Concepts in |Cyclus|
+================================
+
+Several fundamental concepts are deeply engrained in the |Cyclus| kernel, and
+understanding them is important for users and developers of |Cyclus|.
+
+The following concepts are defined in more detail below:
+
+* |Cyclus| is an :ref:`agent-based simulation `
+* agents are either :ref:`regions, institutions, or facilities `
+* |Cyclus| tracks the :ref:`evolution of a system over time `
+* agents interact through a :ref:`dynamic resource exchange ` that is recomputed at each time step
+* |Cyclus| catalogs the transactions of :ref:`discrete quanta of resources `
+* agents may :ref:`enter or leave the simulation ` over the lifetime of a simulation
+* each agent is deployed as a :ref:`clone of a prototype `
+* each prototype is defined as a :ref:`configuration an archetype `
+* archetypes are :ref:`loaded dynamically at runtime ` and can be contributed by any user/developer
+
+.. _agent-based:
+
+Agent-Based Simulation
+----------------------
+
+A |Cyclus| simulation models a system of discrete agents that interact to
+exchange resources. Most of the behavior of a |Cyclus| simulation is the
+result of the interaction among a set of individual and nominally independent
+agents.
+
+.. _rif:
+
+Region, Institution, Facility Hierarchy
+---------------------------------------
+
+The primary agent interaction is among Facility agents, each representing a
+single discrete nuclear fuel cycle facility.
+
+Each Facility agent is owned/operated by an Institution agent, representing a
+legal operating organization such as a utility, government, non-governmental
+organization, etc. Institution agents are responsible for deploying and
+decommissioning Facility agents.
+
+Each Institution operates in a Region agent, representing a geopolitical
+region such as a nation-state, sub-national state, super-national region, etc.
+Region agents are responsible for requesting the deployment of additional
+Facilities through their Institutions.
+
+Institution and Region agents can alter the way that their Facility agents
+interact with other Facility agents.
+
+.. _timesim:
+
+Tracking the Evolution of a System Over Time
+---------------------------------------------
+
+A |Cyclus| simulation marches through time with a fixed time step. At each
+time step, the system itself may change and the dynamic resource exchange is
+recomputed.
+
+.. _dre_concepts:
+
+Dynamic Resource Exchange
+-------------------------
+
+Facility agents interact through the dynamic resource exchange by submitting
+requests for resources and/or receiving bids to provide those resources. All
+facilities that request resources can then establish their preferences across
+the set of bids they receive and the global set of preferences is used to
+resolve the exchange by maximizing the global preference.
+
+.. _discretemat:
+
+Discrete Resource Tracking
+--------------------------
+
+The outcome of the dynamic resource exchange is a set of transactions of
+discrete resources, with specific quantities and identities, between specific
+facility agents. These discrete resources can be tracked through their
+life cycle by their identities.
+
+.. _deploy:
+
+Agent Deployment and Decommissioning
+------------------------------------
+
+Facility agents can be deployed or decommissioned at each time step, changing
+the system that is being modeled through the dynamic resource exchange. The
+decision of when to deploy new facility agents and which agents to deploy is
+made by the institution agents based on user input. Agents may be
+decommissioned either because they reach their lifetime or because a decision
+to decommission is made by the institution that operates them.
+
+.. _prototype:
+
+Agent Prototypes
+----------------
+
+Each agent in the simulation is deployed as a clone of a prototype. A
+prototype is formed by adding user-defined configuration details to an
+archetype.
+
+.. _archetype:
+
+Agent Archetypes
+----------------
+
+Agent archetypes define the logic that governs the behavior of an agent. An
+archetype may allow a user to define some parameters that influence that
+behavior. Broadly speaking, the behavior of an agent can be divided into the
+behavior that represents the physical models of the system and the behavior
+that represents the interaction of the agent with other agents.
+
+.. _plugin:
+
+Run-time Discovery and Loading of Archetypes
+--------------------------------------------
+
+To maximize the flexibility of the |Cyclus| infrastructure, is has been
+designed to allow the addition of new archetypes without having to make any
+changes to the |Cyclus| kernel. Therefore, the kernel has no *a priori*
+knowledge of archetypes or their behavior other than how they are
+deployed/decommissioned and how they interact with the dynamic resource
+exchange. For this reason, every |Cyclus| simulation must find and load the
+archetypes requested by the user.
diff --git a/_sources/basics/ecosystem.rst.txt b/_sources/basics/ecosystem.rst.txt
new file mode 100755
index 000000000..2d3801ded
--- /dev/null
+++ b/_sources/basics/ecosystem.rst.txt
@@ -0,0 +1,162 @@
+====================================
+ The |Cyclus| Community & Ecosystem
+====================================
+
+**The Cyclus project is owned by its community of users & developers and welcomes code & contributions from everyone!**
+
+An important goal of the |cyclus| effort is to attract a community of
+developers contributing to a vibrant ecosystem of models. Due to
+sensitivities regarding the distribution of software for simulating nuclear
+systems, this ecosystem requires careful considerations in its design and
+implementation.
+
+Critical to the success of this community is the widespread availability of
+the core infrastructure of the |Cyclus| simulation environment. Because this
+environment is formulated using a variety of generic concepts not specific to
+nuclear energy systems, this should mitigate concerns for the open source
+distribution of this core infrastructure.
+
+Moreover, this infrastructure is also designed to allow for the addition of
+runtime :term:`modules `, or :term:`plug-ins `, that can be developed and
+distributed under any licensing scheme. Separate from the core
+infrastructure, the distribution responsibility will rest with the developer
+of each module. This system will insulate the core infrastructure from
+accidental "pollution" by modules of a sensitive nature, and, similarly, limit
+issues regarding the authorization for distribution to the author's
+organization. Ideally, most module developers will be authorized for open
+distribution of their modules.
+
+Finally, the community will be relied upon to provide review and curation of
+available modules, establishing both quality assurance practices and
+recommendations for best use cases for each contributed module.
+
+Below, a more detailed exposition of these characteristics is provided.
+
+Open Source Core Infrastructure
+================================
+
+The current portfolio of fuel cycle simulators has been characterized by
+barriers to adoption by new users and developers including:
+
+* policies of limited/restricted distribution,
+
+* reliance on propriety software development infrastructures, and
+
+* deeply embedded nuclear technology assumptions arising from
+ development path.
+
+Because one of the principle purposes of |cyclus| is to create a fuel cycle
+simulator system with a low barrier to adoption, a policy of open source
+distribution of this core infrastructure is critical to its mission.
+(|cyclus| is also committed to free and widely used software development
+tools, such as GNU compilers, SQLite, Boost, etc.) The |cyclus| core is
+currently available via its `GitHub repository
+`_. Interested users and developers are
+invited to make their own copy of this repository, review the list of open
+issues, and participate in the developer's mailing list. Like all open source
+projects, this distribution mode permits a thorough code review by interested
+parties and the possibility of contributions in order to identify/resolve
+defects or request/provide feature enhancements.
+
+The |cyclus| core infrastructure provides a generic environment for modeling
+flows of materials through a collection of nuclear facilities. This
+infrastructure could be used for modeling many different supply chain systems,
+nuclear and non-nuclear alike, this infrastructure prioritizes nuclear systems
+analysis. Addressing the barrier of deeply embedded nuclear technology
+assumptions, this approach ensures that the core infrastructure has a very low
+risk of containing sensitive information regarding the simulation of nuclear
+systems. These capabilities are added by acquiring and invoking plug-ins
+developed and distributed by the |cyclus| community.
+
+The open source approach can also allow the project to leverage the efforts a
+larger pool of developers and improve the quality of the software product
+[1]_.
+
+Decentralized Module Development & Distribution
+===============================================
+
+When a user/developer wishes to contribute a new module to the |cyclus|
+ecosystem, they will be responsible for all aspects of that distribution. The
+|cyclus| core development team will provide a catalog of available modules
+(details are still under development), but this catalog will point to external
+distribution sites that are consistent with each contributors personal and/or
+institutional needs. For example, developers who are permitted to follow an
+open source approach with their own contributions can have their own GitHub
+account and share their modules through the same mechanism as - but a
+different location from - the |cyclus| core. For some subset of open source
+distribution mechanisms, the |cyclus| core will include tools to make it
+easier for individual users to download and install contributed modules or
+collections of modules.
+
+Decentralizing the development and distribution of runtime modules provides a
+number of benefits. First, as is true for the core infrastructure, a larger
+pool of developers can contribute to the |cyclus| ecosystem by providing
+modules that represent their organization's specific interests. If a
+particular user/developer would like to understand the impact of their own
+technology on the greater fuel cycle, they are free to develop a module that
+simulates this technology and contribute it to the broader community.
+
+More importantly, this will contribute to the maintenance of a "pristine" core
+infrastructure, from the point of view of sensitive information. Any software
+added to the source code repository leaves behind permanent artifacts - even
+if removed at a later date. The inclusion of all newly developed plug-ins in a
+centralized software repository could result in the entire repository being
+declared sensitive. Decentralized distribution mitigates this risk.
+
+Finally, a centralized approach would require identifying a single
+organization that would accept an ongoing burden of authorizing distribution,
+assessing quality and assembling collections. A decentralized approach
+removes the burden of authorizing distribution and reviewing contributions
+from a central authority. Rather, the authors and community are responsible
+for these tasks, as described in the following sections.
+
+Distribution Authorization by Owner
+-----------------------------------
+
+Considering the concerns for copyright, intellectual property, and the risk
+that sensitive information could be contained in a module, the burden of
+acquiring and confirming distribution rights by a centralized organization
+could become prohibitive. If instead the modules developed for the |cyclus|
+ecosystem are documented in a catalog that refers to a variety distribution
+sites as appropriate for each developer, the effort for ensuring the rights
+for distribution are the responsibility of the developer and their
+organization. The inclusion of a given module in the catalog requires little
+oversight and the details of distribution remain between the provider and
+consumer of each module.
+
+Peer-review QA and Rating
+---------------------------
+
+For most organizations, including a plug-in in a centralized software
+distribution would be regarded as a tacit approval of the quality and utility
+of the module. In most such cases, a substantial burden of quality assurance
+and testing would be required by the organization preforming this centralized
+distribution. In the decentralized approach of the |cyclus| ecosystem,
+mechanisms will be provided for members of the community to provide
+peer-review of the modules' quality and applicability to certain problems.
+
+For modules that are distributed with an open source policy, other users and
+developers will be able to perform a direct source code review as well as
+testing the functionality of the module in fuel cycle analyses. For other
+distribution policies, more limited review will be possible.
+
+In all cases, practices and policies will emerge from the community to support
+standardization of this process. For example, providing adequate
+documentation and test suites will result in a better review from members of
+the community and ultimately will become pre-requisites to a positive peer
+review.
+
+Curation and Collections
+-------------------------
+
+When the number of contributions is sufficiently large, there will be benefit
+in developing collections of modules that are known to be useful for certain
+types of simulations. A decentralized approach will allow individual members
+of the |cyclus| community to create such collections, providing a curation
+function to help both new and experienced users identify the modules that are
+likely to give them the most benefit.
+
+Footnotes
+^^^^^^^^^
+
+.. [1] J.W. Paulson, *et al*, "An Empirical Study of Open-Source and Closed-Source Software Products", *IEEE Transactions on Software Engineering*, **30** (4), April 2004. http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=01274044
diff --git a/_sources/basics/fcs_background.rst.txt b/_sources/basics/fcs_background.rst.txt
new file mode 100755
index 000000000..0122b242f
--- /dev/null
+++ b/_sources/basics/fcs_background.rst.txt
@@ -0,0 +1,58 @@
+Nuclear Fuel Cycle Simulators
+-----------------------------
+
+A nuclear :term:`fuel cycle simulator` is a tool used to explore the impacts of
+alternative nuclear fuel cycle choices when considered as a full system at a
+national or international level. Fundamentally, these simulators track the
+flow of materials through the nuclear fuel cycle, accounting for processes
+such as enrichment, transmutation, decay, and partition of isotopes. From the
+material flows and information about the operation history of the associated
+facilities, various metrics can be assessed for different nuclear fuel cycle
+designs. As such, economic, environmental and security metrics resulting from
+different fuel cycles can be compared to support decision making on research,
+development and deployment decisions for future fuel cycle facilities.
+
+Fuel cycle simulators provide insights into important trends as nuclear fuel
+cycles undergo technological transitions in an uncertain socio-political
+environment. While it is important to achieve an overall conservation of
+mass, there is typically a trade-off between the accuracy of specific isotopic
+compositions and the speed of calculation. Given the inherent uncertainty of
+making predictions in unknown socio-political futures, the physics models used
+for each individual process in the fuel cycle are generally low-order
+approximations based on a higher order analysis.
+
+Fuel cycle simulators are not designed to provide detailed simulations
+of specific facilities: neither high-fidelity predictive simulation nor
+virtual reality environments.
+
+History of Nuclear Fuel Cycle Simulators
+++++++++++++++++++++++++++++++++++++++++
+
+A variety of simulators have been developed to study nuclear fuel cycles in
+two categories. One category models detailed facilities arranged in complex
+coupling schemes that are validated with measurements from real systems.
+While these tools offer a much more rigorous treatment of the physics, they
+often require an experienced analyst to compute the results and may offer more
+precision in the physics than is warranted given the socio-political
+uncertainty. The other category of tools is typically derived from simplified
+systems models, with physics detail and complexity added where necessary to
+improve the fidelity of results, but preferring rapid computation to
+precision.
+
+Regardless of the development path, these simulators have inherent
+assumptions, limitations in their underlying software infrastructure, and
+constraints on the variety of nuclear fuel cycle options that can be assessed.
+Comparing the results from different tools, often in order to generate
+confidence in them all, can be challenging and frequently requires
+oversimplified problems that preclude the use of the advanced features of any
+one tool.
+
+There are a number of tools currently used around the world to support systems
+decisions on nuclear fuel cycle options:
+
+* VISION
+* DANESS
+* COSI
+* NUWASTE
+* CAFCA
+* NFCSim
diff --git a/_sources/basics/glossary.rst.txt b/_sources/basics/glossary.rst.txt
new file mode 100755
index 000000000..a4b565f6c
--- /dev/null
+++ b/_sources/basics/glossary.rst.txt
@@ -0,0 +1,155 @@
+.. summary Glossary of Cyclus Fuel Cycle Simulator Terms
+
+:version: Document v1.0 - 8/14/2012
+
+Glossary of Cyclus Terms
+========================
+
+.. glossary::
+ :sorted:
+
+ context
+
+ The queryable environment of a |cyclus| simulation.
+
+ fuel cycle simulator
+
+ A computational framework for modeling nuclear fuel cycles.
+
+ commodity
+
+ A name assigned to a class of resources. |cyclus| determines the flow of
+ resources during a time step based on the supply of and demand for
+ commodities based on :term:`agent's ` requests and bids for those
+ commodities.
+
+ dynamic resource exchange
+
+ the methodology that governs time step behavior in |cyclus| -- see
+ :doc:`Dynamic Resource Exchange <../arche/dre>`
+
+ plug-in
+
+ See :term:`module`.
+
+ open development platform
+
+ A code repository or server that is publicly viewable and downloadable,
+ though not necessarily modifiable.
+
+ open development process
+
+ A software development workflow, usually on an :term:`open development
+ platform`, that is transparent to the public. Hallmarks include public bug
+ reports, source code access, and code contribution.
+
+ closed development platform
+
+ A code repository or server that is kept private during development to
+ secure proprietary or sensitive work.
+
+ closed development process
+
+ A software development workflow, usually on a :term:`closed development
+ platform`, that is not transparent to the public as authorization is
+ required before development access to the codebase is granted. This is used
+ for secure proprietary or sensitive work.
+
+ cyclus core
+
+ The repository at github.com/cyclus/cyclus and primary focus of the core
+ developers of the cyclus project.
+
+ cyclus kernel
+
+ The simulation engine housed in :term:`cyclus core`. :term:`Archetypes
+ ` defined in :term:`modules ` are linked dynamically to the
+ kernel at the beginning of every simulation.
+
+ archetype
+
+ A collection of logic and behavior which can be configured into a
+ :term:`prototype` which can then be instantiated in simulation as a
+ :term:`agent`. Archetypes are represented as C++ classes that inherit from
+ the base ``cyclus::Agent`` class.
+
+ prototype
+
+ A configured :term:`archetype` with initial state and conditions.
+ :term:`Agents ` that do act in the simulation are cloned (copied) from
+ prototypes.
+
+ agent
+
+ An entity that acts in a |cyclus| simulation. Agents enter the simulation
+ after having been cloned from a :term:`prototype`. An agent's internal logic
+ and behavior is determined by its :term:`archetype`.
+
+ module
+
+ A shared-object library that houses implementations of :term:`archetypes
+ ` and related tools that is dynamically linked to the :term:`cyclus
+ kernel` at runtime if one of its :term:`archetype` is used in a simulation.
+
+ core developer
+
+ An advanced developer tasked with developing and maintaining the
+ :term:`cyclus kernel` and related code.
+
+ archetype developer
+
+ An individual from science, academia, government, or the general public
+ interested in contributing to the ecosystem of :term:`archetypes `
+ available for use with the simulator.
+
+ user
+
+ A member of the public, government, or academia who use |cyclus| to run
+ simulations.
+
+ nuclear fuel cycle
+
+ The progression of nuclear fuel through the collection of facilities and
+ process stages from mining to disposal that are necessary to generate
+ nuclear power as well as to prepare, manage, recycle, and store nuclear
+ fuel.
+
+ parent agent
+
+ An :term:`agent` that manages (is in charge of) some number of child agents.
+
+ kernel phase
+
+ A phase during a simulation time step that is managed by the :term:`cyclus
+ kernel`.
+
+ agent phase
+
+ A phase during a simulation time step in which :term:`agents ` are
+ allowed to query the simulation environment and perform general actions.
+
+ tick
+
+ An :term:`agent phase` that occurs before the :term:`dynamic resource
+ exchange` every time step
+
+ tock
+
+ An :term:`agent phase` that occurs after the :term:`dynamic resource
+ exchange` every time step
+
+ composition
+
+ A list of nuclides and their relative quantity.
+
+ material
+
+ A particular kind of resource that combines a :term:`composition` and a
+ mass to be exchanged
+
+ entity
+
+ The kind of the archetype. Usually this is either region, institution,
+ or facility. For agents that are not specifically one of these kinds
+ still inherit from the ``Agent`` class the term archetype is used.
+ Otherwise the entity is unknown.
diff --git a/_sources/basics/index.rst.txt b/_sources/basics/index.rst.txt
new file mode 100755
index 000000000..acb1bd323
--- /dev/null
+++ b/_sources/basics/index.rst.txt
@@ -0,0 +1,81 @@
+|Cyclus| Introduction
+=====================
+
+|cyclus| is a nuclear fuel cycle simulation platform whose genesis was driven
+by a variety of gaps seen in previous fuel cycle simulation efforts, which
+attempted to address three major design and development philosophies:
+
+ #. A desire for usability, thus developing a tool which begins with a
+ simple model in a visual development environment that aims to provide an
+ intuitive user interface (e.g. DYMOND, DANESS, VISION)
+ #. A desire for rapid prototyping, thus developing a tool which begins
+ with simple models in a scripting language that allows for quick answers to
+ early problems (e.g. CAFCA, GENIUS v1)
+ #. A desire for detail/fidelity, thus developing a tool with an ad-hoc
+ combination of existing complex analysis tools (e.g. COSI)
+
+Each of these philosophies can hinder the simulation of some classes of
+interesting problems due to complexity limits. In most cases this complexity
+constrains first the usability of the tool followed by its extensibility due
+to increasingly convoluted dependencies. The final victim is performance, as
+the ability to quickly solve simple problems is lost to the desire to solve
+more complex ones.
+
+In addition to these technical challenges there is also an institutional one.
+A combination of closed development platforms and processes has made it
+difficult for an individual researcher to incorporate their ideas into fuel
+cycle systems analysis studies or frameworks. The ability to combine existing
+systems simulation tools with data about new facilities or fuel cycle concepts
+is so challenging that many researchers either choose to avoid systems
+analysis altogether or to write their own simplified tool. These custom fuel
+cycle simulation tools involve a duplication of effort.
+
+Each of these approaches lacks a design basis in computational science and
+software development that can deliver the desired attributes of the final
+software product:
+
+ * **usability:** accommodating a wide range of user sophistication,
+
+ * **performance:** solving simple problems in interactive time scales, and
+
+ * **fidelity:** accommodating many levels of detail & fidelity,
+ commensurate with a range of user sophistication.
+
+While these attributes could be achieved across a set of different tools, by
+providing a common physics and resource exchange infrastructure that can meet
+a broad range of needs, |Cyclus| facilitates meaningful comparisons among
+different use cases that has been challenging when comparing different tools.
+
+A complete nuclear fuel cycle simulator requires modeling efforts in a wide
+variety of physical and social science domains. This places a premium on a
+software development process that will facilitate fluid collaboration among a
+large group of geographically dispersed developers. With this constraint in
+mind, a number of software development practices can be identified as highly
+valuable for this effort:
+
+ * **openness:** the process should have low institutional & technical
+ obstacles to collaboration,
+
+ * **modularity:** a particular approach to modularity should be pursued to
+ allow the core infrastructure to be independent of proprietary or
+ sensitive data and models, and
+
+ * **extensibility:** attention to both robustness and flexibility allows
+ for myriad potential developer extensions.
+
+Sections
+----------
+
+.. toctree::
+ :maxdepth: 1
+
+ concepts
+ sw_dev
+ fcs_background
+ ecosystem
+ projects
+ optsens
+ acknowledgements
+ glossary
+
+
diff --git a/_sources/basics/optsens.rst.txt b/_sources/basics/optsens.rst.txt
new file mode 100755
index 000000000..d4607b5d8
--- /dev/null
+++ b/_sources/basics/optsens.rst.txt
@@ -0,0 +1,13 @@
+
+
+Optimization and Sensitivity
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+There is an initial desire to minimize the direct simulation of institutional
+decision making to seek optimal solutions. Because institutional decision
+making tends to seek an optimal solution only for the actor making that
+decision (local optimization), it may not lead to an outcome that optimizes
+for the largest population of stakeholders. Instead, the fundamental approach
+is to drive a single simulation with a large multi-dimensional data set and
+then allow modern optimization technology to seek globally optimal solutions
+based on global objective functions.
diff --git a/_sources/basics/projects.rst.txt b/_sources/basics/projects.rst.txt
new file mode 100755
index 000000000..9741fd9ac
--- /dev/null
+++ b/_sources/basics/projects.rst.txt
@@ -0,0 +1,19 @@
+Projects Using |Cyclus|
+=========================
+
+A variety of projects are using, or have used, |Cyclus| for both analysis and
+method developments purposes.
+
+
+Consortium for Verification Technology
+--------------------------------------
+
+.. figure:: ../astatic/CVT-logo-250pix1.png
+ :align: right
+ :width: 100
+
+As part of the `Consortium for Verification Technology (CVT)
+ `_, |Cyclus| is being used to study issues in
+nuclear security and non-proliferation. Research areas include the
+incorporation of social-behavioral models to agent interactions, nuclear
+material tracking and forensics, and detector sensitivity estimation.
diff --git a/_sources/basics/sw_dev.rst.txt b/_sources/basics/sw_dev.rst.txt
new file mode 100755
index 000000000..cd4aaf532
--- /dev/null
+++ b/_sources/basics/sw_dev.rst.txt
@@ -0,0 +1,61 @@
+Software Process & Architecture
+================================
+
+The software architecture and accompanying development process are critical to
+a simultaneously robust and flexible analysis platform.
+
+Open Source Development Process
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The |cyclus| development framework employs a modern, open source philosophy
+that ensures transparency, attracts contributions from a varied community of
+collaborators, and guarantees institution-independent access to all potential
+:term:`users `. (`BSD 3-Clause License `_)
+In this development path, a public source code repository provides
+unhindered access to the `fundamental simulation framework
+`_ and `additional agent archetypes
+`_ volunteered by developers. Granting
+unfettered access only to the |cyclus| engine allows for compartmentalization
+of the code and its input data. Thus, secure and proprietary :term:`archetype
+developers ` can be similarly encouraged to utilize the |cyclus| framework.
+This modern development model passively distributes specialized content to
+interested research groups, and facilitates parallel archetype development
+efforts by institutions with complimentary goals. The transparency inherent
+in this type of :term:`open development process` also facilitates code review by
+exposing available content to verification and validation by collaborators
+with diverse areas of specialization and levels of expertise.
+
+Another aspect of this development process is a preference for open source
+third party libraries where additional functionality is necessary and
+available from such libraries. This includes basic infrastructure such as
+file input/output, as well as archetype-specific capabilities like
+integer programming for network flow optimization.
+
+Dynamically Loadable Modules
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Dynamically loadable modules are the primary mechanism for extending |cyclus|
+with new underlying :term:`archetypes `. The primary benefit of this
+approach is encapsulation: the :term:`cyclus kernel` is completely independent
+of the individual archetypes and all customization and extension is
+implemented only in the loadable module. A secondary benefit of this
+encapsulation is the ability for contributors to choose different distribution
+and licensing strategies. Finally, this strategy allows individual developers
+to explore different levels of complexity within their archetypes,
+including wrapping other simulation tools as loadable modules for |cyclus|.
+
+Use Cases & Visualization
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Because of the wide array of use cases for |cyclus|, flexibility in the user
+interface is important to provide users with their desired functionality.
+This is true for input generation as well as output visualization. A
+graphical user interface has been designed and will be implemented in parallel
+with the development of the underlying modules. The graphical interface is
+extensible by loadable modules in the same way as the core code to provide
+developers the same flexibility in managing their input as they have in
+implementing their archetypes. Output visualization is also
+important - the discrete facility/discrete material paradigm generates a
+large volume of small data that needs to be aggregated in various ways to
+provide context to a variety of users.
+
diff --git a/_sources/cep/cep0.rst.txt b/_sources/cep/cep0.rst.txt
new file mode 100755
index 000000000..dbceb4de3
--- /dev/null
+++ b/_sources/cep/cep0.rst.txt
@@ -0,0 +1,83 @@
+|Cyclus| Enhancement Proposals
+==============================
+
+.. raw:: html
+
+
+
+
+:CEP: 0
+:Title: Index of |Cyclus| Enhancement Proposals (CEPs)
+:Version: N/A
+:Last-Modified: 2013-11-01
+:Author: Anthony Scopatz
+:Status: Active
+:Type: Informational
+:Created: 2013-07-03
+
+.. raw:: html
+
+
+
+.. image:: ../astatic/bicyclelady.jpg
+ :align: center
+
+.. raw:: html
+
+
+
+
+Introduction
+------------
+This CEP contains the index of all |Cyclus| Enhancement Proposals,
+known as CEPs. CEP numbers are assigned by the CEP editors, and
+once assigned are never changed. The git history of
+the CEP texts here represent their historical record.
+
+Index
+-----
+
+*Meta-CEPs (CEPs about CEPs or Processes)*
+
+.. toctree::
+ :maxdepth: 1
+
+ PA - 1 - CEP Purpose and Guidelines - Scopatz
+ PA - 2 - Separation of Concerns in the Cyclus Ecosystem - Scopatz
+ PA - 3 - Release Procedure - Scopatz
+ PD - 4 - Attribution of Code Products in the |Cyclus| Ecosystem - Huff
+ PL - 5 - Archetype Development Best Practices - Gidden
+ PD - 6 - Cyclus Pull Request Style Guide - Gidden
+ PD - 80 - Cycamore Archetype API/Warning Requirements - Gidden
+
+*Standard CEPs*
+
+.. toctree::
+ :maxdepth: 1
+
+ SA - 17 - Resource Tracking and Interfaces Re-Re-Redo - Carlsen
+ SA - 18 - Dynamic Resource Exchange Procedure - Gidden
+ SW - 19 - Cyclus Input Procedure Updates - Flanagan
+ SA - 20 - Time Step Execution Stack - Gidden
+ SA - 21 - Agent Identification and Discovery - Carlsen
+ SL - 22 - Logging Methodology and Implementation - Gidden
+ SA - 23 - Defining Time Step Length, High Noon for Blue Moon - Scopatz
+ SA - 24 - Default Preferences - Gidden
+ SA - 25 - Preference Adjustment Process - Gidden
+ SD - 26 - Generalize the DRE to Optimize Multiple Metrics - Flanagan, Scopatz
+ SA - 27 - Toolkit Capabilities Injection into an Archetype - Mouginot
+
+Key
+---
+- S - Standards Track CEP
+- I - Informational CEP
+- P - Process CEP
+
+- A - Accepted proposal
+- R - Rejected proposal
+- W - Withdrawn proposal
+- L - Deferred proposal
+- F - Final proposal
+- C - Active proposal
+- D - Draft proposal
+- U - Superseded proposal
diff --git a/_sources/cep/cep1.rst.txt b/_sources/cep/cep1.rst.txt
new file mode 100755
index 000000000..1f8b27fb8
--- /dev/null
+++ b/_sources/cep/cep1.rst.txt
@@ -0,0 +1,487 @@
+CEP 1 - CEP Purpose and Guidelines
+**********************************
+
+:CEP: 1
+:Title: CEP Purpose and Guidelines
+:Last-Modified: 2013-07-03
+:Author: Anthony Scopatz
+:Status: Active
+:Type: Process
+:Created: 2013-07-03
+
+What is a CEP?
+==============
+
+CEP stands for |Cyclus| Enhancement Proposal. A CEP is a design
+document providing information to the |cyclus| community, or describing
+a new feature or process for |Cyclus| and related projects in its ecosystem.
+The CEP should provide a concise technical specification of the feature and a
+rationale for the feature.
+
+We intend CEPs to be the primary mechanisms for proposing major new
+features, for collecting community input on an issue, and for
+documenting the design decisions that have gone into the |Cyclus| ecosystem.
+The CEP author is responsible for building consensus within the community and
+documenting dissenting opinions.
+
+Because the CEPs are maintained as text files in a versioned
+repository, their revision history is the historical record of the
+feature proposal [1]_.
+
+
+CEP Types
+=========
+
+There are three kinds of CEP:
+
+1. A **Standards Track** CEP describes a new feature or implementation
+ for |cyclus|. It may also describe an interoperability standard that will
+ be supported outside of |cyclus| core.
+
+2. An **Informational** CEP describes a |cyclus| design issue, or
+ provides general guidelines or information to the |cyclus| community,
+ but does not propose a new feature. Informational CEPs do not
+ necessarily represent a |cyclus| community consensus or
+ recommendation, so users and implementers are free to ignore
+ Informational CEPs or follow their advice.
+
+3. A **Process** CEP describes a process surrounding |cyclus|, or
+ proposes a change to (or an event in) a process. Process CEPs are
+ like Standards Track CEPs but apply to areas other than the |cyclus|
+ code development. They may propose an implementation, but not to
+ |cyclus|'s codebase; they often require community consensus; unlike
+ Informational CEPs, they are more than recommendations, and users
+ are typically not free to ignore them. Examples include
+ procedures, guidelines, changes to the decision-making process, and
+ changes to the tools or environment used in |cyclus| development.
+ Any meta-CEP is also considered a Process CEP.
+
+
+CEP Workflow
+============
+
+
+|cyclus|'s BDFP
+---------------
+
+There are several reference in this CEP to the "BDFP". This acronym stands
+for "Benevolent Dictator for the Proposal." In most cases, it is fairly clear
+who this person is (Paul Wilson or Anthony Scopatz). It is this persons
+responsibility to consider the entire |cyclus| ecosystem when deciding whether
+or not to accept a proposal. Weighted with this burden, their decision
+must be adhered to (dictator status), though they will try to do the right
+thing (benevolent).
+
+
+CEP Editors
+-----------
+
+The CEP editors are individuals responsible for managing the administrative
+and editorial aspects of the CEP workflow (e.g. assigning CEP numbers and
+changing their status). See `CEP Editor Responsibilities & Workflow`_ for
+details. The current editors are:
+
+* Paul Wilson
+* Anthony Scopatz
+* Katy Huff
+
+CEP editorship is by invitation of the current editors.
+
+
+Submitting a CEP
+----------------
+
+The CEP process begins with a new idea for |cyclus|. It is highly
+recommended that a single CEP contain a single key proposal or new
+idea. Small enhancements or patches often don't need
+a CEP and can be injected into the |cyclus| development workflow with a
+patch submission to the |cyclus| `issue tracker`_. The more focused the
+CEP, the more successful it tends to be. The CEP editors reserve the
+right to reject CEP proposals if they appear too unfocused or too
+broad. If in doubt, split your CEP into several well-focused ones.
+
+Each CEP must have a champion -- someone who writes the CEP using the
+style and format described below, shepherds the discussions in the
+appropriate forums, and attempts to build community consensus around
+the idea. The CEP champion (a.k.a. Author) should first attempt to
+ascertain whether the idea is CEP-able. Posting to the `cyclus-dev`_
+mailing list is the best way to go about this.
+
+Vetting an idea publicly before going as far as writing a CEP is meant
+to save the potential author time. Many ideas have been brought
+forward for changing |cyclus| that have been rejected for various
+reasons. Asking the |cyclus| community first if an idea is original
+helps prevent too much time being spent on something that is
+guaranteed to be rejected based on prior discussions (searching
+the internet does not always do the trick). It also helps to make sure
+the idea is applicable to the entire community and not just the author.
+Just because an idea sounds good to the author does not
+mean it will work for most people in most areas where |cyclus| is used.
+
+Once the champion has asked the |cyclus| community as to whether an
+idea has any chance of acceptance, a draft CEP should be presented to
+mailing list. This gives the author a chance to flesh out the draft
+CEP to make properly formatted, of high quality, and to address
+initial concerns about the proposal.
+
+Following a discussion on the mailing list, the proposal should be sent as a
+draft CEP to the one of the CEP editors. The draft must be written
+in CEP style as described below, else it will be sent back without further
+regard until proper formatting rules are followed (although minor errors
+will be corrected by the editors).
+
+If the CEP editors approve, they will assign the CEP a number, label it
+as Standards Track, Informational, or Process, give it status "Draft",
+and create and check-in the initial draft of the CEP. The CEP editors
+will not unreasonably deny a CEP. Reasons for denying CEP status
+include duplication of effort, being technically unsound, not
+providing proper motivation or addressing backwards compatibility, or
+not in keeping with the |cyclus| philosophy. The BDFP can be consulted
+during the approval phase, and is the final arbiter of the draft's
+CEP-ability.
+
+Developers with git push privileges for the `CEP repository`_ may claim
+CEP numbers directly by creating and committing a new CEP. When doing so,
+the developer must handle the tasks that would normally be taken care of by
+the CEP editors (see `CEP Editor Responsibilities & Workflow`_). This
+includes ensuring the initial version meets the expected standards for
+submitting a CEP. Alternately, even developers may choose to submit CEPs
+through the CEP editors. When doing so, let the CEP editors know you have
+git push privileges and they can guide you through the process of updating
+the CEP repository directly.
+
+As updates are necessary, the CEP author can check in new versions if they
+(or a collaborating developer) have git push privileges, or else they can
+email new CEP versions to the CEP editors for publication.
+
+After a CEP number has been assigned, a draft CEP may be discussed further on
+mailing list (getting a CEP number assigned early can be useful for ease of
+reference, especially when multiple draft CEPs are being considered at the
+same time).
+
+Standards Track CEPs consist of two parts, a design document and a
+reference implementation. It is generally recommended that at least a
+prototype implementation be co-developed with the CEP, as ideas that sound
+good in principle sometimes turn out to be impractical when subjected to the
+test of implementation.
+
+CEP authors are responsible for collecting community feedback on a CEP
+before submitting it for review. CEP authors should use their discretion here.
+
+
+CEP Review & Resolution
+-----------------------
+
+Once the authors have completed a CEP, they may request a review for
+style and consistency from the CEP editors. However, the content and
+final acceptance of the CEP must be requested of the BDFP, usually via
+an email to the development mailing list. CEPs are reviewed by the
+BDFP and their chosen consultants, who may accept or reject a CEP or
+send it back to the author(s) for revision. For a CEP that is
+predetermined to be acceptable (e.g., it is an obvious win as-is
+and/or its implementation has already been checked in) the BDFP may
+also initiate a CEP review, first notifying the CEP author(s) and
+giving them a chance to make revisions.
+
+The final authority for CEP approval is the BDFP. However, whenever a new
+CEP is put forward, any core developer that believes they are suitably
+experienced to make the final decision on that CEP may offer to serve as
+the BDFP's delegate (or "CEP czar") for that CEP. If their self-nomination
+is accepted by the other core developers and the BDFP, then they will have
+the authority to approve (or reject) that CEP. This process happens most
+frequently with CEPs where the BDFP has granted in principle approval for
+*something* to be done, but there are details that need to be worked out
+before the CEP can be accepted.
+
+If the final decision on a CEP is to be made by a delegate rather than
+directly by the normal BDFP, this will be recorded by including the
+"BDFP" header in the CEP.
+
+For a CEP to be accepted it must meet certain minimum criteria. It
+must be a clear and complete description of the proposed enhancement.
+The enhancement must represent a net improvement. The proposed
+implementation, if applicable, must be solid and must not complicate
+the infrastructure unduly. Finally, a proposed enhancement must be
+follow |cyclus| best practices in order to be accepted by the BDFP.
+
+Once a CEP has been accepted, the reference implementation must be
+completed. When the reference implementation is complete and incorporated
+into the main source code repository, the status will be changed to "Final".
+
+A CEP can also be assigned status "Deferred". The CEP author or an
+editor can assign the CEP this status when no progress is being made
+on the CEP. Once a CEP is deferred, a CEP editor can re-assign it
+to draft status.
+
+A CEP can also be "Rejected". Perhaps after all is said and done it
+was not a good idea. It is still important to have a record of this
+fact. The "Withdrawn" status is similar - it means that the CEP author
+themselves has decided that the CEP is actually a bad idea, or has
+accepted that a competing proposal is a better alternative.
+
+When a CEP is Accepted, Rejected or Withdrawn, the CEP should be updated
+accordingly. In addition to updating the status field, at the very least
+the Resolution header should be added with a link to the relevant post
+in the `cyclus-dev`_ mailing list archives.
+
+CEPs can also be superseded by a different CEP, rendering the original
+obsolete. This is intended for Informational CEPs, where version 2 of
+an API can replace version 1.
+
+The possible paths of the status of CEPs are as follows:
+
+.. image:: cep-0001-1.png
+
+Some Informational and Process CEPs may also have a status of "Active"
+if they are never meant to be completed. E.g. CEP 1 (this CEP).
+
+**Lazy Consensus:** After 1 month of no objections to the wording of a CEP,
+it may be marked as "Accepted" by lazy consensus. The author, BDFP, and
+the Cyclus community manager are jointly responsible for sending out weekly
+reminders of an unapproved CEP without active discussion.
+
+
+CEP Maintenance
+---------------
+
+In general, Standards track CEPs are no longer modified after they have
+reached the Final state. Once a CEP has been completed, the Language and
+Standard Library References become the formal documentation of the expected
+behavior.
+
+Informational and Process CEPs may be updated over time to reflect changes
+to development practices and other details. The precise process followed in
+these cases will depend on the nature and purpose of the CEP being updated.
+
+
+
+What belongs in a successful CEP?
+=================================
+
+Each CEP should have the following parts:
+
+1. Preamble -- headers containing meta-data about the
+ CEP, including the CEP number, a short descriptive title, the names,
+ and optionally the contact info for each author, etc.
+
+2. Abstract -- a short (~200 word) description of the technical issue
+ being addressed.
+
+3. Copyright/public domain -- Each CEP must either be explicitly
+ labeled as placed in the public domain (see this CEP as an
+ example) or licensed under the `Open Publication License`_.
+
+4. Specification -- The technical specification should describe the
+ syntax and semantics of any new feature.
+
+5. Motivation -- The motivation is critical for CEPs that want to
+ change the |cyclus| ecosystem. It should clearly explain why the
+ existing language specification is inadequate to address the
+ problem that the CEP solves. CEP submissions without sufficient
+ motivation may be rejected outright.
+
+6. Rationale -- The rationale fleshes out the specification by
+ describing what motivated the design and why particular design
+ decisions were made. It should describe alternate designs that
+ were considered and related work, e.g. how the feature is supported
+ in other languages.
+
+ The rationale should provide evidence of consensus within the
+ community and discuss important objections or concerns raised
+ during discussion.
+
+7. Backwards Compatibility -- All CEPs that introduce major backwards
+ incompatibilities must include a section describing these
+ incompatibilities and their severity. The CEP must explain how the
+ author proposes to deal with these incompatibilities. CEP
+ submissions without a sufficient backwards compatibility treatise
+ may be rejected outright.
+
+8. Reference Implementation -- The reference implementation must be
+ completed before any CEP is given status "Final", but it need not
+ be completed before the CEP is accepted. While there is merit
+ to the approach of reaching consensus on the specification and
+ rationale before writing code, the principle of "rough consensus
+ and running code" is still useful when it comes to resolving many
+ discussions of API details.
+
+ The final implementation must include test code and documentation
+ appropriate for |cyclus|.
+
+
+CEP Header Preamble
+===================
+
+Each CEP must begin with a header preamble. The headers
+must appear in the following order. Headers marked with "*" are
+optional and are described below. All other headers are required. ::
+
+ CEP:
+ Title:
+ Version:
+ Last-Modified:
+ Author:
+ * BDFP:
+ Status:
+ Type:
+ * Requires:
+ Created:
+ * Cyclus-Version:
+ * Replaces:
+ * Superseded-By:
+ * Resolution:
+
+The Author header lists the names, and optionally the email addresses
+of all the authors/owners of the CEP. The format of the Author header
+value must be
+
+ Random J. User
+
+if the email address is included, and just
+
+ Random J. User
+
+The BDFP field is used to record cases where the final decision to
+approve or reject a CEP rests with someone other than the normal BDFP.
+
+The Type header specifies the type of CEP: Standards Track,
+Informational, or Process.
+
+The Created header records the date that the CEP was assigned a
+number, while Post-History is used to record the dates of when new
+versions of the CEP are posted to |cyclus| mailing list. Both
+headers should be in yyyy-mm-dd format, e.g. 2001-08-14.
+
+Standards Track CEPs will typically have a |cyclus|-Version header which
+indicates the version of |cyclus| that the feature will be released with.
+Standards Track CEPs without a |cyclus|-Version header indicate
+interoperability standards that will initially be supported through
+external libraries and tools, and then supplemented by a later CEP to
+add support to the standard library. Informational and Process CEPs do
+not need a |cyclus|-Version header.
+
+CEPs may have a Requires header, indicating the CEP numbers that this
+CEP depends on.
+
+CEPs may also have a Superseded-By header indicating that a CEP has
+been rendered obsolete by a later document; the value is the number of
+the CEP that replaces the current document. The newer CEP must have a
+Replaces header containing the number of the CEP that it rendered
+obsolete.
+
+
+Auxiliary Files
+===============
+
+CEPs may include auxiliary files such as diagrams. Such files must be
+named ``cep-XXXX-Y.ext``, where "XXXX" is the CEP number, "Y" is a
+serial number (starting at 1), and "ext" is replaced by the actual
+file extension (e.g. "png").
+
+
+Reporting CEP Bugs, or Submitting CEP Updates
+=============================================
+
+How you report a bug, or submit a CEP update depends on several
+factors, such as the maturity of the CEP, the preferences of the CEP
+author, and the nature of your comments. For the early draft stages
+of the CEP, it's probably best to send your comments and changes
+directly to the CEP author. For more mature, or finished CEPs you may
+want to submit corrections to the |cyclus| `issue tracker`_ so that your
+changes don't get lost. If the CEP author is a |cyclus| developer, assign the
+bug/patch to them, otherwise assign it to a CEP editor.
+
+When in doubt about where to send your changes, please check first
+with the CEP author and/or a CEP editor.
+
+CEP authors with git push privileges for the CEP repository can update the
+CEPs themselves by using "git push" to submit their changes.
+
+
+Transferring CEP Ownership
+==========================
+
+It occasionally becomes necessary to transfer ownership of CEPs to a
+new champion. In general, it is preferable to retain the original author as
+a co-author of the transferred CEP, but that's really up to the
+original author. A good reason to transfer ownership is because the
+original author no longer has the time or interest in updating it or
+following through with the CEP process, or has fallen off the face of
+the earth (i.e. is unreachable or not responding to email). A bad
+reason to transfer ownership is because the author doesn't agree with the
+direction of the CEP. One aim of the CEP process is to try to build
+consensus around a CEP, but if that's not possible, an author can always
+submit a competing CEP.
+
+If you are interested in assuming ownership of a CEP, send a message
+asking to take over, addressed to both the original author and the |cyclus|
+mailing list. If the original author doesn't respond to
+email in a timely manner, the CEP editors will make a unilateral
+decision (it's not like such decisions can't be reversed :).
+
+
+CEP Editor Responsibilities & Workflow
+======================================
+
+A CEP editor must subscribe to the |cyclus| development mailing list.
+For each new CEP that comes in an editor does the following:
+
+* Read the CEP to check if it is ready: sound and complete. The ideas
+ must make technical sense, even if they don't seem likely to be
+ accepted.
+
+* The title should accurately describe the content.
+
+* Edit the CEP for language (spelling, grammar, sentence structure, etc.).
+
+If the CEP isn't ready, an editor will send it back to the author for
+revision, with specific instructions.
+
+Once the CEP is ready for the repository, a CEP editor will:
+
+* Assign a CEP number (almost always just the next available number,
+ but sometimes it's a special/joke number, like 666 or 3141).
+
+* Add the CEP to the CEP repository.
+
+* Commit and push the new (or updated) CEP
+
+* Monitor cyclus.github.com to make sure the CEP gets added to the site
+ properly.
+
+* Send email back to the CEP author with next steps (post to the
+ |cyclus| development mailing list).
+
+Many CEPs are written and maintained by developers with write access
+to the |cyclus| codebase. The CEP editors monitor the various repositories
+for CEP changes, and correct any structure, grammar, spelling, or
+markup mistakes they see.
+
+CEP editors don't pass judgment on CEPs. They merely do the
+administrative & editorial part (which is generally a low volume task).
+
+Document History
+================
+This document was forked and modified from the `Python Enhancement Proposals
+ `_
+
+This document is released under the CC-BY 3.0 license.
+
+References and Footnotes
+========================
+
+.. [1] This historical record is available by the normal git commands
+ for retrieving older revisions, and can also be browsed via HTTP here:
+ https://github.com/cyclus/cyclus.github.com/tree/source/source/cep
+
+.. _issue tracker:
+ https://github.com/cyclus/cyclus
+
+.. _Open Publication License: http://www.opencontent.org/openpub/
+
+.. _reStructuredText: http://docutils.sourceforge.net/rst.html
+
+.. _CEP repository: https://github.com/cyclus/cyclus.github.com/tree/source/source/cep
+
+.. _cyclus-dev: https://groups.google.com/forum/#!forum/cyclus-dev
diff --git a/_sources/cep/cep17.rst.txt b/_sources/cep/cep17.rst.txt
new file mode 100755
index 000000000..04b905cd5
--- /dev/null
+++ b/_sources/cep/cep17.rst.txt
@@ -0,0 +1,670 @@
+CEP 17 - Resource Tracking and Interfaces Re-Re-Redo
+***********************************************************
+
+:CEP: 17
+:Title: Resource Tracking and Interfaces Re-Re-Redo
+:Last-Modified: 2013-09-03
+:Author: Robert Carlsen
+:Status: Accepted
+:Type: Standards Track
+:Created: Robert Carlsen
+
+Abstract
+===========
+
+This proposal serves to address two related issues:
+
+1. **Resource tracking:**
+
+ Several types of analysis are made difficult to impossible by the
+ incomplete resource history currently recorded by |Cyclus| simulations. Such
+ analyses include agent time-dependent isotopic inventories and
+ proliferation-resistance material handling. It is proposed that all
+ resource state and state transitions will be tracked (as opposed to just
+ recording state at inter-agent transactions). In addition to required
+ internal additions/changes to resource classes, explicit ``transmute``
+ functionality will be added to the Material class to accommodate
+ mass-conserving state changes that occur in agents such as Reactors.
+
+2. **Resource interface complexity:**
+
+ Creating, querying, and manipulating resources is too complex and is spread
+ across too many classes. The resource class (and friends) will have their
+ interfaces minimized and all extra functionality will be provided by one or
+ more wrapper classes.
+
+Motivation and Rationale
+==========================
+
+This proposal serves to address two related issues: resource tracking and
+resource interface complexity. Because changes to resource tracking will be
+intrusive to the current resource interfaces, performing these changes
+together is desirable.
+
+**Resouce Tracking:**
+
+Currently |Cyclus| only tracks the state of resources when they are transacted.
+This limited tracking is problematic for certain kinds of output
+analysis. Examples:
+
+1. The meaning of "inventory" for agents that transmute materials is
+ ill-defined. To calculate the inventory of a reactor faciltiy, an
+ analysis of present data would show fresh fuel coming in, and spent fuel
+ coming out. The aggregation of transactions to a specific point in time
+ would not be the reactor's current inventory. Rather it would be the
+ reactor's inventory plus the difference between fresh and spent fuel
+ processed until that point in time. The same problem exists with decay.
+
+2. We cannot determine if a resource was ever handled inappropriately (e.g.
+ non-proliferation analysis) internally within an agent.
+
+3. We are unable to determine "source" agents that create material and what
+ they created.
+
+4. There is no mass-conservation-safe way to transmute a material (i.e.
+ change its nuclide composition) outside of destroying and simultaneously
+ creating new material objects (which isn't mass-conservations-safe).
+
+5. When resources are split and combined, there is no way to recall this
+ heritage. Tracing paths of certain material objects is not possible.
+ Analyzing the contribution of agent X to the flow of isotope Y through
+ agent Z is not possible.
+
+The above deficiencies are used as drivers for designing/implementing a more
+thorough resource tracking infrastructure.
+
+Additionally, some materials will exist in the simulation that are not
+"part" of the simulation and should not be recorded in the ouptut. Some of
+these materials will be objects representing what agents are
+offering/requesting. A new implementation must accomodate this
+requirement.
+
+**Resource Interface Complexity:**
+
+The interface(s) for creating, manipulating, and using resources is too
+confusing and complex. There are methods for accessing material state
+variables spread across three classes (Material, IsoVector, CompMap). The
+current trio will be reduced to a duo (Material and Composition classes).
+All query convenience related methods will be moved to one (or more)
+wrapper classes for interrogating and manipulating material compositions.
+*Functionality provided by these wrapper classes can grow organically as
+needs arise without affecting the core resource classes.*
+
+Part of the problem has been that some questions belong to the Material
+class, some belong to the composition class. And some can only be answered
+by using information from both. Another reason to use wrapper classes is
+that sometimes a user/dev might want to manipulate compositions, and other
+times they will want to manipulate materials - and many of those
+queries/operations have significant overlap that we don't want duplicated
+on both classes' implementations nor interfaces. Another reason is to help
+the classes be more modular/maintainable for the core developers. Some
+basic material/composition query/manipulation wrapper(s) can be made
+setting the stage for the further development of a "toolkit" for dealing
+with materials and compositions. External developers can easily create
+toolkits for others to use that don't even need to be a part of the |Cyclus|
+core. This makes it easier to ensure that material/composition inner
+workings remain pure and correct despite rapid or significant changes to
+the kitchen-sink API that will likely evolve.
+
+Specification
+===============
+
+A reference implementation exists for both the |cyclus| core and cycamore.
+These reside at https://github.com/rwcarlsen/cyclus ("res" branch) and
+https://github.com/rwcarlsen/cycamore ("res" branch) respectively. Further
+implementation details can be found there.
+
+Data Tracking
++++++++++++++++++++++++
+
+In addition to tracking the transfer of resources between agents (and
+corresponding state), we track:
+
+* Creation of a resource. Parentless resources are implicitly defined as
+ "newly created"
+
+* Transmutation of a material resource within an agent (Resource,
+ ResourceHeritage, Compositions, GenericResource tables). The transmuted
+ resource has the prev resource as its only parent. This helps address
+ problem #1 and #4 from Motivation section.
+
+* Decay of a material resource (Resource, ResourceHeritage, Compositions
+ tables): This is a special, common case of transmutation.
+
+* All splitting/combining of materials. Tracked by recording the parent(s)
+ of each Resource object. Resources with no parent were newly created.
+ Helps address problem #2, #3 and #5.
+
+This also simplifies rules for acceptable resource handling. Namely, it is
+never okay for a resource to be destructed or thrown-away unless it is
+being stored permanently. The new changes should make it more obvious to
+agent developers how enforce correct, measurable mass-conservation.
+
+This proposed tracking provides orthogonality between resource
+handling/operations and resource ownership. Resource operations don't
+know/care about who is splitting/combining/transmuting/creating them. This
+orthogonality, I believe, is a good feature because: it simplifies the
+resource APIs, decouples transaction and resource manipulation and data
+recording code, and it decouples output data elegantly. Resource tracking
+becomes entirely independent of facility operations, transactions, and
+simulation time-stepping. If problem #1 as described in the Motivation
+section is a fundamentally necessary analysis for basically every
+simulation we want to run, then we either need (minimally) the tracking
+proposed in this CEP or we need to break the orthogonality that I just
+described. Eliminating even one of the things tracked as described above
+will break the ability to unambiguously determine agent inventories.
+
+Output Schema
++++++++++++++++++++++++
+
+All recorded data will stay the same except for the tables listed below:
+
+* [TableName] ([new/modified/removed]): [field1], [field2], ...
+
+- Resource (modified): ID, Time, Type, Quantity, StateID, Parent1, Parent2
+- Compositions (new): ID, Isotope, Quantity
+- TransactedResources (modified): TransactionID, Position, ResourceID
+- GenericResources (modified): ID, Quality, Units
+- IsotopicStates (removed)
+
+
+*Note that unlike GenericResources, there is no units field for
+compositions because we can record all material composition amounts in a
+canonical unit (i.e. kg). GenericResources, however, are
+expected/anticipated to have different unit types along with their
+differing "quality" field values.*
+
+Resources/Material API
++++++++++++++++++++++++
+
+The Material and Composition classes will be designed to provide only the
+minimal interface to support basic manipulation and tracking required by the
+|cyclus| core. All more complex operations will be implemented in helper
+classes (like MatQuery). A summary of each of these classes' new role and
+its public interfaces are described below.
+
+Resource class
+~~~~~~~~~~~~~~~
+
+Resource class provides an abstract interface allowing different types of
+resources to be transacted in a simulation.
+
+.. code-block:: c++
+
+ namespace cyclus {
+
+ typedef std::string ResourceType;
+
+ class Resource {
+ public:
+ typedef boost::shared_ptr Ptr;
+
+ virtual ~Resource() { };
+
+ /// returns the unique id corresponding to this resource and its current
+ /// state.
+ const int id() const;
+
+ /// assigns a new, unique id to this resource and its state.
+ void BumpId();
+
+ /// returns an id representing the specific resource implementation's
+ /// internal state. Any change to the state_id should be accompanied by a
+ /// call to BumpId.
+ virtual int state_id() const = 0;
+
+ virtual const ResourceType type() const = 0;
+
+ /// returns an untracked (not part of the simulation) copy of the resource.
+ virtual Ptr Clone() const = 0;
+ // the clone method implementations should set tracked_ = false.
+
+ /// records the resource's state to the output database. This method should
+ /// generally / NOT record data accessible via the Resource class public
+ /// methods (e.g. / state_id, units, type, quantity)
+ virtual void Record() const = 0;
+
+ /// Returns the units this resource is based in.
+ virtual std::string units() const = 0;
+
+ /// returns the quantity of this resource with dimensions as specified by
+ /// units().
+ virtual double quantity() const = 0;
+
+ /// splits the resource and returns the extracted portion as a new resource
+ /// object. Allows for things like ResourceBuff and market matching to
+ /// split offers/requests of arbitrary resource implementation type.
+ virtual Ptr ExtractRes(double quantity) = 0;
+
+ };
+
+ } // namespace cyclus
+
+Material class
+~~~~~~~~~~~~~~~
+
+The material class is primarily responsible for enabling basic material
+manipulation while helping enforce mass conservation. It also provides the
+ability to easily decay a material up to the current simulation time; it
+does not perform any decay related logic itself.
+
+There are four basic operations that can be performed on materials: create,
+transmute (change material composition - e.g. fission by reactor), absorb
+(combine materials), extract (split a material). All material
+handling/manipulation will be performed using these operations - and all
+operations performed will be recorded. Usage examples:
+
+* A mining facility that "creates" new material
+
+.. code-block:: c++
+
+ Composition::Ptr nat_u = ...
+ double qty = 10.0;
+
+ Material::Ptr m = Material::Create(qty, nat_u);
+
+* A conversion facility mixing uranium and flourine:
+
+.. code-block:: c++
+
+ Material::Ptr uf6 = uranium_buf.PopOne();
+ Material::Ptr f = flourine_buf.PopOne();
+
+ uf6.Absorb(f);
+
+* A reactor transmuting fuel:
+
+.. code-block:: c++
+
+ Composition::Ptr burned_comp = ... // fancy code to calculate burned isotopics
+ Material::Ptr assembly = core_fuel.PopOne();
+
+ assembly.Transmute(burned_comp);
+
+* A separations plant extracting stuff from spent fuel:
+
+.. code-block:: c++
+
+ Composition::Ptr comp = ... // fancy code to calculate extraction isotopics
+ Material::Ptr bucket = spent_fuel.PopOne();
+ double qty = 3.0;
+
+ Material::Ptr mox = bucket.ExtractComp(qty, comp);
+
+
+Proposed material class interface:
+
+.. code-block:: c++
+
+ class Material: public Resource {
+ public:
+ typedef boost::shared_ptr Ptr;
+ static const ResourceType kType;
+
+ virtual ~Material();
+
+ static Ptr Create(double quantity, Composition::Ptr c);
+ static Ptr CreateUntracked(double quantity, Composition::Ptr c);
+
+ virtual int state_id() const;
+
+ virtual const ResourceType type() const;
+
+ virtual Resource::Ptr Clone() const;
+
+ virtual void Record() const;
+
+ /// returns "kg"
+ virtual std::string units() const;
+
+ /// returns the mass of this material in kg.
+ virtual double quantity() const;
+
+ virtual Resource::Ptr ExtractRes(double qty);
+
+ Ptr ExtractQty(double qty);
+
+ Ptr ExtractComp(double qty, Composition::Ptr c, double threshold = eps_rsrc());
+
+ void Absorb(Ptr mat);
+
+ void Transmute(Composition::Ptr c);
+
+ void Decay(int curr_time);
+
+ static void DecayAll(int curr_time);
+
+ Composition::Ptr comp() const;
+ };
+
+ } // namespace cyclus
+
+GenericResource class
+~~~~~~~~~~~~~~~~~~~~~~
+
+Implements the Resource class interface in a simple way usable for things
+like: bananas, man-hours, water, buying power, etc.
+
+.. code-block:: c++
+
+ class GenericResource : public Resource {
+ public:
+ typedef boost::shared_ptr Ptr;
+ static const ResourceType kType;
+
+ static Ptr Create(double quantity, std::string quality, std::string units);
+ static Ptr CreateUntracked(double quantity, std::string quality,
+ std::string units);
+
+ /// not needed/no meaning for generic resources
+ virtual int state_id() const {
+ return 0;
+ };
+
+ /// Returns the concrete type of this resource
+ virtual const ResourceType type() const {
+ return kType;
+ };
+
+ /// Returns a reference to a newly allocated copy of this resource
+ virtual Resource::Ptr Clone() const;
+
+ virtual void Record() const { };
+
+ /// Returns the total quantity of this resource in its base unit
+ virtual std::string units() const {
+ return units_;
+ };
+
+ /// Returns the total quantity of this resource in its base unit
+ virtual double quantity() const {
+ return quantity_;
+ };
+
+ virtual const std::string& quality() const {
+ return quality_;
+ };
+
+ virtual Resource::Ptr ExtractRes(double quantity);
+
+ /// Extracts the specified mass from this resource and returns it as a
+ /// new generic resource object with the same quality/type.
+
+ /// @throws CycGenResourceOverExtract
+ GenericResource::Ptr Extract(double quantity);
+
+ /// Absorbs the contents of the given 'other' resource into this
+ /// resource
+ /// @throws CycGenResourceIncompatible 'other' resource is of a
+ void Absorb(GenericResource::Ptr other);
+ };
+
+ } // namespace cyclus
+
+Composition class
+~~~~~~~~~~~~~~~~~~~~~~
+
+An immutable object responsible for tracking decay lineages (to prevent
+duplicate calculations and output recording) and able to record its
+composition data to output when told. Each composition will keep a pointer
+to references to every other composition that is a result of decaying this
+or a previously decayed-from composition.
+
+Note that previously, composition creation/modification involved a notion
+of equivalence via threshold comparison to facilitate reduced
+memory/storage burdens. This proposal discards this idea in favor of
+defining equivalence trivially as "the same object in memory" or pointer
+equality. Some discussion regarding this can be found in comments here:
+https://github.com/cyclus/cyclus/issues/484. Of particular concern w.r.t.
+the previous equivalence notion is this::
+
+ Also - another potential issue I thought of: Repeatedly calling multiple
+ consecutive small differences negligible could result in compositions
+ staying the same that would have otherwise been appreciably different if
+ each small change were allowed to propogate as a new composition.
+
+While there are definitely uses for material/composition equivalence, they
+should/will not be used by the core (for now) and best belong in MatQuery
+or other places.
+
+.. code-block:: c++
+
+
+ namespace cyclus {
+
+ typedef int Iso;
+ typedef std::map CompMap;
+
+ // Represents an immutable nuclear material composition
+ class Composition {
+ public:
+ typedef boost::shared_ptr Ptr;
+
+ static Ptr CreateAtom(CompMap v);
+ static Ptr CreateMass(CompMap v);
+
+ int id();
+ const CompMap& atom_vect();
+ const CompMap& mass_vect();
+
+ Ptr Decay(int delta);
+
+ /// record in output database (if not done previously).
+ void Record();
+ };
+
+ } // namespace cyclus
+
+compmath namespace
+~~~~~~~~~~~~~~~~~~~~~~
+
+The excellent floating point calculation handling and thresholding
+functionality introduced by @katyhuff will be preserved. The current
+(pre-proposal) Material::Diff and Material::ApplyThreshold methods will become
+public functions that operate on CompMap types. Other common
+composition manipulation functions will live here. They will operate on
+CompMap's because Composition's themselves are immutable. Resource
+and Composition classes will use these methods where appropriate instead of
+their own, internal versions. This namespace is intended to grow organically as
+needed.
+
+.. code-block:: c++
+
+ namespace cyclus {
+ namespace compmath {
+
+ CompMap Add(const CompMap& v1, double qty1,
+ const CompMap& v2, double qty2);
+
+ /// previously Material::Diff
+ CompMap Sub(const CompMap& v1, double qty1,
+ const CompMap& v2, double qty2);
+
+ void ApplyThreshold(CompMap* v, double threshold);
+
+ void Normalize(cyclus::CompMap* v, double val);
+
+ bool ValidIsos(const CompMap& v);
+
+ bool AllPositive(const CompMap& v);
+
+ bool AlmostEq(const CompMap& v1,
+ const CompMap& v2,
+ double threshold);
+
+ } // namespace compmath
+ } // namespace cyclus
+
+
+MatQuery class
+~~~~~~~~~~~~~~~~~~~~~~
+
+(This interface will probably need extension)
+
+This is intended to allow user-developers to *easily* retrieve any kind of
+information about a material they could ever reasonably need. The interface is
+designed to grow organically as needed.
+
+.. code-block:: c++
+
+ class MatQuery {
+ public:
+ MatQuery(Material::Ptr m);
+
+ /// Convenience constructor that auto-casts a Resource::Ptr to a
+ /// Material::Ptr.
+ MatQuery(Resource::Ptr m);
+
+ double mass(Iso iso);
+
+ double moles(Iso iso);
+
+ double mass_frac(Iso iso);
+
+ double atom_frac(Iso iso);
+
+ double qty();
+
+ bool AlmostEqual(Material::Ptr other, double threshold=cyclus.eps());
+ };
+
+Other Changes
+++++++++++++++
+
+The RecipeLibrary's role of composition decay management has been shifted into
+the Composition class. *The decay lineage tracking functionality introduced by
+Matt Gidden has been effectively preserved.* RecipeLibrary now is only
+responsible for loading recipes from xml input and serving them up simulation
+wide. Agents are also allowed to register their own compositions manually.
+RecipeLibrary interface becomes:
+
+.. code-block:: c++
+
+ class RecipeLibrary {
+ public:
+ /**
+ Gives all simulation objects global access to the RecipeLibrary by
+ returning a pointer to it.
+ Like the Highlander, there can be only one.
+
+ @return a pointer to the RecipeLibrary
+ */
+ static RecipeLibrary* Instance();
+
+ /**
+ loads the recipes from the input file
+ */
+ void LoadRecipes(QueryEngine* qe);
+
+ /**
+ loads a specific recipe
+ */
+ void LoadRecipe(QueryEngine* qe);
+
+ /**
+ records a new recipe in the simulation
+ - records the recipe in the BookKeeper
+
+ @param recipe the recipe to be recorded, a CompMapPtr
+ */
+ void AddRecipe(std::string name, Composition::Ptr c);
+
+ /**
+ This returns a CompMapPtr to the named recipe in the recipes_ map
+
+ @param name the name of the parent recipe, a key in the recipes_ map
+ */
+ Composition::Ptr GetRecipe(std::string name);
+ };
+
+Backwards Compatibility
+========================
+
+Most backwards incompatible changes are unambiguously described by the
+reference implementation at https://github.com/rwcarlsen/cycamore ("res"
+branch). Existing modules will need to be updated to use the new API's. These
+changes are fairly straight forward and include:
+
+* Material queries will have to be modified to use MatQuery class.
+
+* CompMap/IsoVector creation will need to change to use new Composition
+ factory methods.
+
+* Material creation will need to change to use new Material factory
+ methods.
+
+* Agents (esp. reactors) must be modified to transmute rather than
+ throw-away/create material.
+
+Other Notes
+============
+
+Current implementation bugs
+++++++++++++++++++++++++++++
+
+* The current (before this CEP) |Cyclus| core does not correctly record
+ decayed compositions in the output database. This makes comparing
+ simulation output size and performance with that of this CEP's proposed
+ changes not exactly "fair".
+
+Backends and Performance
++++++++++++++++++++++++++
+
+Preliminary investigation on my part indicates that this extra tracking
+will cause significant slowdown using an Sqlite backend database *when
+material decay is frequent*. This slowdown prompted the development of a
+faster HDF5 alternative (currently merged into develop branch).
+
+Basic performance stats were collected by running a full |cyclus|
+inpro_low.xml simulation ``time cyclus [path/to/]inpro_low.xml``. For
+reference:
+
+* ~50,000 material objects total
+* 1100 months
+* 2200 decay calculations
+* ~28,000,000 resource object state changes recorded (with CEP implemented)
+
+|Cyclus| was built with CMake's "RELEASE" mode. Results reported are
+approximate and specific to my office computer.
+
+Without proposed changes (decayed compositions are not recorded - current bug):
+
+===================== ========= ===============
+* Backend
+--------------------- -------------------------
+Decay Sqlite Hdf5
+===================== ========= ===============
+Every 2nd timestep 40 sec. 15 sec.
+None 40 sec. 15 sec.
+===================== ========= ===============
+
+With proposed changes:
+
+===================== ========= ===============
+* Backend
+--------------------- -------------------------
+Decay Sqlite Hdf5
+===================== ========= ===============
+Every 2nd timestep 16 min. 55 sec.
+None 54 sec. 15 sec.
+===================== ========= ===============
+
+With proposed changes running inpro_low.xml with decay on and hdf5 backend:
+
+* Event and EventManager code takes ~20% of
+* Hdf5Back code takes ~20% of runtime.
+* ticking, tocking, and daily-tasking take about ~45% of runtime.
+* Decay calculations take ~10% of runtime.
+
+Decay Initiation
+++++++++++++++++++
+
+There has been some debate regarding the best way(s) to handle decaying
+material objects in the simulation. Options include: manually by agents,
+automatically and periodic, automatically at transaction time, and others.
+While this involves the resource+material classes and can have a large
+impact on simulation speed and output size, it has no direct impact on nor
+directly impacts this proposal. Further discussion on this can be found
+here https://github.com/cyclus/cyclus/issues/466 and to lesser degree
+https://github.com/cyclus/cyclus/issues/204.
+
diff --git a/_sources/cep/cep18.rst.txt b/_sources/cep/cep18.rst.txt
new file mode 100755
index 000000000..b90fef19b
--- /dev/null
+++ b/_sources/cep/cep18.rst.txt
@@ -0,0 +1,530 @@
+CEP 18 - Dynamic Resource Exchange Procedure
+********************************************
+
+:CEP: 18
+:Title: Dynamic Resource Exchange Procedure
+:Last-Modified: 2013-11-04
+:Author: Matthew Gidden
+:Status: Accepted
+:Type: Standards Track
+:Created: 2013-09-02
+
+Abstract
+========
+
+An updated procedure for determining dynamic resource exchanges is presented. It
+occurs nominally in four phases: a request for bids, a response to the request
+for bids, preference assignment, and resolution. The first three phases
+encompass an information gathering procedure, providing generic information to
+any market exchange solution procedure. The final phase is modular in that any
+algorithm can be used to solve the exchange. This modular phase takes the place
+of the current implementation of MarketModels. The procedure is informed by
+agent-based supply chain modeling literature :cite:`julka_agent-based_2002` with
+modifications as required for our nuclear-engineering domain specific
+information.
+
+Motivation
+==========
+
+The current implementation of Markets in |Cyclus| includes a base MarketModel
+class which is intended to be derived from by concrete, dynamically loaded,
+user-defined classes. Markets are assigned specific commodities, i.e., there is
+no communication across demand for multiple commodities. Markets act in the
+simulation during the **resolve** step, which occurs after the **tick** and
+before the **tock** for each timestep.
+
+Markets are communicated with through Messages. Communication to Markets utilize
+the Transaction class to define whether the communication is an **offer** or
+**request** for the Market's commodity. Communication is initialized by
+Facilities, but there is no |Cyclus| core support for this operation. Individual
+derived Facilities (e.g., the Sink and Source in Cycamore)
+define this functionality during their **HandleTick** functions. This
+interaction is invoked during the tick phase in the current facility invocations
+purely by practice. There is no requirement for such behavior; for example, one
+could send an offer or request during the tock phase, which would be ignored
+until the proceeding resolve step. In general lookups for specific markets and
+dynamic casts to communicate with those markets are required.
+
+The MarketModel class defines a pure virtual function, **Resolve**, which is
+used by derived classes to determine the specific algorithm by which the market
+is to be resolved. Markets receive proposed Transactions through their
+Communicator class interface, which requires the **ReceieveMessage** function to
+be defined by the market. The Resolve function then invokes the derived-class
+algorithm to determine matches for the given set of offers and requests.
+
+This class structure and interaction has worked well for a proof-of-prototype
+use of |Cyclus| to model simple, once-through fuel cycles. However, an extension
+or refactor is necessary to model more complicated fuel cycles for a number of
+reasons. First, there is no support for facilities that can offer or request
+resources across multiple commodities if a capacity is included. The current
+implementation of the market system can only provide this notion by ordering the
+markets in some arbitrary manner. Second, and perhaps least important of these
+reasons, is that the Transaction class is ambiguous with respect to proposed
+offers, requests, and matched offers and requests. This ambiguity can be
+addressed during a refactor to provide clarity to future developers. Third,
+there is no defined structure to the market-facility interaction. This
+interaction is the core purpose of |Cyclus|' Dynamic Resource Exchange concern,
+but users and developers are required to define their own interactions (e.g.,
+sending offers during the tick phase). The original conception of the tick-tock
+paradigm was to define a notion of time before the resource exchange (i.e., a
+pre-step) and after the resource exchange (i.e., a post-step). The current
+implementation includes the resource exchange concern during both of these
+phases, complicating the process and mixing concerns. Finally, there is no
+response mechanism for facilities to delineate between resources of a given
+commodity. The current implementation places this concern upon the market's
+resolution algorithm, rather than on the facility via some communication
+mechanism, again muddying the concerns associated with the resource exchange.
+
+Rationale
+=========
+
+The proposed refactor addresses each of the issues provided in the previous
+section. The notion of market models is redefined, separating the collection of
+supply-demand information from the algorithm used to match suppliers with
+consumers. The information gathering framework is structured and handled by the
+|Cyclus| core (i.e., not adjustable by model developers). It is top-down in the
+sense that it queries facilities for their supply and demand rather than
+requiring facility-based notifications. Accordingly, concerns are appropriately
+separated: the information is gathered by the core at the beginning of the
+resolve step, allowing facilities to inform a given market algorithm; market
+algorithms determine the set of offers and requests to be matched; and the core
+sends out resolved transactions. Message passing to and from markets is
+addressed by the framework, providing facilities, institutions, and regions each
+with specific, defined agency.
+
+Supply-Demand Framework
+-----------------------
+
+Supply-demand determination at any given time step occurs in nominally three
+steps, or **phases**, and the associated terminology is taken from previous
+supply chain agent-based modeling work
+:cite:`julka_agent-based_2002`. Importantly, this information-gathering step is
+agnostic as to the actual matching algorithm used, it is concerned only with
+querying the current status of supply and demand and facility preference thereof
+in the simulation.
+
+The first phase allows consumers of commodities to denote both the quantity of a
+commodity they need to consume as well as the target isotopics, or quality, by
+**posting** their demand to the market exchange. This posting informs producers
+of commodities what is needed by consumers, and is termed the **Request for
+Bids** (RFB) phase. Consumers are allowed to over-post, i.e., request more
+quantity than they can actually consume, as long as a corresponding capacity
+constraint accompanies this posting. Further, consumers are allowed to post
+demand for multiple commodities that may serve to meet the same combine
+capacity. For example, consider an LWR that can be filled with MOX or UOX. It
+can post a demand for both, but must define a preference over the set of
+possible commodities it can consume. Another example is that of an advanced fuel
+fabrication facility, i.e., one that fabricates fuel partially from separated
+material that has already passed through a reactor. Such a facility can choose
+to fill the remaining space in a certain assembly with various types of fertile
+material, including depleted uranium from enrichment or reprocessed uranium from
+separations. Accordingly, it could demand both commodities as long as it
+provides a corresponding constraint with respect to total consumption.
+
+At the completion of the RFB phase, the market exchange will have a set of
+consumption portfolios, :math:`P`, for each requester in the exchange, shown as
+the orange box in Figure 1. Each portfolio consists of a set of requests,
+:math:`R`, a cardinal preferential ordering over the requests, :math:`\alpha_R`,
+and possibly a set of constraints over the requests, :math:`c_R`. A constraint
+can be associated with more than one request. Take the previous example of MOX
+and UOX for an LWR. Each is a separate request, but a constraint may be
+concerned with the combination of the two. Another example is a repository that
+may request many commodities, but has a radiotoxicity constraint over any
+commodities it receives for a given time step.
+
+A request consists of a quantity, :math:`q_r`, and a target isotopic vector,
+:math:`I_r`. Consumers are allowed to offer the null set of isotopics as their
+profile, effectively providing no information. In general, a requester may have
+more than one request (nodes in Figure 1) per commodity. A prime example is a
+reactor that chooses to requests fuel assemblies, of which they request many.
+
+.. image:: cep-0018-3.png
+ :align: center
+ :scale: 50 %
+
+**Figure 1:** A Requester during the RFB Phase, where a collection of requests
+(as nodes) is shown.
+
+The second phase allows suppliers to **respond** to the set of consumption
+portfolios, and is termed the **Response to Request for Bids** (RRFB) phase
+(analogous to Julka's Reply to Request for Quote phase). Each consumption
+portfolio is comprised of requests for some set of commodities, and suppliers of
+those commodities are allowed to respond to demand. Suppliers, like consumers,
+are allowed to offer the null set of isotopics.
+
+A supplier may have its production constrained by more than one parameter. For
+example, a processing facility may have both a throughput constraint (i.e., it
+can only process material at a certain rate) and an inventory constraint (i.e.,
+it can only hold some total material). Further, the facility could have a
+constraint on the quality of material to be processed, e.g., it may be able to
+handle a maximum radiotoxicity for any given time step which is a function of
+both the quantity of material in processes and the isotopic content of that
+material.
+
+At the completion of the RRFB phase, the market exchange will have a set of
+supplier responses for each request. The supplier responses define the possible
+connections between supplier and producer facilities, i.e., the arcs in a graph
+of a matching problem. A response is comprised of a proposed isotopic profile
+the supplier is able to provide. Furthermore, constraints can be associated with
+the set of responses to be applied by the market matching algorithm. A
+constraint must identify the requests that it is associated with, define a
+capacity, and define a translation function. The translation function takes a
+request as an argument and returns a value in the units of the constraint. A
+prime example is an enrichment facility, which may be able to enrich many
+orders, but is constrained by the total SWUs it can provide.
+
+.. image:: cep-0018-4.png
+ :align: center
+ :scale: 50 %
+
+**Figure 2:** A Supplier during the RRFB Phase, where a collection of commodity
+supplies (as nodes) is shown.
+
+The final phase of the information gathering procedure allows consumer
+facilities to adjust their set of preferences and for managers of consumer
+facilities to affect the consumer's set of preferences, as described in the
+remaining sections. Accordingly, the last phase is termed the **Preference
+Adjustment** (PA) phase. Preference adjustments can occur in response to the set
+of responses provided by producer facilities. Consider the example of a reactor
+facility that requests two fuel types, MOX and UOX. It may get two responses to
+its request for MOX, each with different isotopic profiles of the MOX that can
+be provided. It can then assign preference values over this set of potential MOX
+providers. Another prime example is in the case of repositories. A repository
+may have a defined preference of material to accept based upon its heat load or
+radiotoxicity, both of which are functions of the quality, or isotopics, of a
+material. In certain simulators, limits on fuel entering a repository are
+imposed based upon the amount of time that has elapsed since the fuel has exited
+a reactor, which can be assessed during this phase. The time constraint is, in
+actuality, a constraint on heat load or radiotoxicity (one must let enough of
+the fission products decay). A repository could analyze possible input fuel
+isotopics and set the arc preference of any that violate a given rule to 0,
+effectively eliminating that arc.
+
+It should be noted that these preferences are requester based. This choice is
+based on the current simulation design notion of requesters having a preference
+over possible inputs. It is possible that in the future, one would like to model
+the notion of supplier preference (i.e., more so than the implicit nature
+currently provided by allowing suppliers to set the transaction quality and
+whether to respond to the transaction at all). One suggestion may be to allow
+suppliers to also have a supply preference, and to use the average of them in
+the objective function, but this gets into even murkier modeling/simulation
+ground. Another would be to move the paradigm more towards economics and have
+the suppliers set the cost of a transaction, which they could tailor to the
+requester. However, this draws in a whole other field of bidding that requires
+much more rigor and thought as to its validity and implementation.
+
+.. image:: cep-0018-5.png
+ :align: center
+ :scale: 50 %
+
+**Figure 3:** A supplier-consumer pair with request isotopics, response
+isotopics, and an associated preference.
+
+Institutions and Regions in |Cyclus| are provided in order to add granularity to
+the levels of relational modeling available to a user or developer. Both types
+of agents or models in |Cyclus| can possibly be allowed to affect preferences
+during the PA phase. A slightly longer discussion is included below.
+
+Facility Agency
++++++++++++++++
+
+Facilities in |Cyclus| are abstracted to either consumers or suppliers of
+commodities, and some may be both. Supplier agents are provided agency by being
+able to communicate to the market-resolution mechanism a variety of production
+capacity constraints in second phase of the information gathering
+methodology. Consumer agents are provided agency by being able to assign
+preferences among possible suppliers based on the supplier's quality of
+product. Because this agency is encapsulated for each agent, it is possible to
+define strategies that can be attached or detached to the agents at
+run-time. Such strategies are an example of the Strategy design pattern
+:cite:`vlissides_design_1995`.
+
+Institutional Agency
+++++++++++++++++++++
+
+Institutions in |Cyclus| manage a set of facilities. Facility management is
+nominally split into two main categories: the commissioning and decommissioning
+of facilities and supply-demand association. The goal of including a notion of
+institutions is to allow an increased level of detail when investigating
+regional-specific scenarios. For example, there exist multi-national
+enterprises, such as AREVA, that operate fuel cycle facilities in a variety of
+countries, or regions. Furthermore, there are international governmental
+organizations, such as the IAEA, have proposed managing large fuel cycle
+facilities that service many countries in a given global region. A fuel bank is
+an example of such a facility.
+
+Accordingly, institutions in this proposal are able to augment the preferences
+of supplier-consumer pairs that have been established in order to simulate a
+mutual preference to trade material within an institution. Of course, situations
+arise in real life where an institution has the capability to service its own
+facilities, but choose to use an outside provider because of either cost or time
+constraints. Such a situation is allowed in this framework as well. It is not
+clear how such a relationship should be instantiated and to what degree
+institutions should be allowed to affect their managed facilities'
+preferences. This issue lies squarely in the realm of simulation design
+decisions, part of the **art** of simulation. Accordingly, the strategy of
+affecting preferences is encapsulated within the full preference allocation
+phase in order to allow for further modularity of relational options between
+agents.
+
+Regional Agency
++++++++++++++++
+
+Regions are provided agency by their ability to affect preferences between
+supplier-consumer facility pairs in the PA phase, much like institutions. The
+ability to perturb arc preferences between a given supplier and a given consumer
+allows fuel cycle simulation developers to model relatively complex interactions
+at a regional level, such as tariffs and sanctions. Constraints to cross-border
+trading can also be applied. For example, a region could place constraints on
+the total amount of a given commodity type that is able to flow into it or out
+of it into a different region. Such constraints could be applied not only to
+bulk quantities of a commodity, but also to the quality of each commodity. Such
+a mechanism could be used to model interdiction of highly-enriched uranium
+transport, for example.
+
+.. image:: cep-0018-2.svg
+ :align: center
+
+**Figure 4:** Information Gathering Phase Order.
+
+.. blockdiag code below
+
+ http://interactive.blockdiag.com/?compression=deflate&src=eJztVd1qwyAYvd9TfLjrQVihpJQMmsKgd2n6AMUuX9KAqDMKKyHvXqNbfrbsCexBQY-KcvQc2yeAAktqmD5XShh5_hBMKEiAC45bCBETSZorlWjFsMrwAouL-Nr2w7aQo0F1gxw_DTYaVUPg5e2HPRkpWT2QwyTIFJaW9Ju46kSH1rWB0QuyhOTvGVk-F4C7noQ8R1GcxunStLDgRFm4jKDRi9L9fmEPOIxGs74m-T9eCw2zbEnjeB2Fmi3TQBlzfHDUt5umcZ3tyEy-zWb1ut97Tqgauaa6Ftw-NymUVrTWfo8_30L_Vxx4o6f9HKt-rWf8Kbo7GUM8HQ
+
+ blockdiag {
+ default_group_color = none;
+ default_shape = roundedbox;
+
+ "Query Requesters" -> "Query Suppliers" -> "Requester Prefs"
+
+ group {
+ label = "RFB"
+ color="#008B8B"
+ "Query Requesters"
+ }
+
+ group {
+ label = "RRFB"
+ color="#B8860B"
+ "Query Suppliers"
+ }
+
+ group {
+ label = "PA"
+ color="#9932CC"
+ orientation = portrait
+
+ "Requester Prefs" -> "Inst Prefs" -> "Region Prefs"
+ }
+ }
+
+Market Resolution
+-----------------
+
+Upon completion of the information gathering step, all information regarding the
+exchange is known. Importantly, proposed resource qualities, constraining values
+based on the resource quality, and other data such as preferences and/or costs
+are known. Given these static values, the exchange can be translated to a graph
+with supplier/consumer nodes, arcs defined by bids, supplier and consumer
+constraints on those arcs, and consumer-based preferences for those arcs.
+
+The exchange is responsible for translating its gathered information into such a
+graph formulation, and various solvers can solve the material flow along the
+arcs of that graph. The solutions are then provided to the exchange for
+back-translation into resource-specific request-bid pairs. Given such pairings,
+the exchange executes the trades.
+
+It is important to note that a generic solver interface is defined and its
+constructor is provided a resource exchange graph. Different subclasses can
+define solution algorithms given the graph.
+
+Specification \& Implementation
+===============================
+
+Each major phase method and associated classes are treated. Method inputs and
+outputs are described as well as known issues dealing with their
+implementation. The members and methods of proposed classes are also
+described. Because the phases utilize new classes and containers, those are
+described first.
+
+Constituent Classes and Containers
+----------------------------------
+
+The major new data structures required for this proposal are:
+
+* Bids
+* BidPortfolios
+* CapacityConstraints
+* Requests
+* RequestPortfolios
+
+Reference implementation (in /src) and tests (in /tests) for each can be found
+in the `CEP18 branch`_.
+
+A template approach has been taken, delineating, for instance, a material
+request, ``Request``, from a GenericResource request,
+``Request``. The current behavior (i.e., only using parent
+classes and dynamic casting to derived classes) can be invoked by templating on
+the ``Resource`` type, i.e., ``Request``. See the `capacity constraint
+tests`_ for an example of this range of behavior.
+
+Resource Exchange
+-----------------
+
+The resource exchange is implemented through coordination of two classes, the
+ResourceExchange and the ExchangeContext, both of which are implemented with
+tests in the `CEP18 branch`_.
+
+The ExchangeContext retains the current state of the exchange, including
+information regarding the players (i.e., requesters and suppliers) as well as
+information regarding requests and bids. The ResourceExchange initiates the
+various phases and updates the context state. As currently envisioned, an
+exchange and context's lifetime is the single resolution of the exchange at a
+given time. The exchange is populated with traders as known by the wider
+simulation context. Both the ExchangeContext and ResourceExchange are templated
+on the Resource being exchanged, as was the case above. An overview of the
+exchange implementation follows, noting the state updates of the context at each
+phase.
+
+RFB Phase
++++++++++
+
+Note that the ExchangeContext has no state at the beginning of the phases.
+
+ResourceExchange operations:
+
+* Queries each Trader registered with the simulation Context, asking for
+ RequestPortfolios
+
+ExchangeContext state at end of phase:
+
+* Requesters
+* Requests
+* RequestPortfolio
+
+RRFB Phase
+++++++++++
+
+ResourceExchange operations:
+
+* Queries each Trader registered with the simulation Context, asking for
+ BidPorftolios
+* The ExchangeContext is given to each trader in order to determine all Requests
+ for a specific commodity
+
+ExchangeContext state at end of phase:
+
+* Bidders
+* BidPortfolios
+* Default preferences for each Bid-Request pair (provided in the original Request)
+
+PA Procedure
+++++++++++++
+
+ResourceExchange operations:
+
+* For each Requester and each parent in the Model child-parent tree of that
+ Requester, preferences are allowed to be perturbed, which looks nominally like:
+
+.. code-block:: c++
+
+ /// @brief allows a trader and its parents to adjust any preferences in the
+ /// system
+ void DoAdjustment(Trader* t) {
+ typename PrefMap::type& prefs = ex_ctx_.Prefs(t);
+ Model* m = dynamic_cast(t);
+ while (m != NULL) {
+ cyclus::AdjustPrefs(m, prefs);
+ m = m->parent();
+ }
+ };
+
+For full implementation details, please see the `CEP18 branch`_.
+
+ExchangeContext state at end of phase:
+
+* Possibly perturbed preferences for each Bid-Request pair
+
+ExchangeGraph
+-------------
+
+An ExchangeGraph is a graph representation of a resource exchange. It provides a
+resource-free representation of the exchange, i.e., the quality-specific
+constraint and preference values are "baked in". By the nature of the
+supplier/requester setup, the graph is bipartite, thus there is a notion of U
+(left) and V (right) nodes, and arcs strictly connect a U node to a V
+node. Constraints are defined along arcs, where each u-v node pair is associated
+with a constraining value. Preferences are also defined along arcs.
+
+ExchangeTranslator
+------------------
+
+The ExchangeTranslator is an object responsible for translating a given
+ExchangeContext into an ExchangeGraph, and has a pretty simple interface:
+
+.. code-block:: c++
+
+ template
+ struct ExchangePair {
+ Request::Ptr r; // request
+ Bid::Ptr b; // bid
+ double p; // percent of bid to give
+ }
+
+ template
+ class ExchangeTranslator {
+ public:
+ ExchangeGraph ToGraph(const ExchangeContext& ec) {
+ /* do translation */
+ };
+
+ std::set< ExchangePair >
+ FromGraph(const ExchangeGraph& eg) {
+ /* do back-translation */
+ };
+ };
+
+ExchangeSolver
+--------------
+
+The ExchangeSolver is a virtual interface for solvers of a resource exchange. A
+constrained ExchangeGraph is provided as input, and a solution ExchangeGraph is
+provided as output, which satisfies the provided constraints. It too, has a
+pretty simple interface
+
+.. code-block:: c++
+
+ class ExchangeSolver {
+ public:
+ virtual void Solve(const ExchangeGraph& g) = 0;
+ };
+
+Backwards Compatibility
+=======================
+
+This CEP proposes a number of backwards incompatibilities.
+
+- The MarketModel is replaced by an information gathering procedure and a
+ modular MarketAlgorithm
+
+- Transactions are reduced to accepted offers, rather than proposed offers and
+ requests
+
+- The Message and Communicator classes are no longer needed
+
+Document History
+================
+
+This document is released under the CC-BY 3.0 license.
+
+References and Footnotes
+========================
+
+.. rubric:: References
+
+.. bibliography:: cep-0018-1.bib
+ :cited:
+
+.. _CEP18 branch: https://github.com/gidden/cyclus/tree/cep18
+
+.. _capacity constraint tests: https://github.com/gidden/cyclus/blob/cep18/tests/capacity_constraint_tests.cc
diff --git a/_sources/cep/cep19.rst.txt b/_sources/cep/cep19.rst.txt
new file mode 100755
index 000000000..9182e07bb
--- /dev/null
+++ b/_sources/cep/cep19.rst.txt
@@ -0,0 +1,602 @@
+CEP 19 - |Cyclus| Input Procedure Updates
+********************************************
+
+:CEP: 19
+:Title: |Cyclus| Input Procedure Updates
+:Last-Modified: 2013-10-16
+:Author: Dr. Tony Scopes & Robby Flanny
+:Status: Withdrawn
+:Type: Standards Track
+:Created: 2013-10-16
+
+Introduction
+============
+
+This CEP proposes to update the |cyclus| input paradigm and the module schemas such that
+they enable a wider variety of tools. This CEP was written with two types of tools in mind:
+graphical user interfaces and large scale parameter investigations. The goal of this
+CEP is to give the input scheme the descriptive power it needs to provide users and module
+developers with an elegent and clear method of building |cyclus| input files.
+
+
+The first major change is to develop a suite of patterns for use by |cyclus| module schema.
+These patterns are meant to richly representing module input fields. These patterns will be a
+collection of elements that provide sufficient metadata needed by the two use cases listed
+above. For instance, one such additional element is 'tooltip'.
+
+The second change is the addition of an interface to modules. This interface will be used in
+conjuction with the current 'schema()' member function. This function will be called 'default_inputs()'
+and return an xml input file snippit for the facility with default values in all input fields.
+
+Motivation
+==========
+CycIC (and other less useful interfaces) requires this new suite of patterns to provide users with
+a better experience. For example integrated module documentation is part of this proposal. In addition,
+many elements of the pattern will also be useful for parametric sweeps.
+
+Specification \& Implementation
+===============================
+The following patterns are proposed to be added to the master |Cyclus| schema.
+
+
+Tooltip
++++++++
+Tooltip elements is a short string of text that the developer can add to an input field that will
+show when a user scrolls over this field in the graphical user interface. This is an optional field.
+
+.. code-block:: xml
+
+
+
+
+
+
+
+
+Help
+++++
+Help elements will provide a more thorough explaination of the input field, it can be accessed through the
+graphical user interface. This is an optional field.
+
+.. code-block:: xml
+
+
+
+
+
+
+
+
+Units
++++++
+Units elements apply information to an input field that indicate to the user what units are attached to the
+value in this field.
+
+.. code-block:: xml
+
+
+
+
+
+
+
+
+User Level
+++++++++++
+User level elements allow developers to set the user level of a specific input field. This value ranges
+from 0 to 10 with 0 being simple inputs and 10 being very advanced inputs. This is an optional field
+and if left blank the value will be set to zero by the graphical user interface.
+
+.. code-block:: xml
+
+
+
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+
+
+
+
+
+Vary
+++++
+The 'vary' element is a special boolean element that allows a |cyclus| user to set wether the input
+field it is attached to can be varied for a parametric study. This flag is optional and can take
+the values "true", "false", "1", "0".
+
+.. code-block:: xml
+
+
+
+
+
+
+
+
+Sampling Function
++++++++++++++++++
+Sampling function is an element that goes with the vary element. If the vary element is set to true
+a sampling function is required to provide the sampling behavior for the element. This is a string
+input that represents the mathematical expression of the sampling function. This is an optional flag.
+
+.. code-block:: xml
+
+
+
+
+
+
+
+
+Field Types
++++++++++++
+
+The field types used for input fields are listed below. In general they are associated with a
+specific data type. In addition there are several field types that are categorical. This
+implies that the field has discrete values for which it can take.
+
+.. code-block:: xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Cycic Specific Tags
+===================
+In order to facilitate loading |cyclus| scenarios that were previously built with CycIC
+some additional fields are proposed to be added to the xml grammar. These fields will
+hold information on how to display the graphical parts of the simulation.
+
+This portion of the xml file will not be read by |cyclus|, and should have no impact on
+the |cyclus| core code.
+
+Top level Information
++++++++++++++++++++++
+Here the name of the CycIC simulation, a description, and some comments about it
+can be saved.
+
+.. code-block:: xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Facility Circles
+++++++++++++++++
+Here the initital proposal is to save the x and y locations of the facilities so that
+they may be loaded in the proper place.
+
+.. code-block:: xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Market Circles
++++++++++++++++
+Here the initital proposal is to save the x and y locations of the markets so that
+they may be loaded in the proper place.
+
+.. code-block:: xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Region Shapes
++++++++++++++++
+Here the initital proposal is to save the x and y locations of the region nodes so that
+they may be loaded in the proper place.
+
+.. code-block:: xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Institution Shapes
+++++++++++++++++++++
+Here the initital proposal is to save the x and y locations of the institution
+nodes so that they may be loaded in the proper place.
+
+.. code-block:: xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Document History
+================
+
+This document is released under the CC-BY 3.0 license.
+
+References and Footnotes
+========================
+
+.. rubric:: References
+
diff --git a/_sources/cep/cep2.rst.txt b/_sources/cep/cep2.rst.txt
new file mode 100755
index 000000000..1ed627b16
--- /dev/null
+++ b/_sources/cep/cep2.rst.txt
@@ -0,0 +1,316 @@
+CEP 2 - Separation of Concerns in the |cyclus| Ecosystem
+********************************************************
+
+:CEP: 2
+:Title: Separation of Concerns in the |cyclus| Ecosystem, or Where Do I Put My Code?
+:Last-Modified: 2017-09-01
+:Author: Anthony Scopatz, Matthew Gidden
+:Status: Accepted
+:Type: Process
+:Created: 2013-08-05
+
+Abstract
+========
+The purpose of this CEP is to clearly delineate the purpose -- technical and
+cultural -- of the various projects which make up the |cyclus| ecosystem.
+Projects, for purposes here, are unique entities which have independent lifetimes
+and central concerns. Many projects may try to tackle the same concern but no
+single project may tackle more than one concern. Concerns, like projects, may
+be dependent upon one another.
+
+The central concerns in the |cyclus| ecosystem are
+**dynamic resource exchange simulation** (DRES), **domain models** (DM),
+**analysis & visualization** (A&V), and **simulation orchestration** (ORC).
+
+Concerns
+========
+A rich fuel cycle simulator solution has four primary organizational pieces that
+must have robust implementations. These pieces are a mechanism for solving for
+resource exchange in the fuel cycle, relevant and interesting models for the
+domains of interest (physics, economics, policy, etc.), a
+programmatic method for parsing, slicing, aggregating, and displaying
+simulation results, and a mechanism for executing and collecting many simulations.
+As an effectively designed suite of software, these concerns
+should be completely separated from one another
+and interact only through well-defined interfaces [1]_. This
+independence allows both users and developers to reason about each concern
+without needing to consider upstream effects. Coupled with a stable interface
+or API, this independence also allows users and developers to ignore downstream
+effects in most cases.
+
+The domain model concern is dependent only on the resource exchange concern.
+However, the analysis & visualization concern is directly dependent on both the
+resource exchange and the domain model concerns. These relationships may be seen
+in Figure 1.
+
+.. figure:: cep-0002-1.svg
+ :align: center
+
+ **Figure 1:** Dependencies Between Concerns
+
+.. blockdiag code below
+
+ http://interactive.blockdiag.com/?compression=deflate&src=eJxlkM9qwzAMxu95CtHDbnuC0MFgO47BBr0so7i21ghsKfjPSFv27jOJkyyZb5J-nz_pAwC4QQXDM_ilko3Hs5fUHbVY8bAHFsZ6Q4RWdZhnGWSD5iR9XRXEY8Bew4dVJ7T73dOFlSMNbxgkeY0NP_e6VXxGeCeXrIokvPucDcQ5MYtanCKGFzFow0Iptt90nalHVvYSKMBdwwcKSVm6bv4N5MQvWy3WDb963WKIviiqteL-oVy08c79kajXd-f-SMyBDGnCrVQA4gk5Dm45wU58tqZYz_NJPtVjJFP9889uPS8B_lljVP0CxFWTeA
+
+ {
+ default_group_color = none;
+ default_shape = roundedbox;
+
+ resexc [label="Dynamic Resource\nExchange Simulation"];
+ dommod [label="Domain Models"];
+ anlviz [label="Analysis &\nVisualization"];
+ simorc [label="Simulation\nOrchestration"]
+
+ simorc -> resexc;
+ anlviz -> simorc;
+ resexc -> anlviz;
+
+ group {
+ orientation = portrait;
+ anlviz;
+ dommod;
+ }
+ resexc -> dommod;
+ dommod -> anlviz;
+ }
+
+
+Dynamic Resource Exchange Simulation
+------------------------------------
+The dynamic resource exchange simulation concern is the basis for all other fuel
+cycle concerns. This dictates and manages how resources flow through a system and
+the time paradigm used to model the system. A number of possible representations of
+system elements exist. Two main options stand out: 1) *individual-based* models in
+which every actor receives its own instance, and 2) *fleet-based* models where
+like actors are grouped together and act identically. Resource exchange may be
+implemented using a strict *agent-based* modeling [2]_ approach or strict
+*system dynamics* methods [3]_. However, these two paradigms are not restrictive
+and implementations may pull from a variety of algorithms as needed.
+
+Furthermore, the choice of how to represent time evolution may fall into one
+of the following categories:
+
+* **Equilibrium** - initial transients are ignored or discarded in favor of a steady
+ state solution.
+* **Quasi-static** - initial transients are computed but natural time (sec, min, etc)
+ are replaced with an easier to compute number of passes through a given
+ actor.
+* **Discrete time** - natural time is implemented but discretized to some minimum
+ and constant dt.
+* **Adaptive time** - natural time is implemented and discretized, but the value of
+ dt may change from time step to time step, allowing for finer resolution only
+ when needed.
+* **Continuous time** - natural time is implemented as a continuous variable.
+
+It is important to note that this concern is a solely mathematical endeavor and
+should not implement any domain-specific calculations. However, the
+implementation may be *domain-aware* in that it may know about certain sub-type
+specializations. For example, materials and U.S. Dollars are both sub-types of
+resources. Still, the dynamic resource exchange simulation concern is not
+allowed to discriminate between any of these specializations nor perform
+domain-specific computations (such as transmuting a material or pricing a
+derivative).
+
+This concern is responsible for housing general archetypes that allow for
+general, dynamic simulation of supply chain networks in a resource-neutral
+manner. Supply chain network models require, at minimum, three types of entities
+(i.e., nodes) :cite:`bazaraa2011linear`:
+
+* Sources (supply nodes)
+* Storage (transshipment nodes)
+* Sinks (demand nodes)
+
+In addition to enabling such basic simulations, the dynamic resource exchange
+simulation concern is also responsible for all optimizations of the fuel cycle.
+This includes optimizing resource exchange between multiple actors as well as
+finding the initial conditions which optimize a value function subject to some
+constraints.
+
+Domain Models
+-------------
+The purpose of the domain models concern is to provide interesting, accurate, and
+relevant models of various aspects of the fuel cycle. These aspects are often the
+technical meat of the fuel cycle analysis. However, they may be mathematically
+separated from resource exchange. This concern ensures that those mathematical
+separations remain distinct in the software. There are a number of domain models
+which are pertinent to fuel cycle calculations:
+
+* Physics
+* Chemistry
+* Health Physics
+* Economics
+* Public Policy
+* and more!
+
+The implementation of specific domain computations should rely on the system dynamics
+for all systematic flow and timing needs. The implementation of the domain
+calculations should be completely separated from the system dynamics concern.
+This establishes a clean interface between these two concerns.
+
+For example, take an enrichment facility which is asked to compute product and tails
+enrichments. In the initialization of this calculation, the dynamic resource
+exchange simulation concern hands off the simulation time (t), the time delta (dt),
+and the initial feed material to the underlying physics model. The physics model
+then computes the desired outputs without further interaction with the resource
+exchange model. Lastly, the outputs are returned to the DRES model.
+
+Analysis & Visualization
+------------------------
+The purpose of the analysis & visualization concern is to supply aggregation and
+introspection into the simulation outputs. The analysis may take place at both
+high and low levels, common aggregations should be easy to perform, and static
+and interactive visualization should be provided as a mechanism for easy human
+consumption. All post-processing of simulation data falls under this concern.
+
+The analysis & visualization concern is dependent directly on both the dynamic
+resource exchange simulation concern and the domain models concern. This is because
+meaningful inspection of simulation data requires parameters from both concerns.
+Note that these dependencies are independent. The analysis & visualization tools
+must handle the case where only DRES models are used. However, if domain models
+are used and the analysis & visualization is aware of these domain models,
+all DRES parameters are guaranteed to also be present.
+
+Simulation Orchestration
+------------------------
+Simulation campaigns often involve executing multiple instances of the DRE and
+associated analysis and visualization. This may be with the purpose of,
+
+* performing a sensitivity study,
+* running a parameter sweep,
+* sampling from a large option space, or
+* creating a training set for machine learning models.
+
+This execution and analysis is either managed manually or automatically, but it
+is always managed. Running, analyzing, visualizing, and generating many |cyclus|
+input files is termed here "orchestration." This includes provisioning compute
+resources where these tasks are executed. Data management also falls under the
+purview of simulation orchestration.
+
+Simulation orchestration provides a feedback loop for the |cyclus| ecosystem.
+It both drives the DRE simulator and incorporates the results of previous
+simulations.
+
+
+The |Cyclus| Ecosystem
+======================
+While many fuel cycle simulators may choose to implement all of the above concerns
+in a single project, each concern in the |cyclus| ecosystem is implemented in
+its own project. Many projects may satisfy the needs of a concern. However, no
+project may try to address multiple concerns. This provides a clear guideline
+for which projects should accept which kinds of code.
+
+If for some reason ambiguities exist, first attempt to refactor the code at hand
+with these concerns in mind. If this fails because of a fundamental ambiguity
+or mixing of multiple concerns, place the code with the most dependent concern.
+For example, if it is not clear if a class belongs with domain models or with the
+resource exchange put it with the domain models to be safe.
+
+The |cyclus| development team currently supports projects for these concerns:
+
+* `Cyclus`_ - Dynamic Resource Exchange Simulation (individual actors, discrete
+ time, canonical supply chain entities)
+* `Cycamore`_ - Domain Models
+* `Cymetric`_ - Analysis & Visualization
+* `Cyclist`_ - Analysis & Visualization (historical)
+* `Rickshaw`_ - Simulation orchestration
+
+The dependency graph for these projects is similar to the graph of the concerns.
+Figure 2 displays this graph along with other projects which implement these concerns.
+
+.. figure:: cep-0002-2.svg
+ :align: center
+
+ **Figure 2:** Dependencies Between Projects is |Cyclus| Ecosystem.
+
+.. blockdiag code below
+
+ http://interactive.blockdiag.com/?compression=deflate&src=eJyFUstqwzAQvOcrFgV6M_QYY1JI1fZQKIUUeiklyNLGFpW1QZLbJCX_XsV52HESqtNKM7MzWhYA4HcAzVE4F7UJs8JRvZhJMuRgDJYsZj2GL8UCIxaJVqHKaZkN9pRGDA49LuWxMwA5jTaIoMlG3YJccEKH7IgbkaMZsyl6qp1EeFzKUtgCWUvhK2lq3943p5aKqopUx3Lf8oEqoS28kELjO-0O_2PDp1s-GaUd6L-wMYmoyCEkSawVum3B7p0uypAYHZA1D3yVkyvY1cTCmm-9Pk88scKsvPZwA-_a18LodZOlH37MhpyPUs7PhvT8tosmtbzqTk6eW786WaKP373k1wwrzeMOqA401fIr7sPPBaNdGEjujhPLLiG7wC20ndoJ9DEnE9fss6PWcsvoex_urbqn3fwBgOfNqA
+
+ {
+ default_group_color = none;
+ default_shape = roundedbox;
+
+ group resexc {
+ orientation = portrait;
+ label="Resource Exchange";
+ Cyclus;
+ }
+
+ group dommod {
+ label="Domain Models";
+ color = "#F0CA89";
+ orientation = portrait;
+ Cycamore -- Cyder -- "Bright-lite" -- "Cyborg";
+ }
+
+ group anlviz {
+ label="Analysis & Visualization";
+ color="#CC89CC";
+ CyclusJS -- Cycic;
+ }
+
+ group orc {
+ label="Orchestration";
+ color = "#9befad";
+ Rickshaw;
+ }
+
+ Cyclus -> Cycamore;
+ Cyclus -> CyclusJS ;
+ Cyborg -> CyclusJS [folded];
+ Cycic -> Rickshaw;
+ Rickshaw -> Cyclus [folded];
+ }
+
+Toolkits
+--------
+In any real system, there is glue code which holds the projects together in a
+cohesive manner. A collection of such utilities is called a *toolkit*. While
+toolkits are critically important to well functioning software their components
+are united only in that "should be useful." There need not be underlying concept
+tying them together. For this reason, toolkits are not a top-level concern on
+par with resource exchange, domain models, and analysis & visualization.
+
+Instead, each project may have its own toolkit which contains utilities that
+corresponds most closely with its concern. The toolkit provides a layer on top of
+the concern implementation. Thus the toolkit will be aware of other parts of the
+project but the concern implementation should not call into elements from the toolkit.
+
+For example, resources are part of the primary concern of |cyclus|. Thus
+a ResourceBuffer class would be part of the |cyclus| toolkit. This is because
+resource exchange can be implemented without a ResourceBuffer but such a class
+is useful to provide to domain model developers. Furthermore, the buffer
+applies to all resources is not specific to any domain. Thus this class should be
+included next to the resource exchange implementation.
+
+Summary
+=======
+Many other ecosystems and projects model the fuel cycle and make their own choices
+about how to separate -- or not -- the concerns of resource exchange, domain models,
+and analysis and visualization. The |cyclus| ecosystem places all concerns in
+separate projects. This allows a high degree of modularity between software and
+developers. Such an ecosystem enables experts to contribute their specific
+knowledge base in a way that is independent from other parts of the ecosystem
+while simultaneously integrating well with the rest of the ecosystem. Finally,
+this document provides instructions on where to implement tasks based on the task's
+primary concern.
+
+Document History
+================
+This document is released under the CC-BY 3.0 license.
+
+References and Footnotes
+========================
+
+.. [1] http://en.wikipedia.org/wiki/Separation_of_concerns
+.. [2] http://en.wikipedia.org/wiki/Agent-based_model
+.. [3] http://en.wikipedia.org/wiki/System_dynamics
+
+.. _Cyclus: https://github.com/cyclus/cyclus
+.. _Cycamore: https://github.com/cyclus/cycamore
+.. _Cymetric: https://github.com/cyclus/cymetric
+.. _Cyclist: https://github.com/cyclus/cyclist2
+.. _Rickshaw: https://github.com/ergs/rickshaw
+
+.. bibliography:: cep-0002-1.bib
+ :cited:
diff --git a/_sources/cep/cep20.rst.txt b/_sources/cep/cep20.rst.txt
new file mode 100755
index 000000000..610247c1a
--- /dev/null
+++ b/_sources/cep/cep20.rst.txt
@@ -0,0 +1,203 @@
+CEP 20 - Time Step Execution Stack
+**********************************
+
+:CEP: 20
+:Title: Time Step Execution Stack
+:Last-Modified: 2014-02-24
+:Author: Matthew Gidden
+:Status: Accepted
+:Type: Standards Track
+:Created: 2014-02-19
+
+Abstract
+========
+
+An update to the time step execution stack is proposed. A timestep will now
+progress through phases, including a building phase, a tick phase, a resource
+exchange phase, a tock phase, and a decommissioning phase. Phases are grouped in
+two categories: kernel phases and agent phases. Kernel phases have required or
+guaranteed actions that occur during them, and include the build, exchange, and
+decommission phases. Agent phases include the Tick, Tock, and Decision phases, and allow
+agents to inspect simulation state and update their own state.
+
+Motivation
+==========
+
+The current time step in |cyclus| consists of the following stack:
+
+* Tick
+* Resource Exchange
+* Tock
+
+Until very recently, only Regions received ticks/tocks from the Timer
+class. They were then expected to pass the Tick/Tock "message" to their
+children, and so on, until all Models received a Tick or Tock. It was pointed
+out recently that this behavior, when mixed with entity entry and exit into/from
+the simulation could produce unexpected behavior, e.g., an entity could
+enter/exit in the middle of a time step. Furthermore, modules were developed
+specifically taking advantage of this behavior (i.e., the ordering of
+ticks/tocks) in order to guarantee that entities that were constructed during
+the Tick phase also received a Tick in that phase. Furthermore, this imposed a
+requirement on Regions and Institutions that they pass Ticks and Tocks along to
+their children in a trickle-down-like manner.
+
+Accordingly, there is a need to standardize what can/should be expected to occur
+in each phase of a given time step. Guarantees should be given to module
+developers that if an entity enters a simulation, that it will experience the
+entire time step on the time step it enters, and if an entity leaves a
+simulation, that it will experience an entire time step on the time it leaves.
+
+Tick and Tock serve as phases for agents to perform actions. As an action can
+occur in either phase, no one specific phase serves as a good time to make
+decisions based on the state of the simulation. Therefore a user phase specifically
+for decision must occur after the tock phase. Note, this phase exists only for
+agents to make decisions based on that time step. Other actions should
+occur in the Tick and Tock phases.
+
+Rationale
+=========
+
+By Law's definition :cite:`Law:1999:SMA:554952`, a |cyclus| simulation is,
+broadly, a dynamic, discrete-event simulation that uses a fixed-increment time
+advance mechanism. In general, fixed-increment time advance scenarios assume a
+time step (dt), and assume that all events that would happen during a time occur
+simultaneously at the end of the time step. This situation can be thought of as
+an event-based time advance mechanism, i.e., one that steps from event to event,
+that executes all events simultaneously that were supposed to have occurred in
+the time step.
+
+Two key types of events happen in a |cyclus| simulation (at present):
+
+* the exchange of resources
+* agent entry into and exit from the simulation
+
+Simulation entities can have arbitrarily complex state which is dependent on the
+results of the exchange and the present status of agents in the
+simulation. Accordingly, methods that allow entities to update state must occur
+in response to these events and to schedule agent entry and exit.
+
+Because there is a key event that defines agent interaction in a given time
+step, it is necessary to involve all agents in that interaction. Accordingly it
+is necessary that there be an ordering between these two key types of events,
+deviating slightly from Law's description of fixed-increment time
+advance. Specifically, we want to preserve the following invariant: *any agent
+that exists in a given time step should be included in the resource exchange,
+or, equivalently, experience the entire time step execution stack*.
+
+This leads to the following ordering, or *phases*, of time step execution:
+
+* agents enter simulation (Building Phase)
+* agents respond to current simulation state (Tick Phase)
+* resource exchange execution (Exchange Phase)
+* agents respond to current simulation state (Tock Phase)
+* agents react to simulation (Decision Phase)
+* agents leave simulation (Decommissioning Phase)
+
+The Building, Exchange, and Decommissioning phases each include critical,
+core-based events, and will be called *Kernel* phases. The Tick, Tock, and Decision
+phases do not include core-based events, and instead let agents react to previous
+core-based events and inspect core simulation state. Furthermore, they are
+periods in which agents can update their own state and are accordingly
+considered *Agent* phases. In general, Agent phases *must* bracket *critical*
+Kernel phases, of which only the Exchange Phase exists for now. If another
+critical core phase is added in the future it must provide a similar invariant,
+i.e., that it is bracketed by Agent phases. For example, if a new phase is added
+before Exchange, then the time execution stack would follow as: Building, Tick,
+*New Kernel Phase*, *New Agent Phase*, Exchange, Tock, Decommission.
+
+Technically, whether agent entry occurs simultaneously with agent exit or not
+does not matter from a simulation-mechanics point of view, because the two
+phases have a direct ordering. It will, however, from the point of view of
+module development. It is simpler cognitively to think of an agent entering the
+simulation and acting in that time step, rather than entering a simulation at a
+given time and taking its first action in the subsequent time step.
+
+In the spirit of Law's definition of a fixed-increment time advance mechanism,
+there is a final important invariant: *there is no guaranteed agent ordering of
+within-phase execution*. This invariant allows for:
+
+* a more cognitively simple process
+* paralellization
+
+Any future addition of phases in the timestep execution stack neccessarily
+guarantee the three invariants described above.
+
+Specification \& Implementation
+===============================
+
+Two primary concerns exist for changing the current state of |cyclus| to
+incorporate this CEP:
+
+* how to implement agent entry/exit as described
+* what name to give to the response phases
+
+Currently, the response phases are called Tick and Tock. These names have been
+criticized for not being specific/informative about the expected actions agents
+will/should take during the phases. I propose we instead use *PreExchange* and
+*PostExchange*. Wordsmithing and/or other suggestions are welcome.
+
+The agent entry/exit question is a bit more involved because of the parent-child
+(or manager-managed) relationship agents have in |cyclus|. Specifically, the
+entry and exit of agents should be managed by the agent's manager. The following
+provides one possible specification.
+
+.. code-block:: python
+
+ /// @brief execute time step stack
+ def Step(context):
+ time = context.time()
+
+ for each builder, prototype in build_list[time]:
+ builder.build(prototype)
+
+ for each agent in agent_list:
+ agent.PreExchange()
+
+ for each manager in resource_exchange_managers:
+ manager.Execute()
+
+ for each agent in agent_list:
+ agent.PostExchange()
+
+ for each agent in decomm_list[time]:
+ agent.parent->decommission(agent)
+
+The primary change here is the notion of a build_list and decomm_list. Managers
+of agents, nominally their parent, can add agents to each list as required
+during the Pre- and PostExchange phases. At some future time, the building and
+decommissioning lists can be made queryable in order to determine future overall
+or sub-simulation state (e.g., the power level at a future point in
+time). Accordingly, prototypes (which know their initial state) are used in the
+build_list and to-be decommissioned agents in the decomm_list.
+
+As described above, the notion of build and decommission lists can change in a
+time step. When combined with the invariant that the order of agent execution
+within a phase is unordered, future simulation predictions would be unreliable
+*if* both lists could be changed in within a phase. Therefore, these lists must
+be immutable *during* phases. This issue can be remedied by using staging data
+structures and merging the staging data structures into the lists after the
+completion of a phase.
+
+Backwards Compatibility
+=======================
+
+The overall |cyclus| implementation/framework will remain largely unchanged,
+with the exception of the core's handling of agent entry/exit
+registration. *Cycamore* modules that deal with agent entry/exit will have to be
+redesigned to incorporate the new execution stack.
+
+
+
+Document History
+================
+1. Adding Decision Phase (April 2018) - Author: Robert Flanagan
+
+This document is released under the CC-BY 3.0 license.
+
+References and Footnotes
+========================
+
+.. rubric:: References
+
+.. bibliography:: cep-0020-1.bib
+ :cited:
diff --git a/_sources/cep/cep21.rst.txt b/_sources/cep/cep21.rst.txt
new file mode 100755
index 000000000..e5f719755
--- /dev/null
+++ b/_sources/cep/cep21.rst.txt
@@ -0,0 +1,94 @@
+CEP 21 - Agent Identification and Discovery
+***********************************************************
+
+:CEP: 21
+:Title: Agent Identification and Distribution
+:Last-Modified: 2014-05-05
+:Author: Robert Carlsen
+:Status: Accepted
+:Type: Standards Track
+:Created: Robert Carlsen
+
+Abstract
+========
+
+|Cyclus| is designed to have plugin modules that can be easily distributed and
+installed. A "module" is a shared library containing one or more compiled
+|Cyclus| agents. Agents within mouldes must be uniquely identifiable and
+discoverable by both users managing their |Cyclus| installation and by the
+|Cyclus| kernel itself. A user wishing to use certain modules must install them
+in a desired location and then identify specific agents in them to |Cyclus|.
+This CEP explains where modules can/should be installed and how |Cyclus| finds
+and identifies agents in them.
+
+.. _agent-spec-docs:
+
+Agent Spec
+===========
+
+Agents will be uniquely identified by 3 components together referred to as an
+"agent spec":
+
+1. path: e.g. ``my/module/path``
+
+ A slash-delimited, valid filesystem path relative to CYCLUS_PATH (see
+ Module Discovery below).
+
+2. library: e.g. ``MyModule``
+
+ Name of the compiled shared object library file without the "lib" prefix
+ and without the file extension. If empty, is expanded to the agent class.
+ The example above would correspond to a library file named "libMyModule.so"
+ (linux), "libMyModule.dylib" (darwin), etc.
+
+3. agent class: e.g. ``MyAgent``
+
+ The name of the agent's c++ class as compiled into the shared library file.
+
+An agent spec also has a single-string form composed of the three components
+separated by colons::
+
+ [path]:[library]:[agent-class]
+
+ e.g. "my/module/path:MyModule:MyAgent"
+
+Example linux agent specs with corresponding filepath expansions::
+
+ my/path:MyModule:MyAgent -> my/path/libMyModule.so
+ my/path::MyAgent -> my/path/libMyAgent.so
+ :MyModule:MyAgent -> libMyModule.so
+ ::MyAgent -> libMyAgent.so
+
+Module Discovery
+================
+
+When running a simulation, |Cyclus| will search the following candidate
+directories (in order) for each given agent spec:
+
+1. Each colon-separated directory in the CYCLUS_PATH environment variable.
+
+2. The default |cyclus| module install directory: ``[install-dir]/lib/cyclus``.
+
+|Cyclus| will check for the library by building consecutive paths with the
+following composition::
+
+ [candidate-dir]/[path]/lib[library][extension]
+
+|Cyclus| uses the first matching shared library file found and assumes the
+specified agent class exists inside it.
+
+Conventions
+============
+
+The path should consist of only alpha-numeric characters, slashes,
+underscores, and dashes. **No** spaces. If there are resource files that must
+be installed with the shared library file, the library and resources should be
+placed in their own directory.
+
+The shared library name should consist of only alpha-numeric characters,
+slashes, underscores. **No** spaces. If the shared library only has a
+single agent in it, the library should be the same as the agent class. For
+example, if my agent was named ``MyAgent``, then the library file should be
+named ``libMyAgent.so`` on a linux system. This allows the defaults to
+prevent stuttering in the agent's module spec.
+
diff --git a/_sources/cep/cep22.rst.txt b/_sources/cep/cep22.rst.txt
new file mode 100755
index 000000000..a58441b86
--- /dev/null
+++ b/_sources/cep/cep22.rst.txt
@@ -0,0 +1,28 @@
+CEP 22 - Logging Methodology and Implementation
+**************************************************************
+
+:CEP: 22
+:Title: Logging Methodology and Implementation
+:Last-Modified: 2014-06-29
+:Author: Matthew Gidden
+:Status: Deferred
+:Type: Standards Track
+:Created: 2014-06-29
+
+.. note::
+
+ This CEP is looking for a champion.
+
+Overview
+========
+
+The current state of logging in |cyclus|, i.e., reporting results to `stdout`
+and `stderr`, has been identified as non-ideal. A non-deferred version of this
+CEP will provide a new logging methodology, an implementation thereof, and a
+discussion a series of examples of how logging should occur at both the kernel
+and archetype development level (if neccessary).
+
+Document History
+================
+This document is released under the CC-BY 3.0 license.
+
diff --git a/_sources/cep/cep23.rst.txt b/_sources/cep/cep23.rst.txt
new file mode 100755
index 000000000..3d04bc031
--- /dev/null
+++ b/_sources/cep/cep23.rst.txt
@@ -0,0 +1,139 @@
+CEP 23 - Defining Time Step Length, High Noon for Blue Moon
+**************************************************************
+
+:CEP: 23
+:Title: Defining Time Step Length, High Noon for Blue Moon
+:Last-Modified: 2014-12-01
+:Author: Anthony Scopatz
+:BDFP: Paul P. H. Wilson
+:Status: Draft
+:Type: Standards Track
+:Created: 2014-12-01
+
+Motivation
+==========
+Cyclus is a discrete time simulator whose assumed default time step is
+months. Months are the worst unit ever. This proposal adds precision and
+flexibility to what we mean by :math:`\delta t`. Namely, this CEP moves from
+months to seconds and allows the user to set the time step length, preserving
+a default length of a Julian month.
+
+Discussion
+==========
+Cyclus lacks a canonical time system. This CEP seeks to unambiguously define
+the seconds as the default time unit. This allows agents to unambiguously
+communicate with each other and to determine their own time scales internally.
+This CEP also adds the capability for users to specify a time step length
+(:math:`\delta t`) of their choosing. The default time step, if unspecified,
+will be a well-defined month, improving on the historically nebulous month.
+
+This CEP is motivated by our past woes with months.
+Months are an awful time step because there is no single definition for what a
+month *is* and all definitions lack a physical basis. Days and years map nicely
+(enough) onto a solar cycle. A lunar cycle is 29.53059 days with 7.4 days per phase.
+This does not map on well to any solar equivalent. In fact, a 12 month lunar year
+is only 354.36708 days, which is a far cry from a solar year. This is why many
+lunar calendars are, in fact, lunisolar. Various strategies
+for dealing with this time defect are either to add an extra months occasionally
+or to have non-month days between years.
+
+As physically impossible as it is to perfectly sync the sun and the moon,
+it is an even worse idea to implement a full Gregorian calendar. Like with
+time zones, the opportunities for failure are nearly endless. Furthermore,
+going with a real calendar breaks with the current notion that all time steps
+have an equal :math:`\delta t`.
+
+Specification
+==============================
+This CEP defines the default time step as the average length of a Julian
+month as measured in seconds, the proper unit for time:
+
+.. math::
+
+ \delta t = \frac{365.25 [d]}{12} = \frac{31557600 [s]}{12} = 2629800 [s/m]
+
+Furthermore, this actual time step should be able to be set by the user in the
+input file. The following changes to the master schema(s) are thus needed:
+
+.. code-block:: xml
+
+
+
+
+ . . .
+
+
+
+
+
+
+
+
+
+This information would be added to the context with the following members:
+
+.. code-block:: c++
+
+ class Context {
+ public:
+ // Returns the time step in seconds
+ inline uint64_t dt() { return dt_; };
+
+ // Returns the time step in [units], given as string
+ uint64_t dt(std::string units);
+
+ // Returns the time step in [units], given as TimeUnits enum
+ uint64_t dt(TimeUnits units);
+
+ private:
+ uint64_t dt_; // the length of the time step, in seconds.
+ }
+
+All archetypes and toolkit code should then ask the context what the time step
+size is whenever they actually need the current. As per `CEP20 `_,
+the time step length is fixed for the entire simulation and may not change.
+
+Furthermore, ``TimeUnits`` will be a fixed set of time increments that will
+not be able to be set by the users. An initial set of time units are:
+s, min, hr, d, month (as defined above), y, ky, My, Gy.
+
+Best Practices
+--------------
+Along with this CEP comes the best practice that
+archetypes which model time-dependent behavior should not
+assume a nominal time step. Archetypes should always get the time step length
+from the context. Since the time step is fixed, this need only be done once
+per prototype.
+
+From here, we also define two broad archetype classifications: those which care
+about actual real physical time and those which simply function per
+simulation time step.
+
+When an archetype uses real time, due to physics calculations or other needs,
+the archetype should now check that :math:`\delta t` is within a valid range
+that they define. This is because users will now be able to set the time step.
+This validation check maybe performed in any of the archetype's member functions.
+If a static range is known ahead of time, then this check is most appropriate in
+the constructor. If the time step length is outside of the valid range of the agent,
+then an exception should be raised. We recommend something along the lines of:
+
+.. code-block:: c++
+
+ if (context().dt() > max_dt)
+ throw cyclus::ValidationError("time step exceeds valid range!");
+
+On the other hand, if the archtype only models per time step behavior, then
+state variables should be expressible by default in terms of number of time steps,
+not in terms of seconds. If other time values are desirable, the user
+should explicitly give the time units. For any time-based variable, the default
+associated units should be provided by the metadata.
+
+Implementation
+==============
+The implementation of this code should be fairly straight forward. Unlike time
+itself, there is no funny business here.
+
+Document History
+================
+This document is released under the CC-BY 4.0 license.
+
diff --git a/_sources/cep/cep24.rst.txt b/_sources/cep/cep24.rst.txt
new file mode 100755
index 000000000..b2cc25aa6
--- /dev/null
+++ b/_sources/cep/cep24.rst.txt
@@ -0,0 +1,67 @@
+CEP 24 - Default Preferences
+*****************************************************
+
+:CEP: 24
+:Title: Default Preferences
+:Last-Modified: 2015-07-29
+:Author: Matthew Gidden
+:Status: Accepted
+:Type: Standards Track
+:Created: 2015-04-09
+
+
+Abstract
+========
+
+This CEP describes agreed-upon default preference values within the DRE.
+
+Motivation
+==========
+
+The current default preference is zero. Preferences of zero are problematic
+because they are invariant under multiplication and do not behave well under
+monotonic transformations (e.g., the inversion operator).
+
+Rationale
+=========
+
+The default preference will change from zero to unity. Default preferences will
+then be stable under both additive and multiplicative operations. Currently,
+negative preferences denote potential trades to be removed from resource
+exchanges before the solution phase. This will change from negative to
+non-positive preferences (see `Backwards Compatibility`_).
+
+Specification \& Implementation
+===============================
+
+See [1]_ and [2]_ for the implementation of unity default preferences.
+
+Backwards Compatibility
+=======================
+
+API backwards compatability is not broken with this CEP. However, trade logic
+backwards compatability will be broken if any previous model was dependent on a
+default preference value of `0`. Developers will have to update models given the
+new default preference value of `1`.
+
+For a simulator, however, this is still backwards incompatability -- simulation
+behavior for valid input files can (and will) change if explicit use of 0-valued
+preferences is engaged. Accordingly, to make this deprecation loud and explicit,
+an error will be thrown for the remainder of this minor release cycle (currently
+release 1.3.1 to 1.3.2). At the end of this cycle, arcs with 0-valued
+preferences will be "quietly" removed (i.e., as quietly as negative-preference
+arcs are currently). An issue will be made to perform this update.
+
+For updating archetype code, look primarily to the `AddRequest` and
+`Adjust*Pref` APIs.
+
+Document History
+================
+
+This document is released under the CC-BY 3.0 license.
+
+References and Footnotes
+========================
+
+.. [1] https://github.com/cyclus/cyclus/pull/1121
+.. [2] https://github.com/cyclus/cycamore/pull/381
diff --git a/_sources/cep/cep25.rst.txt b/_sources/cep/cep25.rst.txt
new file mode 100755
index 000000000..13b82fbdc
--- /dev/null
+++ b/_sources/cep/cep25.rst.txt
@@ -0,0 +1,102 @@
+CEP 25 - Preference Adjustment Process
+*****************************************************
+
+:CEP: 25
+:Title: Preference Adjustment Process
+:Last-Modified: 2015-08-25
+:Author: Matthew Gidden
+:Status: Accepted
+:Type: Standards Track
+:Created: 2015-07-07
+
+
+Abstract
+========
+
+This CEP describes the process of adjusting preferences in the DRE, e.g., with
+regard to implementing international trade instruments. It generalizes
+methodology of the preference adjustment phase.
+
+Motivation
+==========
+
+The current preference adjustment phase only includes the requesting facility
+and its managers (i.e. institution and region). Only allowing requesting
+managers to adjust preferences is problematic because it prohibits, for
+example, the complete modeling of intra-regional instruments such as tariffs.
+
+Specification \& Implementation
+===============================
+
+In order for managers of bidding regions to apply tariffs, or any other
+inter-entity instruments, they must be involved in preference
+adjustment. Previously, only managers of the requesting entities were allowed to
+affect preference values. This CEP will allow bidders and managers of bidding
+entities to affect preferences as well.
+
+There is not a clear reason or motivation as-of-yet to allow requesting managers
+to adjust preferences before bidding managers (and vice-versa). Accordingly, a
+general approach is taken for the preference *adjustment ordering*
+methodology. The entities involved in any trade preference adjustment are the
+two traders, and each of their associated managers. In a common Cyclus use case,
+this involves two ``Trader`` entities whose immediate "manager" is the
+``Facility`` entity of whom they are a member. Further, each ``Facility`` is
+managed by an ``Institution`` which is managed by a ``Region``.
+
+For the purpose of this CEP, a default ordering is defined: the requester and
+its managers are queried in order followed by the managers of the bidder. The
+bidder is not involved, because it is assumed that suppliers are motivated to
+reduce inventory. Bidder's managers are involved in order to generally model
+international instruments, such as tariffs. As different orderings are desired
+in the future, they may be implemented. The only requirement of a given ordering
+implementation is that it must maintain a preference adjustment history. That
+is, a data structure comprising and ordered list of entity-preference pairs that
+records the history of the adjusted preference for each trade.
+
+An important caveat includes the adjustment of preferences to a "no trade"
+value. Archetype developers are allowed to denote a trade as "impossible" by
+setting the preference value to a non-positive number. If at any point during
+the adjustment phase such a state is found, the phase is considered over for
+that trade and the trade is removed from the exchange. Consider the following
+situation: a trade is initially set to the default preference of unity; the
+first manager queried has a rule that negates the trade (sending its value to
+negative unity) while the next manager queried has a rule that increases all
+trades by a magnitude of two units. Rather than setting the final trade
+preference at unity based on input from both managers, the trade is removed from
+the exchange after its preference is adjusted by the first manager.
+
+The determination of the final preference value given the adjustment history,
+i.e., *the preference aggregation rule*, is also tuneable. One could imagine
+many different negotiation models, or negotiation rules, by which to determine a
+final value given a collection of entities' input. Again, this CEP provides a
+default rule, which is to take the final preference value, unperturbed, through
+the adjustment process. However, any rule that takes as an argument the
+adjustment history data structure and provides a final preference value is valid
+in this methodology. Of course, different rules may be implemented as they are
+required.
+
+This CEP does not explicitly provide an user-facing interface for adjusting
+either the adjustment ordering or aggregation. The provided methodology is a
+novel first step in fuel cycle simulation, and it is not at all clear that full
+user control over the adjustment process is necessary for the current set of
+modeled scenarios. If that capability is identified as critical path in the
+future, a user-facing interface can be implemented that allows adjustment of
+both the preference adjustment ordering and preference aggregation
+determination.
+
+See [1]_ for implementation of Agent-based preference adjustment.
+
+Backwards Compatibility
+=======================
+
+No backwards incompatibilities are introduced with this CEP.
+
+Document History
+================
+
+This document is released under the CC-BY 3.0 license.
+
+References and Footnotes
+========================
+
+.. [1] https://github.com/cyclus/cyclus/pull/1122
diff --git a/_sources/cep/cep26.rst.txt b/_sources/cep/cep26.rst.txt
new file mode 100755
index 000000000..1b44c3d6e
--- /dev/null
+++ b/_sources/cep/cep26.rst.txt
@@ -0,0 +1,190 @@
+CEP 26 - Generalize the DRE to Optimize Multiple Metrics
+********************************************************
+
+:CEP: 26
+:Title: Generalize the DRE to Optimize Multiple Metrics
+:Last-Modified: 2016-10-19
+:Author: Robert Flanagan \& Anthony Scopatz
+:Status: Draft
+:Type: Standards Track
+:Created: 2016-10-19
+
+
+Abstract
+========
+This CEP proposes to enable broader user customization of the DRE by opening
+up the Cyclus resource exchange interface to many metrics of interest. The DRE will
+no longer solely
+attempt to minimize quantity divided by preference, but rather be capable of
+minimizng or maximizing many metrics jointly. Different DRE solvers may
+choose which metrics to include. Along with this new interface will come a
+new implementation of the Greedy solver that makes use of all metrics.
+
+Motivation
+==========
+There are several fundamental issues with preferences as an optimization variable:
+
+1. Global optimization of Request-Bid arcs is not possible because the meaning and
+ scale of preferences are independent between requesters.
+2. There is no standard conversion from preference to cost, only the convention that
+ cost = quantity / preference.
+3. The limits of preference are :math:`(0, \infty)`, which implies that there is
+ no possible way to reject a bid once it has been made and there is no way to
+ represent negative costs (subsidies).
+4. The preference adjustment phase cannot guarantee validity of adjustments because
+ there is not a uniform preference scaling between requesters.
+5. Preferences do not support a consistent way for other metrics to be resolved into
+ request preferences. Thus to-date, other metrics have been avoided and discouraged.
+
+The failure of preferences as an optimization variable can be shown with the following
+simple system. Consider an exchange graph with two requesters and one bidder for a single
+commodity. The requesters both have infinite capacity, while the bidder may only offer
+a constrained quantity. The bidder may trade 2 units of qualitatively unique resources
+(of the same commodity, e.g. UOX and MOX). Requester 1 has an equal preference (say 5)
+for both resources, even though they are qualitatively different. Requester 2, on the
+other hand, has a high preference (say 15) for one resource and a low preference (say 1)
+for the other resource. Currently in Cyclus, these preferences would be assigned during
+the preference adjustment phase.
+
+The DRE, and the greedy solver in particular, would give both units of the resource to
+Requester 2. This is because the greedy solver sorts by requester, giving precedence to the
+requester with the highest average preference. Requester 1's average preference is 5
+and Requester 2's average preference is 8. Since, both requesters have infinite (or
+greater than or equal to 2 units) of capacity, all bids go to Requester 2.
+
+This situation remains true even as the low preference of Requester 2 tends towards zero
+(i.e. 1e-100). There is no way for Requester 2 to reject a bid and thus Requester 1 will
+never receive a resource. This can be seen in Figure 1 below.
+
+.. figure:: cep-0026-1.png
+ :align: center
+ :scale: 50 %
+
+ Figure 1: Simple transaction with weighted preferences.
+
+The above situation can arise in real world fuel cycle scenarios. One example is the
+case of partitioning used fuel storage based on decay heat into wet and dry storage.
+A used fuel commodity may have instances that are either high or low heat, and storage
+requesters must be able to reject material whose decay heats are above its thermal limit.
+An additional use case is a system where a reactor may choose to be agnostic to UOX or MOX
+in their core while other reactors in the system reject MOX in favor of a strong preference
+for UOX. Cyclus would currently give MOX to the reactor that effectively rejected it anyway,
+leaving the agnostic reactor unfueled.
+
+As a concept, the current formulation of preferences seems poorly defined and therefore
+difficult to explain or intuit. As shown above, this can lead to incorrect and unanticipated
+results. From here, an attempt can either be made to patch the preference system with
+further constraints or it can be replaced with a more customizable, and thus more intuitive and
+directly relevant, concept.
+
+We propose a system that will allow the computation of many potential metrics, will sort
+all of the arcs by minimizing or maximizing each each metric in order of a user given
+precedence, and then will finally perform a single greedy solve on the sorted arcs.
+
+The set of standard available metrics will include the quantity, preference, and
+unit cost. The benefit of providing the unit costs is that they are directly
+and linearly comparable to one another. Moreover they more commonly used to make
+quantitative comparisons than preferences.
+Additionally, costs provide a mechanism for resolving
+request objectives (price limit or maximum cost) and bid objectives (offer price).
+If an offer price is less than or equal to the request price limit, the request-bid
+can be created. Otherwise the request-bid arc will be rejected.
+
+
+Specification \& Implementation
+===============================
+To accomplish the methodology proposed here will require changes to the API within
+the dynamic resource exchange and the cyclus core code. At a minimum,
+
+1. Bids will need to be able to hold a unit cost. The API will need to support
+ developers accessing and setting this cost.
+2. Update Requests to contain a max-unit-cost, as well as a preference.
+3. The current greedy solver will need to be updated or replaced to accomodate the
+ change from preference to a multivariate solver.
+4. Updating all of the existing archetypes within the Cyclus core and Cycamore to
+ support this change.
+
+The first change will be to add the ability for bids to hold a unit cost value. The
+implementation of this may be simple as it will mirror the implementation of the
+current preference attribute of requests. Going forward the request max cost will still be
+the default cost for a request-bid arc. However, this may also be accomplished in a
+more generic fashion by allowing arbitrary metrics, of which unit cost is only one.
+
+The addition of the unit cost on the request may also be simple.
+The majority of the
+work required will be updating all ressource exchange calls currently in use
+throughout the many archetypes and Cyclus core code. Similarly, this could be
+extended to a framework for arbitrary metrics, of which unit cost is only one.
+
+Once Bids and Requests have their own unit costs, updating the default solver for
+Cyclus will be done to perform a global optimization of the entire trade system each
+time step. This can be done by collecting all of the possible Request-Bid arcs.
+These arcs will be constructed by determining if the bid in the arc has a
+unit cost associated with it. If this is the case that unit cost will be used
+for the pair. If there is no bid unit cost however, the max-unit-cost of the
+request will be used. Again, if a metric framework approach is taken, resolution will
+take place via a generic interface, of which cost is only one metric.
+
+Once the arcs have been created, the DRE solver can sort the value of all unit costs
+from smallest to largest, quantities from either lowest-to-highest (current behavior)
+or highest-to-lowest, and prefences from highest to lowest.
+This will therefore minimizing the total cost of the whole system, maximize or
+minimize flow, and maximize preference.
+
+As a motivating feature, these changes also increase the flexibility of the
+greedy solver interface. Namely, it will grant users the ability to specify
+the way the system is optimized. The above mechanism for primarily
+minimizing cost is only one method for global optimization. This proposal
+identifies three primary, orthoganal metrics that the greedy solver will jointly
+solve:
+
+* unit cost (min)
+* quantity (min)
+* preference (max)
+
+Each of these can also be used in conjuction with each other or without the
+others. For example, if two
+request-bid arcs have the same unit cost, these two arcs can be sorted by mass or
+preference. It will also be possible to choose maximization and minimization for
+each of the discussed metrics (unit cost, quantity, preference).
+
+However, the above precedence need not be static. We propose that the user be allowed
+to set the ordering of these metrics in the input file. Furthermore, they will
+also be allowed to modify the flag for whether to maximize or minimize each
+metric. Such a change would enable a much broader set of use cases to be simulated
+according to the users needs. It will also allow the exploration of a vareity
+of DRE effects based on precedence changes.
+This will be setup through the cyclus input file, but the default ordering will be
+``unit cost (min), quantity (min), preference (max)``.
+
+Furthermore, in a framework setting, additional metrics can be registered with the
+dynamic resource exchange and then used in the same way as the standard metrics
+above.
+
+This change represents a fundamental modification to the behavior of the cyclus
+simulator. As mentioned there will be several alterations to the cyclus core code.
+We will aimed to update all of these locations with the new code
+as well as documentation to help developers update their software and to support
+future developers using Cyclus.
+
+Backwards Compatibility
+=======================
+It is our goal to ensure that the Cyclus core and the Cycamore archetypes will be
+updated to be in line with this CEP. Unfortunately any third party archetypes will
+need to be updated by those parties.
+
+It is our aim that this change functions as a staging point for a Cyclus 2.0 release.
+
+The current behaviour of the greedy solver will be recoverable by the user if they set
+the sorting metrics to be ``average requester pref (max), quantity over preference (min)``.
+These two metrics will be added for backwards compatability.
+
+Document History
+================
+
+This document is released under the CC-BY 4.0 license.
+
+References and Footnotes
+========================
+
+.. .. [1] https://github.com/cyclus/cyclus/pull/1293
diff --git a/_sources/cep/cep27.rst.txt b/_sources/cep/cep27.rst.txt
new file mode 100755
index 000000000..153d4a21d
--- /dev/null
+++ b/_sources/cep/cep27.rst.txt
@@ -0,0 +1,187 @@
+CEP 27 - Toolkit Capabilities Injection into an Archetype
+*********************************************************
+
+:CEP: 27
+:Title: Agent Toolkit Capabilities
+:Last-Modified: 2019-10-28
+:Author: Baptiste Mouginot
+:Status: Active
+:Type: Standards Track
+:Created: Baptiste Mouginot
+
+
+Abstract
+========
+
+The |Cyclus| toolkit is designed to easily implement specific capabilities in
+newly developed archetypes, such as a trading policy, commodity producers, etc.
+To add characteristics to archetypes such as `Position` or `Metadata`, the
+actual implementation method is very verbose. It relies on adding the new
+specification in the archetype header, assigning it and use it in the cpp
+file. The developers have to manually ensure the consistency in variable naming and
+implementation across multiple archetypes/files.
+This CEP explains introduces the concept of snippets to simplify and maintain consistency
+in the implementation and the usage, across multiple archetypes.
+
+
+Toolkit Implementation
+======================
+
+Each |Cyclus| toolkit component will contain 3 different files:
+- 2 for the definition of the feature C++ class (``cpp`` and header) that allows
+ the use of the capabilities, and optionally to register its values in the
+ output database,
+- a snippet definition file used to simplify the implementation and ensure
+ consistency accross its integration in the different archetypes.
+
+The snippet definition file will be included in the ``private`` section of the
+archetype header as: ``#include toolkit/my_feature_snippet.cycpp.h``. (The use of the
+``cycpp.h`` has been chosen to allow syntax highlighting and inform developers
+that this is not a standard C++ header.)
+
+The snippet file, will contain the declaration of all the variables required
+to use the capabilities class:
+
+- the definition of the capability class as a member variable.
+
+- initialization of the added variables.
+
+- (optional) if the capability requires/allows variable input from users,
+ standard |Cyclus| member variable declaration with variable ``#pragma`` is
+ required. In addition, to the standard variable declaration and the
+ ``#pragma`` the method also require a ``std::vector
+ cycpp_shape_myvariable`` to be declared for each of the decorated variable
+ that are in the `toolkit/my_feature_snippet.cycpp.h` file. (``cycpp preprocessor`` is
+ not able at the time to add them automatically for included files.)
+
+
+The main purpose of this include method would be to ensure consistency across
+archetypes using the same toolkit capability requiring user input, avoiding 1
+set of input syntax per archetypes for the same capability.
+
+If the toolkit features needs the capabilities to write in the output database a
+``RecordSnippet(Agent* agent)`` method will be implemented in the toolkit class to avoid
+multiplication of implementation in the each archetype using the feature.
+
+
+Archetypes Integration
+======================
+
+When the capability is integrated in an Archetype the following implementations
+have to be done:
+
+1. Include toolkit class header in in the class header:
+ ``#include 'toolkit/my_feature.h'``.
+
+2. Include the snippet in the class header core:
+ ``#include toolkit/my_feature_snippet.cycpp,h``.
+
+3. (optional) In the ``Archetype::EnterNotify()``, initialise the toolkit class member
+ variables with variables.
+
+4. (optional) If required, call the ``RecordSnippet()`` method when necessary during the
+ Archetype operation.
+
+
+Class member vs Inheritance
+===========================
+
+With inheritance of the capability class, one will need to also modify the
+archetype class declaration in addition to simply including the snippet at the
+right place.
+This may also lead to confusion, as one can believe that the user input value
+for variable are passed in the constructor of the class and might lead the
+develop to skip the assignation of the value in the inherited class in the
+``EnterNotify``...
+
+Otherwise behavior would be very similar.
+
+Example:
+========
+
+
+Without Inheritance:
+--------------------
+``toolkit/my_feature_snippet.cycpp.h``:
+.. highlight:: c
+ cyclus::toolkit::Position coordinates(0,0);
+
+ #pragma cyclus var { \
+ "default": 0.0, \
+ "uilabel": "Geographical latitude in degrees as a double", \
+ "doc": "Latitude of the agent's geographical position. The value should " \
+ "be expressed in degrees as a double." }
+ double latitude = 0;
+ // required for compilation but not added by the cycpp preprocessor...
+ std::vector cycpp_shape_latitude;
+
+ #pragma cyclus var { \
+ "default": 0.0, \
+ "uilabel": "Geographical longitude in degrees as a double", \
+ "doc": "Longitude of the agent's geographical position. The value should" \
+ "be expressed in degrees as a double." }
+ double longitude = 0;
+ // required for compilation but not added by the cycpp preprocessor...
+ std::vector cycpp_shape_longitude;
+
+``my_archetype_example.h``:
+.. highlight:: c
+ #include 'toolkit/Position.h'
+
+ class fun_archetype : public cyclus::facility{
+ public:
+ [...]
+ private:
+ [...]
+ #include "toolkit/my_feature_snippet.cycpp.h"
+ }
+
+``my_archetype_example.cpp``:
+.. highlight:: c
+ void fun_archetype::EnterNotify() {
+ coordinates.set_position(latitude, longitude);
+ coordinates.RecordPosition(this);
+ [...]
+ }
+
+With Inheritance:
+-----------------
+``toolkit/my_feature_snippet.cycpp.h``:
+.. highlight:: c
+ #pragma cyclus var { \
+ "default": 0.0, \
+ "uilabel": "Geographical latitude in degrees as a double", \
+ "doc": "Latitude of the agent's geographical position. The value should " \
+ "be expressed in degrees as a double." }
+ double latitude = 0;
+ // required for compilation but not added by the cycpp preprocessor...
+ std::vector cycpp_shape_latitude;
+
+ #pragma cyclus var { \
+ "default": 0.0, \
+ "uilabel": "Geographical longitude in degrees as a double", \
+ "doc": "Longitude of the agent's geographical position. The value should" \
+ "be expressed in degrees as a double." }
+ double longitude = 0;
+ // required for compilation but not added by the cycpp preprocessor...
+ std::vector cycpp_shape_longitude;
+
+``my_archetype_example.h``:
+.. highlight:: c
+ #include 'toolkit/Position.h'
+
+ class fun_archetype : public cyclus::facility, public Position {
+ public:
+ [...]
+ private:
+ [...]
+ #include "toolkit/my_feature_snippet.cycpp.h"
+ }
+
+``my_archetype_example.cpp``:
+.. highlight:: c
+ void fun_archetype::EnterNotify() {
+ this.set_position(latitude, longitude);
+ this.RecordPosition(this);
+ [...]
+ }
diff --git a/_sources/cep/cep3.rst.txt b/_sources/cep/cep3.rst.txt
new file mode 100755
index 000000000..882993db2
--- /dev/null
+++ b/_sources/cep/cep3.rst.txt
@@ -0,0 +1,406 @@
+CEP 3 - |Cyclus| Release Procedure
+********************************************************
+
+:CEP: 3
+:Title: |Cyclus| Release Procedure
+:Last-Modified: 2017-11-06
+:Author: Anthony Scopatz and Matthew Gidden and Baptiste Mouginot
+:Status: Accepted
+:Type: Process
+:Created: 2013-10-25
+
+Abstract
+========
+The purpose of this document is to act as a guideline and checklist for how
+to release the |cyclus| core code base and the supported projects in the ecosystem.
+
+The |Cyclus| Ecosystem
+======================
+The very first thing to do when preparing for an upcoming release is to elect
+a release manager. This person has the special responsibility of making sure
+all of the following tasks are implemented. Therefore, their judgment for the
+placement of issues and code stability must be adhered to.
+
+The |cyclus| ecosystem has a few projects which are all released together.
+(This may change in the future a development diverges and the core becomes more
+stable.) The projects that are under the release manager's purview are:
+
+* `Cyclus`_
+* `Cycamore`_
+* `Cymetric`_
+
+The projects which are not yet under the release managers purview are:
+
+* `Rickshaw`_
+* `CyclusJS`_
+
+
+.. note::
+
+ The following full release process only applies to MAJOR and MINOR
+ release number changes. MICRO or PATCH releases may be performed
+ with a version bump and a git tag alone. This is to enable fast turn
+ arounds for bug fixes and binary package creation (ie deb or conda).
+ Therefore versions with a non-zero MICRO number should be considered
+ relatively unstable.
+
+
+Release Candidates (Tags & Branches)
+====================================
+At the beginning of a release, a special branch for *each* project should be
+made off of ``master`` named ``vX.X.X-release``. Note the *v* at the beginning. Each
+project should have the initial version of of it's release branch *tagged* as
+``X.X.X-rc1``, the first release candidate.
+
+.. note::
+
+ To distingush them, branch names have a ``v`` prefix (``vX.X.X-release``)
+ while tag names lack this prefix (``X.X.X-rcX``).
+
+Release candidates serve as an official proving ground for the release. Upon
+creation, an announcement should be made to the developer's list, and users of
+the project should be encouraged to test them out in order to bugs/other issues.
+
+Any required changes must be pull requested from a topical branch into the
+*release* branch. After this has been accepted, the topical branch must be
+merged with ``master`` as well. The release branch is there so that development
+can continue on the ``master`` branch while the release candidates (rc) are out
+and under review. This is because otherwise any new developments would have to
+wait until post-release to be merged into ``master`` to prevent them from
+accidentally getting released early.
+
+Everything that is in the release branch must also be part of ``master``.
+Graphically,
+
+.. figure:: cep-0003-1.svg
+ :align: center
+
+ **Figure 1:** Branch hierarchy under release.
+
+.. note::
+
+ Any commits merged into the release branch must *also* be merged into
+ ``master``. It is common practice for the release manager to request the
+ reviewer pull requests to merge the topical branch into ``master``
+ as well. However, it is the ultimate release manager's responsibility to
+ make sure ``master`` is kept up to date with the ``release`` branch.
+
+If changes are made to the release branch, a new candidate must be issued after
+*2 - 5 days*. Every time a new release candidate comes out the ``vX.X.X-release``
+must be tagged with the name ``X.X.X-rcX``. A developer's list annoucement must
+accompany any new candidate.
+
+The release branch must be quiet and untouched for *2 - 5 days prior* to the
+full release. When the full and final release happens, the ``vX.X.X-release``
+branch is deleted. All commits in the ``vX.X.X-release`` branch must have also
+been merged into the ``master`` branch as they were accepted.
+
+Project Checklist
+=================
+
+.. note::
+
+ Utility scripts for this process can be found in the `release`_ repository
+
+Releasing a |cyclus| project is comprised of the following operations. Each
+operation should be enacted in order.
+
+Release Candidate Process
+-------------------------
+
+#. Review **ALL** issues and pull requests, reassigning or closing them as needed.
+
+#. Ensure that all issues/PRs in this release's milestone have been closed.
+ Moving them to the next release's milestone is a perfectly valid strategy for
+ completing this milestone.
+
+#. Initiate the release candidate process (see above)
+
+#. Review the current state of documentation and make approriate updates.
+
+#. Finish the release candidate process
+
+ - make sure all commits in the ``release`` branch also are in ``master``
+
+Release Process
+---------------
+
+#. Make sure every local |cyclus| project repository is up to date with its
+ ``master``, and ``vX.X.X-release`` branches on ``upstream``.
+
+#. Bump the version in ``cyclus/src/version.h.in`` and ``cyclus/cyclus/__init__.py``,
+ ``cycamore/src/cycamore_version.h.in``, and
+ ``cymetric/setup.py``; commit the changes
+
+#. Perform maintenance tasks for all projects. The maintenance depends on `PyNE
+ `_ and Doxygen. Maintenance files can be
+ found `here
+ `_.
+
+ - they are described in detail below, *but* the ``maintenance.sh`` utility
+ in ``release/utils`` will do this automatically for you
+
+ - make sure to have your ``rs.cred`` file (see ``maintenance.sh``'s help)
+
+ .. code-block:: bash
+
+ $ cd /path/to/release/utils
+ $ export CYCLUS_DIR=/path/to/cyclus
+ $ export CYCAMORE_DIR=/path/to/cycamore
+ $ ./maintenance.sh -r -v X.X.X # X.X.X is *this* version
+
+ .. note::
+
+ If maintenance script fails because of an ABI failure that is caused by
+ a compiler update (or other similar change caused by reasons other
+ than code changes), you might want to accept them and procceed with the
+ release with those. To do so you need to generate the new symbols and
+ commit them:
+
+ #. First make sure those changes can be ignored by emailing for
+ discussion/approval the dev-list
+
+ #. if the dev-list agrees to those changes, update the symbols and
+ commit the new one:
+
+ .. code-block:: bash
+
+ $ cd $CYCLUS_DIR/release
+ $ ./smbchk.py --update -t X.X.X # X.X.X is *this* version
+ $ git add symbols.json
+ $ git commit -m "Describe here all the change on the ABI"
+
+
+#. Commit all changes for all projects.
+
+ .. code-block:: bash
+
+ $ cd /path/to/project
+ $ git checkout vX.X.X-release
+ $ git commit -am "final release commit after maintenence"
+
+#. Update all master branches.
+
+ .. code-block:: bash
+
+ $ cd /path/to/project
+ $ git checkout master
+ $ git merge --no-ff vX.X.X-release
+ $ git push upstream master
+
+#. *Locally* tag the repository for *each* of the projects.
+
+ .. code-block:: bash
+
+ $ cd /path/to/project
+ $ git checkout master
+ $ git merge --no-ff vX.X.X-release
+ $ git tag -a -m "Cyclus project release X.X.X, see http://fuelcycle.org/previous/vX.X.X.html for release notes" X.X.X
+
+#. Draft release notes.
+
+ - the ``make_release_notes.sh`` utility in ``release/utils`` will help
+ provide a template
+
+ .. code-block:: bash
+
+ $ cd /path/to/release/utils
+ $ export CYCLUS_DIR=/path/to/cyclus
+ $ export CYCAMORE_DIR=/path/to/cycamore
+ $ export CYMETRIC_DIR=/path/to/cymetric
+ $ ./make_release_notes.sh W.W.W X.X.X # W.W.W is the previous version, X.X.X is *this* version
+
+ - add the release notes as ``cyclus.github.com/source/previous/vX.X.X.rst``
+ with appropriate updates to ``index.rst`` in that directory
+
+#. Update the API docs.
+
+ - the ``api_docs.sh`` utility in ``release/utils`` will do this
+ automatically for you
+
+ .. code-block:: bash
+
+ $ cd /path/to/release/utils
+ $ export CYCLUS_DIR=/path/to/cyclus
+ $ export CYCAMORE_DIR=/path/to/cycamore
+ $ ./api_docs.sh X.X.X # X.X.X is *this* version
+
+#. Update the ``master`` branch of all projects and clean up.
+
+ .. code-block:: bash
+
+ $ cd /path/to/project
+ $ git push upstream X.X.X master
+ $ git push upstream --delete vX.X.X-release
+
+#. Manually visit the github.com page for each project and draft/publish a new release.
+
+ - See instructions `here
+ `_
+
+
+#. Update Conda-forge
+
+ - For each project, find the corresponding feedstock repository in the
+ conda-forge organization on github. For example, cyclus' feedstock is at
+ https://github.com/conda-forge/cyclus-feedstock
+
+ - In each project's feedstok, open up a PR which updates the
+ `recipe/meta.yaml` file with the new version number and the new SHA-256
+ value of the new version's tarball. See conda-forge documentation for more
+ or ask the feedstock maintainers for help.
+
+ - Note that each feedstock must be accepted and the package uploaded to
+ anaconda.org (automatic) prior to accepting updates for the next feedstock
+ dependency. For example, cyclus must be fully updated before cycamore.
+
+
+#. Create a DOI. See :doc:`CEP4 <./cep4>` for details.
+
+ - This can be updated one day to use the Figshare `API
+ `_
+
+#. Update website release information.
+
+ - on the front page (``source/index.rst``)
+ - DOIs (``source/cite/index.rst``)
+ - release notes (``source/previous/index.rst``), remember both the release
+ notes and the zip/tar URLs!
+ - layout template (``source/atemplates/layout.html``) of the website
+ - install from tarball instruction
+ (``source/user/install_from_tarball.rst``)
+
+
+#. Commit all changes to ``cyclus.github.com`` and ``make gh-publish``
+
+#. Send out an email to ``cyclus-dev`` and ``cyclus-users`` to announce the release!
+
+
+.. This part has been commented, as it is required for the website, but the
+ person in charge of the release might not have the proper access to update the
+ Dory worker. This should be automated when a merge is done on the master branch
+ a CI-hook should update the dory cloudlus server and relaunch the worker.
+ Moreover the cloudlus server is not directly related to Cyclus and depend on
+ the UW-Madison community but the website relies on it to host the
+ online cyclus calculation... (see
+ https://github.com/cyclus/cyclus.github.com/pull/227#pullrequestreview-21589660
+ discussion for more details.)
+
+.. #. Update ``Dory``'s ``Cyclus``/``Cycamore`` version and relaunch ``Dory`` worker.
+ To do this you need a acces to the ``Dory`` server (if you don't please
+ contact an administrator), the ``go`` toolchain as well as ``cde`` installed
+ on your computer. Also, the release version of ``Cyclus`` and ``Cycamore``
+ have to be compiled on you system and both executable and lib have to be on
+ the default paths. Please refer to the :doc:`source installation
+ <../user/install_from_git>` if you need.
+.. .. code-block:: bash
+ $ git clone https://github.com/rwcarlsen/cloudlus.git
+ $ cd cloudlus
+ $ go install ./cmd/cloudlus
+ $ cd misc/fuelcycle.org
+ $ make
+ $ ssh dory.fuelcycle.org 'mv cyc-cde.tar.gz cyc-cde.tar.gz_bkp'
+ $ scp cyc-cde.tar.gz dory:fuelcycle.org:./
+ $ ssh dory.fuelcycle.org
+ $ ps -fe | grep cloudlus | grep work | grep ':80' | cut -d" " -f6 | xargs kill -9
+ $ rm -rf worker-*
+ $ ./launch.sh 2
+
+
+
+Maintainence Tasks
+==================
+
+.. note::
+
+ There is now the ``maintenence.sh`` utility in ``release/utils`` that
+ will automate this for you. The section remains here for posterity.
+
+Each project may have associate maintenance tasks which may need to be performed
+at least as often as every micro release.
+
+|Cyclus|
+--------
+
+**Update PyNE:** PyNE source code is included and shipped as part of |cyclus|. As pyne
+evolves, we'll want to have our version evolve as well. Here are the steps to do so.
+These assume that in your HOME dir there are both the pyne and |cyclus| repos. Remember
+to check in the changes afterwards.
+
+.. code-block:: bash
+
+ $ cd ~/pyne
+ $ ./amalgamate.py -s pyne.cc -i pyne.h
+ $ cp pyne.* ~/cyclus/src
+
+**Update Nuclear Data:** PyNE also provides a nuclear data library generator which we use for
+our source data. Occassionally, this needs to be updated as updates to pyne itself come out.
+The command for generating |cyclus| specific nuclear data is as follows:
+
+.. code-block:: bash
+
+ $ cd ~/pyne
+ $ nuc_data_make -o cyclus_nuc_data.h5 \
+ -m atomic_mass,scattering_lengths,decay,simple_xs,materials,eaf,wimsd_fpy,nds_fpy
+
+Once the file is generated it must be put onto rackspace.
+
+**Update Gtest:** We include a copy of the fused Gtest source code within our
+source tree located in the ``tests/GoogleTest`` directory. To keep up with
+Gtest's natural evolution cycle, please download the latest release of Google Tests
+and follow `the fused source directions here`_. If we go too long without doing this,
+it could be very painful to update.
+
+**Verify & Update API Stability:** Since |Cyclus| v1.0 we promise API
+stability. Luckily, we have a tool for keeping track of this mostly
+automatically. In order to check this correctly, you must have a **RELEASE**
+build of Cyclus compiled/installed. Every release please run the following
+command to verify that the release branch is stable:
+
+.. code-block:: bash
+
+ $ cd cyclus/release
+ $ ./smbchk.py --update -t HEAD --no-save --check
+
+If |cyclus| only has API additions, it is considered stable and the command will
+tell you so. If |cyclus| also has API deletions, then |cyclus| is considered
+unstable and a diff of the symbols will be printed.
+**You cannot release |cyclus| if it is unstable!** Please post the diff to
+either the mailing list or the issue tracker and work to resolve the removed
+symbols until it this command declares that |cyclus| is stable. It is
+probably best to do this prior to any release candidates if possible.
+
+Once stable and there are no more code changes to be made, add the symbols
+in this release to the database with the following command (again - make sure
+you are working on a RELEASE build of Cyclus):
+
+.. code-block:: bash
+
+ $ cd cyclus/release
+ $ ./smbchk.py --update -t X.X.X
+
+where ``X.X.X`` is the version tag. This should alter the ``symbols.json``
+file. Commit this and add it to the repo.
+
+Cycamore
+--------
+
+No maintenence required.
+
+Cymetric
+--------
+
+No maintenance required.
+
+Document History
+================
+
+This document is released under the CC-BY 3.0 license.
+
+.. _Cyclus: https://github.com/cyclus/cyclus
+.. _Cycamore: https://github.com/cyclus/cycamore
+.. _Cymetric: https://github.com/cyclus/cymetric
+.. _Rickshaw: https://github.com/ergs/rickshaw
+.. _CyclusJS: https://github.com/cyclus/cyclist2
+.. _release: https://github.com/cyclus/release
+.. _the fused source directions here: https://code.google.com/p/googletest/wiki/V1_6_AdvancedGuide#Fusing_Google_Test_Source_Files
diff --git a/_sources/cep/cep4.rst.txt b/_sources/cep/cep4.rst.txt
new file mode 100755
index 000000000..e2abf4dec
--- /dev/null
+++ b/_sources/cep/cep4.rst.txt
@@ -0,0 +1,127 @@
+CEP 4 - Attribution of Code Products in the |cyclus| Ecosystem
+**************************************************************
+
+:CEP: 4
+:Title: Attribution of Code Products in the |cyclus| Ecosystem
+:Last-Modified: 2014-06-27
+:Author: Kathryn Huff
+:Status: Accepted
+:Type: Process
+:Created: 2014-06-01
+
+Abstract
+========
+
+The purpose of this CEP is to define the method for attribution of code
+products within the |cyclus| ecosystem. In particular, along with any software
+release a unique, publicly citable object should be created which
+appropriately attributes its authors. This CEP therefore introduces a method
+for creating a `Digital Object Identifier`_ for each code release, with alphabetically ordered
+authorship, and encapsulating all of and only the authors responsible for that
+effort.
+
+Concerns
+========
+
+The concerns driving this CEP are threefold :
+
+* **Unambiguous Citation**
+* **Author Identification**
+* **Contribution Equality**
+
+First, public and unambiguous citation of scientific and code products like
+those in the |cyclus| ecosystem is of paramount importance to scientific
+reproducibility. Due to the algorithmic and authorship differences between
+versions of the codebase, a unique identifier is required for accurate citation
+of that version. Therefore, to enable reproducibility in the use of the
+|cyclus| ecosystem, each version must be unambiguously citable with a distinct
+DOI.
+
+Second, to provide an appropriately transparent public link between the
+identities and efforts of the authors, the true names of the authors should be
+listed. As with other forms of scientific publication, public attribution of
+authorship is of importance for appropriately enabling direct praise and blame
+related to that scientific work :cite:`shamoo_responsible_2003`. This feature
+of scientific publication holds the scientist accountable for their work and
+enables them to establish a record of their scientific pursuits. It is for this
+reason that clear attribution of true names is superior to other options, such
+as using a pseudonym for the group (Cyclus developers).
+
+Finally, since ordering of authorship has conventional meaning and value in the
+scientific community, the ordering of authorship for code products in the
+|cyclus| ecosystem should similarly reflect the community consensus concerning
+relative contribution importance. Specifically, due to the inherently
+apples-and-oranges nature of code contributions, no metric for code importance
+was deemed suitable for comparing contribution importance within the |cyclus|
+ecosystem. That is, a lack of hierarchy was preferred. Thus, alphabetical
+ordering, which is perceived by convention as non-hierarchical, shall be used.
+
+What releases should have a DOI?
+------------------------------------
+
+Cyclus versions are indicated by numbers of the form : vMAJ.MIN.MICRO-patch. At the
+very least, major, and minor versions should have associated DOIs. For micro
+versions, which do not undergo a release process, a DOI is optional.
+
+How should a DOI be created?
+------------------------------------
+
+Creation of a DOI should be conducted or delegated by the code release
+manager. Accordingly, :doc:`CEP3<./cep3>` has been updated to reflect this responsibility.
+That person is responsible for identifying the code contributors since the last
+release at that level.
+
+Among online services that have the capability of creating a DOI for a code
+product, `figshare`_ is preferred. It was initially chosen due to both its
+nascent adoption by the scientific computing community and its native
+ability to capture github-hosted codebases.
+
+Once the DOI is created, it should be recorded on the cyclus website and should
+be shared with the development team.
+
+
+Who is an author?
+------------------------------------
+
+An author has contributed code contributing to the release.
+For a **major release**, all authors that contributed code between version
+m.0.0 and version n.0.0 should be listed in the n.0.0 code release DOI.
+
+In the same way, for a **minor release**, all authors that contributed code between 1.m.0 and
+1.n.0 should be listed in the 1.n.0 code release DOI. Note that additional authors
+should not be included if they have not contributed to this minor release. For
+example, if someone has contributed to version 1.0.0, but not since then, that
+person should not be listed as an author on the DOI for version 1.1.0.
+
+How are authors listed?
+------------------------------------
+
+All authors should be listed in (english) alphabetical order. This serves both
+to (1) convey a lack of hierarchy in code contribution importance and to (2) reflect the
+true identities of the authors.
+
+Summary
+=======
+
+In the absence of a rigid convention in the scientific computing community concerning
+contribuion metrics, author attribution, and code citation, this CEP proposes
+that uniquely and publicly citable DOIs as well as comprehensive but flat
+authorship reflect the needs and desires of the |cyclus| development community.
+Finally, this document provides resources for implementing the requirements
+it introduces.
+
+Document History
+================
+This document is released under the CC-BY 3.0 license.
+
+References and Footnotes
+========================
+
+.. _figshare: http://figshare.com/
+.. _Digital Object Identifier: http://en.wikipedia.org/wiki/Digital_object_identifier
+
+.. rubric:: References
+
+.. bibliography:: cep-0004-1.bib
+ :cited:
+
diff --git a/_sources/cep/cep5.rst.txt b/_sources/cep/cep5.rst.txt
new file mode 100755
index 000000000..3f16dfc9e
--- /dev/null
+++ b/_sources/cep/cep5.rst.txt
@@ -0,0 +1,54 @@
+CEP 5 - Archetype Development Best Practices
+**************************************************************
+
+:CEP: 5
+:Title: Archetype Development Best Practices
+:Last-Modified: 2014-06-29
+:Author: Matthew Gidden
+:Status: Deferred
+:Type: Process
+:Created: 2014-06-29
+
+.. note::
+
+ This CEP is looking for a champion.
+
+Overview
+========
+
+As the archetype ecosystem begins to develop, an initial set of archetype
+development best practices need to be identified that both achieve the aims of
+fuel cycle simulation and analysis and encourage the continued proliferation of
+the ecosystem. This set of best practices should have general consensus among
+both kernel and archetype developers, it should be documented, and the best
+practices should be used in code examples. This CEP could be a living document
+for some amount of time that is updated as additional best practices are
+identified.
+
+A primary example of such a concern is archetype interaction implementation. One
+of the aims of Cyclus as a fuel cycle simulator is to provide a plug-and-play,
+modular platform. Accordingly, there is a desire for archetypes to actually *be*
+plug-and-playable. However, in an initial use case, archetype developers found
+the easiest archetype implementation to include explicit type identification.
+
+Three interaction models have been identified:
+
+* *Black Box* - do not dynamically type check, requiring all interfaces be known
+ at compile time (note that not even Cyclus currently is completely "black box"
+ in this manner -- the institution class type checks its children to access the
+ facility's ``Decommission`` API).
+* *Grey Box* - dynamic type check can be performed only for |cyclus| and |cyclus|
+ toolkit interfaces. To date this has been implemented using toolkit mixins
+ with Cycamore agents.
+* *White Box* - dynamic type checking can be performed for any interface,
+ specifically allowing special interactions between two archetype
+ implementations.
+
+A non-deferred version of this CEP will identify these interaction models and
+provide guidance for which models the use of which are considered a best
+practice.
+
+Document History
+================
+This document is released under the CC-BY 3.0 license.
+
diff --git a/_sources/cep/cep6.rst.txt b/_sources/cep/cep6.rst.txt
new file mode 100755
index 000000000..5a17cdfe5
--- /dev/null
+++ b/_sources/cep/cep6.rst.txt
@@ -0,0 +1,109 @@
+CEP 6 - |Cyclus| Pull Request Style Guide
+**************************************************************
+
+:CEP: 6
+:Title: |Cyclus| Pull Request Style Guide
+:Last-Modified: 2015-05-08
+:Author: Matthew Gidden
+:Status: Draft
+:Type: Process
+:Created: 2015-05-04
+
+Abstract
+========
+
+There is a strong motivation for summarizing and enumerating feature additions,
+bug fixes, and other changes to the code base. Through use of an agreed-upon
+format and style, tools for aggregating and categorizing changes can be
+developed. While this strategy may be applied to issues, this CEP is related to
+pull requests (PRs) only.
+
+A canoncial class of top-level labels is proposed. The purpose of these labels
+is to broadly categorize additions to the code base. Then, a minimum style guide
+is proposed to provide a known, queryable structure to the body of each pull
+request.
+
+Labels
+=======
+
+Every PR must be assigned at least one label from the following set:
+
+- Feature - Release Notes
+- Feature
+- Bug Fix
+- Maintenance
+- Other
+
+While a PR may have any number of other descriptive labels, it is considered
+blocked if it does not have (at minimum) one of the above labels.
+
+A PR may be labeled as `Feature - Release Notes` by either the author or
+reviewer. If there is a disagreement between the two parties, deference is given
+to the party who prefers the `Feature - Release Notes` tag. A PR with this label
+is provided candidacy for inclusion in the release notes (highlighting the
+feature addition) but does not guaranteed inclusion in the release notes. The
+release manager is provided deference in making the decision of what features to
+highlight in the release notes, per `CEP 3 `_.
+
+Layout
+=======
+
+Any PR must have, at minimum, a succinct summary of its associated changes. This
+summary must be present at the top of the PR body and must be followed by a new
+line. A PR is considered blocked if it does comply with this structure.
+
+Any additional structure, while clarifying, is optional.
+
+Example
+-------
+
+The following provides an example of the raw markdown associated with an
+existing `PR `_::
+
+ Added simple buy and sell inventory policies
+
+ Detail
+ ======
+ Inventory policies were added that automate simplistic interactions with the
+ DRE. Each policy is assigned to a `ResBuf` instance and implements the `Trader`
+ interface. They can be initialized with information regarding the commodities to
+ be bought or sold as well as a maximum per-timestep throughput. Purchasing
+ inventory policies also support `(S, s)` behavior, noted in supply chain literature. [1]
+
+ [1] Zheng, Yu-Sheng. "A simple proof for optimality of (s, S) policies in
+ infinite-horizon inventory systems." Journal of Applied Probability
+ (1991): 802-810.
+
+ Related Issues
+ ==============
+ * closes #1047
+ * related to cyclus/cycamore#318
+
+Automation
+==========
+
+Using the Github `API `_ either directly or
+through a module like `github3.py
+ `_ in conjunction with a standard
+style can allow for the automation of otherwise repetitive and time consuming
+tasks. A chief use case is the generation of release notes. Specifically, if
+every PR that enables a major and minor feature can be identified and
+a summary statement extracted, then the task of writing release notes becomes
+much simpler. This proposal enables such tools to be constructed and utilized.
+
+Backwards Compatibility
+=======================
+
+Closed PRs are archival documents whereas a codebase is a living
+"document". Accordingly, while one would expect a code style guide to be
+applicable upon acceptance to the entire code base, this style guide to only be
+applicable to open PRs. Closed PR text cannot be edited such that it no longer
+complies with the document structure listed in the Layout section. Additional
+comments on closed PRs encouraged as they are needed.
+
+Document History
+================
+
+This document is released under the CC-BY 3.0 license.
+
+.. _syntax: https://help.github.com/articles/github-flavored-markdown/
\ No newline at end of file
diff --git a/_sources/cep/cep80.rst.txt b/_sources/cep/cep80.rst.txt
new file mode 100755
index 000000000..7cebba2f4
--- /dev/null
+++ b/_sources/cep/cep80.rst.txt
@@ -0,0 +1,51 @@
+CEP 80 - Cycamore Archetype API/Warning Requirements
+**************************************************************
+
+:CEP: 80
+:Title: Cycamore Archetype API/Warning Requirements
+:Last-Modified: 2015-05-21
+:Author: Matthew Gidden
+:Status: Draft
+:Type: Process
+:Created: 2015-05-21
+
+Abstract
+==========
+
+History has shown that initial designs for archetypes can be quickly found to be
+insufficient after usage by others. With timely user response, these designs can
+be updated to be more robust in a short period of time, thereby satisfying a
+broader range of use cases. This CEP proposes a standard workflow requiring
+warnings in any new archetype for at least one release cycle.
+
+Proposal
+===========
+
+Reasoning
+-----------
+
+An archetype developer can design a general archetype that satisfies her set of
+use cases. After sufficient review, valid and useful archetypes should be merged
+into Cycamore. A number of use cases have shown that small additions, however,
+can be made to otherwise useful archetypes that greatly expand their set of use
+cases. This process is healthy, should be expected, and the ecosystem sanctioned
+workflow should take account of it.
+
+Requirements
+---------------------------
+
+Any *new* archetype proposed to be merged into Cycamore *must* have an
+``ExperimentalWarning`` in its constructor and its user-facing API (i.e., input
+file format) is considered unstable. This warning and expected instability must
+remain until at least the next microrelease.
+
+Backwards Compatibility
+=======================
+
+Any archetypes in Cycamore at the present time that did not exist at the last
+microrelease must be updated to conform to this CEP.
+
+Document History
+================
+
+This document is released under the CC-BY 3.0 license.
diff --git a/_sources/cite/index.rst.txt b/_sources/cite/index.rst.txt
new file mode 100755
index 000000000..50e62994c
--- /dev/null
+++ b/_sources/cite/index.rst.txt
@@ -0,0 +1,51 @@
+|Cyclus| Publications & Meetings
+=================================
+
+.. image:: ../astatic/flying_gears.jpg
+ :align: center
+ :scale: 50
+
+|Cyclus| in the Literature
+--------------------------
+
+The following are notable publications regarding |cyclus|:
+
+.. bibliography:: pubs.bib
+ :all:
+ :list: enumerated
+ :enumtype: upperroman
+
+|Cyclus| Presentations
+-----------------------
+
+The following are presentations given about |cyclus|:
+
+* `Cyclus: Next Generation Fuel Cycle Simulator `_, presented at the Fuel Cycle Options Campaign meeting, 12/16/14, Las Vegas, NV
+* `Market-Based and System-Wide Fuel Cycle Optimization `_, presented at the Fuel Cycle Options Campaign meeting, 12/16/14, Las Vegas, NV
+
+
+
+|Cyclus| Meetings and Tutorials
+-------------------------------
+
+The |Cyclus| community will occasionally hold meetings and tutorials, with documents shared here:
+
+.. toctree::
+ :maxdepth: 1
+ :glob:
+
+ meetings/*
+ tutorials/*
+
+
+
+Citing |Cyclus|
+---------------
+
+Here are entries for citing |cyclus| and Cycamore in your publications:
+
+.. bibliography:: citecyc.bib
+ :all:
+ :list: bullet
+
+.. _here: citecyc.bib
diff --git a/_sources/cite/meetings/2014.10.23.ANL.rst.txt b/_sources/cite/meetings/2014.10.23.ANL.rst.txt
new file mode 100755
index 000000000..2dc873739
--- /dev/null
+++ b/_sources/cite/meetings/2014.10.23.ANL.rst.txt
@@ -0,0 +1,79 @@
+Review of Cyclus Code and Associated Modules/Tools Development - Argonne National Lab (10/23/14)
+================================================================================================
+
+Agenda
+------
+
++---------+------------------------------------------------------------------+------------------------+
+| 8:00 | Welcomes - Fuel Cycle Options Campaign & Cyclus Development Team | B.P. Singh (DOE) |
+| | | R. Wigeland (INL) |
+| | | T. Taiwo (ANL) |
+| | | P. Wilson (U. Wisc) |
++---------+------------------------------------------------------------------+------------------------+
+| 8:20 | Introductory Comments by DOE Technical | B. Dixon (INL) |
+| | Point of Conctact for Cyclus Related-Activities | |
++---------+------------------------------------------------------------------+------------------------+
+| 8:30 | |830_wilson|_ | P. Wilson (U. Wisc) |
++---------+------------------------------------------------------------------+------------------------+
+| 9:30 | |930_scopatz|_ | Scopatz (U. Wisc) |
++---------+------------------------------------------------------------------+------------------------+
+| 10:00 | |1000_brossard|_ | Brossard (U. Wisc) |
++---------+------------------------------------------------------------------+------------------------+
+| 10:30 | Break | |
++---------+------------------------------------------------------------------+------------------------+
+| 10:45 | Building Cyclus Scenarios with Cycic (Live Demo) | Flanagan (U. Texas) |
++---------+------------------------------------------------------------------+------------------------+
+| 11:15 | |1115_livnat|_ | Livnat (U. Utah) |
++---------+------------------------------------------------------------------+------------------------+
+| 11:45 | |1145_huff|_ | Huff (UC- Berkeley) |
++---------+------------------------------------------------------------------+------------------------+
+| 12:15 | Lunch | |
++---------+------------------------------------------------------------------+------------------------+
+| 13:30 | Insights on Fuel Cycle Simulators | Price (Consultant) |
++---------+------------------------------------------------------------------+------------------------+
+| 14:00 | |1400_schneider|_ | Schneider (U. Texas) |
++---------+------------------------------------------------------------------+------------------------+
+| 14:30 | |1430_skutnik|_ | Skutnik (U. Tennessee) |
++---------+------------------------------------------------------------------+------------------------+
+| 15:00 | Break | |
++---------+------------------------------------------------------------------+------------------------+
+| 15:15 | |1515_carlsen|_ | Carlsen (U. Wisc) |
++---------+------------------------------------------------------------------+------------------------+
+| 15:45 | |1545_scopatz|_ | Scopatz (U. Wisc) |
++---------+------------------------------------------------------------------+------------------------+
+
+.. |830_wilson| replace:: Cyclus Development: History, Strategy, Contributors, Funding, Future Developmental Needs, and Potential Users
+
+.. _830_wilson: http://dx.doi.org/10.6084/m9.figshare.1285435
+
+.. |930_scopatz| replace:: Cyclus v1.1 Status and Capabilities
+
+.. _930_scopatz: http://dx.doi.org/10.6084/m9.figshare.1289050
+
+.. |1000_brossard| replace:: Thrust 1: Stakeholder, Parameter & Metric Identification
+
+.. _1000_brossard: http://dx.doi.org/10.6084/m9.figshare.1285755
+
+.. |1115_livnat| replace:: Exploring Cyclus Results with Cyclist
+
+.. _1115_livnat: http://dx.doi.org/10.6084/m9.figshare.1291039
+
+.. |1145_huff| replace:: Module development for FCO analysis
+
+.. _1145_huff: http://dx.doi.org/10.6084/m9.figshare.1287476
+
+.. |1400_schneider| replace:: Reactor Modules for Cyclus based on Bright-lite
+
+.. _1400_schneider: http://dx.doi.org/10.6084/m9.figshare.1291036
+
+.. |1430_skutnik| replace:: Facility Modules for Cyclus based on Origen
+
+.. _1430_skutnik: http://dx.doi.org/10.6084/m9.figshare.1291144
+
+.. |1545_scopatz| replace:: A Cyclus Roadmap
+
+.. _1545_scopatz: http://dx.doi.org/10.6084/m9.figshare.1289053
+
+.. |1515_carlsen| replace:: Cyclus Optimization Strategies
+
+.. _1515_carlsen: http://dx.doi.org/10.6084/m9.figshare.1289349
diff --git a/_sources/cite/tutorials/2015-ans-archdev.rst.txt b/_sources/cite/tutorials/2015-ans-archdev.rst.txt
new file mode 100755
index 000000000..c3ca0a3c6
--- /dev/null
+++ b/_sources/cite/tutorials/2015-ans-archdev.rst.txt
@@ -0,0 +1,29 @@
+|cyclus| Archetype Developer's Tutorial at the 2015 ANS Annual Meeting
+----------------------------------------------------------------------
+
+| **Where:** `ANS Annual Meeting `_ (Lone Star A)
+| **When:** Wednesday, June 10, 1:00-4:00 PM
+| **Who:** `Matt Gidden `_ & `The Cyclus Development team `_
+| **Why:** Learn how to develop your own plugin module for the Cyclus Fuel Cycle Simulator
+
+Cyclus is an advanced and flexible fuel cycle simulator capable of modeling
+the long-term impacts of different nuclear fuel cycle options. The tutorial
+will demonstrate how developers can integrate their archetype with the
+graphical user interface for both scenario definition and output exploration
+and describe how to distribute new archetypes as part of the Cyclus
+community. Cyclus, its graphical user interfaces, and its development tools
+are all freely available for users and developers. Participants should bring a
+laptop computer for the installation of Cyclus. Participants are also advised
+to attend the :doc:`Users Tutorial<2015-ans-users>` earlier that day.
+
+All participants should
+
+- start by installing |Cyclus| via instructions on the `Readme
+