Skip to content

Commit

Permalink
Enable printing by default
Browse files Browse the repository at this point in the history
  • Loading branch information
govindchari committed Feb 5, 2025
1 parent 1ce2626 commit 3329c27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions qocogen/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def generate_cmakelists(solver_dir):
f = open(solver_dir + "/CMakeLists.txt", "a")
f.write("cmake_minimum_required(VERSION 3.18)\n")
f.write("project(qoco_custom)\n\n")
f.write("if(ENABLE_PRINTING)\n")
f.write(" add_compile_definitions(ENABLE_PRINTING)\n")
f.write("if(DISABLE_PRINTING)\n")
f.write(" add_compile_definitions(DISABLE_PRINTING)\n")
f.write("endif()\n\n")
f.write("if(QOCO_CUSTOM_BUILD_TYPE STREQUAL Debug)\n")
f.write(" set(QOCO_CUSTOM_BUILD_TYPE Debug)\n")
Expand Down Expand Up @@ -1083,7 +1083,7 @@ def generate_utils(
f.write("unsigned char check_stopping(Workspace* work);\n")
f.write("void copy_solution(Workspace* work);\n")
f.write("void unscale_solution(Workspace* work);\n")
f.write("#ifdef ENABLE_PRINTING\n")
f.write("#ifndef DISABLE_PRINTING\n")
f.write("#include <stdio.h>\n")
f.write("void print_header(Workspace* work);\n")
f.write("void print_footer(Workspace* work);\n")
Expand Down Expand Up @@ -1585,7 +1585,7 @@ def generate_utils(
Gnnz = len(G.data) if G is not None else 0

f.write("void print_header(Workspace* work) {\n")
f.write("#ifdef ENABLE_PRINTING\n")
f.write("#ifndef DISABLE_PRINTING\n")
f.write(' printf("\\n");\n')
f.write(
' printf("+-------------------------------------------------------+\\n");\n'
Expand Down Expand Up @@ -1665,7 +1665,7 @@ def generate_utils(
f.write("}\n\n")

f.write("void print_footer(Workspace* work) {\n")
f.write("#ifdef ENABLE_PRINTING\n")
f.write("#ifndef DISABLE_PRINTING\n")
f.write(
' printf("\\nstatus: %s ", QOCO_CUSTOM_SOLVE_STATUS_MESSAGE[work->sol.status]);\n'
)
Expand All @@ -1675,7 +1675,7 @@ def generate_utils(
f.write("}\n\n")

f.write("void log_iter(Workspace* work) {\n")
f.write("#ifdef ENABLE_PRINTING\n")
f.write("#ifndef DISABLE_PRINTING\n")
f.write(
'printf("| %2d | %+.2e | %+.3e | %+.3e | %+.3e | %+.2e | %.3f |\\n",work->sol.iters, work->sol.obj, work->sol.pres, work->sol.dres, work->sol.gap, work->mu, work->a);'
)
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/run_generated_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def run_generated_solver(solver_dir):
os.system(
"cd "
+ solver_dir
+ " && mkdir build && cd build && cmake -DQOCO_CUSTOM_BUILD_TYPE:STR=Release -DENABLE_PRINTING:BOOL=TRUE .. && make && ./runtest && cd ../.."
+ " && mkdir build && cd build && cmake -DQOCO_CUSTOM_BUILD_TYPE:STR=Release .. && make && ./runtest && cd ../.."
)
with open(solver_dir + "/build/result.bin", "rb") as file:
# Read the unsigned int (4 bytes)
Expand Down

0 comments on commit 3329c27

Please sign in to comment.