Skip to content

Commit

Permalink
Adjusted API for new conventions and updated topt_ltd.py with a heuri…
Browse files Browse the repository at this point in the history
…stics working for the 2x2 fishnet.
  • Loading branch information
ValentinHirschi committed Aug 30, 2022
1 parent 5a4b45f commit 162addf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
8 changes: 6 additions & 2 deletions API_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@

try:
# Import the rust bindings
from ltd import LTD, CrossSection
#from ltd import LTD, CrossSection
from ltd import CrossSection
except ImportError:
print("ERROR: Could not import the rust back-end 'ltd' module. Compile it first with:"
" ./make_lib from within the pyNLoop directory.")
Expand All @@ -71,6 +72,8 @@
_MODEs.append(args.mode)

if args.mode=='LTD':
print("ERROR: LTD functionality deprecated.")
raise
rust_instance = LTD(
settings_file = pjoin(root_path, args.hyperparameter_path),
topology_file = pjoin(root_path, args.topologies_path),
Expand Down Expand Up @@ -110,7 +113,8 @@ def API_initialise(

try:
# Import the rust bindings
from ltd import LTD, CrossSection
#from ltd import LTD, CrossSection
from ltd import CrossSection
except ImportError as e:
print("PYTHONPATH:\n%s"%str(sys.path))
print("DYLD_LIBRARY_PATH:\n%s"%os.environ.get('DYLD_LIBRARY_PATH',''))
Expand Down
20 changes: 13 additions & 7 deletions TOPT_LTD/topt_ltd.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,6 @@ def get_index_of_first_different_element(listA, listB):

def NEW_merge_topt_terms_without_numerators(self, topt_terms, debug=False):

topt_terms = sorted(topt_terms, key=lambda t: t[0][1][0])
node_map = { v : i for i, v in enumerate(topt_terms[0][0][1][0]) }
inv_node_map = {v : k for k, v in node_map.items()}
topt_terms = [ [(n, (tuple([node_map[o_i] for o_i in o[0]]),)), t ] for (n, o), t in topt_terms]

orderings_representatives = { orderings: orderings[0] for (num, orderings), terms in topt_terms}

def get_index_of_first_different_element(listA, listB):
for i,(a,b) in enumerate(zip(listA,listB)):
if a!=b:
Expand All @@ -448,6 +441,16 @@ def get_permutations(listA,listB):
else:
return tuple(permutations)

#topt_terms = sorted(topt_terms, key=lambda t: t[0][1][0])
node_map = { v : i for i, v in enumerate(topt_terms[0][0][1][0]) }
inv_node_map = {v : k for k, v in node_map.items()}
topt_terms = [ [(n, (tuple([node_map[o_i] for o_i in o[0]]),)), t ] for (n, o), t in topt_terms]
# One try if there are still some fail here is to order the terms so as to have the maximal number of perms w.r.t first (i.e. 0,1,2,3...)
# Still not clear what the tie breaker needs to be though
# defining_term = topt_terms[0]
# topt_terms = sorted(topt_terms, key=lambda t: len(get_permutations( defining_term[0][1][0], t[0][1][0] )) )

orderings_representatives = { orderings: orderings[0] for (num, orderings), terms in topt_terms}

def ordering_metric(a,b,merged_e_surf_in_num,common_e_surfs,non_common_e_surfs):

Expand Down Expand Up @@ -833,6 +836,9 @@ def process_topt_terms(self, topt_terms):
# orientations_to_consider = [
# (-1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1),
# ]
# orientations_to_consider = [
# (-1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1),
# ]
orientations_to_consider = None
topt_terms = ({ o : topt_terms[o] for o in orientations_to_consider } if orientations_to_consider is not None else topt_terms)

Expand Down

0 comments on commit 162addf

Please sign in to comment.