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:
- Default
A single randomly generated state of size1 × N. - User-defined initial states
A user-provided array of sizerun_num × N. - Multiple random initial states
A set of random states of sizerun_num × N, either:- reproducible using a fixed
initial_states_seed, or - generated randomly without a fixed seed.
- reproducible using a fixed
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 seconds1 – 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,
)