Skip to content

Fix the supply function in quantities.py to impose minimum constraint #335

Closed

Description

@tsmbland

I've just found why the discrepancy.

  1. The sector output, taking the values right out of the market, gives the right values as market information is calculated based on the constrains (so figure on the right is correct).
  2. The MCA information, surprisingly and I don't know why, is obtained by recalculating everything. In this line, it limits the supply so it is not higher than the maximum production, but it does not impose any minimum constrain but to fulfil the demand, and therefore the minimum service constrained is not honoured.

In summary, the calculation for the MCAMetric_Supply.csv is wrong - and I would presume that any other calculation that uses this supply function will also be wrong, as no minimum constrains are imposed but to fulfill the demand.

Originally posted by @dalonsoa in #321 (comment)

Activity

  1. moved this to 📋 Backlog in MUSEon Jun 12, 2024
  2. tsmbland commented on Jun 12, 2024

    @tsmbland
    CollaboratorAuthor

    @dalonsoa Are you working on this, or would you like me to look into it?

  3. ahawkes commented on Jun 12, 2024

    @ahawkes
    Collaborator
  4. dalonsoa commented on Jun 12, 2024

    @dalonsoa
    Collaborator

    @tsmbland , nope, so all yours!

  5. self-assigned this
    on Jun 12, 2024
  6. moved this from 📋 Backlog to 🔖 Ready in MUSEon Jun 12, 2024
  7. moved this from 🔖 Ready to 🏗 In progress in MUSEon Jun 14, 2024
  8. moved this from 🏗 In progress to No status in MUSEon Jun 17, 2024
  9. moved this to 🔖 Ready in MUSEon Jun 17, 2024
  10. dalonsoa commented on Jun 21, 2024

    @dalonsoa
    Collaborator

    So, I've been looking into this and, after digging in the exciting world of decorators and registries, it turns out this function is used whenever dispatch_production = 'share' is chosen for a sector, which is most of the times. So:

    1. We cannot simply get rid of this function.
    2. The function has been doing things wrong all along, as it does not respect the minimum service factor.

    So the fix passes through updating the function such that we also calculate a minimum_production and impose it here.

  11. moved this from 🔖 Ready to 🏗 In progress in MUSEon Jun 21, 2024
  12. ahawkes commented on Jun 21, 2024

    @ahawkes
    Collaborator
  13. dalonsoa commented on Jun 21, 2024

    @dalonsoa
    Collaborator

    E.g. if dispatch is set to share means that the dispatch must follow the demand profile shape, but a minimum service constraint is also imposed that does not allow this

    The maximum production (which includes the utilisation factor) can also prevent this from happening, so also using the minimum service constraint will not lead to a new situation that is not potentially happening already.

    However I’m not entirely sure that that is the intention of dispatch_production = share. Is there another option that is something like “merit order”?

    Ok, as it is often the case, this is an undocumented/wrongly documented feature of MUSE. If you go to the input file documentation (to this section) it explains what the investment_production and the dispatch_production are. But the valid options for either case (which are the same) are not correct. These options can be found in the code itself (and the API documentation), everything with the register_production decorator. The current options are: maximum, share, match and costed. I'm not sure if any of them do what you want.

  14. ahawkes commented on Jun 21, 2024

    @ahawkes
    Collaborator

    Wow. Don't all of the 4 options potentially (likely!) contradict the dispatch as computed in the call to highs that we've discussed previously? Why are they all calculated again here? Am I missing something?

  15. moved this from 🏗 In progress to 👀 In review in MUSEon Jun 24, 2024
  16. dalonsoa commented on Jun 24, 2024

    @dalonsoa
    Collaborator

    I've created a PR (#368) to close this issue and, after seeing what files were modified, I think I know why there're two routes for calculating stuff (to be checked): The individual dispatch functions are only really used by the ad-hoc solver, not the scipy solver, which takes the output of the solver as the dispatch, as it should since it contains all the constrains. The ad-hoc solver needs to calculate everything manually, and hence this functions.

    This is not really documented, as far as I can tell, which leads to incorrect use of the input parameters, normally irrelevant as they will not affect the result or it will result in contradictory outputs. The MCAMetric-related outputs used the quantities calculated with the ad-hoc solver, which are not necessarily the same than the scipy solver.

  17. ahawkes commented on Jun 24, 2024

    @ahawkes
    Collaborator

    But have we solved the fundamental issue? It's not OK to have contradictory outputs, right? I do not understand why this "ad-hoc" solver exists. Why do we have this output reported in two different places?

  18. dalonsoa commented on Jun 24, 2024

    @dalonsoa
    Collaborator

    @ahawkes , the adhoc solver has always existed, coming from the time of the original MUSE but using xarray and the more modern architecture setup by Mayeul, and indeed it is still the default, although none of the models or examples use it. There has never been a suggestion or discussion to drop it, so there it is.

    The fundamental issue is, mainly, one of documentation.

  19. ahawkes commented on Jun 24, 2024

    @ahawkes
    Collaborator

    OK, but is it simple enough to change the default to spicy? And make sure that this conflicting result is not provided to the user when using spicy? Because it's understandably very confusing.

    I think probably worth dropping the ad-hoc as it does not appear to respect input data, but we should ask @sgiarols of any known implications. Any thoughts Sara?

  20. moved this from 👀 In review to On hold in MUSEon Jun 28, 2024
  21. moved this from On hold to 🏗 In progress in MUSEon Jul 8, 2024
  22. moved this from 🏗 In progress to On hold in MUSEon Jul 22, 2024
  23. removed their assignment
    on Sep 9, 2024
  24. tsmbland commented on Oct 28, 2024

    @tsmbland
    CollaboratorAuthor

    Closed by #368

  25. moved this from On hold to ✅ Done in MUSEon Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    • Status
      ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions