slp 0.1.6

SolHOP Linear Programming Solver
Documentation
# slp

SolHOP Linear Programming Solver.

[![Crates.io](https://img.shields.io/crates/v/slp.svg)](https://crates.io/crates/slp)
[![Crates.io](https://img.shields.io/crates/d/slp.svg)](https://crates.io/crates/slp)
![Crates.io](https://img.shields.io/crates/l/slp)
[![Docs](https://docs.rs/slp/badge.svg)](https://docs.rs/slp)
[![Build Status](https://dev.azure.com/solhop/slp/_apis/build/status/solhop.slp?branchName=master)](https://dev.azure.com/solhop/slp/_build/latest?definitionId=1&branchName=master)
[![Coverage Status](https://coveralls.io/repos/github/solhop/slp/badge.svg?branch=master)](https://coveralls.io/github/solhop/slp?branch=master)

Currently, the simplex method is implemented.
Soon ILP and MIP will be supported.

This projetct is still in development.
The APIs can change a lot before the first stable release v1.0.0.

## Install and Run

### Install

```sh
cargo install slp
```

### Help

```sh
$ slp --help
slp 0.1.6
SolHOP Linear Programming Solver

USAGE:
    slp [FLAGS] <file>

FLAGS:
    -h, --help        Prints help information
    -p, --parallel    Enable data parallelism
    -r, --rat64       Use Rational64
    -V, --version     Prints version information

ARGS:
    <file>    Input file
```

### Usage

```sh
slp input.txt
```

where `input.txt` contains the LP instance to be solved.

If no file is provided then input is taken from `stdin`.

To enable data parallelism use `-p` flag.

```sh
slp input.txt -p
```

## Input format

The input is provided throught `stdin`.

An example of LP instance is

```txt
max        2x1 + 3x2
subject to 2x1 +  x2 <= 18
           6x1 + 5x2 <= 60
           2x1 + 5x2 <= 40
            x1       >= 0
            x2       >= 0
```

The corresponding input format is

```txt
3 2 # 3 is number of constraints and 2 is number of variables
2 3 # coefficients of objective function to be maximized: 2x1 + 3x2
2 1 18 # Constraint 1: 2x1 +  x2 <= 18
6 5 60 # Constraint 2: 6x1 + 5x2 <= 60
2 5 40 # Constraint 3: 2x1 + 5x2 <= 40
# x1 >= 0 and x2 >= 0 are always assumed
```

## Output format

The output of the `slp` solver is sent to `stdout` and it can be one of the following:

```txt
INFEASIBLE
```

or

```txt
UNBOUNDED
```

or

```txt
OPTIMAL 28
SOLUTION 5 6
```

representing the objective value to be `28` and the solution as `x1 = 5, x2 = 6`.

## Support for Rational LP Solver

To use Rational64 numbers, use `-r` flag.

Input:

```txt
3 2
-6 -3
-1 -1 -1
-2 1 -1
0 3 2
```

Output when run using command `rsat input.txt`:

```txt
OPTIMAL -5
SOLUTION 0.6666666666666666 0.33333333333333337
```

Output when run using command `rsat -r input.txt`:

```txt
OPTIMAL -5
SOLUTION 2/3 1/3
```

## License

[MIT](LICENSE)