On Feb 18, 10:45 am, Harald Schilly <harald.schi...@gmail.com> wrote:
> <algebraicame...@gmail.com> wrote:
> > How many soldiers are there?
>
> If you install the cbc or glpk spkg, you can pose this as a MILP and
> something like that should work:

ok, now i got the solver running and i can test it ;)
so, actually it should look like this:

sage: p = MixedIntegerLinearProgram(maximization=False)
sage: soldiers = p.new_variable(vtype=p.__INTEGER)[1]
sage: columns = p.new_variable(vtype=p.__INTEGER)
sage: p.add_constraint(soldiers, min=1)
sage: [ p.add_constraint( a*columns[i] + b -soldiers, min=0, max=0)
for i,(a,b) in enumerate([[2,1], [3,2], [4,3], [5,4], [6,5], [7,0]])]
[None, None, None, None, None, None]
sage: p.set_objective(soldiers)
sage: p.solve()
119.0

# how many soldiers are in each column?
sage: p.get_values(columns)
{0: 59.0, 1: 39.0, 2: 29.0, 3: 23.0, 4: 19.0, 5: 17.0}

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to