JuliaSimModelOptimiser get calibration results

Can JuliaSimModelOptimiser.jl topics be asked here?

I define a search space and create an JuliaSimModelOptimizer.InverseProblem. Then I calibrate my search space to data and get a JuliaSimModelOptimizer.CalibrateResult.

Right now I am using my search space to find out the order of the CalibrateResult.original.

Is there a better way to get the calibrated parameters with names?

param = [ a => (0.0, 1.0),
          b => (0.0, 1.0),
          c => (0.0, 1.0)]

invprob = InverseProblem(experiment, sys, param);
results = calibrate(invprob, alg)

tuned_param = [(param[i].first => results.original[i]) for i in 1:length(results.original)]

The CalibrateResult has an AbstractArray and a Tables.jl interface, so you can access the results by name with results[:a] or by index with results[1]. The column names are given by Tables.columnnames.

One consequence for that is that you can easily create a DataFrame out of the result with just DataFrame(results), or you can write it to as .csv file with CSV.write(io, res). To create a vector of pairs, you can use Tables.columnnames(results) .=> results.

I would not advise to use .original directly, as that might contain more elements than you expect or have them in a different order depending on internal optimizations.

For example MultipleShooting will introduce additional optimization variables for the starting points of the segments, so the vector in .original will contain the full solution, which will lead to a bounds error. If you instead index into results directly you will always only have access to the parameters that have names.
Also, if you mix initial conditions and parameters in the search space, the order in the result won’t match with the order that you provided in the search space (param), so it’s better to always use the Tables.columnnames API.

1 Like