Calculating Induced vs. Ambient Volume Using Lrs Engine
Hi All,
I aim to calculate the volumes of not-full dimensional polytopes. Using ambient measure, the volume is always 0. So, I want to use induced measure. At the same time, though, I also want the engine to be Lrs.
If I just do .volume(engine = 'lrs'), I always get 0. Is this an error? Or is this because the system is using ambient measure for the volume?
To try and fix the issue, I want to have both induced measure and lrs engine. However, when I input something like .volume(measure = 'induced', engine = 'lrs'), I get an error. Is there some way for me to get both?
EDIT To address a comment, I'm pasting the code I used. Unfortunately, I don't have enough points to add attachments, so I'll also copy the entire error message below.
CODE
def getVolume(self):
return self.poly.volume(measure = "induced", engine="lrs")*factorial(self.poly.dim())
ERROR MESSAGE (long)
KeyError Traceback (most recent call last)
/home/sc_serv/sage/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/misc/cachefunc.pyx in sage.misc.cachefunc.CachedMethodCaller.__call__ (build/cythonized/sage/misc/cachefunc.c:10347)()
1942 try:
-> 1943 return cache[k]
1944 except TypeError: # k is not hashable
KeyError: (('induced', 'lrs'), ())
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
/tmp/ipykernel_162824/3888703736.py in <module>
200 G = DiGraph({Integer(0):[Integer(4),Integer(5),Integer(6),Integer(7),Integer(8)], Integer(1):[Integer(5),Integer(6),Integer(7),Integer(8)], Integer(2):[Integer(6),Integer(7),Integer(8)], Integer(3):[Integer(7),Integer(8)], Integer(4):[Integer(8)], Integer(5):[Integer(8)], Integer(6):[Integer(8)], Integer(7):[Integer(8)]})
201 H=DiGraph({Integer(0):[Integer(2),Integer(3),Integer(4)], Integer(1):[Integer(3),Integer(4)], Integer(2):[Integer(4)], Integer(3):[Integer(4)]})
--> 202 FlowPolytope(H, [Integer(1),Integer(1),Integer(1),Integer(1),-Integer(4)]).getVolume().radical_expression()
203 I=DiGraph({Integer(0):[Integer(4),Integer(5),Integer(6),Integer(7),Integer(8)], Integer(1):[Integer(5),Integer(6),Integer(7),Integer(8)], Integer(2):[Integer(6),Integer(7),Integer(8)], Integer(3):[Integer(7),Integer(8)], Integer(4):[Integer(8)], Integer(5):[Integer(8)], Integer(6):[Integer(8)], Integer(7):[Integer(8)]})
204 FlowPolytope(I, [Integer(1),Integer(1),Integer(1),Integer(1),Integer(1),Integer(1),Integer(1),Integer(1),-Integer(8)]).getVolume().radical_expression()
/tmp/ipykernel_162824/3888703736.py in getVolume(self, eng)
63 needs Sage 5.9 for 'lrs' engine
64 """
---> 65 return self.poly.volume(measure = "induced", engine="lrs")*factorial(self.poly.dim())
66
67 def getVertices(self):
/home/sc_serv/sage/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/misc/cachefunc.pyx in sage.misc.cachefunc.CachedMethodCaller.__call__ (build/cythonized/sage/misc/cachefunc.c:10483)()
1946 return cache[k]
1947 except KeyError:
-> 1948 w = self._instance_call(*args, **kwds)
1949 cache[k] = w
1950 return w
/home/sc_serv/sage/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/misc/cachefunc.pyx in sage.misc.cachefunc.CachedMethodCaller._instance_call (build/cythonized/sage/misc/cachefunc.c:9949)()
1822 True
1823 """
-> 1824 return self.f(self._instance, *args, **kwds)
1825
1826 cdef fix_args_kwds(self, tuple args, dict kwds):
/home/sc_serv/sage/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/geometry/polyhedron/base.py in volume(self, measure, engine, **kwds)
4738 else:
4739 sqrt_Adet = AA(Adet).sqrt()
-> 4740 scaled_volume = AA(scaled_volume)
4741 return scaled_volume / sqrt_Adet
4742 elif measure == 'induced_rational':
/home/sc_serv/sage/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9388)()
896 if mor is not None:
897 if no_extra_args:
--> 898 return mor._call_(x)
899 else:
900 return mor._call_with_args(x, args, kwds)
/home/sc_serv/sage/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4665)()
159 print(type(C), C)
160 print(type(C._element_constructor), C._element_constructor)
--> 161 raise
162
163 cpdef Element _call_with_args(self, x, args=(), kwds={}):
/home/sc_serv/sage/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4557)()
154 cdef Parent C = self._codomain
155 try:
--> 156 return C._element_constructor(x)
157 except Exception:
158 if print_warnings:
/home/sc_serv/sage/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/rings/qqbar.py in _element_constructor_(self, x)
1109 elif hasattr(x, '_algebraic_'):
1110 return x._algebraic_(AA)
-> 1111 return AlgebraicReal(x)
1112
1113 def _repr_(self):
/home/sc_serv/sage/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/rings/qqbar.py in __init__(self, x)
5292 -1.414213562373095?
5293 """
-> 5294 AlgebraicNumber_base.__init__(self, AA, x)
5295 self._ensure_real()
5296
/home/sc_serv/sage/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/rings/qqbar.py in __init__(self, parent, x)
3610 self._descr = ANExtensionElement(QQbar_I_generator, QQbar_I_nf([x[0], -x[1]]))
3611 else:
-> 3612 raise TypeError("Illegal initializer for algebraic number")
3613
3614 prec = 64
TypeError: Illegal initializer for algebraic number
Please provide an example so people have something to experiment with.