Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This can be written as a <a href="http://en.wikipedia.org/wiki/Linear_programming" rel="nofollow noreferrer">linear programming</a> problem. For most 'typical' problems, the simplex method is a fast, relatively simple way to solve such problems, or there are open source LP solvers available.</p> <p>For your example:</p> <p>Let <em>0 &lt;= xi &lt;= 1</em></p> <ul> <li><em>x1</em> = One if one coupon is spent on item 1, zero otherwise </li> <li><em>x2</em> = One if two coupons are spent on item 1, zero otherwise </li> <li><em>x3</em> = One if one coupon is spent on item 2, zero otherwise</li> <li><em>x4</em> = One if two coupons are spent on item 2, zero otherwise </li> <li><em>x5</em> = One if three coupons are spent on item 3, zero otherwise </li> <li>...</li> </ul> <p>Assume that if I spend two coupons on item 1, then both x1 and x2 are one. This implies the constraint</p> <ul> <li><em>x1 >= x2</em></li> </ul> <p>With similar constraints for the other items, e.g.,</p> <ul> <li><em>x3 >= x4</em></li> <li><em>x4 >= x5</em></li> </ul> <p>The amount saved is</p> <ul> <li><em>Saved = 10 x1 + 5 x2 + 0 x3 + 5 x4 + 10 x5 + ...</em></li> </ul> <p>If you want to find the most money saved with a fixed number of coupons, then you want to minimize <em>Saved</em> subject to the constraints above and the additional constraint:</p> <ul> <li><em>coupon count = x1 + x2 + x3 + ...</em></li> </ul> <p>This works for any matrix and number of items. Changing notation (and feeling sad that I can't do subscripts), let <em>0 &lt;= y_ij &lt;= 1</em> be one if <em>j</em> coupons are spent on item number <em>i</em>. The we have the constraints</p> <ul> <li><em>y_i(j-1) >= y_ij</em></li> </ul> <p>If the amount saved from spending <em>j</em> coupons on item <em>i</em> is <em>M_ij</em>, where we define <em>M_i0 = 0</em>, then maximize</p> <ul> <li><em>Saved = Sum_ij (M_ij - M_i(j-1)) y_ij</em></li> </ul> <p>subject to the above constraints and</p> <ul> <li><em>coupon count = Sum_ij y_ij</em></li> </ul> <p>(The italics formatting doesn't seem to be working here)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload