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

Add vintage version for multi-year #741

Closed
wants to merge 6 commits into from

Conversation

gnawin
Copy link
Member

@gnawin gnawin commented Aug 14, 2024

Pull request details

Describe the changes made in this pull request

This PR is huge, because it involves change the data structure and the model, which does not make sense if this PR gets separated.

List of related issues or pull requests

Closes #740

Collaboration confirmation

As a contributor I confirm

  • I read and followed the instructions in README.dev.md
  • The documentation is up to date with the changes introduced in this Pull Request (or NA)
  • Tests are passing
  • Lint is passing

@gnawin
Copy link
Member Author

gnawin commented Aug 14, 2024

@abelsiqueira The time resolution part, for assets/flows/constraints, seems to complain about the type as I mentioned earlier.

  • I have to remove the type of the first argument in compute_rp_partition. That removes that particular error for constraints. See line 208 in time-resolution.jl
  • compute_assets_partitions! complains about the type as well for the assets in line 507 in io.jl.

I'm a bit lost here, maybe you could see what changes I made lead to these errors?

rep_periods_partitions = Dict{Int,Vector{TimestepsBlock}}()
timeframe_profiles = Dict{Int,Dict{String,Vector{Float64}}}()
rep_periods_profiles = Dict{Int,Dict{Tuple{String,Int},Vector{Float64}}}()
timeframe_partitions = Dict{Int,PeriodsBlock}()
Copy link
Member

@abelsiqueira abelsiqueira Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked at the whole code, but I think this should be the following:

Suggested change
timeframe_partitions = Dict{Int,PeriodsBlock}()
timeframe_partitions = Dict{Int,Vector{PeriodsBlock}}()

Comment on lines 88 to 95
end for a in MetaGraphsNext.labels(graph) if asset_filter(a) for
y in active_years[a] for iy in (
if any(graph[a].investable[iy] for iy in years)
filter(iy -> graph[a].investable[iy], years)
else
[0]
end
) for rp in RP[y]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is the issue with the type.

if any(graph[a].investable[iy] for iy in years)
filter(iy -> graph[a].investable[iy], years)
else
[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[0]
[false]

Trying to translate.
If the graph is investable at any of the years, then loop it over the values of investable for each year.
Else, loop yi over [0].
This is a problem because you are returning a vector of booleans in the first and a vector of integers in the second.

You can also try:

Suggested change
[0]
Bool[]

Unless you need the single value there.

Also, just try for it in filter(iy -> graph[a].investable[iy], years). I think maybe it won't work (and you might have tried already).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I want to return a list of investment years, for which iy (investment year) can be looped over. So I'm trying to say, if the asset is investable at any of the years, then get the list of years for which the graph[a].investable[iy] is true.
Else, use a default list of [0], i.e., year 0.

@abelsiqueira
Copy link
Member

I made some comments on what, I think, is an issue. I also don't like the graph creation, but I have to read it more carefully to suggest something.

@gnawin
Copy link
Member Author

gnawin commented Aug 15, 2024

@abelsiqueira The other I still have to try but at least I found the cause of this error

compute_assets_partitions! complains about the type as well for the assets in line 507 in io.jl.

I did not realize the change of schemas in #737 3 days ago, and therefore I'm still using read_csv_folder instead of the new one _read_csv_folder with schemas 😢

Copy link
Member Author

@gnawin gnawin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@datejada I came across a few things about storage when I was doing this PR, maybe you could double-check? Thanks

LinearAlgebra.dot(sub_df_flows.flow, sub_df_flows.duration) * row_map.weight
end

if !is_storage_level # got an error here, that's why I modified this condition
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@datejada This condition was if is_storage_level, which is the same as the previous one, is this intentional or a glitch?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a glitch, but the function is confusing, so we will clean it in the refactor. Thanks for the feedback.

("min_storage_level", row.rep_period),
row.timesteps_block,
0.0,
) * (
graph[row.asset].initial_storage_capacity +
(row.asset ∈ Ai ? energy_limit[row.asset] : 0.0)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@datejada I also came across this: the same energy_limit is used for both max and min constraints?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct since we use a minimum storage level profile for the min constraint 😄

@gnawin
Copy link
Member Author

gnawin commented Sep 3, 2024

Replaced by #745

@gnawin gnawin closed this Sep 3, 2024
@datejada datejada mentioned this pull request Sep 26, 2024
52 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the most complicated method
3 participants