Core Algorithms

AutoTight

class popcor.AutoTight[source]

Class for automatic constraint generation.

static get_A_learned(lifter, A_known=[], var_dict=None, method='qrp', verbose=False) list[source]

Generate list of learned constraints by sampling the lifter.

Parameters:
  • lifter – StateLifter object

  • A_known – list of known constraints, if given, will generate basis that is orthogonal to these given constraints.

  • var_dict – variable dictionary, if None, will use all variables

  • method – method to use for basis generation, can be ‘qr’, ‘qrp’, or ‘svd’. ‘qrp’ is recommended.

  • verbose – if True, will print timing information

Returns:

list of learned constraints.

static get_duality_gap(cost_local, cost_sdp, relative=True)[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.