Skip to content
Snippets Groups Projects
Commit cadb69da authored by Dominik Krupke's avatar Dominik Krupke
Browse files

adds debug

parent 99fe55c9
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
# Experiment 24: Parallel CP-SAT
# Experiment 25: Parallel CP-SAT for BAFT
Also for BAFT, we see that 4 threads perform best on a Ryzen7 5800X.
Here even stronger than for AFT.
This is very surprising.
%% Cell type:code id: tags:
``` python
import datetime
from aemeasure import read_as_pd, unpack
from aemeasure.evaluation_tools.interval_tables import convert_to_percentage_interval
from aemeasure.plotting import quick_plot_setup
import matplotlib.pyplot as plt
from utils.json import read_instance
import pandas as pd
import seaborn as sns
quick_plot_setup(use_tex=True)
```
%% Cell type:code id: tags:
``` python
unpack("01_results.json")
table = read_as_pd("./01_results.json", ["instance", "solver", "timelimit", "infeasible", "threads", "resolution", "use_lp_minmax", "use_all_different", "Solution", "runtime", "opt", "rounding", "hostname", "timestamp"])
table = table[table["timelimit"]==30]
table.drop_duplicates(subset=["instance", "solver", "threads"], inplace=True)
```
%% Output
Following ZIPs are detected:
01_results_2021-06-29.zip
01_results_2021-06-30.zip
01_results_2021-07-02.zip
Choosing: 01_results_2021-07-02.zip
Loaded dataframe ./01_results.json
Executed on: ['algry03']
During: 2021-06-30 21:47:47.031810 and 2021-07-02 06:13:03.227038
%% Cell type:code id: tags:
``` python
# Extend instance information
table["edges"] = table["instance"].apply(lambda i: read_instance(i).graph.number_of_edges())
table["points"] = table["instance"].apply(lambda i: read_instance(i).graph.number_of_nodes())
table["Instance-type"] = table["instance"].apply(lambda s: "Celestial" if "cel_graph" in s else "General")
table["Solved"] = table["opt"].apply(lambda x: 100.0 if x else 0.0)
table
```
%% Output
instance \
0 ../../instance_based_pn_msc/cel_graph_370.json
1 ../../instance_based_pn_msc/cel_graph_370.json
2 ../../instance_based_pn_msc/cel_graph_370.json
3 ../../instance_based_pn_msc/cel_graph_370.json
4 ../../instance_based_pn_msc/cel_graph_370.json
... ...
9285 ../../instance_based_pn_msc/general_1416.json
9286 ../../instance_based_pn_msc/general_1416.json
9287 ../../instance_based_pn_msc/general_1416.json
9288 ../../instance_based_pn_msc/general_1416.json
9289 ../../instance_based_pn_msc/general_1416.json
solver resolution threads \
0 CPB(Integralizer(1000000, floor), threads=1, N... 1000000 1
1 CPB(Integralizer(1000000, floor), threads=2, N... 1000000 2
2 CPB(Integralizer(1000000, floor), threads=4, N... 1000000 4
3 CPB(Integralizer(1000000, floor), threads=8, N... 1000000 8
4 CPB(Integralizer(1000000, floor), threads=16, ... 1000000 16
... ... ... ...
9285 CPB(Integralizer(1000000, floor), threads=1, N... 1000000 1
9286 CPB(Integralizer(1000000, floor), threads=2, N... 1000000 2
9287 CPB(Integralizer(1000000, floor), threads=4, N... 1000000 4
9288 CPB(Integralizer(1000000, floor), threads=8, N... 1000000 8
9289 CPB(Integralizer(1000000, floor), threads=16, ... 1000000 16
rounding Solution opt timelimit runtime \
0 floor 2.667265 True 30 0.815501
1 floor 2.667265 True 30 0.852575
2 floor 2.667265 True 30 0.575475
3 floor 2.667265 True 30 0.579792
4 floor 2.667265 True 30 0.644997
... ... ... ... ... ...
9285 floor 2.484583 False 30 31.048664
9286 floor 2.484583 False 30 31.084929
9287 floor 2.459897 True 30 9.988468
9288 floor 2.459897 True 30 12.961630
9289 floor 2.459897 True 30 26.031481
timestamp hostname edges points Instance-type Solved
0 2021-06-30T21:47:47.031810 algry03 84 15 Celestial 100.0
1 2021-06-30T21:47:47.887464 algry03 84 15 Celestial 100.0
2 2021-06-30T21:47:48.467834 algry03 84 15 Celestial 100.0
3 2021-06-30T21:47:49.053590 algry03 84 15 Celestial 100.0
4 2021-06-30T21:47:49.704772 algry03 84 15 Celestial 100.0
... ... ... ... ... ... ...
9285 2021-07-02T06:11:35.895159 algry03 323 31 General 0.0
9286 2021-07-02T06:12:08.774545 algry03 323 31 General 0.0
9287 2021-07-02T06:12:20.597599 algry03 323 31 General 100.0
9288 2021-07-02T06:12:35.378897 algry03 323 31 General 100.0
9289 2021-07-02T06:13:03.227038 algry03 323 31 General 100.0
[9290 rows x 15 columns]
%% Cell type:code id: tags:
``` python
# Smooth the data by using intervals
percentage = 5
interval_table = convert_to_percentage_interval(table, on_column="points", percentage=percentage)
```
%% Cell type:markdown id: tags:
## Solved in time
## Number of instances solved to optimality
%% Cell type:code id: tags:
``` python
percentage = 5
interval_table = convert_to_percentage_interval(table, on_column="points", percentage=percentage)
t = table.groupby(["threads"])["opt"].sum()
t["Instances"]=len(table["instance"].unique())
t
```
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(5,3.5))
t = interval_table.groupby(["points", "threads"])["Solved"].mean().reset_index()
sns.lineplot(data=t, x="points", y="Solved", hue="threads", style="threads", palette="tab10")
plt.ylabel("Solved within 10s (\%)")
plt.xlabel(f"Number of points (±{percentage}\%)")
plt.legend(loc="upper left")
plt.tight_layout()
plt.savefig("02a_solved_in_percent.pdf")
plt.show()
```
%% Output
findfont: Font family ['serif'] not found. Falling back to DejaVu Sans.
%% Cell type:markdown id: tags:
## Average runtime
%% Cell type:code id: tags:
``` python
table.groupby(["threads"])["runtime"].mean()
```
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(5,3.5))
sns.lineplot(data=interval_table, x="points", y="runtime", hue="threads", style="threads", palette="tab10")
plt.ylabel("Runtime (s)")
plt.xlabel(f"Number of points (±{percentage}\%)")
plt.legend(loc="upper left")
plt.tight_layout()
plt.savefig("02b_runtime.pdf")
plt.show()
```
%% Output
%% Cell type:code id: tags:
``` python
t = table.groupby(["threads"])["opt"].sum()
t["Instances"]=len(table["instance"].unique())
t
```
%% Output
threads
1 1163
2 1171
4 1477
8 1433
16 1427
Instances 1858
Name: opt, dtype: int64
%% Cell type:code id: tags:
``` python
table.groupby(["threads"])["runtime"].mean()
```
%% Output
threads
1 13.945694
2 13.961070
4 9.369919
8 10.016697
16 10.677972
Name: runtime, dtype: float64
......
......@@ -4,12 +4,11 @@ import os
import socket
import sys
sys.path.append("../../")
import networkx as nx
from experiments.utils import get_cpu, list_instances
from experiments.utils import get_cpu, list_instances, try_to_reuse
from cp import CpSolver, Integralizer
from heuristics.greedy import Greedy
from utils.json import read_instance
......@@ -41,14 +40,8 @@ for p, instance in list_instances(max_points=100):
for with_hint in [True, False]:
qu = {"instance": p, "solver": solver.identifier(), "threads": solver.threads,
"timelimit": timelimit, "CPU": cpu, "hint": with_hint}
try:
for q in query("../24_cp_parallel/01_results.json", qu):
with Measurement(result_db) as m:
m.update(qu)
m["hint"] = False
print("reusing", m)
except Exception as e:
print(e)
try_to_reuse(qu, result_db, ["../24_cp_parallel/01_results.json",
"../13_cp_vs_mip/01_results.json"])
if exists(result_db, qu):
print("skip", p, solver.identifier())
continue
......@@ -77,6 +70,8 @@ for p, instance in list_instances(max_points=100):
m["timelimit"] = timelimit
m["solution"] = to_json(sol)
m.save_seconds("runtime")
if not (m["solution"] or m["runtime"] >= timelimit):
print("DEBUG", m)
assert m["solution"] or m["runtime"] >= timelimit
m.save_metadata()
print(m)
......
%% Cell type:markdown id: tags:
# Experiment 24: Parallel CP-SAT
# Experiment 26: CP-SAT with Hints.
How does CP-SAT perform if we give a hint?
%% Cell type:code id: tags:
``` python
import datetime
from aemeasure import read_as_pd, unpack
from aemeasure.evaluation_tools.interval_tables import convert_to_percentage_interval
from aemeasure.plotting import quick_plot_setup
import matplotlib.pyplot as plt
from utils.json import read_instance
import pandas as pd
import seaborn as sns
quick_plot_setup(use_tex=True)
```
%% Cell type:code id: tags:
``` python
unpack("01_results.json")
table = read_as_pd("./01_results.json", ["instance", "solver", "timelimit", "infeasible", "threads", "resolution", "use_lp_minmax", "use_all_different", "Solution", "runtime", "opt", "rounding", "hostname", "timestamp"])
table = read_as_pd("./01_results.json", ["instance", "solver", "timelimit", "hint", "infeasible", "threads", "resolution", "use_lp_minmax", "use_all_different", "Solution", "runtime", "opt", "rounding", "hostname", "timestamp"])
table = table[table["timelimit"]==30]
table.drop_duplicates(subset=["instance", "solver", "threads"], inplace=True)
```
%% Output
Following ZIPs are detected:
01_results_2021-06-29.zip
01_results_2021-06-30.zip
Choosing: 01_results_2021-06-30.zip
Loaded dataframe ./01_results.json
Executed on: ['algry04']
During: 2021-06-29 13:31:25.182097 and 2021-06-30 21:10:17.581419
%% Cell type:code id: tags:
``` python
# Extend instance information
table["edges"] = table["instance"].apply(lambda i: read_instance(i).graph.number_of_edges())
table["points"] = table["instance"].apply(lambda i: read_instance(i).graph.number_of_nodes())
table["Instance-type"] = table["instance"].apply(lambda s: "Celestial" if "cel_graph" in s else "General")
table["Solved"] = table["opt"].apply(lambda x: 100.0 if x else 0.0)
table
```
%% Output
instance \
9290 ../../instance_based_pn_msc/cel_graph_370.json
9291 ../../instance_based_pn_msc/cel_graph_370.json
9292 ../../instance_based_pn_msc/cel_graph_370.json
9293 ../../instance_based_pn_msc/cel_graph_370.json
9294 ../../instance_based_pn_msc/cel_graph_370.json
... ...
20380 ../../instance_based_pn_msc/general_1416.json
20381 ../../instance_based_pn_msc/general_1416.json
20382 ../../instance_based_pn_msc/general_1416.json
20383 ../../instance_based_pn_msc/general_1416.json
20384 ../../instance_based_pn_msc/general_1416.json
solver resolution threads \
9290 CP(Integralizer(1000000, floor), threads=1, No... 1000000 1
9291 CP(Integralizer(1000000, floor), threads=2, No... 1000000 2
9292 CP(Integralizer(1000000, floor), threads=4, No... 1000000 4
9293 CP(Integralizer(1000000, floor), threads=8, No... 1000000 8
9294 CP(Integralizer(1000000, floor), threads=16, N... 1000000 16
... ... ... ...
20380 CP(Integralizer(1000000, floor), threads=1, No... 1000000 1
20381 CP(Integralizer(1000000, floor), threads=2, No... 1000000 2
20382 CP(Integralizer(1000000, floor), threads=4, No... 1000000 4
20383 CP(Integralizer(1000000, floor), threads=8, No... 1000000 8
20384 CP(Integralizer(1000000, floor), threads=16, N... 1000000 16
rounding Solution opt timelimit runtime \
9290 floor 1.644502 True 30 0.098755
9291 floor 1.644502 True 30 0.096753
9292 floor 1.644502 True 30 0.097006
9293 floor 1.644502 True 30 0.098888
9294 floor 1.644502 True 30 0.098472
... ... ... ... ... ...
20380 floor 1.032746 True 30 0.975131
20381 floor 1.032746 True 30 0.964861
20382 floor 1.032746 True 30 0.932640
20383 floor 1.032746 True 30 0.942646
20384 floor 1.032746 True 30 0.974058
timestamp hostname edges points Instance-type \
9290 2021-06-29T19:32:33.963603 algry04 84 15 Celestial
9291 2021-06-29T19:32:36.190505 algry04 84 15 Celestial
9292 2021-06-29T19:32:38.496195 algry04 84 15 Celestial
9293 2021-06-29T19:32:40.793206 algry04 84 15 Celestial
9294 2021-06-29T19:32:43.053840 algry04 84 15 Celestial
... ... ... ... ... ...
20380 2021-06-30T21:09:51.733279 algry04 323 31 General
20381 2021-06-30T21:09:58.210361 algry04 323 31 General
20382 2021-06-30T21:10:04.737945 algry04 323 31 General
20383 2021-06-30T21:10:11.148134 algry04 323 31 General
20384 2021-06-30T21:10:17.581419 algry04 323 31 General
Solved
9290 100.0
9291 100.0
9292 100.0
9293 100.0
9294 100.0
... ...
20380 100.0
20381 100.0
20382 100.0
20383 100.0
20384 100.0
[11095 rows x 15 columns]
%% Cell type:markdown id: tags:
## Solved in time
%% Cell type:code id: tags:
``` python
percentage = 5
interval_table = convert_to_percentage_interval(table, on_column="points", percentage=percentage)
```
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(5,3.5))
t = interval_table.groupby(["points", "threads"])["Solved"].mean().reset_index()
sns.lineplot(data=t, x="points", y="Solved", hue="threads", style="threads", palette="tab10")
plt.ylabel("Solved within 10s (\%)")
plt.xlabel(f"Number of points (±{percentage}\%)")
plt.legend(loc="upper left")
plt.tight_layout()
plt.savefig("02a_solved_in_percent.pdf")
plt.show()
```
%% Output
%% Cell type:code id: tags:
``` python
t = table.groupby(["instance"])["opt"].sum()
t = t[t==5]
instances_solved_by_all = list(t.index)
t = table[table["instance"].isin(instances_solved_by_all)]
t_ = convert_to_percentage_interval(t, on_column="points", percentage=percentage)
t_ = t_.groupby(["points", "threads"])[["runtime"]].mean().reset_index()
plt.figure(figsize=(3.5,3.5))
sns.lineplot(data=t_, x="points", y="runtime", hue="threads", palette="tab10")
plt.ylabel("Runtime (s)")
plt.xlabel(f"Number of points (±{percentage}\%)")
plt.legend(loc="upper left", title="Threads")
plt.tight_layout()
plt.savefig("02b_runtime.pdf")
plt.show()
```
%% Output
findfont: Font family ['serif'] not found. Falling back to DejaVu Sans.
%% Cell type:code id: tags:
``` python
t = table.groupby(["threads"])["opt"].sum()
t["Instances"]=len(table["instance"].unique())
t
```
%% Output
threads
1 2109
2 2118
4 2165
8 2161
16 2157
Instances 2219
Name: opt, dtype: int64
%% Cell type:code id: tags:
``` python
table.groupby(["threads"])["runtime"].mean()
```
%% Output
threads
1 4.546896
2 4.333599
4 3.444087
8 3.608154
16 3.834284
Name: runtime, dtype: float64
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment