Using mlr3 to stop and resume optimization

48 Views Asked by At

I would like to optimize the parameters of a numerical model. To do this, I run my model sequentially over and over again. Each time a genetic algorithm from the R-package GA proposes a different set of parameter values. At the end of each run, a cost function evaluates model performance by comparing the model outputs against observations. The essential part of my code looks like this:

result <- ga(type = "real-valued", fitness = cost.fun, […] )

The ga function runs until a solution is found. This works fine for test runs, but for production runs, node failures can interrupt the optimization and I need to start from scratch. To solve this, I need to store the interim results of the optimization in such a way that they can be used to restart the optimization process. I think this can be done with mlr3, but don't yet understand how. I am also not sure if I can use mlr3 in conjunction with ga. I am getting the sense that I would need to replace the my ga function with an optimization approach provided with mlr3, which is OK with me. If you could provide me with a working example then that would be great! Thanks!

1

There are 1 best solutions below

1
On

Yes mlr3, or rather bbotk the optimization package of mlr3, can save the evaluated points even if your remote node crashes. Afterwards the optimization can be started again. You would have to write a custom optimizer that uses ga. Then a callback that writes the archive to disk so that nothing is lost if a node fails. Nobody will present you a working example, that is work for several days. More info about bbotk and callbacks. Good luck.