pycityagent 2.0.0a83__cp39-cp39-macosx_11_0_arm64.whl → 2.0.0a84__cp39-cp39-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.
- pycityagent/cityagent/blocks/economy_block.py +8 -0
- pycityagent/economy/econ_client.py +6 -3
- pycityagent/environment/simulator.py +3 -3
- pycityagent/pycityagent-sim +0 -0
- pycityagent/simulation/simulation.py +14 -21
- {pycityagent-2.0.0a83.dist-info → pycityagent-2.0.0a84.dist-info}/METADATA +2 -2
- {pycityagent-2.0.0a83.dist-info → pycityagent-2.0.0a84.dist-info}/RECORD +11 -11
- {pycityagent-2.0.0a83.dist-info → pycityagent-2.0.0a84.dist-info}/LICENSE +0 -0
- {pycityagent-2.0.0a83.dist-info → pycityagent-2.0.0a84.dist-info}/WHEEL +0 -0
- {pycityagent-2.0.0a83.dist-info → pycityagent-2.0.0a84.dist-info}/entry_points.txt +0 -0
- {pycityagent-2.0.0a83.dist-info → pycityagent-2.0.0a84.dist-info}/top_level.txt +0 -0
@@ -112,6 +112,14 @@ class ConsumptionBlock(Block):
|
|
112
112
|
for i in range(len(firms_id)):
|
113
113
|
demand_each_firm.append(int(consumption_each_firm[i]//prices[i]))
|
114
114
|
real_consumption = await self.economy_client.calculate_consumption(firms_id, agent_id, demand_each_firm)
|
115
|
+
if real_consumption == -1:
|
116
|
+
node_id = await self.memory.stream.add_economy(description=f"I failed to buy goods, cause I do not have enough money.")
|
117
|
+
return {
|
118
|
+
'success': False,
|
119
|
+
'evaluation': f"I failed to buy goods, cause I do not have enough money.",
|
120
|
+
'consumed_time': 0,
|
121
|
+
'node_id': node_id
|
122
|
+
}
|
115
123
|
node_id = await self.memory.stream.add_economy(description=f"I bought some goods, and spent {real_consumption:.1f} on {intention}")
|
116
124
|
evaluation = {
|
117
125
|
'success': True,
|
@@ -504,7 +504,7 @@ class EconomyClient:
|
|
504
504
|
|
505
505
|
async def calculate_taxes_due(
|
506
506
|
self,
|
507
|
-
org_id:
|
507
|
+
org_id: int,
|
508
508
|
agent_ids: list[int],
|
509
509
|
incomes: list[float],
|
510
510
|
enable_redistribution: bool,
|
@@ -523,7 +523,6 @@ class EconomyClient:
|
|
523
523
|
"""
|
524
524
|
start_time = time.time()
|
525
525
|
log = {"req": "calculate_taxes_due", "start_time": start_time, "consumption": 0}
|
526
|
-
# TODO: support multiple org
|
527
526
|
request = org_service.CalculateTaxesDueRequest(
|
528
527
|
government_id=org_id,
|
529
528
|
agent_ids=agent_ids,
|
@@ -569,7 +568,11 @@ class EconomyClient:
|
|
569
568
|
)
|
570
569
|
log["consumption"] = time.time() - start_time
|
571
570
|
self._log_list.append(log)
|
572
|
-
|
571
|
+
if response.success:
|
572
|
+
return response.actual_consumption
|
573
|
+
else:
|
574
|
+
return -1
|
575
|
+
|
573
576
|
|
574
577
|
async def calculate_real_gdp(self, nbs_id: int):
|
575
578
|
start_time = time.time()
|
@@ -114,7 +114,7 @@ class Simulator:
|
|
114
114
|
map_file=_map_pb_path,
|
115
115
|
max_day=config["simulator"].get("max_day", 1000),
|
116
116
|
start_step=config["simulator"].get("start_step", 28800),
|
117
|
-
total_step=24*60*60,
|
117
|
+
total_step=config["simulator"].get("total_step", 24*60*60*365),
|
118
118
|
log_dir=config["simulator"].get("log_dir", "./log"),
|
119
119
|
min_step_time=config["simulator"].get("min_step_time", 1000),
|
120
120
|
sim_addr=config["simulator"].get("server", None),
|
@@ -363,7 +363,7 @@ class Simulator:
|
|
363
363
|
log = {"req": "get_simulator_day", "start_time": start_time, "consumption": 0}
|
364
364
|
now = await self._client.clock_service.Now({})
|
365
365
|
now = cast(dict[str, int], now)
|
366
|
-
day = now["
|
366
|
+
day = int(now["t"]//(24*60*60))
|
367
367
|
log["consumption"] = time.time() - start_time
|
368
368
|
self._log_list.append(log)
|
369
369
|
return day
|
@@ -385,7 +385,7 @@ class Simulator:
|
|
385
385
|
now = cast(dict[str, int], now)
|
386
386
|
log["consumption"] = time.time() - start_time
|
387
387
|
self._log_list.append(log)
|
388
|
-
return now["t"]
|
388
|
+
return now["t"]%(24*60*60)
|
389
389
|
|
390
390
|
async def get_person(self, person_id: int) -> dict:
|
391
391
|
"""
|
pycityagent/pycityagent-sim
CHANGED
Binary file
|
@@ -1019,24 +1019,9 @@ class AgentSimulation:
|
|
1019
1019
|
- None
|
1020
1020
|
"""
|
1021
1021
|
try:
|
1022
|
-
# check whether insert agents
|
1023
|
-
simulator_day = await self._simulator.get_simulator_day()
|
1024
|
-
need_insert_agents = False
|
1025
|
-
if simulator_day > self._simulator_day:
|
1026
|
-
need_insert_agents = True
|
1027
|
-
self._simulator_day = simulator_day
|
1028
|
-
if need_insert_agents:
|
1029
|
-
await self.resume_simulator()
|
1030
|
-
insert_tasks = []
|
1031
|
-
for group in self._groups.values():
|
1032
|
-
insert_tasks.append(group.insert_agent.remote())
|
1033
|
-
await asyncio.gather(*insert_tasks)
|
1034
|
-
|
1035
1022
|
# step
|
1036
1023
|
simulator_day = await self._simulator.get_simulator_day()
|
1037
|
-
simulator_time = int(
|
1038
|
-
await self._simulator.get_simulator_second_from_start_of_day()
|
1039
|
-
)
|
1024
|
+
simulator_time = int(await self._simulator.get_simulator_second_from_start_of_day())
|
1040
1025
|
logger.info(
|
1041
1026
|
f"Start simulation day {simulator_day} at {simulator_time}, step {self._total_steps}"
|
1042
1027
|
)
|
@@ -1113,12 +1098,20 @@ class AgentSimulation:
|
|
1113
1098
|
monitor_task = asyncio.create_task(self._monitor_exp_status(stop_event))
|
1114
1099
|
|
1115
1100
|
try:
|
1116
|
-
|
1117
|
-
await self._simulator.get_time() + day * 24 * 3600
|
1118
|
-
) # type:ignore
|
1101
|
+
end_day = self._simulator_day + day
|
1119
1102
|
while True:
|
1120
|
-
|
1121
|
-
|
1103
|
+
current_day = await self._simulator.get_simulator_day()
|
1104
|
+
# check whether insert agents
|
1105
|
+
need_insert_agents = False
|
1106
|
+
if current_day > self._simulator_day:
|
1107
|
+
self._simulator_day = current_day
|
1108
|
+
# if need_insert_agents:
|
1109
|
+
# insert_tasks = []
|
1110
|
+
# for group in self._groups.values():
|
1111
|
+
# insert_tasks.append(group.insert_agent.remote())
|
1112
|
+
# await asyncio.gather(*insert_tasks)
|
1113
|
+
|
1114
|
+
if current_day >= end_day: # type:ignore
|
1122
1115
|
break
|
1123
1116
|
(
|
1124
1117
|
llm_log_list,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: pycityagent
|
3
|
-
Version: 2.0.
|
3
|
+
Version: 2.0.0a84
|
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.
|
48
|
+
Requires-Dist: pycityproto>=2.2.4
|
49
49
|
Requires-Dist: requests>=2.32.3
|
50
50
|
Requires-Dist: Shapely>=2.0.6
|
51
51
|
Requires-Dist: PyYAML>=6.0.2
|
@@ -1,16 +1,10 @@
|
|
1
|
-
pycityagent-
|
2
|
-
pycityagent-2.0.0a83.dist-info/LICENSE,sha256=n2HPXiupinpyHMnIkbCf3OTYd3KMqbmldu1e7av0CAU,1084
|
3
|
-
pycityagent-2.0.0a83.dist-info/WHEEL,sha256=md3JO_ifs5j508p3TDNMgtQVtnQblpGEt_Wo4W56l8Y,107
|
4
|
-
pycityagent-2.0.0a83.dist-info/entry_points.txt,sha256=BZcne49AAIFv-hawxGnPbblea7X3MtAtoPyDX8L4OC4,132
|
5
|
-
pycityagent-2.0.0a83.dist-info/top_level.txt,sha256=yOmeu6cSXmiUtScu53a3s0p7BGtLMaV0aff83EHCTic,43
|
6
|
-
pycityagent-2.0.0a83.dist-info/METADATA,sha256=XmwytGxXKWAS-M9uFrfJ3Csu1jkQhXN1Po0ZBUyc5nI,9110
|
7
|
-
pycityagent/pycityagent-sim,sha256=MmiGNhZgGjXYLJ2EYTGMhfGAZU8TnU7ORsJ6kdtzjDs,36973378
|
1
|
+
pycityagent/pycityagent-sim,sha256=Ax6cjHjT8VcT5t07VboL_Ruor2eXSdSEml4Jvv-L5dQ,36972594
|
8
2
|
pycityagent/__init__.py,sha256=PUKWTXc-xdMG7px8oTNclodsILUgypANj2Z647sY63k,808
|
9
3
|
pycityagent/pycityagent-ui,sha256=Ur95yZygIaZ5l_CDqP9394M5GQ66iV5PkcNPYFWqzvk,41225346
|
10
4
|
pycityagent/metrics/mlflow_client.py,sha256=-iyh4BPVnBkluhmfucUzibCUnBX2iftkz4tVJJVxwHw,6958
|
11
5
|
pycityagent/metrics/__init__.py,sha256=X08PaBbGVAd7_PRGLREXWxaqm7nS82WBQpD1zvQzcqc,128
|
12
6
|
pycityagent/economy/__init__.py,sha256=aonY4WHnx-6EGJ4WKrx4S-2jAkYNLtqUA04jp6q8B7w,75
|
13
|
-
pycityagent/economy/econ_client.py,sha256=
|
7
|
+
pycityagent/economy/econ_client.py,sha256=NUzrFzl0EL4UkMscGRRSu1JQmeCPwIkPvTbJDRefUcQ,29231
|
14
8
|
pycityagent/tools/__init__.py,sha256=y7sMVMHf0AbivlczM2h-kr7mkgXK-WAx3S9BXLXkWvw,235
|
15
9
|
pycityagent/tools/tool.py,sha256=4ZJSHbNM8dfAVwZEw8T0a2_9OuPsPQpKSVL4WxZVBUc,9022
|
16
10
|
pycityagent/llm/llmconfig.py,sha256=6AqCMV4B_JqBD2mb98bLGzpUdlOCnziQKae-Hhxxp-E,469
|
@@ -27,7 +21,7 @@ pycityagent/memory/utils.py,sha256=oJWLdPeJy_jcdKcDTo9JAH9kDZhqjoQhhv_zT9qWC0w,8
|
|
27
21
|
pycityagent/memory/const.py,sha256=nFmjvt-8FEB0hc0glOH3lliqJhkhf3D_NKxWI0pf6TY,936
|
28
22
|
pycityagent/memory/faiss_query.py,sha256=KPeyzIjD0dzkxr-TlOeCiIlkdh1WAyyipCAXUEt97Lk,17350
|
29
23
|
pycityagent/memory/state.py,sha256=JFCBuK1AS-HqscvdGS9ATF9AUU8t29_2leDY_6iO2_4,5158
|
30
|
-
pycityagent/simulation/simulation.py,sha256=
|
24
|
+
pycityagent/simulation/simulation.py,sha256=08xtIVwmO35r5XbUW9nMDo9rL_6mtDtjWbeXnUyNR6c,49340
|
31
25
|
pycityagent/simulation/__init__.py,sha256=u1WpgwVxPboXWMxrUQKMXJNmTKQYAeCaqZv9HmSxESY,118
|
32
26
|
pycityagent/simulation/agentgroup.py,sha256=oXo2iRUThh_96JhXHMufT8_BPx0PrlwqbMpiVqK_viA,36957
|
33
27
|
pycityagent/simulation/storage/pg.py,sha256=xRshSOGttW-p0re0fNBOjOpb-nQ5msIE2LsdT79_E_Y,8425
|
@@ -52,7 +46,7 @@ pycityagent/workflow/prompt.py,sha256=rzenP4EFGxbWE1aq-x2036b6umKvi5cQx2xtWULwgI
|
|
52
46
|
pycityagent/workflow/block.py,sha256=WJfCeL8e117GzkVPJCRNsQZZinccMnVyEubkwrf-17U,12295
|
53
47
|
pycityagent/workflow/trigger.py,sha256=4nzAwywGQsFabgo6gzp-vD2EV4wII7Z0LHGEAsflSEY,7608
|
54
48
|
pycityagent/environment/__init__.py,sha256=fFIth2jxxgZ92cXm-aoM2igHgaSqsYGwtBhyb7opjzk,166
|
55
|
-
pycityagent/environment/simulator.py,sha256=
|
49
|
+
pycityagent/environment/simulator.py,sha256=qiqeRQDm7cprFJhAkxtdBNAvohiGGUaNIPGyFXmPdZU,22667
|
56
50
|
pycityagent/environment/utils/port.py,sha256=3OM6kSUt3PxvDUOlgyiendBtETaWU8Mzk_8H0TzTmYg,295
|
57
51
|
pycityagent/environment/utils/grpc.py,sha256=_lB4-k4dTKuNvApaDiYgFxiLTPtYG42DVQtG9yOj9pQ,2022
|
58
52
|
pycityagent/environment/utils/base64.py,sha256=hoREzQo3FXMN79pqQLO2jgsDEvudciomyKii7MWljAM,374
|
@@ -87,7 +81,7 @@ pycityagent/cityagent/blocks/needs_block.py,sha256=NYKrGDoYCuXoupMNMuSNhx4Ci1paC
|
|
87
81
|
pycityagent/cityagent/blocks/cognition_block.py,sha256=yzjB0D_95vytpa5xiVdmTSpGp8H9HXcjWzzFN0OpP0k,15398
|
88
82
|
pycityagent/cityagent/blocks/social_block.py,sha256=eedOlwRTGI47QFELYmfe2a_aj0GuHJweSyDxA6AYXcU,15493
|
89
83
|
pycityagent/cityagent/blocks/__init__.py,sha256=h6si6WBcVVuglIskKQKA8Cxtf_VKen1sNPqOFKI311Q,420
|
90
|
-
pycityagent/cityagent/blocks/economy_block.py,sha256=
|
84
|
+
pycityagent/cityagent/blocks/economy_block.py,sha256=SSqb2qX5cVQ1zM8hyxvhnyTwgGwUrV2YViKtGRXmJhQ,20079
|
91
85
|
pycityagent/cityagent/blocks/utils.py,sha256=K--6odjUDUu9YrwrHPaiPIHryo7m_MBmcBqDAy3cV5M,1816
|
92
86
|
pycityagent/cityagent/blocks/other_block.py,sha256=LdtL6248xvMvvRQx6NvdlJrWWZFu8Xusjxb9yEh1M0k,4365
|
93
87
|
pycityagent/cityagent/blocks/plan_block.py,sha256=A5DvtXIy98MZkRGUQmp26grNI5i0BVbl3aEM_Ebd6Z4,11271
|
@@ -95,3 +89,9 @@ pycityagent/cityagent/blocks/mobility_block.py,sha256=qkRiV0nkGOUUoo9lGIjAFE_Hl0
|
|
95
89
|
pycityagent/survey/models.py,sha256=g3xni4GcA1Py3vlGt6z4ltutjgQ4G0uINYAM8vKRJAw,5225
|
96
90
|
pycityagent/survey/__init__.py,sha256=rxwou8U9KeFSP7rMzXtmtp2fVFZxK4Trzi-psx9LPIs,153
|
97
91
|
pycityagent/survey/manager.py,sha256=tHkdeq4lTfAHwvgf4-udsXri0z2l6E00rEbvwl7SqRs,3439
|
92
|
+
pycityagent-2.0.0a84.dist-info/RECORD,,
|
93
|
+
pycityagent-2.0.0a84.dist-info/LICENSE,sha256=n2HPXiupinpyHMnIkbCf3OTYd3KMqbmldu1e7av0CAU,1084
|
94
|
+
pycityagent-2.0.0a84.dist-info/WHEEL,sha256=md3JO_ifs5j508p3TDNMgtQVtnQblpGEt_Wo4W56l8Y,107
|
95
|
+
pycityagent-2.0.0a84.dist-info/entry_points.txt,sha256=BZcne49AAIFv-hawxGnPbblea7X3MtAtoPyDX8L4OC4,132
|
96
|
+
pycityagent-2.0.0a84.dist-info/top_level.txt,sha256=yOmeu6cSXmiUtScu53a3s0p7BGtLMaV0aff83EHCTic,43
|
97
|
+
pycityagent-2.0.0a84.dist-info/METADATA,sha256=wK7JDsxgO5pTlH_YLtftS9-nmD9T97_6-YZp8zru9dA,9110
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|