From 2637c7b2327edef8217712c6c101c10b932a521b Mon Sep 17 00:00:00 2001 From: yokkon <0506422606e@gmail.com> Date: Tue, 31 May 2022 23:17:44 +0300 Subject: [PATCH 1/4] fixed conflicts --- agents/super_agent/super_agent.py | 35 ++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/agents/super_agent/super_agent.py b/agents/super_agent/super_agent.py index 754f456..0dff2ce 100644 --- a/agents/super_agent/super_agent.py +++ b/agents/super_agent/super_agent.py @@ -61,6 +61,8 @@ def __init__(self): self._me = None self._profile_interface: ProfileInterface = None self._progress = None + self._util_threshold_calculator = None + self.pick_acceptence_pattern(random.randint(0,2)) self._protocol = None self._parameters: Parameters = None self._utility_space = None @@ -334,15 +336,38 @@ def is_good(self, bid): avg_max_utility = self._persistent_data.get_avg_max_utility(self._opponent_name) \ if self._persistent_data._known_opponent(self._opponent_name) \ else self._avg_utility - self._util_threshold = max_value - ( - max_value - 0.55 * self._avg_utility - 0.4 * avg_max_utility + 0.5 * pow(self._std_utility, 2)) * \ - (math.exp(self.alpha * self._progress.get(get_ms_current_time())) - 1) / (math.exp( - self.alpha) - 1) + + self._util_threshold = self._util_threshold_calculator(max_value, avg_max_utility) + if self._util_threshold < self._min_utility: self._util_threshold = self._min_utility - return float(self.calc_utility(bid)) >= self._util_threshold + def pick_acceptence_pattern(self, pattern): + if pattern == 0: + self._util_threshold_calculator = lambda max_value, avg_max_utility : max_value - ( + max_value - 0.55 * self._avg_utility - 0.4 * avg_max_utility + 0.5 * pow(self._std_utility, 2)) * \ + (math.exp(self.alpha * self._progress.get(get_ms_current_time())) - 1) / (math.exp( + self.alpha) - 1) + elif pattern == 1: + self._util_threshold_calculator = lambda max_value, avg_max_utility: max_value - ( + max_value - 0.55 * self._avg_utility - 0.4 * avg_max_utility + 0.5 * pow(self._std_utility, 2)) * \ + (math.exp( + self.alpha * self._progress.get( + get_ms_current_time())) - 1) / ( + math.exp( + self.alpha) - 1) - (math.sin(5*(self._progress.get(get_ms_current_time())))/20) + elif pattern == 2: + self._util_threshold_calculator = lambda max_value, avg_max_utility: max_value - ( + max_value - 0.55 * self._avg_utility - 0.4 * avg_max_utility + 0.5 * pow(self._std_utility, 2)) * \ + (math.exp( + self.alpha * self._progress.get( + get_ms_current_time())) - 1) / ( + math.exp( + self.alpha) - 1) if self._progress.get(get_ms_current_time()) < 0.7 else max_value - ( + max_value - 0.55 * self._avg_utility - 0.4 * avg_max_utility + 0.5 * pow(self._std_utility, 2)) * \ + (math.exp(3 * self._progress.get(get_ms_current_time())) - 1) / (math.exp(3) - 1) + def on_negotiation_near_end(self): bid: Bid = None for attempt in range(1000): From 976a58eed0a9ebe709ab1cce90ebc0fe292447ca Mon Sep 17 00:00:00 2001 From: yokkon <0506422606e@gmail.com> Date: Tue, 31 May 2022 23:23:59 +0300 Subject: [PATCH 2/4] Added pattern description log --- agents/super_agent/super_agent.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/agents/super_agent/super_agent.py b/agents/super_agent/super_agent.py index 0dff2ce..2f2056c 100644 --- a/agents/super_agent/super_agent.py +++ b/agents/super_agent/super_agent.py @@ -344,6 +344,8 @@ def is_good(self, bid): return float(self.calc_utility(bid)) >= self._util_threshold def pick_acceptence_pattern(self, pattern): + patterns_desc = {0 : 'Noraml Decay', 1: 'Decaying with sinus', 2:'Decaying with step (alpha changing)'} + self.getReporter().log(logging.INFO, f"Acceptence pattern selected {patterns_desc[pattern]}") if pattern == 0: self._util_threshold_calculator = lambda max_value, avg_max_utility : max_value - ( max_value - 0.55 * self._avg_utility - 0.4 * avg_max_utility + 0.5 * pow(self._std_utility, 2)) * \ From 747015350b1323466feedeaf3d89f90a01c8cf10 Mon Sep 17 00:00:00 2001 From: Ben Nageris Date: Tue, 31 May 2022 23:28:05 +0300 Subject: [PATCH 3/4] added multiagents in run tournament and format super_agent --- agents/super_agent/super_agent.py | 42 ++++++++++++++++----------- run_tournament.py | 47 ++++++++++++++++--------------- 2 files changed, 50 insertions(+), 39 deletions(-) diff --git a/agents/super_agent/super_agent.py b/agents/super_agent/super_agent.py index 2f2056c..17ac7c6 100644 --- a/agents/super_agent/super_agent.py +++ b/agents/super_agent/super_agent.py @@ -62,7 +62,7 @@ def __init__(self): self._profile_interface: ProfileInterface = None self._progress = None self._util_threshold_calculator = None - self.pick_acceptence_pattern(random.randint(0,2)) + self.pick_acceptence_pattern(random.randint(0, 2)) self._protocol = None self._parameters: Parameters = None self._utility_space = None @@ -344,31 +344,39 @@ def is_good(self, bid): return float(self.calc_utility(bid)) >= self._util_threshold def pick_acceptence_pattern(self, pattern): - patterns_desc = {0 : 'Noraml Decay', 1: 'Decaying with sinus', 2:'Decaying with step (alpha changing)'} + patterns_desc = {0: 'Noraml Decay', 1: 'Decaying with sinus', 2: 'Decaying with step (alpha changing)'} self.getReporter().log(logging.INFO, f"Acceptence pattern selected {patterns_desc[pattern]}") if pattern == 0: - self._util_threshold_calculator = lambda max_value, avg_max_utility : max_value - ( - max_value - 0.55 * self._avg_utility - 0.4 * avg_max_utility + 0.5 * pow(self._std_utility, 2)) * \ - (math.exp(self.alpha * self._progress.get(get_ms_current_time())) - 1) / (math.exp( - self.alpha) - 1) + self._util_threshold_calculator = lambda max_value, avg_max_utility: max_value - ( + max_value - 0.55 * self._avg_utility - 0.4 * avg_max_utility + 0.5 * pow(self._std_utility, 2)) * \ + (math.exp( + self.alpha * self._progress.get( + get_ms_current_time())) - 1) / ( + math.exp( + self.alpha) - 1) elif pattern == 1: self._util_threshold_calculator = lambda max_value, avg_max_utility: max_value - ( max_value - 0.55 * self._avg_utility - 0.4 * avg_max_utility + 0.5 * pow(self._std_utility, 2)) * \ - (math.exp( - self.alpha * self._progress.get( - get_ms_current_time())) - 1) / ( - math.exp( - self.alpha) - 1) - (math.sin(5*(self._progress.get(get_ms_current_time())))/20) + (math.exp( + self.alpha * self._progress.get( + get_ms_current_time())) - 1) / ( + math.exp( + self.alpha) - 1) - ( + math.sin(5 * ( + self._progress.get( + get_ms_current_time()))) / 20) elif pattern == 2: self._util_threshold_calculator = lambda max_value, avg_max_utility: max_value - ( max_value - 0.55 * self._avg_utility - 0.4 * avg_max_utility + 0.5 * pow(self._std_utility, 2)) * \ - (math.exp( - self.alpha * self._progress.get( - get_ms_current_time())) - 1) / ( - math.exp( - self.alpha) - 1) if self._progress.get(get_ms_current_time()) < 0.7 else max_value - ( + (math.exp( + self.alpha * self._progress.get( + get_ms_current_time())) - 1) / ( + math.exp( + self.alpha) - 1) if self._progress.get( + get_ms_current_time()) < 0.7 else max_value - ( max_value - 0.55 * self._avg_utility - 0.4 * avg_max_utility + 0.5 * pow(self._std_utility, 2)) * \ - (math.exp(3 * self._progress.get(get_ms_current_time())) - 1) / (math.exp(3) - 1) + (math.exp(3 * self._progress.get(get_ms_current_time())) - 1) / ( + math.exp(3) - 1) def on_negotiation_near_end(self): bid: Bid = None diff --git a/run_tournament.py b/run_tournament.py index eade575..d8b6917 100644 --- a/run_tournament.py +++ b/run_tournament.py @@ -17,29 +17,32 @@ # You need to specify a time deadline (is milliseconds (ms)) we are allowed to negotiate before we end without agreement. tournament_settings = { "agents": [ + {"class": "agents.CSE3210.agent11.agent11.Agent11"}, + {"class": "agents.CSE3210.agent14.agent14.Agent14"}, + {"class": "agents.CSE3210.agent18.agent18.Agent18"}, + {"class": "agents.CSE3210.agent19.agent19.Agent19"}, + {"class": "agents.CSE3210.agent2.agent2.Agent2"}, + {"class": "agents.CSE3210.agent22.agent22.Agent22"}, + {"class": "agents.CSE3210.agent24.agent24.Agent24"}, + {"class": "agents.CSE3210.agent25.agent25.Agent25"}, + {"class": "agents.CSE3210.agent26.agent26.Agent26"}, + {"class": "agents.CSE3210.agent27.agent27.Agent27"}, + {"class": "agents.CSE3210.agent29.agent29.Agent29"}, + {"class": "agents.CSE3210.agent3.agent3.Agent3"}, + {"class": "agents.CSE3210.agent32.agent32.Agent32"}, + {"class": "agents.CSE3210.agent33.agent33.Agent33"}, + {"class": "agents.CSE3210.agent41.agent41.Agent41"}, + {"class": "agents.CSE3210.agent43.agent43.Agent43"}, + {"class": "agents.CSE3210.agent50.agent50.Agent50"}, + {"class": "agents.CSE3210.agent52.agent52.Agent52"}, + {"class": "agents.CSE3210.agent55.agent55.Agent55"}, + {"class": "agents.CSE3210.agent58.agent58.Agent58"}, + {"class": "agents.CSE3210.agent61.agent61.Agent61"}, + {"class": "agents.CSE3210.agent64.agent64.Agent64"}, + {"class": "agents.CSE3210.agent67.agent67.Agent67"}, + {"class": "agents.CSE3210.agent68.agent68.Agent68"}, + {"class": "agents.CSE3210.agent7.agent7.Agent7"}, { - "class": "agents.boulware_agent.boulware_agent.BoulwareAgent", - }, - { - "class": "agents.conceder_agent.conceder_agent.ConcederAgent", - }, - { - "class": "agents.hardliner_agent.hardliner_agent.HardlinerAgent", - }, - { - "class": "agents.linear_agent.linear_agent.LinearAgent", - }, - { - "class": "agents.random_agent.random_agent.RandomAgent", - }, - { - "class": "agents.stupid_agent.stupid_agent.StupidAgent", - }, - { - "class": "agents.template_agent.template_agent.TemplateAgent", - "parameters": {"storage_dir": "agent_storage/TemplateAgent"}, - }, -{ "class": "agents.super_agent.super_agent.SuperAgent", "parameters": {"storage_dir": "agent_storage/SuperAgent"}, } From 832abed87da6b1dc8f694410be28eb8febfda5a5 Mon Sep 17 00:00:00 2001 From: yokkon <0506422606e@gmail.com> Date: Sun, 5 Jun 2022 21:39:09 +0300 Subject: [PATCH 4/4] Finished 5 different threshold patterns --- agents/super_agent/super_agent.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/agents/super_agent/super_agent.py b/agents/super_agent/super_agent.py index 17ac7c6..22feda7 100644 --- a/agents/super_agent/super_agent.py +++ b/agents/super_agent/super_agent.py @@ -62,7 +62,7 @@ def __init__(self): self._profile_interface: ProfileInterface = None self._progress = None self._util_threshold_calculator = None - self.pick_acceptence_pattern(random.randint(0, 2)) + self.pick_acceptence_pattern(random.randint(0, 4)) self._protocol = None self._parameters: Parameters = None self._utility_space = None @@ -344,7 +344,7 @@ def is_good(self, bid): return float(self.calc_utility(bid)) >= self._util_threshold def pick_acceptence_pattern(self, pattern): - patterns_desc = {0: 'Noraml Decay', 1: 'Decaying with sinus', 2: 'Decaying with step (alpha changing)'} + patterns_desc = {0: 'Noraml Decay', 1: 'Decaying with sinus', 2: 'Decaying with step (alpha changing)', 3:'Decaying with cosinus', 4:'Linear decay'} self.getReporter().log(logging.INFO, f"Acceptence pattern selected {patterns_desc[pattern]}") if pattern == 0: self._util_threshold_calculator = lambda max_value, avg_max_utility: max_value - ( @@ -378,6 +378,22 @@ def pick_acceptence_pattern(self, pattern): (math.exp(3 * self._progress.get(get_ms_current_time())) - 1) / ( math.exp(3) - 1) + elif pattern == 3: + self._util_threshold_calculator = lambda max_value, avg_max_utility: max_value - ( + max_value - 0.55 * self._avg_utility - 0.4 * avg_max_utility + 0.5 * pow(self._std_utility, 2)) * \ + (math.exp( + self.alpha * self._progress.get( + get_ms_current_time())) - 1) / ( + math.exp( + self.alpha) - 1) - ( + math.cos(5 * ( + self._progress.get( + get_ms_current_time()))) / 20) + elif pattern == 4: + self._util_threshold_calculator = lambda max_value, avg_max_utility: max_value - ( + max_value - 0.55 * self._avg_utility - 0.4 * avg_max_utility + 0.5 * pow(self._std_utility, 2)) * (self._progress.get( + get_ms_current_time())/2) + def on_negotiation_near_end(self): bid: Bid = None for attempt in range(1000):