From a61c7a82b99b0c38676a5ee5fa879b8fca5844e4 Mon Sep 17 00:00:00 2001 From: Adrian Manteza Date: Tue, 22 Mar 2022 20:31:17 +0000 Subject: [PATCH] make the print problem optional in local dev --- app/helpers/service_helper.py | 5 +++-- app/services/loft_service.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/helpers/service_helper.py b/app/helpers/service_helper.py index a8ad6f7..7cee388 100644 --- a/app/helpers/service_helper.py +++ b/app/helpers/service_helper.py @@ -112,8 +112,9 @@ def solution_items(variables, solver_run): return form_items -def print_problem_logs(problem): - print(problem); +def print_problem_variables(problem): + # Uncomment this as needed in local dev + # print(problem); for v in problem.variables(): print(v.name, "=", v.varValue); # probably a better place for this... diff --git a/app/services/loft_service.py b/app/services/loft_service.py index b999e48..32ea6f2 100644 --- a/app/services/loft_service.py +++ b/app/services/loft_service.py @@ -160,8 +160,8 @@ class LoftService(Base): if LpStatus[problem.status] == 'Infeasible': logging.info(f'attempt infeasible for drift of {current_drift}%') - if current_drift == Target.max_drift(): # this is the last attempt, so lets finalize the solution - if ApplicationConfigs.local_dev_env: service_helper.print_problem_logs(problem); + if current_drift >= Target.max_drift(): # this is the last attempt, so lets finalize the solution + if ApplicationConfigs.local_dev_env: service_helper.print_problem_variables(problem); logging.info(f'No feasible solution found for Form {form_number}!') @@ -171,7 +171,7 @@ class LoftService(Base): current_drift += Target.max_drift_increment() else: - if ApplicationConfigs.local_dev_env: service_helper.print_problem_logs(problem); + if ApplicationConfigs.local_dev_env: service_helper.print_problem_variables(problem); logging.info(f'Optimal solution found with drift of {current_drift}%!')