pycityagent 2.0.0a65__cp311-cp311-macosx_11_0_arm64.whl → 2.0.0a67__cp311-cp311-macosx_11_0_arm64.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.
Files changed (87) hide show
  1. pycityagent/agent/agent.py +157 -57
  2. pycityagent/agent/agent_base.py +316 -43
  3. pycityagent/cityagent/bankagent.py +49 -9
  4. pycityagent/cityagent/blocks/__init__.py +1 -2
  5. pycityagent/cityagent/blocks/cognition_block.py +54 -31
  6. pycityagent/cityagent/blocks/dispatcher.py +22 -17
  7. pycityagent/cityagent/blocks/economy_block.py +46 -32
  8. pycityagent/cityagent/blocks/mobility_block.py +209 -105
  9. pycityagent/cityagent/blocks/needs_block.py +101 -54
  10. pycityagent/cityagent/blocks/other_block.py +42 -33
  11. pycityagent/cityagent/blocks/plan_block.py +59 -42
  12. pycityagent/cityagent/blocks/social_block.py +167 -126
  13. pycityagent/cityagent/blocks/utils.py +13 -6
  14. pycityagent/cityagent/firmagent.py +17 -35
  15. pycityagent/cityagent/governmentagent.py +3 -3
  16. pycityagent/cityagent/initial.py +79 -49
  17. pycityagent/cityagent/memory_config.py +123 -94
  18. pycityagent/cityagent/message_intercept.py +0 -4
  19. pycityagent/cityagent/metrics.py +41 -0
  20. pycityagent/cityagent/nbsagent.py +24 -36
  21. pycityagent/cityagent/societyagent.py +9 -4
  22. pycityagent/cli/wrapper.py +2 -2
  23. pycityagent/economy/econ_client.py +407 -81
  24. pycityagent/environment/__init__.py +0 -3
  25. pycityagent/environment/sim/__init__.py +0 -3
  26. pycityagent/environment/sim/aoi_service.py +2 -2
  27. pycityagent/environment/sim/client.py +3 -31
  28. pycityagent/environment/sim/clock_service.py +2 -2
  29. pycityagent/environment/sim/lane_service.py +8 -8
  30. pycityagent/environment/sim/light_service.py +8 -8
  31. pycityagent/environment/sim/pause_service.py +9 -10
  32. pycityagent/environment/sim/person_service.py +20 -20
  33. pycityagent/environment/sim/road_service.py +2 -2
  34. pycityagent/environment/sim/sim_env.py +21 -5
  35. pycityagent/environment/sim/social_service.py +4 -4
  36. pycityagent/environment/simulator.py +249 -27
  37. pycityagent/environment/utils/__init__.py +2 -2
  38. pycityagent/environment/utils/geojson.py +2 -2
  39. pycityagent/environment/utils/grpc.py +4 -4
  40. pycityagent/environment/utils/map_utils.py +2 -2
  41. pycityagent/llm/embeddings.py +147 -28
  42. pycityagent/llm/llm.py +178 -111
  43. pycityagent/llm/llmconfig.py +5 -0
  44. pycityagent/llm/utils.py +4 -0
  45. pycityagent/memory/__init__.py +0 -4
  46. pycityagent/memory/const.py +2 -2
  47. pycityagent/memory/faiss_query.py +140 -61
  48. pycityagent/memory/memory.py +394 -91
  49. pycityagent/memory/memory_base.py +140 -34
  50. pycityagent/memory/profile.py +13 -13
  51. pycityagent/memory/self_define.py +13 -13
  52. pycityagent/memory/state.py +14 -14
  53. pycityagent/message/message_interceptor.py +253 -3
  54. pycityagent/message/messager.py +133 -6
  55. pycityagent/metrics/mlflow_client.py +47 -4
  56. pycityagent/pycityagent-sim +0 -0
  57. pycityagent/pycityagent-ui +0 -0
  58. pycityagent/simulation/__init__.py +3 -2
  59. pycityagent/simulation/agentgroup.py +150 -54
  60. pycityagent/simulation/simulation.py +276 -66
  61. pycityagent/survey/manager.py +45 -3
  62. pycityagent/survey/models.py +42 -2
  63. pycityagent/tools/__init__.py +1 -2
  64. pycityagent/tools/tool.py +93 -69
  65. pycityagent/utils/avro_schema.py +2 -2
  66. pycityagent/utils/parsers/code_block_parser.py +1 -1
  67. pycityagent/utils/parsers/json_parser.py +2 -2
  68. pycityagent/utils/parsers/parser_base.py +2 -2
  69. pycityagent/workflow/block.py +64 -13
  70. pycityagent/workflow/prompt.py +31 -23
  71. pycityagent/workflow/trigger.py +91 -24
  72. {pycityagent-2.0.0a65.dist-info → pycityagent-2.0.0a67.dist-info}/METADATA +2 -2
  73. pycityagent-2.0.0a67.dist-info/RECORD +97 -0
  74. pycityagent/environment/interact/__init__.py +0 -0
  75. pycityagent/environment/interact/interact.py +0 -198
  76. pycityagent/environment/message/__init__.py +0 -0
  77. pycityagent/environment/sence/__init__.py +0 -0
  78. pycityagent/environment/sence/static.py +0 -416
  79. pycityagent/environment/sidecar/__init__.py +0 -8
  80. pycityagent/environment/sidecar/sidecarv2.py +0 -109
  81. pycityagent/environment/sim/economy_services.py +0 -192
  82. pycityagent/metrics/utils/const.py +0 -0
  83. pycityagent-2.0.0a65.dist-info/RECORD +0 -105
  84. {pycityagent-2.0.0a65.dist-info → pycityagent-2.0.0a67.dist-info}/LICENSE +0 -0
  85. {pycityagent-2.0.0a65.dist-info → pycityagent-2.0.0a67.dist-info}/WHEEL +0 -0
  86. {pycityagent-2.0.0a65.dist-info → pycityagent-2.0.0a67.dist-info}/entry_points.txt +0 -0
  87. {pycityagent-2.0.0a65.dist-info → pycityagent-2.0.0a67.dist-info}/top_level.txt +0 -0
@@ -1,25 +1,49 @@
1
1
  import asyncio
2
- from typing import Optional
3
2
  import socket
4
- from ..memory import Memory
3
+ from typing import Optional
4
+
5
5
  from ..environment import Simulator
6
+ from ..memory import Memory
6
7
 
7
8
  KEY_TRIGGER_COMPONENTS = [Memory, Simulator]
8
9
 
10
+ __all__ = [
11
+ "EventTrigger",
12
+ "MemoryChangeTrigger",
13
+ "TimeTrigger",
14
+ ]
15
+
9
16
 
10
17
  class EventTrigger:
11
- """Base class for event triggers that wait for specific conditions to be met."""
18
+ """Base class for event triggers that wait for specific conditions to be met.
19
+
20
+ - **Attributes**:
21
+ - `required_components` (List[Type]): A list of component types required by this trigger.
22
+ """
12
23
 
13
24
  # 定义该trigger需要的组件类型
14
25
  required_components: list[type] = []
15
26
 
16
27
  def __init__(self, block=None):
28
+ """
29
+ - **Description**:
30
+ - Initializes the EventTrigger with an optional block which contains dependencies.
31
+
32
+ - **Args**:
33
+ - `block`: An object containing necessary dependencies for the trigger. Defaults to None.
34
+ """
17
35
  self.block = block
18
36
  if block is not None:
19
37
  self.initialize()
20
38
 
21
39
  def initialize(self) -> None:
22
- """Initialize the trigger with necessary dependencies."""
40
+ """
41
+ - **Description**:
42
+ - Initialize the trigger with necessary dependencies and checks for missing components.
43
+
44
+ - **Raises**:
45
+ - `RuntimeError`: If the block is not set or required components are missing.
46
+ """
23
47
  if not self.block:
24
48
  raise RuntimeError("Block not set for trigger")
25
49
 
@@ -37,24 +61,32 @@ class EventTrigger:
37
61
  )
38
62
 
39
63
  async def wait_for_trigger(self) -> None:
40
- """Wait for the event trigger to be activated.
64
+ """
65
+ - **Description**:
66
+ - Wait for the event trigger to be activated.
41
67
 
42
- Raises:
43
- NotImplementedError: Subclasses must implement this method.
68
+ - **Raises**:
69
+ - `NotImplementedError`: Subclasses must implement this method.
44
70
  """
45
71
  raise NotImplementedError
46
72
 
47
73
 
48
74
  class MemoryChangeTrigger(EventTrigger):
49
- """Event trigger that activates when a specific key in memory changes."""
75
+ """Event trigger that activates when a specific key in memory changes.
76
+
77
+ - **Attributes**:
78
+ - `required_components` (List[Type]): Specifies that the Memory component is required.
79
+ """
50
80
 
51
81
  required_components = [Memory]
52
82
 
53
83
  def __init__(self, key: str) -> None:
54
- """Initialize the memory change trigger.
84
+ """
85
+ - **Description**:
86
+ - Initialize the memory change trigger.
55
87
 
56
- Args:
57
- key (str): The key in memory to monitor for changes.
88
+ - **Args**:
89
+ - `key` (str): The key in memory to monitor for changes.
58
90
  """
59
91
  self.key = key
60
92
  self.trigger_event = asyncio.Event()
@@ -62,14 +94,27 @@ class MemoryChangeTrigger(EventTrigger):
62
94
  super().__init__()
63
95
 
64
96
  def initialize(self) -> None:
65
- """Initialize the trigger with memory from block."""
97
+ """
98
+ - **Description**:
99
+ - Initialize the trigger with memory from block and add watcher for the specified key.
100
+
101
+ - **Raises**:
102
+ - `RuntimeError`: If the block is not properly set.
103
+ """
66
104
  super().initialize() # 首先检查必需组件
105
+ assert self.block is not None
67
106
  self.memory = self.block.memory
68
107
  asyncio.create_task(self.memory.add_watcher(self.key, self.trigger_event.set))
69
108
  self._initialized = True
70
109
 
71
110
  async def wait_for_trigger(self) -> None:
72
- """Wait for the memory change trigger to be activated."""
111
+ """
112
+ - **Description**:
113
+ - Wait for the memory change trigger to be activated.
114
+
115
+ - **Raises**:
116
+ - `RuntimeError`: If the trigger is not properly initialized.
117
+ """
73
118
  if not self._initialized:
74
119
  raise RuntimeError("Trigger not properly initialized")
75
120
  await self.trigger_event.wait()
@@ -77,7 +122,11 @@ class MemoryChangeTrigger(EventTrigger):
77
122
 
78
123
 
79
124
  class TimeTrigger(EventTrigger):
80
- """Event trigger that activates periodically based on time intervals."""
125
+ """Event trigger that activates periodically based on time intervals.
126
+
127
+ - **Attributes**:
128
+ - `required_components` (List[Type]): Specifies that the Simulator component is required.
129
+ """
81
130
 
82
131
  required_components = [Simulator]
83
132
 
@@ -87,15 +136,17 @@ class TimeTrigger(EventTrigger):
87
136
  hours: Optional[int] = None,
88
137
  minutes: Optional[int] = None,
89
138
  ) -> None:
90
- """Initialize the time trigger with interval settings.
139
+ """
140
+ - **Description**:
141
+ - Initialize the time trigger with interval settings.
91
142
 
92
- Args:
93
- days (Optional[int]): Execute every N days
94
- hours (Optional[int]): Execute every N hours
95
- minutes (Optional[int]): Execute every N minutes
143
+ - **Args**:
144
+ - `days` (Optional[int]): Execute every N days. Defaults to None.
145
+ - `hours` (Optional[int]): Execute every N hours. Defaults to None.
146
+ - `minutes` (Optional[int]): Execute every N minutes. Defaults to None.
96
147
 
97
- Raises:
98
- ValueError: If all interval parameters are None or negative
148
+ - **Raises**:
149
+ - `ValueError`: If all interval parameters are None or any of them are negative.
99
150
  """
100
151
  if all(param is None for param in (days, hours, minutes)):
101
152
  raise ValueError("At least one time interval must be specified")
@@ -125,8 +176,15 @@ class TimeTrigger(EventTrigger):
125
176
  super().__init__()
126
177
 
127
178
  def initialize(self) -> None:
128
- """Initialize the trigger with necessary dependencies."""
179
+ """
180
+ - **Description**:
181
+ - Initialize the trigger with necessary dependencies and start monitoring task.
182
+
183
+ - **Raises**:
184
+ - `RuntimeError`: If the block is not properly set.
185
+ """
129
186
  super().initialize() # 首先检查必需组件
187
+ assert self.block is not None
130
188
  self.memory = self.block.memory
131
189
  self.simulator = self.block.simulator
132
190
  # 启动时间监控任务
@@ -134,7 +192,10 @@ class TimeTrigger(EventTrigger):
134
192
  self._initialized = True
135
193
 
136
194
  async def _monitor_time(self):
137
- """持续监控时间并在达到间隔时触发事件"""
195
+ """
196
+ - **Description**:
197
+ - Continuously monitor the time and trigger the event when the interval has passed.
198
+ """
138
199
  # 第一次调用时直接触发
139
200
  self.trigger_event.set()
140
201
 
@@ -156,7 +217,13 @@ class TimeTrigger(EventTrigger):
156
217
  await asyncio.sleep(10) # 发生错误时等待较长时间
157
218
 
158
219
  async def wait_for_trigger(self) -> None:
159
- """Wait for the time trigger to be activated."""
220
+ """
221
+ - **Description**:
222
+ - Wait for the time trigger to be activated.
223
+
224
+ - **Raises**:
225
+ - `RuntimeError`: If the trigger is not properly initialized.
226
+ """
160
227
  if not self._initialized:
161
228
  raise RuntimeError("Trigger not properly initialized")
162
229
  await self.trigger_event.wait()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pycityagent
3
- Version: 2.0.0a65
3
+ Version: 2.0.0a67
4
4
  Summary: LLM-based city environment agent building library
5
5
  Author-email: Yuwei Yan <pinkgranite86@gmail.com>, Junbo Yan <yanjb20thu@gmali.com>, Jun Zhang <zhangjun990222@gmali.com>
6
6
  License: MIT License
@@ -45,7 +45,7 @@ Requires-Dist: openai>=1.58.1
45
45
  Requires-Dist: Pillow<12.0.0,>=11.0.0
46
46
  Requires-Dist: protobuf<5.0.0,<=4.24.0
47
47
  Requires-Dist: pycitydata>=1.0.3
48
- Requires-Dist: pycityproto>=2.2.0
48
+ Requires-Dist: pycityproto>=2.2.2
49
49
  Requires-Dist: requests>=2.32.3
50
50
  Requires-Dist: Shapely>=2.0.6
51
51
  Requires-Dist: PyYAML>=6.0.2
@@ -0,0 +1,97 @@
1
+ pycityagent-2.0.0a67.dist-info/RECORD,,
2
+ pycityagent-2.0.0a67.dist-info/LICENSE,sha256=n2HPXiupinpyHMnIkbCf3OTYd3KMqbmldu1e7av0CAU,1084
3
+ pycityagent-2.0.0a67.dist-info/WHEEL,sha256=NW1RskY9zow1Y68W-gXg0oZyBRAugI1JHywIzAIai5o,109
4
+ pycityagent-2.0.0a67.dist-info/entry_points.txt,sha256=BZcne49AAIFv-hawxGnPbblea7X3MtAtoPyDX8L4OC4,132
5
+ pycityagent-2.0.0a67.dist-info/top_level.txt,sha256=yOmeu6cSXmiUtScu53a3s0p7BGtLMaV0aff83EHCTic,43
6
+ pycityagent-2.0.0a67.dist-info/METADATA,sha256=c4r6nC0hBaQ9ux_-fHHvugj-ReCAlqoKDbWew9PE1f8,9110
7
+ pycityagent/pycityagent-sim,sha256=7AF-sHfnUfVBbiBMOWc11C_5xc9rfEip9lg_7vUieUU,35884466
8
+ pycityagent/__init__.py,sha256=PUKWTXc-xdMG7px8oTNclodsILUgypANj2Z647sY63k,808
9
+ pycityagent/pycityagent-ui,sha256=Ur95yZygIaZ5l_CDqP9394M5GQ66iV5PkcNPYFWqzvk,41225346
10
+ pycityagent/metrics/mlflow_client.py,sha256=-iyh4BPVnBkluhmfucUzibCUnBX2iftkz4tVJJVxwHw,6958
11
+ pycityagent/metrics/__init__.py,sha256=X08PaBbGVAd7_PRGLREXWxaqm7nS82WBQpD1zvQzcqc,128
12
+ pycityagent/economy/__init__.py,sha256=aonY4WHnx-6EGJ4WKrx4S-2jAkYNLtqUA04jp6q8B7w,75
13
+ pycityagent/economy/econ_client.py,sha256=9kzGMhzoTsOXzyv6vBPscc7LbU3gvN5yiuofMUBOgvE,24797
14
+ pycityagent/tools/__init__.py,sha256=y7sMVMHf0AbivlczM2h-kr7mkgXK-WAx3S9BXLXkWvw,235
15
+ pycityagent/tools/tool.py,sha256=-HZvKeq4gFMo2wJPk6vcr8EdXubM7kA0qC82zv_yS-s,9011
16
+ pycityagent/llm/llmconfig.py,sha256=6AqCMV4B_JqBD2mb98bLGzpUdlOCnziQKae-Hhxxp-E,469
17
+ pycityagent/llm/__init__.py,sha256=iWs6FLgrbRVIiqOf4ILS89gkVCTvS7HFC3vG-MWuyko,205
18
+ pycityagent/llm/llm.py,sha256=DvrgrnrmR2JAQRVOvvRo3w4aD8M-qLAqVSD5pXZHr4M,19019
19
+ pycityagent/llm/embeddings.py,sha256=3610I-_scAy8HwRNpT8hVJpH9_8_pTLCPptqnzSq10o,11322
20
+ pycityagent/llm/utils.py,sha256=rSx_fp-_Gh0vZ-x2rqAUqnpS56BVTZ4ChfAMarB8S1A,195
21
+ pycityagent/memory/memory.py,sha256=Shf-8ZAPCzxcIgZM-L64OzwjkCmIlN_26ByeI-meqnE,44760
22
+ pycityagent/memory/profile.py,sha256=Z1shwFc6MqakorbiY6rGqVAgCJP4YTpDrqnMQZcYQno,5227
23
+ pycityagent/memory/__init__.py,sha256=NClJAXC4G6I8kFWkPEcU2lbVDfyrRb5HrrBHgCXrzOU,125
24
+ pycityagent/memory/memory_base.py,sha256=av_sbD62PZbJyM8E9wmVuqYqgsutghcO7nJdAxGpHi0,9784
25
+ pycityagent/memory/self_define.py,sha256=rndjWvQfi4x_90jtQWuCtWwLFBKqe7sExsDqs4I-KEw,5224
26
+ pycityagent/memory/utils.py,sha256=oJWLdPeJy_jcdKcDTo9JAH9kDZhqjoQhhv_zT9qWC0w,877
27
+ pycityagent/memory/const.py,sha256=nFmjvt-8FEB0hc0glOH3lliqJhkhf3D_NKxWI0pf6TY,936
28
+ pycityagent/memory/faiss_query.py,sha256=KPeyzIjD0dzkxr-TlOeCiIlkdh1WAyyipCAXUEt97Lk,17350
29
+ pycityagent/memory/state.py,sha256=JFCBuK1AS-HqscvdGS9ATF9AUU8t29_2leDY_6iO2_4,5158
30
+ pycityagent/simulation/simulation.py,sha256=WlCs76fvLdZNzmAJvAsKdXiTH7eyvVmqOG9xK-OhQWk,47719
31
+ pycityagent/simulation/__init__.py,sha256=u1WpgwVxPboXWMxrUQKMXJNmTKQYAeCaqZv9HmSxESY,118
32
+ pycityagent/simulation/agentgroup.py,sha256=TlZekAZBjJsch2ZlvDWgRNyFmyc6kwzd_S550s2Lflw,36796
33
+ pycityagent/simulation/storage/pg.py,sha256=xRshSOGttW-p0re0fNBOjOpb-nQ5msIE2LsdT79_E_Y,8425
34
+ pycityagent/message/message_interceptor.py,sha256=QWuTUqi1Cu214fhFs0f78tD2zflMnb6zEAGB4RutXxs,17736
35
+ pycityagent/message/__init__.py,sha256=f5QH7DKPqEAMyfSlBMnl3uouOKlsoel909STlIe7nUk,276
36
+ pycityagent/message/messager.py,sha256=UdOyEMLmaF3ZUvXHmratZxKNEb3BpmN7VyRdvGJWTL4,9060
37
+ pycityagent/utils/avro_schema.py,sha256=dzytGiDy5tDFTi5QJ8pHySl9xrbXZ0Qwrc1ONUhfzwk,4150
38
+ pycityagent/utils/__init__.py,sha256=GQEa4x_uJBK19Z57vfm9Omvqg1c4ysi3QJ9wx8xiDhI,524
39
+ pycityagent/utils/survey_util.py,sha256=o-gvmmfus3vMIN-EMWPzfLbHkDH4DfZb8B-yBd_mGYk,2076
40
+ pycityagent/utils/pg_query.py,sha256=KAcnBDLyzUu2il18SGXxk8dySdBen_8ejfpxiWuKUMA,2225
41
+ pycityagent/utils/decorators.py,sha256=Gk3r41hfk6awui40tbwpq3C7wC7jHaRmLRlcJFlLQCE,3160
42
+ pycityagent/utils/parsers/__init__.py,sha256=AN2xgiPxszWK4rpX7zrqRsqNwfGF3WnCA5-PFTvbaKk,281
43
+ pycityagent/utils/parsers/code_block_parser.py,sha256=jy6wHx9zypvJTWneCKuUaLQL19d4yLK6C_awc7y8A-k,1179
44
+ pycityagent/utils/parsers/parser_base.py,sha256=ZbqRcqOBL9hfHVZSltQSQmJnWrtuJS9aYeOJU-FlJ0E,1725
45
+ pycityagent/utils/parsers/json_parser.py,sha256=sakKohUuMcUH2toR85CAG_37D02ZoAn6LlzLgftUjmo,2923
46
+ pycityagent/agent/agent_base.py,sha256=s2jFdGadn9gL9WPXf-WpdaPgY-yjzsxfcZp6VVr1K8M,37996
47
+ pycityagent/agent/__init__.py,sha256=U20yKu9QwSqAx_PHk5JwipfODkDfxONtumVfnsKjWFg,180
48
+ pycityagent/agent/agent.py,sha256=CmgjlH4oBJ0elApYXbmEI33sJ_GKh2KS0bFBY0kUgVE,18874
49
+ pycityagent/cli/wrapper.py,sha256=bAwmfWTXbGld-uiMnIMhKp22IVRQjhLUToknyUDk9rQ,1147
50
+ pycityagent/workflow/__init__.py,sha256=H08Ko3eliZvuuCMajbEri-IP4-SeswYU6UjHBNA4Ze0,490
51
+ pycityagent/workflow/prompt.py,sha256=rzenP4EFGxbWE1aq-x2036b6umKvi5cQx2xtWULwgIk,3392
52
+ pycityagent/workflow/block.py,sha256=WJfCeL8e117GzkVPJCRNsQZZinccMnVyEubkwrf-17U,12295
53
+ pycityagent/workflow/trigger.py,sha256=4nzAwywGQsFabgo6gzp-vD2EV4wII7Z0LHGEAsflSEY,7608
54
+ pycityagent/environment/__init__.py,sha256=fFIth2jxxgZ92cXm-aoM2igHgaSqsYGwtBhyb7opjzk,166
55
+ pycityagent/environment/simulator.py,sha256=bZr167qLth2tK8HtQm_L82OdnG2pM5SeP-iA26A7aRo,21259
56
+ pycityagent/environment/utils/port.py,sha256=3OM6kSUt3PxvDUOlgyiendBtETaWU8Mzk_8H0TzTmYg,295
57
+ pycityagent/environment/utils/grpc.py,sha256=_lB4-k4dTKuNvApaDiYgFxiLTPtYG42DVQtG9yOj9pQ,2022
58
+ pycityagent/environment/utils/base64.py,sha256=hoREzQo3FXMN79pqQLO2jgsDEvudciomyKii7MWljAM,374
59
+ pycityagent/environment/utils/__init__.py,sha256=9FoaNGpNmhWehA-iRQ4m9t85AOtPsCg4TTMDzZJ81Qc,239
60
+ pycityagent/environment/utils/map_utils.py,sha256=iNdsvyrknJT_fWo64TMFW3SB7lbLe2H9hF_l-a4eHE4,5761
61
+ pycityagent/environment/utils/protobuf.py,sha256=0BsM_G7x2B_6DMIBHe9bjVuQDOXUytNRQ03g9e05F3c,1170
62
+ pycityagent/environment/utils/geojson.py,sha256=R5GVMvU1Gn6eteG3L10-f1mQ9tvrnGJJAQ2Uh8djTXk,673
63
+ pycityagent/environment/utils/const.py,sha256=1LqxnYJ8FSmq37fN5kIFlWLwycEDzFa8SFS-8plrFlU,5396
64
+ pycityagent/environment/sim/pause_service.py,sha256=UUTa4pTBOX_MGKki9QDgKId7scch0waAWF9xRVmNlAs,1701
65
+ pycityagent/environment/sim/person_service.py,sha256=T1pRi5jDcivSInX7iGZoHKYZmgO7_t5MYtLhU12_LC4,10793
66
+ pycityagent/environment/sim/aoi_service.py,sha256=bYVJDrOfDn8hgOORDU7PxMaT-fpqXA5Z0A080l2EPBc,1242
67
+ pycityagent/environment/sim/sim_env.py,sha256=szkrZtVrm3NXBxLJ2n_ghOhYtTaDUpVak9krjBXgC8Y,4580
68
+ pycityagent/environment/sim/lane_service.py,sha256=bmf0zOWkxDzMEDlhTdHNRJRiTFGgzjbeqmex387gHZs,3964
69
+ pycityagent/environment/sim/client.py,sha256=x4REWPRFG_C2s0-CWz8MnYalD_esfu2pPHf_vpsCG78,2852
70
+ pycityagent/environment/sim/__init__.py,sha256=CyJc5Tey9MgzomZv0ynAcV0yaUlSE3bPbegYXar8wJc,601
71
+ pycityagent/environment/sim/social_service.py,sha256=Y4A56aKXsjSv18UFumGPjQoJVMcM8Z6uTPI_C9D2PZw,2038
72
+ pycityagent/environment/sim/light_service.py,sha256=q4pKcGrm7WU0h29I1dFIDOz2OV0BM-2s37uC6zokkoA,4290
73
+ pycityagent/environment/sim/clock_service.py,sha256=4Hly8CToghj0x_XbDgGrIZy1YYAlDH0EUGCiCDYpk_I,1375
74
+ pycityagent/environment/sim/road_service.py,sha256=Bb1sreO0Knt9tcqH_WJF-I3P3G92bRAlzDBEa--25GE,1297
75
+ pycityagent/cityagent/metrics.py,sha256=yXZ4uRXARjDAvPKyquut7YWs363nDcIV0J1KQgYacZE,2169
76
+ pycityagent/cityagent/memory_config.py,sha256=52QkS_4wtM-PPTM5xR10IPvG00VOlWogFTOP6BqBrYo,11899
77
+ pycityagent/cityagent/bankagent.py,sha256=uL9ATilEddhJR25qW0p8jX6I9QKGm3gDi1wmJNr6Hbg,4036
78
+ pycityagent/cityagent/__init__.py,sha256=gcBQ-a50XegFtjigQ7xDXRBZrywBKqifiQFSRnEF8gM,572
79
+ pycityagent/cityagent/firmagent.py,sha256=x9Yvrd9j0dSILUm__e9dBT7FBgJ0q7VFzbNUC10Vg5A,3677
80
+ pycityagent/cityagent/nbsagent.py,sha256=2021QjPm2JFhDJ0KKNpEZwtTT8GaGyj2zf6KCKHdL3Y,4059
81
+ pycityagent/cityagent/initial.py,sha256=a8ed-vvagYw8tJY-uzYm_sAja2545QRAEa58Tp4DHck,6130
82
+ pycityagent/cityagent/societyagent.py,sha256=2WSXh-eElgigXfDHOh9KoDU2KCmIatwD2D57cZlh0Fs,20253
83
+ pycityagent/cityagent/message_intercept.py,sha256=dyT1G-nMxKb2prhgtyFFHFz593qBrkk5DnHsHvG1OIc,4418
84
+ pycityagent/cityagent/governmentagent.py,sha256=YoydTQ-LMOF5ZbisxG4vQFaFT9ZS0DzDjb3hQg87YzM,2830
85
+ pycityagent/cityagent/blocks/dispatcher.py,sha256=U5BPeUrjrTyDaznYfT6YUJIW8vfKVRDF4EO0oOn6Td4,2886
86
+ pycityagent/cityagent/blocks/needs_block.py,sha256=LwoH-4WcAF5L8IOW2ytf51QeIghq9D9KspQ92s5k4Nk,15897
87
+ pycityagent/cityagent/blocks/cognition_block.py,sha256=5QWhX2vg1VqYYzm-qBITBhVntaaetePQoa7OqvmXJug,15170
88
+ pycityagent/cityagent/blocks/social_block.py,sha256=QwmfVYa0Q0anMTYsJe8IxMRecJCNEpCuTsm9bo27eEM,15439
89
+ pycityagent/cityagent/blocks/__init__.py,sha256=h6si6WBcVVuglIskKQKA8Cxtf_VKen1sNPqOFKI311Q,420
90
+ pycityagent/cityagent/blocks/economy_block.py,sha256=CCF2xPxwAiMy0PhFis11_tjH0NMYwSnbUx9VUNfIbGg,19061
91
+ pycityagent/cityagent/blocks/utils.py,sha256=uu4iQOYKwIT87AqbT5KT4W8p_UI_dZfuXkyxWto_EQ0,2097
92
+ pycityagent/cityagent/blocks/other_block.py,sha256=LdtL6248xvMvvRQx6NvdlJrWWZFu8Xusjxb9yEh1M0k,4365
93
+ pycityagent/cityagent/blocks/plan_block.py,sha256=LcmG7d9oMezq9TiEerFJyUZytZRg5Zf03B7m6aV7HCI,11465
94
+ pycityagent/cityagent/blocks/mobility_block.py,sha256=YmKhJW_srC6b6n_LvJujSO-eB-13G10BhDnURaVVdj8,15290
95
+ pycityagent/survey/models.py,sha256=g3xni4GcA1Py3vlGt6z4ltutjgQ4G0uINYAM8vKRJAw,5225
96
+ pycityagent/survey/__init__.py,sha256=rxwou8U9KeFSP7rMzXtmtp2fVFZxK4Trzi-psx9LPIs,153
97
+ pycityagent/survey/manager.py,sha256=tHkdeq4lTfAHwvgf4-udsXri0z2l6E00rEbvwl7SqRs,3439
File without changes
@@ -1,198 +0,0 @@
1
- """环境相关的Interaction定义"""
2
-
3
- from enum import Enum
4
- from typing import Callable, Optional, Any
5
- from abc import ABC, abstractmethod
6
- from typing import Callable, Any
7
-
8
-
9
- class ActionType(Enum):
10
- """
11
- 行动类型枚举 所有行动本质上为数据推送
12
- Action Type enumeration, all actions are essentially data push
13
-
14
- Types:
15
- - Sim = 1, 用于表示与模拟器对接的行动
16
- - Hub = 2, 用于表示与AppHub(前端)对接的行动
17
- - Comp = 3, 表示综合类型 (可能同时包含与Sim以及Hub的交互)
18
- """
19
-
20
- Sim = 1
21
- Hub = 2
22
- Comp = 3
23
-
24
-
25
- class Action:
26
- """
27
- - Action
28
- """
29
-
30
- def __init__(
31
- self,
32
- agent,
33
- type: ActionType,
34
- source: Optional[str] = None,
35
- before: Optional[Callable[[list], Any]] = None,
36
- ) -> None:
37
- """
38
- 默认初始化
39
-
40
- Args:
41
- - agent (Agent): the related agent
42
- - type (ActionType)
43
- - source (str): 数据来源, 默认为None, 如果为None则会从接收用户传入的数据作为Forward函数参数, 否则从WM.Reason数据缓存中取对应数据作为参数
44
- - before (function): 数据处理方法, 用于当Reason缓存中的参数与标准格式不符时使用
45
- """
46
- self._agent = agent
47
- self._type = type
48
- self._source = source
49
- self._before = before
50
-
51
- def get_source(self):
52
- """
53
- 获取source数据
54
- """
55
- if self._source != None:
56
- source = self._agent.Brain.Memory.Working.Reason[self._source]
57
- if self._before != None:
58
- source = self._before(source)
59
- return source
60
- else:
61
- return None
62
-
63
- @abstractmethod
64
- async def Forward(self):
65
- """接口函数"""
66
-
67
-
68
- class SimAction(Action):
69
- """SimAction: 模拟器关联Action"""
70
-
71
- def __init__(
72
- self,
73
- agent,
74
- source: Optional[str] = None,
75
- before: Optional[Callable[[list], Any]] = None,
76
- ) -> None:
77
- super().__init__(agent, ActionType.Sim, source, before)
78
-
79
-
80
- class HubAction(Action):
81
- """HubAction: Apphub关联Action"""
82
-
83
- def __init__(
84
- self,
85
- agent,
86
- source: Optional[str] = None,
87
- before: Optional[Callable[[list], Any]] = None,
88
- ) -> None:
89
- super().__init__(agent, ActionType.Hub, source, before)
90
-
91
-
92
- class SetSchedule(SimAction):
93
- """
94
- 用于将agent的行程信息同步至模拟器 —— 仅对citizen类型agent适用
95
- Synchronize agent's schedule to simulator —— only avalable for citizen type of agent
96
- """
97
-
98
- def __init__(
99
- self,
100
- agent,
101
- source: Optional[str] = None,
102
- before: Optional[Callable[[list], Any]] = None,
103
- ) -> None:
104
- super().__init__(agent, source, before)
105
-
106
- async def Forward(self, schedule=None):
107
- """
108
- 如果当前行程已经同步至模拟器: 跳过同步, 否则同步至模拟器
109
- If current schedule has been synchronized to simulator: skip, else sync
110
- """
111
- if not schedule == None:
112
- if not schedule.is_set:
113
- """同步schedule至模拟器"""
114
- self._agent.Scheduler.now.is_set = True
115
- departure_time = schedule.time
116
- mode = schedule.mode
117
- aoi_id = schedule.target_id_aoi
118
- poi_id = schedule.target_id_poi
119
- end = {"aoi_position": {"aoi_id": aoi_id, "poi_id": poi_id}}
120
- activity = schedule.description
121
- trips = [
122
- {
123
- "mode": mode,
124
- "end": end,
125
- "departure_time": departure_time,
126
- "activity": activity,
127
- }
128
- ]
129
- set_schedule = [
130
- {"trips": trips, "loop_count": 1, "departure_time": departure_time}
131
- ]
132
-
133
- # * 与模拟器对接
134
- req = {"person_id": self._agent._id, "schedules": set_schedule}
135
- await self._agent._client.person_service.SetSchedule(req)
136
- elif self._source != None:
137
- schedule = self.get_source()
138
- if schedule != None and not schedule.is_set:
139
- """同步schedule至模拟器"""
140
- self._agent.Scheduler.now.is_set = True
141
- departure_time = schedule.time
142
- mode = schedule.mode
143
- aoi_id = schedule.target_id_aoi
144
- poi_id = schedule.target_id_poi
145
- end = {"aoi_position": {"aoi_id": aoi_id, "poi_id": poi_id}}
146
- activity = schedule.description
147
- trips = [
148
- {
149
- "mode": mode,
150
- "end": end,
151
- "departure_time": departure_time,
152
- "activity": activity,
153
- }
154
- ]
155
- set_schedule = [
156
- {"trips": trips, "loop_count": 1, "departure_time": departure_time}
157
- ]
158
-
159
- # * 与模拟器对接
160
- req = {"person_id": self._agent._id, "schedules": set_schedule}
161
- await self._agent._client.person_service.SetSchedule(req)
162
-
163
-
164
- class SendAgentMessage(SimAction):
165
- """
166
- 发送信息给其他agent
167
- Send messages to other agents
168
- """
169
-
170
- def __init__(
171
- self,
172
- agent,
173
- source: Optional[str] = None,
174
- before: Optional[Callable[[list], Any]] = None,
175
- ) -> None:
176
- super().__init__(agent, source, before)
177
-
178
- async def Forward(self, messages: Optional[dict] = None):
179
- if not messages == None and len(messages) > 0:
180
- req = {"messages": []}
181
- for message in messages:
182
- from_id = self._agent._id
183
- to_id = message["id"]
184
- mes = message["message"]
185
- req["messages"].append({"from": from_id, "to": to_id, "message": mes})
186
- await self._agent._client.social_service.Send(req)
187
- elif self._source != None:
188
- messages = self.get_source()
189
- if not messages == None and len(messages) > 0:
190
- req = {"messages": []}
191
- for message in messages:
192
- from_id = self._agent._id
193
- to_id = message["id"]
194
- mes = message["message"]
195
- req["messages"].append(
196
- {"from": from_id, "to": to_id, "message": mes}
197
- )
198
- await self._agent._client.social_service.Send(req)
File without changes
File without changes