Skip to content

Commit ac9601e

Browse files
authored
[_dq_quadprog_solver.py] Allowing only equality constraints as well.
1 parent 81c23b7 commit ac9601e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

dqrobotics/solvers/_dq_quadprog_solver.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
# Copyright (c) 2019-2022 DQ Robotics Developers
2+
# Copyright (c) 2019-2026 DQ Robotics Developers
33
#
44
# This file is part of DQ Robotics.
55
#
@@ -62,16 +62,18 @@ def solve_quadratic_program(self, H, f, A, b, Aeq, beq):
6262
:param beq: the m x 1 value for the inequality constraints.
6363
:return: the optimal x
6464
"""
65-
A_internal = A
66-
b_internal = b
67-
if Aeq is not None and beq is not None:
65+
A_internal = A if A is not None else Aeq
66+
b_internal = b if b is not None else beq
67+
if A is not None and B is not None Aeq is not None and beq is not None:
6868
if Aeq.shape == (0, 0) or beq.shape == 0:
6969
pass
7070
else:
7171
A_internal = np.vstack([A, Aeq, -Aeq])
7272
beq = beq.reshape(-1)
7373
b_internal = np.concatenate([b.reshape(-1), beq + self.equality_constraints_tolerance,
7474
-beq + self.equality_constraints_tolerance])
75+
else:
76+
raise ValueError("A, b, Aeq, beq, cannot all be None.")
7577
if A_internal.shape == (0, 0) or b_internal.shape == 0:
7678
# Calls from DQRobotics CPP will trigger this condition
7779
A_internal = np.zeros((1, H.shape[0]))

0 commit comments

Comments
 (0)