(@ #include @) // this is the basic iterative algorithm for the computation of the // congestion Z at each step. *operation* void iterate() *wrapper* RoutingAlgorithm (@ Ring* ring = get_ring(); RoutingTable* rtable = get_routing_table(); int max_iter = *get_max_iter(); int i, count = 0; double Z, Z_prev; get_init()->initialize_util(ring); // cout << "\n\nPrinting the ring... \n"; // ring->print_ring(); // cout << "\n\nPrinting the routing table...\n"; // rtable->print_routing_table(); cout << "\n\nNow iterating and computing congestion Z...\n"; for (i = 1; i <= max_iter; i++) { cout << "********************* Iteration " << i << " ********************" << endl; cout << "a. computing proximities...\n"; get_prox()->compute_proximities(rtable, ring); cout << "b. sorting the routing table...\n"; rtable->sort_routing_table(); cout << "c. computing probabilities...\n"; get_prob()->compute_probabilities(rtable, ring); cout << "d. computing flows...\n"; get_flow()->compute_flows(rtable); cout << "e. computing total flows\n"; ring->compute_total_flows(rtable); //rtable->print_routing_table(); cout << "f. looking for congestion Z...\n"; Z = ring->congestion(); cout << " Z = " << Z << endl; if (i > 1 && fabs(Z - Z_prev) < 1e-5) count++; else count = 0; if (count >= 4) break; cout << "g. computing utilization...\n"; get_util()->compute_utilization(ring, Z, i+1); Z_prev = Z; } if (count >= 4) { cout << "\n\nCONVERGED to Z = " << Z << endl; } else { cout << "\n\nNO CONVERGENCE\n"; } @)