Changeset 1118 for applications/doprava
- Timestamp:
- 06/29/10 00:08:57 (14 years ago)
- Location:
- applications/doprava
- Files:
-
- 21 added
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/doprava/Zlicingw.cfg
r1111 r1118 50 50 // constant entrances: entrances = "zlicin_const01_495_601.csv"; 51 51 // entrances = "zlicin_const02_495_601.csv"; 52 entrances = "zlicin_const0 1_495_601.csv";52 entrances = "zlicin_const02_495_601.csv"; 53 53 54 54 // Simulation length. Due to design of the Aimsun simulator, 55 55 // simulation in our case starts always at 00:00:00. Default simulation 56 56 // length is 24 hours (24:00:00). 57 stop_time = " 00:05:00";57 stop_time = "24:00:00"; 58 58 59 59 // Simulation length in number of cycles (one cycle = 90 s) 60 60 // If present, overwrites stop_time. Ensures corrent termination of simulation 61 61 // Example: 1 hour = 40 cycles, 6 hours = 240 cycles, 24 hours = 960 62 //stop_cycle=5;62 stop_cycle=5; 63 63 64 64 }; -
applications/doprava/traffic_agent_offset.h
r1111 r1118 137 137 } 138 138 } 139 if (found) { 140 141 //counting rating 142 string group = name+"_"+lanes(i).sg; //e.g. 495_VA 143 int index=group_index(group); 144 145 t_green_begin=green_starts(index) + offset; 146 double green_time=green_times(index)*cycle_length; 147 t_green_end=t_green_begin+green_time; 148 149 /************** counting with all exps ****************/ 150 151 int k; 152 double t_act=t_green_begin; 153 virtual_queue=lanehs(i)->queue; 154 155 //cycle goes through all "stopping" points and counts queue lenght at these points 156 do { 157 k=min_i(t_cars_begin); 158 159 if (k!=-1) { 160 double a=cars_count(k); 161 double b=t_cars_begin(k); 162 double c=t_cars_end(k); 163 164 //in case there are cars comming before t_green begin 165 if (t_cars_begin(k)<t_act) { 166 if (t_cars_end(k)<=t_act) { 167 virtual_queue+=cars_count(k); 168 169 cars_count.del(k); 170 t_cars_begin.del(k); 171 t_cars_end.del(k); 172 173 } 174 else { 175 double pomer=(t_cars_begin(k)-t_act)/(t_cars_end(k)-t_cars_begin(k)); 176 virtual_queue+=cars_count(k)*pomer; 177 t_cars_begin(k)=t_act; 178 } 139 140 } 141 if (found) { 142 143 //counting rating 144 string group = name+"_"+lanes(i).sg; //e.g. 495_VA 145 int index=group_index(group); 146 147 t_green_begin=green_starts(index) + offset; 148 double green_time=green_times(index)*cycle_length; 149 t_green_end=t_green_begin+green_time; 150 151 /************** counting with all exps ****************/ 152 153 int k; 154 double t_act=t_green_begin; 155 virtual_queue=lanehs(i)->queue; 156 157 //cycle goes through all "stopping" points and counts queue lenght at these points 158 do { 159 k=min_i(t_cars_begin); 160 161 if (k!=-1) { 162 double a=cars_count(k); 163 double b=t_cars_begin(k); 164 double c=t_cars_end(k); 165 166 //in case there are cars comming before t_green begin 167 if (t_cars_begin(k)<t_act) { 168 if (t_cars_end(k)<=t_act) { 169 virtual_queue+=cars_count(k); 170 171 cars_count.del(k); 172 t_cars_begin.del(k); 173 t_cars_end.del(k); 174 179 175 } 180 else if (t_cars_begin(k)==t_act) {181 if (t_cars_end(k)<t_green_end) {182 virtual_queue+=cars_count(k)-(t_cars_end(k)-t_act)/car_leaving;183 t_act=t_cars_end(k);184 185 cars_count.del(k);186 t_cars_begin.del(k);187 t_cars_end.del(k);188 }189 //if t_cars_end>=t_green_end190 else {191 virtual_queue+=cars_count(k)-(t_green_end-t_act)/car_leaving;192 t_act=t_green_end;193 194 cars_count.del(k);195 t_cars_begin.del(k);196 t_cars_end.del(k);197 }198 199 200 }201 //if t_cars_begin(k)>=t_act202 176 else { 203 if (t_cars_end(k)<t_green_end) { 204 virtual_queue-=(t_cars_end(k)-t_act)/car_leaving; 205 t_act=t_cars_end(k); 206 } 207 else { 208 virtual_queue-=(t_green_end-t_act)/car_leaving; 209 t_act=t_green_end; 210 } 177 double pomer=(t_cars_begin(k)-t_act)/(t_cars_end(k)-t_cars_begin(k)); 178 virtual_queue+=cars_count(k)*pomer; 179 t_cars_begin(k)=t_act; 211 180 } 212 181 } 213 //if no other expectations found 182 else if (t_cars_begin(k)==t_act) { 183 if (t_cars_end(k)<t_green_end) { 184 virtual_queue+=cars_count(k)-(t_cars_end(k)-t_act)/car_leaving; 185 t_act=t_cars_end(k); 186 187 cars_count.del(k); 188 t_cars_begin.del(k); 189 t_cars_end.del(k); 190 } 191 //if t_cars_end>=t_green_end 192 else { 193 virtual_queue+=cars_count(k)-(t_green_end-t_act)/car_leaving; 194 t_act=t_green_end; 195 196 cars_count.del(k); 197 t_cars_begin.del(k); 198 t_cars_end.del(k); 199 } 200 } 201 //if t_cars_begin(k)>=t_act 214 202 else { 215 virtual_queue-=(t_green_end-t_act)/car_leaving; 216 t_act=t_green_end; 203 if (t_cars_end(k)<t_green_end) { 204 virtual_queue-=(t_cars_end(k)-t_act)/car_leaving; 205 t_act=t_cars_end(k); 206 } 207 else { 208 virtual_queue-=(t_green_end-t_act)/car_leaving; 209 t_act=t_green_end; 210 } 217 211 } 218 if (virtual_queue<0) { 219 rating-=virtual_queue; 220 virtual_queue=0; 221 } 222 223 } while (t_act<t_green_end); 224 } 212 } 213 //if no other expectations found 214 else { 215 virtual_queue-=(t_green_end-t_act)/car_leaving; 216 t_act=t_green_end; 217 } 218 if (virtual_queue<0) { 219 rating-=virtual_queue; 220 virtual_queue=0; 221 } 222 223 } while (t_act<t_green_end); 225 224 } 226 225 } … … 244 243 245 244 new_center=center; 246 int max_index=max_ of_three(rating_p,rating_c,rating_n);245 int max_index=max_i_of_three(rating_p,rating_c,rating_n); 247 246 switch (max_index) { 248 247 case 0: … … 309 308 recieved_exps=original_exps; 310 309 311 int max_index=max_ of_three(rating_p,rating_c,rating_n);310 int max_index=max_i_of_three(rating_p,rating_c,rating_n); 312 311 switch (max_index) { 313 312 case 0: … … 433 432 434 433 //! returns index of maximum of entered values 435 int max_ of_three(const double a, const double b, const double c) {434 int max_i_of_three(const double a, const double b, const double c) { 436 435 int index = a > b ? 0 : 1; 437 436 … … 606 605 //split_exps(); 607 606 608 last_offset=planned_offset; 609 610 planned_offset=find_best_offset(planned_offset,8); 611 planned_offset=normalize_offset(planned_offset); 607 608 if (!passive) { 609 last_offset=planned_offset; 610 planned_offset=find_best_offset(planned_offset,8); 611 planned_offset=normalize_offset(planned_offset); 612 } 612 613 613 614 … … 748 749 } 749 750 750 //void log_register(logger &l, const string &prefix){ 751 // if ( log_level[logoffset]){ 752 // l.add_vector ( log_level, logoffset, RV("mujoffset",1), prefix ); 753 // } 754 //} 755 //void log_write() const { 756 // if (log_level[logoffset]){ 757 // log_level.store(logoffset, (double)planned_offset); 758 // //log_level.store(logoffset, planned_rating); 759 // } 760 //} 751 void log_register(logger &l, const string &prefix){ 752 if ( log_level[logoffset]){ 753 l.add_vector ( log_level, logoffset, RV("mujoffset",1), prefix ); //TODO 754 } 755 } 756 void log_write() const { 757 if (log_level[logoffset]){ 758 vec offset_vec(1); 759 offset_vec(0)=(double)planned_offset; 760 log_level.store(logoffset, offset_vec); 761 //log_level.store(logoffset, planned_rating); 762 } 763 } 761 764 762 765