Core Algorithms

AutoTight

class popcor.AutoTight[source]

Class for automatic constraint generation.

static get_A_learned(lifter, A_known: list = [], var_dict: dict | list | None = None, method: str = 'qrp', verbose: bool = False) tuple[list, list][source]

Generate list of learned constraints by sampling the lifter.

static get_duality_gap(cost_local: float, cost_sdp: float, relative: bool = True) float[source]

AutoTemplate

class popcor.AutoTemplate(lifter: StateLifter)[source]

Class to incrementally learn and augment constraint templates until we reach tightness.

apply(lifter: StateLifter, use_known: bool = False) list[source]

Apply the learned templates to a new lifter.

run(use_known: bool = True, use_incremental: bool = False, variable_list: list[list[str]] | None = None, verbose: bool = False, plot: bool = False)[source]

Run the template learning algorithm until we reach tightness, or run out of variables to add.

Parameters:
  • use_known – whether to use the known constraints of the lfiter (must have get_A_known).

  • use_incremental – whether to keep adding the learned tempaltes to the set of known constraints, to enforce we find orthogonal ones.

  • variable_list – list of lists of variables to consider. If not given, will use the VARIABLE_LIST parameter of the lifter class.