name: agent-based-simulator description: 基于智能体的建模技能,用于模拟具有异质交互智能体的复杂适应系统 allowed-tools:
- Read
- Write
- Glob
- Grep
- Bash
metadata:
specialization: 决策智能
domain: 商业
category: 仿真
priority: lower
tools-libraries:
- mesa
- agentpy
- pyNetLogo
基于智能体的模拟器
概述
基于智能体的模拟器技能提供通过模拟异质、交互的智能体来建模复杂适应系统的能力。它支持自下而上地理解涌现的市场行为、客户动态和竞争互动,为战略决策提供支持。
能力
- 智能体定义与行为建模
- 环境与空间建模
- 交互规则设定
- 涌现行为观察
- 参数扫描
- 集成模拟运行
- 可视化与动画
- 结果统计分析
使用流程
- 战争推演与竞争响应建模
- 市场规模与机会评估
- 客户细分分析
使用方法
智能体定义
# 定义客户智能体
customer_agent = {
"type": "Customer",
"attributes": {
"budget": {"distribution": "normal", "mean": 1000, "std": 200},
"brand_loyalty": {"distribution": "uniform", "min": 0, "max": 1},
"price_sensitivity": {"distribution": "beta", "alpha": 2, "beta": 5},
"preferred_features": ["功能列表"]
},
"behaviors": {
"purchase_decision": {
"triggers": ["需求产生", "看到促销"],
"evaluation": "加权效用",
"factors": ["价格", "质量", "品牌匹配度"]
},
"word_of_mouth": {
"probability": 0.3,
"reach": {"distribution": "poisson", "lambda": 5},
"sentiment_spread": True
},
"brand_switching": {
"threshold": 0.7,
"factors": ["满意度", "竞争对手促销"]
}
}
}
环境定义
# 定义市场环境
environment = {
"topology": "network", # 或 "grid", "continuous"
"network_type": "small_world",
"network_params": {"k": 6, "p": 0.1},
"global_properties": {
"economic_condition": {"initial": "normal", "transitions": "markov"},
"market_size": 10000,
"growth_rate": 0.02
}
}
交互规则
# 定义交互规则
interactions = {
"customer_customer": {
"information_sharing": {
"probability": "基于关系",
"content": ["产品体验", "价格信息"]
},
"social_influence": {
"mechanism": "阈值模型",
"threshold_distribution": "normal"
}
},
"customer_company": {
"purchase": {
"frequency": "基于需求",
"channel": ["线上", "线下", "混合"]
},
"complaint": {
"trigger": "满意度 < 0.3",
"resolution_impact": 0.5
}
},
"company_company": {
"price_competition": "古诺|伯特兰|斯塔克尔伯格",
"market_signaling": True
}
}
模拟配置
# 模拟设置
simulation_config = {
"time_steps": 365,
"agents": {
"Customer": 5000,
"Company": 3
},
"ensemble_runs": 100,
"parameter_sweep": {
"price_sensitivity_mean": [0.3, 0.5, 0.7],
"word_of_mouth_probability": [0.1, 0.3, 0.5]
},
"data_collection": {
"agent_level": ["satisfaction", "brand_choice"],
"model_level": ["market_shares", "total_revenue", "gini_coefficient"]
}
}
输入模式
{
"agents": {
"agent_type": {
"count": "number",
"attributes": "object",
"behaviors": "object"
}
},
"environment": {
"topology": "string",
"properties": "object"
},
"interactions": "object",
"simulation_config": {
"time_steps": "number",
"ensemble_runs": "number",
"parameter_sweep": "object",
"random_seed": "number"
}
}
输出模式
{
"summary_statistics": {
"metric_name": {
"mean": "number",
"std": "number",
"percentiles": "object",
"time_series": ["number"]
}
},
"emergent_patterns": [
{
"pattern": "string",
"frequency": "number",
"conditions": "object"
}
],
"parameter_sweep_results": {
"parameter_combination": {
"outcomes": "object"
}
},
"agent_trajectories": "object (sample)",
"network_metrics": {
"clustering_coefficient": "number",
"average_path_length": "number",
"degree_distribution": "object"
},
"visualization_paths": ["string"]
}
最佳实践
- 从简单的智能体开始,逐步增加复杂性
- 根据现实世界观察验证智能体行为
- 使用集成运行来考虑随机变异性
- 对关键参数进行敏感性分析
- 记录所有行为规则及其合理性
- 在极端条件下测试涌现行为
- 在可用时与聚合级数据进行比较
使用案例
| 使用案例 | 智能体类型 | 关键行为 |
|---|---|---|
| 市场动态 | 客户、公司 | 购买、定价 |
| 创新扩散 | 采纳者、影响者 | 采纳、沟通 |
| 供应链 | 供应商、分销商、零售商 | 订购、库存 |
| 意见形成 | 公民、媒体 | 影响、信息传播 |
集成点
- 与系统动力学建模器连接,用于混合方法
- 为竞争场景提供战争推演编排器
- 支持场景叙事生成器,用于故事线创建
- 与蒙特卡洛引擎集成,用于不确定性传播