MC++
Non-Verified Interval Arithmetic for Factorable Functions
Author
Benoît Chachuat

Computational methods for enclosing the range of functions find their origins in interval analysis back in the early 1960s [Moore, 1966; Moore et al., 2009]. For functions whose expressions can be broken down into a finite number of elementary unary and binary operations, namely factorable functions, interval bounding can be readily automated. The class mc::Interval provides a basic implementation of interval arithmetic, which is not a verified implementation in the sense that rounding errors are not accounted for. For verified interval computations, it is strongly recommended to use third-party libraries such as PROFIL or FILIB++.

The implementation of mc::Interval relies on the operator/function overloading mechanism of C++. This makes the computation of bounds both simple and intuitive, similar to computing function values in real arithmetics. Moreover, mc::Interval can be used as the underlying interval type in other classes of MC++ via templates; e.g., mc::McCormick<mc::Interval>, mc::TModel<mc::Interval>, mc::TVar<mc::Interval>.

How do I compute interval bounds on the range of a factorable function?

Suppose we want to calculate bounds on the range of the real-valued function \(f(x,y)=x(\exp(x)-y)^2\) for \((x,y)\in [-2,1]^2\).

First, we shall define the variables \(x\) and \(y\). This is done as follows:

#include "interval.hpp"
typedef mc::Interval I;
I X( -2., 1. );
I Y( -2., 1. );

Essentially, the last two lines mean that X and Y are variable of type mc::Interval, both defined as \([-2,1]\).

Having defined the variables, bounds on the range of \(f\) on \([-2,1]^2\) are simply calculated as

I F = X*pow(exp(X)-Y,2);

These bounds can be displayed to the standard output as:

std::cout << "F bounds: " << F << std::endl;

which produces the following output:

F bounds: [ -4.45244e+01 :  2.22622e+01 ] 

Moreover, the upper and lower bounds in the interval bound F can be retrieved as:

double Fl = IF.l();
double Fu = IF.u();

exp,

Which functions are overloaded in mc::Interval?

mc::Interval overloads the usual functions exp, log, sqr, sqrt, pow, inv, cos, sin, tan, acos, asin, atan, erf, erfc, min, max, fabs. mc::Interval also defines the following functions:

  • inter(Z,X,Y), computing the intersection \(Z = X\cap Y\) and returning true/false if the intersection is nonempty/empty
  • hull(X,Y), returning the interval hull of \(X\cup Y\)
  • diam(X), returning the diameter of \(X\)
  • mid(X), returning the mid-point of \(X\)
  • abs(X), returning the absolute value of \(X\)

What are the options in mc::Interval and how are they set?

The class mc::Interval has a public static member called mc::Interval::options that can be used to set/modify the options; e.g.,

mc::Interval::options.DISPLAY_DIGITS = 7;

The available options are as follows:

Options in mc::Interval::Options: name, type and description
Name TypeDefault Description
DISPLAY_DIGITS unsigned int 5 Number of digits in output stream

What errors can be encountered in using mc::Interval?

Errors are managed based on the exception handling mechanism of the C++ language. Each time an error is encountered, a class object of type Interval::Exceptions is thrown, which contains the type of error.

Possible errors encountered in using mc::Interval are:

Exceptions in mc::Interval
Number Description
1 Division by zero
2 Inverse with zero in range
3 Log with negative values in range
4 Square-root with nonpositive values in range
5 Inverse cosine with values outside of [-1,1] range
6 Inverse sine with values outside of [-1,1] range
7 Tangent with values \(\frac{\pi}{2}+k\,\pi\), with \(k\in\mathbb{Z}\), in range

References