From eeb7bcec5f01a591a416638656efa2424c0157ac Mon Sep 17 00:00:00 2001 From: SimonRohou Date: Fri, 8 Jan 2021 10:32:39 +0100 Subject: [PATCH 1/4] [lohner] uint -> unsigned int (Windows compilation) --- src/core/contractors/dyn/tubex_CtcLohner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/contractors/dyn/tubex_CtcLohner.cpp b/src/core/contractors/dyn/tubex_CtcLohner.cpp index 62e7f649..c4760583 100644 --- a/src/core/contractors/dyn/tubex_CtcLohner.cpp +++ b/src/core/contractors/dyn/tubex_CtcLohner.cpp @@ -65,7 +65,7 @@ class LohnerAlgorithm { * \param H parameter to overwrite the integration time step * \return enclosure of the system's state */ - const ibex::IntervalVector &integrate(uint steps, double H = -1); + const ibex::IntervalVector &integrate(unsigned int steps, double H = -1); /** * \brief contract the global & local enclosure of the previous integration step @@ -98,7 +98,7 @@ class LohnerAlgorithm { */ ibex::IntervalVector globalEnclosure(const ibex::IntervalVector &initialGuess, double direction); - uint dim; //!< dimension of the system's state + unsigned int dim; //!< dimension of the system's state double h; //!< integration time step double eps; //!< inflation parameter for the global enclosure int contractions; //!< number of contractions of the global enclosure by the estimated local enclosure From 500fcce0c072a3c5052fdd041e3a985b57596b5d Mon Sep 17 00:00:00 2001 From: SimonRohou Date: Fri, 8 Jan 2021 12:43:45 +0100 Subject: [PATCH 2/4] [lohner] "not" keyword (Windows compilation) --- src/core/contractors/dyn/tubex_CtcLohner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/contractors/dyn/tubex_CtcLohner.cpp b/src/core/contractors/dyn/tubex_CtcLohner.cpp index c4760583..9695467f 100644 --- a/src/core/contractors/dyn/tubex_CtcLohner.cpp +++ b/src/core/contractors/dyn/tubex_CtcLohner.cpp @@ -235,7 +235,7 @@ void CtcLohner::contract(tubex::TubeVector &tube, TimePropag t_propa) { } void CtcLohner::contract(tubex::Tube &tube, TimePropag t_propa) { - assert(not tube.is_empty()); + assert(!tube.is_empty()); tubex::TubeVector tubeVector(1, tube); contract(tubeVector, t_propa); tube = tubeVector[0]; From 5c069aabea20731f0e7418c48393b4bb84296a48 Mon Sep 17 00:00:00 2001 From: SimonRohou Date: Fri, 8 Jan 2021 19:26:13 +0100 Subject: [PATCH 3/4] [doc] updated doxygen2docstring (Windows compilation) --- doc/api/Doxyfile.in | 18 +++++++++--------- scripts/pybind/doxygen2docstring.py | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/doc/api/Doxyfile.in b/doc/api/Doxyfile.in index 48f99ae2..02583f16 100644 --- a/doc/api/Doxyfile.in +++ b/doc/api/Doxyfile.in @@ -99,7 +99,7 @@ OUTPUT_LANGUAGE = English # Possible values are: None, LTR, RTL and Context. # The default value is: None. -OUTPUT_TEXT_DIRECTION = None +# Not supported anymore: OUTPUT_TEXT_DIRECTION = None # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class @@ -205,7 +205,7 @@ JAVADOC_AUTOBRIEF = NO # interpreted by doxygen. # The default value is: NO. -JAVADOC_BANNER = NO +# Not supported anymore: JAVADOC_BANNER = NO # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If @@ -304,7 +304,7 @@ OPTIMIZE_OUTPUT_VHDL = NO # separated into more groups, etc. # The default value is: NO. -OPTIMIZE_OUTPUT_SLICE = NO +# Not supported anymore: OPTIMIZE_OUTPUT_SLICE = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given @@ -480,7 +480,7 @@ EXTRACT_PRIVATE = NO # methods of a class will be included in the documentation. # The default value is: NO. -EXTRACT_PRIV_VIRTUAL = NO +# Not supported anymore: EXTRACT_PRIV_VIRTUAL = NO # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. @@ -1096,7 +1096,7 @@ CLANG_OPTIONS = # Note: The availability of this option depends on whether or not doxygen was # generated with the -Duse_libclang=ON option for CMake. -CLANG_DATABASE_PATH = +# Not supported anymore: CLANG_DATABASE_PATH = #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index @@ -1548,7 +1548,7 @@ FORMULA_TRANSPARENT = YES # to create new LaTeX commands to be used in formulas as building blocks. See # the section "Including formulas" for details. -FORMULA_MACROFILE = +# Not supported anymore: FORMULA_MACROFILE = # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see # https://www.mathjax.org) which uses client side JavaScript for the rendering @@ -1733,7 +1733,7 @@ MAKEINDEX_CMD_NAME = makeindex # The default value is: makeindex. # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_MAKEINDEX_CMD = makeindex +# Not supported anymore: LATEX_MAKEINDEX_CMD = makeindex # If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX # documents. This may be useful for small projects and may help to save some @@ -1875,7 +1875,7 @@ LATEX_TIMESTAMP = NO # LATEX_OUTPUT directory will be used. # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_EMOJI_DIRECTORY = +# Not supported anymore: LATEX_EMOJI_DIRECTORY = #--------------------------------------------------------------------------- # Configuration options related to the RTF output @@ -2019,7 +2019,7 @@ XML_PROGRAMLISTING = YES # The default value is: NO. # This tag requires that the tag GENERATE_XML is set to YES. -XML_NS_MEMB_FILE_SCOPE = NO +# Not supported anymore: XML_NS_MEMB_FILE_SCOPE = NO #--------------------------------------------------------------------------- # Configuration options related to the DOCBOOK output diff --git a/scripts/pybind/doxygen2docstring.py b/scripts/pybind/doxygen2docstring.py index 70b14945..e907858b 100644 --- a/scripts/pybind/doxygen2docstring.py +++ b/scripts/pybind/doxygen2docstring.py @@ -212,16 +212,16 @@ def sentence(str): print("\nArgs:", file=f) for param in params: - param_name = param.find("declname").text - print(indent + param_name, "(" + get_tags_text(param.find("type")) + "): ", end='', file=f) - - parameterlist = memberdef.find("detaileddescription/para/parameterlist") - - if parameterlist: - for parameteritem in parameterlist.iter("parameteritem"): - if parameteritem.find("parameternamelist").find("parametername").text == param_name: - param_description = sentence(get_tags_text(parameteritem.find("parameterdescription"))) - print(param_description, file=f) + param_name = param.find("declname") + if param_name: + print(indent + param_name.text, "(" + get_tags_text(param.find("type")) + "): ", end='', file=f) + parameterlist = memberdef.find("detaileddescription/para/parameterlist") + + if parameterlist: + for parameteritem in parameterlist.iter("parameteritem"): + if parameteritem.find("parameternamelist").find("parametername").text == param_name.text: + param_description = sentence(get_tags_text(parameteritem.find("parameterdescription"))) + print(param_description, file=f) # Return value (if any) return_val = memberdef.find(".//simplesect[@kind='return']") From 782e4cc9750b5d880c35531969a76d29ff2995ab Mon Sep 17 00:00:00 2001 From: Auguste Bourgois Date: Mon, 11 Jan 2021 16:41:19 +0100 Subject: [PATCH 4/4] [core] corrected error caused by use of string to define functions --- src/core/contractors/dyn/tubex_CtcLohner.cpp | 29 +++++----- src/core/contractors/dyn/tubex_CtcLohner.h | 2 - tests/core/tests_ctc_lohner.cpp | 56 ++++++++++---------- 3 files changed, 44 insertions(+), 43 deletions(-) diff --git a/src/core/contractors/dyn/tubex_CtcLohner.cpp b/src/core/contractors/dyn/tubex_CtcLohner.cpp index 62e7f649..0e3386bb 100644 --- a/src/core/contractors/dyn/tubex_CtcLohner.cpp +++ b/src/core/contractors/dyn/tubex_CtcLohner.cpp @@ -42,19 +42,21 @@ struct GlobalEnclosureError : public std::runtime_error { */ class LohnerAlgorithm { public: - constexpr static const double FWD = 1, BWD = -1; + constexpr static const double FWD = 1., BWD = -1.; /** * \brief Creates a Lohner algorithm object * * \param f function defining the system \f$\dot{\mathbf{x}}=\mathbf{f}(\mathbf{x})\f$ * \param h time step of the integration method + * \param direction forward or backaward integration * \param u0 initial condition of the system * \param contractions number of contractions of the global enclosure by the estimated local enclosure * \param eps inflation parameter for the global enclosure */ LohnerAlgorithm(const ibex::Function *f, double h, + bool forward, const ibex::IntervalVector &u0 = ibex::IntervalVector::empty(1), int contractions = 1, double eps = 0.1); @@ -93,13 +95,14 @@ class LohnerAlgorithm { * \brief Computes an estimation of the global enclosure of the system * * \param initialGuess initial guess for the global enclosure - * \param direction forward or backward in time + * \param dir forward or backward in time * \return estimation of the global enclosure */ - ibex::IntervalVector globalEnclosure(const ibex::IntervalVector &initialGuess, double direction); + ibex::IntervalVector globalEnclosure(const ibex::IntervalVector &initialGuess, double dir); uint dim; //!< dimension of the system's state double h; //!< integration time step + double direction; //!< forward or backward integration double eps; //!< inflation parameter for the global enclosure int contractions; //!< number of contractions of the global enclosure by the estimated local enclosure ibex::IntervalVector u; //!< local enclosure @@ -115,11 +118,13 @@ class LohnerAlgorithm { LohnerAlgorithm::LohnerAlgorithm(const ibex::Function *f, double h, + bool forward, const ibex::IntervalVector &u0, int contractions, double eps) : dim(f->nb_var()), h(h), + direction((forward) ? FWD : BWD), eps(eps), contractions(contractions), u(u0), @@ -140,12 +145,12 @@ const ibex::IntervalVector &LohnerAlgorithm::integrate(unsigned int steps, doubl for (int j = 0; j < contractions; ++j) { z1 = 0.5 * h * h * f->jacobian(u_t) * f->eval_vector(u_t); ibex::Vector m1 = z1.mid(); - ibex::IntervalMatrix A = ibex::Matrix::eye(dim) + h * f->jacobian(u); + ibex::IntervalMatrix A = ibex::Matrix::eye(dim) + h * direction * f->jacobian(u); Eigen::HouseholderQR qr(EigenHelpers::i2e((A * B).mid())); B1 = EigenHelpers::e2i(qr.householderQ()); B1inv = ibex::real_inverse(B1); r1 = (B1inv * A * B) * r + B1inv * (z1 - m1); - u_hat1 = u_hat + h * f->eval_vector(u_hat).mid() + m1; + u_hat1 = u_hat + h * direction * f->eval_vector(u_hat).mid() + m1; u1 = u_hat1 + B1 * r1; if (j < contractions - 1) { u_t = u_t & globalEnclosure(u1, BWD); @@ -156,10 +161,10 @@ const ibex::IntervalVector &LohnerAlgorithm::integrate(unsigned int steps, doubl return u; } -ibex::IntervalVector LohnerAlgorithm::globalEnclosure(const ibex::IntervalVector &initialGuess, double direction) { +ibex::IntervalVector LohnerAlgorithm::globalEnclosure(const ibex::IntervalVector &initialGuess, double dir) { ibex::IntervalVector u_0 = initialGuess; for (unsigned int i = 0; i < 30; ++i) { - ibex::IntervalVector u_1 = initialGuess + direction * ibex::Interval(0, h) * f->eval_vector(u_0); + ibex::IntervalVector u_1 = initialGuess + dir * direction * ibex::Interval(0, h) * f->eval_vector(u_0); if (u_0.is_superset(u_1)) { return u_0; } else { @@ -185,22 +190,20 @@ const ibex::IntervalVector &LohnerAlgorithm::getGlobalEnclosure() const { CtcLohner::CtcLohner(const ibex::Function &f, int contractions, double eps) : DynCtc(), - _x_(ExprSymbol::new_(Dim::col_vec(f.nb_var()))), m_f(f), - m_f_1(_x_, -m_f(_x_)), contractions(contractions), dim(f.nb_var()), eps(eps) {} void CtcLohner::contract(tubex::TubeVector &tube, TimePropag t_propa) { - assert((!tube.is_empty())&&(tube.size() == dim)); + assert((!tube.is_empty()) && (tube.size() == dim)); IntervalVector input_gate(dim, Interval(0)), output_gate(dim, Interval(0)), slice(dim, Interval(0)); double h; if (t_propa & TimePropag::FORWARD) { for (int j = 0; j < dim; ++j) { input_gate[j] = tube[j].slice(0)->input_gate(); } - LohnerAlgorithm lo(&m_f, 0.1, input_gate, contractions, eps); + LohnerAlgorithm lo(&m_f, 0.1, true, input_gate, contractions, eps); // Forward loop for (int i = 0; i < tube.nb_slices(); ++i) { h = tube[0].slice(i)->tdomain().diam(); @@ -218,7 +221,7 @@ void CtcLohner::contract(tubex::TubeVector &tube, TimePropag t_propa) { for (int j = 0; j < dim; ++j) { input_gate[j] = tube[j].last_slice()->output_gate(); } - LohnerAlgorithm lo2(&m_f_1, 0.1, input_gate, contractions, eps); + LohnerAlgorithm lo2(&m_f, 0.1, false, input_gate, contractions, eps); // Backward loop for (int i = tube.nb_slices() - 1; i >= 0; --i) { h = tube[0].slice(i)->tdomain().diam(); @@ -252,7 +255,7 @@ vector CtcLohner::m_str_expected_doms( void CtcLohner::contract(vector &v_domains) { // todo: manage the contractor on a slice level - + if (v_domains.size() != 1) throw DomainsTypeException(m_ctc_name, v_domains, m_str_expected_doms); diff --git a/src/core/contractors/dyn/tubex_CtcLohner.h b/src/core/contractors/dyn/tubex_CtcLohner.h index cc7d1421..b17f3200 100644 --- a/src/core/contractors/dyn/tubex_CtcLohner.h +++ b/src/core/contractors/dyn/tubex_CtcLohner.h @@ -63,9 +63,7 @@ class CtcLohner : public tubex::DynCtc { void contract(std::vector &v_domains) override; protected: - const ibex::ExprSymbol &_x_; //!< symbol for inner litteral function ibex::Function m_f; //!< forward function - ibex::Function m_f_1; //!< backward function int contractions; //!< number of contractions of the global enclosure by the estimated local enclosure int dim; //!< dimension of the state vector double eps; //!< inflation parameter for the global enclosure diff --git a/tests/core/tests_ctc_lohner.cpp b/tests/core/tests_ctc_lohner.cpp index dee43812..3ac3bbd2 100644 --- a/tests/core/tests_ctc_lohner.cpp +++ b/tests/core/tests_ctc_lohner.cpp @@ -65,34 +65,34 @@ TEST_CASE("CtcLohner") { CHECK(x->output_gate().is_superset(Interval(exp(domain.ub())))); } -// SECTION("Test CtcLohner / TubeVector - dim 2") { -// Interval domain(0., 1.); -// -// TubeVector x(domain, 2); -// IntervalVector condition(2, Interval(1.)); -// x.set(condition, 0.); -// -// Function f("x", "y", "(-x ; y)"); -// CtcLohner ctc_lohner(f); -// ctc_lohner.contract(x, TimePropag::FORWARD); -// -// CHECK_FALSE(x.codomain().is_unbounded()); -// // TODO : CHECK(x.codomain()[0].is_superset(exp(-domain))); -// CHECK(x(0.)[0].is_superset(Interval(exp(-0.)))); -// CHECK(x(1.)[0].is_superset(Interval(exp(-1.)))); -// // TODO : CHECK(x.codomain()[1].is_superset(exp(domain))); -// CHECK(x(0.)[1].is_superset(Interval(exp(0.)))); -// CHECK(x(1.)[1].is_superset(Interval(exp(1.)))); -// -// //if(false & VIBES_DRAWING) // drawing results -// //{ -// // vibes::beginDrawing(); -// // VIBesFigTube fig_tube("picard", &x); -// // fig_tube.set_properties(100, 100, 500, 500); -// // fig_tube.show(true); -// // vibes::endDrawing(); -// //} -// } + SECTION("Test CtcLohner / TubeVector - dim 2") { + Interval domain(0., 1.); + double dt = 0.1; + TubeVector x(domain, dt, 2); + IntervalVector condition(2, Interval(1.)); + x.set(condition, 0.); + + Function f("x", "y", "(-x ; y)"); + CtcLohner ctc_lohner(f); + ctc_lohner.contract(x, TimePropag::FORWARD); + + CHECK_FALSE(x.codomain().is_unbounded()); + // TODO : CHECK(x.codomain()[0].is_superset(exp(-domain))); + CHECK(x(0.)[0].is_superset(Interval(exp(-0.)))); + CHECK(x(1.)[0].is_superset(Interval(exp(-1.)))); + // TODO : CHECK(x.codomain()[1].is_superset(exp(domain))); + CHECK(x(0.)[1].is_superset(Interval(exp(0.)))); + CHECK(x(1.)[1].is_superset(Interval(exp(1.)))); + + //if(false & VIBES_DRAWING) // drawing results + //{ + // vibes::beginDrawing(); + // VIBesFigTube fig_tube("picard", &x); + // fig_tube.set_properties(100, 100, 500, 500); + // fig_tube.show(true); + // vibes::endDrawing(); + //} + } SECTION("Test CtcLohner / TubeVector - dim 1 - forward") { Interval domain(0., 1.);