Skip to content

Internalize variables -> self.variables & add revenue functions within a class #2

Open
minhokg wants to merge 2 commits intoFlexPwr:mainfrom
minhokg:main
Open

Internalize variables -> self.variables & add revenue functions within a class #2
minhokg wants to merge 2 commits intoFlexPwr:mainfrom
minhokg:main

Conversation

@minhokg
Copy link
Contributor

@minhokg minhokg commented Mar 21, 2024

This pull request addresses the two issues about optimizer.py and suggests improvements.

  1. Internalize variables in each function into a class
    For example, in the step1_optimize_daa function, I modified step1_cha_daa to self.step1_cha_daa. By doing so, the step2_optimize_ida function no longer needs the step1 function's return value.
    That is, step2 function requires fewer arguments than previous: From step2_optimize_ida(self, ..., ida_price_vector: list, step1_cha_daa: list, step1_dis_daa: list) to step2_optimize_ida(self,..., ida_price_vector: list). The same logic is applied to the step3 functions (i.e. it no longer needs step2 return values).
  2. Add revenue functions within a class
    Previously, revenue values( DAA, IDA, IDC) were calculated outside the optimizer class. So, I added the revenue functions inside the class for convenience.
    For example,
    def revenue_daa(self) -> float:
        # Calculate the revenue of DAA market

        return(np.sum(np.asarray(self.daa_price_vector) * (np.asarray(self.step1_dis_daa) - self.step1_cha_daa)) * 1/4)

So you can calculate the revenue just by calling the function

revenue_daa = optimizer_flex.revenue_daa()

Because all variables within the class are internalized, the revenue_daa function doesn't need any additional argument. You can see the example in the modified example.ipynb.

Thank you for reviewing this pull request. I'm eager to address any feedback and further improve the bess_optimizer.

@korawichni
Copy link

Dear minhokg,

Thanks for this contribution. It is really useful. One quick question is should the power_cap be taken into account as well in the revenue calculation because step1_dis_daa and step1_cha_daa are fractions of the bid energy?

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