Closed tomnonnen closed 1 year ago
Hi @tomnonnen ,
This seems like it potentially is a good way to address the problem :smile:
I've got a few comments about the structure of the code which are potentially best addressed on GitHub through a code review/pull request. The best way to go about this is probably to:
Create a branch
link on the right-hand side of this issue to open a new branch for this issue,dev
branchmaster
branch.Regarding the method, I think it definitely sounds like it's worth giving it a go!
I think there might be something to consider around when certain devices run and whether they have to run. E.G., perhaps a user should be able to specify that they want to charge their laptop or car/run a washing machine between 2 and 4 pm, in which case there may need to be consideration of prioritising those device loads during those hours in your packing algorithm. E.G., pack devices that have to run (e.g., light bulbs at night) followed by those which need to run soon/specifically in one of these hours, followed by those which can run any time (e.g., hot-water heating) with perhaps some bit of code that forces a device to run if it reaches the end of the time period even if there isn't enough solar. (I.E., the grid is utilised?)
Once you've maximised the amount of solar energy resource that was used at each hour, there'll probably need to be some adjustment/calculation as to when you use the grid for the remaining amount. I.E., some devices, such as light bulbs, which run through the night (i.e., can't all be turned on at 6 p.m.) will need to run through whereas others, potentially, should either run when the grid is cheapest, or there needs to be a way to decide (perhaps arbitrarily) when they run during non-solar hours.
These may not be issues, but potentially worth considering.
@tomnonnen , it would be good to have your features implemented into CLOVER as this is definitely something that could have a good impact and which there is a good deal of interest in! :smiley:
@tomnonnen , I'm not sure whether you've thought about adding your code to CLOVER as a result of your project, but it might be worth doing as it then has the potential to either make into the next version of CLOVER (CLOVER 6.0, which we'll hopefully publish somewhere with all of the features) or another paper 😄
Issue
We want to optimize the management of devices to increase the consumption of PV energy. In fact, given the matrix probability for each device, the consumption for each device, and the production PV for each day, we want to assign the PV production to the consumption of each device as best as possible.
Proposal
The solution is inspired by the solution for the Knapsack problem. In the knapsack problem, you need to pack a set of items, with given values and sizes (such as weights), into a bag with a maximum capacity. If the total size of the items exceeds the capacity, you can't pack them all. The problem is to choose a subset of the items of maximum total value that will fit in the bag.
Here one bag is one hour (maybe in the future it will be one minute or one 5-minute). The items are the devices. The concept of value is changed by the probability of the device. The concept of value is changed by the probability of the device. So we want to choose a subset of the devices of maximum total probability that will fit in the production PV for that given hour.
Now the problem is that we have multiple "bags" in a day (we have 24 hours in a day), and the items sometimes need to be in multiple bags (for example I want to charge a specific device in the morning and in the afternoon). Furthermore, the items have different values in each bag (the probability to charge a specific device in the morning is maybe different than in the afternoon), but their size remains unchanged (the device needs the same charge in the morning and in the afternoon).
So my idea is to be greedy. So during a given day, we compute all the solutions for each bag (each hour) of the Knapsack problem (dynamic programming), we take then the bag (the hour) with the highest probability. Then we update all the probabilities given the fact that a device needs to be sometimes in multiple bags. We put this bag into a blacklist. Then we restart this process by computing all the solutions for each bag that are not in the blacklist. We continue until all the bags are in the blacklist.