# Main functions of the HotPath heuristic with (version 3). # Last edited on 2021-02-08 19:58:20 by jstolfi def best_path (R, G, Delta, parameters, start_time): # Returns the optimal order {S} of the moves according to heuristic 2, # with maximum allowed cooling {Delta}, and also the total extrusion time {Tend} of {S} and also the maximum cooling # time {Cmax} for any side, and the corresponding side {smax}. # It does not extrude the raster links for now. Each element of {S} is a pair (move, reversebit). # # The solution will start with move R[0] and each new move will be adjacent at least one previously extruded # move. Uses backtracking. return heuristic3_IMP.best_path (R, G, Delta, parameters, start_time) # AUXILIARY PROCEDURES def best_path_aux(S, Front, Delta, G, R, parameters, start_time): # Given a partial solution {S} for the move order optimization problem, and # the corresponding list of {Front} moves tries to complete it into a full # solution {Sfull}. If it succeds returns the {Sfull}, the maximum cooling time # {Cmax} among the new moves added, and the corresponding side {smax}. If it fails returns None in place of # {Sfull}. Assumes that the {Front} has at least one move in each component of the connectivity graph that # has not been yet completey extruded. return heuristic3_IMP.best_path_aux(S, Front, Delta, G, R, parameters, start_time) def update_front(Front, el, G, R): # Returns a copy of the {Front}, excluding the filler element {el} and adding # all filler elements that are adjacent to {el} (that is, # share a contact with {el}). If one of those elements is not # an entry of a block in {G}, also adds the entry elements of that # block. In any case, skips elements that are already in the # tentative tool-path or in the {Front}. return heuristic3_IMP.update_front(Front, el, G, R)