Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
f817d46
Polytope, first version
damien-masse Apr 29, 2025
9826bbd
Merge branch 'codac2_dev' into codac2_polytope
damien-masse May 9, 2025
e6a6966
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse May 13, 2025
ba2130c
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse May 21, 2025
ef7c62f
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Jun 2, 2025
20df663
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Jun 20, 2025
1e6d368
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Jun 30, 2025
189c1e5
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Jul 16, 2025
6079cd9
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Jul 21, 2025
ae394eb
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Aug 25, 2025
5d9a3a6
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Sep 11, 2025
93a76fa
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Sep 25, 2025
fc67e66
partial construction
damien-masse Sep 29, 2025
2058340
Merge branch 'codac2_polytope' of https://github.com/damien-masse/cod…
damien-masse Sep 29, 2025
9fb8b3a
followup
damien-masse Oct 1, 2025
1393057
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Oct 15, 2025
8db0568
temporaire
damien-masse Oct 15, 2025
54e98e1
Merge branch 'codac2_polytope' of https://github.com/damien-masse/cod…
damien-masse Oct 15, 2025
71f1509
tmp
damien-masse Oct 17, 2025
eeb1912
tmp
damien-masse Oct 21, 2025
c2a77e0
better, but not complete
damien-masse Oct 27, 2025
b300c48
example
damien-masse Oct 27, 2025
ae60ce3
Change
damien-masse Nov 4, 2025
dd0ecdf
temporary commit
damien-masse Nov 5, 2025
cdadead
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Nov 7, 2025
f90a827
correction?
damien-masse Nov 10, 2025
5f0dcdc
First tests, hull...
damien-masse Nov 14, 2025
7d3f54f
Intersection of polytopes
damien-masse Nov 18, 2025
4a5d908
Separation between polytope-clp and polytope.
damien-masse Nov 21, 2025
ca54be1
Python bindings (partial), python tests. Manual (preliminary version).
damien-masse Nov 21, 2025
06dfb83
Merge branch 'codac2_dev' into codac2_polytope
damien-masse Nov 21, 2025
cc5aee1
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Nov 22, 2025
e9337a1
Modification for readability, new tests.
damien-masse Nov 24, 2025
777df53
Bug fixes, renaming of methods, clp fixes.
damien-masse Nov 25, 2025
c8fa180
Centered form with polytopes. Better separation with CLP. Some bug fi…
damien-masse Nov 26, 2025
ee74c7b
Left- and right- "pseudoinverse" enclosure for non-square matrices.
damien-masse Dec 1, 2025
8686d66
bugfix in python
damien-masse Dec 1, 2025
e37e13f
Polytope contractor and separator
damien-masse Dec 12, 2025
99bd953
Polytope: test contractor and separator + python binding for contract…
damien-masse Dec 15, 2025
a98a2e1
Small improvement to the doc.
damien-masse Dec 15, 2025
4c12b26
Few modifications.
damien-masse Dec 18, 2025
258fa6e
Remove CLP extension.
damien-masse Dec 18, 2025
f974f6c
Remove clp tests
damien-masse Dec 18, 2025
82c772d
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Jan 7, 2026
eb97a36
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Jan 8, 2026
e504032
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Feb 6, 2026
1f0dccb
[doc] Update for zonotopes
godardma Feb 17, 2026
c2afa6f
[doc] Update for zonotopes
godardma Feb 18, 2026
5c1e938
[doc] Documentation for OctaSym
godardma Feb 18, 2026
6193020
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Feb 19, 2026
5cf6fbf
[doc] Documentation for OctaSym
godardma Feb 20, 2026
aa82d89
[doc] update for OctaSym doc
godardma Feb 20, 2026
1c4f3a6
[doc] commented C++ apt installation
godardma Feb 20, 2026
d3ebe72
[doc] Update following Simon's comments (thanks!)
godardma Mar 10, 2026
1b8523b
Merge pull request #351 from godardma/documentation
SimonRohou Mar 17, 2026
7ba6d49
Merge branch 'codac-team:codac2' into codac2_polytope
damien-masse Mar 20, 2026
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: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,4 @@
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CODAC_URL})
# todo: finish deb package

include(CPack)
include(CPack)
1 change: 1 addition & 0 deletions doc/manual/manual/contractors/index.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.. _sec-ctc:
Contractors, separators
=======================

Expand Down
33 changes: 33 additions & 0 deletions doc/manual/manual/geometry/facets.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.. _sec-polytope:

Facet classes
=============

Main author: `Damien Massé <https://labsticc.fr/fr/annuaire/masse-damien>`_

Facets
------

.. doxygentypedef:: codac2::Facet
:project: codac

.. doxygennamespace:: codac2::Facet_
:project: codac
:members:

.. doxygenclass:: codac2::FacetBase
:project: codac
:members:

.. doxygenclass:: codac2::FacetRhs
:project: codac
:members:


Collection of facets
--------------------

.. doxygenclass:: codac2::CollectFacets
:project: codac
:members:

3 changes: 2 additions & 1 deletion doc/manual/manual/geometry/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Geometry
========

Codac provides a set of utility functions for basic 2d geometric calculations.
Codac provides a set of utility functions for basic geometric calculations.

Several basic geometric types are available under the form of classes representing enclosures of these types. For instance, a 2d point if represented by an ``IntervalVector`` enclosing it, a segment between two 2d points is implemented by the ``Segment`` class, the endpoints of which are ``IntervalVector`` objects. Furthermore, ``Polygon`` and ``ConvexPolygon`` are also available. Operations between these structure will reliably meet the uncertainties associated with the enclosure of points (vertices), as well as floating-point calculations.

Expand All @@ -16,6 +16,7 @@ Because computations are based on interval arithmetic, all these functions provi
segment.rst
polygon.rst
zonotope.rst
polytope.rst

Related interval enumerations
-----------------------------
Expand Down
60 changes: 60 additions & 0 deletions doc/manual/manual/geometry/polytope.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.. _sec-polytope:

Polytope
========

Main author: `Damien Massé <https://labsticc.fr/fr/annuaire/masse-damien>`_

The Polytope class represent convex polytopes (or, more generally,
convex polyhedra).
Polytopes are internally represented as intersections of linear constraints
(and a bounding box), in a class name CollectFacets.
A double-description algorithm is used to compute generators for operations
requiring them (union, projections...). Due to the imprecise nature of
floating-point computations, the algorithm is designed such that the
convex hull of the "generators" encloses the polytope. However, no guarantee
is given that each vertice of the polytope is associated to a generator.
As a result,
going back to the hyperplane representation may return a larger polytope.

.. toctree::
:maxdepth: 1

facets.rst
polytope_class.rst


Building a polytope
-------------------
Polytopes can be defined from a set of facets (linear inequalities
or equalities), or a set of vertices.

.. tabs::

.. group-tab:: C++

.. literalinclude:: src_polytope.cpp
:language: c++
:start-after: [polytope-1-beg]
:end-before: [polytope-1-end]
:dedent: 2

Output of a polytope
--------------------
Polytopes are displayed as a set of linear constraints and a bounding box.
To display the set of vertices, one can use the
vertices() method.

.. tabs::

.. group-tab:: C++

.. literalinclude:: src_polytope.cpp
:language: c++
:start-after: [polytope-2-beg]
:end-before: [polytope-2-end]
:dedent: 2

Operations on polytopes
-----------------------

14 changes: 14 additions & 0 deletions doc/manual/manual/geometry/polytope_class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. _sec-polytope:

The Polytope class
==================

Main author: `Damien Massé <https://labsticc.fr/fr/annuaire/masse-damien>`_

Polytope
--------

.. doxygenclass:: codac2::Polytope
:project: codac
:members:

83 changes: 83 additions & 0 deletions doc/manual/manual/geometry/src_polytope.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Author : Damien Massé
// Graphical illustration of the polytope test

#include <codac>
#include <vector>
#include <memory>

using namespace std;
using namespace codac2;

void draw_polytope(Figure3D &fig, const Polytope &P, const StyleProperties &st) {
std::vector<std::vector<Vector>> facets3D=P.vertices_3Dfacets();
Vector center = Vector::zero(3);
Matrix transfo = Matrix::Identity(3,3);
for (const std::vector<Vector> &vec : facets3D) {
fig.draw_polygon(center,transfo,vec,st);
}
}

int main(int argc, char *argv[])
{
// std::cout << std::scientific << std::setprecision(20);

Figure3D fig("manual_polytope");

fig.draw_axes();

// [polytope-1-beg]
// definition using vertices
std::vector<Vector> vertices
{ {0,0,0}, {2,1,0}, {-1,1,0}, {0,1.5,2}, {-1.5,0,-1.5}, {0,3,0} };
Polytope p1(vertices); // vertices {0,0,0}, {2,1,0}, etc.
// definition using facets
std::vector<std::pair<Row,double>> facets
{ { {1,1,0.75}, 3 }, // x+y+0.75z <= 3
{ {-1,-0.4,0.6} ,0.6 }, // -x-0.4y+0.6z <= 0.6
{ {-1,0.5,0.375} ,1.5 }, // ...
{ {-1,0.5,0} ,1.5 },
{ {0.5,-1,0.75} ,0 },
{ {-0.75,-1,0.75} ,0 },
{ {0.5,-1,-0.5} ,0 },
{ {1.0/3.0,1.0/3.0,-1} ,1 } };
// the first argument is a bounding box, here the whole space
Polytope p2(IntervalVector(3), facets);
// p1 and p2 are almost the same polytope
// [polytope-1-end]


// [polytope-2-beg]
std::cout << p1 << std::endl;
/* output, each facet is a row (sequences of double) and a right-hand-side
Polytope(bbox [ [-1.5, 2] ; [0, 3] ; [-1.5, 2] ]) :
Collectfacets : 8 facets
1 : 1 1 0.75<=3
2 : -1 -0.399999 0.6<=0.600001
3 : -1 0.5 0.375<=1.5
4 : -1 0.5 1.77636e-16<=1.5
5 : 0.5 -1 0.75<=0
6 : -0.75 -1 0.750001<=5.92119e-16
7 : 0.5 -1 -0.5<=0
8 : 0.333334 0.333334 -1<=1
end Collectfacets
EndPolytope
*/
std::vector<IntervalVector> vp2 = p2.vertices(); /* hull of p2 */
for (auto &v : vp2) std::cout << v << std::endl;
/* output : "vertices" are boxes which enclose the polytope, but each
box may not enclose a "real vertice". E.g. the vertice (0,0,0) is
not inside the second box displayed.
[ [1.99999, 2.00001] ; [0.999999, 1.00001] ; [-2.4743e-14, -1.70641e-15] ]
[ [-7.76463e-15, 1.69539e-14] ; [-3.15401e-14, -2.88916e-15] ; [-2.52802e-14, -2.40763e-15] ]
[ [-1.50001, -1.5] ; [-1.16016e-14, -9.33785e-15] ; [-1.50001, -1.5] ]
[ [-7.11673e-15, 1.609e-14] ; [1.49999, 1.50001] ; [1.99999, 2.00001] ]
[ [-2.47539e-15, 9.90153e-16] ; [2.99999, 3.00001] ; [-2.31036e-15, 3.30051e-15] ]
[ [-1.00001, -0.999999] ; [1, 1.00001] ; [1.83361e-15, 3.20883e-15] ]
*/
// [polytope-2-end]

fig.draw_polytope(p1,StyleProperties(Color::dark_red(0.8),"p1"));
fig.draw_polytope(p2,StyleProperties(Color::dark_blue(0.8),"p2"));

return 0;
}
Binary file added doc/manual/manual/geometry/zonotope.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 60 additions & 6 deletions doc/manual/manual/geometry/zonotope.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,69 @@ The following classes represent zonotopes.
Zonotope
--------

.. doxygenclass:: codac2::Zonotope
:project: codac
:members:
A zonotope is a convex and symmetric polytope.
It can be represented as the Minkowski sum of a finite number of line segments, which are called its generators.

In Codac, zonotopes are represented by the class :class:`Zonotope`. A zonotope is defined by its center and its generators.
The center is a :class:`Vector`, noted :math:`z`, and the generators are stored in a :class:`Matrix`, noted :math:`A`.
Each column of the matrix corresponds to a generator.

The resulting zonotope is:

.. math::
Z = z + A \cdot [-1,1]^m

Where :math:`m` is the number of generators (i.e., the number of columns of the matrix :math:`A`).

For example, let us consider the following zonotope in :math:`\mathbb{R}^2`:

.. math::
Z = \left(\begin{array}{c} 1\\ 2\\ \end{array}\right) + \left(\begin{array}{ccc} 1 & 0 & 2 \\ 0 & 1 & 1 \end{array}\right) \cdot [-1,1]^3

It can be constructed in Codac as follows:

.. tabs::

.. code-tab:: py

z = Vector([1,2])
A = Matrix([[1,0,2],[0,1,1]])

Z = Zonotope(z, A)

.. code-tab:: c++

Vector z({1,2});
Matrix A({{1,0,2},{0,1,1}});

Zonotope Z(z, A);

.. code-tab:: matlab

z = Vector({1,2});
A = Matrix({{1,0,2},{0,1,1}});

Z = Zonotope(z,A);

The resulting zonotope is represented in the figure below:

.. figure:: zonotope.png
:width: 400px

Additional methods are provided to handle zonotopes.

- `box()`: gives the bounding box of the zonotope. Returns an :class:`IntervalVector`.
- `proj(v)`: Projects the zonotope on a given subspace, defined by the vector of indices `v` (:class:`std::vector\<Index\>`). Returns a :class:`Zonotope`.

.. _subsec-zonotope-parallelepiped:

Parallelepiped
--------------

.. doxygenclass:: codac2::Parallelepiped
:project: codac
:members:
A parallelepiped is a special case of zonotope, where the number of generators is equal or less than the dimension of the space.

It inherits from the `Zonotope` class, and thus has the same properties and methods. In addition, it defines the following methods:

- `vertices()`: gives the vertices of the parallelepiped. Returns a :class:`std::vector\<Vector\>`.
- `contains(v)`: checks if the point `v` is contained in the parallelepiped. Returns a :class:`BoolInterval`. **The matrix A must be invertible**
- `is_superset(x)`: checks if the parallelepiped is a superset of the :class:`IntervalVector` `x`. Returns a :class:`BoolInterval`. **The matrix A must be invertible**
Loading
Loading