Skip to content

Commit 0825024

Browse files
authored
Merge pull request #368 from SimonRohou/codac2_dev
Added pave_tube and TDomain::truncate
2 parents 9f0ef4a + 0ecda10 commit 0825024

File tree

14 files changed

+151
-57
lines changed

14 files changed

+151
-57
lines changed

doc/manual/development/changelog.rst

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,25 @@
33
Changelog
44
=========
55

6+
7+
Commit 52b81c8 ([cmake] warning for Doxygen version)
8+
----------------------------------------------------
9+
10+
Python binding build requirement
11+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12+
13+
Doxygen 1.16.1 or newer is now required when ``WITH_PYTHON`` is enabled.
14+
If this version is not available, the API documentation will not be generated,
15+
which may cause issues when building the Python binding from source.
16+
This has no impact on the C++ build nor on downloading/installing the Python packages.
17+
18+
619
Pull Request from godardma (15/10)
720
----------------------------------
821

22+
Parallelepiped drawing API
23+
~~~~~~~~~~~~~~~~~~~~~~~~~~
24+
925
Due to the addition of the Parallelepiped object the signature of the following functions has changed :
1026

1127
- DefaultFigure::draw_parallelepiped
@@ -40,6 +56,9 @@ They used to take a Vector and a Matrix as arguments, now they take a Parallelep
4056
fig_3d.draw_parallelepiped({{1,-1.5,1.5},
4157
{{1,0,0},{0,0.5,0},{0,0.2,0.1}}});
4258

59+
Zonotope drawing API
60+
~~~~~~~~~~~~~~~~~~~~
61+
4362
Due to the addition of the Zonotope object the signature of the following functions has changed :
4463

4564
- DefaultFigure::draw_zonotope
@@ -87,5 +106,4 @@ They used to take a Vector and a Matrix as arguments, now they take a Zonotope o
87106
fig_3d.draw_zonotope({{1.5,1.5,1.5},
88107
{{0.3,-0.2,-0.2,0.3,-0.1,0.0},
89108
{0.2,0.1,-0.1,0.0,0.05,0.2},
90-
{0.4,0.3,0.0,-0.1,0.2,0.1}}});
91-
109+
{0.4,0.3,0.0,-0.1,0.2,0.1}}});

python/src/core/contractors/codac2_py_CtcInverse.h

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void export_CtcInverse(py::module& m,
102102
// Detecting whether we are in "domains" mode or "tubes" mode
103103

104104
bool has_domain_args = false;
105-
bool has_tube_args = false;
105+
[[maybe_unused]] bool has_tube_args = false;
106106

107107
for(size_t i = 0 ; i < xs.size() ; ++i)
108108
{
@@ -196,22 +196,24 @@ void export_CtcInverse(py::module& m,
196196
Index total_size = 0;
197197
for(size_t i = 0 ; i < xs.size() ; ++i)
198198
{
199-
py::handle h = xs[i];
200-
201-
if(py::isinstance<SlicedTube<Interval>>(h))
202-
{
203-
auto& x = h.cast<SlicedTube<Interval>&>();
204-
assert_release(TDomain::are_same(tdomain, x.tdomain())
205-
&& "contract(): all SlicedTube arguments must share the same tdomain");
206-
total_size += 1;
207-
}
208-
else
209-
{
210-
auto& x = h.cast<SlicedTube<IntervalVector>&>();
211-
assert_release(TDomain::are_same(tdomain, x.tdomain())
212-
&& "contract(): all SlicedTube arguments must share the same tdomain");
213-
total_size += x.size();
214-
}
199+
assert_release([&](){
200+
py::handle h = xs[i];
201+
if(py::isinstance<SlicedTube<Interval>>(h))
202+
{
203+
[[maybe_unused]] auto& x = h.cast<SlicedTube<Interval>&>();
204+
if(!TDomain::are_same(tdomain, x.tdomain()))
205+
return false;
206+
total_size += 1;
207+
}
208+
else
209+
{
210+
[[maybe_unused]] auto& x = h.cast<SlicedTube<IntervalVector>&>();
211+
if(!TDomain::are_same(tdomain, x.tdomain()))
212+
return false;
213+
total_size += x.size();
214+
}
215+
return true;
216+
}() && "contract(): all SlicedTube arguments must share the same tdomain");
215217
}
216218

217219
assert_release(total_size == as_ctc_base<C>(c).size()

python/src/core/domains/tube/codac2_py_TDomain.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ void export_TDomain(py::module& m)
6363
.def("delete_gates", &TDomain::delete_gates,
6464
VOID_TDOMAIN_DELETE_GATES)
6565

66+
.def("truncate", &TDomain::truncate,
67+
VOID_TDOMAIN_TRUNCATE_CONST_INTERVAL_REF,
68+
"new_tdomain"_a)
69+
6670
.def("__repr__", [](const TDomain& x) {
6771
std::ostringstream stream;
6872
stream << x;

python/src/core/paver/codac2_py_pave.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,33 @@ void export_pave(py::module& m)
2323
{
2424
m.def("pave", (PavingOut (*)(const IntervalVector&,const CtcBase<IntervalVector>&,double,bool))&codac2::pave,
2525
PAVINGOUT_PAVE_CONST_INTERVALVECTOR_REF_CONST_CTCBASE_INTERVALVECTOR_REF_DOUBLE_BOOL,
26-
"x"_a, "c"_a, "eps"_a, "verbose"_a=false);
26+
"x0"_a, "c"_a, "eps"_a, "verbose"_a=false);
2727

2828
m.def("pave", (PavingOut (*)(const IntervalVector&,const CtcBase<IntervalVector>&,double,double&,bool))&codac2::pave,
2929
PAVINGOUT_PAVE_CONST_INTERVALVECTOR_REF_CONST_CTCBASE_INTERVALVECTOR_REF_DOUBLE_DOUBLE_REF_BOOL,
30-
"x"_a, "c"_a, "eps"_a, "time"_a, "verbose"_a=false);
30+
"x0"_a, "c"_a, "eps"_a, "time"_a, "verbose"_a=false);
3131

3232
m.def("pave", (PavingInOut (*)(const IntervalVector&,const SepBase&,double,bool))&codac2::pave,
3333
PAVINGINOUT_PAVE_CONST_INTERVALVECTOR_REF_CONST_SEPBASE_REF_DOUBLE_BOOL,
34-
"x"_a, "s"_a, "eps"_a, "verbose"_a=false);
34+
"x0"_a, "s"_a, "eps"_a, "verbose"_a=false);
3535

3636
m.def("regular_pave", &codac2::regular_pave,
3737
PAVINGINOUT_REGULAR_PAVE_CONST_INTERVALVECTOR_REF_CONST_FUNCTION_BOOLINTERVAL_CONST_INTERVALVECTOR_REF__REF_DOUBLE_BOOL,
38-
"x"_a, "test"_a, "eps"_a, "verbose"_a=false);
38+
"x0"_a, "test"_a, "eps"_a, "verbose"_a=false);
3939

4040
m.def("sivia", (PavingInOut (*)(const IntervalVector&,const AnalyticFunction<ScalarType>&,const Interval&,double,bool))&codac2::sivia,
4141
PAVINGINOUT_SIVIA_CONST_INTERVALVECTOR_REF_CONST_ANALYTICFUNCTION_Y_REF_CONST_TYPENAME_Y_DOMAIN_REF_DOUBLE_BOOL,
42-
"x"_a, "f"_a, "y"_a, "eps"_a, "verbose"_a=false);
42+
"x0"_a, "f"_a, "y"_a, "eps"_a, "verbose"_a=false);
4343

4444
m.def("sivia", (PavingInOut (*)(const IntervalVector&,const AnalyticFunction<VectorType>&,const IntervalVector&,double,bool))&codac2::sivia,
4545
PAVINGINOUT_SIVIA_CONST_INTERVALVECTOR_REF_CONST_ANALYTICFUNCTION_Y_REF_CONST_TYPENAME_Y_DOMAIN_REF_DOUBLE_BOOL,
46-
"x"_a, "f"_a, "y"_a, "eps"_a, "verbose"_a=false);
46+
"x0"_a, "f"_a, "y"_a, "eps"_a, "verbose"_a=false);
4747

4848
m.def("sivia", (PavingInOut (*)(const IntervalVector&,const AnalyticFunction<MatrixType>&,const IntervalMatrix&,double,bool))&codac2::sivia,
4949
PAVINGINOUT_SIVIA_CONST_INTERVALVECTOR_REF_CONST_ANALYTICFUNCTION_Y_REF_CONST_TYPENAME_Y_DOMAIN_REF_DOUBLE_BOOL,
50-
"x"_a, "f"_a, "y"_a, "eps"_a, "verbose"_a=false);
50+
"x0"_a, "f"_a, "y"_a, "eps"_a, "verbose"_a=false);
51+
52+
m.def("pave_tube", (PavingInOut (*)(const IntervalVector&,const SlicedTube<IntervalVector>&,double,bool))&codac2::pave_tube,
53+
PAVINGINOUT_PAVE_TUBE_CONST_INTERVALVECTOR_REF_CONST_SLICEDTUBE_INTERVALVECTOR_REF_DOUBLE_BOOL,
54+
"x0"_a, "f"_a, "eps"_a, "verbose"_a=false);
5155
}

src/core/contractors/codac2_CtcInter.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,22 @@ namespace codac2
104104
assert_release(all_same_size(c...));
105105
}
106106

107+
/**
108+
* \brief Builds an intersection contractor from a collection of contractors.
109+
*
110+
* All contractors must act on contracted objects of the same size.
111+
*
112+
* \param ctcs Collection of contractors sequentially.
113+
*/
114+
CtcInter(const Collection<CtcBase<IntervalVector>>& ctcs)
115+
: Ctc<CtcInter<X...>,X...>(ctcs.front()->size()), _ctcs(ctcs)
116+
{
117+
for(const auto& ci : _ctcs)
118+
{
119+
assert_release(ci->size() == this->size());
120+
}
121+
}
122+
107123
/**
108124
* \brief Returns the number of stored contractors.
109125
*

src/core/domains/interval/codac2_IntervalVector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace codac2
3434
inline std::ostream& operator<<(std::ostream& os, const IntervalVector& x)
3535
{
3636
if(x.is_empty())
37-
return os << "[ empty " << x.size() << "d vector ]";
37+
return os << "[ empty " << x.size() << "d box ]";
3838

3939
else
4040
{

src/core/domains/paving/codac2_Paving.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ namespace codac2
7575
return n->hull().intersects(intersecting_box);
7676
});
7777

78+
if(l.empty())
79+
l.push_back(IntervalVector::empty(this->size()));
7880
return l;
7981
}
8082

src/core/domains/tube/codac2_TDomain.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,17 @@ namespace codac2
209209
else ++it;
210210
}
211211
}
212+
213+
void TDomain::truncate(const Interval& new_tdomain)
214+
{
215+
sample(new_tdomain.lb());
216+
sample(new_tdomain.ub());
217+
this->remove_if(
218+
[&new_tdomain](const TSlice& s)
219+
{
220+
return !s.intersects(new_tdomain);
221+
});
222+
}
212223

213224
ostream& operator<<(ostream& os, const TDomain& x)
214225
{

src/core/domains/tube/codac2_TDomain.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@ namespace codac2
144144
* After this operation, only non-degenerate temporal slices remain.
145145
*/
146146
void delete_gates();
147+
148+
/**
149+
* \brief Restricts this temporal domain to a subdomain
150+
*
151+
* Temporal slices outside ``new_tdomain`` are removed. Gates are added at the
152+
* bounds of ``new_tdomain`` so that the resulting partition exactly matches
153+
* the new temporal domain.
154+
*
155+
* \param new_tdomain temporal interval to keep
156+
*/
157+
void truncate(const Interval& new_tdomain);
147158

148159
/**
149160
* \brief Stream output for a temporal domain

src/core/domains/tube/codac2_tube_cart_prod.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace codac2
2424
SlicedTube v(tdomain, IntervalVector(s));
2525

2626
for(auto it = tdomain->begin() ; it != tdomain->end() ; it++)
27-
v(it)->codomain() = cart_prod(x(it)->codomain()...);
27+
v.slice(it)->codomain() = cart_prod(x.slice(it)->codomain()...);
2828

2929
return v;
3030
}

0 commit comments

Comments
 (0)