Skip to content

Commit

Permalink
simple version of getGoodnessValues added
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Chepizhko committed Aug 21, 2024
1 parent 15c2d21 commit b8a9f64
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
3 changes: 2 additions & 1 deletion server/app/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"p":0.1,
"ttl":25,
"w_exploit":0.5,
"t_exploration":50
"t_exploration":50,
"beta":1.0
}
30 changes: 23 additions & 7 deletions server/app/swarm_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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

0 comments on commit b8a9f64

Please sign in to comment.