23 using SetValuesMap = std::map<ExprID,std::shared_ptr<SepBase>>;
29 SetExpr& operator=(
const SetExpr& x) =
delete;
30 virtual std::shared_ptr<CtcBase<IntervalVector>> create_ctc(
const FunctionArgsList& args,
const std::vector<std::shared_ptr<CtcBase<IntervalVector>>>& x)
const = 0;
31 virtual std::shared_ptr<SepBase> create_sep(
const FunctionArgsList& args,
const std::vector<std::shared_ptr<SepBase>>& x)
const = 0;
33 virtual bool belongs_to_args_list(
const FunctionArgsList& args)
const = 0;
36 template<
typename C,
typename... X>
41 SetOperationExpr(std::shared_ptr<X>... x)
45 SetOperationExpr(
const SetOperationExpr<C,X...>& e)
49 std::shared_ptr<ExprBase> copy()
const
51 return std::make_shared<SetOperationExpr<C,X...>>(*this);
54 void replace_arg(
const ExprID& old_arg_id,
const std::shared_ptr<ExprBase>& new_expr)
59 virtual bool belongs_to_args_list(
const FunctionArgsList& args)
const
63 std::apply([&b,args](
auto &&... x)
65 ((b &= x->belongs_to_args_list(args)), ...);
71 std::shared_ptr<CtcBase<IntervalVector>> create_ctc(
const FunctionArgsList& args,
const std::vector<std::shared_ptr<CtcBase<IntervalVector>>>& values)
const
74 [
this,values,args](
auto &&... x)
76 return C::create_ctc(x->create_ctc(args,values)...);
81 std::shared_ptr<SepBase> create_sep(
const FunctionArgsList& args,
const std::vector<std::shared_ptr<SepBase>>& values)
const
84 [
this,values,args](
auto &&... x)
86 return C::create_sep(x->create_sep(args,values)...);
93 class SetOperationExpr<ProjSetOp,SetExpr> :
public SetExpr,
public OperationExprBase<SetExpr>
97 SetOperationExpr(std::shared_ptr<SetExpr> x,
const std::vector<Index>& proj_indices,
double eps)
98 :
OperationExprBase<SetExpr>(x), _proj_indices(proj_indices), _y(nullptr), _eps(eps)
101 SetOperationExpr(std::shared_ptr<SetExpr> x,
const std::vector<Index>& proj_indices,
const IntervalVector& y,
double eps)
102 :
OperationExprBase<SetExpr>(x), _proj_indices(proj_indices), _y(std::make_shared<IntervalVector>(y)), _eps(eps)
105 SetOperationExpr(
const SetOperationExpr& e)
106 :
OperationExprBase<SetExpr>(e), _proj_indices(e._proj_indices), _y(e._y), _eps(e._eps)
109 std::shared_ptr<ExprBase> copy()
const
111 return std::make_shared<SetOperationExpr<ProjSetOp,SetExpr>>(*this);
114 void replace_arg(
const ExprID& old_arg_id,
const std::shared_ptr<ExprBase>& new_expr)
119 virtual bool belongs_to_args_list(
const FunctionArgsList& args)
const
121 return std::get<0>(this->
_x)->belongs_to_args_list(args);
124 std::shared_ptr<CtcBase<IntervalVector>> create_ctc(
const FunctionArgsList& args,
const std::vector<std::shared_ptr<CtcBase<IntervalVector>>>& values)
const
126 throw std::logic_error(
"CtcProj not yet available");
130 std::shared_ptr<SepBase> create_sep(
const FunctionArgsList& args,
const std::vector<std::shared_ptr<SepBase>>& values)
const
133 return ProjSetOp::create_sep(std::get<0>(this->
_x)->create_sep(args,values), _proj_indices, *_y, _eps);
135 return ProjSetOp::create_sep(std::get<0>(this->
_x)->create_sep(args,values), _proj_indices, _eps);
140 const std::vector<Index> _proj_indices;
141 const std::shared_ptr<IntervalVector> _y;
146 class SetOperationExpr<InverseSetOp,SetExpr> :
public SetExpr,
public OperationExprBase<SetExpr>
150 SetOperationExpr(
const AnalyticFunction<VectorType>& f, std::shared_ptr<SetExpr> x)
154 SetOperationExpr(
const SetOperationExpr& e)
158 std::shared_ptr<ExprBase> copy()
const
160 return std::make_shared<SetOperationExpr<InverseSetOp,SetExpr>>(*this);
163 void replace_arg(
const ExprID& old_arg_id,
const std::shared_ptr<ExprBase>& new_expr)
168 virtual bool belongs_to_args_list(
const FunctionArgsList& args)
const
170 return std::get<0>(this->
_x)->belongs_to_args_list(args);
173 std::shared_ptr<CtcBase<IntervalVector>> create_ctc(
const FunctionArgsList& args,
const std::vector<std::shared_ptr<CtcBase<IntervalVector>>>& values)
const
175 return InverseSetOp::create_ctc(_f, std::get<0>(this->
_x)->create_ctc(args,values));
178 std::shared_ptr<SepBase> create_sep(
const FunctionArgsList& args,
const std::vector<std::shared_ptr<SepBase>>& values)
const
180 return InverseSetOp::create_sep(_f, std::get<0>(this->
_x)->create_sep(args,values));
185 const AnalyticFunction<VectorType> _f;
189 class SetOperationExpr<ActionSetOp,SetExpr> :
public SetExpr,
public OperationExprBase<SetExpr>
193 SetOperationExpr(
const OctaSym& a, std::shared_ptr<SetExpr> x)
197 SetOperationExpr(
const SetOperationExpr& e)
201 std::shared_ptr<ExprBase> copy()
const
203 return std::make_shared<SetOperationExpr<ActionSetOp,SetExpr>>(*this);
206 void replace_arg(
const ExprID& old_arg_id,
const std::shared_ptr<ExprBase>& new_expr)
211 virtual bool belongs_to_args_list(
const FunctionArgsList& args)
const
213 return std::get<0>(this->
_x)->belongs_to_args_list(args);
216 std::shared_ptr<CtcBase<IntervalVector>> create_ctc(
const FunctionArgsList& args,
const std::vector<std::shared_ptr<CtcBase<IntervalVector>>>& values)
const
218 return ActionSetOp::create_ctc(_a, std::get<0>(this->
_x)->create_ctc(args,values));
221 std::shared_ptr<SepBase> create_sep(
const FunctionArgsList& args,
const std::vector<std::shared_ptr<SepBase>>& values)
const
223 return ActionSetOp::create_sep(_a, std::get<0>(this->
_x)->create_sep(args,values));
Abstract base class for representing an expression.
Definition codac2_ExprBase.h:85
A base class for expressions representing operations with multiple operands.
Definition codac2_ExprBase.h:164
void replace_arg(const ExprID &old_arg_id, const std::shared_ptr< ExprBase > &new_expr)
Replaces a variable by a new expression.
Definition codac2_ExprBase.h:209
OperationExprBase(std::shared_ptr< X >... x)
Definition codac2_ExprBase.h:176
std::tuple< std::shared_ptr< X >... > _x
Definition codac2_ExprBase.h:258