Skip to content

Commit

Permalink
[all] codac::Vector/Function/Matrix/Ctc (using ibex)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonRohou committed Feb 10, 2021
1 parent 01822cc commit 85a651e
Show file tree
Hide file tree
Showing 52 changed files with 256 additions and 175 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ script:
- make install
#- cd python/python_package
#- /usr/bin/python3.5 setup.py develop --user
#- /usr/bin/python3.5 pycodac/tests/test_arithmetic.py
#- /usr/bin/python3.5 pyibex/tests/test_arithmetic.py
#- cd ../../

# Building the examples
Expand Down Expand Up @@ -480,7 +480,7 @@ script:
- make install
#- cd python/python_package
#- /usr/bin/python3.5 setup.py develop --user
#- /usr/bin/python3.5 pycodac/tests/test_arithmetic.py
#- /usr/bin/python3.5 pyibex/tests/test_arithmetic.py
#- cd ../../

# Building the examples
Expand Down
2 changes: 1 addition & 1 deletion doc/doc/manual/02-variables/02-var-dynamic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ Next pages will present several methods to use *tubes* that are envelopes of tra


.. rubric:: Footnotes
.. [#f1] In Codac, a ``codac::TFunction`` is the extension of IBEX's ``ibex::Function`` objects, for the dynamical case (see more `about IBEX's functions <http://www.ibex-lib.org/doc/function.html>`_).
.. [#f1] In Codac, a ``codac::TFunction`` is the extension of IBEX's ``Function`` objects, for the dynamical case (see more `about IBEX's functions <http://www.ibex-lib.org/doc/function.html>`_).
.. admonition:: Technical documentation
Expand Down
8 changes: 4 additions & 4 deletions doc/doc/manual/04-static-contractors/01-ctc-function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ The boxes are contracted in order to remove some vectors that are not consistent

.. #include <codac.h>
.. #include <codac-rob.h>
.. #include "ibex_CtcHC4.h"
.. #include "codac_CtcHC4.h"
.. #include "ibex_SystemFactory.h"
.. #include "ibex_Ctc3BCid.h"
.. #include "codac_Ctc3BCid.h"
..
.. using namespace std;
.. using namespace codac;
Expand All @@ -159,7 +159,7 @@ The boxes are contracted in order to remove some vectors that are not consistent
.. int main()
.. {
.. SIVIAPaving p({{-3.,3.},{-3.,3.}});
.. p.compute(ibex::Function("x1", "x2", "x1*cos(x1-x2)*sin(x1)+x2"), {{0.}}, 0.01);
.. p.compute(Function("x1", "x2", "x1*cos(x1-x2)*sin(x1)+x2"), {{0.}}, 0.01);
.. CtcFunction ctc_f(Function("x1", "x2", "x1*cos(x1-x2)*sin(x1)+x2"));
..
.. vibes::beginDrawing();
Expand Down Expand Up @@ -198,7 +198,7 @@ Going further
This ``CtcFunction`` class is a generic shortcut to deal with :math:`\mathbf{f}(\mathbf{x})=\mathbf{0}` or :math:`\mathbf{f}(\mathbf{x})\in[\mathbf{y}]`. However, several algorithms exist to optimally deal with different classes of problems. A list of static contractors is provided in the IBEX library: `see more <http://www.ibex-lib.org/doc/contractor.html>`_.
The user is invited to use an appropriate tool to deal with the constraint at stake.

The IBEX contractor behind ``CtcFunction`` is a ``ibex::CtcFwdBwd`` coupled with a ``ibex::Ctc3BCid``.
The IBEX contractor behind ``CtcFunction`` is a ``CtcFwdBwd`` coupled with a ``Ctc3BCid``.


.. admonition:: Technical documentation
Expand Down
2 changes: 1 addition & 1 deletion doc/doc/manual/04-static-contractors/03-ctc-polar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Calls to :math:`\mathcal{C}_{\textrm{polar}}` will allow the contraction of the

// ...

pyibex::CtcPolar ctc_polar;
pyCtcPolar ctc_polar;

ctc_polar.contract(b1[0], b1[1], d1, theta1);
ctc_polar.contract(b2[0], b2[1], d2, theta2);
Expand Down
2 changes: 1 addition & 1 deletion doc/doc/manual/08-going-further/03-pavings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ SIVIAPaving
.. code-tab:: c++

SIVIAPaving p({{-3.,3.},{-3.,3.}});
p.compute(ibex::Function("x", "y", "x*cos(x-y)*sin(x)+y"),
p.compute(Function("x", "y", "x*cos(x-y)*sin(x)+y"),
{{-0.35,0.35}},
0.01);

Expand Down
4 changes: 2 additions & 2 deletions doc/doc/tutorial/04-own-contractor/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ where :math:`\bigsqcup`, called *squared union*, returns the smallest box enclos

.. code-tab:: cpp

class MyCtc : public ibex::Ctc
class MyCtc : public Ctc
{
public:

MyCtc(const std::vector<IntervalVector>& M_)
: ibex::Ctc(2), // the contractor acts on 2d boxes
: Ctc(2), // the contractor acts on 2d boxes
M(M_) // attribute needed later on for the contraction
{

Expand Down
1 change: 0 additions & 1 deletion examples/tuto/05_dyn_rangebearing/05_dyn_rangebearing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

using namespace std;
using namespace codac;
using namespace pyibex;

int main()
{
Expand Down
2 changes: 1 addition & 1 deletion make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fi
cmake -DBUILD_TESTS=OFF -DWITH_TUBE_TREE="${WITH_TUBE_TREE}" ..
fi

make
make -j
make api
make doc
cd ..
Expand Down
2 changes: 1 addition & 1 deletion python/codac_py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* the GNU Lesser General Public License (LGPL).
*/

#include "ibex_Ctc.h"
#include "codac_Ctc.h"
#include "codac_DynCtc.h"
#include "codac_TFnc.h"
#include "codac_VIBesFig.h"
Expand Down
12 changes: 6 additions & 6 deletions python/pyIbex_type_caster.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef __PYIBEX_TYPE_CASTER_H__
#define __PYIBEX_TYPE_CASTER_H__

#include "ibex_Vector.h"
#include "codac_Vector.h"
#include "ibex_Array.h"
#include "ibex_Ctc.h"
#include "codac_Ctc.h"
#include <pybind11/pybind11.h>

NAMESPACE_BEGIN(pybind11)
Expand All @@ -12,11 +12,11 @@ NAMESPACE_BEGIN(detail)
using ibex::Vector;
using ibex::Array;

template <> struct type_caster<ibex::Vector> {
template <> struct type_caster<Vector> {
public:
PYBIND11_TYPE_CASTER(ibex::Vector, _("Vector"));
PYBIND11_TYPE_CASTER(Vector, _("Vector"));

type_caster<ibex::Vector>() : value(1) { }
type_caster<Vector>() : value(1) { }
bool load(handle src_hdl, bool convert) {
PyObject *src = src_hdl.ptr();
if (!PyList_Check(src) && !PyTuple_Check(src))
Expand All @@ -37,7 +37,7 @@ template <> struct type_caster<ibex::Vector> {
return true;
}

static handle cast(const ibex::Vector &src, return_value_policy policy, handle parent) {
static handle cast(const Vector &src, return_value_policy policy, handle parent) {
list l(src.size());

for (int i = 0; i < src.size(); i++){
Expand Down
2 changes: 1 addition & 1 deletion python/src/core/contractors/static/codac_py_CtcDist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using namespace pybind11::literals;

void export_CtcDist(py::module& m)
{
py::class_<CtcDist,ibex::Ctc> ctc_dist(m, "CtcDist", CTCDIST_MAIN);
py::class_<CtcDist,Ctc> ctc_dist(m, "CtcDist", CTCDIST_MAIN);
ctc_dist

.def(py::init<>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,15 @@ void export_TrajectoryVector(py::module& m)
.def("__rmul__", [](const TrajectoryVector& y, double x) { return x*y; })
.def("__rmul__", [](const TrajectoryVector& y, const Trajectory& x) { return x*y; })

// todo const TrajectoryVector operator*(const Trajectory& x, const ibex::Vector& y);
// todo const TrajectoryVector operator*(const ibex::Matrix& x, const TrajectoryVector& y);
// todo const TrajectoryVector operator*(const Trajectory& x, const Vector& y);
// todo const TrajectoryVector operator*(const Matrix& x, const TrajectoryVector& y);

.def("__truediv__", [](const TrajectoryVector& x, double y) { return x/y; })
.def("__truediv__", [](const TrajectoryVector& x, const Trajectory& y) { return x/y; })

// todo const TrajectoryVector operator/(const ibex::Vector& x, const Trajectory& y);
// todo const TrajectoryVector operator/(const Vector& x, const Trajectory& y);

// todo const TrajectoryVector vecto_product(const TrajectoryVector& x, const ibex::Vector& y);
// todo const TrajectoryVector vecto_product(const ibex::Vector& x, const TrajectoryVector& y);
// todo const TrajectoryVector vecto_product(const TrajectoryVector& x, const Vector& y);
// todo const TrajectoryVector vecto_product(const Vector& x, const TrajectoryVector& y);
;
}
2 changes: 1 addition & 1 deletion python/src/robotics/codac_py_TPlane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void export_TPlane(py::module& m)
"precision"_a, "p"_a, "v"_a)

.def("compute_proofs", (void (TPlane::*)(const TubeVector&,const TubeVector&))&TPlane::compute_proofs,
TPLANE_VOID_COMPUTE_PROOFS_INTERVALVECTORPINTERVALVECTORB,
TPLANE_VOID_COMPUTE_PROOFS_TUBEVECTOR_TUBEVECTOR,
"p"_a, "v"_a)

.def("nb_loops_detections", &TPlane::nb_loops_detections,
Expand Down
6 changes: 3 additions & 3 deletions src/3rd/capd/codac_capd_integrateODE.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "codac_TubeVector.h"
#include "codac_TFunction.h"
#include "codac_IntervalVector.h"
#include "ibex_Function.h"
#include "codac_Function.h"

namespace codac
{
Expand All @@ -25,15 +25,15 @@ namespace codac
* \brief Integrates the autonomous ODE \f$\dot{\mathbf{x}}=\mathbf{f}(\mathbf{x})\f$ using CAPD.
*
* \param tdomain temporal domain \f$[t_0,t_f]\f$
* \param f the function \f$\mathbf{f}\f$ (defined with a `ibex::Function` object)
* \param f the function \f$\mathbf{f}\f$ (defined with a `Function` object)
* \param x0 the initial condition \f$\mathbf{x}_0\f$ at \f$t_0\f$
* \param tube_dt sampling value \f$\delta\f$ for the temporal discretization of the resulting tube
* \param capd_order (optional) order of the integration method
* \param capd_dt (optional) custom time step for CAPD integration
* \return TubeVector enclosing the solution
*/
TubeVector CAPD_integrateODE(
const Interval& tdomain, const ibex::Function& f, const IntervalVector& x0,
const Interval& tdomain, const Function& f, const IntervalVector& x0,
double tube_dt = 0., int capd_order = 20, double capd_dt = 0.);

// Non autonomous
Expand Down
5 changes: 2 additions & 3 deletions src/3rd/pyibex/pyibex_Catan2.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
#ifndef __IBEX_CTC_ANGLE_H__
#define __IBEX_CTC_ANGLE_H__

#include "codac_IntervalVector.h"
#include "ibex_Ctc.h"
#include <codac_IntervalVector.h>
#include <codac_Ctc.h>
#include <tuple>
// using namespace std;

using ibex::Ctc;
using ibex::bwd_imod;

namespace codac {
Expand Down
4 changes: 1 addition & 3 deletions src/3rd/pyibex/pyibex_CtcPolar.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

#include <codac_Interval.h>
#include <codac_IntervalVector.h>
#include "ibex_Ctc.h"

using ibex::Ctc;
#include <codac_Ctc.h>

using namespace std;

Expand Down
17 changes: 6 additions & 11 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# Codac - cmake configuration file
# ==================================================================

list(APPEND SRC ${CMAKE_CURRENT_SOURCE_DIR}/functions/codac_TFnc.h
list(APPEND SRC ${CMAKE_CURRENT_SOURCE_DIR}/functions/codac_Function.h
${CMAKE_CURRENT_SOURCE_DIR}/functions/codac_TFnc.h
${CMAKE_CURRENT_SOURCE_DIR}/functions/codac_TFnc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/functions/codac_TFunction.h
${CMAKE_CURRENT_SOURCE_DIR}/functions/codac_TFunction.cpp
Expand Down Expand Up @@ -72,6 +73,8 @@
${CMAKE_CURRENT_SOURCE_DIR}/domains/slice/codac_Slice.cpp
${CMAKE_CURRENT_SOURCE_DIR}/domains/slice/codac_Slice_polygon.cpp
${CMAKE_CURRENT_SOURCE_DIR}/domains/slice/codac_Slice_operators.cpp
${CMAKE_CURRENT_SOURCE_DIR}/variables/real/codac_Vector.h
${CMAKE_CURRENT_SOURCE_DIR}/variables/real/codac_Matrix.h
${CMAKE_CURRENT_SOURCE_DIR}/variables/trajectory/codac_RandTrajectory.h
${CMAKE_CURRENT_SOURCE_DIR}/variables/trajectory/codac_RandTrajectory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/variables/trajectory/codac_Trajectory.h
Expand All @@ -92,6 +95,7 @@
${CMAKE_CURRENT_SOURCE_DIR}/serialize/codac_serialize_tubes.cpp
${CMAKE_CURRENT_SOURCE_DIR}/serialize/codac_serialize_intervals.h
${CMAKE_CURRENT_SOURCE_DIR}/serialize/codac_serialize_intervals.cpp
${CMAKE_CURRENT_SOURCE_DIR}/contractors/static/codac_Ctc.h
${CMAKE_CURRENT_SOURCE_DIR}/contractors/static/codac_CtcDist.h
${CMAKE_CURRENT_SOURCE_DIR}/contractors/static/codac_CtcDist.cpp
${CMAKE_CURRENT_SOURCE_DIR}/contractors/static/codac_CtcFunction.h
Expand Down Expand Up @@ -148,6 +152,7 @@
${CMAKE_CURRENT_SOURCE_DIR}/domains/interval
${CMAKE_CURRENT_SOURCE_DIR}/domains/tube
${CMAKE_CURRENT_SOURCE_DIR}/domains/slice
${CMAKE_CURRENT_SOURCE_DIR}/variables/real
${CMAKE_CURRENT_SOURCE_DIR}/variables/trajectory
${CMAKE_CURRENT_SOURCE_DIR}/exceptions
${CMAKE_CURRENT_SOURCE_DIR}/serialize
Expand Down Expand Up @@ -183,17 +188,7 @@
file(WRITE ${CODAC_MAIN_HEADER} "/* This file is generated by CMake */\n\n")
file(APPEND ${CODAC_MAIN_HEADER} "#ifndef __CODAC_H__\n#define __CODAC_H__\n\n")
# Simplifying access to frequently used items of IBEX
file(APPEND ${CODAC_MAIN_HEADER} "#include <ibex_Vector.h>\n")
file(APPEND ${CODAC_MAIN_HEADER} "#include <ibex_Matrix.h>\n")
file(APPEND ${CODAC_MAIN_HEADER} "#include <ibex_Ctc.h>\n")
file(APPEND ${CODAC_MAIN_HEADER} "#include <ibex_Function.h>\n")
file(APPEND ${CODAC_MAIN_HEADER} "\n")
file(APPEND ${CODAC_MAIN_HEADER} "namespace codac\n{\n")
file(APPEND ${CODAC_MAIN_HEADER} " using ibex::Vector;\n")
file(APPEND ${CODAC_MAIN_HEADER} " using ibex::Matrix;\n")
file(APPEND ${CODAC_MAIN_HEADER} " using ibex::Ctc;\n")
file(APPEND ${CODAC_MAIN_HEADER} " using ibex::Function;\n")
file(APPEND ${CODAC_MAIN_HEADER} "}\n\n")
file(APPEND ${CODAC_MAIN_HEADER} "#include <codac-rob.h>\n") # todo: clean this organization
file(APPEND ${CODAC_MAIN_HEADER} "#include <codac-pyibex.h>\n") # todo: clean this organization
foreach(header_path ${HDR})
Expand Down
19 changes: 10 additions & 9 deletions src/core/arithmetic/codac_traj_arithmetic.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "codac_Trajectory.h"
#include "codac_TrajectoryVector.h"
#include "codac_Matrix.h"

namespace codac
{
Expand Down Expand Up @@ -287,14 +288,14 @@ namespace codac
* \param y
* \return TrajectoryVector output
*/
const TrajectoryVector operator+(const TrajectoryVector& x, const ibex::Vector& y);
const TrajectoryVector operator+(const TrajectoryVector& x, const Vector& y);

/** \brief \f$\mathbf{x}+\mathbf{y}(\cdot)\f$
* \param x
* \param y
* \return TrajectoryVector output
*/
const TrajectoryVector operator+(const ibex::Vector& x, const TrajectoryVector& y);
const TrajectoryVector operator+(const Vector& x, const TrajectoryVector& y);


/** \brief \f$-\mathbf{x}(\cdot)\f$
Expand All @@ -315,14 +316,14 @@ namespace codac
* \param y
* \return TrajectoryVector output
*/
const TrajectoryVector operator-(const TrajectoryVector& x, const ibex::Vector& y);
const TrajectoryVector operator-(const TrajectoryVector& x, const Vector& y);

/** \brief \f$\mathbf{x}-\mathbf{y}(\cdot)\f$
* \param x
* \param y
* \return TrajectoryVector output
*/
const TrajectoryVector operator-(const ibex::Vector& x, const TrajectoryVector& y);
const TrajectoryVector operator-(const Vector& x, const TrajectoryVector& y);


/** \brief \f$x\cdot\mathbf{y}(\cdot)\f$
Expand All @@ -344,14 +345,14 @@ namespace codac
* \param y
* \return TrajectoryVector output
*/
const TrajectoryVector operator*(const Trajectory& x, const ibex::Vector& y);
const TrajectoryVector operator*(const Trajectory& x, const Vector& y);

/** \brief \f$x(\cdot)\cdot\mathbf{y}\f$
* \param x
* \param y
* \return TrajectoryVector output
*/
const TrajectoryVector operator*(const ibex::Matrix& x, const TrajectoryVector& y);
const TrajectoryVector operator*(const Matrix& x, const TrajectoryVector& y);


/** \brief \f$\mathbf{x}(\cdot)/y\f$
Expand All @@ -373,22 +374,22 @@ namespace codac
* \param y
* \return TrajectoryVector output
*/
const TrajectoryVector operator/(const ibex::Vector& x, const Trajectory& y);
const TrajectoryVector operator/(const Vector& x, const Trajectory& y);


/** \brief \f$\mathbf{x}(\cdot)\times\mathbf{y}\f$ (or \f$\mathbf{x}(\cdot)\wedge\mathbf{y}\f$ in physics)
* \param x
* \param y
* \return TrajectoryVector output
*/
const TrajectoryVector vecto_product(const TrajectoryVector& x, const ibex::Vector& y);
const TrajectoryVector vecto_product(const TrajectoryVector& x, const Vector& y);

/** \brief \f$\mathbf{x}\times\mathbf{y}(\cdot)\f$ (or \f$\mathbf{x}\wedge\mathbf{y}(\cdot)\f$ in physics)
* \param x
* \param y
* \return TrajectoryVector output
*/
const TrajectoryVector vecto_product(const ibex::Vector& x, const TrajectoryVector& y);
const TrajectoryVector vecto_product(const Vector& x, const TrajectoryVector& y);


/** \brief \f$\mid\mathbf{x}(\cdot)\mid\f$
Expand Down
Loading

0 comments on commit 85a651e

Please sign in to comment.