Skip to content
Go to file

Build Status Build status Conda_Statux

Ibex python binding


pyIbex is a python binding of ibex-lib. It aims at providing a basic interface of Ibex types (Interval, IntervalVector, Function, Ctc, Sep, ...), and high level functionalities such as contractors and separators programming.

It uses pybind11 to link C++ code to python. It contains core functionalities of ibex and additional modules:

  • geometry to deal with geometrical constraints
    • Polygon separator "SepPolygon" article
    • Separator transformation "SepTransform"
    • Sepatator fix point "SepFixPpoint"
    • Polar contractor and separators "CtcPolar, SepPolarXY" article

See pyibex website for more informations.

Install with a precompiled version using pip

With pip

>>> python -m pip install pyibex

try it.

A set of example can be found in the pyibex/example directory. to run them enter:

>>> python -m pyibex.example.main

Build From Source



The build process is entirely based on cmake with the following options:

- use -DCMAKE_INSTALL_PREFIX= to change the install destination
- use -DCMAKE_BUILD_TYPE=DEBUG | RELEASE to change the compilation mode
- use -DIBEX_ROOT= if ibex is installed in a non-standard directory
  • use -DPYTHON_VERSION= to set the target python version.

Sometime, you will have to manually specify python executable, include and libs directory using:

-using -DPYTHON_EXECUTABLE to specify python executable path.

Alternatively, run the provided script/ script. remark : If Ibex isn't installed on the current machine, it will be downloaded, build and installed.

remark : Ibex must be compuled with the -fPIC option

Linux/Mac OS X

If ibex-lib is not installed

git clone -b develop
cd ibex-lib
mkdir build && cd build
make && make check && make install

To install pyIbex run the following commands:

git clone
cd pyIbex
git submodule init
mkdir -p build && cd build
make && make test
# generate the python package
make pip_package
# or go to the package directory and install in dev mode
cd ./src/python_package
python ./ develop

###For Windows Users (Win64 version) (Not ready Yet)

  • Build Ibex Open the developer command prompt and compile ibex-lib
git clone -b with_cmake
cd ibex-lib
mkdir build
cd build
cmake -G "Visual Studio 12 2013 Win64" -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF ../
msbuild /P:Configuration=Release /p:RuntimeLibrary=MT_StaticRelease PACKAGE.vcxproj

The last command generates a installer for ibex-lib

cd pyIbex
mkdir build
cd build
cmake -G "Visual Studio 12 2013 Win64" -DIBEX_ROOT=$$$$$$$$ -DPYTHON_EXECUTABLE=$$$$$$$$ ../
msbuild /P:Configuration=Release /p:RuntimeLibrary=MT_StaticRelease INSTALL.vcxproj


###Basic types manipulation

# Load pyIbex lib
from pyIbex import *

# Create new Intervals
a = Interval.EMPTY_SET
a = Interval.ALL_REALS
a  = Interval(-2, 3)

# Create IntervalVector
b = IntervalVector( 2, a)
c = IntervalVector([1,2,3])
d = IntervalVector([[-1,3], [3,10], [-3, -1]])

e = IntervalVector( (a, Interval(-1,0), Interval(0)) )

# Operations
e = c & d
e = c+d
e = a * c

###Functions and contractors manipulation

# Define a Function from an equation
f = Function("x", "y", "x^2 + y^2 - 3")

# FwdBwd Contractor
ctc1 = CtcFwdBwd(f, CmpOp.LEQ, FwdMode.AFFINE_MODE)

# CtcIn/CtcOut contractors :math:`$f \in [-2.5, 3.5]$`
ctcIn = CtcIn(f, Interval(3).inflate(0.5))
ctcOut = CtcNotIn(f, Interval(3).inflate(0.5))

# Operations on Contractors
# composition of two contractor
ctc = ctcIn & ctcOut
# union of a python list of contractors
ctc1 = CtcUnion([ctcIn, ctcOut, ctc1])
You can’t perform that action at this time.