-
Notifications
You must be signed in to change notification settings - Fork 20
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
Move incoming and outgoing flow computation to DuckDB #919
base: main
Are you sure you want to change the base?
Conversation
Benchmark Results
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #919 +/- ##
=======================================
Coverage 99.17% 99.17%
=======================================
Files 29 29
Lines 1205 1215 +10
=======================================
+ Hits 1195 1205 +10
Misses 10 10 ☔ View full report in Codecov by Sentry. |
7a6306a
to
604362b
Compare
@datejada @suvayu This introduces the big issue of the past: computing the indices of the incoming (and outgoing) flows is slow: julia> using TimerOutputs;
julia> TulipaEnergyModel.to = TimerOutput();
julia> begin
using TulipaEnergyModel, TulipaIO, DuckDB, DataFrames
con = DBInterface.connect(DuckDB.DB)
schemas = TulipaEnergyModel.schema_per_table_name
read_csv_folder(con, "benchmark/EU/"; schemas)
ep = EnergyProblem(con)
create_model!(ep)
end
Precompiling TulipaEnergyModel...
2 dependencies successfully precompiled in 8 seconds. 122 already precompiled.
EnergyProblem:
- Time creating internal structures (in seconds): 8.04610275
- Time computing constraints partitions (in seconds): 4.152481208
- Time creating dataframes (in seconds): 41.245806959
- Time creating variables indices (in seconds): 2.7459e-5
- Model created!
- Time for creating the model (in seconds): 42.290705958
- Number of variables: 1556419
- Number of constraints for variable bounds: 1248359
- Number of structural constraints: 2303880
- Model not solved!
julia> TulipaEnergyModel.to
────────────────────────────────────────────────────────────────────────────────────────────────
Time Allocations
─────────────────────── ────────────────────────
Tot / % measured: 120s / 68.9% 26.8GiB / 82.9%
Section ncalls time %tot avg alloc %tot avg
────────────────────────────────────────────────────────────────────────────────────────────────
create_model 1 41.3s 49.9% 41.3s 22.1GiB 99.2% 22.1GiB
add_expression_terms_to_df 1 12.1s 14.6% 12.1s 8.69GiB 39.1% 8.69GiB
add_capacity_constraints! 1 10.7s 12.9% 10.7s 5.34GiB 24.0% 5.34GiB
add_storage_constraints! 1 3.46s 4.2% 3.46s 1.90GiB 8.5% 1.90GiB
objective 1 3.02s 3.7% 3.02s 1.05GiB 4.7% 1.05GiB
add_flow_variables! 1 2.90s 3.5% 2.90s 1.70GiB 7.7% 1.70GiB
add_transport_constraints! 1 2.87s 3.5% 2.87s 1.55GiB 7.0% 1.55GiB
add_storage_variables! 1 996ms 1.2% 996ms 414MiB 1.8% 414MiB
multi-year investment expressions 1 663ms 0.8% 663ms 109MiB 0.5% 109MiB
add_consumer_constraints! 1 656ms 0.8% 656ms 317MiB 1.4% 317MiB
add_hub_constraints! 1 570ms 0.7% 570ms 447MiB 2.0% 447MiB
unpacking dataframes 1 408ms 0.5% 408ms 75.8MiB 0.3% 75.8MiB
add_investment_variables! 1 317ms 0.4% 317ms 10.7MiB 0.0% 10.7MiB
add_expressions_for_storage 1 113ms 0.1% 113ms 23.0MiB 0.1% 23.0MiB
add_conversion_constraints! 1 94.8ms 0.1% 94.8ms 25.4MiB 0.1% 25.4MiB
add_unit_commitment_variables! 1 85.6ms 0.1% 85.6ms 2.49MiB 0.0% 2.49MiB
add_investment_constraints! 1 39.7ms 0.0% 39.7ms 1.95MiB 0.0% 1.95MiB
add_energy_constraints! 1 40.6μs 0.0% 40.6μs 64.0B 0.0% 64.0B
Create constraints indices 1 39.8s 48.1% 39.8s 34.5KiB 0.0% 34.5KiB
Create t_incoming_nonzero 1 29.1s 35.2% 29.1s 4.70KiB 0.0% 4.70KiB
Create t_outgoing_nonzero 1 10.5s 12.6% 10.5s 4.70KiB 0.0% 4.70KiB
Create highest_in_out_incoming 1 65.4ms 0.1% 65.4ms 4.70KiB 0.0% 4.70KiB
Create highest_in_out_outgoing 1 35.3ms 0.0% 35.3ms 4.70KiB 0.0% 4.70KiB
unpacking and creating sets 1 1.01s 1.2% 1.01s 188MiB 0.8% 188MiB
Create partition tables 1 641ms 0.8% 641ms 5.38MiB 0.0% 5.38MiB
────────────────────────────────────────────────────────────────────────────────────────────────
Now the goal is to improve (if possible) the creation of table t_incoming_nonzero. |
7a1ddaf
to
34ba4a1
Compare
Related to #895