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

Implement start penalty functionality #291

Merged
merged 4 commits into from
Jun 1, 2024

Conversation

werdnum
Copy link
Contributor

@werdnum werdnum commented May 23, 2024

How to use:

  • Set def_start_penalty to a list of floats. For each deferrable load with a penalty P, each time the deferrable load turns on will incur an additional cost of P • P_deferrable_nomcost of electricity at that time. Intuitively, how many extra hours would the load have to run to avoid starting up again.
  • Pass def_current_state in runtime_params to avoid incorrectly penalizing a start if a forecast is run when the load is already running.

I also made a couple of other supporting changes:

  • Added unit tests for the relevant scenarios in test_optimization.py, plus one for the set_def_constant function. In doing so, I found a missing constraint for set_def_constant and added it to the optimizer (P_def_bin2 was not constrained to be zero when P_deferrable was zero).
  • Added comments for all the start-related constraints to help myself understand it.

werdnum added 3 commits May 23, 2024 01:34
…f usage that each start should be equivalent to.
- Add (guessed) explanations for the start constraints.
- Move the start variable constraints that define it out of the set_def_constant if statement.
- FIx the penalty, original was invalid LLM slop.
…"free" if the load is already running - leads to oscillation.
@werdnum
Copy link
Contributor Author

werdnum commented May 23, 2024

Solves #261

…nd, including that the constant functionality has not been working properly.
@davidusb-geek
Copy link
Owner

Hi @werdnum, is this ready to merge?
Probably some documentation needed somewhere.
From what I see this is only usable from the runtime parameters dictionary, but not from the configuration file?

@werdnum
Copy link
Contributor Author

werdnum commented May 28, 2024 via email

@davidusb-geek
Copy link
Owner

Ok, I'm merging. But from what I see this will only works when passing def_start_penalty and def_current_state at runtime. For def_current_state it makes completely sense, but for def_start_penalty this could be set directly in the configuration file.
A small entry on the documentation would be needed don't you think.
I will merge and then try to update the documentation later on another PR

@davidusb-geek davidusb-geek merged commit 40023e1 into davidusb-geek:master Jun 1, 2024
13 checks passed
@davidusb-geek
Copy link
Owner

Hi, this was merged but not correctly reviewed I guess.
I was trying to update the documentation an stumbled on this.
There are some important things that I don't fully understand:

Let's start with this code for def_start_penalty:

        # Add term penalizing each startup where configured
        if ("def_start_penalty" in self.optim_conf and self.optim_conf["def_start_penalty"]):
            for k in range(self.optim_conf["num_def_loads"]):
                if (len(self.optim_conf["def_start_penalty"]) > k and self.optim_conf["def_start_penalty"][k]):
                    objective = objective + plp.lpSum(
                        -0.001 * self.timeStep * self.optim_conf["def_start_penalty"][k] * P_def_start[k][i] *\
                            unit_load_cost[i] * self.optim_conf['P_deferrable_nom'][k]
                        for i in set_I)

This self.optim_conf["def_start_penalty"] is supposed to be a list of floats.
But it seems to me that you are treating this a list of bool.
For example here if ("def_start_penalty" in self.optim_conf and self.optim_conf["def_start_penalty"]).
Another term I don't understand is len(self.optim_conf["def_start_penalty"]) > k. If that parameter is a list of floats with a single float for each deferrable then when is this condition supposed to True? And again this is treating self.optim_conf["def_start_penalty"][k] as if it were a bool.

Same comment for the def_current_state parameter.
This condition can never hold if that parameter is a list of bool with a single bool for each deferrable load: if ("def_current_state" in self.optim_conf and len(self.optim_conf["def_current_state"]) > k):
I'm a bit lost here.

@werdnum
Copy link
Contributor Author

werdnum commented Jun 10, 2024 via email

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

Successfully merging this pull request may close these issues.

2 participants