Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[website] Rename the size column to instance, fix size filters #77

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 42 additions & 4 deletions website/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,26 +96,64 @@
+ "h"
)

sizes_df["Spatial resolution"] = sizes_df["Spatial resolution"].apply(
lambda x: f"{x} node" if int(x) == 1 else f"{x} nodes"
)
sizes_df["Temporal resolution"] = (
sizes_df["Temporal resolution"].astype(str) + "h"
)

# Filter the sizes_df to include only sizes present in the results CSV for the selected benchmark
filtered_results = df_result[df_result["Benchmark"] == selected_benchmark]
matching_sizes = filtered_results["Size"].unique()
filtered_sizes_df = sizes_df[sizes_df["Size"].isin(matching_sizes)]

if not filtered_sizes_df.empty:
display_sizes_df = filtered_sizes_df.drop(columns=["Size"])
display_sizes_df = filtered_sizes_df.rename(
columns={
"N. of variables": "n_of_variables",
"N. of constraints": "n_of_constraints",
},
)

# Build grid options for the filtered sizes table
gb_sizes = GridOptionsBuilder.from_dataframe(filtered_sizes_df)
gb_sizes.configure_grid_options(domLayout="autoHeight")
grid_options_sizes = gb_sizes.build()

column_config = [
{
"field": "Size",
"headerName": "Instance",
"pinned": "left",
},
{
"field": "Spatial resolution",
},
{
"field": "Temporal resolution",
},
{
"field": "n_of_variables",
"headerName": "N. of variables",
},
{
"field": "n_of_constraints",
"headerName": "N. of constraints",
},
]

grid_options = {
"columnDefs": column_config,
}

# Display filtered sizes table using ag-Grid
AgGrid(
filtered_sizes_df,
display_sizes_df,
editable=False,
sortable=True,
filter=True,
gridOptions=grid_options_sizes,
gridOptions=grid_options,
fit_columns_on_grid_load=True,
)
else:
Expand Down Expand Up @@ -156,7 +194,7 @@
for solver in status_subset["Solver"].unique():
subset = status_subset[status_subset["Solver"] == solver]
tooltip_text = subset.apply(
lambda row: f"Solver: {row['Solver']}<br>Size: {row['Size']}",
lambda row: f"Solver: {row['Solver']}<br>Instance: {row['Size']}",
axis=1,
)

Expand Down
2 changes: 1 addition & 1 deletion website/components/compare_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def create_comparison_chart(

# Create tooltips for hover information
hover_text = subset.apply(
lambda row: (f"{row['Benchmark']}<br>Size: {row['Size']}"),
lambda row: (f"{row['Benchmark']}<br>Instance: {row['Size']}"),
axis=1,
)

Expand Down
2 changes: 1 addition & 1 deletion website/components/home_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def render_benchmark_scatter_plot(data: pd.DataFrame, metadata, key):
status_symbols.get(status, "circle") for status in subset["Status"]
]
hover_text = subset.apply(
lambda row: f"{row['Benchmark']}<br>Size: {row['Size']}",
lambda row: f"{row['Benchmark']}<br>Instance: {row['Size']}",
axis=1,
)

Expand Down
3 changes: 3 additions & 0 deletions website/raw-results.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,8 @@
# Round the DataFrame values
df = df.round({"Objective Value": 2, "Runtime (s)": 1, "Memory Usage (MB)": 0})

# Rename 'Size' to 'Instance'
df = df.rename(columns={"Size": "Instance"})

# Display the filtered table
filtered_df = display_table(df)
9 changes: 6 additions & 3 deletions website/scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@


def create_subplots(data, y_metric):
# Rename 'Size' to 'Instance'
data = data.rename(columns={"Size": "Instance"})

status_symbols = {
"TO": "x", # Timeout gets an "X"
"ok": "circle", # Normal execution gets a circle
Expand All @@ -22,7 +25,7 @@ def create_subplots(data, y_metric):
color="Solver",
symbol="Status",
symbol_map=status_symbols,
hover_data=["Benchmark", "Size"],
hover_data=["Benchmark", "Instance"],
title="Spatial Resolution",
)

Expand All @@ -33,7 +36,7 @@ def create_subplots(data, y_metric):
color="Solver",
symbol="Status",
symbol_map=status_symbols,
hover_data=["Benchmark", "Size"],
hover_data=["Benchmark", "Instance"],
title="Num Variables",
)

Expand All @@ -44,7 +47,7 @@ def create_subplots(data, y_metric):
color="Solver",
symbol="Status",
symbol_map=status_symbols,
hover_data=["Benchmark", "Size"],
hover_data=["Benchmark", "Instance"],
title="Num Constraints",
)

Expand Down
50 changes: 45 additions & 5 deletions website/utils/filters.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from packaging.version import parse


def filter_data(df, filtered_metadata):
# Extract selected problem sizes from filtered metadata
selected_sizes = filtered_metadata["Selected Problem Size"].iloc[0]
Expand All @@ -11,13 +14,50 @@ def filter_data(df, filtered_metadata):
"L": lambda runtime: runtime > 3600,
}

# Combine conditions based on selected sizes
runtime_condition = df["Runtime (s)"].apply(
# Filter to keep only rows for the solver "highs" first
highs_df = df[df["Solver"] == "highs"].copy()

# Ensure we consider the latest version of each solver
if "Solver Version" in highs_df.columns:
# Ensure all values in "Solver Version" are strings
highs_df["Solver Version"] = highs_df["Solver Version"].astype(str)

# Parse solver versions, handling invalid or missing values
highs_df["Solver Version"] = highs_df["Solver Version"].apply(
lambda x: parse(x) if x and x.lower() != "nan" else None
)

# Sort by Solver, Solver Version (descending), and remove duplicates
highs_df = highs_df.sort_values(
by=["Solver", "Solver Version"], ascending=[True, False]
)
highs_df = highs_df.drop_duplicates(
subset=["Solver", "Size", "Benchmark"], keep="first"
)

# Create a dictionary to map the highest version of highs runtime for each ("Benchmark", "Size")
highs_runtime_dict = highs_df.set_index(["Benchmark", "Size"])[
"Runtime (s)"
].to_dict()

# Add the highs_run_time column to the original df based on the dictionary
df["highs_run_time"] = df.apply(
lambda row: highs_runtime_dict.get((row["Benchmark"], row["Size"]), None),
axis=1,
)

# Combine conditions based on highs_run_time
runtime_condition = df["highs_run_time"].apply(
lambda runtime: any(size_conditions[size](runtime) for size in selected_sizes)
if runtime is not None
else False
)

# Filter df to include only rows meeting the runtime condition
# Filter df to include only rows meeting the runtime condition and filtered benchmarks
filtered_benchmarks = filtered_metadata["Benchmark Name"].unique()
df = df[df["Benchmark"].isin(filtered_benchmarks) & runtime_condition]
filtered_df = df[df["Benchmark"].isin(filtered_benchmarks) & runtime_condition]

# Drop the temporary highs_run_time column
filtered_df = filtered_df.drop(columns=["highs_run_time"], errors="ignore")

return df
return filtered_df
Loading