Mimi Framework

Make MCS @defmcs accept constrained distributions?

Thanks all, this is super helpful!

Hi again, sorry for the delayed feedback. I still have the same issue after pulling Richard’s changes on my master branch and using the Mimi master branch: I still get the error
ERROR: UndefVarError: ReshapedDistribution not defined.
How come the new ReshapedDistribution structure does not seem to be recognized even if I pulled it on my computer?

Also when I comment out l.30: alpha = Mimi.ReshapedDistribution([5, 5], Dirichlet(25,1)), I still get as error:
ERROR: MethodError: no method matching set_models!(::MonteCarloSimulation, ::MarginalModel).

I suppose this means that the new version of Mimi is not correctly pulled?

I can look into this if you push it, sorry it’s causing you trouble. Just so I understand the state of your environment, we’ve now released Mimi0.7.0, so you should be able to ]free Mimi and work with the latest tagged version now.

Thanks a lot Lisa! Just pushed. I still get the UndefVarError: ReshapedDistribution not defined error, even after doing ]free Mimi.

But everything else works; when I comment the Mimi.ReshapedDistribution part out (l.30), I got everything running.

Great, I’ll take a look tomorrow or tonight, and give you an update on an easier way for you to work wth FUND per recent updates as soon as I complete that. Should make your folder structure way simpler.

1 Like

@hbenveniste I’m sorry I didn’t think of this earlier, but I think your error is actually very small! In general, the list of “exported” functions by Mimi is small, because those are the ones we try extremely hard not to “break” in future releases. Often, more advanced users like you want to use functions that are not exported, meaning that you cannot directly use them without importing them. There are a few ways to do that. One way is just to prefix the function with Mimi., i.e. Mimi.ReshapedDistribution. If there is something you are doing quite often, and that is annoying, you can directly import more functions. For example, the beginning of test_reshaping.jl looks like this:

using Mimi
using Distributions
using Query
using DataFrames
using IterTools
using DelimitedFiles

using Test

using Mimi: reset_compdefs, modelinstance, compinstance, 
            get_var_value, OUTER, INNER, ReshapedDistribution

For you, you would basically need to put both of these lines in

using Mimi # brings in all exported functions, you already do this
using Mimi: ReshapedDistribution # brings in ReshapedDistribution

Then you can use ReshapedDistribution wherever want without the Mimi. prefix!

Shoot, you did already do this! Ok then I think you must be running an old version of Mimi, what happens when you type ]st Mimi? Let’s make sure you have the latest version by typing using ]up, which will update all of your packages. Then ]st should show that you have [e4e893b0] Mimi v0.8.0.

You will need to

  • change @defmcs to @defsim
  • change run_mcs to run_sim

Then try to run it, it should work but I"ll double check on my machine now.

Thanks Lisa! I did already try to updates packages multiple times, but I still am on [e4e893b0] Mimi v0.6.4. I’m not sure why that’s happening?

Oh well that’s certainly the problem! Hm that’s really strange, can you send me the full list of what comes out when you do ]st?

    Status `C:\Users\Helene\.julia\environments\v1.0\Project.toml`
  [336ed68f] CSV v0.4.3
  [a93c6f00] DataFrames v0.17.1
  [31c24e10] Distributions v0.16.4
  [89b67f3b] ExcelFiles v0.9.1
  [f67ccb44] HDF5 v0.11.0
  [4138dd39] JLD v0.9.1
  [e4e893b0] Mimi v0.6.4
  [76087f3c] NLopt v0.5.1
  [2913bbd2] StatsBase v0.29.0
  [0ae4a718] VegaDatasets v0.5.0
  [112f6efa] VegaLite v0.6.0

Alright well to start you should upgrade to Julia v1.1, which is required by Mimi v0.8.0, so do that now.

no other way to do it than just downloading directly Julia v1.1 right?

For VSCode, when you open it you will probably see this at the bottom:
25%20PM

If you click on Julia env: v1.x you will get a drop down menu like this:

Click on the v1.1 option, and then go delete the folder of v1.0 to avoid confusion later. Now if you run cmd + enter on a line to run it, you should see a command line window and ] should give you something like ! (v1.1) pkg>.

Let me know how all of this goes, happy to help you along. You’ll need to re-add any packages you were using with ]add Mimi; add Distributions etc.

Yay it works! Thanks all!

Oh that’s great news! Let me know if there’s any trouble, I had issues with VSCode reverting to Julia v1.0 until I (1) changed the binary path and (2) deleted that environments/v1.0 folder.