First time here? Check out the FAQ!

Ask Your Question
2

Computing polyhedron from MIP

asked 8 years ago

mforets gravatar image

updated 2 years ago

tmonteil gravatar image

I want to run the following code (I'm using SAGE v6.10 release version 2015-12-18):

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()

However, it outputs the error message:

AttributeError: type object 'float' has no attribute 'fraction_field'

I noticed that if instead of using real variables I use only integer variables, then it works fine. For instance:

P = MixedIntegerLinearProgram()
x = P.new_variable()
A = random_matrix(ZZ, 3, 2); 
P.add_constraint(A*x <= [2,1,0]) 
P.polyhedron()

outputs:

A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 1 vertex and 2 rays

What do you suggest to overcome this problem?

Thanks

Preview: (hide)

Comments

About 2 years ago (not sure which version of Sage that was), the polyhedron worked. But, it appears to be an issue now.

calc314 gravatar imagecalc314 ( 8 years ago )

Thanks. Anyway, I should try installing sagemath v7.2.

mforets gravatar imagemforets ( 8 years ago )

Adding confirmed_bug tag, and a link to trac ticket 23326.

tmonteil gravatar imagetmonteil ( 7 years ago )

@tmonteil : great, thanks.

mforets gravatar imagemforets ( 7 years ago )
1

It is fixed in 8.0

sage: P = MixedIntegerLinearProgram()
sage: x = P.new_variable()
sage: A = random_matrix(ZZ, 3, 2); 
sage: P.add_constraint(A*x <= [2,1,0]) 
sage: P.polyhedron()
A 2-dimensional polyhedron in RDF^2 defined as the convex hull of 3 vertices
vdelecroix gravatar imagevdelecroix ( 7 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 8 years ago

tmonteil gravatar image

updated 6 years ago

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
Preview: (hide)
link

Comments

Nice workaround!

mforets gravatar imagemforets ( 8 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 8 years ago

Seen: 479 times

Last updated: Sep 17 '18