Open NicolasRouquette opened 1 year ago
The problem is in this function in pacti.terms.polyhedra.plots
:
def _get_feasible_point(a_mat: np.ndarray, b: np.ndarray, interior: bool = True) -> np.ndarray:
a_mat_1 = np.concatenate((a_mat, np.linalg.norm(a_mat, axis=1, keepdims=True)), axis=1)
a_mat_new = np.concatenate((a_mat_1, np.array([[0, 0, -1]])), axis=0)
b_new = np.concatenate((np.reshape(b, (-1, 1)), np.array([[0]])), axis=0)
obj = np.array([0, 0, 1])
if interior:
obj = np.array([0, 0, -1])
res = linprog(c=obj, A_ub=a_mat_new, b_ub=b_new, bounds=(None, None))
if res["status"] == 2:
raise ValueError("Constraints are unfeasible")
return np.array(res["x"])[0:-1] # noqa: WPS349 Found redundant subscript slice
The logic lacks a check for res["status"] == 3
(unbounded variables).
From what I recall, the function plot_guarantees
should never find unbounded behavior. This is because the bounds provided by the user are used as additional constraints in the optimization.
Why are you calling _get_bounding_vertices
directly?
Describe the bug A clear and concise description of what the bug is.
Plotting constraints can produce a strange error.
To Reproduce Steps to reproduce the behavior:
Expected behavior A clear and concise description of what you expected to happen.
No error
Screenshots If applicable, add screenshots to help explain your problem.
System (please complete the following information):
Additional context Add any other context about the problem here.