Bayesian Optimization in real-time with Simulink and Code Generation
For a particular application, I need to implement Bayesian Optimization so to continuously run in a Simulink model. The simulink model is a control algorithm, which has to be translated into C code, and run on an ECU. The Bayesian Optimization should update the controller parameters (which are the parameters to be optimized) based on a certain cost function, which is directly measured from some sensors available to the ECU. So in practice my cost function should "wait" for a flag "experiment completed" coming from the simulink model; after the flag is generated, the cost function is evaluated based on the data.
More in details, the algorithm idea is something like this:
Perform the experiment by using a certain set of parameters.
After the experiment is done, the cost function for that set of parameters can be evaluated.
Run an iteration of bayesopt() and update the GP model, etc. A new set of parameters is selected through acquisition function.
The experiment is then performed again, and the new cost function is evaluated, and so on…
Now, I know that I can’t directly use bayesopt() in code generation. Is there a way to do this without having to completely rewrite the code for the Bayesian Optimization?For a particular application, I need to implement Bayesian Optimization so to continuously run in a Simulink model. The simulink model is a control algorithm, which has to be translated into C code, and run on an ECU. The Bayesian Optimization should update the controller parameters (which are the parameters to be optimized) based on a certain cost function, which is directly measured from some sensors available to the ECU. So in practice my cost function should "wait" for a flag "experiment completed" coming from the simulink model; after the flag is generated, the cost function is evaluated based on the data.
More in details, the algorithm idea is something like this:
Perform the experiment by using a certain set of parameters.
After the experiment is done, the cost function for that set of parameters can be evaluated.
Run an iteration of bayesopt() and update the GP model, etc. A new set of parameters is selected through acquisition function.
The experiment is then performed again, and the new cost function is evaluated, and so on…
Now, I know that I can’t directly use bayesopt() in code generation. Is there a way to do this without having to completely rewrite the code for the Bayesian Optimization? For a particular application, I need to implement Bayesian Optimization so to continuously run in a Simulink model. The simulink model is a control algorithm, which has to be translated into C code, and run on an ECU. The Bayesian Optimization should update the controller parameters (which are the parameters to be optimized) based on a certain cost function, which is directly measured from some sensors available to the ECU. So in practice my cost function should "wait" for a flag "experiment completed" coming from the simulink model; after the flag is generated, the cost function is evaluated based on the data.
More in details, the algorithm idea is something like this:
Perform the experiment by using a certain set of parameters.
After the experiment is done, the cost function for that set of parameters can be evaluated.
Run an iteration of bayesopt() and update the GP model, etc. A new set of parameters is selected through acquisition function.
The experiment is then performed again, and the new cost function is evaluated, and so on…
Now, I know that I can’t directly use bayesopt() in code generation. Is there a way to do this without having to completely rewrite the code for the Bayesian Optimization? control, optimization, code generation MATLAB Answers — New Questions