# Main functions of the HotPath heuristic. # Last edited on 2021-02-08 19:57:15 by jstolfi import heuristic2_IMP def best_path (o, R, Delta, parms, links): # Takes a set {R} of filler elements (oriented paths) with contacts # between them. Returns the best tool-path {ph} that starts at the point {o} and # consists of concatenations of filler elements from {R} # with maximum allowed contact cooling {Delta}. # # Uses heuristic 2 (backtracking with ordered candidate set). # # If {links} is false, uses jumps to connect the filler elements. # If {links} is true, uses traces whenever possible. # # For efficiency, the procedure uses some fields of the {Path} # objects that comprise the filler elements in {R} to mark the # elements that have been incorporated in the pa heuristic2_IMP.best_path (o, R, Delta, parms, links) def best_path_aux (ph, Front, Delta, parms, links): # Given a partial tool-path {ph} for the move order optimization # problem, and the corresponding list of {Front} moves tries to # complete it into a full tool-path {ph_full}. If it succeeds returns # {ph_full}. If it fails returns None. Assumes that the {Front} has at # least one move in each component of the connectivity graph that has # not been yet completey extruded. heuristic2_IMP.best_path_aux (ph, Front, Delta, parms, links) def update_front(Front, el): # Returns a copy of the {Front} list, excluding the filler element {el}, # and adding all filler elements that are adjacent to {el} (that is, # share a contact with {el}) and are not yet in the tentative tool-path or in the {Front}. return heuristic2_IMP.update_front(Front, el)