Ask Your Question

Revision history [back]

A workaround ould be the following. Thanks to linearity, you can:

  • approximate all the real numbers by closest rational, for example

    sage: QQ(1.2) 6/5

  • find a common denominator of each entry (using the gcd function an the denominator method for rational numbers)

  • make an integer program out of this
  • construct the polyhedron as wanted
  • rescale the polyhedron : if P is a polyhedron and q is an integer, the fraction P/q is well defined in Sage and will result into a rescaled polyhedron.

A workaround ould be the following. Thanks to linearity, you can:

  • approximate all the real numbers by closest rational, for example

    sage: QQ(1.2) example QQ(1.2) results in 6/5

  • find a common denominator of each entry (using the gcd function an the denominator method for rational numbers)

  • make an integer program out of this
  • construct the polyhedron as wanted
  • rescale the polyhedron : if P is a polyhedron and q is an integer, the fraction P/q is well defined in Sage and will result into a rescaled polyhedron.

A workaround ould be the following. Thanks to linearity, you can:

  • approximate all the real numbers by closest rational, for example QQ(1.2) results in 6/5
  • find a common denominator of each entry (using the gcd function an the denominator method for rational numbers)
  • make an integer program out of this
  • construct the polyhedron as wanted
  • rescale the polyhedron : if P is a polyhedron and q is an integer, the fraction P/q is well defined in Sage and will result into a rescaled polyhedron.

EDIT: note that with recent versions of Sage the polyhedron method works again for floating-point linear programs:

sage: P = MixedIntegerLinearProgram()
....: x = P.new_variable()
....: A = random_matrix(RR, 3, 2); 
....: P.add_constraint(A*x <= [2.1,1.5,0.4]) 
....: P.polyhedron()
....: 
A 2-dimensional polyhedron in RDF^2 defined as the convex hull of 2 vertices and 2 rays