Training Linear Layers without gradient available

Hey everyone, this might be a somewhat unusual problem but I’m really hoping you are able to help me:

I’m trying to simulate some abstract trajectories and want to use a linear neural network to help with that. The way my algorithm works, is that for each step along the path the network gets the current state as an input and generates a few values, that I use to determine the next step.
When the entire simulation is finished some statistical properties of the entire run are calculated to summarize essential features of the generated trajectory in a single function. The final goal for the network is to generate the coefficients for each next step in such a way, that the statistics of the resulting trajectory mirrors a given function I use as the target value. Because of that I always need to generate an entire trajectory, before I can check how well the network performed.

My problem arises when trying to compute the gradient. Because the network is used in every timestep, the exact equation to calculate the next step from the networks output is highly complicated and the statistical summarizing is added in the end, I am not able to reconstruct the influence of network weights on the final result and can’t give the optimizer the gradient it needs to train the network.

Do you have any idea how to solve this? Maybe there is an unconventional way of determining the gradients if the loss-function is calculated from very complicated and abstract results not trivially connected to the networks output?