RobertTLange/evosax

Is there a way to implement constraints in the optimization?

brunomorayib opened this issue · 3 comments

I want to implement a Model Predictive Controller using, for example, genetic algorithms. I want to optimize the input U of a dynamical system which is described by a discrete-time ode:

X_{K+1} = f(X_k,U_k)

Input and states (X) are subject to constraints. SInce the optimization variable is U, I can easily implement constraints on that, by simply not accepting the U that are outside the constraints, but there's an easy way to implement constraints on the state X? Over which I don't have direct control?

Hi there, do you want to optimize both X and U with evolutionary methods? The es_params object allows you to specify clip_min and clip_max, which clip the ES optimized parameters into a specified range. So you could set

es_params = es_params.replace(clip_min=lower, clip_max=upper)

to enforce the constraints. Otherwise there are no specific ES implemented that explicitly account for these constraints. I hope this could help.

Hi, thank you for answering. No, the X is not an optimization variable, so I understand that there`s no easy way to constrain that one. Thanks!

Okaydokey. I will close the issue. Feel free to reopen if there is anything from the evosax side that can be improved. Cheers, Rob