Parameter estimation
If we think about creating models of a control object in terms of the data we have about the model, then there are often 3 approaches:
A white box model is a model in which we know all the basic dynamics of the system.
On the contrary, the black box model implies that we don't know the dynamics at all.
This example examines the intermediate gray box approach, when we know the structure of the model, but we lack some parameters.
The missing parameters can be selected based on experimental data. This is a rather complex algorithm, but thanks to the collaboration of scripts and models, even such a difficult task can be implemented in the code.
For the convenience of reuse of the algorithm in other projects, the code is hidden by Masks of code cells. Masks only work in the Code Editor, so the full functionality is not available in the Community. Therefore, the masked code below has been replaced with screenshots from the parameter_estimation.ngscript file.
Loading data from a table
using DataFrames, CSV;
df_in = DataFrame(time=exp_time_data, value=exp_in_data)
df_in = Float64.(df_in);
wa_in = WorkspaceArray(string(rand()), df_in)
In this example, the control object is a DC motor. The model contains all the known parameters from the engine documentation. But the friction is not given in the documentation, so now there are approximate values in the blocks of coefficients of viscous friction and sliding friction.
The next cell runs the model for simulation to make sure that the results of the model will be far from the experimental data.
Comparison of experimental data and model data
Connecting libraries for evaluation
using DataFrames
try
using NLopt
catch
Pkg.add(["NLopt"])
using NLopt
end
try
using Interpolations
catch
Pkg.add(["Interpolations"])
using Interpolations
end
Result:
In 30 iterations, we have selected the following parameters:
Результаты оценки:
b = 0.024429360665833955
c = 1.4808238712308082
We are quite satisfied with the results.
To improve the result, you can experiment with initial assumptions, optimization settings, and submit various input data to the experimental bench.