-
Notifications
You must be signed in to change notification settings - Fork 2
エージェントの歩き方
noda50 edited this page Jan 3, 2015
·
9 revisions
- event 発生のチェック。(event.checkIfHappend())
- エージェント生成のチェック。(factory.tryUpdateAndGenerate())
- エージェントの追加。(agents.addAll(generated_agents_step))
- effectiveLink の操作(意味不明)
- すべてのリンクに対し、 link.preUpdate()。 なかでは、Agent の並べ替えと、lane への配置をおこなっている。
- すべてのエージェントに対し、agent.preUpdate()。 link 順、lane 順、Agent の前後順で処理。
- すべてのリンクに対して、link.update()。
- すべてのエージェントに対して agent.update()。 順番は、agents 配列に入っている順。 避難完了しているエージェントは、それなりの処理。 その後、ログへの吐き出し。 最後に averageSpeed を計算。
- pollution の処理。
- agentView の処理。
- next_link_candidate はクリア。
- calc_speed() を呼び出して、速度計算。
- move_set() 呼び出し。
- d は、speed に direction を掛けたものになっている。なので、逆方向の場合、負の数。
- もし STOP_TIMES のリンク上で、Stop 状態なら、 speed を0、next_position を現在の position と同じにして、すぐに戻る。
- 実際に動く距離 (distance_to_move) の計算。
- next_position を、次の位置に。
- (next_position, current_link, next_node, routePlan の index) を (next_position_tmp, link, node, route_index_orig) に入れておく。
- もし、next_position_tmp が link の範囲を超えていたら、以下を繰り返す。 0. on_node を true にして navigate() を呼び出し、次のリンク (next_link) を求める。 0. next_link に入る準備(next_link.registerEnter()) 0. on_node は false に。 0. distance_to_move は、残りの移動距離に。この際、正の数にする。 0. link を next_linkに、node も次のものにする。 0. next_position_tmp を、direction にあわせて修正。
- routePlan の index を元に戻す。
- 終わっていたり、goal にたどり着いていれば、終了。
- move_commit() 呼び出し。
- next_position を position にする。
- position がリンク外になっていたら、以下の処理。 0. 到達したノードがゴールなら、終了。 0. 次のリンクで進むべき距離を求め、distance_to_move に保存。 0. navigate(time, current_link next_node) を呼び出す。 0. tryToPassNode(time) を呼び出す。 0. distance_to_move に応じて移った先のリンク上での position を記録。
- node_now からの道を、way_candidates にいれる。
- 例外処理。
- way_candidates が空なら、なにかおかしい。
- way_candidates が1つしかなければ、それを返す。
- goal が設定されていなければ、元に戻る。
- sane_navigation(time, way_candidates)を呼び出す。結果は target に。
- target が空でなければ、それを返す。
- target が空なら、ランダムに道を選んで返す。
- sane_navigation_from_node(time, current_link, next_node) を呼び出す。 way_candidates は結局、使わない。
- 前回と同じなら、キャッシュしたものを返す。
- node から伸びる道を way_candidates にいれる。
- way_candidates から、コスト最小のものを見つける。以下の例外処理を含む。
- goal のタグを含む道があるなら、それが答えなので、それを返す。
- 同様に中継タグを持つならそれを返す。 routePlan は進めておく。
- 同コストのものがあれば、それらからランダムに選ぶ。
- Agent は、prev_node,current_link,next_node を保持。このうち、next_node を超えようとしている。 次に行くリンクは、next_link_candidate に保持。
- recordTrail(time)で経路記録。
- current_link から Agent が抜ける。(agentExits(this))
- まず prev_node を進める(=next_node と同じとする)
- previous_link に current_link を退避。
- current_link を進める。(=next_link_candidateと同じとする)
- next_link_candidate の、進行方向先のノードを、node_now とする。
- node_now から繋がる道のリストを way_candidates とする。(swing の決定に利用するらしい。)
- direction を、direction_orig に退避。
- calc_next_target(next_node) で、必要に応じて routePlan を進める。
- next_node を進める。同時に position と direction のセット。
- 移った先のリンクにAgentが入っていく。(agentEnters(this))
- current_link がゴールで、他のプランを持たない場合は、終了。
- on_node が true で、サブゴールにたどり着いていれば、routePlan をシフト。
- routePlan が空でなければ、そのトップからサブゴールをとる。 そのサブゴールへの経路情報(hint)がnodeに書かれていれば、それを返す。 そうでないなら、routePlan をさらに shift。
- routePlan がからになったら、goal を返す。