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
c310a63fd4
Added ability to perform a round.
...
The graph is now auto-updated with each new round
2023-10-01 23:49:45 +01:00
8dcbbd48ec
Added utility for indexing into nodes.
2023-10-01 23:26:00 +01:00
fc9fe036cc
Replaced node_neighbors_pos with nx.neighbors.
2023-10-01 23:14:47 +01:00
827ac905c6
Created wrapper over the graph.
...
Fixed `node_neighbors_pos` using the width as height.
2023-10-01 23:13:27 +01:00
4e788aa1f2
Merged Race and Tile into Agent.
...
Tile was acting mostly as a node anyway.
This also decreases memory consumption (slightly) due to not storing the empty tiles, which allows for sparse graphs later.
Race was also referred to as "agent" in most relevant literature, so that was changed.
2023-10-01 23:02:35 +01:00
aaae524f2f
Each tile's satisfaction is now calculated.
...
Grid display now shows the satisfaction of each tile.
2023-10-01 22:19:41 +01:00
7ea5b00901
Initial tiles are now randomly chosen.
2023-09-30 23:30:47 +01:00
278c5adb34
Improving typing of some variables.
2023-09-30 23:28:18 +01:00
7df4f702bd
Sorted all imports using isort.
2023-09-30 23:13:36 +01:00
621a4276a8
Separated existing classes into their own files.
2023-09-30 23:10:46 +01:00
4291aa38b3
Added the missing diagonal edges to the graph.
...
Graph size is now a variable.
2023-09-30 23:04:44 +01:00
ed5352f621
Added ability to select between two display methods.
...
Currently supported are `GRAPH` (the "normal" method) and `GRID` (the method introduced in the last commit).
2023-09-30 23:01:03 +01:00
3af665ca29
Graph is now shown as a proper grid.
2023-09-30 22:54:14 +01:00
5d0ecce962
Fixed == None to is None.
2023-09-28 14:41:10 +01:00
e67b54356d
Removed match statement for < python.10.
2023-09-28 14:40:42 +01:00
556e7c6935
Changed empty race to gray.
...
Increases graph size.
Changed figure size
Only nodes are drawn node.
2023-09-28 14:38:43 +01:00
e2c682cb7b
Changed how node positions are calculated.
2023-09-28 14:17:58 +01:00
21d7330cf4
Improved tile initialization.
2023-09-28 14:16:28 +01:00
3d33af4047
Added data to each node.
2023-09-28 14:10:45 +01:00
e381fa930e
Improved graph visualization.
2023-09-28 13:38:39 +01:00