diff --git a/server/app/parameters.json b/server/app/parameters.json index e50d484..b5b4a0e 100644 --- a/server/app/parameters.json +++ b/server/app/parameters.json @@ -2,5 +2,6 @@ "p":0.1, "ttl":25, "w_exploit":0.5, - "t_exploration":50 + "t_exploration":50, + "beta":1.0 } diff --git a/server/app/swarm_agent.py b/server/app/swarm_agent.py index b6ab777..bebe3e3 100644 --- a/server/app/swarm_agent.py +++ b/server/app/swarm_agent.py @@ -91,12 +91,8 @@ def local_query(self): base_url = "http://127.0.0.1:8001/api/v0/graph" full_url = f"{base_url}?{encoded_query}" - print(full_url) - response = requests.get(full_url) - print(response) - return response def get_neighbor_pheromones(self): @@ -112,12 +108,32 @@ def get_neighbor_pheromones(self): "neighbors" ]: neighbors_dict[neighbor["neighbor_id"]] = neighbor["pheromone_value"] - print(neighbor["neighbor_id"], neighbor["pheromone_value"]) self.pheromone_table[keyword] = neighbors_dict + + def getGoodnessValues( + self, keyword + ): + + goodness_values = [] + + for neighbor in self.pheromone_table[keyword]: + + goodness_values.append( + self.pheromone_table[keyword][ + neighbor + ] + * self.parameters["beta"] + ) + + return goodness_values + + def step(self): response = self.local_query() self.get_neighbor_pheromones() - print("pheromone_table", self.pheromone_table) - print("self.keyword:", self.keyword) + print("pheromone_table[{keyword}]".format(keyword=self.keyword), self.pheromone_table[self.keyword]) + goodness_values=self.getGoodnessValues(self.keyword) + print(goodness_values) + return response