dimod.reference.samplers.IdentitySampler.sample#

IdentitySampler.sample(bqm: BinaryQuadraticModel, *, initial_states: Sequence[float | floating | integer] | Mapping[Hashable, float | floating | integer] | Tuple[Sequence[float | floating | integer], Sequence[Hashable]] | Tuple[ndarray, Sequence[Hashable]] | ndarray | Sequence[Sequence[float | floating | integer]] | Tuple[Sequence[Sequence[float | floating | integer]], Sequence[Hashable]] | Sequence[Sequence[float | floating | integer] | Mapping[Hashable, float | floating | integer] | Tuple[Sequence[float | floating | integer], Sequence[Hashable]] | Tuple[ndarray, Sequence[Hashable]] | ndarray] | Iterator[Sequence[float | floating | integer] | Mapping[Hashable, float | floating | integer] | Tuple[Sequence[float | floating | integer], Sequence[Hashable]] | Tuple[ndarray, Sequence[Hashable]] | ndarray] | None = None, initial_states_generator: Literal['none', 'tile', 'random'] = 'random', num_reads: int | None = None, seed: int | None = None, **kwargs) SampleSet[source]#

Return, expand, or truncate the provided initial states.

Parameters:
  • bqm – Binary quadratic model to be sampled.

  • initial_states – 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 as_samples() for a description of samples-like.

  • initial_states_generator

    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.

  • num_reads – Number of reads. If not explicitly given, the number of reads is set to the number of initial states, or if initial states are not given, to the default of 1.

  • seed – Seed (32-bit unsigned integer) 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 SampleSet with the specified initial states, optionally truncated or augmented.