pyjac.core.cache_optimizer module

Reorders loads of rate and species subs to optimize cache hits, etc.

pyjac.core.cache_optimizer.plot(specs, reacs, consider_thd, fwd_spec_mapping, fwd_rxn_mapping)[source]

Convenience plotting function. Marked for removal.

pyjac.core.cache_optimizer.optimizer_loop(starting_order, mapping, lookback, improve_cutoff, random_tries)[source]
Parameters:
  • starting_order – Initial order of elements
  • mapping – Mapping of order to “correct” location
  • lookback (int) – Width of lookahead/lookforward
  • improve_cutoff (int) – Number of iterations without improvement before return
  • random_tries (int) – Number of random initializations to try
Returns:

  • global_max
  • global_max_order

pyjac.core.cache_optimizer.optimize_cache(specs, reacs, multi_thread, force_optimize, build_path, last_spec, consider_thd=False, improve_cutoff=20, rand_init_tries=10000, lookback_max=2, rand_restarts_max=5, max_time=6000)[source]

Optimize species and reaction orders to improve cache hit rates.

Parameters:
  • specs (list of SpecInfo) – List of species in the mechanism.
  • reacs (list of ReacInfo) – List of reactions in the mechanism.
  • multi_thread (int) – The number of threads to use during optimization
  • force_optimize (bool) – If true, reoptimize even if past data is available
  • build_path (str) – The path to the build directory
  • last_spec (int) – The index of the species that should be placed last
  • consider_thd (bool) – If true, consider third body species in the reactions
  • improve_cutoff (int) – The number of iterations without improvement before return
  • rand_init_tries (int) – The number of random initializations to try
  • lookback_max (int) – The width of lookahead/lookforward (at maximum)
  • rand_restarts_max (int) – The number of restarts to try within the iteration
  • max_time (int) – The maximum time duration of each optimziation step
Returns:

  • specs (list of SpecInfo) – The reordered list of species in the mechanism
  • reacs (list of ReacInfo) – the reordered list of reacs in the mechanism
  • fwd_spec_mapping (list of int) – A mapping of the original mechanism to the new species order
  • fwd_rxn_mapping (list of int) – A mapping of the original mechanism to the new reaction order
  • reverse_spec_mapping (list of int) – A mapping of the new species order to the original mechanism
  • reverse_rxn_mapping (list of int) – A mapping of the new reaction order to the original mechanism