Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added documentation on PaGMO interface #266

Open
wants to merge 1 commit into
base: source
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions developerGuide/extendingOptimization/MissionLinker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions developerGuide/extendingOptimization/Missionsegmentblock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions developerGuide/extendingOptimization/basics.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
.. _optimization_basics:

Basics
======

.. _optimization-linearInterpolation:

Linear interpolation
~~~~~~~~~~~~~~~~~~~~

The interpolation used by the linking methods is linear. Assume we have two available epochs
:math:`t_0` and :math:`t_1` and the respective function values :math:`f(t_0)` and :math:`f(t_1)`.
If we want to retrieve the value of :math:`f` at :math:`t_e`, with

.. math::

t_0 < t_e < t_1

then, assuming that :math:`e = t_1 - t_0` is small enough, the value can be retrieved as following:

.. math::

f(t_e) = f(t_0) + (f(t_1) - f(t_0))(t_e - t_0)/(t_1 - t_0)

.. _optimization-dynamicPointerCast:

Dynamic pointer cast
~~~~~~~~~~~~~~~~~~~~

Let us consider the class ``DecisionVariableSettings``:

.. code-block:: cpp
:caption: :class:`Tudat/Optimization/decisionVariableSettings.h`
:name: decisionVariableSettings-h

struct DecisionVariableSettings{

DecisionVariableSettings( std::vector< boost::shared_ptr< SingleDecisionVariableSettings > >
multiDecisionVariableSettings ) : decisionVariableSettings_( multiDecisionVariableSettings )
{ }

DecisionVariableSettings( boost::shared_ptr< SingleDecisionVariableSettings >
singleDecisionVariableSettings )
{
decisionVariableSettings_.push_back( singleDecisionVariableSettings );
}

std::vector< boost::shared_ptr< SingleDecisionVariableSettings > > decisionVariableSettings_;

};

The member ``decisionVariableSettings_`` is a vector of ``boost::shared_ptr< SingleDecisionVariableSettings >``,
but any index can be as well initialized as ``boost::shared_ptr< >`` of any of the
``SingleDecisionVariableSettings`` derived classes.

For example, if the first member of the constructor parameter ``multiDecisionVariableSettings`` is of the type
``boost::shared_ptr< SingleKeplerElementDecisionVariableSettings >`` the value is accepted and stored as
``boost::shared_ptr< SingleDecisionVariableSettings >``.

``SingleKeplerElementDecisionVariableSettings`` contains methods and members that do not belong to
``SingleDecisionVariableSettings``. In order to access these methods one has to perform a **dynamic pointer cast**.

Let us stick to the example above. That means that ``decisionVariableSettings_[0]`` is stored as
``boost::shared_ptr< SingleDecisionVariableSettings >`` but contains information of ``SingleKeplerElementDecisionVariableSettings``.

This can be accertained with the flag ``SingleDecisionVariableSettings::decisionVariable_``, which in this case is set
automatically by the constructor of ``SingleKeplerElementDecisionVariableSettings`` to be:

.. code-block:: cpp

decisionVariableSettings_[0]->decisionVariable_ == single_kepler_element_decision_variable;

The dynamic cast to retrieve the information of the derived class is then performed as following:


.. code-block:: cpp

boost::shared_ptr< SingleKeplerElementDecisionVariableSettings > dynamicCastDecisionVariable =
boost::dynamic_pointer_cast< SingleKeplerElementDecisionVariableSettings >( decisionVariableSettings_[0] );


Now all the ``SingleKeplerElementDecisionVariableSettings`` are available inside ``dynamicCastDecisionVariable``.

2 changes: 2 additions & 0 deletions developerGuide/extendingOptimization/fluxDiagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions developerGuide/extendingOptimization/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.. _extendingOptimization:

Extending the optimization namespace
====================================

The goal of this page is to document how the :ref:`tudatOptimizationIndex` can be updated to support new/additional features of Tudat.

.. toctree::
:maxdepth: 2

basics
objectiveFunction
missionSegment
missionLinker
necessaryFeatures
Loading