【问题标题】:Parma Polyhedra Library: Vertex Enumeration and Floating-Point ArithmeticParma 多面体库:顶点枚举和浮点运算
【发布时间】:2018-04-02 08:44:43
【问题描述】:

我正在使用帕尔马多面体库 (PPL) 对给定多面体进行顶点枚举。这已经讨论过here。但是,我无法弄清楚如何在计算中使用有理数而不是整数。

下面的代码生成一个线段 [0.3,3.7](一维凸多面体),PPL 返回两个整数 {0,3},但我想要有理数 {0.3,3.7}。我如何建议 PPL 使用有理数(浮点运算)?

    #include <cstddef>
    #include <stdio.h>
    #include "ppl.hh"

    using namespace Parma_Polyhedra_Library;

    int main() {
      Variable x(0);
      C_Polyhedron ph(1);
      ph.refine_with_constraint( x <= 3.7);
      ph.refine_with_constraint( x >= 0.3);

      Generator_System gs = ph.generators();
      for(Generator_System::const_iterator it = gs.begin(); it != gs.end(); it++) {
        const Generator& g = *it;
        std::cout << g.coefficient(x) << std::endl;
      }
      return 0;
    }

【问题讨论】:

    标签: c++ discrete-mathematics polyhedra


    【解决方案1】:

    ppl 在其约束的定义中期望整数。你将不得不用公分母来衡量你的不平等。

    【讨论】:

      猜你喜欢
      • 2015-07-13
      • 1970-01-01
      • 2012-12-20
      • 1970-01-01
      • 2016-08-23
      • 2014-01-24
      • 2012-03-19
      • 2021-09-26
      相关资源
      最近更新 更多