From 6bcc275e74da1156fb0ec610e18b7cf42c559ec2 Mon Sep 17 00:00:00 2001
From: sapling <281042132@qq.com>
Date: Sun, 27 Oct 2024 16:57:45 +0800
Subject: [PATCH 1/4] feat:add fingerprint show
---
.vscode/launch.json | 22 ++++++++++++++++++++++
_app/overview.py | 21 +++++++++++++++++++++
2 files changed, 43 insertions(+)
create mode 100644 .vscode/launch.json
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..da4f23d
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,22 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+
+ {
+ "name": "Python: Streamlit",
+ "type": "debugpy",
+ "request": "launch",
+ "module": "streamlit",
+ "args": [
+ "run",
+ "${workspaceFolder}/app.py",
+ "--server.address",
+ "127.0.0.1",
+ "--server.port",
+ "6006"
+ ],
+ "console": "integratedTerminal",
+ "justMyCode": true
+ }
+ ]
+}
\ No newline at end of file
diff --git a/_app/overview.py b/_app/overview.py
index b3cef22..83181d8 100644
--- a/_app/overview.py
+++ b/_app/overview.py
@@ -5,6 +5,8 @@
SolverBlock,
ResponseBlock,
InitialModelBlock,
+ SolutionsBlock,
+ PresolvedModelBlock,
)
@@ -21,6 +23,8 @@ def show_overview(parser):
try:
solver_block = parser.get_block_of_type(SolverBlock)
initial_model_block = parser.get_block_of_type(InitialModelBlock)
+ presolved_model_block = parser.get_block_of_type(PresolvedModelBlock)
+ solution_block = parser.get_block_of_type(SolutionsBlock)
search_progress_block = parser.get_block_of_type(SearchProgressBlock)
response_block = parser.get_block_of_type(ResponseBlock)
col1, col2 = st.columns(2)
@@ -135,6 +139,23 @@ def show_overview(parser):
if fig:
# because we display this figure twice, we need to give it a unique key
st.plotly_chart(fig, use_container_width=True, key="search_progress_overview")
+
+ initial_fingerprint = initial_model_block.get_model_fingerprint()
+ presolved_fingerprint = presolved_model_block.get_model_fingerprint()
+ num_solutions = solution_block.get_num_solutions()
+
+ st.markdown("The following section displays the fingerprints of the initial model, the presolved model, and the solution. Hover over the truncated values to see the full fingerprint or number.")
+ markdown_content = f"""
+ > **Initial Model Fingerprint**:
{initial_fingerprint[:100]}
+ >
+ > **Presolved Model Fingerprint**: {presolved_fingerprint[:100]}
+ >
+ > **Solution Model Fingerprint**: {num_solutions}
+ """
+
+ # 使用 st.markdown 渲染 Markdown 内容
+ st.markdown(markdown_content, unsafe_allow_html=True)
+
except KeyError as ke:
st.error(
f"Error parsing information. Log seems to be incomplete: {ke}. Make sure you enter the full log without any modifications. The parser is sensitive to new lines."
From 2f3b5e3ff6b0bf9157f810440c0af6b695c34eab Mon Sep 17 00:00:00 2001
From: sapling <281042132@qq.com>
Date: Sun, 27 Oct 2024 17:00:26 +0800
Subject: [PATCH 2/4] feat:add fingerprint show
---
.vscode/launch.json | 22 ----------------------
1 file changed, 22 deletions(-)
delete mode 100644 .vscode/launch.json
diff --git a/.vscode/launch.json b/.vscode/launch.json
deleted file mode 100644
index da4f23d..0000000
--- a/.vscode/launch.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "version": "0.2.0",
- "configurations": [
-
- {
- "name": "Python: Streamlit",
- "type": "debugpy",
- "request": "launch",
- "module": "streamlit",
- "args": [
- "run",
- "${workspaceFolder}/app.py",
- "--server.address",
- "127.0.0.1",
- "--server.port",
- "6006"
- ],
- "console": "integratedTerminal",
- "justMyCode": true
- }
- ]
-}
\ No newline at end of file
From 9f73facf8bc139c1bfe06525384130243ff2ed25 Mon Sep 17 00:00:00 2001
From: sapling <281042132@qq.com>
Date: Sun, 27 Oct 2024 17:03:06 +0800
Subject: [PATCH 3/4] feat:add fingerprint show
---
_app/overview.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/_app/overview.py b/_app/overview.py
index 83181d8..7cfb21b 100644
--- a/_app/overview.py
+++ b/_app/overview.py
@@ -153,7 +153,6 @@ def show_overview(parser):
> **Solution Model Fingerprint**: {num_solutions}
"""
- # 使用 st.markdown 渲染 Markdown 内容
st.markdown(markdown_content, unsafe_allow_html=True)
except KeyError as ke:
From 78b7f50310f8b1a13ca5bf6ad4df25f974321b4a Mon Sep 17 00:00:00 2001
From: sapling <281042132@qq.com>
Date: Sun, 27 Oct 2024 18:30:43 +0800
Subject: [PATCH 4/4] feat:add solution fingerprint
---
.gitignore | 2 ++
_app/overview.py | 7 +++----
cpsat_log_parser/blocks/solver_response.py | 6 ++++++
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/.gitignore b/.gitignore
index 7b7f2e9..9843490 100644
--- a/.gitignore
+++ b/.gitignore
@@ -131,3 +131,5 @@ dmypy.json
examples/tsp_evaluation/PRIVATE_DATA/full_experiment_data
evaluations/tsp/2023-11-18_random_euclidean/PRIVATE_DATA
evaluations/tsp/2023-11-18_tsplib/PRIVATE_DATA
+
+.vscode/
\ No newline at end of file
diff --git a/_app/overview.py b/_app/overview.py
index 7cfb21b..7a955c2 100644
--- a/_app/overview.py
+++ b/_app/overview.py
@@ -24,7 +24,6 @@ def show_overview(parser):
solver_block = parser.get_block_of_type(SolverBlock)
initial_model_block = parser.get_block_of_type(InitialModelBlock)
presolved_model_block = parser.get_block_of_type(PresolvedModelBlock)
- solution_block = parser.get_block_of_type(SolutionsBlock)
search_progress_block = parser.get_block_of_type(SearchProgressBlock)
response_block = parser.get_block_of_type(ResponseBlock)
col1, col2 = st.columns(2)
@@ -142,15 +141,15 @@ def show_overview(parser):
initial_fingerprint = initial_model_block.get_model_fingerprint()
presolved_fingerprint = presolved_model_block.get_model_fingerprint()
- num_solutions = solution_block.get_num_solutions()
+ solution_fingerprint = response_block.get_solution_fingerprint()
- st.markdown("The following section displays the fingerprints of the initial model, the presolved model, and the solution. Hover over the truncated values to see the full fingerprint or number.")
+ st.markdown("The following section displays the fingerprints of the initial model, the presolved model, and the solution.")
markdown_content = f"""
> **Initial Model Fingerprint**: {initial_fingerprint[:100]}
>
> **Presolved Model Fingerprint**: {presolved_fingerprint[:100]}
>
- > **Solution Model Fingerprint**: {num_solutions}
+ > **Solution Fingerprint**: {solution_fingerprint}
"""
st.markdown(markdown_content, unsafe_allow_html=True)
diff --git a/cpsat_log_parser/blocks/solver_response.py b/cpsat_log_parser/blocks/solver_response.py
index c5d855a..24b59d9 100644
--- a/cpsat_log_parser/blocks/solver_response.py
+++ b/cpsat_log_parser/blocks/solver_response.py
@@ -11,6 +11,12 @@ def __init__(self, lines: typing.List[str]) -> None:
def matches(lines: typing.List[str]) -> bool:
return lines[0].startswith("CpSolverResponse") if lines else False
+ def get_solution_fingerprint(self) -> str:
+ for line in self.lines:
+ if "solution_fingerprint" in line:
+ return line.split("solution_fingerprint:")[1].strip(")")
+ return "None"
+
def get_title(self) -> str:
return "CpSolverResponse"