A Python binding for ibex-lib
C++ Python CMake Shell
Clone or download
Latest commit 2780dc9 Mar 12, 2018
Permalink
Failed to load latest commit information.
CMakeModules
doc [doc] update Mar 12, 2018
docs [doc] update website Mar 12, 2018
pybind11 @ b48d4a0 [fix] update pyibex and version number Jan 31, 2018
pyibex [build] minor changes for CI tests Feb 25, 2018
src
travis_script [master] add upload script for travis Oct 23, 2016
.gitignore [pre_v1.5] add examples Jul 8, 2016
.gitmodules [master] update pybind11 base repository Oct 22, 2016
.travis.yml [build] minor changes for CI tests Feb 25, 2018
CMakeLists.txt [release] v1.6.4 Feb 25, 2018
LICENSE
README.md [doc] update doc for version 1.6.4 Mar 6, 2018
appveyor.yml [pre_v1.6.3] update pybind11 to version 2.2.1 Oct 26, 2017
changelog [install] add vibes requirement (for iamooc) Mar 12, 2018
install.sh

README.md

Build Status Build status Conda_Statux

Ibex python binding


Introduction

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

Dependancies

###Building

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 install.sh script. remark : If Ibex isn't installed on the current machine, it will be downloaded, build and installed.

Linux/Mac OS X


To install pyIbex run the following commands:

git clone https://github.com/benEnsta/pyIbex.git
cd pyIbex
git submodule init
mkdir -p build && cd build
make
# if pip is installed run
make install_python
# otherwise
make install

If you used a non stantdart install preifx (-DCMAKE_INSTALL_PREFIX), add ${PREFIX}/lib/python3/dist-packages to your PYTHONPATH

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

  • Build Ibex Open the developer command prompt and compile ibex-lib
git clone -b with_cmake https://github.com/benEnsta/ibex-lib.git
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

Tutorial

###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])