codac 2.0.0
Loading...
Searching...
No Matches
codac2_CtcQInter.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <type_traits>
13#include "codac2_qinter.h"
14#include "codac2_CtcWrapper.h"
15#include "codac2_Collection.h"
17
18namespace codac2
19{
20 class CtcQInter : public Ctc<CtcQInter,IntervalVector>
21 {
22 public:
23
24 // q is the maximum number of constraints that may be violated.
25 CtcQInter(unsigned int q, const Collection<CtcBase<IntervalVector>>& c)
26 : Ctc<CtcQInter,IntervalVector>([&c]() {
27 assert_release(!c.empty());
28 Index n = size_of(c.front());
29 for(const auto& s : c) {
30 (void)s;
31 assert_release(size_of(s) == n && "all contractors must be of same size");
32 }
33 return n;
34 }()), _q(q), _ctcs(c)
35 {
36 assert_release(q <= c.size());
37 }
38
39 // q is the maximum number of constraints that may be violated.
40 explicit CtcQInter(unsigned int q, Index n, const Collection<CtcBase<IntervalVector>>& ctcs = {})
41 : Ctc<CtcQInter,IntervalVector>(n), _q(q), _ctcs(ctcs)
42 {
43 std::cout << "CtcQInter::CtcQInter(unsigned int q, Index n, ..) is deprecated." << std::endl;
44 std::cout << "Use CtcQInter::CtcQInter(unsigned int q, ..) instead." << std::endl;
45 assert_release(n > 0);
46 assert_release(q <= ctcs.size());
47 }
48
49 template<typename C>
50 requires (IsCtcBaseOrPtr<C,IntervalVector> && !std::is_same_v<CtcQInter,C>)
51 CtcQInter(unsigned int q, const C& c)
52 : CtcQInter(q, {c})
53 { }
54
55 template<typename... C>
56 requires (IsCtcBaseOrPtr<C,IntervalVector> && ...)
57 CtcQInter(unsigned int q, const C&... c)
58 : CtcQInter(q, {c...})
59 { }
60
61 size_t nb() const;
62
63 void contract(IntervalVector& x) const;
64
65 protected:
66
67 size_t _q;
68 Collection<CtcBase<IntervalVector>> _ctcs;
69 };
70}
Definition codac2_OctaSym.h:21
Eigen::Matrix< Interval,-1, 1 > IntervalVector
Alias for a dynamic-size column vector of intervals.
Definition codac2_IntervalVector.h:25