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

Refactored class_optimize.py #88

Merged
merged 3 commits into from
Oct 5, 2024
Merged

Conversation

NormannK
Copy link
Collaborator

@NormannK NormannK commented Oct 4, 2024

  • Optimized Imports: Removed unused imports and organized them.
  • Refactored Code: Introduced split_individual function for clarity.
  • Improved Efficiency: Enhanced penalty calculation and streamlined loops.
  • Updated Evaluation Logic: Better handling of penalties in evaluate.
  • Type Hints added.

Notes:

  • Fixed seed option added for automated tests
  • Verbose option added, default False
  • isfloat is only used in flask_server.py
  • start_hour is not used in this class
  • identical results with the old version using test.py and fixed seeds

- Optimized Imports: Removed unused imports and organized them.
- Refactored Code: Introduced split_individual function for clarity.
- Improved Efficiency: Enhanced penalty calculation and streamlined loops.
- Updated Evaluation Logic: Better handling of penalties in evaluate.
- Type Hints added
- fixed seed option added for automated tests
- verbose comment added, default False

Notes:
- isfloat is only used in flask_server.py
- start_hour is not used in this class
This was referenced Oct 4, 2024
@NormannK
Copy link
Collaborator Author

NormannK commented Oct 4, 2024

statistically proof that the new class is as good as (the same) as the old one.
image
see #93 for results from the original class

start_hour,
self.prediction_hours,
einspeiseverguetung_euro_pro_wh,
extra_data=extra_data,
)

os.system("cp visualisierungsergebnisse.pdf ~/")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result PDF path file should be configurable, maybe a method parameter or config parameter.

creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
creator.create("Individual", list, fitness=creator.FitnessMin)

# PARAMETER
# Initialize toolbox with attributes and operations
self.toolbox = base.Toolbox()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialization should be move to __init__. Toolbox is used in other places as well.

verbose: bool = False,
fixed_seed: Optional[int] = None,
):
"""Initialize the optimization problem with the required parameters."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring can be more helpful to describe each parameter. I'm using Google Style docstrings, maybe we can discuss on using in this project.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets discuss this in the discussion section.

@drbacke drbacke merged commit 909a0fe into Akkudoktor-EOS:main Oct 5, 2024
2 checks passed
@NormannK NormannK deleted the patch-4 branch October 5, 2024 07:46
danimo pushed a commit that referenced this pull request Oct 5, 2024
Test meant for class_optimize.
Will only work with PR #88 since the old class has no way to use a fixed random seed.
drbacke pushed a commit that referenced this pull request Oct 6, 2024
Test meant for class_optimize.
Will only work with PR #88 since the old class has no way to use a fixed random seed.
Lasall pushed a commit that referenced this pull request Jan 1, 2025
Test meant for class_optimize.
Will only work with PR #88 since the old class has no way to use a fixed random seed.
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.

3 participants