Skip to content

エージェントの歩き方

noda50 edited this page Jan 3, 2015 · 9 revisions

AgentHandler

update(nodes, links, time)

  1. event 発生のチェック。(event.checkIfHappend())
  2. エージェント生成のチェック。(factory.tryUpdateAndGenerate())
  3. エージェントの追加。(agents.addAll(generated_agents_step))
  4. effectiveLink の操作(意味不明)
  5. すべてのリンクに対し、 link.preUpdate()。 なかでは、Agent の並べ替えと、lane への配置をおこなっている。
  6. すべてのエージェントに対し、agent.preUpdate()。 link 順、lane 順、Agent の前後順で処理。
  7. すべてのリンクに対して、link.update()。
  8. すべてのエージェントに対して agent.update()。 順番は、agents 配列に入っている順。 避難完了しているエージェントは、それなりの処理。 その後、ログへの吐き出し。 最後に averageSpeed を計算。
  9. pollution の処理。
  10. agentView の処理。

RunningAroundPersion

preUpdate(time)

  1. next_link_candidate はクリア。
  2. calc_speed() を呼び出して、速度計算。
  3. move_set() 呼び出し。

move_set(d, time, will_move_out) // LANE もしくは DENSITY の場合の move_set

  1. d は、speed に direction を掛けたものになっている。なので、逆方向の場合、負の数。
  2. もし STOP_TIMES のリンク上で、Stop 状態なら、 speed を0、next_position を現在の position と同じにして、すぐに戻る。
  3. 実際に動く距離 (distance_to_move) の計算。
  4. next_position を、次の位置に。
  5. (next_position, current_link, next_node, routePlan の index) を (next_position_tmp, link, node, route_index_orig) に入れておく。
  6. もし、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 にあわせて修正。
  7. routePlan の index を元に戻す。

update(time)

  1. 終わっていたり、goal にたどり着いていれば、終了。
  2. move_commit() 呼び出し。

move_commit(time)

  1. next_position を position にする。
  2. position がリンク外になっていたら、以下の処理。 0. 到達したノードがゴールなら、終了。 0. 次のリンクで進むべき距離を求め、distance_to_move に保存。 0. navigate(time, current_link next_node) を呼び出す。 0. tryToPassNode(time) を呼び出す。 0. distance_to_move に応じて移った先のリンク上での position を記録。

navigate(time, link_now, node_now)

  1. node_now からの道を、way_candidates にいれる。
  2. 例外処理。
    • way_candidates が空なら、なにかおかしい。
    • way_candidates が1つしかなければ、それを返す。
    • goal が設定されていなければ、元に戻る。
  3. sane_navigation(time, way_candidates)を呼び出す。結果は target に。
  4. target が空でなければ、それを返す。
  5. target が空なら、ランダムに道を選んで返す。

sane_navivation(time, way_candidates)

  1. sane_navigation_from_node(time, current_link, next_node) を呼び出す。 way_candidates は結局、使わない。

savigation_from_node(time, link, node)

  1. 前回と同じなら、キャッシュしたものを返す。
  2. node から伸びる道を way_candidates にいれる。
  3. way_candidates から、コスト最小のものを見つける。以下の例外処理を含む。
    • goal のタグを含む道があるなら、それが答えなので、それを返す。
    • 同様に中継タグを持つならそれを返す。 routePlan は進めておく。
  4. 同コストのものがあれば、それらからランダムに選ぶ。

tryToPassNode(time)

  1. Agent は、prev_node,current_link,next_node を保持。このうち、next_node を超えようとしている。 次に行くリンクは、next_link_candidate に保持。
  2. recordTrail(time)で経路記録。
  3. current_link から Agent が抜ける。(agentExits(this))
  4. まず prev_node を進める(=next_node と同じとする)
  5. previous_link に current_link を退避。
  6. current_link を進める。(=next_link_candidateと同じとする)
  7. next_link_candidate の、進行方向先のノードを、node_now とする。
  8. node_now から繋がる道のリストを way_candidates とする。(swing の決定に利用するらしい。)
  9. direction を、direction_orig に退避。
  10. calc_next_target(next_node) で、必要に応じて routePlan を進める。
  11. next_node を進める。同時に position と direction のセット。
  12. 移った先のリンクにAgentが入っていく。(agentEnters(this))
  13. current_link がゴールで、他のプランを持たない場合は、終了。

calc_next_target(node)

  1. on_node が true で、サブゴールにたどり着いていれば、routePlan をシフト。
  2. routePlan が空でなければ、そのトップからサブゴールをとる。 そのサブゴールへの経路情報(hint)がnodeに書かれていれば、それを返す。 そうでないなら、routePlan をさらに shift。
  3. routePlan がからになったら、goal を返す。
Clone this wiki locally