# OptimizationFlag¶

Inheritance Diagram

Class Attributes and Properties

 OptimizationFlag.default OptimizationFlag.none OptimizationFlag.safe OptimizationFlag.skip_arg_checks
class tenpy.tools.optimization.OptimizationFlag(value)[source]

Bases: enum.IntEnum

Options for the global ‘optimization level’ used for dynamical optimizations.

Whether we optimize dynamically is decided by comparison of the global “optimization level” with one of the following flags. A higher level includes all the previous optimizations.

Level

Flag

Description

0

none

Don’t do any optimizations, i.e., run many sanity checks. Used for testing.

1

default

Skip really unnecessary sanity checks, but also don’t try any optional optimizations if they might give an overhead.

2

safe

Activate safe optimizations in algorithms, even if they might give a small overhead. Example: Try to compress the MPO representing the hamiltonian.

3

skip_arg_checks

Unsafe! Skip (some) class sanity tests and (function) argument checks.

Warning

When unsafe optimizations are enabled, errors will not be detected that easily, debugging is much harder, and you might even get segmentation faults in the compiled parts. Use this kind of optimization only for code which you succesfully ran before with (very) similar parmeters and disabled optimiztions! Enable this optimization only during the parts of the code where it is really necessary. Check whether it actually helps - if it doesn’t, keep the optimization disabled!