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

style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf #166

Merged
merged 1 commit into from
May 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions self_correction/self_corrector.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import random


class SelfCorrector:
def __init__(self, feedback_loop, transaction_parameters):
self.feedback_loop = feedback_loop
Expand All @@ -10,16 +11,25 @@ def adjust_parameters(self, user_feedback=None, system_performance=None):
Adjusts the transaction parameters based on user feedback or system performance.
"""
if user_feedback is not None:
if user_feedback == 'increase':
self.feedback_loop.add_correction(IncreaseParameterCorrection(self.transaction_parameters))
elif user_feedback == 'decrease':
self.feedback_loop.add_correction(DecreaseParameterCorrection(self.transaction_parameters))
if user_feedback == "increase":
self.feedback_loop.add_correction(
IncreaseParameterCorrection(self.transaction_parameters)
)
elif user_feedback == "decrease":
self.feedback_loop.add_correction(
DecreaseParameterCorrection(self.transaction_parameters)
)

if system_performance is not None:
if system_performance < 0.9:
self.feedback_loop.add_correction(IncreaseParameterCorrection(self.transaction_parameters))
self.feedback_loop.add_correction(
IncreaseParameterCorrection(self.transaction_parameters)
)
elif system_performance > 0.95:
self.feedback_loop.add_correction(DecreaseParameterCorrection(self.transaction_parameters))
self.feedback_loop.add_correction(
DecreaseParameterCorrection(self.transaction_parameters)
)


class IncreaseParameterCorrection:
def __init__(self, transaction_parameters):
Expand All @@ -33,6 +43,7 @@ def apply(self, transaction_parameters):
transaction_parameters[parameter_name] += random.uniform(0.1, 0.5)
return transaction_parameters


class DecreaseParameterCorrection:
def __init__(self, transaction_parameters):
self.transaction_parameters = transaction_parameters
Expand Down
Loading