In [1]:
using MathProgBase
In [2]:
# examples from http://mathprogbasejl.readthedocs.io/en/latest/linprog.html
In [8]:
methods(linprog)
Out[8]:
4 methods for generic function linprog:
\begin{split}\min_{x,y}\quad &-x\\ s.t. \quad &2x + y \leq 1.5\\ & x \geq 0, y \geq 0\end{split}

Form 1

linprog(c, A, lb, ub, l, u)
\begin{split}\min_{x}\quad &c^Tx\\ s.t.\quad &lb \leq Ax \leq ub\\ &l \leq x \leq u\\\end{split}
In [3]:
sol = linprog([-1,0],[2 1],-Inf,1.5,0,Inf)
Out[3]:
MathProgBase.HighLevelInterface.LinprogSolution(:Optimal,-0.75,[0.75,0.0],Dict{Any,Any}(Pair{Any,Any}(:redcost,[0.0,0.5]),Pair{Any,Any}(:lambda,[-0.5])))

Form 1'

(shortcut with implicit [0,Inf] constraints)

In [6]:
sol = linprog([-1,0],[2 1],-Inf,1.5)
Out[6]:
MathProgBase.HighLevelInterface.LinprogSolution(:Optimal,-0.75,[0.75,0.0],Dict{Any,Any}(Pair{Any,Any}(:redcost,[0.0,0.5]),Pair{Any,Any}(:lambda,[-0.5])))

Form 2

linprog(c, A, sense, b, l, u)
\begin{split}\min_{x}\quad &c^Tx\\ s.t. \quad &a_i^Tx \text{ sense}_i \, b_i \forall\,\, i\\ &l \leq x \leq u\\\end{split}
In [13]:
sol = linprog([-1,0],[2 1],'<',1.5)
Out[13]:
MathProgBase.HighLevelInterface.LinprogSolution(:Optimal,-0.75,[0.75,0.0],Dict{Any,Any}(Pair{Any,Any}(:redcost,[0.0,0.5]),Pair{Any,Any}(:lambda,[-0.5])))
In [10]:
sol = linprog([-1,0],[2 1; 1 0],['<','>'],[1.5; 0.25])
Out[10]:
MathProgBase.HighLevelInterface.LinprogSolution(:Optimal,-0.75,[0.75,0.0],Dict{Any,Any}(Pair{Any,Any}(:redcost,[0.0,0.5]),Pair{Any,Any}(:lambda,[-0.5,0.0])))