73 Commits

Author SHA1 Message Date
4b3da07b29 Added the ability to output the satisfaction image with GRID_FILE display method. 2023-10-15 13:15:58 +01:00
d5c3c81cf0 Added JSON_OUTPUT execution method.
Added script to parse output of `JSON_OUTPUT` execution method.
2023-10-13 06:00:43 +01:00
31089de57c Moved body of if __name__ == "__main__" to a function. 2023-10-13 05:12:29 +01:00
15a089f6a4 Fixed GAgent not inheriting Agent. 2023-10-13 05:11:08 +01:00
cdc578ded0 Moved all parameter definitions outside of main. 2023-10-12 15:00:28 +01:00
a63085b58f Separated agents into an abstract class with implementations.
Added `GAgent`, an agent that has lies between a gradient.
2023-10-12 14:50:40 +01:00
aebf851576 Added average satisfaction calculation output to json. 2023-10-12 14:46:35 +01:00
adcabbdcca Fixed time calculation being possibly slightly off. 2023-10-07 10:03:43 +01:00
61feed5910 Added DisplayMethod.GRID_FILE to output the graph as a grid to an image file. 2023-10-07 09:49:56 +01:00
a0ed42bc39 Fixed Agent.color not returning a tuple. 2023-10-07 09:48:04 +01:00
73b61e9b4d Added benchmark mode. 2023-10-07 09:34:43 +01:00
5771ebcbdd Cached agents and agent weights in fill_with_agents. 2023-10-07 08:37:39 +01:00
cc8d03a428 Created main function to wrap over if __name__ == "__main__" condition. 2023-10-07 08:32:47 +01:00
4e491245ef Agents are now stored in a separate dictionary.
This speeds up everything considerably, due to the double-indirection of `graph -> node -> agent`.
2023-10-06 15:07:15 +01:00
9a496d0c5b Added logging of graph creation. 2023-10-04 15:56:14 +01:00
2ebd981bcd Debug flags no longer require __debug__.
This ensures we can turn on some of the cheaper debug flags while testing large datasets.
2023-10-04 15:50:59 +01:00
fe6e3cb923 Equilibrium checking is now behind a debug flag. 2023-10-04 15:50:07 +01:00
881e21fdd9 Improved performance of Graph.fill_with_agents. 2023-10-04 15:45:34 +01:00
9e849a5138 Improved performance in Graph.{agent_satisfaction, remove_agent}. 2023-10-04 15:25:20 +01:00
8f05d66d77 Added Grid.update_unsatisfied_nodes_cache_multiple.
This is a more efficient form of calling `update_unsatisfied_nodes_cache` in a loop.
2023-10-04 15:18:46 +01:00
cf7cee5f3b Replaced nx.neighbors with nx.Graph.adj. 2023-10-04 14:40:25 +01:00
a29a89b8af Added Graph.move_agents to efficiently move several nodes at once. 2023-10-04 14:36:35 +01:00
db84512225 Moved random generation to local variable instead of using global.
This avoid anyone using numpy's global random state behind our back and changing the results.
2023-10-04 11:28:33 +01:00
c724edf88d Removed default arguments from caches.
This ensures we don't accidentally leave them uninitialized.
2023-10-04 11:07:00 +01:00
0e34ff2daf Upgraded sanity check to optionally check for all caches. 2023-10-04 11:05:12 +01:00
80b0c6740d Added display method NONE.
This is particularly useful for benchmarking.
2023-10-04 09:35:36 +01:00
1bdf6a3867 update_unsatisfied_nodes_cache now removes satisfied agents from the unsatisfied agents cache.
Note: The variable threshold was removed, as this now caused it to take much longer with the current used seed.
2023-10-04 09:26:35 +01:00
acb29c9cbf Improved messages on some asserts. 2023-10-04 08:49:12 +01:00
33e234374b Fixed usage of set.remove instead of set.discard. 2023-10-04 08:29:22 +01:00
e2c9910364 Fixed an assert message being removed. 2023-10-04 08:22:55 +01:00
23d05f5fba Fixed mis-naming of variable. 2023-10-03 07:26:11 +01:00
426b40907b Time per unsatisfied agent is now printed. 2023-10-02 20:53:35 +01:00
e6136300fa Each agent may now calculate their satisfaction separately. 2023-10-02 20:39:38 +01:00
8607b89b1a Sorted and removes unused imports. 2023-10-02 06:16:23 +01:00
867f09a528 Moved cur_round and logging outside Graph. 2023-10-02 06:15:54 +01:00
6b844b36c6 Each agent may now have a separate satisfaction threshold 2023-10-02 06:13:04 +01:00
9f9810faac Fixed asserts having the wrong syntax.
Added assert on equilibrium to check that all agents are satisfied.
2023-10-02 05:59:59 +01:00
b3665ce2da Agent weights are now normalized before passing to numpy.random.choice. 2023-10-02 05:29:13 +01:00
b8d0207a87 Fixed final round not printing how long it took. 2023-10-02 05:12:33 +01:00
8ba26b5a99 Added type alias for node position. 2023-10-02 05:10:25 +01:00
306c26c8e1 Fixed graph not being drawn when reaching equilibrium 2023-10-02 03:41:45 +01:00
188da6700f Fixed rounds being executed in multiples of rounds_per_display even when reaching equilibrium earlier. 2023-10-02 03:32:22 +01:00
a73d9f8428 Fixed formatting of time not correcting displaying micro and nano seconds. 2023-10-02 03:31:47 +01:00
fdc5eb1e75 Added ability to perform multiple rounds per display.
This is to combat the current inefficiencies of drawing.
2023-10-02 02:57:47 +01:00
7a7aeda1a7 Replaced reservoir sampling with shuffling.
Unfortunately, the reservoir sampling implementation was bugged, and correcting it would make the algorithm `O(max(n, k))`.
This is due to not being able to advance the set iterator efficiently by a delta, which makes it so we need to call `next(it)` in a loop.

As for shuffling, we can't make it more efficient by only shuffling `k` elements, as there's no built-in function for that, and slicing the list in any way will affect the results.
2023-10-02 02:56:26 +01:00
fa5971d8ad Fixed figures not being cleared.
This resulted in the figure getting laggier as time went on.
2023-10-02 02:41:35 +01:00
3e24da6f8a Fixed formatting of time using scientific notation sometimes 2023-10-02 02:36:55 +01:00
38c092136c Introduced caching of unsatisfied nodes.
Added some logging to `do_round`.
2023-10-02 02:34:13 +01:00
380e754b1c Introduced caching of empty nodes. 2023-10-02 01:45:50 +01:00
fe851f37c1 Improved initial agent randomization.
Improved empty node finding during round.
2023-10-02 00:12:28 +01:00