codac 1.5.6
Loading...
Searching...
No Matches
codac2_pave.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include "codac2_Paving.h"
13#include "codac2_Ctc.h"
14#include "codac2_Sep.h"
16
17namespace codac2
18{
19 // eps: accuracy of the paving algorithm, the undefined boxes will have their max_diam <= eps
20
21 PavingOut pave(const IntervalVector& x, std::shared_ptr<const CtcBase<IntervalVector>> c, double eps, bool verbose = false);
22 PavingOut pave(const IntervalVector& x, const CtcBase<IntervalVector>& c, double eps, bool verbose = false);
23 PavingInOut pave(const IntervalVector& x, std::shared_ptr<const SepBase> s, double eps, bool verbose = false);
24 PavingInOut pave(const IntervalVector& x, const SepBase& s, double eps, bool verbose = false);
25
26 template<typename Y>
27 PavingInOut sivia(const IntervalVector& x, const AnalyticFunction<Y>& f, const typename Y::Domain& y, double eps, bool verbose = false)
28 {
29 clock_t t_start = clock();
30
31 PavingInOut p(x);
32 std::list<std::shared_ptr<PavingInOut_Node>> l { p.tree() };
33
34 while(!l.empty())
35 {
36 auto n = l.front();
37 l.pop_front();
38
39 assert(n->is_leaf());
40 auto eval = f.eval(std::get<1>(n->boxes()));
41
42 if(eval.is_subset(y))
43 std::get<1>(n->boxes()).set_empty();
44
45 else if(!eval.intersects(y))
46 std::get<0>(n->boxes()).set_empty();
47
48 else if(n->unknown().max_diam() > eps)
49 {
50 n->bisect();
51 l.push_back(n->left());
52 l.push_back(n->right());
53 }
54 }
55
56 if(verbose)
57 printf("Computation time: %.4fs\n", (double)(clock()-t_start)/CLOCKS_PER_SEC);
58 return p;
59 }
60}