Revision 1422, 1.2 kB
(checked in by jabu, 12 years ago)
|
BaseTrafficAgentCt? - zaklad agenta pro rizeni delky cyklu
Master, Observer - rizeni centralnim agentem Master, Observer jen posila data
|
Rev | Line | |
---|
[1422] | 1 | #pragma once |
---|
| 2 | #include "BaseTrafficAgentCt.h" |
---|
| 3 | |
---|
| 4 | class TrafficAgentLQObserver : public BaseTrafficAgentCt { |
---|
| 5 | public: |
---|
| 6 | |
---|
| 7 | void adapt(const vec &glob_dt) { |
---|
| 8 | BaseTrafficAgentCt::adapt(glob_dt); |
---|
| 9 | B = zeros( queues.length(), 1); |
---|
| 10 | // jeden clen matice B |
---|
| 11 | for ( int i=0; i<queues.length(); i ++ ) { |
---|
| 12 | B(i,0) = - s_flow(i) * lanehs(i)->green_time_ratio; |
---|
| 13 | } |
---|
| 14 | } |
---|
| 15 | |
---|
| 16 | void broadcast( Setting &set ) { |
---|
| 17 | if ( nOfBroadcast == 0 ) { |
---|
| 18 | stringstream what; |
---|
| 19 | for ( int i = 0; i < queueData.length(); i ++ ) |
---|
| 20 | sendQueueData( set, queueData(i) ); |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | // send alphas |
---|
| 26 | string dummyDet = "DUMMY_DET"; |
---|
| 27 | for ( int i = 0; i < lanehs.length(); i++ ) { |
---|
| 28 | for ( int j = 0; j < lanehs(i)->rv_outputs.length(); j ++ ) { |
---|
| 29 | if ( dummyDet.compare(lanehs(i)->rv_outputs.name(j)) != 0 ) { |
---|
| 30 | //what.str(""); |
---|
| 31 | //what << "coef" << lanehs(i)->rv_outputs.name(j); |
---|
| 32 | //double val = s_flow(i) * lanehs(i)->green_time_ratio * lanehs(i)->getLane().alpha(j); |
---|
| 33 | //sendToAll<double>(set, what.str(), val); |
---|
| 34 | } |
---|
| 35 | } |
---|
| 36 | } |
---|
| 37 | } |
---|
| 38 | //BaseTrafficAgentCt::broadcast(set); |
---|
| 39 | nOfBroadcast ++; |
---|
| 40 | |
---|
| 41 | // send B matrix |
---|
| 42 | } |
---|
| 43 | }; |
---|
| 44 | UIREGISTER(TrafficAgentLQObserver); |
---|