diff --git a/r2sol.cc b/r2sol.cc index 62aed8d40d59177e8e858838961b1445d85eba04..01e4c059246736b651bbd295d5c8b49d5235b8f5 100644 --- a/r2sol.cc +++ b/r2sol.cc @@ -755,13 +755,13 @@ int tend_ongoing_move[NMAX]; bool OverlapsOngoingMove(int t1, int t2, int node, const short int covered_by[][MAXNODES], const int is_covered[][MAXNODES], int is_covered_idx, const Path tmp_path[], short int tmax_at_poz_node[]) { - ///***if (t1 < tend_ongoing_move[node]) return true; - if (t2 <= tend_ongoing_move[node]) return true; + if (t1 < tend_ongoing_move[node]) return true; + //if (t2 <= tend_ongoing_move[node]) return true; //return false; - //***const int min_tstart = t2;//USE_STRICT_SPACING_TO_AVOID_DEADLOCKS ? t2 : t1; - const int min_tstart = t1;//USE_STRICT_SPACING_TO_AVOID_DEADLOCKS ? t2 : t1; + const int min_tstart = t2;//USE_STRICT_SPACING_TO_AVOID_DEADLOCKS ? t2 : t1; + //const int min_tstart = t1;//USE_STRICT_SPACING_TO_AVOID_DEADLOCKS ? t2 : t1; const int aid_t1 = is_covered[t1][node] == is_covered_idx ? covered_by[t1][node] : -1; @@ -798,13 +798,15 @@ bool FindBestPath(int aid, const short int covered_by[][MAXNODES], const int is_ int t1 = TINIT, t2 = TINIT, rnode = -1, ro = -1, tstart = T; + const int MIN_HSIZE = 1;//5; + if (!agent_aid.inside_poz) { rnode = agent_aid.poz_node; ro = agent_aid.poz_o; t1 = TINIT + max(agent_aid.malfunc - 1, 0); for (tstart = t1; tstart < T; ++tstart) { if (!CanEnterCell(aid, tstart + 1, -1, rnode, covered_by, is_covered, is_covered_idx, tmp_path)) continue; - if (hsize >= 1) break; + if (hsize >= MIN_HSIZE) break; int t2 = tstart + 1; const int est_tmin = t2 + dmin_aid[rnode][ro]; if (est_tmin > T) { @@ -873,8 +875,6 @@ bool FindBestPath(int aid, const short int covered_by[][MAXNODES], const int is_ if (tmp_path_aid.tmax < TINIT || tmp_path_aid.p[tmp_path_aid.tmax].node == agent_aid.target_node) TMIN = tmp_path_aid.tmax; - const int MIN_HSIZE = 1;//5; - while (hsize >= 1 || tstart < T) { int t, node, o, ct1; @@ -1349,20 +1349,16 @@ void RandomPermutations(int tid, int ntries) { } } } - bool inconsistent = false; for (int idx = 0; idx < N; ++idx) { const auto& aid = perm_tid[idx]; const auto& agent_aid = agent[aid]; if (agent_aid.status == DONE_REMOVED) continue; auto& tmp_path_tid_aid = tmp_path_tid[aid]; UncoverPath(aid, tmp_path_tid_aid, covered_by_tid, is_covered_tid, is_covered_idx_tid); - if (!FindBestPath(aid, covered_by_tid, is_covered_tid, is_covered_idx_tid, can_reach_tid, can_reach_idx_tid, can_reach_with_t1_tid, heap_tid, heap_size_tid, prev_tid, tmp_path_tid, &tmp_path2_tid[aid], tmax_at_poz_node_tid)) { - //inconsistent = true; - //break; - } + FindBestPath(aid, covered_by_tid, is_covered_tid, is_covered_idx_tid, can_reach_tid, can_reach_idx_tid, can_reach_with_t1_tid, heap_tid, heap_size_tid, prev_tid, tmp_path_tid, &tmp_path2_tid[aid], tmax_at_poz_node_tid); CoverPath(aid, tmp_path_tid_aid, covered_by_tid, is_covered_tid, is_covered_idx_tid); } - if (!inconsistent && RunConsistencyChecks(tmp_path_tid, covered_by_tid, is_covered_tid, is_covered_idx_tid, false)) { + if (RunConsistencyChecks(tmp_path_tid, covered_by_tid, is_covered_tid, is_covered_idx_tid, false)) { int num_done_agents = 0; double cost = 0.0; int max_tmax = 0; @@ -1849,7 +1845,7 @@ bool AdjustIPaths() { int tend_move_aid1 = tend_move + (aid1 < aid && agent[aid1].target_node != next_node ? 1 : 0); const auto& agent_aid1 = agent[aid1]; if (last_path_elem.num_partial_turns == 0 && (next_aidx[aid1] > next_checkpoint[aid1] || agent[aid1].moving_to_node < 0)) { - const int min_tstart = tend_move;//USE_STRICT_SPACING_TO_AVOID_DEADLOCKS ? tend_move : t_curr_node; + const int min_tstart = tend_move; assert(t_curr_node < tend_move); if (tend_move_aid1 - agent_aid1.cturns < min_tstart) tend_move_aid1 = min_tstart + agent_aid1.cturns; } @@ -2199,7 +2195,7 @@ void GetMoves(const char* testid, bool replay_mode = false) { const int kMaxNumAdjustIPathsWithoutFullPlanRegenartion = 5; const bool full_regenerate_paths = !updated_paths_ok || num_adjust_ipaths_without_full_plan_regeneration > kMaxNumAdjustIPathsWithoutFullPlanRegenartion; if (full_regenerate_paths) { - RegenerateFullPlan(4, TINIT == 0 ? 18 : /*12*/ 10); + RegenerateFullPlan(4, TINIT == 0 ? 18 : 10); num_adjust_ipaths_without_full_plan_regeneration = 0; } else { assert(TINIT >= 1); diff --git a/scores.txt b/scores.txt index eb60eb59e5047bfa924d6e97d8827b5bead55e46..006d7ab0572266f651d368ae587ee4b8bff8c91d 100644 --- a/scores.txt +++ b/scores.txt @@ -1,20 +1,20 @@ -0 115 85.1851851852 -49653.9166667006 10 7.4074074074 7.4074074074 -1 100 71.4285714286 -43604.9166666858 -6 -4.2857142857 1.5608465608 -2 66 54.5454545455 -47303.2500000250 11 9.0909090909 9.0909090909 -3 80 100.0000000000 -12082.7500000020 0 0.0000000000 0.0000000000 -4 123 79.3548387097 -84319.9166666058 19 12.2580645161 6.1290322581 -5 130 99.2366412214 -39629.9166666687 7 5.3435114504 5.8671919888 -6 165 95.3757225434 -60916.1666667209 35 20.2312138728 9.4581974598 -7 107 78.6764705882 -41366.8333333417 14 10.2941176471 9.6253814973 +0 120 88.8888888889 -48977.4166666987 5 3.7037037037 3.7037037037 +1 108 77.1428571429 -41917.6666666799 8 5.7142857143 4.7089947090 +2 67 55.3719008264 -46622.0000000222 1 0.8264462810 3.4148118997 +3 80 100.0000000000 -11866.1666666689 0 0.0000000000 2.5611089247 +4 132 85.1612903226 -92379.5833332421 9 5.8064516129 3.2101774624 +5 131 100.0000000000 -38494.9999999999 1 0.7633587786 2.8023743484 +6 161 93.0635838150 -63298.0000000537 -4 -2.3121387283 2.0717296232 +7 107 78.6764705882 -43111.2500000140 0 0.0000000000 1.8127634203 +8 92 76.6666666667 -39970.0833333421 13 10.8333333333 2.8150489662 +9 71 46.4052287582 -74806.7500000093 7 4.5751633987 2.9910604094 +10 116 69.0476190476 -84733.0833332976 29 17.2619047619 4.2884098960 +11 103 99.0384615385 -15266.5000000033 13 12.5000000000 4.9727090713 +12 74 67.2727272727 -49139.0833333591 4 3.6363636364 4.8699132687 +13 132 83.0188679245 -55239.4166667169 20 12.5786163522 5.4205349175 +14 94 76.4227642276 -51465.5833333656 3 2.4390243902 5.2217675490 +15 90 47.3684210526 -142797.6666665631 11 5.7894736842 5.2572491824 -8 79 65.8333333333 -42068.4166666825 -3 -2.5000000000 0.3728663107 -9 64 41.8300653595 -78048.1666666569 3 1.9607843137 0.5316581110 -10 87 51.7857142857 -92886.0833332524 -1 -0.5952380952 0.4292130013 -11 90 86.5384615385 -18690.0833333352 -4 -3.8461538462 0.0729324307 -12 70 63.6363636364 -48049.9166666936 4 3.6363636364 0.3470425234 -13 112 70.4402515723 -58866.8333333958 -14 -8.8050314465 -0.3066770458 -14 91 73.9837398374 -53871.5000000432 9 7.3170731707 7.3170731707 -15 79 41.5789473684 -141963.1666665719 4 2.1052631579 4.7111681643 16 44 39.2857142857 -79070.4999999909 -8 -7.1428571429 0.7598263953 17 101 70.1388888889 -59876.9166667267 9 6.2500000000 2.1323697964 18 83 45.1086956522 -65137.1666667329 0 0.0000000000 1.7058958372 diff --git a/tmp-scores.txt b/tmp-scores.txt index d8b7983d97b4d70e1cc845f06d62ed8582c4cb90..c6ffa02be90f8071025540cda27241646065c118 100644 --- a/tmp-scores.txt +++ b/tmp-scores.txt @@ -1,5 +1,6 @@ -0 120 88.8888888889 -48977.4166666987 5 3.7037037037 3.7037037037 -1 108 77.1428571429 -41917.6666666799 8 5.7142857143 4.7089947090 -2 67 55.3719008264 -46622.0000000222 1 0.8264462810 3.4148118997 -3 80 100.0000000000 -11866.1666666689 0 0.0000000000 2.5611089247 -4 132 85.1612903226 -92379.5833332421 9 5.8064516129 3.2101774624 +0 114 84.4444444444 -50443.5000000380 -6 -4.4444444444 -4.4444444444 +1 110 78.5714285714 -41208.8333333436 2 1.4285714286 -1.5079365079 +2 63 52.0661157025 -49503.0833333628 -4 -3.3057851240 -2.1072193799 +3 80 100.0000000000 -12103.2500000025 0 0.0000000000 -1.5804145350 +4 134 86.4516129032 -92102.3333332341 2 1.2903225806 -1.0062671118 +5 128 97.7099236641 -37359.9166666591 -3 -2.2900763359 -1.2202353158