Method for combining derivative free optimization results of different data inputs I am working on an algorithm that has multiple fixed parameters. The algorithm analyzes time series data and spits out a number. The fixed parameters need to be such that this number is as small as possible.

What I found, is that when optimizing the parameters for a specific time period, these parameters don't necessarily work well when used on another time period.

The way I see it, is that there are two possible solutions to this problem:


use a longer time period when optimizing the parameters
find a method of combining the optimal parameters for different time periods, such that these "averaged" parameters work well on all time periods


Option 1. would be incredibly expensive in terms of computational time. And although it makes intuitive sense that this should fix the problem, I am not sure that this would indeed be the case.

Option 2. reminds me of training neural networks, where one would feed in a large number of "data points" and somehow take a (weighted) average of the results to find a set of parameters that work well for all data points. Unfortunately, I know very little to nothing about the algorithms used for this kind of optimization/learning.

Any help or suggestions are greatly appreciated. Please let me know if there is anything you'd like me to expand upon.

Thanks!

EDIT:
As suggested in the comments, here is some additional information:


my loss function is not an actual mathematical function, so I don't know exactly what it looks like, this also means that I can't compute the gradient.
The optimization method I currently use is differential evolution using the best1bin strategy.
The reason the predictions fail is because of overfitting.
There are ~10 parameters
One iteration takes about 5-8 seconds
You say you are overfitting.  The usual solution is to use more training data and/or regularization.

The easiest solution is probably going to be to train on all data, not just a limited time window.  Perhaps you can find a better mathematical optimization algorithm. You don't give any details on the optimization algorithm you are using or how you compute the loss function; perhaps using a stochastic version (e.g., analogous to SGD instead of GD) would provide better efficiency.  You could also consider Bayesian optimization, which constructs a differentiable model to estimate/predict the output of your loss function, and then uses SGD on it.  Another option is to use gradient-based methods and estimate the gradient using finite differences; if you have 10 parameters, you can estimate the gradient by evaluating the function 11 times on 11 different inputs.  Then you could combine that with gradient descent.

Or perhaps you can use regularization; for instance, if you have a prior on parameters, you might be able to choose a suitable regularization method.  I suspect it's going to be hard to say without getting into the specifics.