Skip to content

Commit f54e1b5

Browse files
committed
Fix bug with having 0 in P.data, A.data, and G.data
1 parent 53e9aef commit f54e1b5

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "qocogen"
7-
version = "0.1.4"
7+
version = "0.1.5"
88
description = "QOCOGEN: Custom Code Generator for the QOCO solver"
99
readme = "README.md"
1010
requires-python = ">=3.8"

qocogen/codegen.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ def _generate_solver(
1414
):
1515
solver_dir = output_dir + "/" + name
1616

17+
# Need to handle case where 0 is in P.data, A.data, or G.data.
18+
if P is not None:
19+
for i in range(P.nnz):
20+
if P.data[i] == 0:
21+
P.data[i] += 1e-16
22+
if A is not None:
23+
for i in range(A.nnz):
24+
if A.data[i] == 0:
25+
A.data[i] += 1e-16
26+
if G is not None:
27+
for i in range(G.nnz):
28+
if G.data[i] == 0:
29+
G.data[i] += 1e-16
1730
print("\n")
1831
if os.path.exists(solver_dir):
1932
print("Removing existing solver.")
@@ -1674,7 +1687,7 @@ def generate_utils(
16741687
' printf("| QOCO Custom Generated Solver |\\n");\n'
16751688
)
16761689
f.write(
1677-
' printf("| (c) Govind M. Chari, 2024 |\\n");\n'
1690+
' printf("| (c) Govind M. Chari, 2025 |\\n");\n'
16781691
)
16791692
f.write(
16801693
' printf("| University of Washington Autonomous Controls Lab |\\n");\n'

0 commit comments

Comments
 (0)