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

Make Py scripts agnostic to console location; alphabetize imports #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 5 additions & 4 deletions evaluation/flowcutter_order.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import subprocess
import pathlib
import re
import subprocess
import sys

experiments_folder = ""

binary_path = "./../build/"
console = binary_path + "console"
binary_path = pathlib.Path(__file__).parent.absolute() / "../build"
console = str(binary_path / "console")

def graph_path(G):
return experiments_folder + G + "/"
Expand Down Expand Up @@ -47,7 +48,7 @@ def save_flowcutter_cch_order(console, ncutters, graph_path, order_path, info_lo
#args.append("save_permutation_of_nodes_since_last_file_load")
args.append("save_routingkit_node_permutation_since_last_load")
args.append(order_path)

with open(info_log, 'w') as f:
subprocess.run(args, universal_newlines=True, stdout=f)

Expand Down
9 changes: 5 additions & 4 deletions evaluation/inertialflow_order.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import subprocess
import pathlib
import re
import subprocess
import sys

experiments_folder = ""

binary_path = "./../build/"
console = binary_path + "console"
binary_path = pathlib.Path(__file__).parent.absolute() / "../build"
console = str(binary_path / "console")

def graph_path(G):
return experiments_folder + G + "/"
Expand Down Expand Up @@ -48,7 +49,7 @@ def save_inertial_flow_cch_order(console, graph_path, order_path, info_log):

args.append("save_routingkit_node_permutation_since_last_load")
args.append(order_path)

with open(info_log, 'w') as f:
subprocess.run(args, universal_newlines=True, stdout=f)

Expand Down
12 changes: 6 additions & 6 deletions evaluation/inertialflowcutter_order.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import pandas as pd
import numpy as np
import pathlib
import re
import subprocess
import sys
import re


experiments_folder = ""

binary_path = "./../build/"
console = binary_path + "console"
binary_path = pathlib.Path(__file__).parent.absolute() / "../build"
console = str(binary_path / "console")

def order_path(G,P):
return experiments_folder + G + "." + P + ".order"
Expand Down Expand Up @@ -83,6 +83,6 @@ def main():
save_inertialflowcutter_cch_order(cutters, G)
order_time = parse_order_log(G,P)["order_running_time"]
print(P, G, round(order_time, 3), sep=',')

if __name__ == '__main__':
main()
9 changes: 5 additions & 4 deletions evaluation/kahip_order.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import subprocess
import pathlib
import re
import subprocess
import sys

experiments_folder = ""

binary_path = "./../build/"
console = binary_path + "console"
binary_path = pathlib.Path(__file__).parent.absolute() / "../build"
console = str(binary_path / "console")

def graph_path(G):
return experiments_folder + G + "/"
Expand All @@ -31,7 +32,7 @@ def save_kahip_cch_order(console, graph_path, order_path, info_log):
args.append("flow_cutter_set")
args.append("random_seed")
args.append("5489")

args.append("report_time")
args.append("reorder_nodes_in_kahip_nested_dissection_order")
args.append("0.2") #maximum imbalance
Expand Down
1 change: 0 additions & 1 deletion evaluation/metis_order.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ echo -n metis,$G,
./ndmetis tmp | grep "Ordering" | sed -E 's/^[ \t]*Ordering:[ \t]+([0-9.]+)[ \t]+sec[ \t]+\(METIS time\)[ \t]*$/\1/'
./../build/console load_routingkit_unweighted_graph $G/first_out $G/head permutate_nodes tmp.iperm save_routingkit_node_permutation_since_last_load $G.metis.order
rm tmp tmp.iperm

25 changes: 14 additions & 11 deletions evaluation/order_experiments.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import pandas as pd
import numpy as np
import os
import pathlib
import re
import subprocess
import os

import pandas as pd
import numpy as np


experiments_folder = ""

graphs = ["col", "cal", "europe", "usa"]
partitioners = ["metis", "kahip_v0_71", "kahip_v1_00_cut", "kahip_v2_11", "inertial_flow", "flowcutter3", "flowcutter20", "flowcutter100","inertialflowcutter4", "inertialflowcutter8", "inertialflowcutter12", "inertialflowcutter16"]

binary_path = "./../build/"
console = binary_path + "console"
customization_binary = binary_path + "customize"
query_binary = binary_path + "query"
binary_path = pathlib.Path(__file__).parent.absolute() / "../build"
console = str(binary_path / "console")
customization_binary = str(binary_path / "customize")
query_binary = str(binary_path / "query")

def config_contained(G, P, results):
cpd = pd.DataFrame.from_dict({
Expand Down Expand Up @@ -42,13 +45,13 @@ def query_file(G):
def parse_order_log(G,P):
args = [console]
args.append("load_routingkit_unweighted_graph")

args.append(graph_path(G) + "first_out")
args.append(graph_path(G) + "head")
args.append("add_back_arcs")
args.append("remove_multi_arcs")
args.append("remove_loops")

args.append("permutate_nodes_routingkit")
args.append(order_path(G,P))

Expand Down Expand Up @@ -96,7 +99,7 @@ def run_queries(G,P):
return float(t)

def main():

order_times = pd.read_csv(experiments_folder + "order_running_time.csv")

if not os.path.isfile(experiments_folder + "order_experiments.csv"): #Create nonsensical file
Expand Down Expand Up @@ -138,7 +141,7 @@ def main():
results.sort_values(["graph_id", "partitioner_id"], ascending=[True,True], inplace=True)
results.drop(columns=["graph_id", "partitioner_id"])
results.to_csv(experiments_folder + "order_experiments.csv", index=False)



if __name__ == '__main__':
Expand Down
19 changes: 11 additions & 8 deletions evaluation/parameterstudy.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import configurable_inertialflowcutter_order as ifc
import pandas as pd
import numpy as np
import os
import pathlib
import re
import subprocess
import os

import configurable_inertialflowcutter_order as ifc
import numpy as np
import pandas as pd


experiments_folder = ""
graph = "col" #TODO replace again with europe
Expand All @@ -12,10 +15,10 @@
query_sources = experiments_folder + graph + ".q.s"
query_targets = experiments_folder + graph + ".q.t"

binary_path = "./../build/"
order_console = binary_path + "console"
customization_binary = binary_path + "customize"
query_binary = binary_path + "query"
binary_path = pathlib.Path(__file__).parent.absolute() / "../build"
order_console = str(binary_path / "console")
customization_binary = str(binary_path / "customize")
query_binary = str(binary_path / "query")


def config_contained(config, results):
Expand Down
20 changes: 11 additions & 9 deletions evaluation/toplevel_cut_experiments.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import os
import pathlib
import re
import pandas as pd
import metis_cut as metis
import kahip_cut as kahip
import inertialflow_cut as inertialflow

import flowcutter_cut as flowcutter
import inertialflow_cut as inertialflow
import inertialflowcutter_cut as ifc
import kahip_cut as kahip
import metis_cut as metis
import pandas as pd

experiments_folder = ""
graphs = ["col", "cal", "europe", "usa"]
partitioners = ["metis", "kahip_v2_11", "inertial_flow", "flowcutter3", "flowcutter20", "inertialflowcutter4", "inertialflowcutter8", "inertialflowcutter12", "inertialflowcutter16"]
imbalances = [0.0, 0.01, 0.03, 0.05, 0.1, 0.2, 0.3, 0.5, 0.7, 0.9]

binary_path = "./../build/"
console = binary_path + "console"
metis_path = "./" + experiments_folder + "gpmetis"
binary_path = pathlib.Path(__file__).parent.absolute() / "../build"
console = str(binary_path / "console")
metis_path = "./" + experiments_folder + "gpmetis"

def graph_path(G):
return experiments_folder + G + "/"
Expand Down Expand Up @@ -80,7 +82,7 @@ def compute_inertial_flow_cuts(G):
results = pd.DataFrame(rows)
return results.set_index("epsilon").sort_index()

def compute_flow_cutter_cuts(G, cutters):
def compute_flow_cutter_cuts(G, cutters):
cuts = flowcutter.flowcutter_pareto(console, graph_path(G), cutters)
node_count = cuts.iloc[-1]["small_side_size"] + cuts.iloc[-1]["large_side_size"]
cuts['imbalance'] = cuts["large_side_size"] / ((node_count + 1) // 2) - 1
Expand All @@ -97,7 +99,7 @@ def compute_flow_cutter_cuts(G, cutters):
results = pd.DataFrame(rows)
return results.set_index("epsilon").sort_index()

def compute_inertial_flow_cutter_cuts(G, cutters):
def compute_inertial_flow_cutter_cuts(G, cutters):
cuts = ifc.inertialflowcutter_pareto(console, graph_path(G), cutters)
node_count = cuts.iloc[-1]["small_side_size"] + cuts.iloc[-1]["large_side_size"]
cuts['imbalance'] = cuts["large_side_size"] / ((node_count + 1) // 2) - 1
Expand Down