ai-nk-cce 0.1.0__py3-none-any.whl → 0.1.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ai-nk-cce
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: This repository is used to train AI agents to predict good strategies in a social learning game based on a NK landscape.
5
5
  Author: Luis Mienhardt
6
6
  Author-email: mienhardt@mpib-berlin.mpg.de
@@ -28,7 +28,7 @@ model/scripts/template_rl.slurm,sha256=Un8VTcS8n-W4l4nkz6xER9R6NpeKX4vQp2Go2Hv6C
28
28
  model/train.py,sha256=fhNvzUEgEqREsDZPjRLyNPVU4zjBUkF1lbUKr93d4b4,9619
29
29
  nk_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
30
  nk_model/assembler.py,sha256=ea9YDlYBiWp927jf2oxl9NaeMzYhXeaKBF5cOKSF1C4,3192
31
- nk_model/biased_prediction_agent.py,sha256=hXkgNi3yTlv3xwCrwPyAo6cBJ_G2CHXvgZaHn0T5hJI,12302
31
+ nk_model/biased_prediction_agent.py,sha256=qK1sEYyqO-p8AHG2_eCvxzxdLX-FF3yJs9g0vYxWjjU,13928
32
32
  nk_model/dataset.py,sha256=fwaCvSd75Rz4afQ5VmbMjLoBSi9lCNWARI4GpyJ5ENQ,14471
33
33
  nk_model/enums.py,sha256=rUzY6ky4tISpH9IVHc2Zxy7Uqzn0wTkDmlg6kDTxXnY,403
34
34
  nk_model/landscape_cache.py,sha256=7V2w9MErkoAMfTK_1MLf1NDPzIJ9PeuyBV8bEuWszO0,4727
@@ -41,6 +41,6 @@ utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
41
  utils/binary_conversion.py,sha256=9YTEbxSUNuGnVWAIU5fG1U1bjdqSbhC1C3NGUmqv-C8,3705
42
42
  utils/logging.py,sha256=SQlSxGt4ntkW3kyyy8cj_Moldg10szIzP1Cu1wMJVVo,895
43
43
  utils/utils.py,sha256=_GypnP34bOrr3OD8PB-8QmJmMcpM6hTJm5G67PXhAME,1455
44
- ai_nk_cce-0.1.0.dist-info/METADATA,sha256=QrOK2mNNijYE-3d7W4um5DwdbXdPtV-sIsa_3QwvIAs,3604
45
- ai_nk_cce-0.1.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
46
- ai_nk_cce-0.1.0.dist-info/RECORD,,
44
+ ai_nk_cce-0.1.1.dist-info/METADATA,sha256=xtWbrvLzh22mStUgTDaWdDeySeMVagTGnyp1YmaEbE0,3604
45
+ ai_nk_cce-0.1.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
46
+ ai_nk_cce-0.1.1.dist-info/RECORD,,
@@ -32,7 +32,8 @@ class BiasedPredictionAgent:
32
32
  bias_power: Power applied to bias landscape G. Higher values
33
33
  make the bias more pronounced for regions with higher G(x)
34
34
  """
35
- self.landscape = landscape
35
+ self.landscape = self._normalize_landscape(landscape)
36
+
36
37
  self.bias_seed = bias_seed
37
38
  self.bias_power = bias_power
38
39
 
@@ -49,6 +50,53 @@ class BiasedPredictionAgent:
49
50
  List[Tuple[np.ndarray, float]],
50
51
  ] = {}
51
52
 
53
+ def _normalize_landscape(self, landscape: NKLandscape) -> NKLandscape:
54
+ """
55
+ Normalize landscape payoffs to [0, 1] range.
56
+
57
+ Args:
58
+ landscape: NKLandscape to normalize
59
+
60
+ Returns:
61
+ New NKLandscape with normalized payoffs
62
+ """
63
+ # Extract payoffs
64
+ payoffs = np.array([item.payoff for item in landscape.items])
65
+ min_payoff = np.min(payoffs)
66
+ max_payoff = np.max(payoffs)
67
+
68
+ # Normalize to [0, 1]
69
+ if max_payoff > min_payoff:
70
+ normalized_payoffs = (payoffs - min_payoff) / (
71
+ max_payoff - min_payoff
72
+ )
73
+ else:
74
+ normalized_payoffs = np.zeros_like(payoffs)
75
+
76
+ # Create new landscape with normalized payoffs
77
+ normalized_items = [
78
+ Item(
79
+ coordinates=item.coordinates.copy(),
80
+ payoff=normalized_payoffs[i],
81
+ )
82
+ for i, item in enumerate(landscape.items)
83
+ ]
84
+
85
+ # Create a new NKLandscape object
86
+ normalized_landscape = NKLandscape.__new__(NKLandscape)
87
+ normalized_landscape.params = landscape.params
88
+ normalized_landscape.N = landscape.N
89
+ normalized_landscape.K = landscape.K
90
+ normalized_landscape.M = landscape.M
91
+ normalized_landscape.items = normalized_items
92
+ normalized_landscape._payoff_lookup = {
93
+ tuple(item.coordinates): item.payoff
94
+ for item in normalized_items
95
+ }
96
+ normalized_landscape.uuid = f"{landscape.uuid}_normalized"
97
+
98
+ return normalized_landscape
99
+
52
100
  def _create_bias(self) -> NKLandscape:
53
101
  """
54
102
  Create bias landscape G with N'=N, K'=0.