algorhino-anemone 0.1.9__py3-none-any.whl → 0.1.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {algorhino_anemone-0.1.9.dist-info → algorhino_anemone-0.1.11.dist-info}/METADATA +6 -6
- algorhino_anemone-0.1.11.dist-info/RECORD +82 -0
- {algorhino_anemone-0.1.9.dist-info → algorhino_anemone-0.1.11.dist-info}/WHEEL +1 -1
- anemone/__init__.py +1 -2
- anemone/factory.py +16 -30
- anemone/indices/__init__.py +1 -0
- anemone/indices/index_manager/__init__.py +2 -3
- anemone/indices/index_manager/factory.py +13 -8
- anemone/indices/index_manager/node_exploration_manager.py +60 -55
- anemone/indices/node_indices/__init__.py +2 -3
- anemone/indices/node_indices/factory.py +16 -14
- anemone/indices/node_indices/index_data.py +20 -24
- anemone/indices/node_indices/index_types.py +5 -7
- anemone/nn/torch_evaluator.py +18 -11
- anemone/node_evaluation/__init__.py +1 -0
- anemone/node_evaluation/node_direct_evaluation/__init__.py +2 -3
- anemone/node_evaluation/node_direct_evaluation/factory.py +1 -1
- anemone/node_evaluation/node_direct_evaluation/node_direct_evaluator.py +19 -42
- anemone/node_evaluation/node_tree_evaluation/node_minmax_evaluation.py +113 -115
- anemone/node_evaluation/node_tree_evaluation/node_tree_evaluation.py +11 -8
- anemone/node_evaluation/node_tree_evaluation/node_tree_evaluation_factory.py +5 -5
- anemone/node_factory/__init__.py +2 -3
- anemone/node_factory/algorithm_node_factory.py +4 -9
- anemone/node_factory/base.py +5 -12
- anemone/node_selector/__init__.py +5 -6
- anemone/node_selector/branch_explorer.py +18 -21
- anemone/node_selector/factory.py +16 -16
- anemone/node_selector/node_selector.py +6 -12
- anemone/node_selector/node_selector_args.py +2 -5
- anemone/node_selector/node_selector_types.py +4 -8
- anemone/node_selector/notations_and_statics.py +4 -10
- anemone/node_selector/opening_instructions.py +37 -57
- anemone/node_selector/recurzipf/__init__.py +1 -0
- anemone/node_selector/recurzipf/recur_zipf_base.py +14 -42
- anemone/node_selector/sequool/__init__.py +2 -3
- anemone/node_selector/sequool/factory.py +3 -8
- anemone/node_selector/sequool/sequool.py +32 -50
- anemone/node_selector/uniform/__init__.py +1 -2
- anemone/node_selector/uniform/uniform.py +10 -18
- anemone/nodes/__init__.py +2 -3
- anemone/nodes/algorithm_node/__init__.py +1 -3
- anemone/nodes/algorithm_node/algorithm_node.py +35 -37
- anemone/nodes/itree_node.py +25 -31
- anemone/nodes/tree_node.py +30 -29
- anemone/nodes/tree_traversal.py +10 -11
- anemone/nodes/utils.py +14 -13
- anemone/progress_monitor/__init__.py +1 -0
- anemone/progress_monitor/progress_monitor.py +55 -75
- anemone/recommender_rule/__init__.py +1 -2
- anemone/recommender_rule/recommender_rule.py +7 -16
- anemone/search_factory/__init__.py +2 -3
- anemone/search_factory/search_factory.py +25 -28
- anemone/tree_and_value_branch_selector.py +26 -19
- anemone/tree_exploration.py +30 -41
- anemone/tree_manager/__init__.py +3 -4
- anemone/tree_manager/algorithm_node_tree_manager.py +15 -29
- anemone/tree_manager/factory.py +3 -5
- anemone/tree_manager/tree_expander.py +13 -15
- anemone/tree_manager/tree_manager.py +14 -25
- anemone/trees/__init__.py +3 -5
- anemone/trees/descendants.py +80 -115
- anemone/trees/factory.py +9 -13
- anemone/trees/tree.py +8 -11
- anemone/trees/tree_visualization.py +10 -10
- anemone/updates/__init__.py +4 -5
- anemone/updates/algorithm_node_updater.py +11 -13
- anemone/updates/factory.py +2 -4
- anemone/updates/index_block.py +13 -14
- anemone/updates/index_updater.py +7 -12
- anemone/updates/minmax_evaluation_updater.py +7 -12
- anemone/updates/updates_file.py +27 -26
- anemone/updates/value_block.py +10 -10
- anemone/utils/comparable.py +3 -4
- anemone/utils/dataclass.py +10 -13
- anemone/utils/dict_of_numbered_dict_with_pointer_on_max.py +16 -23
- anemone/utils/logger.py +13 -12
- anemone/utils/my_value_sorted_dict.py +4 -7
- anemone/utils/small_tools.py +16 -18
- algorhino_anemone-0.1.9.dist-info/RECORD +0 -82
- {algorhino_anemone-0.1.9.dist-info → algorhino_anemone-0.1.11.dist-info}/licenses/LICENSE +0 -0
- {algorhino_anemone-0.1.9.dist-info → algorhino_anemone-0.1.11.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: algorhino-anemone
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.11
|
|
4
4
|
Summary: anemone searches trees
|
|
5
5
|
Author-email: Victor Gabillon <victorgabillon@gmail.com>
|
|
6
6
|
License-Expression: GPL-3.0-only
|
|
@@ -12,18 +12,18 @@ Classifier: Operating System :: OS Independent
|
|
|
12
12
|
Requires-Python: >=3.13
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
|
-
Requires-Dist: valanga>=0.1.
|
|
16
|
-
Requires-Dist: atomheart>=0.1.
|
|
15
|
+
Requires-Dist: valanga>=0.1.14
|
|
16
|
+
Requires-Dist: atomheart>=0.1.7
|
|
17
17
|
Requires-Dist: rich
|
|
18
18
|
Requires-Dist: sortedcollections>=2.1.0
|
|
19
19
|
Requires-Dist: graphviz
|
|
20
20
|
Provides-Extra: test
|
|
21
|
-
Requires-Dist: pytest>=
|
|
21
|
+
Requires-Dist: pytest>=9.0.2; extra == "test"
|
|
22
22
|
Requires-Dist: coverage; extra == "test"
|
|
23
23
|
Requires-Dist: pytest-cov>=6.0.0; extra == "test"
|
|
24
24
|
Provides-Extra: lint
|
|
25
|
-
Requires-Dist: ruff>=0.
|
|
26
|
-
Requires-Dist: pylint>=
|
|
25
|
+
Requires-Dist: ruff>=0.15.0; extra == "lint"
|
|
26
|
+
Requires-Dist: pylint>=4.0.4; extra == "lint"
|
|
27
27
|
Provides-Extra: typecheck
|
|
28
28
|
Requires-Dist: mypy>=1.18.2; extra == "typecheck"
|
|
29
29
|
Requires-Dist: pyright[nodejs]>=1.1.408; extra == "typecheck"
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
algorhino_anemone-0.1.11.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
2
|
+
anemone/__init__.py,sha256=15XN-GemLe35vDc4CBT9DE0IVap1g1jP2IVI8X_2Tqo,928
|
|
3
|
+
anemone/basics.py,sha256=wKagPFuxXhDQbjTuM1Qjh37HcJt0m39NBMDg2dc2M6M,188
|
|
4
|
+
anemone/factory.py,sha256=IHtTjR2S92sqeRY2KBNagui3oDPCOEj5IDR3yF5DL0I,6075
|
|
5
|
+
anemone/state_transition.py,sha256=fxvHZOYRtWV5ExXRIoehdRg9qV6zhgiE5uiCeOc80Dc,1418
|
|
6
|
+
anemone/tree_and_value_branch_selector.py,sha256=-Jehxi328Q-rUvU7gZorRVWRDijyBlwrRbaFBvaNiOY,3655
|
|
7
|
+
anemone/tree_exploration.py,sha256=a-uOaPp41K2vCjl9yYQHmVKjZH8Lrpmtbsohpl80Ik0,10242
|
|
8
|
+
anemone/indices/__init__.py,sha256=s1_3fzDPi-L7VQcee0GCpuhza2Exljee-LVuxPu3ht0,65
|
|
9
|
+
anemone/indices/index_manager/__init__.py,sha256=JWYMhOT-XX3cZ36OEy-veZvA8Dbjm_TCwBeyUgEFMr8,501
|
|
10
|
+
anemone/indices/index_manager/factory.py,sha256=15t-olh8mGSP739j0ZYm2uqfWCb9zz1wilkfdC1Dtvg,2014
|
|
11
|
+
anemone/indices/index_manager/node_exploration_manager.py,sha256=WG72bKkKsZbCZ2PKMG8RU0BLb4tvIOF0amEelcb_wTA,23273
|
|
12
|
+
anemone/indices/node_indices/__init__.py,sha256=UcrRQDEs8HybHVkFbUZl9beS3N8EcuGYq7YzOLOxKwk,760
|
|
13
|
+
anemone/indices/node_indices/factory.py,sha256=suPUsjjK3o_fBrjLhab9ELXM8eeXQd5_feWgERTNYaM,4345
|
|
14
|
+
anemone/indices/node_indices/index_data.py,sha256=TH30Rs-meexyFjdIOyGBjgCLTPc1nF4WtbDzlDi-RUs,5345
|
|
15
|
+
anemone/indices/node_indices/index_types.py,sha256=9qwZxv7OBgytwcWGZ-1G6RYDBvQD5rOFxMuBd6vfJAg,551
|
|
16
|
+
anemone/nn/torch_evaluator.py,sha256=lALUV8rm4c80wFxiWHI_-00BMenqAaivqz29GbqPXHY,3611
|
|
17
|
+
anemone/node_evaluation/__init__.py,sha256=FIeCBTB3QsNsIJ22inDJNf3vVsIBdFUuqJJ0L8Q8d9Y,58
|
|
18
|
+
anemone/node_evaluation/node_direct_evaluation/__init__.py,sha256=FB_WFfdy0oTsz1sRF2Rd7-sXoI5Iu1Rdyolj0HF0Uis,884
|
|
19
|
+
anemone/node_evaluation/node_direct_evaluation/factory.py,sha256=z-AywVoud87mL_NLXY3DjbfPhTPBMZmuVdLLGlrQTjE,457
|
|
20
|
+
anemone/node_evaluation/node_direct_evaluation/node_direct_evaluator.py,sha256=HjWVFJy4UDA6VB-6tCkS3iWcFEzYTFa_363GIdwdNzA,5367
|
|
21
|
+
anemone/node_evaluation/node_tree_evaluation/node_minmax_evaluation.py,sha256=aLQFTR_3uqpAF3QxLHdl9U4X4993_-BFOSAWVRoWzOY,34615
|
|
22
|
+
anemone/node_evaluation/node_tree_evaluation/node_tree_evaluation.py,sha256=Ej8h5FNnarEHNbNA68wfu2abXWfRW2PLWDqMYaUN5mo,4282
|
|
23
|
+
anemone/node_evaluation/node_tree_evaluation/node_tree_evaluation_factory.py,sha256=3BEXa080hgb4bE4r-130_ANM4LGl4vzwPJbEhsbpzw0,1328
|
|
24
|
+
anemone/node_factory/__init__.py,sha256=4HMQ9MBID2odRrkR-t8BX89vTdmN2xybTL0mW5WnXUY,535
|
|
25
|
+
anemone/node_factory/algorithm_node_factory.py,sha256=XDaWaTY552uJ90ECC2lqyWreSc0cc04DLuvXIhd8dSI,4098
|
|
26
|
+
anemone/node_factory/base.py,sha256=jcj5Tagvgu6ZYllpvxxLhsApUROxEz3iMdaXbuasTfA,2106
|
|
27
|
+
anemone/node_selector/__init__.py,sha256=fi_BlhEuBh29CWhTpBuSPa9PLrfoPyiCVXGXIyEn8uo,1306
|
|
28
|
+
anemone/node_selector/branch_explorer.py,sha256=Oh0cOtys2s--nZsTDataR3IjZIN6SFs-Q0uu5eVrxxU,2556
|
|
29
|
+
anemone/node_selector/factory.py,sha256=WHSTqsaOf-P3LWo-b97fr_uBUxdkdzqzC25eR8Hi5Nw,2111
|
|
30
|
+
anemone/node_selector/node_selector.py,sha256=DJ1w6mRso-LKD8tRLESdlC4yYyf5T1-RcULfo2s4EBk,1096
|
|
31
|
+
anemone/node_selector/node_selector_args.py,sha256=m4fFMswcHaNQyHSiV0OaoF2gQUWe4_7V5dmO4_nTqQE,531
|
|
32
|
+
anemone/node_selector/node_selector_types.py,sha256=D7CSGcqWFQAyiQfTiunq2i6JxyiIbL_Y3Ru17ujP_CQ,305
|
|
33
|
+
anemone/node_selector/notations_and_statics.py,sha256=XuzHQJmqsuuZnR9pDq8uUO_kyeioqfbJKDyVodhadVY,2592
|
|
34
|
+
anemone/node_selector/opening_instructions.py,sha256=gtu1wO0s5FNu0vH9ZF7ItlZQujQLHy6ArJ1CyHGwTIg,7553
|
|
35
|
+
anemone/node_selector/recurzipf/__init__.py,sha256=nGrweb6xLrknVOO3DqQzSiGxSLso9uPcOR12PLEJRPk,56
|
|
36
|
+
anemone/node_selector/recurzipf/recur_zipf_base.py,sha256=8GNfiFdNZZrxNP7k2HlSyO_T2m1PhX953hVXoD9hiso,3795
|
|
37
|
+
anemone/node_selector/sequool/__init__.py,sha256=3A-yFgnQookFcDHPaSBaJsF97Ia0jsT_g9yY8OEm1Xw,471
|
|
38
|
+
anemone/node_selector/sequool/factory.py,sha256=wmNOf3uYJ0eerjFvx1jdyORtneCtzDuGW9oRHjD-KRo,3056
|
|
39
|
+
anemone/node_selector/sequool/sequool.py,sha256=z3FsoJYs1URpRMOFoZGDCaGRg9inHcj32ZcmFEjbL_E,11350
|
|
40
|
+
anemone/node_selector/uniform/__init__.py,sha256=Y28PZn5mvO7nm9aY9LRxPB-_UUmRnW-Yc8Yc97lBY7o,352
|
|
41
|
+
anemone/node_selector/uniform/uniform.py,sha256=Rdvt0tmWfK8FTxE4ql7xLT2vgIWPnq5iu_QPlzWa_XY,3630
|
|
42
|
+
anemone/nodes/__init__.py,sha256=QiMFfcRefUaP8OtRweuTqjSZ-43TPjIx-P790_v13RU,379
|
|
43
|
+
anemone/nodes/itree_node.py,sha256=akniqYyUdBk63h0zIBrrGHBJ_HDf3jfuA9_18AliQvw,3442
|
|
44
|
+
anemone/nodes/tree_node.py,sha256=O_C9dqWZ_8F-TGmXChtu5jnvmIFl213KyIKWqiGPIQw,7660
|
|
45
|
+
anemone/nodes/tree_traversal.py,sha256=pqtEKdG-NUwrHPu0OnvWTsoBxFDSxKlwBdFTum5jJS8,3926
|
|
46
|
+
anemone/nodes/utils.py,sha256=WHES9GaJuaF5gVP8knzG1iZGnOKEDKtDKwkv2KjItLo,4472
|
|
47
|
+
anemone/nodes/algorithm_node/__init__.py,sha256=AYJ2KAm9xXL42inS6lkypQPHt9sYtWdBPmK9ShgCYYE,115
|
|
48
|
+
anemone/nodes/algorithm_node/algorithm_node.py,sha256=HAqL9iL4Mo7J8N2cxX4ofsjdBRivWW_Ywi4lHB3Kq_A,6533
|
|
49
|
+
anemone/progress_monitor/__init__.py,sha256=zwsFet62FUlbonLTtDOye2VmLFEl8XWAJQJ6NdKu0pY,64
|
|
50
|
+
anemone/progress_monitor/progress_monitor.py,sha256=mFR24b4qtp8bV7ZWbCTb7U-6L4KQOcLKCgvMmfLeRWE,11105
|
|
51
|
+
anemone/recommender_rule/__init__.py,sha256=ia_KPE4CsDgt8qEtKMLHS3vOZcv6aaAqHAbchjBNHEM,333
|
|
52
|
+
anemone/recommender_rule/recommender_rule.py,sha256=pt3HUbH1V_pZC-sKo1Ged6vm_wvmVrea9s2YqipPv44,4374
|
|
53
|
+
anemone/search_factory/__init__.py,sha256=wjaaLMJUlQfn2y6a74AApX01RgmYo50xF63x7z0AWfY,605
|
|
54
|
+
anemone/search_factory/search_factory.py,sha256=jPdjQfhrwwT_EF3asACtAu_FLfCQ0NaX2ODGbuSHMzw,6512
|
|
55
|
+
anemone/tree_manager/__init__.py,sha256=1kRsT7_UQ_YI8NEvpZqV13RETEfgw9mrzjKZcl4w_hY,948
|
|
56
|
+
anemone/tree_manager/algorithm_node_tree_manager.py,sha256=GK6heOTHGNeGrVPq3EYaEOrMbN8FsTjmNay0BkpNJDM,8478
|
|
57
|
+
anemone/tree_manager/factory.py,sha256=76o9DoOpK_rin1caKsHPk7PkmNwvLChWvPYlHdJvb6o,2666
|
|
58
|
+
anemone/tree_manager/tree_expander.py,sha256=AzpwI4hVLNRpphirWX5fruSIiWL6bV-9yv-XPAzzdoY,4033
|
|
59
|
+
anemone/tree_manager/tree_manager.py,sha256=16zlg4OjiLMua0wGIPoFCD4RqVQkAthNE7GtxGnYkGg,7926
|
|
60
|
+
anemone/trees/__init__.py,sha256=3ujCsvrveUCBUWHtklD_jcUzVhYycBphZCaIcDJcXbE,268
|
|
61
|
+
anemone/trees/descendants.py,sha256=CNRjwuPW3UA-B9fDG3XRQigzgYgwUIrhzYxPtO4kGeQ,25889
|
|
62
|
+
anemone/trees/factory.py,sha256=ZXe22pLF0mq41eThFSVhOX6nOeBI2Cq9Y7bwPY9vAJM,2290
|
|
63
|
+
anemone/trees/tree.py,sha256=HqoPjB9HcIrWYV0iv8eoBn6d2OGIlJ6GfcjdxjgEhSQ,1964
|
|
64
|
+
anemone/trees/tree_visualization.py,sha256=IOBnwuykk4rKW0HyeyiohOs27mas7-P60_gnEGl9OBY,4634
|
|
65
|
+
anemone/updates/__init__.py,sha256=0PzroMHow_viONeaUeEH_Oc0KS-bwHp9PYvm4ekdido,1099
|
|
66
|
+
anemone/updates/algorithm_node_updater.py,sha256=96VcRxvMHRmuvZw8mdMz2QTcI4jnqGQmje_3I_mbSjE,5786
|
|
67
|
+
anemone/updates/factory.py,sha256=MoAtf2o9BuljpHr-HcE6Up5NdEfSed5IQO1hyMF7ssc,1187
|
|
68
|
+
anemone/updates/index_block.py,sha256=YvLQXsEHxe_sU2Am8LwxQSXbgjC598o7gCZ3MiId7KA,3003
|
|
69
|
+
anemone/updates/index_updater.py,sha256=KmE3RazrfWOH_rSQ1VbSbYDgUzwFaeTRSI6AfAkYdw4,3531
|
|
70
|
+
anemone/updates/minmax_evaluation_updater.py,sha256=dFqPhsXErk_R39Z2V6oGzE8oLiBsI2flq1dxU3XEIeI,3958
|
|
71
|
+
anemone/updates/updates_file.py,sha256=NGDf1l3At4ufeoQ_wpURIPEvx9oS1dndEqvWwydlAak,10011
|
|
72
|
+
anemone/updates/value_block.py,sha256=Z5J4BZzkUCMaqAfcA061bxO00iwGKMqH5UOYDNVG5zI,4598
|
|
73
|
+
anemone/utils/comparable.py,sha256=-A7uqdIHHfokivT-rWVOGueKBMGxetscUR2QkLzuop0,898
|
|
74
|
+
anemone/utils/dataclass.py,sha256=KtOViWQF33DfJkhIq0WX_TFNTfDjsMQZdEyX4pZrKw4,1758
|
|
75
|
+
anemone/utils/dict_of_numbered_dict_with_pointer_on_max.py,sha256=f-VcVP_UpzW8TayJydnXWHpw30UC04MLbjeEvEO-z9Y,3877
|
|
76
|
+
anemone/utils/logger.py,sha256=DqV0C8l9PxA6a72RG4HX0G_YaSjSlidwdnJLdyIvxGI,3009
|
|
77
|
+
anemone/utils/my_value_sorted_dict.py,sha256=DiL0Ds_TkE88jZB_NJ8fE98Ksaskf3qIyocc5TyoD3M,586
|
|
78
|
+
anemone/utils/small_tools.py,sha256=KtFzO9GYZch-pLdO83IFFXA-s3HpjU38lA832u3JTQU,2800
|
|
79
|
+
algorhino_anemone-0.1.11.dist-info/METADATA,sha256=DmG7BfcmgreqQ-5E5os6DztCaR_C5whOZIbFiLXG2F0,5693
|
|
80
|
+
algorhino_anemone-0.1.11.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
81
|
+
algorhino_anemone-0.1.11.dist-info/top_level.txt,sha256=G1vbB-vAevQVde3UZ5X1_Ysy1_6sJDEueHRi2qcDgrY,8
|
|
82
|
+
algorhino_anemone-0.1.11.dist-info/RECORD,,
|
anemone/__init__.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
This module provides functionality for creating tree and value builders for the TreeAndValuePlayer.
|
|
1
|
+
"""Provide functionality for creating tree and value builders for the TreeAndValuePlayer.
|
|
3
2
|
|
|
4
3
|
The TreeAndValuePlayerArgs class represents the arguments for configuring the TreeAndValuePlayer.
|
|
5
4
|
The create_tree_and_value_builders function is used to create the tree and value builders.
|
anemone/factory.py
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Module for creating Tree and Value Branch Selector objects.
|
|
3
|
-
"""
|
|
1
|
+
"""Module for creating Tree and Value Branch Selector objects."""
|
|
4
2
|
|
|
5
3
|
from dataclasses import dataclass
|
|
6
|
-
from queue import Queue
|
|
7
4
|
from random import Random
|
|
8
|
-
from typing import Literal
|
|
5
|
+
from typing import Literal
|
|
9
6
|
|
|
10
|
-
from valanga import
|
|
11
|
-
RepresentationFactory,
|
|
12
|
-
StateModifications,
|
|
13
|
-
TurnState,
|
|
14
|
-
)
|
|
7
|
+
from valanga import RepresentationFactory, StateModifications, TurnState
|
|
15
8
|
from valanga.evaluator_types import EvaluatorInput
|
|
16
9
|
|
|
17
10
|
from anemone import node_factory
|
|
@@ -30,7 +23,6 @@ from anemone.nodes.algorithm_node.algorithm_node import AlgorithmNode
|
|
|
30
23
|
from anemone.progress_monitor.progress_monitor import (
|
|
31
24
|
AllStoppingCriterionArgs,
|
|
32
25
|
)
|
|
33
|
-
from anemone.utils.dataclass import IsDataclass
|
|
34
26
|
|
|
35
27
|
from . import node_selector as node_selector_m
|
|
36
28
|
from . import recommender_rule
|
|
@@ -44,9 +36,7 @@ TREE_AND_VALUE_LITERAL_STRING: Literal["TreeAndValue"] = "TreeAndValue"
|
|
|
44
36
|
|
|
45
37
|
@dataclass
|
|
46
38
|
class TreeAndValuePlayerArgs:
|
|
47
|
-
"""
|
|
48
|
-
Dataclass for Tree and Value Player Arguments.
|
|
49
|
-
"""
|
|
39
|
+
"""Dataclass for Tree and Value Player Arguments."""
|
|
50
40
|
|
|
51
41
|
node_selector: node_selector_m.AllNodeSelectorArgs
|
|
52
42
|
opening_type: node_selector_m.OpeningType
|
|
@@ -57,23 +47,21 @@ class TreeAndValuePlayerArgs:
|
|
|
57
47
|
|
|
58
48
|
|
|
59
49
|
def create_tree_and_value_branch_selector[StateT: TurnState](
|
|
60
|
-
state_type:
|
|
50
|
+
state_type: type[StateT],
|
|
61
51
|
args: TreeAndValuePlayerArgs,
|
|
62
52
|
random_generator: Random,
|
|
63
53
|
master_state_evaluator: MasterStateEvaluator,
|
|
64
54
|
state_representation_factory: RepresentationFactory[
|
|
65
|
-
StateT,
|
|
55
|
+
StateT, EvaluatorInput, StateModifications
|
|
66
56
|
]
|
|
67
57
|
| None,
|
|
68
|
-
queue_progress_player: Queue[IsDataclass] | None,
|
|
69
58
|
) -> TreeAndValueBranchSelector[StateT]:
|
|
70
|
-
"""
|
|
59
|
+
"""Create a branch selector using the default minmax tree evaluation.
|
|
71
60
|
|
|
72
61
|
This keeps the existing API stable, while allowing advanced users to inject a
|
|
73
62
|
different tree-evaluation strategy via
|
|
74
63
|
`create_tree_and_value_branch_selector_with_tree_eval_factory`.
|
|
75
64
|
"""
|
|
76
|
-
|
|
77
65
|
node_tree_evaluation_factory: NodeTreeEvaluationFactory[StateT]
|
|
78
66
|
node_tree_evaluation_factory = NodeTreeMinmaxEvaluationFactory[StateT]()
|
|
79
67
|
|
|
@@ -84,35 +72,34 @@ def create_tree_and_value_branch_selector[StateT: TurnState](
|
|
|
84
72
|
master_state_evaluator=master_state_evaluator,
|
|
85
73
|
state_representation_factory=state_representation_factory,
|
|
86
74
|
node_tree_evaluation_factory=node_tree_evaluation_factory,
|
|
87
|
-
queue_progress_player=queue_progress_player,
|
|
88
75
|
)
|
|
89
76
|
|
|
90
77
|
|
|
91
78
|
def create_tree_and_value_branch_selector_with_tree_eval_factory[StateT: TurnState](
|
|
92
|
-
state_type:
|
|
79
|
+
state_type: type[StateT],
|
|
93
80
|
args: TreeAndValuePlayerArgs,
|
|
94
81
|
random_generator: Random,
|
|
95
82
|
master_state_evaluator: MasterStateEvaluator,
|
|
96
83
|
state_representation_factory: RepresentationFactory[
|
|
97
|
-
StateT,
|
|
84
|
+
StateT, EvaluatorInput, StateModifications
|
|
98
85
|
]
|
|
99
86
|
| None,
|
|
100
87
|
node_tree_evaluation_factory: NodeTreeEvaluationFactory[StateT],
|
|
101
|
-
queue_progress_player: Queue[IsDataclass] | None,
|
|
102
88
|
) -> TreeAndValueBranchSelector[StateT]:
|
|
103
|
-
"""
|
|
104
|
-
Create a TreeAndValueBranchSelector object with the given arguments.
|
|
89
|
+
"""Create a TreeAndValueBranchSelector object with the given arguments.
|
|
105
90
|
|
|
106
91
|
Args:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
random_generator (
|
|
92
|
+
state_type (type[StateT]): The state type for the search.
|
|
93
|
+
args (TreeAndValuePlayerArgs): Arguments for creating the selector.
|
|
94
|
+
random_generator (Random): The random number generator.
|
|
95
|
+
master_state_evaluator (MasterStateEvaluator): Evaluator for state values.
|
|
96
|
+
state_representation_factory (RepresentationFactory | None): Optional state representation factory.
|
|
97
|
+
node_tree_evaluation_factory (NodeTreeEvaluationFactory[StateT]): Factory for node tree evaluations.
|
|
110
98
|
|
|
111
99
|
Returns:
|
|
112
100
|
TreeAndValueBranchSelector: The created TreeAndValueBranchSelector object.
|
|
113
101
|
|
|
114
102
|
"""
|
|
115
|
-
|
|
116
103
|
_ = state_type # not used here
|
|
117
104
|
|
|
118
105
|
node_evaluator: NodeDirectEvaluator[StateT] = create_node_evaluator(
|
|
@@ -159,7 +146,6 @@ def create_tree_and_value_branch_selector_with_tree_eval_factory[StateT: TurnSta
|
|
|
159
146
|
node_selector_create=search_factory.create_node_selector_factory(),
|
|
160
147
|
stopping_criterion_args=args.stopping_criterion,
|
|
161
148
|
recommend_branch_after_exploration=args.recommender_rule,
|
|
162
|
-
queue_progress_player=queue_progress_player,
|
|
163
149
|
)
|
|
164
150
|
)
|
|
165
151
|
return tree_branch_selector
|
anemone/indices/__init__.py
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Index utilities for node exploration and index management."""
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
This module provides functionality for managing exploration index managers.
|
|
1
|
+
"""Provide functionality for managing exploration index managers.
|
|
3
2
|
|
|
4
3
|
The module includes the following functions and classes:
|
|
5
4
|
- create_exploration_index_manager: A function to create an exploration index manager.
|
|
@@ -9,4 +8,4 @@ The module includes the following functions and classes:
|
|
|
9
8
|
from .factory import create_exploration_index_manager
|
|
10
9
|
from .node_exploration_manager import NodeExplorationIndexManager
|
|
11
10
|
|
|
12
|
-
__all__ = ["
|
|
11
|
+
__all__ = ["NodeExplorationIndexManager", "create_exploration_index_manager"]
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
This module contains the factory function to create a node exploration index manager based on the given index computation
|
|
3
|
-
"""
|
|
1
|
+
"""Provide a factory for node exploration index managers."""
|
|
4
2
|
|
|
5
3
|
from anemone.indices.index_manager.node_exploration_manager import (
|
|
6
4
|
NodeExplorationIndexManager,
|
|
@@ -14,11 +12,20 @@ from anemone.indices.node_indices.index_types import (
|
|
|
14
12
|
)
|
|
15
13
|
|
|
16
14
|
|
|
15
|
+
class UnknownIndexComputationError(ValueError):
|
|
16
|
+
"""Raised when an index computation type is not recognized."""
|
|
17
|
+
|
|
18
|
+
def __init__(self, index_computation: IndexComputationType) -> None:
|
|
19
|
+
"""Initialize the error with the unsupported computation type."""
|
|
20
|
+
super().__init__(
|
|
21
|
+
f"player creator: can not find {index_computation} in {__name__}"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
17
25
|
def create_exploration_index_manager(
|
|
18
26
|
index_computation: IndexComputationType | None = None,
|
|
19
27
|
) -> NodeExplorationIndexManager:
|
|
20
|
-
"""
|
|
21
|
-
Creates a node exploration index manager based on the given index computation type.
|
|
28
|
+
"""Create a node exploration index manager for the given index computation type.
|
|
22
29
|
|
|
23
30
|
Args:
|
|
24
31
|
index_computation (IndexComputationType | None): The type of index computation to be used.
|
|
@@ -43,8 +50,6 @@ def create_exploration_index_manager(
|
|
|
43
50
|
case IndexComputationType.MIN_LOCAL_CHANGE:
|
|
44
51
|
node_exploration_manager = UpdateIndexLocalMinChange()
|
|
45
52
|
case _:
|
|
46
|
-
raise
|
|
47
|
-
f"player creator: can not find {index_computation} in {__name__}"
|
|
48
|
-
)
|
|
53
|
+
raise UnknownIndexComputationError(index_computation)
|
|
49
54
|
|
|
50
55
|
return node_exploration_manager
|
|
@@ -31,13 +31,13 @@ class _StateWithTurn(State, Protocol):
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
class NodeExplorationIndexManager(Protocol):
|
|
34
|
-
"""
|
|
35
|
-
A protocol for managing the exploration indices of nodes in a tree.
|
|
34
|
+
"""A protocol for managing the exploration indices of nodes in a tree.
|
|
36
35
|
|
|
37
36
|
This protocol defines methods for updating the exploration indices of nodes in a tree.
|
|
38
37
|
|
|
39
38
|
Args:
|
|
40
39
|
Protocol (type): The base protocol type.
|
|
40
|
+
|
|
41
41
|
"""
|
|
42
42
|
|
|
43
43
|
needs_parent_state: bool
|
|
@@ -47,11 +47,12 @@ class NodeExplorationIndexManager(Protocol):
|
|
|
47
47
|
root_node: NodeT,
|
|
48
48
|
root_node_exploration_index_data: NodeExplorationData[NodeT, Any] | None,
|
|
49
49
|
) -> None:
|
|
50
|
-
"""
|
|
51
|
-
Updates the exploration index of the root node in the tree.
|
|
50
|
+
"""Update the exploration index of the root node in the tree.
|
|
52
51
|
|
|
53
52
|
Args:
|
|
54
53
|
root_node (AlgorithmNode): The root node of the tree.
|
|
54
|
+
root_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the root node.
|
|
55
|
+
|
|
55
56
|
"""
|
|
56
57
|
...
|
|
57
58
|
|
|
@@ -65,21 +66,23 @@ class NodeExplorationIndexManager(Protocol):
|
|
|
65
66
|
tree: Tree[NodeT],
|
|
66
67
|
child_rank: int,
|
|
67
68
|
) -> None:
|
|
68
|
-
"""
|
|
69
|
-
Updates the exploration index of a child node in the tree.
|
|
69
|
+
"""Update the exploration index of a child node in the tree.
|
|
70
70
|
|
|
71
71
|
Args:
|
|
72
72
|
child_node (AlgorithmNode): The child node to update.
|
|
73
73
|
parent_node (AlgorithmNode): The parent node of the child node.
|
|
74
|
+
parent_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the parent.
|
|
75
|
+
child_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the child.
|
|
76
|
+
parent_node_state (_StateWithTurn | None): Parent node state with turn information, if needed.
|
|
74
77
|
tree (Tree): The tree containing the nodes.
|
|
75
78
|
child_rank (int): The rank of the child node among its siblings.
|
|
79
|
+
|
|
76
80
|
"""
|
|
77
81
|
...
|
|
78
82
|
|
|
79
83
|
|
|
80
84
|
class NullNodeExplorationIndexManager(NodeExplorationIndexManager):
|
|
81
|
-
"""
|
|
82
|
-
A class representing a null node exploration index manager.
|
|
85
|
+
"""A class representing a null node exploration index manager.
|
|
83
86
|
|
|
84
87
|
This class is used when there is no need to update the exploration index of nodes in a tree.
|
|
85
88
|
It inherits from the NodeExplorationIndexManager class.
|
|
@@ -92,13 +95,13 @@ class NullNodeExplorationIndexManager(NodeExplorationIndexManager):
|
|
|
92
95
|
root_node: NodeT,
|
|
93
96
|
root_node_exploration_index_data: NodeExplorationData[NodeT, Any] | None,
|
|
94
97
|
) -> None:
|
|
95
|
-
"""
|
|
96
|
-
Updates the exploration index of the root node in the tree.
|
|
98
|
+
"""Update the exploration index of the root node in the tree.
|
|
97
99
|
|
|
98
100
|
Args:
|
|
99
101
|
root_node (AlgorithmNode): The root node of the tree.
|
|
102
|
+
root_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the root node.
|
|
103
|
+
|
|
100
104
|
"""
|
|
101
|
-
...
|
|
102
105
|
|
|
103
106
|
def update_node_indices[NodeT: AlgorithmNode[Any]](
|
|
104
107
|
self,
|
|
@@ -110,22 +113,23 @@ class NullNodeExplorationIndexManager(NodeExplorationIndexManager):
|
|
|
110
113
|
tree: Tree[NodeT],
|
|
111
114
|
child_rank: int,
|
|
112
115
|
) -> None:
|
|
113
|
-
"""
|
|
114
|
-
Updates the exploration index of a child node in the tree.
|
|
116
|
+
"""Update the exploration index of a child node in the tree.
|
|
115
117
|
|
|
116
118
|
Args:
|
|
117
119
|
child_node (AlgorithmNode): The child node to update.
|
|
118
120
|
parent_node (AlgorithmNode): The parent node of the child node.
|
|
121
|
+
parent_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the parent.
|
|
122
|
+
child_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the child.
|
|
123
|
+
parent_node_state (_StateWithTurn | None): Parent node state with turn information, if needed.
|
|
119
124
|
tree (Tree): The tree containing the nodes.
|
|
120
125
|
child_rank (int): The rank of the child node among its siblings.
|
|
126
|
+
|
|
121
127
|
"""
|
|
122
128
|
raise NotImplementedError("should not be raised")
|
|
123
129
|
|
|
124
130
|
|
|
125
131
|
class UpdateIndexGlobalMinChange:
|
|
126
|
-
"""
|
|
127
|
-
A class that updates the exploration index of nodes in a tree using the global minimum change strategy.
|
|
128
|
-
"""
|
|
132
|
+
"""A class that updates the exploration index of nodes in a tree using the global minimum change strategy."""
|
|
129
133
|
|
|
130
134
|
needs_parent_state = False
|
|
131
135
|
|
|
@@ -134,11 +138,12 @@ class UpdateIndexGlobalMinChange:
|
|
|
134
138
|
root_node: NodeT,
|
|
135
139
|
root_node_exploration_index_data: NodeExplorationData[NodeT, Any] | None,
|
|
136
140
|
) -> None:
|
|
137
|
-
"""
|
|
138
|
-
Updates the exploration index of the root node in the tree using the global minimum change strategy.
|
|
141
|
+
"""Update the exploration index of the root node using the global minimum change strategy.
|
|
139
142
|
|
|
140
143
|
Args:
|
|
141
144
|
root_node (AlgorithmNode): The root node of the tree.
|
|
145
|
+
root_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the root node.
|
|
146
|
+
|
|
142
147
|
"""
|
|
143
148
|
root_value: float = root_node.tree_evaluation.get_value_white()
|
|
144
149
|
|
|
@@ -158,16 +163,18 @@ class UpdateIndexGlobalMinChange:
|
|
|
158
163
|
tree: Tree[NodeT],
|
|
159
164
|
child_rank: int,
|
|
160
165
|
) -> None:
|
|
161
|
-
"""
|
|
162
|
-
Updates the exploration index of a child node in the tree using the global minimum change strategy.
|
|
166
|
+
"""Update the exploration index of a child node using the global minimum change strategy.
|
|
163
167
|
|
|
164
168
|
Args:
|
|
165
169
|
child_node (AlgorithmNode): The child node to update.
|
|
166
170
|
parent_node (AlgorithmNode): The parent node of the child node.
|
|
171
|
+
parent_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the parent.
|
|
172
|
+
child_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the child.
|
|
173
|
+
parent_node_state (_StateWithTurn | None): Parent node state with turn information, if needed.
|
|
167
174
|
tree (Tree): The tree containing the nodes.
|
|
168
175
|
child_rank (int): The rank of the child node among its siblings.
|
|
169
|
-
"""
|
|
170
176
|
|
|
177
|
+
"""
|
|
171
178
|
_ = child_rank
|
|
172
179
|
_ = parent_node
|
|
173
180
|
_ = tree
|
|
@@ -193,10 +200,6 @@ class UpdateIndexGlobalMinChange:
|
|
|
193
200
|
abs(child_node_max_path_value - child_node_min_path_value) / 2
|
|
194
201
|
)
|
|
195
202
|
|
|
196
|
-
# the amount of change for the child to become better than any of its ancestor
|
|
197
|
-
# and become the overall best bode, the max is computed with the parent index
|
|
198
|
-
# child_index: float = max(local_child_index, parent_index)
|
|
199
|
-
|
|
200
203
|
# the index of the child node is updated now
|
|
201
204
|
# as a child node can have multiple parents we take the min if an index was previously computed
|
|
202
205
|
if child_node_exploration_index_data.index is None:
|
|
@@ -220,9 +223,7 @@ class UpdateIndexGlobalMinChange:
|
|
|
220
223
|
|
|
221
224
|
|
|
222
225
|
class UpdateIndexZipfFactoredProba:
|
|
223
|
-
"""
|
|
224
|
-
A class that updates the exploration index of nodes in a tree using the Zipf factored probability strategy.
|
|
225
|
-
"""
|
|
226
|
+
"""A class that updates the exploration index of nodes in a tree using the Zipf factored probability strategy."""
|
|
226
227
|
|
|
227
228
|
needs_parent_state = False
|
|
228
229
|
|
|
@@ -231,13 +232,13 @@ class UpdateIndexZipfFactoredProba:
|
|
|
231
232
|
root_node: NodeT,
|
|
232
233
|
root_node_exploration_index_data: NodeExplorationData[NodeT, Any] | None,
|
|
233
234
|
) -> None:
|
|
234
|
-
"""
|
|
235
|
-
Updates the exploration index of the root node in the tree using the Zipf factored probability strategy.
|
|
235
|
+
"""Update the exploration index of the root node using the Zipf factored probability strategy.
|
|
236
236
|
|
|
237
237
|
Args:
|
|
238
238
|
root_node (AlgorithmNode): The root node of the tree.
|
|
239
|
-
|
|
239
|
+
root_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the root node.
|
|
240
240
|
|
|
241
|
+
"""
|
|
241
242
|
_ = root_node
|
|
242
243
|
assert isinstance(
|
|
243
244
|
root_node_exploration_index_data, RecurZipfQuoolExplorationData
|
|
@@ -255,14 +256,17 @@ class UpdateIndexZipfFactoredProba:
|
|
|
255
256
|
tree: Tree[NodeT],
|
|
256
257
|
child_rank: int,
|
|
257
258
|
) -> None:
|
|
258
|
-
"""
|
|
259
|
-
Updates the exploration index of a child node in the tree using the Zipf factored probability strategy.
|
|
259
|
+
"""Update the exploration index of a child node using the Zipf factored probability strategy.
|
|
260
260
|
|
|
261
261
|
Args:
|
|
262
262
|
child_node (AlgorithmNode): The child node to update.
|
|
263
263
|
parent_node (AlgorithmNode): The parent node of the child node.
|
|
264
|
+
parent_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the parent.
|
|
265
|
+
child_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the child.
|
|
266
|
+
parent_node_state (_StateWithTurn | None): Parent node state with turn information, if needed.
|
|
264
267
|
tree (Tree): The tree containing the nodes.
|
|
265
268
|
child_rank (int): The rank of the child node among its siblings.
|
|
269
|
+
|
|
266
270
|
"""
|
|
267
271
|
_ = parent_node
|
|
268
272
|
|
|
@@ -306,9 +310,7 @@ class UpdateIndexZipfFactoredProba:
|
|
|
306
310
|
|
|
307
311
|
|
|
308
312
|
class UpdateIndexLocalMinChange:
|
|
309
|
-
"""
|
|
310
|
-
A class that updates the exploration index of nodes in a tree using the local minimum change strategy.
|
|
311
|
-
"""
|
|
313
|
+
"""A class that updates the exploration index of nodes in a tree using the local minimum change strategy."""
|
|
312
314
|
|
|
313
315
|
needs_parent_state = True
|
|
314
316
|
|
|
@@ -317,11 +319,12 @@ class UpdateIndexLocalMinChange:
|
|
|
317
319
|
root_node: NodeT,
|
|
318
320
|
root_node_exploration_index_data: NodeExplorationData[NodeT, Any] | None,
|
|
319
321
|
) -> None:
|
|
320
|
-
"""
|
|
321
|
-
Updates the exploration index of the root node in the tree using the local minimum change strategy.
|
|
322
|
+
"""Update the exploration index of the root node using the local minimum change strategy.
|
|
322
323
|
|
|
323
324
|
Args:
|
|
324
325
|
root_node (AlgorithmNode): The root node of the tree.
|
|
326
|
+
root_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the root node.
|
|
327
|
+
|
|
325
328
|
"""
|
|
326
329
|
_ = root_node
|
|
327
330
|
assert isinstance(root_node_exploration_index_data, IntervalExplo)
|
|
@@ -341,16 +344,18 @@ class UpdateIndexLocalMinChange:
|
|
|
341
344
|
tree: Tree[NodeT],
|
|
342
345
|
child_rank: int,
|
|
343
346
|
) -> None:
|
|
344
|
-
"""
|
|
345
|
-
Updates the exploration index of a child node in the tree using the local minimum change strategy.
|
|
347
|
+
"""Update the exploration index of a child node using the local minimum change strategy.
|
|
346
348
|
|
|
347
349
|
Args:
|
|
348
350
|
child_node (AlgorithmNode): The child node to update.
|
|
349
351
|
parent_node (AlgorithmNode): The parent node of the child node.
|
|
352
|
+
parent_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the parent.
|
|
353
|
+
child_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the child.
|
|
354
|
+
parent_node_state (_StateWithTurn | None): Parent node state with turn information, if needed.
|
|
350
355
|
tree (Tree): The tree containing the nodes.
|
|
351
356
|
child_rank (int): The rank of the child node among its siblings.
|
|
352
|
-
"""
|
|
353
357
|
|
|
358
|
+
"""
|
|
354
359
|
_ = tree
|
|
355
360
|
_ = child_rank
|
|
356
361
|
|
|
@@ -405,7 +410,6 @@ class UpdateIndexLocalMinChange:
|
|
|
405
410
|
value=child_white_value, interval=inter_level_interval
|
|
406
411
|
)
|
|
407
412
|
else:
|
|
408
|
-
...
|
|
409
413
|
local_index = None
|
|
410
414
|
if parent_node_state.turn == Color.BLACK:
|
|
411
415
|
best_branch_black: BranchKey | None = (
|
|
@@ -459,22 +463,23 @@ class UpdateIndexLocalMinChange:
|
|
|
459
463
|
)
|
|
460
464
|
|
|
461
465
|
|
|
462
|
-
# TODO their might be ways to optimize the computation such as not recomptuing for the whole tree
|
|
466
|
+
# TODO: their might be ways to optimize the computation such as not recomptuing for the whole tree
|
|
463
467
|
def update_all_indices[NodeT: AlgorithmNode[Any]](
|
|
464
468
|
tree: Tree[NodeT], index_manager: NodeExplorationIndexManager
|
|
465
469
|
) -> None:
|
|
466
|
-
"""
|
|
467
|
-
The idea is to compute an index $ind(n)$ for a node $n$ that measures the minimum amount of change
|
|
468
|
-
in the value of all the nodes such that this node $n$ becomes the best.
|
|
470
|
+
"""Compute exploration indices for nodes in the tree.
|
|
469
471
|
|
|
470
|
-
This
|
|
471
|
-
|
|
472
|
+
This computes an index $ind(n)$ for a node $n$ that measures the minimum amount
|
|
473
|
+
of change in the value of all the nodes such that this node $n$ becomes the best.
|
|
474
|
+
It can be computed recursively as:
|
|
475
|
+
ind(n) = max(ind(parent(n), 0.5 * abs(value(n) - value(parent(n)))))
|
|
472
476
|
|
|
473
477
|
Args:
|
|
474
|
-
|
|
475
|
-
|
|
478
|
+
tree: The tree to update.
|
|
479
|
+
index_manager: The index manager that defines the update logic.
|
|
476
480
|
|
|
477
481
|
Returns:
|
|
482
|
+
None
|
|
478
483
|
|
|
479
484
|
"""
|
|
480
485
|
if isinstance(index_manager, NullNodeExplorationIndexManager):
|
|
@@ -489,7 +494,7 @@ def update_all_indices[NodeT: AlgorithmNode[Any]](
|
|
|
489
494
|
|
|
490
495
|
tree_depth: TreeDepth
|
|
491
496
|
for tree_depth in tree_nodes:
|
|
492
|
-
#
|
|
497
|
+
# TODO: how are we sure that the hm comes in order?
|
|
493
498
|
parent_node: NodeT
|
|
494
499
|
for parent_node in tree_nodes[tree_depth].values():
|
|
495
500
|
branch_rank: int
|
|
@@ -518,26 +523,26 @@ def update_all_indices[NodeT: AlgorithmNode[Any]](
|
|
|
518
523
|
)
|
|
519
524
|
|
|
520
525
|
|
|
521
|
-
# TODO their might be ways to optimize the computation such as not recomptuing for the whole tree
|
|
526
|
+
# TODO: their might be ways to optimize the computation such as not recomptuing for the whole tree
|
|
522
527
|
|
|
523
528
|
|
|
524
529
|
def print_all_indices[NodeT: AlgorithmNode[Any]](
|
|
525
530
|
tree: Tree[NodeT],
|
|
526
531
|
) -> None:
|
|
527
|
-
"""
|
|
528
|
-
Prints the exploration indices of all nodes in the given tree.
|
|
532
|
+
"""Print the exploration indices of all nodes in the given tree.
|
|
529
533
|
|
|
530
534
|
Args:
|
|
531
535
|
tree (Tree): The tree containing the nodes.
|
|
532
536
|
|
|
533
537
|
Returns:
|
|
534
538
|
None
|
|
539
|
+
|
|
535
540
|
"""
|
|
536
541
|
tree_nodes: RangedDescendants[NodeT] = tree.descendants
|
|
537
542
|
|
|
538
543
|
tree_depth: TreeDepth
|
|
539
544
|
for tree_depth in tree_nodes:
|
|
540
|
-
#
|
|
545
|
+
# TODO: how are we sure that the hm comes in order?
|
|
541
546
|
for parent_node in tree_nodes[tree_depth].values():
|
|
542
547
|
assert isinstance(parent_node, AlgorithmNode)
|
|
543
548
|
if parent_node.exploration_index_data is not None:
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
This module provides functionality for managing node indices in the tree value package.
|
|
1
|
+
"""Provide functionality for managing node indices in the tree value package.
|
|
3
2
|
|
|
4
3
|
The following classes and functions are available:
|
|
5
4
|
|
|
@@ -15,8 +14,8 @@ from .index_data import NodeExplorationData
|
|
|
15
14
|
from .index_types import IndexComputationType
|
|
16
15
|
|
|
17
16
|
__all__ = [
|
|
18
|
-
"NodeExplorationData",
|
|
19
17
|
"ExplorationIndexDataFactory",
|
|
20
18
|
"IndexComputationType",
|
|
19
|
+
"NodeExplorationData",
|
|
21
20
|
"create_exploration_index_data",
|
|
22
21
|
]
|