-
Notifications
You must be signed in to change notification settings - Fork 132
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
Features/integrate stochastic programming #809
base: dev
Are you sure you want to change the base?
Conversation
Hello @e-zolotarevskaya! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2022-02-17 10:12:12 UTC |
Hi @e-zolotarevskaya: I'm happy to assist and review on this one. I changed the base of your Pull Request to I think, your draft component seems to be located correctly. You can check other experimental component classes for how to implement. Feel free to ask back if anything is unclear. |
@jokochems thank you! Speaking of files location, what would be a good place for my test script? For now I made a nested directory in constraints folder, but didn't add it to git as I was unsure if it is right. |
That depends on what you are referring to when you use the term "tests".
|
Is there something new here? @e-zolotarevskaya could you share the scripts you already used for your example (using pure pyomo)...it would then be easier to understand the conrete use case and find the abstract version and its implementation in solph... |
Hi! So far I've been mostly working on validating the concept in Julia. It's working quite well now, so I'm moving back to pyomo and oemof. |
Hey, this looks already quite great! The variables you want i.e. for your first stage variables you have already found. My first idea was to create a set with all flows (i.e. variables) of the first stage (there might be more, such as the storage level, or investment and binary (nonconvex) variables. But I think, all of them except the storage content, are associated with the flow. So from the API side something like this could be possible
Then, internally, we build sets
Collecting the first stage variables could also be done by users and we would not need to change the source code. Getting the first stage objective right is a little more tricky. But as every "Block" which guild constraints has a method |
But we might have a call to discuss the details (what is required, what is possible, etc) |
I added a first idea (only for the flow-associated variables). Collecting the variables can acutally be easy once we have all our first stage cost expressions (as a pyomo-Expression instance) For example like this with a model
I suggest combining all first stage cost expressions in one big one |
# def _fix_value_rule(model): | ||
# """""" | ||
# for inp, out in m.FIRSTSTAGE_FLOWS: | ||
# for t in m.TIMESTEPS: | ||
# self.fix_value_constr.add( | ||
# (inp, out, t), | ||
# m.flow[inp, out, t] == | ||
# m.flows[inp, out].fix[t] * m.flows[inp, out].nominal_value) | ||
# | ||
# self.fix_value_constr = Constraint(m.FIRSTSTAGE_FLOWS, m.TIMESTEPS, noruleinit=True) | ||
# self.fix_value_build = BuildAction(rule=_fix_value_rule) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is obsolete..
I looked through the code and found the following places where cost expressions occur (they are all build in
I wonder if there is an elegant way of having only one file with all the method definitions "_objective_expression()" for the stochastic version and simply overriding the present method inside the block if e.g. the model has an attribute "stochastic" (or isinstance of Of course, creating a whole new set of inherited classes, i.e. |
Thank you for taking a look! I tried to do something similar to the set using filters and selecting flows associated with certain components, but this is much cleaner. If we could have a call to discuss it in more detail I would appreciate it. |
Just a small info, I rebuild the mpisppy farmer example with oemof-solph and results are the same. You can check it out here: |
What is the status of this work on stochastic programming integration? I'd be glad to help. I am not super deep into oemof or pyomo modeling, but I have a project I'm working on that I want to extend to include stochasticity and also integrate with and/or contribute models back to an energy modeling framework so that there's a better chance for my work to be useful to others. |
Integration of stochastic programming into oemof to optimize potential of providing ancillary services.
Resolves #778