1. Home
  2. /
  3. Virtual Lab Tutorials
  4. /
  5. Initial State

Initial State

While the optical system starts from random initial states that are not user-controlled, the emulator allows explicit control over these states. This enables reproducible experiments as well as exploration of a broader range of system dynamics.

There are three ways to define the initial state in the emulator:

  1. Default
    A single randomly generated state of size 1 × N.
  2. User-defined initial states
    A user-provided array of size run_num × N.
  3. Multiple random initial states
    A set of random states of size run_num × N, either:
    • reproducible using a fixed initial_states_seed, or
    • generated randomly without a fixed seed.

Note: A simulation can be continued from its endpoint by using the output of the previous run as the initial state for the new simulation (option 2 above).

Example

The initialization options are shown in the code snippets bellow:

Set up

Python
import numpy as np
from laser_mind_client import LaserMind

# Get token and initialize client:
pathToRefreshTokenFile="C:\\path\\to\\your\\token.txt"
lsClient = LaserMind(pathToRefreshTokenFile=pathToTokenFile)

# Create a coupling matrix:
N = 5
coupling_matrix = 0.5 * np.eye(N, dtype=numpy.complex64)
coupling = (1 - 0.5) / 2
for i in range(size - 1):
    coupling_matrix[i, i+1] = coupling
    coupling_matrix[i+1, i] = coupling

niters = 10000  # number of iterations
stop_at = 60    # in seconds

1 – Default

Python
## Option 1: one state, chosen randomly (default)
result = lsClient.solve_coupling_matrix_sim_lpu(matrix_data  = coupling_matrix,
                                                num_iterations = niters,
                                                timeout  = stop_at,
                                                )

2 – User-defined states

Python
## Option 2: provided by user
states = np.array([
    [0.317 + 0.655j, -0.200 - 0.066j, 0.634 + 0.625j, 0.132 - 0.430j, -0.552 + 0.287j],
    [0.521 - 0.412j,  0.103 + 0.189j, -0.774 + 0.221j, 0.448 + 0.097j, -0.129 - 0.533j]
])
result = lsClient.solve_coupling_matrix_sim_lpu(matrix_data  = coupling_matrix,
                                                initial_states_vector = states,
                                                num_iterations = niters,
                                                timeout  = stop_at,
                                                )

3 – Multiple random states

Python
## Option 3: Random multiple states
run_number = 10    # amount of multiple states
# (a) chosen randomly
result = lsClient.solve_coupling_matrix_sim_lpu(matrix_data  = coupling_matrix,
                                                num_runs = run_number,
                                                num_iterations = niters,
                                                timeout  = stop_at,
                                                )

# (b) chosen with a fixed seed number
seed_number = 42
result = lsClient.solve_coupling_matrix_sim_lpu(matrix_data  = coupling_matrix,
                                                initial_states_seed = seed_number,
                                                num_runs = run_number,
                                                num_iterations = niters,
                                                timeout  = stop_at,
                                                )

How can we help?