mcmtroffaes / pycddlib

A Python wrapper for Komei Fukuda's cddlib.
http://packages.python.org/pycddlib/
GNU General Public License v2.0
61 stars 9 forks source link

Rays computed correctly ? #46

Closed tzcntrl closed 4 years ago

tzcntrl commented 4 years ago

Hi, in case of running the following code:

############################### Code begin ############################ import cdd import numpy as np from fractions import Fraction

PA = np.array([[1,0]]) Pb = np.array([[1]])

h = cdd.Matrix(np.concatenate([Pb,-PA],axis=1) + Fraction(), number_type='fraction')

h.rep_type = cdd.RepType.INEQUALITY H = cdd.Polyhedron(h) print(H.get_generators()) ############################### Code end ############################

I get the following result:

V-representation linearity 1 3 begin 3 3 rational 0 -1 0 1 1 0 0 0 1 end

Now, two questions arise: 1) The documentation says the vector t of the V-representation [t V] should start with ones, being followed by zeros according to the numbers of rays. Why is this not the case here? 2) The Polyhedron that is given by the tuple (PA, Pb) is a halfspace going vertically through the point/vertex v = [1,0]. However, the V-representation shown above gives me something else except for the case that the first ray is meant to be a line. Is this correct?

mcmtroffaes commented 4 years ago
  1. The ordering is not guaranteed (the documentation merely gives a canonical example).
  2. The representation seems correct to me: {(x1,x2):x1<=1}={(1,0)+a(-1,0)+b(0,1):a>=0} - the "linearity 1 3" line means the 3rd ray is fully linear.
tzcntrl commented 4 years ago

Ok, that was kind of hard to understand from the documentation. Thank you very much for your explanation.

mcmtroffaes commented 4 years ago

Sure, it's a standard correspondence in duality (primal equalities corresponding to dual free variables) so it's should be obvious to anyone having a basic understanding of the theory. It's not really explained in the cddlib docs either. Maybe it's worth adding a note in the pycddlib docs.

mcmtroffaes commented 4 years ago

It's now here: https://pycddlib.readthedocs.io/en/latest/matrix.html

tzcntrl commented 4 years ago

Great, this helps. Thank you very much.