I have some JuMP (optimisation package) variables which I want to save to a data frame to then save to a .csv file. My idea is to have a data frame that would look something like this:
df = DataFrame(JuMPVariable = Symbol[], Value = Number[],
Dimensions = Tuple[])
I would then implement a for loop to push all the JuMP variables to the data frame. However, the dimensions of the JuMP variables vary, so I can’t just do:
for d = 1:length(jump_var)
push!(df, symbol, jump_var[d], d)
In fact what I’ve written above wouldn’t work, I just can’t even begin to think about how I would do this. I think I need some sort of recursion, but have never done that before (at least not consciously).
If it helps, I would like my output to look something like this:
│ Row │ JuMPVariable │ Value │ Dimensions │
│ │ Symbol │ Number │ Tuple │
├─────┼──────────────┼────────┼─────────────┤
│ 1 │ Capacity │ 1000 │ ("Wind",) │
│ 2 │ OPEX │ 100 │ ("Wind", 1) │
│ 3 │ OPEX │ 100 │ ("Wind", 2) │
│ 4 │ OPEX │ 100 │ ("Wind", 3) │
│ 5 │ OPEX │ 100 │ ("Wind", 4) │
│ 6 │ OPEX │ 100 │ ("PV", 1) │