当前位置: 首页>>代码示例>>Python>>正文


Python Actor.route方法代码示例

本文整理汇总了Python中actor.Actor.route方法的典型用法代码示例。如果您正苦于以下问题:Python Actor.route方法的具体用法?Python Actor.route怎么用?Python Actor.route使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在actor.Actor的用法示例。


在下文中一共展示了Actor.route方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _fill

# 需要导入模块: from actor import Actor [as 别名]
# 或者: from actor.Actor import route [as 别名]
	def _fill(self, fill_config, actor_config):
		""" 
		Initial filling of lots. 
		First, the configuration files of the simulation scenario are parsed, then every lot is filled to its specified value.
		The actors' parameters which are used to fill the lot are taken from the config JSOBN via a weighted random choice.
		"""

		''' parse config files '''
		fill_file = open(os.path.dirname(__file__) +  "/" + fill_config)
		fill_json = json.load(fill_file)
		init_attributes = fill_json

		actor_file = open(os.path.dirname(__file__) +  "/" + actor_config)
		actor_json = json.load(actor_file)
		actor_attributes = actor_json

		for i,lot in enumerate(self.lots):
			self.percent_occupancy = 0

			# do until the lot is full
			while self.percent_occupancy < 70:

				# get size of actor
				size_choices = [(ix*0.5, el) for ix, el in enumerate(actor_attributes["residential"]["size_distribution"])]
				size = wr.choice(size_choices)

				# get remaining parking time of actor
				remaining_park_time_choices = [(ix, el) for ix, el in enumerate(init_attributes["remaining_duration"])]
				# parking_time = wr.choice(remaining_park_time_choices) + random.randint(0,1800)
				parking_time = wr.choice(remaining_park_time_choices)*3600 + random.randint(-1800,1800)

				# build actor attributes
				params = {
					"size": size,
					"color": actor_attributes["residential"]["color"],
					"name": actor_attributes["residential"]["name"],
					"forbidden_lot_types": actor_attributes["residential"]["forbidden_lot_types"],
					"pos":  lot.geometry.coords[0],
					"rot": 0,
					"speed": 0,
					"target_speed": 0,
					"target_location": None,
					"target_node_id": None,
					"parking_start_time": self.simulation.start_time,
					"parking_time": parking_time-self.simulation.start_time,
					"parking_size": size + 2 * random.random(),
					"search_tolerance": random.gauss(0.6, 0.1),
					"max_search_time": 0,
					"init_time": 0,
					"technology": None
				}

				# look for space , occupy and initialize actor there
				space = lot.look_for_space(params["pos"], params["parking_size"])
				if space == False:
					percent_occupancy = lot.lot_percentage()
					break
				else:
					#create actor
					actor = Actor(self.simulation.actor_manager, self.simulation.router, params, {"lot": lot, "space":space})

					# occupy, place and add actor to lot
					lot.occupy(space)
					self.simulation.actor_manager.add(actor)

					# give current edge parameters to actor:
					actor.current_route_element = {
						"eid": lot.edge[2]["eid"],
						"start_node":lot.edge[2]["start_nid"],
						"end_node":lot.edge[2]["end_nid"],
						"start_pos": lot.edge[2]["geom"].coords[0],
						"end_pos": lot.edge[2]["geom"].coords[-1],
						"vecs": []
					}
					actor.route = []

				self.percent_occupancy = lot.lot_percentage()


		print "--> filled lots with initial data"
开发者ID:chriserik,项目名称:ipasum,代码行数:82,代码来源:lot.py


注:本文中的actor.Actor.route方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。