cotengra.hyperoptimizers.hyper ============================== .. py:module:: cotengra.hyperoptimizers.hyper .. autoapi-nested-parse:: Base hyper optimization functionality. Attributes ---------- .. autoapisummary:: cotengra.hyperoptimizers.hyper._PATH_FNS cotengra.hyperoptimizers.hyper._OPTLIB_FNS cotengra.hyperoptimizers.hyper._OPTLIB_DEFAULTS cotengra.hyperoptimizers.hyper._HYPER_SEARCH_SPACE cotengra.hyperoptimizers.hyper._HYPER_CONSTANTS Classes ------- .. autoapisummary:: cotengra.hyperoptimizers.hyper.HyperOptLib cotengra.hyperoptimizers.hyper.TrialSetObjective cotengra.hyperoptimizers.hyper.TrialConvertTree cotengra.hyperoptimizers.hyper.TrialTreeMulti cotengra.hyperoptimizers.hyper.SlicedTrialFn cotengra.hyperoptimizers.hyper.SimulatedAnnealingTrialFn cotengra.hyperoptimizers.hyper.ReconfTrialFn cotengra.hyperoptimizers.hyper.SlicedReconfTrialFn cotengra.hyperoptimizers.hyper.CompressedReconfTrial cotengra.hyperoptimizers.hyper.ComputeScore cotengra.hyperoptimizers.hyper.HyperOptimizer cotengra.hyperoptimizers.hyper.ReusableHyperOptimizer cotengra.hyperoptimizers.hyper.HyperCompressedOptimizer cotengra.hyperoptimizers.hyper.ReusableHyperCompressedOptimizer cotengra.hyperoptimizers.hyper.HyperMultiOptimizer Functions --------- .. autoapisummary:: cotengra.hyperoptimizers.hyper.get_default_hq_methods cotengra.hyperoptimizers.hyper.get_default_optlib_eco cotengra.hyperoptimizers.hyper.get_default_optlib cotengra.hyperoptimizers.hyper.get_hyper_space cotengra.hyperoptimizers.hyper.get_hyper_constants cotengra.hyperoptimizers.hyper.register_hyper_optlib cotengra.hyperoptimizers.hyper.register_hyper_function cotengra.hyperoptimizers.hyper.list_hyper_functions cotengra.hyperoptimizers.hyper.base_trial_fn cotengra.hyperoptimizers.hyper.progress_description Module Contents --------------- .. py:function:: get_default_hq_methods() .. py:function:: get_default_optlib_eco() Get the default optimizer favoring speed. .. py:function:: get_default_optlib() Get the default optimizer balancing quality and speed. .. py:data:: _PATH_FNS .. py:data:: _OPTLIB_FNS .. py:data:: _OPTLIB_DEFAULTS .. py:data:: _HYPER_SEARCH_SPACE .. py:data:: _HYPER_CONSTANTS .. py:function:: get_hyper_space() .. py:function:: get_hyper_constants() .. py:class:: HyperOptLib Base class for hyper-optimization library interfaces. Subclasses should implement ``setup``, ``get_setting``, and ``report_result``. .. py:method:: setup(methods, space, optimizer=None, **kwargs) :abstractmethod: Initialize the optimizer state. :param methods: The list of contraction methods to optimize over. :type methods: list[str] :param space: The search space for each method. :type space: dict[str, dict[str, dict]] :param optimizer: The parent ``HyperOptimizer`` instance, for accessing attributes like ``max_repeats``. :type optimizer: HyperOptimizer, optional :param kwargs: Extra options specific to the optimizer library. .. py:method:: get_setting() :abstractmethod: Suggest the next setting to trial. :returns: **setting** -- Must contain at least ``{"method": str, "params": dict}``. May also include tokens for reporting. :rtype: dict .. py:method:: report_result(setting, trial, score) :abstractmethod: Report the result of a trial. :param setting: The setting dict returned by ``get_setting``. :type setting: dict :param trial: The trial result dict. :type trial: dict :param score: The scalar score for this trial. :type score: float .. py:method:: cleanup() Clean up any resources (threads, connections, etc.). Called at the end of each ``HyperOptimizer._search()`` run. The default implementation does nothing. .. py:function:: register_hyper_optlib(name, cls, defaults=None) Register a hyper-optimization library backend. :param name: The name of the backend. :type name: str :param cls: A ``HyperOptLib`` subclass. :type cls: type .. py:function:: register_hyper_function(name, ssa_func, space, constants=None) Register a contraction path finder to be used by the hyper-optimizer. :param name: The name to call the method. :type name: str :param ssa_func: The raw function that returns a 'ContractionTree', with signature ``(inputs, output, size_dict, **kwargs)``. :type ssa_func: callable :param space: The space of hyper-parameters to search. :type space: dict[str, dict] .. py:function:: list_hyper_functions() Return a list of currently registered hyper contraction finders. .. py:function:: base_trial_fn(inputs, output, size_dict, method, **kwargs) .. py:class:: TrialSetObjective(trial_fn, objective) .. py:attribute:: trial_fn .. py:attribute:: objective .. py:method:: __call__(*args, **kwargs) .. py:class:: TrialConvertTree(trial_fn, cls) .. py:attribute:: trial_fn .. py:attribute:: cls .. py:method:: __call__(*args, **kwargs) .. py:class:: TrialTreeMulti(trial_fn, varmults, numconfigs) .. py:attribute:: trial_fn .. py:attribute:: varmults .. py:attribute:: numconfigs .. py:method:: __call__(*args, **kwargs) .. py:class:: SlicedTrialFn(trial_fn, **opts) .. py:attribute:: trial_fn .. py:attribute:: opts .. py:method:: __call__(*args, **kwargs) .. py:class:: SimulatedAnnealingTrialFn(trial_fn, **opts) .. py:attribute:: trial_fn .. py:attribute:: opts .. py:method:: __call__(*args, **kwargs) .. py:class:: ReconfTrialFn(trial_fn, forested=False, parallel=False, **opts) .. py:attribute:: trial_fn .. py:attribute:: forested :value: False .. py:attribute:: parallel :value: False .. py:attribute:: opts .. py:method:: __call__(*args, **kwargs) .. py:class:: SlicedReconfTrialFn(trial_fn, forested=False, parallel=False, **opts) .. py:attribute:: trial_fn .. py:attribute:: forested :value: False .. py:attribute:: parallel :value: False .. py:attribute:: opts .. py:method:: __call__(*args, **kwargs) .. py:class:: CompressedReconfTrial(trial_fn, minimize=None, **opts) .. py:attribute:: trial_fn .. py:attribute:: minimize :value: None .. py:attribute:: opts .. py:method:: __call__(*args, **kwargs) .. py:class:: ComputeScore(fn, score_fn, score_compression=0.75, score_smudge=1e-06, on_trial_error='warn', seed=0) The final score wrapper, that performs some simple arithmetic on the trial score to make it more suitable for hyper-optimization. .. py:attribute:: fn .. py:attribute:: score_fn .. py:attribute:: score_compression :value: 0.75 .. py:attribute:: score_smudge :value: 1e-06 .. py:attribute:: on_trial_error :value: 'warn' .. py:attribute:: rng .. py:method:: __call__(*args, **kwargs) .. py:function:: progress_description(best, info='concise') .. py:class:: HyperOptimizer(methods=None, minimize='flops', max_repeats=128, max_time=None, parallel='auto', simulated_annealing_opts='auto', slicing_opts='auto', slicing_reconf_opts='auto', reconf_opts='auto', optlib=None, optlib_opts=None, space=None, score_compression=0.75, on_trial_error='warn', max_training_steps=None, constants=None, progbar=False, **kwargs) Bases: :py:obj:`cotengra.oe.PathOptimizer` A path optimizer that samples a series of contraction trees while optimizing the hyper parameters used to generate them. The drivers specified in ``methods`` are used to generate the trial contraction trees according to certain hyper-parameters, and the results are scored according to ``minimize`` and fed back to ``optlib`` to suggest new parameters. If any of ``simulated_annealing_opts``, ``slicing_opts``, ``slicing_reconf_opts``, or ``reconf_opts`` are supplied, then once a trial tree is generated, it will be modified by the corresponding options (and in the order above) and the flops and size of the trial will be updated to the modified version, before the score is reported. :param methods: Which method(s) to use from ``list_hyper_functions()``. :type methods: None or sequence[str] or str, optional :param minimize: How to score each trial, used to train the optimizer and rank the results. If a custom callable, it should take a ``trial`` dict as its argument and return a single float. It is also supplied by default to any relevant refinement stages, such as subtree reconfiguration. :type minimize: str, Objective or callable, optional :param max_repeats: The maximum number of trial contraction trees to generate. Default: 128. :type max_repeats: int, optional :param max_time: The maximum amount of time to run for. Use ``None`` for no limit. You can also set an estimated execution 'rate' here like ``'rate:1e9'`` that will terminate the search when the estimated FLOPs of the best contraction found divided by the rate is greater than the time spent searching, allowing quick termination on easy contractions. :type max_time: None or float, optional :param parallel: Whether to parallelize the search. :type parallel: 'auto', False, True, int, or distributed.Client :param simulated_annealing_opts: If supplied, once a trial contraction path is found, refine it using simulated annealing with the given options, and then update the flops and size of the trial with the refined version. Notable options and defaults: - `tsteps=50`: number of temperature steps, - `target_size`: simulteneously slice the tree to this size, - `tfinal=0.05`: final temperature, - `tstart=2`: initial temperature. See :meth:`ContractionTree.simulated_anneal` for full details. :type simulated_annealing_opts: dict, optional :param slicing_opts: If supplied, once a trial contraction path is found, try slicing with the given options, and then update the flops and size of the trial with the sliced versions. Notable options: - `target_size`: slice until reaching this size, - `target_slices`: slice into this many slices. See :meth:`ContractionTree.slice` for full details. :type slicing_opts: dict, optional :param slicing_reconf_opts: If supplied, once a trial contraction path is found, try slicing interleaved with subtree reconfiguation with the given options, and then update the flops and size of the trial with the sliced and reconfigured versions. - `target_size`: slice until reaching this size, - `reconf_opts`: options passed to the subtree reconfiguration stage, see below. See :meth:`ContractionTree.slice_and_reconfigure` for full details. :type slicing_reconf_opts: dict, optional :param reconf_opts: If supplied, once a trial contraction path is found, try subtree reconfiguation with the given options, and then update the flops and size of the trial with the reconfigured versions. Notable options and defaults are: - `subtree_size=6`: size of subtree to optimally reconfigure, - `maxiter="auto"`: maximum number of subtree reconfigurations, by default scales with size of contraction (up to 1024), - `select='max'`: which subtrees to prioritize for reconfiguration. See :meth:`ContractionTree.subtree_reconfigure` for full details. :type reconf_opts: dict, optional :param optlib: Which optimizer to sample and train with. :type optlib: {'optuna', 'cmaes', 'nevergrad', 'sses', 'sbplx', ...}, optional :param optlib_opts: Supplied to the hyper-optimizer library initialization. :param space: The hyper space to search, see ``get_hyper_space`` for the default. :type space: dict, optional :param score_compression: Raise scores to this power in order to compress or accentuate the differences. The lower this is, the more the selector will sample from various optimizers rather than quickly specializing. :type score_compression: float, optional :param on_trial_error: What to do if a trial fails. If ``'warn'`` (default), a warning will be printed and the trial will be given a score of ``inf``. If ``'raise'`` the error will be raised. If ``'ignore'`` the trial will be given a score of ``inf`` silently. :type on_trial_error: {'warn', 'raise', 'ignore'}, optional :param max_training_steps: The maximum number of trials to train the optimizer with. Setting this can be helpful when the optimizer itself becomes costly to train (e.g. for Gaussian Processes). :type max_training_steps: int, optional :param constants: A dict mapping method name to a dict of constant parameters to pass to the trial function for that method. Any parameters specified here will override those in the search space. :type constants: dict[dict], optional :param progbar: Show live progress of the best contraction found so far. :type progbar: bool, optional :param kwargs: Extra options to pass to the optimizer library initialization, on top of those in ``optlib_opts`` (which take precedence). .. py:attribute:: compressed :value: False .. py:attribute:: multicontraction :value: False .. py:attribute:: max_repeats :value: 128 .. py:attribute:: _repeats_start :value: 0 .. py:attribute:: max_time :value: None .. py:property:: parallel .. py:attribute:: method_choices :value: [] .. py:attribute:: param_choices :value: [] .. py:attribute:: scores :value: [] .. py:attribute:: times :value: [] .. py:attribute:: costs_flops :value: [] .. py:attribute:: costs_write :value: [] .. py:attribute:: costs_size :value: [] .. py:attribute:: simulated_annealing_opts :value: None .. py:attribute:: slicing_opts :value: None .. py:attribute:: reconf_opts :value: None .. py:attribute:: slicing_reconf_opts :value: None .. py:property:: minimize .. py:attribute:: score_compression :value: 0.75 .. py:attribute:: on_trial_error :value: 'warn' .. py:attribute:: best_score .. py:attribute:: max_training_steps :value: None .. py:attribute:: best .. py:attribute:: trials_since_best :value: 0 .. py:attribute:: _optimizer .. py:attribute:: progbar :value: False .. py:property:: tree .. py:property:: path .. py:method:: setup(inputs, output, size_dict) .. py:method:: _maybe_cancel_futures() .. py:method:: _maybe_report_result(setting, trial) .. py:method:: _gen_results(repeats, trial_fn, trial_args) .. py:method:: _get_and_report_next_future() .. py:method:: _gen_results_parallel(repeats, trial_fn, trial_args) .. py:method:: _search(inputs, output, size_dict) .. py:method:: search(inputs, output, size_dict) Run this optimizer and return the ``ContractionTree`` for the best path it finds. .. py:method:: get_tree() Return the ``ContractionTree`` for the best path found. .. py:method:: __call__(inputs, output, size_dict, memory_limit=None) ``opt_einsum`` interface, returns direct ``path``. .. py:method:: get_trials(sort=None) .. py:method:: print_trials(sort=None) .. py:method:: to_df() Create a single ``pandas.DataFrame`` with all trials and scores. .. py:method:: to_dfs_parametrized() Create a ``pandas.DataFrame`` for each method, with all parameters and scores for each trial. .. py:attribute:: plot_trials .. py:attribute:: plot_trials_alt .. py:attribute:: plot_scatter .. py:attribute:: plot_scatter_alt .. py:attribute:: plot_parameters_parallel .. py:class:: ReusableHyperOptimizer(*, directory=None, overwrite=False, hash_method='a', cache_only=False, directory_split='auto', **opt_kwargs) Bases: :py:obj:`cotengra.reusable.ReusableOptimizer` Like ``HyperOptimizer`` but it will re-instantiate the optimizer whenever a new contraction is detected, and also cache the paths (and sliced indices) found. :param directory: If specified use this directory as a persistent cache. If ``True`` auto generate a directory in the current working directory based on the options which are most likely to affect the path (see `ReusableHyperOptimizer._get_path_relevant_opts`). :type directory: None, True, or str, optional :param overwrite: If ``True``, the optimizer will always run, overwriting old results in the cache. This can be used to update paths without deleting the whole cache. If ``'improved'`` then only overwrite if the new path is better. :type overwrite: bool or 'improved', optional :param hash_method: The method used to hash the contraction tree. The default, ``'a'``, is faster hashwise but doesn't recognize when indices are permuted. :type hash_method: {'a', 'b', ...}, optional :param cache_only: If ``True``, the optimizer will only use the cache, and will raise ``KeyError`` if a contraction is not found. :type cache_only: bool, optional :param directory_split: If specified, the hash will be split into two parts, the first part will be used as a subdirectory, and the second part will be used as the filename. This is useful for avoiding a very large flat diretory. If "auto" it will check the current cache if any and guess from that. :type directory_split: "auto" or bool, optional :param opt_kwargs: Supplied to ``HyperOptimizer``. .. py:method:: _get_path_relevant_opts() Get a frozenset of the options that are most likely to affect the path. These are the options that we use when the directory name is not manually specified. .. py:method:: _get_suboptimizer() .. py:method:: _deconstruct_tree(opt, tree) .. py:method:: _reconstruct_tree(inputs, output, size_dict, con) .. py:class:: HyperCompressedOptimizer(chi=None, methods=('greedy-compressed', 'greedy-span', 'kahypar-agglom'), minimize='peak-compressed', simulated_annealing_opts='auto', reconf_opts='auto', **kwargs) Bases: :py:obj:`HyperOptimizer` A compressed contraction path optimizer that samples a series of ordered contraction trees while optimizing the hyper parameters used to generate them. :param chi: The maximum bond dimension to compress to. If ``None`` then use the square of the largest existing dimension. If ``minimize`` is specified as a full scoring function, this is ignored. :type chi: None or int, optional :param methods: Which method(s) to use from ``list_hyper_functions()``. :type methods: None or sequence[str] or str, optional :param minimize: How to score each trial, used to train the optimizer and rank the results. If a custom callable, it should take a ``trial`` dict as its argument and return a single float. :type minimize: str, Objective or callable, optional :param max_repeats: The maximum number of trial contraction trees to generate. Default: 128. :type max_repeats: int, optional :param max_time: The maximum amount of time to run for. Use ``None`` for no limit. You can also set an estimated execution 'rate' here like ``'rate:1e9'`` that will terminate the search when the estimated FLOPs of the best contraction found divided by the rate is greater than the time spent searching, allowing quick termination on easy contractions. :type max_time: None or float, optional :param parallel: Whether to parallelize the search. :type parallel: 'auto', False, True, int, or distributed.Client :param slicing_opts: If supplied, once a trial contraction path is found, try slicing with the given options, and then update the flops and size of the trial with the sliced versions. :type slicing_opts: dict, optional :param slicing_reconf_opts: If supplied, once a trial contraction path is found, try slicing interleaved with subtree reconfiguation with the given options, and then update the flops and size of the trial with the sliced and reconfigured versions. :type slicing_reconf_opts: dict, optional :param reconf_opts: If supplied, once a trial contraction path is found, try subtree reconfiguation with the given options, and then update the flops and size of the trial with the reconfigured versions. :type reconf_opts: dict, optional :param optlib: Which optimizer to sample and train with. :type optlib: {'cmaes', 'optuna', 'nevergrad', 'skopt', ...}, optional :param space: The hyper space to search, see ``get_hyper_space`` for the default. :type space: dict, optional :param score_compression: Raise scores to this power in order to compress or accentuate the differences. The lower this is, the more the selector will sample from various optimizers rather than quickly specializing. :type score_compression: float, optional :param max_training_steps: The maximum number of trials to train the optimizer with. Setting this can be helpful when the optimizer itself becomes costly to train (e.g. for Gaussian Processes). :type max_training_steps: int, optional :param progbar: Show live progress of the best contraction found so far. :type progbar: bool, optional :param optlib_opts: Supplied to the hyper-optimizer library initialization. .. py:attribute:: compressed :value: True .. py:attribute:: multicontraction :value: False .. py:class:: ReusableHyperCompressedOptimizer(chi=None, methods=('greedy-compressed', 'greedy-span', 'kahypar-agglom'), minimize='peak-compressed', **kwargs) Bases: :py:obj:`ReusableHyperOptimizer` Like ``HyperCompressedOptimizer`` but it will re-instantiate the optimizer whenever a new contraction is detected, and also cache the paths found. :param chi: The maximum bond dimension to compress to. If ``None`` then use the square of the largest existing dimension. If ``minimize`` is specified as a full scoring function, this is ignored. :type chi: None or int, optional :param directory: If specified use this directory as a persistent cache. If ``True`` auto generate a directory in the current working directory based on the options which are most likely to affect the path (see `ReusableHyperOptimizer._get_path_relevant_opts`). :type directory: None, True, or str, optional :param overwrite: If ``True``, the optimizer will always run, overwriting old results in the cache. This can be used to update paths without deleting the whole cache. :type overwrite: bool, optional :param hash_method: The method used to hash the contraction tree. The default, ``'a'``, is faster hashwise but doesn't recognize when indices are permuted. :type hash_method: {'a', 'b', ...}, optional :param cache_only: If ``True``, the optimizer will only use the cache, and will raise ``KeyError`` if a contraction is not found. :type cache_only: bool, optional :param opt_kwargs: Supplied to ``HyperCompressedOptimizer``. .. py:method:: _get_suboptimizer() .. py:method:: _deconstruct_tree(opt, tree) .. py:method:: _reconstruct_tree(inputs, output, size_dict, con) .. py:class:: HyperMultiOptimizer(methods=None, minimize='flops', max_repeats=128, max_time=None, parallel='auto', simulated_annealing_opts='auto', slicing_opts='auto', slicing_reconf_opts='auto', reconf_opts='auto', optlib=None, optlib_opts=None, space=None, score_compression=0.75, on_trial_error='warn', max_training_steps=None, constants=None, progbar=False, **kwargs) Bases: :py:obj:`HyperOptimizer` A path optimizer that samples a series of contraction trees while optimizing the hyper parameters used to generate them. The drivers specified in ``methods`` are used to generate the trial contraction trees according to certain hyper-parameters, and the results are scored according to ``minimize`` and fed back to ``optlib`` to suggest new parameters. If any of ``simulated_annealing_opts``, ``slicing_opts``, ``slicing_reconf_opts``, or ``reconf_opts`` are supplied, then once a trial tree is generated, it will be modified by the corresponding options (and in the order above) and the flops and size of the trial will be updated to the modified version, before the score is reported. :param methods: Which method(s) to use from ``list_hyper_functions()``. :type methods: None or sequence[str] or str, optional :param minimize: How to score each trial, used to train the optimizer and rank the results. If a custom callable, it should take a ``trial`` dict as its argument and return a single float. It is also supplied by default to any relevant refinement stages, such as subtree reconfiguration. :type minimize: str, Objective or callable, optional :param max_repeats: The maximum number of trial contraction trees to generate. Default: 128. :type max_repeats: int, optional :param max_time: The maximum amount of time to run for. Use ``None`` for no limit. You can also set an estimated execution 'rate' here like ``'rate:1e9'`` that will terminate the search when the estimated FLOPs of the best contraction found divided by the rate is greater than the time spent searching, allowing quick termination on easy contractions. :type max_time: None or float, optional :param parallel: Whether to parallelize the search. :type parallel: 'auto', False, True, int, or distributed.Client :param simulated_annealing_opts: If supplied, once a trial contraction path is found, refine it using simulated annealing with the given options, and then update the flops and size of the trial with the refined version. Notable options and defaults: - `tsteps=50`: number of temperature steps, - `target_size`: simulteneously slice the tree to this size, - `tfinal=0.05`: final temperature, - `tstart=2`: initial temperature. See :meth:`ContractionTree.simulated_anneal` for full details. :type simulated_annealing_opts: dict, optional :param slicing_opts: If supplied, once a trial contraction path is found, try slicing with the given options, and then update the flops and size of the trial with the sliced versions. Notable options: - `target_size`: slice until reaching this size, - `target_slices`: slice into this many slices. See :meth:`ContractionTree.slice` for full details. :type slicing_opts: dict, optional :param slicing_reconf_opts: If supplied, once a trial contraction path is found, try slicing interleaved with subtree reconfiguation with the given options, and then update the flops and size of the trial with the sliced and reconfigured versions. - `target_size`: slice until reaching this size, - `reconf_opts`: options passed to the subtree reconfiguration stage, see below. See :meth:`ContractionTree.slice_and_reconfigure` for full details. :type slicing_reconf_opts: dict, optional :param reconf_opts: If supplied, once a trial contraction path is found, try subtree reconfiguation with the given options, and then update the flops and size of the trial with the reconfigured versions. Notable options and defaults are: - `subtree_size=6`: size of subtree to optimally reconfigure, - `maxiter="auto"`: maximum number of subtree reconfigurations, by default scales with size of contraction (up to 1024), - `select='max'`: which subtrees to prioritize for reconfiguration. See :meth:`ContractionTree.subtree_reconfigure` for full details. :type reconf_opts: dict, optional :param optlib: Which optimizer to sample and train with. :type optlib: {'optuna', 'cmaes', 'nevergrad', 'sses', 'sbplx', ...}, optional :param optlib_opts: Supplied to the hyper-optimizer library initialization. :param space: The hyper space to search, see ``get_hyper_space`` for the default. :type space: dict, optional :param score_compression: Raise scores to this power in order to compress or accentuate the differences. The lower this is, the more the selector will sample from various optimizers rather than quickly specializing. :type score_compression: float, optional :param on_trial_error: What to do if a trial fails. If ``'warn'`` (default), a warning will be printed and the trial will be given a score of ``inf``. If ``'raise'`` the error will be raised. If ``'ignore'`` the trial will be given a score of ``inf`` silently. :type on_trial_error: {'warn', 'raise', 'ignore'}, optional :param max_training_steps: The maximum number of trials to train the optimizer with. Setting this can be helpful when the optimizer itself becomes costly to train (e.g. for Gaussian Processes). :type max_training_steps: int, optional :param constants: A dict mapping method name to a dict of constant parameters to pass to the trial function for that method. Any parameters specified here will override those in the search space. :type constants: dict[dict], optional :param progbar: Show live progress of the best contraction found so far. :type progbar: bool, optional :param kwargs: Extra options to pass to the optimizer library initialization, on top of those in ``optlib_opts`` (which take precedence). .. py:attribute:: compressed :value: False .. py:attribute:: multicontraction :value: True