Metadata-Version: 2.1
Name: pyCIAP
Version: 0.0.2
Summary: A simple package the solve CIAPs with dwell time constraints
Home-page: https://github.com/jhelgert/pyCIAP
Author: Jonathan Helgert
Author-email: jhelgert@mail.uni-mannheim.de
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: numpy


# pyCIAP

![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/jhelgert/pyCIAP)

This a tiny package to solve the Combinatorial Integral Approximation Problem (CIAP)
including dwell-time constraints by a dwell-time sum-up rounding algorithm, see [1]
for the theoretical results.

## Install

Thanks to to the wheels, you can install the package like this

```
pip3 install pyCIAP
```


Alternatively, you can build and install from source 

``` 
pip3 install git+https://github.com/jhelgert/pyCIAP
```

However, note that the latter requires Cython and a installed C++ compiler.

## Example:

``` python
from pyCIAP import DSUR, solveCIAPMDT
import numpy as np

# Relaxed control fulfilling SOS1-constraint
b_rel = np.array([[
    0.47131227, 0.78736104, 0.97325193, 0.53496864, 
    0.73187786, 0.07838749, 0.48948843, 0.64580892],
    [0.52868773, 0.21263896, 0.02674807, 0.46503136, 
    0.26812214, 0.92161251, 0.51051157, 0.35419108]])

# time grid
dt = 1.0
time = np.arange(0, b_rel.shape[1], dt)

# Computes a binary control fulfilling the minimum dwell times
# The dwell times are always in number of time steps, i.e. multiples of dt
b_bin = DSUR(b_rel, 1.0, time, min_up_time=3, min_down_time=3)
```
gives

``` python
array([[1, 1, 1, 0, 0, 0, 1, 1],
       [0, 0, 0, 1, 1, 1, 0, 0]])
```

In order to compare the DSUR solution to the global optimum, one can
solve the CIAP by Gurobi and use the solution as MIP start:

``` python
runtime, eps_opt, eps_dsur = solveCIAPMDT(b_rel, dt, 3, 3, start_sol=b_bin)
```

Here `eps_opt` and `eps_dsur` denote the objective values of the corresponding
CIAP, i.e. the *integrality gap*.

[1]: https://link.springer.com/article/10.1007/s10107-020-01533-x


