From 754c204b4fe24ceb7feda8b5103fcf1b182bf07f Mon Sep 17 00:00:00 2001 From: JAJHall Date: Wed, 28 Aug 2024 12:43:53 +0100 Subject: [PATCH] plot_highs_log.py now avoids printing spurious incumbent lines when best solution is NaN --- examples/plot_highs_log.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/plot_highs_log.py b/examples/plot_highs_log.py index e3fe0150b0..6163c96039 100644 --- a/examples/plot_highs_log.py +++ b/examples/plot_highs_log.py @@ -1,6 +1,7 @@ import re import matplotlib.pyplot as plt import numpy as np +import math as math def parse_highs_log(log_file_path): @@ -107,7 +108,8 @@ def plot_highs_log( # Plot vertical hash lines where Best Solution changes for i in range(1, len(best_sol_values)): - if best_sol_values[i] != best_sol_values[i - 1]: # Change detected + # Print if change detected and not NaN + if (best_sol_values[i] != best_sol_values[i - 1]) and not(math.isnan(best_sol_values[i])): ax1.axvline(x=time_values[i], color="grey", linestyle="--", linewidth=0.5) # Shift plot area left to make room on the right for the three y-axis labels.