MC++
mcprofil.hpp
1 // Copyright (C) 2009-2013 Benoit Chachuat, Imperial College London.
2 // All Rights Reserved.
3 
4 #ifndef MC__MCPROFIL_HPP
5 #define MC__MCPROFIL_HPP
6 
7 #include "mcop.hpp"
8 #include "mcfunc.hpp"
9 #include <Interval.h>
10 #include <Functions.h>
11 #include <Constants.h>
12 namespace mc
13 {
15 template <> struct Op< ::INTERVAL >
16 {
17  typedef ::INTERVAL T;
18  static T point( const double c ) { return T(c); }
19  static T zeroone() { return T(0.,1.); }
20  static void I(T& x, const T& y) { x = y; }
21  static double l(const T& x) { return ::Inf(x); }
22  static double u(const T& x) { return ::Sup(x); }
23  static double abs (const T& x) { return ::Abs(x); }
24  static double mid (const T& x) { return ::Mid(x); }
25  static double diam(const T& x) { return ::Diam(x); }
26  static T inv (const T& x) { return T(1.)/x; }
27  static T sqr (const T& x) { return ::Sqr(x); }
28  static T sqrt(const T& x) { return ::Sqrt(x); }
29  static T log (const T& x) { return ::Log(x); }
30  static T xlog(const T& x) { return T( ::Pred(mc::xlog(mc::mid(::Inf(x),::Sup(x),std::exp(-1.)))), ::Succ(std::max(mc::xlog(::Inf(x)),mc::xlog(::Sup(x)))) ); }
31  static T fabs(const T& x) { return T(::Pred(mc::mid(::Inf(x),::Sup(x),0.)),::Succ(::Abs(x))); }
32  static T exp (const T& x) { return ::Exp(x); }
33  static T sin (const T& x) { return ::Sin(x); }
34  static T cos (const T& x) { return ::Cos(x); }
35  static T tan (const T& x) { return ::Tan(x); }
36  static T asin(const T& x) { return ::ArcSin(x); }
37  static T acos(const T& x) { return ::ArcCos(x); }
38  static T atan(const T& x) { return ::ArcTan(x); }
39  static T hull(const T& x, const T& y) { return ::Hull(x,y); }
40  static T min (const T& x, const T& y) { return T( ::Pred(std::min(::Inf(x),::Inf(y))), ::Succ(std::min(::Sup(x),::Sup(y))) ); }
41  static T max (const T& x, const T& y) { return T( ::Pred(std::max(::Inf(x),::Inf(y))), ::Succ(std::max(::Sup(x),::Sup(y))) ); }
42  static T arh (const T& x, const double k) { return ::Exp(-x/k); }
43  template <typename X> static T pow(const X& x, const int n) { return( (n>=3&&n%2)? ::Hull(::Power(Inf(x),n),::Power(Sup(x),n)): ::Power(x,n) ); }
44  template <typename X, typename Y> static T pow(const X& x, const Y& y) { return ::Power(x,y); }
45  static T monomial (const unsigned int n, const T* x, const int* k) { return n? ::Power(x[0], k[0]) * monomial( n-1, x+1, k+1 ): 1.; }
46  static bool inter(T& xIy, const T& x, const T& y) { return ::Intersection(xIy,x,y); }
47  static bool eq(const T& x, const T& y) { return x==y; }
48  static bool ne(const T& x, const T& y) { return x!=y; }
49  static bool lt(const T& x, const T& y) { return x<y; }
50  static bool le(const T& x, const T& y) { return x<=y; }
51  static bool gt(const T& x, const T& y) { return y<x; }
52  static bool ge(const T& x, const T& y) { return y<=x; }
53 };
54 
55 } // namespace mc
56 
57 #endif
C++ structure to allow usage of various template parameters in the types mc::McCormick, mc::TModel, mc::TVar, and mc::SpecBnd of MC++ _ Specialization of this structure is required for the template parameters can be found in the header files defining the types mc::McCormick, mc::TModel, mc::TVar, and mc::SpecBnd.
Definition: mcop.hpp:13