Skip to content

catsupfish/pyIbex

 
 

Repository files navigation

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

About

A Python binding for ibex-lib

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 48.5%
  • Python 37.2%
  • CMake 13.1%
  • Shell 1.2%