如何在顶点枚举的浮点算法和精确算法之间进行选择?

2024-09-30 10:26:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用pycddlib(Komei Fukuda的cddlib的Python包装器)生成由线性不等式给出的多面体的所有顶点。为了防止由浮点运算引起的计算不准确,我想使用精确运算。在cddlib中,据说

When some strange behavior is observed, it is always wise to create a rational approximation of the input (for example, one can replace 0.3333333 with 1/3) and to compute it with cddlib compiled with GMP Rational to see what a correct behavior should be. Whenever the time is not important, it is safer to use GMP rational arithmetic.

通过定义不等式,可以选择分数而不是浮点:mat = cdd.Matrix([[2,-1,-1,0],[0,1,0,0],[0,0,1,0]], number_type='fraction') 但是我怎么知道ccdlib现在是否是用GMP Rational编译的呢


Tags: thetoiswithit线性rational多面体

热门问题