我正在使用Parma多面体库(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;
}发布于 2018-06-04 00:58:03
ppl在其约束的定义中需要整数。你将不得不用公分母来衡量你的不平等。
https://stackoverflow.com/questions/49608045
复制相似问题