1 | #include "traffic_agent.h" |
---|
2 | |
---|
3 | void LaneHandler::connect_data(BaseTrafficAgent& agent0) |
---|
4 | { |
---|
5 | agent = &agent0; |
---|
6 | agentin2input.set_connection(rv_inputs, agent->rv_inputs); |
---|
7 | ivec queue_index_tmp = agent->rv_queues.dataind(rv_queue); |
---|
8 | if (queue_index_tmp.length()==1){ |
---|
9 | queue_index=queue_index_tmp(0); |
---|
10 | } else { |
---|
11 | bdm_error("queue " + lane.queue + " not found"); |
---|
12 | } |
---|
13 | } |
---|
14 | |
---|
15 | double LaneHandler::expected_output(double green_time){ |
---|
16 | double last_inputs=0.0; |
---|
17 | |
---|
18 | agentin2input.filldown(agent->inputs, inputs); |
---|
19 | queue = agent->queues(queue_index); |
---|
20 | |
---|
21 | double exp_output=0.0; |
---|
22 | |
---|
23 | ///////// |
---|
24 | //Velmi jednoduchy odhad |
---|
25 | agentin2input.filldown(agent->inputs,inputs); |
---|
26 | |
---|
27 | for (int i=0;i<inputs.length();i+=2) { |
---|
28 | last_inputs+=inputs(i); |
---|
29 | } |
---|
30 | |
---|
31 | exp_output=last_inputs*(green_time/agent->step_time); |
---|
32 | |
---|
33 | //////// |
---|
34 | return exp_output; |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | void BaseTrafficAgent::from_setting(const Setting& set) |
---|
39 | { |
---|
40 | bdm::Participant::from_setting(set); |
---|
41 | |
---|
42 | // load from file |
---|
43 | if (set.exists("lanes")){ |
---|
44 | Setting &Slanes=set["lanes"]; |
---|
45 | lanes.set_length(Slanes.getLength()); |
---|
46 | for(int l=0; l<lanes.length(); l++){ |
---|
47 | lanes(l).from_setting(Slanes[l]); |
---|
48 | } |
---|
49 | } |
---|
50 | //UI::get(lanes,set,"lanes", UI::compulsory); |
---|
51 | UI::get(neighbours, set, "neighbours", UI::optional); |
---|
52 | } |
---|