WState

class WState(block_size, n_blocks)[source]

Bases: InitialState

Product of W-states on contiguous qubit blocks.

Prepares a uniform superposition over one-hot basis states within each block:

|s₀⟩ = |W_{block_size}⟩^{⊗ n_blocks}

where |W_n⟩ = (|10…0⟩ + |01…0⟩ + … + |00…1⟩) / √n.

Useful as the initial state for any one-hot encoded problem (routing, assignment, scheduling, graph coloring, etc.).

Parameters:
  • block_size (int) – Number of qubits per block (≥ 1).

  • n_blocks (int) – Number of blocks (≥ 1).

Methods Summary

build(wires)

Prepare W-states on each block of qubits.

Methods Documentation

build(wires)[source]

Prepare W-states on each block of qubits.

Parameters:

wires (Sequence) – Must have length block_size * n_blocks.

Return type:

QuantumCircuit

Returns:

A QuantumCircuit with block_size * n_blocks qubits.