Ticket #7012: trac_7012-details.patch

File trac_7012-details.patch, 1.5 KB (added by ncohen, 11 years ago)
  • sage/numerical/knapsack.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1254669768 -7200
    # Node ID 14516cf5b0ccefed648d0043a7c9beb7121a5598
    # Parent  03eaf3619a9cd4f998c1611f2d2037c7f60c88b8
    knapsack updated, one doctest fixed
    
    diff -r 03eaf3619a9c -r 14516cf5b0cc sage/numerical/knapsack.py
    a b  
    642642        seq = [(x,1) for x in seq]
    643643
    644644    from sage.numerical.mip import MixedIntegerLinearProgram
    645     p = MixedIntegerLinearProgram(sense=1)
     645    p = MixedIntegerLinearProgram(maximization=True)
    646646    present = p.new_variable()
    647647    p.set_objective(sum([present[i] * seq[i][1] for i in range(len(seq))]))
    648648    p.add_constraint(sum([present[i] * seq[i][0] for i in range(len(seq))]), max=max)
  • sage/numerical/mip.pyx

    diff -r 03eaf3619a9c -r 14516cf5b0cc sage/numerical/mip.pyx
    a b  
    640640            sage: p.add_constraint(1.5*x[1] + 3*x[2], max=4)
    641641            sage: p.solve()           # optional - requires Glpk or COIN-OR/CBC
    642642            6.6666666666666661
    643             sage: p.get_values(x)     # optional - requires Glpk or COIN-OR/CBC
     643            sage: p.get_values(x)     # optional random - requires Glpk or COIN-OR/CBC
    644644            {1: 0.0, 2: 1.3333333333333333}
    645645
    646646            sage: ### Computation of a maximum stable set in Petersen's graph