0

I attempted to use **pycddlib ** to find vertices in a polytope with Python. I followed the code in this post. Polytope, Python - find extreme points

import numpy as np
import cdd as pcdd

A = np.array([[0,1,0,1,0], [0,0,1,0,1], [1,0,0,0,1], [0,1,1,0,0], [1,0,0,0,0]])
K = A - A.transpose()
C = np.vstack( (K, -np.eye(5), [1]*5) )
b = [[0]]*10 + [[1]]
M = np.hstack( (b, -C) )


mat = pcdd.Matrix(M, linear=False, number_type="fraction") 
mat.rep_type = pcdd.RepType.INEQUALITY

poly = pcdd.Polyhedron(mat)
ext = poly.get_generators()
print(ext)

However, python reports the following error message:

Traceback (most recent call last):
  File "C:\Users\Lenovo\PycharmProjects\PythonProject\.venv\main.py", line 10, in <module>
    mat = pcdd.Matrix(M, linear=False, number_type="fraction")
TypeError: __init__() takes exactly 0 positional arguments (1 given)

I have installed numpy and pycddlib, but couldn't figure out the issue.

1
  • It seems to be a configuration problem. I copy pasted the snippet and it worked for me. cdd 2.1.6, numpy 1.23.4 and python 3.10.12 The output from your example is "V-representation begin 3 6 rational 1 1/3 0 1/3 1/3 0 1 0 0 0 1/2 1/2 1 0 0 0 0 0 end" Commented Jan 4 at 21:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.