Changeset 1146 for applications/doprava
- Timestamp:
- 07/21/10 00:43:16 (14 years ago)
- Location:
- applications/doprava
- Files:
-
- 1 removed
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/doprava/Zlicingw.cfg
r1136 r1146 18 18 stage_names = ("495_F1","495_F2","495_F3"); 19 19 stage_times = [30,30,20]; 20 passive= 0;21 VP=4 0; //average speed of cars20 passive=1; 21 VP=45; //average speed of cars 22 22 car_leaving_time=2; //time cars need to leave queue 23 23 cycle_count=5; //number of complete negotiation cycles before making avarage offset and sending it to Aimsun … … 47 47 stage_names = ("601_F1","601_F2","601_F3"); 48 48 stage_times = [30,30,20]; 49 passive= 1;50 VP=4 0; //average speed of cars49 passive=0; 50 VP=45; //average speed of cars 51 51 car_leaving_time=2; //time cars need to leave queue 52 52 cycle_count=5; //number of complete negotiation cycles before making avarage offset and sending it to Aimsun -
applications/doprava/traffic_agent_offset.h
r1136 r1146 8 8 double rating_change; 9 9 int negot_start; 10 int negot_offset; 10 11 int negot_limit; 11 12 … … 88 89 exp(0)=lanehs(i)->expected_output(green_time)*lanes(i).alpha(j) / green_time; 89 90 90 start_time = green_starts(group_index(name+"_"+lanes(i).sg)) + lanes(i).output_distances(j)/VP+ planned_offset;91 start_time = green_starts(group_index(name+"_"+lanes(i).sg)) + (3.6*lanes(i).output_distances(j))/(VP) + planned_offset; 91 92 //first car arrive time 92 93 exp(1)=start_time; … … 324 325 325 326 rating_c=count_rating(planned_offset, recieved_exps, rv_recieved_exps); 326 rating_p=count_rating(planned_offset, positive_exps, 327 rating_n=count_rating(planned_offset, negative_exps, 328 327 rating_p=count_rating(planned_offset, positive_exps, rv_recieved_exps); 328 rating_n=count_rating(planned_offset, negative_exps, rv_recieved_exps); 329 329 330 int max_index=max_i_of_three(rating_p,rating_c,rating_n); 330 331 switch (max_index) { … … 464 465 465 466 planned_offset=last_offset; 467 planned_rating=0; 466 468 467 469 //set state variables to default values … … 470 472 send_requests=false; 471 473 need_exps=true; 472 negot_start=4; 474 negot_offset=negot_start; 475 476 if (actual_time/cycle_length<2) { 477 need_exps=false; 478 final_state=true; 479 } 473 480 } 474 481 … … 488 495 // broadcast expected cars 489 496 if (!requesters.empty()) { 490 double a;491 497 expected_cars(); 492 498 do { … … 498 504 UI::save ( outputs, msg, "value"); 499 505 requesters.pop_back(); 500 a=outputs (10);501 506 } while (!requesters.empty()); 502 507 } … … 578 583 579 584 // offset change 580 change_request(ind(0))=find_best_exps(negot_ start,neighbours(i),rating_change);585 change_request(ind(0))=find_best_exps(negot_offset,neighbours(i),rating_change); 581 586 // rating change 582 587 change_request(ind(1))=rating_change; 583 588 } 584 589 585 if (negot_ start>=negot_limit) {586 negot_ start/=2;590 if (negot_offset>negot_limit) { 591 negot_offset/=2; 587 592 send_requests=true; 588 593 } … … 597 602 else if (what=="offset_change_request") { 598 603 double final_rating_diff; 604 605 planned_rating=count_rating(planned_offset, recieved_exps, rv_recieved_exps); 599 606 600 607 rv_recieved_changes=*rv; … … 602 609 603 610 for (int i=0;i<rv_recieved_changes.length();i++) { 604 605 611 ivec ind=RV(rv_recieved_changes.name(i),2).dataind(rv_recieved_changes); 606 607 612 final_rating_diff=-planned_rating+count_rating(planned_offset+(int)recieved_changes(ind(0)), recieved_exps, rv_recieved_exps)+recieved_changes(ind(1)); 613 608 614 if (final_rating_diff>=0) { 609 615 planned_offset+=(int)recieved_changes(ind(0)); … … 612 618 } 613 619 } 614 615 620 new_stable_state=true; 616 621 } … … 648 653 649 654 UI::get(last_offset, set, "offset", UI::compulsory); 655 656 //optional reading parameters from config 650 657 UI::get(passive, set, "passive", UI::optional); 651 UI::get(car_leaving_time, set, "car_leaving_time", UI:: compulsory);658 UI::get(car_leaving_time, set, "car_leaving_time", UI::optional); 652 659 UI::get(VP, set, "VP", UI::optional); 653 660 UI::get(cycle_count, set, "cycle_count", UI::optional); … … 697 704 void log_register(logger &l, const string &prefix){ 698 705 if ( log_level[logoffset]){ 699 l.add_vector ( log_level, logoffset, RV(" 1",2), "x"+prefix ); //TODO706 l.add_vector ( log_level, logoffset, RV("a",2), "x"+prefix ); 700 707 } 701 708 }