GasModels.jl icon indicating copy to clipboard operation
GasModels.jl copied to clipboard

result["data"]

Open rb004f opened this issue 5 years ago • 6 comments

result["data"] should report the count of the new components, such as storage, transfers, etc. Update the results_data.md file when this is done

rb004f avatar May 01 '20 20:05 rb004f

I dropped this feature in IM v0.5 because it was not obvious how we could easily generalize across packages and I didn't really see a need for it anymore. Do you have a use case in mind?

ccoffrin avatar May 01 '20 21:05 ccoffrin

The statistics are still being reported in GasModels (as of the v0.7 branch). If we are going to continue to report it, we should keep it up to date. It was/is a nice feature to sometimes look at when inspecting a solution, but not a core feature. In terms of generalization, what about generating a foo_count for any entry at the top level of the data dictionary for which itself is a dictionary?

rb004f avatar May 01 '20 21:05 rb004f

Got ya. The generalization you propose could work. Another option is to have a function that each package can overload as they prefer.

Part of my motivation was that a typical workflow would look like,

data = parse(...)
result = run_foo(data, ...)
print_stats(data, result["solution"])

If you would like to summarize the solution, you would usually have the data right next to it. So you can design some arbitrary post-processing function to generate metrics that are better than the simple one that used to be in result["data"].

Another option would be something like,

data = parse(...)
result = run_foo(data, ...)
update_data!(data, result["solution"])
print_metrics(data)

This is even more flexible because print_metrics can be called on any data, before or after a solve.

BTW, have you tried the print_summary(data)/print_summary(data["solution"]) feature? It should be working with GasModels and I find it's a great way to quickly inspect results in the REPL.

Do you think either of these would be a good fit for your use case?

ccoffrin avatar May 01 '20 21:05 ccoffrin

the print functions look like a good substitute. The resolution of this issue will be dropping support for this feature.

rb004f avatar May 01 '20 22:05 rb004f

Great!

ccoffrin avatar May 01 '20 22:05 ccoffrin

@kaarthiksundar, can we get this into the v0.7 release?

ccoffrin avatar May 01 '20 22:05 ccoffrin