I would like to make my Julia/JuMP code more flexible and prepare it for larger test cases. For this I would need to
- Read in data from a given directory
- Build a model based on it - here since the model is large and has different functional parts I would like to use separate functions for this
- Solve the model and extract key result data
- Write the results into file
- Change the directory and start again (in a loop)
So this should be done for about 100+ test cases… and would really need to do this type of testing in loops (automatically). What I already tried was to create a function
#function 1: basic math model function CreateMathModel(parameters) create variables and constraints return m #function 2: add special variables and constraints function AddMathModelFeatures(m,parameters) create some new variables and constraints - also involving already created variables return m #later I want to optimize it and read and store the values in another function
But the main problem is that in function 2, it does not recognize the variables I created in function 1… and I get errors such as “type Model has no field x” What is the best way to deal with this? There are quite a few variables involved so it can get complex. I googled for help but it is not trivial to find solutions following the new format (JuMP 0.19).
Thankful for any tips!