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

Using an out-of-scope variable - ref extensions #668

Closed
kaarthiksundar opened this issue Feb 6, 2020 · 11 comments
Closed

Using an out-of-scope variable - ref extensions #668

kaarthiksundar opened this issue Feb 6, 2020 · 11 comments
Milestone

Comments

@kaarthiksundar
Copy link
Collaborator

function build_ref(data::Dict{String,<:Any}; ref_extensions=[])

@ccoffrin what is pm in the line ref_ext(pm). It is not in scope. But I guess the tests does not capture this.

@ccoffrin
Copy link
Member

ccoffrin commented Feb 6, 2020

Good catch! The ref_ext does not make sense outside of instantiate_model call, so I think I would just remove that functionality from this method.

@kaarthiksundar
Copy link
Collaborator Author

kaarthiksundar commented Feb 6, 2020

Actually, it is a nice feature and does make sense. Some one would like to add a ref extension without building a model. But it is just that the input to the ref_ext functions should be the ref itself in addition to the data. I see why you would pass on AbstractPowerModel itself since it contains both. Let me know what you think. I would just overload ref_ext to take the data and the ref.

@ccoffrin
Copy link
Member

ccoffrin commented Feb 6, 2020

Good point, if you like we can change the API of the ref_ext to those two arguments instead of the AbstractPowerModel. Can you tell me a little more about your use case? At the moment I am only using this feature for backward compatibility with some code that was pre-ref_ext.

@kaarthiksundar
Copy link
Collaborator Author

Consider this - I have some new expansion planning model that I want to build from scratch (stand-anlone: think PowerModelsAnnex type) with data having additional fields. I would use the plain build_ref and add additional fields that include the expansion options into ref according to my need.

@ccoffrin
Copy link
Member

ccoffrin commented Feb 6, 2020

Fair point, but why do you want to add these options via the ref_extensions call, instead of after you get a hold of the ref object? Because you want to use some ref_extensions that are already part of PowerModels?

@kaarthiksundar
Copy link
Collaborator Author

kaarthiksundar commented Feb 6, 2020

Yes, but my use case was for GasModels. Basically I am reading in the static data using parse_file(), then adding a bunch of additional fields to the data dictionary using a prep_transient_data(data::Dict{String,Any}) and then building the ref. Ideally the basic build_ref will take care of all the fields that are need for the static data and my extension would add the additional fields to the ref. Either way, the only things that the ref_ext would require is the ref and the data. It is independent of the model. I envision GasModels supporting only certain transient models, and if I want to test out other models for research (similar to Annex), I would use this feature.

@ccoffrin
Copy link
Member

ccoffrin commented Feb 6, 2020

Sounds good. I am open to making this API change the new standard approach.

@kaarthiksundar
Copy link
Collaborator Author

Great, thanks

@kaarthiksundar kaarthiksundar changed the title Using an out-of-scope variable Using an out-of-scope variable - ref extensions Feb 6, 2020
@kaarthiksundar
Copy link
Collaborator Author

@ccoffrin How do you make changes to the data if you have additional fields. For instance lets say you read in additional fields from the matpower extension format. Where does the code for making every additional field go?

@ccoffrin ccoffrin added this to the v0.16.0 milestone Feb 8, 2020
@ccoffrin
Copy link
Member

ccoffrin commented Feb 8, 2020

so far every set of data extensions have been associated with a specific problem definition. A ref_extention is defined for that specific problem that deals with the additional fields. For example, https://github.com/lanl-ansi/PowerModels.jl/blob/master/src/prob/tnep.jl#L70.

@ccoffrin
Copy link
Member

closed in v0.16

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

No branches or pull requests

2 participants