# JuliaSimModelOptimiser get calibration results

**URL:** <https://discourse.julialang.org/t/juliasimmodeloptimiser-get-calibration-results/107503>\
**Category:** Optimization (Mathematical)\
**Tags:** juliasim\
**Created:** [December 12, 2023, 2:56pm UTC](https://discourse.julialang.org/t/juliasimmodeloptimiser-get-calibration-results/107503 "2023-12-12T14:56:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpex](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rpex/32/204786_2.png) [@rpex](https://discourse.julialang.org/u/rpex)\
**Post date:** [December 12, 2023, 2:56pm UTC](https://discourse.julialang.org/t/juliasimmodeloptimiser-get-calibration-results/107503/1 "2023-12-12T14:56:05Z")

</div>

_Can JuliaSimModelOptimiser.jl topics be asked here?_

I define a search space and create an [`JuliaSimModelOptimizer.InverseProblem`](https://help.juliahub.com/jsmo/stable/manual/inverseproblem/#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?

```julia
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)]

```

---

<div class="post-metadata">

**Author:** ![SebastianM-C](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sebastianm-c/32/2480_2.png) [@SebastianM-C](https://discourse.julialang.org/u/SebastianM-C)\
**Post date:** [December 12, 2023, 3:33pm UTC](https://discourse.julialang.org/t/juliasimmodeloptimiser-get-calibration-results/107503/2 "2023-12-12T15:33:10Z")

</div>

The `CalibrateResult` has an `AbstractArray` and a [`Tables.jl` interface](https://tables.juliadata.org/stable/#Using-the-Interface-(i.e.-consuming-Tables.jl-compatible-sources)), 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.
