help with parallel simulation and setting up parallel worker workspaces, getting error with
11 vues (au cours des 30 derniers jours)
A brief description (in case I'm turning this into a xy problem):
I'm working on a project where we are conducting run to failure experiments for a UAV and have two identical simulink models, except one of them has some extra monitoring and log output. We run the UAV mission, then degrade some of the parameters, and repeat this over and over until the UAV crashes or violates a safety threshold. This is good, but we want to know before the UAV actually crashes, which is where the parallel part comes in. We simulate the "digital twin" in parallel to collect many samples after each real mission, and then generate a distribution from those samples that can tell us if the UAV is going to crash on the next mission. With a 1D polyfit and sliding window, we can forecast a few missions out. In order for this to work, the degradation parameters from the main workspace with the real UAV need passed to each parallel workspace. The problem is that I am getting an error "Array indices must be positive integers or logical values" for each of the parallel workers.
I have a function called parallel_initializer_handler() that is executed on line 173 of next_paper.mlx which creates the workspace for each parallel worker. When I execute this function in the main workspace, I do not get any error, and the struct which I am updating is successfully updated.
This is how I am setting this up:
in(n) = Simulink.SimulationInput("digitaltwin1c");
out = parsim(in, 'ShowSimulationManager',"off", 'ShowProgress',"off", "UseFastRestart", "on", "SetupFcn", @()parallel_initializer_handler(i, lookback, horizon, r_var, q_var, m_var, twin_sample_rate));
Should I approach this differently? How can I peer into each of the parallel workspaces to see what is happening? How can I fix the error, and know that I am passing variables correctly? How can I get some output that says, "this is parallel worker X, the value of my variable is Y" ?
Alvaro le 22 Nov 2022
Modifié(e) : Alvaro le 22 Nov 2022
You can set a diary for each worker and print the iteration that a particular worker is working on as well as any parameters that were passed to that worker. Afterwards, you can peek into the diaries to see what each worker was doing during the simulation.
A simple example is attached where an array of random numbers is passed to a pool of workers and each worker writes in their respective diary the iteration and random number assigned to it.
The following thread has more details on how this process works.