scm.reactmap.heuristics.HeuristicsManager

class scm.reactmap.heuristics.HeuristicsManager(settings)

The HeuristicsManager class is responsible for executing the heuristics (upper and lower bounds) on a reaction problem. The class will automatically be called by the Map class during a normal reactmap run. Advanced users may sometimes find it useful to work with instances of the HeuristicsManager class, but this will likely be for finding approximate solutions to very difficult problems or other advanced case studies.

Keyword Arguments
  • reaction (reactmap.Reaction) – The reaction problem for which to find the upper and lower bounds.

  • settings (reactmap.Settings) – The settings class that details which heuristics to try.

Example

We will use the HeuristicsManager class to find an upper bound (a feasible solution) to the reaction mapping problem between CCCCO and CCOCC. Here we find that the default upper bound options are sufficient in finding a tight upper bound.

>>> import reactmap as rm
>>> reac = rm.Molecule(smiles='CCCCO')
>>> prod = rm.Molecule(smiles='CCOCC')
>>> reaction = rm.Reaction(reactant = reac, product = prod)
>>> heurManager = rm.heuristics.HeuristicsManager(rm.Settings(ub_greedy = True))
>>> heurManager.run(reaction)
>>> print(reaction.ub)
4
>>> rm.Map(reaction)
>>> print(reaction.cost)
4

Methods

run(reaction)
try_lb(f, heur_name)

This function tries a lower bound. If a better lower bound was found it updates the appropriate fields in the reaction class.

Keyword Arguments
  • f (func) – The function handle for a lower bound heuristic

  • heur_name (str) – The settings name of the lower bound. This is required for logging.

try_ub(f, heur_name)

This function tries a upper bound. If a better upper bound was found it updates the appropriate fields in the reaction class.

Keyword Arguments
  • f (func) – The function handle for a upper bound heuristic

  • heur_name (str) – The settings name of the upper bound. This is required for logging.