Skip to content

Commit

Permalink
Merge pull request #166 from KOSASIH/deepsource-transform-372d25cd
Browse files Browse the repository at this point in the history
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
  • Loading branch information
KOSASIH authored May 12, 2024
2 parents a2c15fb + eaa46e0 commit 15cd974
Showing 1 changed file with 17 additions and 6 deletions.
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

0 comments on commit 15cd974

Please sign in to comment.