I want to count the number of integral points inside of a bounded polyhedron. The polyhedron is defined by the following system of equations:
> eqns = [ [-100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, -1, 0, 0, 0, 0, -1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1, 0, 0, 1, 1, -1, 0, 0], [0, 0, 0, 0, -1, 0, -1, 1, 0, 1, 0, 0, 0], [0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1, 1, -1], [0, 0, -1, -1, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, -1, 1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0] ] and the following system of inequalities: > ieqs = [ [-1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] ] And so I did: > Polyhedron(eqns=eqns, ieqs=ieqs).integral_points_count() 1260 However, if I look at all of the slices obtained by fixing the first variable x_0 (which must be 1 <= x_0 <= 100 by the first equation and inequality) then I get the following numbers of integral points in each slice: > [Polyhedron(eqns=eqns+[[-k, 1, 0,0,0,0,0,0,0,0,0,0,0]], ieqs=ieqs).integral_points_count() for k in range(1, 101)] [84, 84, 84, ...., 0, 0, 0] Which is fewer points in total: > sum(_) 1197 Can anyone reproduce this? Is this a bug in Sage or LattE? I'm using Sage 8.0 with LattE installed via "sage -i latte_int" and have attached the full example code. Thanks, Mark -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
from sage.all import Polyhedron eqns = [ [0, -1, 0, 0, 0, 0, -1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1, 0, 0, 1, 1, -1, 0, 0], [0, 0, 0, 0, -1, 0, -1, 1, 0, 1, 0, 0, 0], [0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1, 1, -1], [0, 0, -1, -1, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, -1, 1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 1], [-100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0] ] ieqs = [ [-1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] ] print(Polyhedron(eqns=eqns, ieqs=ieqs).integral_points_count()) print(sum([Polyhedron(eqns=eqns+[[-k, 1, 0,0,0,0,0,0,0,0,0,0,0]], ieqs=ieqs).integral_points_count() for k in range(1, 101)]))