Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tables.jl support for results #3096

Closed
hellemo opened this issue Sep 28, 2022 · 4 comments · Fixed by #3104
Closed

Tables.jl support for results #3096

hellemo opened this issue Sep 28, 2022 · 4 comments · Fixed by #3104
Labels
Category: Containers Related to the Containers submodule Status: Help Wanted Help is welcome on this issue Type: Feature request
Milestone

Comments

@hellemo
Copy link
Contributor

hellemo commented Sep 28, 2022

We are considering moving the Tables.jl support for results from SparseVariables.jl to another package. (sintefore/SparseVariables.jl#20). One issue then is whether support for the default containers from JuMP should be in a separate package from the SparseVariables type(s) or not.

One alternative would be to add Tables.jl support for DenseAxisArrays and SparseAxisArrays to JuMP, as Tables is designed to be a light dependency (and keep the Tables support for our own types in our package). What do you think?

Some other things to consider (that might go together with this or belong in separate issues) are:

  • It would be nice if DenseAxisArrays and SparseAxisArrays would also store the subindex names/index_vars, in our current implementation these have to be added explicitly when generating e.g. a DataFrame with the variable values from the solver (kind of a follow-up to Pass names (index_vars) to container extensions. #3088). With names stored with the container, one could generate result tables with good default column names automatically.
  • Performance of reading results from solvers. I haven't looked into this yet, but getting large results feels kind of slow. Fast read of results that can easily be dropped into dataframes, plots, csv etc would be a nice usability improvement.
@odow
Copy link
Member

odow commented Sep 28, 2022

Related https://discourse.julialang.org/t/efficient-serialization-of-jump-results/87896

cc @jd-foster

I haven't really looked at the Tables.jl stuff, but what would the output be? Columns with the keys and then one value column? That could be quite nice, and would work for both Dense and Sparse

@hellemo
Copy link
Contributor Author

hellemo commented Sep 28, 2022

Yes, exactly. Tables support for Dense is already implemented in SparseVariables, and I think Sparse is in the works (@trulsf ?)

For the example in the readme (after solving):

julia> # Read solution values for u (DenseAxisArray)
       DataFrame(table(u, :u, :car, :year))
12×3 DataFrame
│ Row │ car    │ year  │ u       │
│     │ String │ Int64 │ Float64 │
├─────┼────────┼───────┼─────────┤
│ 1   │ ford   │ 2000  │ 1.0     │
│ 2   │ bmw    │ 2000  │ 1.0     │
│ 3   │ opel   │ 2000  │ 1.0     │
│ 4   │ ford   │ 2001  │ 1.0     │
│ 5   │ bmw    │ 2001  │ 1.0     │
│ 6   │ opel   │ 2001  │ 1.0     │
│ 7   │ ford   │ 2002  │ 1.0     │
│ 8   │ bmw    │ 2002  │ 1.0     │
│ 9   │ opel   │ 2002  │ 1.0     │
│ 10  │ ford   │ 2003  │ 1.0     │
│ 11  │ bmw    │ 2003  │ 1.0     │
│ 12  │ opel   │ 2003  │ 1.0     │

julia> using PrettyTables

julia> pretty_table(table(y)) # SparseVarArray
┌──────┬──────┬─────┐
│  car │ year │   y │
├──────┼──────┼─────┤
│  bmw │ 2001 │ 0.0 │
│ ford │ 2001 │ 0.0 │
│ ford │ 2000 │ 0.0 │
│  bmw │ 2002 │ 0.0 │
└──────┴──────┴─────┘

@odow
Copy link
Member

odow commented Sep 28, 2022

This could actually be quite nice. Happy to review a PR if you want to make one?

@odow odow added this to the 1.x milestone Sep 28, 2022
@odow odow added Type: Enhancement Category: Containers Related to the Containers submodule Status: Help Wanted Help is welcome on this issue Type: Feature request and removed Type: Enhancement labels Sep 28, 2022
@hellemo
Copy link
Contributor Author

hellemo commented Sep 29, 2022

Sure, will get back to you with a PR. No promises on timeline, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Containers Related to the Containers submodule Status: Help Wanted Help is welcome on this issue Type: Feature request
Development

Successfully merging a pull request may close this issue.

2 participants