-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
Improve support for relational algebra #3438
Comments
The alternative is to parse
|
This tutorial is relevant for any changes in the future looking at this: https://jump.dev/JuMP.jl/stable/tutorials/linear/multi_commodity_network/ |
See also #3212 |
Perhaps I do like #3441 julia> using JuMP, DataFrames
julia> function JuMP.Containers.container(
f::Function,
indices,
::Type{DataFrames.DataFrame},
names,
)
rows = vec(collect(indices))
df = DataFrames.DataFrame(NamedTuple{tuple(names...)}(arg) for arg in rows)
df.value = [f(arg...) for arg in rows]
return df
end
julia> model = Model();
julia> @variables(model, begin
x[i in 1:2, j in i:2], (container = DataFrames.DataFrame)
y[i in 1:2, 1:2], (container = DataFrames.DataFrame)
z[i in 1:2, j in 1:2; isodd(i+j)], (container = DataFrames.DataFrame)
end);
julia> x
3×3 DataFrame
Row │ i j value
│ Int64 Int64 GenericV…
─────┼─────────────────────────
1 │ 1 1 x[1,1]
2 │ 1 2 x[1,2]
3 │ 2 2 x[2,2]
julia> y
4×3 DataFrame
Row │ i ##288 value
│ Int64 Int64 GenericV…
─────┼─────────────────────────
1 │ 1 1 y[1,1]
2 │ 2 1 y[2,1]
3 │ 1 2 y[1,2]
4 │ 2 2 y[2,2]
julia> z
2×3 DataFrame
Row │ i j value
│ Int64 Int64 GenericV…
─────┼─────────────────────────
1 │ 1 2 z[1,2]
2 │ 2 1 z[2,1] |
If we supported that syntax, then improvements to how we parsed and constructed the sparse index sets would just be a performance optimization. |
Motivated by https://jump.dev/2023/07/20/gams-blog/
To make this syntax a bit nicer
The text was updated successfully, but these errors were encountered: