Applies the optimizer.
State
The state from which to sample.
Parameters
The simulation parameters.
The optimized state.