资源简介
SUMO Simulation of Urban MObility is an open source highly portable microscopic and continuous road traffic simulation package designed to handle large road networks It is mainly developed by employees of the Institute of Transportation Systems at the German Aerospace Center SUMO is open source licensed under the GPL ">SUMO Simulation of Urban MObility is an open source highly portable microscopic and continuous road traffic simulation package designed to handle large road networks It is mainly developed by employees of the Institute of Transportation Systems at the German Aerospace Center SUMO is open sourc [更多]
代码片段和文件信息
#!/usr/bin/env python
“““
@file agentManager.py
@author Michael Behrisch
@author Daniel Krajzewicz
@date 2008-10-09
@version $Id: agentManager.py 14678 2013-09-11 08:53:06Z behrisch $
Control the CityMobil parking lot with a multi agent system.
SUMO Simulation of Urban MObility; see http://sumo.sourceforge.net/
Copyright (C) 2008-2012 DLR (http://www.dlr.de/) and contributors
This file is part of SUMO.
SUMO is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License or
(at your option) any later version.
“““
import vehicleControl statistics
from constants import *
class PersonAgent:
def __init__(self id):
self.id = id
def startRequest(self source target cybers):
minCost = INFINITY
minCar = None
for car in cybers:
cost = car.request(self source target)
if (cost < minCost):
if minCar:
minCar.reject(self)
minCar = car
minCost = cost
else:
car.reject(self)
minCar.accept(self)
class Task:
def __init__(self person source target estCost):
self.person = person
self.source = source
self.target = target
self.estCost = estCost
self.startStep = None
def __repr__(self):
return “<%s %s %s %s>“ % (self.person.id self.source self.target self.startStep)
class CyberAgent:
def __init__(self id):
self.id = id
self.load = 0
self.pending = {}
self.tasks = []
self.running = []
self.costMatrix = {}
self.totalEstimatedCost = 0
self.position = None
self.broken = False
def request(self person source target):
if self.broken:
estCost = INFINITY
elif (source target) in self.costMatrix:
estCost = self.costMatrix[(source target)]
else:
estCost = 2 * DOUBLE_ROWS * ROW_DIST / CYBER_SPEED
self.pending[person] = Task(person source target estCost)
return self.totalEstimatedCost + estCost
def accept(self person):
task = self.pending[person]
self.tasks.append(task)
self.totalEstimatedCost += task.estCost
del self.pending[person]
def reject(self person):
del self.pending[person]
def _findNextTarget(self wait):
minTarget = “z“
minDownstreamTarget = “z“
minSource = “z“
minDownstreamSource = “z“
edge = vehicleControl.getPosition(self.id)
if edge == “cyberin“:
edge = “cyber“
for task in self.running:
if task.target < minTarget:
minTarget = task.target
if task.target < minDownstreamTarget and task.target > edge:
minDownstreamTar
相关资源
- ns2下leach协议源码
- windows cygwin ns2安装步骤
- 基于ZigBee无线传感网络技术的污染气
- An investigation into effects of Argon anneali
- ns-2.34安装包
- NS2的Wimax仿真扩展包
- NS2 2.35版本
- AODV的NS2仿真
- NS2工作环境安装图文详解
- sumo车辆仿真
- gpsr协议源码
- 基于NS2的AdHoc网络路由仿真研究
- ns2车联网协议添加
- ns2中文教程,讲的很详细
- NS2手册包括英文版和精美中文版还有
- Data Clustering Theory Algorithms and Applicat
- ns2.34可以使用的leach文件
- ns2 leach
- leach协议的MIT源码及详细仿真过程亲测
- LEACH协议源码及NS2下安装教程
- NS2 TCL脚本
- 交通仿真软件SUMO的基本使用方法
- 城市交通仿真平台SUMO(V1.3).pdf
- Manifold learning theory and applications2011清
- ns2中文手册
- wintwins23
- sumo用户手册
- 这是我做的一个基于NS2的ADHOC网络路由
- AODV路由协议NS2仿真
- NS2 资料全集 中文版
评论
共有 条评论