<p>Probably the most famous instance in which a greedy algorithm is known to solve an LP is for the special case of the transportation problem.  Hoffman ("On simple linear programs", in <em>Convexity</em>, vol. 7 of <em>Proceedings of Symposia in Pure Mathematics</em>, pages 317-327, 1963) proved that if the cost matrix for a (maximization) transportation problem satisfies the <em>Monge property</em> ($c_{ij} + c_{kl} \geq c_{il} + c_{kj}$ when $1 \leq i &lt; k \leq n$, $1 \leq j &lt; l \leq n$) then an optimal solution can be found in a greedy manner like the one you describe.  </p>

<p>Hoffman also has a survey paper ("<a href="http://books.google.com/books?id=hQo4AAAAIAAJ&amp;pg=PA97&amp;lpg=PA97&amp;dq=on%20greedy%20algorithms%20that%20succeed%20hoffman&amp;source=bl&amp;ots=MTuuU5aBTQ&amp;sig=8Jh5_-KZ9kzBHKi1f6cCvWoB9GI&amp;hl=en&amp;ei=VylxTuSNB4TZiALg1dnHAg&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=1&amp;sqi=2&amp;ved=0CCIQ6AEwAA#v=onepage&amp;q=on%20greedy%20algorithms%20that%20succeed%20hoffman&amp;f=false" rel="nofollow">On greedy algorithms that succeed</a>") from 1985 in which he discusses known cases in which a greedy algorithm gives an optimal solution to an LP.  Besides his own work cited above (about which he says, "most of the linear programming problems known [by 1963] to be susceptible to a greedy algorithm were special cases of the Monge idea"), he mentions Edmonds' linear programming interpretation of a generalization of matroids and a discussion of the case when $A$ is nonnegative, among other things.</p>

<p>I imagine there are more recent results, but hopefully this at least partially answers your question and gives you some ideas of where else to look.</p>

CC BY-SA 3.0
2011-10-01T21:15:44.243Z
I'd like to thank Prof Spivey for his suggestion. It took me a while to chase the references but I will provide a fuller description as an answer.
Robert Almgren
CC BY-SA 3.0
2011-09-14T22:39:11.763Z
2011-09-14T22:39:11.763Z
Mike Spivey
<p>Thanks to Prof Spivey's suggestion, I finally located what I think is the state of the art: Ulrich Faigle, Alan J. Hoffman, and Walter Kern, "A Characterization of Nonnegative Box-Greedy Matrices", SIAM J. Disc. Math. 9 (1996) pp 1-6. A matrix is "greedy" if the algorithm I described above gives the optimal solution for all $b$. A matrix is "box-greedy" if the greedy algorithm gives the optimal solution with the additional condition $x\le d$ for all $b$ and all $d\ge0$. Clearly, box-greedy is a stronger condition than greedy.</p>

<p>Always assume that $c_1\ge\dots\ge c_n&gt;0$. Faigle, Hoffman, and Kern prove that $A$ is box greedy if and only if it has no $k\times(k+1)$ (for any $k$) submatrix of the form $\begin{pmatrix} r_1 &amp; s_1 &amp; &amp; &amp; \\ r_2 &amp; &amp; s_2 &amp; &amp; \\ \vdots &amp; &amp; &amp; \ddots \\ r_k &amp; &amp; &amp; &amp; s_k \end{pmatrix}$ with each $r_j&gt;0$ and $\sum_{i:s_i&gt;0} \frac{r_i}{s_i} &gt; 1$. In extracting the submatrices, arbitrary permutations of rows are allowed but not columns, and arbitrary subsetting of rows and columns is allowed. Thus in particular, with $k=1$, the nonzero elements in each row of $A$ must be nondecreasing.</p>

<p>It turns out, unfortunately, that in my problem the matrices are no box-greedy though I still believe they are greedy. For example, in my $A_1$ above the condition is violated and this matrix is not box-greedy though it is greedy. As far as I know, there are no results on identifying greedy matrices.</p>

CC BY-SA 3.0
2011-10-03T02:37:06.467Z
I'm glad my answer helped you find this!
Mike Spivey
CC BY-SA 4.0
2021-01-10T21:50:53.917Z
what do you mean by "arbitrary subsetting of rows and columns?"
ABu
CC BY-SA 3.0
2011-10-01T21:27:15.350Z
2011-10-01T21:27:15.350Z
Robert Almgren
<p>The easiest example for something like this might be the fractional knapsack problem where items are permitted to be fractionalized. this problem (and its lp dual) can be solved by sorting the items for profit per weight, choosing the longest sequence in this order which is feasible and fractionalizing the last item.</p>

CC BY-SA 3.0
2011-10-05T11:26:57.623Z
2011-10-05T11:26:57.623Z
anonymous
<p>I have a family of linear programming problems:  maximise $c&#39; x$ subject to $A x\le b$, $x\ge0$. The elements of $A$, $b$, and $c$ are nonnegative integers, $c$ strictly positive. ($x$ should also be integral but I will worry about that later.)</p>

<p>It often happens in my application that the coefficients $A$ and $c$ are such that a simplified one-pass algorithm gives the optimal solution for every choice of $b$: the one-pass algorithm determines the elements $x_1,\dots,x_n$ in sequence, choosing each $x_j$ to be the largest possible value consistent with the already-determined values $x_1,\dots,x_{j-1}$. In simplex language, the sequence of entering variables is just $x_1$ to $x_n$, and it terminates after $n$ steps. This saves a lot of time compared to full-on simplex.</p>

<p>This algorithm works when the columns of $A$ and the elements of $c$ have been sorted from "cheap" to "expensive". A "cheap" variable is a column of $A$ with generally small values, for which the corresponding element of $c$ is large:  for that element of $x$ you get a lot of output with not very much demand on the constraint $b$. So the algorithm just says "do the easy stuff first."</p>

<p>My question is: what property of $A$ and $c$ would assure us that this simplified algorithm works for all $b$? My initial conjecture was that the nonzero elements of $A$ should be increasing in each row, but that is not correct.</p>

<p>Here are some examples, all with $c=(1,1,1)$:
$A_1=\begin{pmatrix} 1 &amp; 1 &amp; 1 \\ 1 &amp; 2 &amp; 3 \\ 3 &amp; 2 &amp; 0\end{pmatrix}$,
$A_2=\begin{pmatrix} 0 &amp; 0 &amp; 1 \\ 3 &amp; 0 &amp; 2 \\ 0 &amp; 3 &amp; 2 \end{pmatrix}$,
$A_3=\begin{pmatrix} 1 &amp; 1 &amp; 1 \\ 1 &amp; 0 &amp; 0 \\ 1 &amp; 0 &amp; 1 \end{pmatrix}$,
$A_4=\begin{pmatrix} 1 &amp; 0 &amp; 1 \\ 0 &amp; 1 &amp; 0 \\ 0 &amp; 1 &amp; 1 \end{pmatrix}$.
For all of these, the sequential algorithm gives the optimal solution for all values of $b$ (by numerical experimentation). $A_3$ is the only one for which all permutations of columns also work. $A_1$ and $A_3$ are especially baffling, since $(1,1,3)$ looks more expensive than $(1,3,0)$ and $(1,1,1)$ more expensive than $(1,0,0)$.</p>

<p>I would be tremendously grateful for any pointers to the literature, for any problems like this, or any suggestions at all. There must have been other cases where some variables can be determined to be "cheaper" than others and can safely be done first. With all the work that has been done on linear programming over the years, it seems that something similar must have come up, but I haven't been able to find it.</p>

<ds.algorithms><reference-request><linear-programming><matrices>
Linear programming solution in one pass with ordered variables
Robert Almgren
# Linear programming solution in one pass with ordered variables

(Asked by: username_0 on 2011-09-04)

I have a family of linear programming problems: maximise $c' x$ subject to $A x\le b$, $x\ge0$. The elements of $A$, $b$, and $c$ are nonnegative integers, $c$ strictly positive. ($x$ should also be integral but I will worry about that later.)

It often happens in my application that the coefficients $A$ and $c$ are such that a simplified one-pass algorithm gives the optimal solution for every choice of $b$: the one-pass algorithm determines the elements $x\_1,\dots,x\_n$ in sequence, choosing each $x\_j$ to be the largest possible value consistent with the already-determined values $x\_1,\dots,x\_{j-1}$. In simplex language, the sequence of entering variables is just $x\_1$ to $x\_n$, and it terminates after $n$ steps. This saves a lot of time compared to full-on simplex.

This algorithm works when the columns of $A$ and the elements of $c$ have been sorted from "cheap" to "expensive". A "cheap" variable is a column of $A$ with generally small values, for which the corresponding element of $c$ is large: for that element of $x$ you get a lot of output with not very much demand on the constraint $b$. So the algorithm just says "do the easy stuff first."

My question is: what property of $A$ and $c$ would assure us that this simplified algorithm works for all $b$? My initial conjecture was that the nonzero elements of $A$ should be increasing in each row, but that is not correct.

Here are some examples, all with $c=(1,1,1)$:
$A\_1=\begin{pmatrix} 1 & 1 & 1 \\ 1 & 2 & 3 \\ 3 & 2 & 0\end{pmatrix}$,
$A\_2=\begin{pmatrix} 0 & 0 & 1 \\ 3 & 0 & 2 \\ 0 & 3 & 2 \end{pmatrix}$,
$A\_3=\begin{pmatrix} 1 & 1 & 1 \\ 1 & 0 & 0 \\ 1 & 0 & 1 \end{pmatrix}$,
$A\_4=\begin{pmatrix} 1 & 0 & 1 \\ 0 & 1 & 0 \\ 0 & 1 & 1 \end{pmatrix}$.
For all of these, the sequential algorithm gives the optimal solution for all values of $b$ (by numerical experimentation). $A\_3$ is the only one for which all permutations of columns also work. $A\_1$ and $A\_3$ are especially baffling, since $(1,1,3)$ looks more expensive than $(1,3,0)$ and $(1,1,1)$ more expensive than $(1,0,0)$.

I would be tremendously grateful for any pointers to the literature, for any problems like this, or any suggestions at all. There must have been other cases where some variables can be determined to be "cheaper" than others and can safely be done first. With all the work that has been done on linear programming over the years, it seems that something similar must have come up, but I haven't been able to find it.

**Tags:** ds.algorithms, reference-request, linear-programming, matrices

---

## 3 answers

### Answer by username_1 on 2011-09-14. Score: 4

Probably the most famous instance in which a greedy algorithm is known to solve an LP is for the special case of the transportation problem. Hoffman ("On simple linear programs", in *Convexity*, vol. 7 of *Proceedings of Symposia in Pure Mathematics*, pages 317-327, 1963) proved that if the cost matrix for a (maximization) transportation problem satisfies the *Monge property* ($c\_{ij} + c\_{kl} \geq c\_{il} + c\_{kj}$ when $1 \leq i < k \leq n$, $1 \leq j < l \leq n$) then an optimal solution can be found in a greedy manner like the one you describe.

Hoffman also has a survey paper ("[On greedy algorithms that succeed](http://books.google.com/books?id=hQo4AAAAIAAJ&pg=PA97&lpg=PA97&dq=on%20greedy%20algorithms%20that%20succeed%20hoffman&source=bl&ots=MTuuU5aBTQ&sig=8Jh5_-KZ9kzBHKi1f6cCvWoB9GI&hl=en&ei=VylxTuSNB4TZiALg1dnHAg&sa=X&oi=book_result&ct=result&resnum=1&sqi=2&ved=0CCIQ6AEwAA#v=onepage&q=on%20greedy%20algorithms%20that%20succeed%20hoffman&f=false)") from 1985 in which he discusses known cases in which a greedy algorithm gives an optimal solution to an LP. Besides his own work cited above (about which he says, "most of the linear programming problems known [by 1963] to be susceptible to a greedy algorithm were special cases of the Monge idea"), he mentions Edmonds' linear programming interpretation of a generalization of matroids and a discussion of the case when $A$ is nonnegative, among other things.

I imagine there are more recent results, but hopefully this at least partially answers your question and gives you some ideas of where else to look.

> **Comments:**
> **username_0**: I'd like to thank Prof Spivey for his suggestion. It took me a while to chase the references but I will provide a fuller description as an answer.  

---

### Answer by username_0 on 2011-10-01. Score: 4

Thanks to Prof Spivey's suggestion, I finally located what I think is the state of the art: Ulrich Faigle, Alan J. Hoffman, and Walter Kern, "A Characterization of Nonnegative Box-Greedy Matrices", SIAM J. Disc. Math. 9 (1996) pp 1-6. A matrix is "greedy" if the algorithm I described above gives the optimal solution for all $b$. A matrix is "box-greedy" if the greedy algorithm gives the optimal solution with the additional condition $x\le d$ for all $b$ and all $d\ge0$. Clearly, box-greedy is a stronger condition than greedy.

Always assume that $c\_1\ge\dots\ge c\_n>0$. Faigle, Hoffman, and Kern prove that $A$ is box greedy if and only if it has no $k\times(k+1)$ (for any $k$) submatrix of the form $\begin{pmatrix} r\_1 & s\_1 & & & \\ r\_2 & & s\_2 & & \\ \vdots & & & \ddots \\ r\_k & & & & s\_k \end{pmatrix}$ with each $r\_j>0$ and $\sum\_{i:s\_i>0} \frac{r\_i}{s\_i} > 1$. In extracting the submatrices, arbitrary permutations of rows are allowed but not columns, and arbitrary subsetting of rows and columns is allowed. Thus in particular, with $k=1$, the nonzero elements in each row of $A$ must be nondecreasing.

It turns out, unfortunately, that in my problem the matrices are no box-greedy though I still believe they are greedy. For example, in my $A\_1$ above the condition is violated and this matrix is not box-greedy though it is greedy. As far as I know, there are no results on identifying greedy matrices.

> **Comments:**
> **username_1**: I'm glad my answer helped you find this!  
> **username_2**: what do you mean by "arbitrary subsetting of rows and columns?"  

---

### Answer by username_3 on 2011-10-05. Score: 3

The easiest example for something like this might be the fractional knapsack problem where items are permitted to be fractionalized. this problem (and its lp dual) can be solved by sorting the items for profit per weight, choosing the longest sequence in this order which is feasible and fractionalizing the last item.


---

