ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 08 Jun 2013 16:44:57 -0500Error intersecting polyhedrahttps://ask.sagemath.org/question/10202/error-intersecting-polyhedra/I have a dictionary of polyhedra which I want to consider various intersections and unions of. For now, my dictionary has four polyhedra in it. When running the following for loop:
v={} # contains coordinates of the tetrahedron, centered at (0,0,0)
v[1] = vector([1,0,-1/sqrt(2)])
v[2] = vector([-1,0,-1/sqrt(2)])
v[3] = vector([0,1,1/sqrt(2)])
v[4] = vector([0,-1,1/sqrt(2)])
V = {1,2,3,4}
b={} # will contain coordinates of vertices of the subdivision of the tetrahedron
for X in powerset(V):
q = len(X)
if q > 0:
b[tuple(X)] = (1/q)*sum([v[i] for i in X])
poly_int = Polyhedron([b[key] for key in b.keys()]) # this is a tetrahedron containing
# all of my polyhedra
for i in [1,2,3,4]:
poly_int = poly[i] & poly_int
I get a very nasty error:
AttributeError: 'Polyhedra_RDF_cdd_with_category.element_class'
object has no attribute '_Vrepresentation'
(The traceback for the error is quite long. I can include it if needed.)
Manually computing
poly[1] & poly[2] & poly[3] & poly[4]
gives the same error. HOWEVER, if instead I compute
(poly[1] & poly[2]) & (poly[3] & poly[4])
I get no errors. While this is a fine workaround for this particular case, I'm scripting these intersections and need some way to actually compute these intersections automatically. Using something like
poly[1].intersection(poly[2]) # etc.
doesn't help either. Any thoughts?Thu, 06 Jun 2013 10:13:30 -0500https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/Comment by kcrisman for <p>I have a dictionary of polyhedra which I want to consider various intersections and unions of. For now, my dictionary has four polyhedra in it. When running the following for loop:</p>
<pre><code>v={} # contains coordinates of the tetrahedron, centered at (0,0,0)
v[1] = vector([1,0,-1/sqrt(2)])
v[2] = vector([-1,0,-1/sqrt(2)])
v[3] = vector([0,1,1/sqrt(2)])
v[4] = vector([0,-1,1/sqrt(2)])
V = {1,2,3,4}
b={} # will contain coordinates of vertices of the subdivision of the tetrahedron
for X in powerset(V):
q = len(X)
if q > 0:
b[tuple(X)] = (1/q)*sum([v[i] for i in X])
poly_int = Polyhedron([b[key] for key in b.keys()]) # this is a tetrahedron containing
# all of my polyhedra
for i in [1,2,3,4]:
poly_int = poly[i] & poly_int
</code></pre>
<p>I get a very nasty error:</p>
<pre><code>AttributeError: 'Polyhedra_RDF_cdd_with_category.element_class'
object has no attribute '_Vrepresentation'
</code></pre>
<p>(The traceback for the error is quite long. I can include it if needed.)</p>
<p>Manually computing</p>
<pre><code>poly[1] & poly[2] & poly[3] & poly[4]
</code></pre>
<p>gives the same error. HOWEVER, if instead I compute</p>
<pre><code>(poly[1] & poly[2]) & (poly[3] & poly[4])
</code></pre>
<p>I get no errors. While this is a fine workaround for this particular case, I'm scripting these intersections and need some way to actually compute these intersections automatically. Using something like</p>
<pre><code>poly[1].intersection(poly[2]) # etc.
</code></pre>
<p>doesn't help either. Any thoughts?</p>
https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17550#post-id-17550If you could edit your question to include the definition of `b` that would probably help; I'm trying some basic polyhedra and just getting the empty polyhedron even with multiple `&`s, and the diagnosis you give indicates it's probably a very specific edge case that is going wrong. (Also note that `intersection` *should* (?) be the same as `&`, since this particular binary operator turns into `__and__`, I believe.)Thu, 06 Jun 2013 14:33:42 -0500https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17550#post-id-17550Comment by Bill for <p>I have a dictionary of polyhedra which I want to consider various intersections and unions of. For now, my dictionary has four polyhedra in it. When running the following for loop:</p>
<pre><code>v={} # contains coordinates of the tetrahedron, centered at (0,0,0)
v[1] = vector([1,0,-1/sqrt(2)])
v[2] = vector([-1,0,-1/sqrt(2)])
v[3] = vector([0,1,1/sqrt(2)])
v[4] = vector([0,-1,1/sqrt(2)])
V = {1,2,3,4}
b={} # will contain coordinates of vertices of the subdivision of the tetrahedron
for X in powerset(V):
q = len(X)
if q > 0:
b[tuple(X)] = (1/q)*sum([v[i] for i in X])
poly_int = Polyhedron([b[key] for key in b.keys()]) # this is a tetrahedron containing
# all of my polyhedra
for i in [1,2,3,4]:
poly_int = poly[i] & poly_int
</code></pre>
<p>I get a very nasty error:</p>
<pre><code>AttributeError: 'Polyhedra_RDF_cdd_with_category.element_class'
object has no attribute '_Vrepresentation'
</code></pre>
<p>(The traceback for the error is quite long. I can include it if needed.)</p>
<p>Manually computing</p>
<pre><code>poly[1] & poly[2] & poly[3] & poly[4]
</code></pre>
<p>gives the same error. HOWEVER, if instead I compute</p>
<pre><code>(poly[1] & poly[2]) & (poly[3] & poly[4])
</code></pre>
<p>I get no errors. While this is a fine workaround for this particular case, I'm scripting these intersections and need some way to actually compute these intersections automatically. Using something like</p>
<pre><code>poly[1].intersection(poly[2]) # etc.
</code></pre>
<p>doesn't help either. Any thoughts?</p>
https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17547#post-id-17547Right. Sorry. Each poly[i] is a polyhedron defined as a convex hull on some of the points from b.Thu, 06 Jun 2013 14:50:29 -0500https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17547#post-id-17547Comment by kcrisman for <p>I have a dictionary of polyhedra which I want to consider various intersections and unions of. For now, my dictionary has four polyhedra in it. When running the following for loop:</p>
<pre><code>v={} # contains coordinates of the tetrahedron, centered at (0,0,0)
v[1] = vector([1,0,-1/sqrt(2)])
v[2] = vector([-1,0,-1/sqrt(2)])
v[3] = vector([0,1,1/sqrt(2)])
v[4] = vector([0,-1,1/sqrt(2)])
V = {1,2,3,4}
b={} # will contain coordinates of vertices of the subdivision of the tetrahedron
for X in powerset(V):
q = len(X)
if q > 0:
b[tuple(X)] = (1/q)*sum([v[i] for i in X])
poly_int = Polyhedron([b[key] for key in b.keys()]) # this is a tetrahedron containing
# all of my polyhedra
for i in [1,2,3,4]:
poly_int = poly[i] & poly_int
</code></pre>
<p>I get a very nasty error:</p>
<pre><code>AttributeError: 'Polyhedra_RDF_cdd_with_category.element_class'
object has no attribute '_Vrepresentation'
</code></pre>
<p>(The traceback for the error is quite long. I can include it if needed.)</p>
<p>Manually computing</p>
<pre><code>poly[1] & poly[2] & poly[3] & poly[4]
</code></pre>
<p>gives the same error. HOWEVER, if instead I compute</p>
<pre><code>(poly[1] & poly[2]) & (poly[3] & poly[4])
</code></pre>
<p>I get no errors. While this is a fine workaround for this particular case, I'm scripting these intersections and need some way to actually compute these intersections automatically. Using something like</p>
<pre><code>poly[1].intersection(poly[2]) # etc.
</code></pre>
<p>doesn't help either. Any thoughts?</p>
https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17546#post-id-17546With code, please... :-) Again, my first guesses at *which* points didn't work. Sorry for asking for *all* of it, but a "minimal working example" is key for debugging this. We don't want to try to guess what you mean.Thu, 06 Jun 2013 14:57:51 -0500https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17546#post-id-17546Comment by Bill for <p>I have a dictionary of polyhedra which I want to consider various intersections and unions of. For now, my dictionary has four polyhedra in it. When running the following for loop:</p>
<pre><code>v={} # contains coordinates of the tetrahedron, centered at (0,0,0)
v[1] = vector([1,0,-1/sqrt(2)])
v[2] = vector([-1,0,-1/sqrt(2)])
v[3] = vector([0,1,1/sqrt(2)])
v[4] = vector([0,-1,1/sqrt(2)])
V = {1,2,3,4}
b={} # will contain coordinates of vertices of the subdivision of the tetrahedron
for X in powerset(V):
q = len(X)
if q > 0:
b[tuple(X)] = (1/q)*sum([v[i] for i in X])
poly_int = Polyhedron([b[key] for key in b.keys()]) # this is a tetrahedron containing
# all of my polyhedra
for i in [1,2,3,4]:
poly_int = poly[i] & poly_int
</code></pre>
<p>I get a very nasty error:</p>
<pre><code>AttributeError: 'Polyhedra_RDF_cdd_with_category.element_class'
object has no attribute '_Vrepresentation'
</code></pre>
<p>(The traceback for the error is quite long. I can include it if needed.)</p>
<p>Manually computing</p>
<pre><code>poly[1] & poly[2] & poly[3] & poly[4]
</code></pre>
<p>gives the same error. HOWEVER, if instead I compute</p>
<pre><code>(poly[1] & poly[2]) & (poly[3] & poly[4])
</code></pre>
<p>I get no errors. While this is a fine workaround for this particular case, I'm scripting these intersections and need some way to actually compute these intersections automatically. Using something like</p>
<pre><code>poly[1].intersection(poly[2]) # etc.
</code></pre>
<p>doesn't help either. Any thoughts?</p>
https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17542#post-id-17542OK. So, I've lost that original code which produced this error. However, I have noticed some new strange behavior when intersecting polyhedra and can give you specifics:
a = Polyhedron([[1.0, 0.0, -0.7071067812], [0.5, -0.5, 0.0]])
b = Polyhedron([[-0.5,-0.5,0.0]])
c = Polyhedron([[0.0, -1.0, 0.7071067812], [0.5, -0.5, 0.0], [-0.5, -0.5, 0.0]]).
a & b is empty, while (a & b) & c is 0-dimensional.
Sat, 08 Jun 2013 09:22:26 -0500https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17542#post-id-17542Comment by kcrisman for <p>I have a dictionary of polyhedra which I want to consider various intersections and unions of. For now, my dictionary has four polyhedra in it. When running the following for loop:</p>
<pre><code>v={} # contains coordinates of the tetrahedron, centered at (0,0,0)
v[1] = vector([1,0,-1/sqrt(2)])
v[2] = vector([-1,0,-1/sqrt(2)])
v[3] = vector([0,1,1/sqrt(2)])
v[4] = vector([0,-1,1/sqrt(2)])
V = {1,2,3,4}
b={} # will contain coordinates of vertices of the subdivision of the tetrahedron
for X in powerset(V):
q = len(X)
if q > 0:
b[tuple(X)] = (1/q)*sum([v[i] for i in X])
poly_int = Polyhedron([b[key] for key in b.keys()]) # this is a tetrahedron containing
# all of my polyhedra
for i in [1,2,3,4]:
poly_int = poly[i] & poly_int
</code></pre>
<p>I get a very nasty error:</p>
<pre><code>AttributeError: 'Polyhedra_RDF_cdd_with_category.element_class'
object has no attribute '_Vrepresentation'
</code></pre>
<p>(The traceback for the error is quite long. I can include it if needed.)</p>
<p>Manually computing</p>
<pre><code>poly[1] & poly[2] & poly[3] & poly[4]
</code></pre>
<p>gives the same error. HOWEVER, if instead I compute</p>
<pre><code>(poly[1] & poly[2]) & (poly[3] & poly[4])
</code></pre>
<p>I get no errors. While this is a fine workaround for this particular case, I'm scripting these intersections and need some way to actually compute these intersections automatically. Using something like</p>
<pre><code>poly[1].intersection(poly[2]) # etc.
</code></pre>
<p>doesn't help either. Any thoughts?</p>
https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17537#post-id-17537In this last case, yes, that seems likely. I'm still wondering what happened in your original code, I just couldn't reconstruct it.Sat, 08 Jun 2013 16:44:57 -0500https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17537#post-id-17537Comment by Bill for <p>I have a dictionary of polyhedra which I want to consider various intersections and unions of. For now, my dictionary has four polyhedra in it. When running the following for loop:</p>
<pre><code>v={} # contains coordinates of the tetrahedron, centered at (0,0,0)
v[1] = vector([1,0,-1/sqrt(2)])
v[2] = vector([-1,0,-1/sqrt(2)])
v[3] = vector([0,1,1/sqrt(2)])
v[4] = vector([0,-1,1/sqrt(2)])
V = {1,2,3,4}
b={} # will contain coordinates of vertices of the subdivision of the tetrahedron
for X in powerset(V):
q = len(X)
if q > 0:
b[tuple(X)] = (1/q)*sum([v[i] for i in X])
poly_int = Polyhedron([b[key] for key in b.keys()]) # this is a tetrahedron containing
# all of my polyhedra
for i in [1,2,3,4]:
poly_int = poly[i] & poly_int
</code></pre>
<p>I get a very nasty error:</p>
<pre><code>AttributeError: 'Polyhedra_RDF_cdd_with_category.element_class'
object has no attribute '_Vrepresentation'
</code></pre>
<p>(The traceback for the error is quite long. I can include it if needed.)</p>
<p>Manually computing</p>
<pre><code>poly[1] & poly[2] & poly[3] & poly[4]
</code></pre>
<p>gives the same error. HOWEVER, if instead I compute</p>
<pre><code>(poly[1] & poly[2]) & (poly[3] & poly[4])
</code></pre>
<p>I get no errors. While this is a fine workaround for this particular case, I'm scripting these intersections and need some way to actually compute these intersections automatically. Using something like</p>
<pre><code>poly[1].intersection(poly[2]) # etc.
</code></pre>
<p>doesn't help either. Any thoughts?</p>
https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17549#post-id-17549@kcrisman OK. I included a definition of b. It's a dictionary containing the coordinates of the barycentric subdivision of a 3-simplex.Thu, 06 Jun 2013 14:40:15 -0500https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17549#post-id-17549Comment by kcrisman for <p>I have a dictionary of polyhedra which I want to consider various intersections and unions of. For now, my dictionary has four polyhedra in it. When running the following for loop:</p>
<pre><code>v={} # contains coordinates of the tetrahedron, centered at (0,0,0)
v[1] = vector([1,0,-1/sqrt(2)])
v[2] = vector([-1,0,-1/sqrt(2)])
v[3] = vector([0,1,1/sqrt(2)])
v[4] = vector([0,-1,1/sqrt(2)])
V = {1,2,3,4}
b={} # will contain coordinates of vertices of the subdivision of the tetrahedron
for X in powerset(V):
q = len(X)
if q > 0:
b[tuple(X)] = (1/q)*sum([v[i] for i in X])
poly_int = Polyhedron([b[key] for key in b.keys()]) # this is a tetrahedron containing
# all of my polyhedra
for i in [1,2,3,4]:
poly_int = poly[i] & poly_int
</code></pre>
<p>I get a very nasty error:</p>
<pre><code>AttributeError: 'Polyhedra_RDF_cdd_with_category.element_class'
object has no attribute '_Vrepresentation'
</code></pre>
<p>(The traceback for the error is quite long. I can include it if needed.)</p>
<p>Manually computing</p>
<pre><code>poly[1] & poly[2] & poly[3] & poly[4]
</code></pre>
<p>gives the same error. HOWEVER, if instead I compute</p>
<pre><code>(poly[1] & poly[2]) & (poly[3] & poly[4])
</code></pre>
<p>I get no errors. While this is a fine workaround for this particular case, I'm scripting these intersections and need some way to actually compute these intersections automatically. Using something like</p>
<pre><code>poly[1].intersection(poly[2]) # etc.
</code></pre>
<p>doesn't help either. Any thoughts?</p>
https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17548#post-id-17548Sorry, one more question - what is `poly`? I thought maybe `v` is `poly`, but that doesn't make sense.Thu, 06 Jun 2013 14:49:00 -0500https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17548#post-id-17548Comment by Bill for <p>I have a dictionary of polyhedra which I want to consider various intersections and unions of. For now, my dictionary has four polyhedra in it. When running the following for loop:</p>
<pre><code>v={} # contains coordinates of the tetrahedron, centered at (0,0,0)
v[1] = vector([1,0,-1/sqrt(2)])
v[2] = vector([-1,0,-1/sqrt(2)])
v[3] = vector([0,1,1/sqrt(2)])
v[4] = vector([0,-1,1/sqrt(2)])
V = {1,2,3,4}
b={} # will contain coordinates of vertices of the subdivision of the tetrahedron
for X in powerset(V):
q = len(X)
if q > 0:
b[tuple(X)] = (1/q)*sum([v[i] for i in X])
poly_int = Polyhedron([b[key] for key in b.keys()]) # this is a tetrahedron containing
# all of my polyhedra
for i in [1,2,3,4]:
poly_int = poly[i] & poly_int
</code></pre>
<p>I get a very nasty error:</p>
<pre><code>AttributeError: 'Polyhedra_RDF_cdd_with_category.element_class'
object has no attribute '_Vrepresentation'
</code></pre>
<p>(The traceback for the error is quite long. I can include it if needed.)</p>
<p>Manually computing</p>
<pre><code>poly[1] & poly[2] & poly[3] & poly[4]
</code></pre>
<p>gives the same error. HOWEVER, if instead I compute</p>
<pre><code>(poly[1] & poly[2]) & (poly[3] & poly[4])
</code></pre>
<p>I get no errors. While this is a fine workaround for this particular case, I'm scripting these intersections and need some way to actually compute these intersections automatically. Using something like</p>
<pre><code>poly[1].intersection(poly[2]) # etc.
</code></pre>
<p>doesn't help either. Any thoughts?</p>
https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17541#post-id-17541Perhaps it is because these polyhedra are degenerate?Sat, 08 Jun 2013 09:24:38 -0500https://ask.sagemath.org/question/10202/error-intersecting-polyhedra/?comment=17541#post-id-17541