Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[examples] added simple tube paving (1d)
- Loading branch information
1 parent
0996ca9
commit bed28ab
Showing
7 changed files
with
184 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# ================================================================== | ||
# codac / basics example - cmake configuration file | ||
# ================================================================== | ||
|
||
cmake_minimum_required(VERSION 3.0.2) | ||
project(codac_basics_08 LANGUAGES CXX) | ||
|
||
# Adding IBEX | ||
|
||
# In case you installed IBEX in a local directory, you need | ||
# to specify its path with the CMAKE_PREFIX_PATH option. | ||
# set(CMAKE_PREFIX_PATH "~/ibex-lib/build_install") | ||
|
||
find_package(IBEX REQUIRED) | ||
ibex_init_common() # IBEX should have installed this function | ||
message(STATUS "Found IBEX version ${IBEX_VERSION}") | ||
|
||
# Adding Eigen3 | ||
|
||
# In case you installed Eigen3 in a local directory, you need | ||
# to specify its path with the CMAKE_PREFIX_PATH option, e.g. | ||
# set(CMAKE_PREFIX_PATH "~/eigen/build_install") | ||
|
||
find_package(Eigen3 REQUIRED NO_MODULE) | ||
message(STATUS "Found Eigen3 version ${EIGEN3_VERSION}") | ||
|
||
# Adding Codac | ||
|
||
# In case you installed Codac in a local directory, you need | ||
# to specify its path with the CMAKE_PREFIX_PATH option. | ||
# set(CMAKE_PREFIX_PATH "~/codac/build_install") | ||
|
||
find_package(CODAC REQUIRED) | ||
message(STATUS "Found Codac version ${CODAC_VERSION}") | ||
|
||
# Compilation | ||
|
||
add_executable(${PROJECT_NAME} main.cpp) | ||
target_compile_options(${PROJECT_NAME} PUBLIC ${CODAC_CXX_FLAGS}) | ||
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${CODAC_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS}) | ||
target_link_libraries(${PROJECT_NAME} PUBLIC ${CODAC_LIBRARIES} Ibex::ibex ${CODAC_LIBRARIES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# ================================================================== | ||
# tubex-lib - build script | ||
# ================================================================== | ||
|
||
#!/bin/bash | ||
|
||
mkdir build -p | ||
cd build | ||
cmake .. | ||
make | ||
cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* Codac - Examples | ||
* Tube paving | ||
* ---------------------------------------------------------------------------- | ||
* | ||
* \brief Tube paving | ||
* \date 2021 | ||
* \author Simon Rohou | ||
* \copyright Copyright 2021 Codac Team | ||
* \license This program is distributed under the terms of | ||
* the GNU Lesser General Public License (LGPL). | ||
*/ | ||
|
||
#include <codac.h> | ||
|
||
using namespace std; | ||
using namespace codac; | ||
|
||
class TemporalPaving : public Paving | ||
{ | ||
public: | ||
|
||
TemporalPaving(const IntervalVector& init_box) : Paving(init_box, SetValue::UNKNOWN) | ||
{ | ||
|
||
} | ||
|
||
void compute(float precision, const Tube& x) | ||
{ | ||
assert(precision > 0.); | ||
const Interval& t = box()[0], &y = box()[1]; | ||
|
||
if(!x(t).intersects(y)) | ||
return set_value(SetValue::OUT); | ||
|
||
pair<Interval,Interval> p = x.eval(t); | ||
|
||
if((p.first == NEG_INFINITY || p.first.ub() < y.lb()) | ||
&& (p.second == POS_INFINITY || p.second.lb() > y.ub())) | ||
return set_value(SetValue::IN); | ||
|
||
if(box().max_diam() < precision) | ||
return set_value(SetValue::UNKNOWN); | ||
|
||
else | ||
{ | ||
bisect(); | ||
((TemporalPaving*)m_first_subpaving)->compute(precision, x); | ||
((TemporalPaving*)m_second_subpaving)->compute(precision, x); | ||
} | ||
} | ||
}; | ||
|
||
int main() | ||
{ | ||
float dt = 0.005; | ||
Interval tdomain(0,6); | ||
Tube x(tdomain, dt, TFunction("sin(t)+(t+1)*[-0.1,0.1]")); | ||
x.set(Interval(-1.6,1.6),Interval(3,4)); | ||
|
||
clock_t t_start = clock(); | ||
TemporalPaving paving(IntervalVector({{-1,7},{-2,2}})); | ||
x.enable_synthesis(true); | ||
paving.compute(dt*2.,x); | ||
printf("Paving computation time: %.2fs\n", (double)(clock() - t_start)/CLOCKS_PER_SEC); | ||
|
||
vibes::beginDrawing(); | ||
VIBesFigPaving fig_paving("Paving", &paving); | ||
fig_paving.set_properties(100, 100, 800, 400); | ||
fig_paving.show(); | ||
vibes::endDrawing(); | ||
|
||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters