# Workflow question: loading models for simulation

**URL:** <https://discourse.julialang.org/t/workflow-question-loading-models-for-simulation/72709>\
**Category:** Performance\
**Created:** [December 7, 2021, 12:58pm UTC](https://discourse.julialang.org/t/workflow-question-loading-models-for-simulation/72709 "2021-12-07T12:58:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivborissov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ivborissov/32/2841_2.png) [@ivborissov](https://discourse.julialang.org/u/ivborissov)\
**Post date:** [December 7, 2021, 12:58pm UTC](https://discourse.julialang.org/t/workflow-question-loading-models-for-simulation/72709/1 "2021-12-07T12:58:50Z")

</div>

Hi,

My question is related to optimization of the following workflow. I have a package `MySimPkg` to simulate ODE-based models and I load those models (currently julia `.jl` files) to run simulations. Each `model.jl` looks like:

```julia
function mymodel()

# some code

return my_model_struct
end

```

In `MySimPkg` I have the following function to load models

```julia
function load_mymodel(model_jl)
  Base.include(Main, model_jl)
  return Base.invokelatest(Main.mymodel)
end

```

And to start simulations I run:

```julia
using MySimPkg

mod1 = load_mymodel("path_to_mymodel1")
s1 = simulate(mod1)

mod2 = load_mymodel("path_to_mymodel2")
s2 = simulate(mod2)

```

However `include` and `invokelatest` are time consuming procedures and it seems there could be a way to optimize this workflow. Is there better solution for this problem?

Thanks,  
Ivan
