davidusb-geek / emhass

emhass: Energy Management for Home Assistant, is a Python module designed to optimize your home energy interfacing with Home Assistant.
MIT License
316 stars 64 forks source link

Type of self-consumption optimization is always bigm, never maxmin #141

Closed michaelpiron closed 11 months ago

michaelpiron commented 11 months ago

Hi @davidusb-geek ,

In the code, I noticed that in case of a self-consumption cost function, the optimizer always applies the so-called "bigm" method, due to this hard-coded parameter:

https://github.com/davidusb-geek/emhass/blob/a4255f54f2c5ae2e9e34b0fd5ee6d7c1ed2efef6/src/emhass/optimization.py#L138

However, the documentation explains the "maxmin" method, which is never invoked due to the parameter above. Is there an issue with the maxmin method (e.g. never leads to a solution)?

Happy to help further, based on your reply.

davidusb-geek commented 11 months ago

Yes it is hard coded to big M. It was long time ago but I think that the other method has convergence problems, probably the equations are not well posed. The big M was a second possible method but the maxmin is the elegant correct way to handle this. Of course that you can help, all contributions are more than welcomed. If you are interested we have another problem in the constraints section with constraints: set_def_const and treat_def_as_semi_cont. The don't seem to be compatible and are causing infeasible issues.

michaelpiron commented 11 months ago

Ok, I will adapt the documentation to reflect the reality that self-consumption cost function uses the big M method.

regarding the other issue on constraints, is there already a bug report of this? If not, can you provide more input/evidence of the issue?

thx

davidusb-geek commented 11 months ago

regarding the other issue on constraints, is there already a bug report of this? If not, can you provide more input/evidence of the issue?

I dived into this other issue and it is solved in the current release.

michaelpiron commented 11 months ago

Updated the optimizer documentation here: #143 It now describes that self-consumption has two methods (bigM and maxmin), and that currently only method bigM is used.