# Best valid path from list of path elements by backtracking search. # Last edited on 2021-12-25 21:31:00 by stolfi import best_elem_path_IMP def solve(OPHS, org, mp_jump): # This procedure tries to solve the HTPP, namely build a tool-path out of a # given list {OPHS} of oriented path elements, respecting the cooling time limits # of the contacts attached to them, while trying to minimize the total # fabrication time. # # Returns {fph} and {ncalls}, where # # {fph} is either {None} or a single path that is the concatenation # of every path in {OPHS}, in some order, in any of its two # orientations; plus all applicable links and necessary jumps (with # {Move_Parms} parameters {mp_jump}). The path will be valid (that # is, satifies all cooling time constraints) and will have minimum # fabtime among all valid paths. # # {ncalls} is the number of recursive calls made in the backtracking # enumeration. # # If {org} is not {None}, it should be a point of {\RR^2}. In that # case the path {fph} will start at {org}, and usually will begin with # a jump from {org} to the starting point of the first element used. # # Each element {oph} in {OPHS} should have a set {path.get_links(oph)} # with zero or more link paths that end at {pini(oph)}; and a set # {path.get_links(rev(oph))} with zero or more link paths that end at # {pfin(oph)}. The reverse of each of those link paths should be a # link path of some other raster trace, usually on a scan-line # adjacent to that o {oph}. # # The procedure {path.get_contacts(oph,isd)} should return the set of # all relevant contacts whose side {isd} is a trace of the element # {oph} of {OPHS}. The sets {contact.get_side_paths(ct,isd)} of those contacts # should be consistent with the above. # # The cooling time limits of all those contacts should have been set # to a value greater than 0 (possibly {+oo}). No contact should have # both sides covered by the same path of {OPHS}. # # The contact sets {path.get_contacts(fph,isd)} are NOT set, and the # sets {contact.get_side_paths(ct,isd)} of those contacts are NOT # changed. # # The procedure uses backtracking enumeration of all tool-paths that # are valid (respectd all contact cooling constraints) and returns the # one with minimum fab-time. return best_elem_path_IMP.solve(OPHS, org, mp_jump) def describe_and_check_input(wr, OPHS, org, mp_jump): # Prints main attributes of {solve}'s input data to # file {wr} in human-readable form. return best_elem_path_IMP.describe_and_check_input(wr, OPHS, org, mp_jump)