Hi,

Thanks for reporting this bug!  It is now on trac as ticket #6214:
http://trac.sagemath.org/sage_trac/ticket/6214

I think I understand what is causing the problem and I will try to
make a patch soon.  The .dim() method tries to store the result in
P._dim so it is not recomputed each time, but this value is set
incorrectly when the polytope is first defined.  If you do:

P=Polyhedron(ieqs=DATA, linearities = [[-31,1,1,1,1,1,1]])

then the dimension is correct; also if you delete P._dim then then
dimension is correctly computed from the vertices.

To clarify the inequalities, they are of the form [b,a1,...,an], which
represents the inequality b + a1*x1 + a2*x2 + ... + an*xn >= 1.  So to
put an equality in as inequalities, you need to use [b,a1,...,an] and
[-b1,-a1,...,-an].  The linearities keyword is better, and I see that
it is missing from the documentation for Polyhedron.

As an aside, you might not want to use DATA as a variable name if you
are using the notebook, since it is predefined as a path to a special
directory.

Again, thanks for reporting this, thats how this code will get
better.

-Marshall Hampton

On Jun 4, 8:43 am, Drini <[email protected]> wrote:
> I was checking the new polytope commands
> specifically a polytope in R^2   with points (a,b,c,d,e,f) such that
>
> e+b>= c+d
> e+c >= b+d
> a+b+c+d+e+f =  31
> (this is a polytope I had worked on before so I know it very well)
>
> After several tries (documentation still sparse and incomplete) I
> managed to cosntruct it.
> Checked vertices:
>
> P.vertices()
> [[0, 0, 0, 0, 0, 31], [31, 0, 0, 0, 0, 0], [0, 0, 0, 31/2, 31/2, 0],
> [0,
> 0, 31/2, 0, 31/2, 0], [0, 0, 0, 0, 31, 0], [0, 31/2, 0, 0, 31/2, 0],
> [0,
> 31/2, 31/2, 0, 0, 0]]
>
> That's right, 7 vertices, the right ones (again this is a polytope I
> knew before)
>
> P.ambiend_dim()
> 6
>
> P.dim()
> 6
>
> !!!!!
> ======================================
> The ambient dimension is indeed 6 (we're after all in R^6) but the
> polytope has dimension 5 for it's contained in the a+b+c+d+e+f=31
> hyperplane (and thus its dimension is 1 less than ambient) Notice all
> vertices have coordinates adding 31, therefore it's indeed contained
> in the hyperplane
> Polymake verified this as well saying dimension is 5
>
> Now I don't know how or where to submit a bug, but I suppose people
> involved with development here know
> so the least I can do is  comment there's a bug so it's known and
> forwarded (and then stop doing polytope computations in sagemath for a
> bit longer)
> ========================================
>
> By the way, on the "Polyhedron" documentation ?<tab>  ieqs stands for
> inequalities or equalities?
>
> For the record, here's how I constructed the polytope
>
> DATA=[[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, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1],
> [0,
> 0, 1, -1, -1, 1, 0], [0, 0, -1, 1, -1, 1, 0], [-31, 1, 1, 1, 1, 1, 1],
> [31, 1, 1, 1, 1, 1, 1]]
>
> notice the "double" equation a+b+c+d+e+f >= 31 and a+b+c+d+e+f >=
> -31   (equivalent to the equality a+b+c+d+e+f=31 )
>
> P=Polyhedron(ieqs=DATA)
>
> P.ieqs()
> [[0, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [-31, 1, 1, 1, 1, 1,
> 1],
> [0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 1, -1, -1, 1, 0],
> [0, 0, -1, 1, -1, 1, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1]]
>
> P.vertices()
> [[0, 0, 0, 0, 0, 31], [31, 0, 0, 0, 0, 0], [0, 0, 0, 31/2, 31/2, 0],
> [0,
> 0, 31/2, 0, 31/2, 0], [0, 0, 0, 0, 31, 0], [0, 31/2, 0, 0, 31/2, 0],
> [0,
> 31/2, 31/2, 0, 0, 0]]
>
> Notice that "ieqs" dropped one of the lines with 31 (so I suppose
> "ieqs" means equalities  after all but that's incosistent with the
> minus sign, isn't it?)
> Changing DATA to use only one of those lines has no effect, same
> vertices, dimension still is wrongly reported as 6
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to