dimod.Initialized.parse_initial_states

Initialized.parse_initial_states(bqm, initial_states=None, initial_states_generator='random', num_reads=None, seed=None)[source]

Parses/generates initial states for an initialized sampler.

Parameters:
  • bqm (BinaryQuadraticModel) – The binary quadratic model.
  • num_reads (int, optional, default=len(initial_states) or 1) – Number of reads. If num_reads is not explicitly given, it is selected to match the number of initial states given. If no initial states are given, it defaults to 1.
  • initial_states (samples-like, optional, default=None) – One or more samples, each defining an initial state for all the problem variables. Initial states are given one per read, but if fewer than num_reads initial states are defined, additional values are generated as specified by initial_states_generator. See func:.as_samples for a description of “samples-like”.
  • initial_states_generator ({'none', 'tile', 'random'}, optional, default='random') –

    Defines the expansion of initial_states if fewer than num_reads are specified:

    • ”none”:
      If the number of initial states specified is smaller than num_reads, raises ValueError.
    • ”tile”:
      Reuses the specified initial states if fewer than num_reads or truncates if greater.
    • ”random”:
      Expands the specified initial states with randomly generated states if fewer than num_reads or truncates if greater.
  • seed (int (32-bit unsigned integer), optional) – Seed to use for the PRNG. Specifying a particular seed with a constant set of parameters produces identical results. If not provided, a random seed is chosen.
Returns:

A named tuple with [‘initial_states’, ‘initial_states_generator’, ‘num_reads’, ‘seed’] as generated by this function.