Thanks. Sorry for the dumb posting. Daniel
On Tuesday, January 29, 2013 3:37:43 PM UTC, Dima Pasechnik wrote: > > On 2013-01-29, Daniel Friedan <[email protected] <javascript:>> wrote: > > ------=_Part_964_12292304.1359472365223 > > Content-Type: text/plain; charset=ISO-8859-1 > > > > The following example from Sage Reference v5.6 >> Numerical Optimization > >> > > Mixed integer linear programming > > http://www.sagemath.org/doc/reference/sage/numerical/mip.html > > gives a wrong answer when solver = 'PPL' is used. The equality > constraints > > are violated. > > No, they are not. Note that you round the output, > which need not be integer. > > If in the last line you do > print 'w_%s = %s' % (i, v) > you get > > w_0 = 15/2 > w_1 = 5 > w_2 = 3/2 > w_3 = 1 > > which is OK. > > The original example does integer LP, by the way (and PPL can't so it). > So it's OK to round in this case, but not for an ordinary LP... > > Best, > Dmitrii > > > > Sage 5.6-OSX-64bit-10.6 under OS X 10.6.8 > > > > sage: p = MixedIntegerLinearProgram(maximization=False, solver = "PPL") > > sage: print p.base_ring() > > sage: w = p.new_variable() > > sage: p.add_constraint(w[0] + w[1] + w[2] - 14*w[3] == 0) > > sage: p.add_constraint(w[1] + 2*w[2] - 8*w[3] == 0) > > sage: p.add_constraint(2*w[2] - 3*w[3] == 0) > > sage: p.add_constraint(w[0] - w[1] - w[2] >= 0) > > sage: p.add_constraint(w[3] >= 1) > > sage: _ = [ p.set_min(w[i], None) for i in range(1,4) ] > > sage: p.set_objective(w[3]) > > sage: p.show() > > sage: print 'Objective Value:', p.solve() > > sage: for i, v in p.get_values(w).iteritems():\ > > sage: print 'w_%s = %s' % (i, int(round(v))) > > > > Rational Field > > Minimization: > > x_3 > > Constraints: > > constraint_0: 0 <= x_0 + x_1 + x_2 - 14 x_3 <= 0 > > constraint_1: 0 <= x_1 + 2 x_2 - 8 x_3 <= 0 > > constraint_2: 0 <= 2 x_2 - 3 x_3 <= 0 > > constraint_3: - x_0 + x_1 + x_2 <= 0 > > constraint_4: - x_3 <= -1 > > Variables: > > x_0 is a continuous variable (min=0, max=+oo) > > x_1 is a continuous variable (min=-oo, max=+oo) > > x_2 is a continuous variable (min=-oo, max=+oo) > > x_3 is a continuous variable (min=-oo, max=+oo) > > Objective Value: 1 > > w_0 = 8 > > w_1 = 5 > > w_2 = 2 > > w_3 = 1 > > > > > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
