binary linear programming solver in Python

前端 未结 2 1924
天涯浪人
天涯浪人 2021-01-01 19:11

I have a Python script in which I need to solve a linear programming problem. The catch is that the solution must be binary. In other words, I need an equivalent of MATLAB\'

2条回答
  •  梦谈多话
    2021-01-01 19:38

    This is a half-answer, but you can use Python to interface with GLPK (through python-glpk). GLPK supports integer linear programs. (binary programs are just a subset of integer programs).

    http://en.wikipedia.org/wiki/GNU_Linear_Programming_Kit

    Or you could simply write your problem in Python and generate an MPS file (which most standard LP/MILP (CPLEX, Gurobi, GLPK) solvers will accept). This may be a good route to take, because as far as I am aware, there aren't any high quality MILP solvers that are native to Python (and there may never be). This will also allow you to try out different solvers.

    http://code.google.com/p/pulp-or/

    As for interfacing Python with MATLAB, I would just roll my own solution. You could generate a .m file and then run it from the command line

    % matlab -nojava myopt.m
    

    Notes:

    1. If you're an academic user, you can get a free license to Gurobi, a high performance LP/MILP solver. It has a Python interface. http://www.gurobi.com/
    2. OpenOpt is a Python optimization suite that interfaces with different solvers. http://en.wikipedia.org/wiki/OpenOpt

提交回复
热议问题