Getting Started

What follows is a guide for installing yaposib very quickly and solve your first linear program using it.


Alternative: development version

  1. Follow 1., 2. and 3. from the previous method
  2. Clone the repository
git clone
  1. Run
cd yaposib
sudo python install

Checking your installation

The utility yaposib-config is a helper script that helps you determine if your installation went fine. Run it without any argument.


This tool runs the yaposib test suite on every solvers that you Osi build reportedly supports. Since not all solvers behave equivalently, some tests might fail with some solvers, and succeed with others. A failure does not necessarily means that yaposib is completely unusable with your solver, it might simply mean that it was not tested yet combined with your solver. Please report any failures on the bugtracker.

Code samples

Let’s dive into the code. Here is an example program that illustrates some features of yaposib:

builds the following problem

0  <= x <= 4
-1 <= y <= 1
0  <= z
0  <= w

minimize obj = x + 4*y + 9*z
such that:
c1: x+y <= 5
c2: x+z >= 10
c3: -y+z == 7
c4: w >= 0
import yaposib

prob = yaposib.Problem("Clp")

obj = prob.obj = "MyProblem"
obj.maximize = False

# names
cols = prob.cols
for var_name in ["x", "y", "z", "w"]:
    col = cols.add(yaposib.vec([])) = var_name
# lowerbounds
for col in cols:
    col.lowerbound = 0
cols[1].lowerbound = -1
# upperbounds
cols[0].upperbound = 4
cols[1].upperbound = 1
# constraints
rows = prob.rows
# constraints bounds
rows[0].upperbound = 5
rows[1].lowerbound = 10
rows[2].lowerbound = 7
rows[2].upperbound = 7
rows[3].lowerbound = 0
# constraints names
for row, name in zip(rows, ["c1", "c2", "c3", "c4"]): = name

# obj
prob.obj[0] = 1
prob.obj[1] = 4
prob.obj[2] = 9


for col in prob.cols:
    print("%s=%s" % (, col.solution))

It is also easy to write a generic command line solver in a few lines of code. The following script is part of the yaposib distribution and is shipped as the command line utility yaposib-solve

import yaposib
import sys

def main():
    """Extra simple command line mps solver"""

    if len(sys.argv) <= 1:
        print("Usage: yaposib-solve <file1.mps> [<file2.mps> ...]")

    solver = yaposib.available_solvers()[0]

    for filename in sys.argv[1:]:

        problem = yaposib.Problem(solver)

        print("Will now solve %s" % filename)
        err = problem.readMps(filename)
        if not err:
            if problem.status == 'optimal':
                print("Optimal value: %f" % problem.obj.value)
                for var in problem.cols:
                    print("\t%s = %f" % (, var.solution))
                print("No optimal solution could be found.")

if __name__ == "__main__":

Other examples are available in the examples directory.