Skip to content

Commit 9ac9478

Browse files
committed
Improved printing in user_callback of examples/call_highs_from_python.py, and using dev_run = True
1 parent 48f19da commit 9ac9478

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

examples/call_highs_from_python.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,19 +242,20 @@ def user_callback(
242242
data_in,
243243
user_callback_data
244244
):
245-
# dev_run = True
246-
dev_run = False
245+
dev_run = True
246+
#dev_run = False
247247

248248
# Callback for MIP Improving Solution
249249
if callback_type == hscb.HighsCallbackType.kCallbackMipImprovingSolution:
250250
# Assuming it is a list or array
251251
assert user_callback_data is not None, "User callback data is None!"
252252

253253
if dev_run:
254-
print(f"userCallback(type {callback_type};")
255-
print(f"data {user_callback_data:.4g}): {message}")
256-
print(f"with objective {data_out.objective_function_value}")
254+
print(f"userCallback(type {callback_type}; "
255+
f"data {user_callback_data:.4g}): {message} "
256+
f"with objective {data_out.objective_function_value:.4g}")
257257
print(f"and solution[0] = {data_out.mip_solution[0]}")
258+
print(f"and solution[1] = {data_out.mip_solution[1]}")
258259

259260
# Check and update the objective function value
260261
assert (
@@ -289,11 +290,12 @@ def user_callback(
289290

290291
elif callback_type == hscb.HighsCallbackType.kCallbackMipInterrupt:
291292
if dev_run:
292-
print(f"userInterruptCallback(type {callback_type}): {message}")
293+
print(f"userInterruptCallback(type {callback_type}; "
294+
f"data {user_callback_data:.4g}): {message} "
295+
f"with objective {data_out.objective_function_value:.4g}")
293296
print(f"Dual bound = {data_out.mip_dual_bound:.4g}")
294297
print(f"Primal bound = {data_out.mip_primal_bound:.4g}")
295298
print(f"Gap = {data_out.mip_gap:.4g}")
296-
print(f"Objective = {data_out.objective_function_value:.4g}")
297299

298300
data_in.user_interrupt = (
299301
data_out.objective_function_value < user_callback_data

0 commit comments

Comments
 (0)