├── CMakeLists.txt ├── Genetic.cpp ├── Genetic.h ├── Hillclimbing.cpp ├── Hillclimbing.h ├── Instances ├── C101.TXT ├── RC105.txt ├── RC208.txt └── S-RC2-1000 │ ├── RC21010.TXT │ ├── RC210_1.TXT │ ├── RC210_2.TXT │ ├── RC210_3.TXT │ ├── RC210_4.TXT │ ├── RC210_5.TXT │ ├── RC210_6.TXT │ ├── RC210_7.TXT │ ├── RC210_8.TXT │ └── RC210_9.TXT ├── Point.cpp ├── Point.h ├── SAnnealing.cpp ├── SAnnealing.h ├── Solution.cpp ├── Solution.h ├── SubCandidate.cpp ├── SubCandidate.h ├── Utils.cpp ├── Utils.h ├── Vehicle.cpp ├── Vehicle.h ├── VehicleState.cpp ├── VehicleState.h └── main.cpp /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Set the minimum version of CMake required to build this project 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | # Define the project and specify the language used 5 | project(vrptw VERSION 1.0 LANGUAGES CXX) 6 | 7 | # Set the C++ standard to C++11 8 | set(CMAKE_CXX_STANDARD 11) 9 | set(CMAKE_CXX_STANDARD_REQUIRED True) 10 | 11 | # Add the optimization flag 12 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast") 13 | 14 | # Add pthread as a link option 15 | set(THREADS_PREFER_PTHREAD_FLAG ON) 16 | find_package(Threads REQUIRED) 17 | 18 | # Add all the source files involved in the build 19 | add_executable(vrptw 20 | main.cpp 21 | Genetic.cpp 22 | Hillclimbing.cpp 23 | Point.cpp 24 | Solution.cpp 25 | SubCandidate.cpp 26 | Utils.cpp 27 | Vehicle.cpp 28 | VehicleState.cpp 29 | ) 30 | 31 | # Link the executable with the pthread library 32 | target_link_libraries(vrptw PRIVATE Threads::Threads) 33 | -------------------------------------------------------------------------------- /Genetic.cpp: -------------------------------------------------------------------------------- 1 | #include "Genetic.h" 2 | #include "Utils.h" 3 | #include "Solution.h" 4 | #include 5 | #include "Hillclimbing.h" 6 | #include "Vehicle.h" 7 | #include "VehicleState.h" 8 | #include "Point.h" 9 | #include "math.h" 10 | #include 11 | #include 12 | 13 | 14 | std::list> Genetic::solutions; 15 | double Genetic::ticket_max = 0; 16 | double Genetic::max_weight = 0; 17 | int Genetic::population_limit = 0; 18 | 19 | struct solutions_comparator 20 | { 21 | bool operator()(const std::pair& inst1, const std::pair& inst2) 22 | { 23 | return inst1.first->weight < inst2.first->weight; 24 | } 25 | }; 26 | 27 | void Genetic::generate_population() 28 | { 29 | //std::cout << "Generating population\n"; 30 | //The first solution is the best that hillclimbing can get 31 | auto solution = Hillclimbing::run(); 32 | //auto solution = Utils::random_solution(); 33 | 34 | solutions.push_back(std::pair(solution, 0)); 35 | for (int i = 1; i < population_limit; ++i) 36 | { 37 | solution = Utils::random_solution(); 38 | 39 | if (solution->weight > max_weight) 40 | max_weight = solution->weight; 41 | 42 | solutions.push_back(std::pair(solution, 0)); 43 | } 44 | //ticket_max = pow(ticket_max, 2); // to much 45 | max_weight *= 2; 46 | //std::cout << "Initial solutions calculated\n"; 47 | } 48 | 49 | bool Genetic::avaliate_population() 50 | { 51 | double last_weight = 0; 52 | for (auto it = solutions.begin(); it != solutions.end(); ++it) 53 | { 54 | (*it).second = (max_weight - (*it).first->weight) + last_weight; 55 | last_weight = (*it).second; 56 | } 57 | ticket_max = last_weight; 58 | if (static_cast(ticket_max) == 0) 59 | { 60 | return false; 61 | } 62 | return true; 63 | } 64 | 65 | std::list> Genetic::select_parents() 66 | { 67 | std::list> res; 68 | Solution* p1; 69 | Solution* p2; 70 | 71 | for (int j = 0; j < static_cast(population_limit / 2); ++j) 72 | { 73 | int i = rand() % static_cast(ticket_max); 74 | for (auto solution : solutions) 75 | { 76 | if (i <= solution.second) 77 | { 78 | p1 = solution.first; 79 | break; 80 | } 81 | } 82 | i = rand() % static_cast(ticket_max); 83 | for (auto solution : solutions) 84 | { 85 | if (i <= solution.second) 86 | { 87 | p2 = solution.first; 88 | break; 89 | } 90 | } 91 | res.push_back(std::pair(p1, p2)); 92 | } 93 | 94 | return res; 95 | } 96 | 97 | /* 98 | Solution* Genetic::old_generate_child(Solution* p1, Solution* p2) 99 | { 100 | auto solution = new Solution; 101 | //edge recombination crossover 102 | 103 | //TODO: improve neighboors 104 | std::unordered_map> neighboors; 105 | 106 | int total_nodes = 0; 107 | for (auto vehicle : p1->vehicles) 108 | { 109 | for(auto nid = vehicle->nodes.begin(); nid != vehicle->nodes.end(); ++nid) 110 | { 111 | auto next = std::next(nid); 112 | auto n = &neighboors[(*nid)->p]; 113 | if(next != vehicle->nodes.end()) 114 | { 115 | n->push_back((*next)->p); 116 | } 117 | } 118 | } 119 | for (auto vehicle : p2->vehicles) 120 | { 121 | for (auto nid = vehicle->nodes.begin(); nid != vehicle->nodes.end(); ++nid) 122 | { 123 | auto next = std::next(nid); 124 | auto n = &neighboors[(*nid)->p]; 125 | if (next != vehicle->nodes.end()) 126 | { 127 | n->push_back((*next)->p); 128 | } 129 | } 130 | } 131 | auto it = neighboors.begin(); 132 | std::advance(it, ((double)rand() / (RAND_MAX))); 133 | Point* node = (*it).first; 134 | neighboors.erase(it++); 135 | Vehicle * v = new Vehicle(solution); 136 | solution->vehicles.push_back(v); 137 | 138 | total_nodes = neighboors.size(); 139 | while(!neighboors.empty()) 140 | { 141 | auto ec = 0; 142 | v->add_node(node, v->nodes.size(), ec); 143 | if(ec) 144 | { 145 | ec = 0; 146 | v = new Vehicle(solution); 147 | v->add_node(node, 0, ec); 148 | solution->vehicles.push_back(v); 149 | } 150 | 151 | //remove node from neighboors list 152 | for (auto it = neighboors.begin(); it != neighboors.end(); ++it) 153 | { 154 | (*it).second.remove(node); 155 | } 156 | 157 | //if x neighbor list is empty 158 | if(neighboors[node].empty()) 159 | { 160 | neighboors.erase(node); 161 | //Find a random node 162 | if (neighboors.size() > 0) { 163 | auto offset = rand() % neighboors.size(); 164 | auto it = neighboors.begin(); 165 | 166 | std::advance(it, offset); 167 | 168 | node = (*it).first; 169 | 170 | }else 171 | { 172 | return solution; 173 | } 174 | }else 175 | { 176 | auto node_neighboors = neighboors[node]; 177 | auto n_it = node_neighboors.begin()++; 178 | auto neighboor = *n_it; 179 | std::pair fewest_neighboors(neighboor, neighboors[neighboor].size()); 180 | 181 | for(;n_it != node_neighboors.end(); ++n_it) 182 | { 183 | neighboor = *n_it; 184 | auto size = neighboors[neighboor].size(); 185 | //Todo: if theres a tie, chose randomly one 186 | if(size < fewest_neighboors.second) 187 | { 188 | fewest_neighboors.first = neighboor; 189 | fewest_neighboors.second = size; 190 | } 191 | } 192 | 193 | node = fewest_neighboors.first; 194 | } 195 | } 196 | 197 | 198 | return solution; 199 | } 200 | */ 201 | 202 | Solution* Genetic::generate_child(Solution* p1, Solution* p2) 203 | { 204 | auto solution = new Solution; 205 | //Route-Based Crossover 206 | std::list vehicle_pool; 207 | for (auto vehicle : p1->vehicles) 208 | { 209 | vehicle_pool.push_back(vehicle); 210 | } 211 | for (auto vehicle : p2->vehicles) 212 | { 213 | vehicle_pool.push_back(vehicle); 214 | } 215 | 216 | auto total_nodes = Utils::raw_rows.size() - 1; 217 | 218 | while (!vehicle_pool.empty()) 219 | { 220 | auto it = vehicle_pool.begin(); 221 | std::advance(it, rand() % vehicle_pool.size()); 222 | auto pool = *it; 223 | vehicle_pool.erase(it); 224 | 225 | auto nv = new Vehicle(solution); 226 | solution->vehicles.push_back(nv); 227 | auto pos = 0; 228 | for (auto node : pool->nodes) 229 | { 230 | if (!solution->has_node(node->p)) 231 | { 232 | auto ec = 0; 233 | nv->add_node(node->p, pos++, ec); 234 | total_nodes--; 235 | } 236 | } 237 | if (nv->nodes.empty()) 238 | { 239 | solution->vehicles.remove(nv); 240 | delete nv; 241 | } 242 | } 243 | 244 | solution->total_weight(); 245 | return solution; 246 | } 247 | 248 | Solution* Genetic::run(int max_iter) 249 | { 250 | generate_population(); 251 | solutions.sort(solutions_comparator()); 252 | while (true || max_iter-- > 0) 253 | { 254 | if (!avaliate_population()) 255 | { 256 | return (*solutions.begin()).first; 257 | } 258 | std::list> parents = select_parents(); 259 | 260 | //Generate childs and add to solutions pool 261 | for (auto parent : parents) 262 | { 263 | solutions.push_back(std::pair(generate_child(parent.first, parent.second), 0)); 264 | } 265 | 266 | //Mutate solutions 267 | max_weight = 0; 268 | for (auto solution : solutions) 269 | { 270 | solution.first->mutate(); 271 | 272 | if (solution.first->weight > max_weight) 273 | max_weight = solution.first->weight; 274 | } 275 | 276 | 277 | //Kill the worst 278 | solutions.sort(solutions_comparator()); 279 | auto it = solutions.begin(); 280 | std::advance(it, population_limit); 281 | 282 | auto it2 = it; 283 | for (; it2 != solutions.end(); ++it2) 284 | delete (*it2).first; 285 | 286 | solutions.erase(it, solutions.end()); 287 | 288 | std::cout << "Genetic iteration, best solution: " << (*solutions.begin()).first->weight << "\n"; 289 | } 290 | return solutions.begin()->first; 291 | } 292 | 293 | void Genetic::clear() 294 | { 295 | for (auto solution : solutions) 296 | { 297 | delete solution.first; 298 | } 299 | solutions.clear(); 300 | ticket_max = 0; 301 | max_weight = 0; 302 | } 303 | -------------------------------------------------------------------------------- /Genetic.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class Solution; 5 | 6 | class Genetic 7 | { 8 | public: 9 | static int population_limit; 10 | static std::list> solutions; 11 | static double ticket_max; 12 | static double max_weight; 13 | 14 | static void generate_population(); 15 | static std::list> select_parents(); 16 | static Solution* generate_child(Solution* p1, Solution* p2); 17 | static bool avaliate_population(); 18 | static Solution* run(int max_iter); 19 | static void clear(); 20 | 21 | 22 | }; 23 | 24 | -------------------------------------------------------------------------------- /Hillclimbing.cpp: -------------------------------------------------------------------------------- 1 | #include "Hillclimbing.h" 2 | #include "Solution.h" 3 | #include "Utils.h" 4 | #include 5 | 6 | Solution* Hillclimbing::solution; 7 | 8 | Solution* Hillclimbing::run(int max_fails) 9 | { 10 | 11 | solution = Utils::pfih(); 12 | //std::cout << "Push Foward Insert Heuristic calculated\n"; 13 | //std::cout << "Initial weight: " << solution->total_weight() << "\n"; 14 | 15 | auto consecutive_fails = 0; 16 | auto improved = false; 17 | while(consecutive_fails < max_fails) 18 | { 19 | solution->mutate1(improved); 20 | if (!improved) { 21 | consecutive_fails++; 22 | }else 23 | { 24 | consecutive_fails = 0; 25 | } 26 | 27 | } 28 | return solution; 29 | } -------------------------------------------------------------------------------- /Hillclimbing.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Solution; 4 | 5 | class Hillclimbing 6 | { 7 | public: 8 | static Solution* solution; 9 | static Solution* run(int max_fails = 10000); 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /Instances/C101.TXT: -------------------------------------------------------------------------------- 1 | C101 2 | 3 | VEHICLE 4 | NUMBER CAPACITY 5 | 25 200 6 | 7 | CUSTOMER 8 | CUST NO. XCOORD. YCOORD. DEMAND READY TIME DUE DATE SERVICE TIME 9 | 10 | 0 40 50 0 0 1236 0 11 | 1 45 68 10 912 967 90 12 | 2 45 70 30 825 870 90 13 | 3 42 66 10 65 146 90 14 | 4 42 68 10 727 782 90 15 | 5 42 65 10 15 67 90 16 | 6 40 69 20 621 702 90 17 | 7 40 66 20 170 225 90 18 | 8 38 68 20 255 324 90 19 | 9 38 70 10 534 605 90 20 | 10 35 66 10 357 410 90 21 | 11 35 69 10 448 505 90 22 | 12 25 85 20 652 721 90 23 | 13 22 75 30 30 92 90 24 | 14 22 85 10 567 620 90 25 | 15 20 80 40 384 429 90 26 | 16 20 85 40 475 528 90 27 | 17 18 75 20 99 148 90 28 | 18 15 75 20 179 254 90 29 | 19 15 80 10 278 345 90 30 | 20 30 50 10 10 73 90 31 | 21 30 52 20 914 965 90 32 | 22 28 52 20 812 883 90 33 | 23 28 55 10 732 777 90 34 | 24 25 50 10 65 144 90 35 | 25 25 52 40 169 224 90 36 | 26 25 55 10 622 701 90 37 | 27 23 52 10 261 316 90 38 | 28 23 55 20 546 593 90 39 | 29 20 50 10 358 405 90 40 | 30 20 55 10 449 504 90 41 | 31 10 35 20 200 237 90 42 | 32 10 40 30 31 100 90 43 | 33 8 40 40 87 158 90 44 | 34 8 45 20 751 816 90 45 | 35 5 35 10 283 344 90 46 | 36 5 45 10 665 716 90 47 | 37 2 40 20 383 434 90 48 | 38 0 40 30 479 522 90 49 | 39 0 45 20 567 624 90 50 | 40 35 30 10 264 321 90 51 | 41 35 32 10 166 235 90 52 | 42 33 32 20 68 149 90 53 | 43 33 35 10 16 80 90 54 | 44 32 30 10 359 412 90 55 | 45 30 30 10 541 600 90 56 | 46 30 32 30 448 509 90 57 | 47 30 35 10 1054 1127 90 58 | 48 28 30 10 632 693 90 59 | 49 28 35 10 1001 1066 90 60 | 50 26 32 10 815 880 90 61 | 51 25 30 10 725 786 90 62 | 52 25 35 10 912 969 90 63 | 53 44 5 20 286 347 90 64 | 54 42 10 40 186 257 90 65 | 55 42 15 10 95 158 90 66 | 56 40 5 30 385 436 90 67 | 57 40 15 40 35 87 90 68 | 58 38 5 30 471 534 90 69 | 59 38 15 10 651 740 90 70 | 60 35 5 20 562 629 90 71 | 61 50 30 10 531 610 90 72 | 62 50 35 20 262 317 90 73 | 63 50 40 50 171 218 90 74 | 64 48 30 10 632 693 90 75 | 65 48 40 10 76 129 90 76 | 66 47 35 10 826 875 90 77 | 67 47 40 10 12 77 90 78 | 68 45 30 10 734 777 90 79 | 69 45 35 10 916 969 90 80 | 70 95 30 30 387 456 90 81 | 71 95 35 20 293 360 90 82 | 72 53 30 10 450 505 90 83 | 73 92 30 10 478 551 90 84 | 74 53 35 50 353 412 90 85 | 75 45 65 20 997 1068 90 86 | 76 90 35 10 203 260 90 87 | 77 88 30 10 574 643 90 88 | 78 88 35 20 109 170 90 89 | 79 87 30 10 668 731 90 90 | 80 85 25 10 769 820 90 91 | 81 85 35 30 47 124 90 92 | 82 75 55 20 369 420 90 93 | 83 72 55 10 265 338 90 94 | 84 70 58 20 458 523 90 95 | 85 68 60 30 555 612 90 96 | 86 66 55 10 173 238 90 97 | 87 65 55 20 85 144 90 98 | 88 65 60 30 645 708 90 99 | 89 63 58 10 737 802 90 100 | 90 60 55 10 20 84 90 101 | 91 60 60 10 836 889 90 102 | 92 67 85 20 368 441 90 103 | 93 65 85 40 475 518 90 104 | 94 65 82 10 285 336 90 105 | 95 62 80 30 196 239 90 106 | 96 60 80 10 95 156 90 107 | 97 60 85 30 561 622 90 108 | 98 58 75 20 30 84 90 109 | 99 55 80 10 743 820 90 110 | 100 55 85 20 647 726 90 111 | -------------------------------------------------------------------------------- /Instances/RC105.txt: -------------------------------------------------------------------------------- 1 | RC105 2 | 3 | VEHICLE 4 | NUMBER CAPACITY 5 | 25 200 6 | 7 | CUSTOMER 8 | CUST NO. XCOORD. YCOORD. DEMAND READY TIME DUE DATE SERVICE TIME 9 | 10 | 0 40 50 0 0 240 0 11 | 1 25 85 20 71 191 10 12 | 2 22 75 30 30 150 10 13 | 3 22 85 10 64 184 10 14 | 4 20 80 40 151 161 10 15 | 5 20 85 20 40 160 10 16 | 6 18 75 20 96 123 10 17 | 7 15 75 20 35 155 10 18 | 8 15 80 10 101 111 10 19 | 9 10 35 20 101 111 10 20 | 10 10 40 30 123 144 10 21 | 11 8 40 40 69 79 10 22 | 12 8 45 20 32 152 10 23 | 13 5 35 10 152 162 10 24 | 14 5 45 10 35 117 10 25 | 15 2 40 20 68 78 10 26 | 16 0 40 20 59 114 10 27 | 17 0 45 20 147 180 10 28 | 18 44 5 20 79 124 10 29 | 19 42 10 40 58 115 10 30 | 20 42 15 10 111 162 10 31 | 21 40 5 10 45 165 10 32 | 22 40 15 40 94 119 10 33 | 23 38 5 30 75 85 10 34 | 24 38 15 10 128 194 10 35 | 25 35 5 20 171 181 10 36 | 26 95 30 30 58 171 10 37 | 27 95 35 20 60 93 10 38 | 28 92 30 10 55 120 10 39 | 29 90 35 10 52 112 10 40 | 30 88 30 10 75 102 10 41 | 31 88 35 20 50 170 10 42 | 32 87 30 10 116 175 10 43 | 33 85 25 10 51 85 10 44 | 34 85 35 30 62 182 10 45 | 35 67 85 20 138 169 10 46 | 36 65 85 40 43 78 10 47 | 37 65 82 10 69 189 10 48 | 38 62 80 30 85 95 10 49 | 39 60 80 10 36 74 10 50 | 40 60 85 30 87 112 10 51 | 41 58 75 20 92 121 10 52 | 42 55 80 10 33 66 10 53 | 43 55 85 20 117 168 10 54 | 44 55 82 10 74 84 10 55 | 45 20 82 10 37 72 10 56 | 46 18 80 10 98 157 10 57 | 47 2 45 10 38 109 10 58 | 48 42 5 10 64 184 10 59 | 49 42 12 10 109 128 10 60 | 50 72 35 30 71 191 10 61 | 51 55 20 19 69 126 10 62 | 52 25 30 3 25 145 10 63 | 53 20 50 5 101 111 10 64 | 54 55 60 16 127 180 10 65 | 55 30 60 16 150 160 10 66 | 56 50 35 19 130 159 10 67 | 57 30 25 23 82 139 10 68 | 58 15 10 20 172 182 10 69 | 59 10 20 19 42 162 10 70 | 60 15 60 17 137 202 10 71 | 61 45 65 9 55 106 10 72 | 62 65 35 3 62 72 10 73 | 63 65 20 6 39 108 10 74 | 64 45 30 17 53 82 10 75 | 65 35 40 16 11 43 10 76 | 66 41 37 16 134 161 10 77 | 67 64 42 9 80 90 10 78 | 68 40 60 21 144 173 10 79 | 69 31 52 27 51 61 10 80 | 70 35 69 23 172 210 10 81 | 71 65 55 14 52 107 10 82 | 72 63 65 8 27 147 10 83 | 73 2 60 5 65 118 10 84 | 74 20 20 8 151 161 10 85 | 75 5 5 16 57 172 10 86 | 76 60 12 31 85 95 10 87 | 77 23 3 7 163 173 10 88 | 78 8 56 27 90 119 10 89 | 79 6 68 30 99 109 10 90 | 80 47 47 13 190 222 10 91 | 81 49 58 10 80 121 10 92 | 82 27 43 9 14 134 10 93 | 83 37 31 14 19 139 10 94 | 84 57 29 18 106 116 10 95 | 85 63 23 2 42 162 10 96 | 86 21 24 28 77 126 10 97 | 87 12 24 13 100 110 10 98 | 88 24 58 19 67 96 10 99 | 89 67 5 25 105 177 10 100 | 90 37 47 6 74 127 10 101 | 91 49 42 13 97 217 10 102 | 92 53 43 14 15 25 10 103 | 93 61 52 3 173 208 10 104 | 94 57 48 23 50 170 10 105 | 95 56 37 6 20 140 10 106 | 96 55 54 26 87 207 10 107 | 97 4 18 35 112 157 10 108 | 98 26 52 9 14 134 10 109 | 99 26 35 15 87 97 10 110 | 100 31 67 3 200 210 10 111 | -------------------------------------------------------------------------------- /Instances/RC208.txt: -------------------------------------------------------------------------------- 1 | RC208 2 | 3 | VEHICLE 4 | NUMBER CAPACITY 5 | 25 1000 6 | 7 | CUSTOMER 8 | CUST NO. XCOORD. YCOORD. DEMAND READY TIME DUE DATE SERVICE TIME 9 | 10 | 0 40 50 0 0 960 0 11 | 1 25 85 20 388 911 10 12 | 2 22 75 30 30 546 10 13 | 3 22 85 10 353 708 10 14 | 4 20 80 40 425 913 10 15 | 5 20 85 20 40 630 10 16 | 6 18 75 20 228 667 10 17 | 7 15 75 20 161 558 10 18 | 8 15 80 10 229 624 10 19 | 9 10 35 20 213 648 10 20 | 10 10 40 30 404 753 10 21 | 11 8 40 40 33 511 10 22 | 12 8 45 20 46 519 10 23 | 13 5 35 10 395 911 10 24 | 14 5 45 10 35 697 10 25 | 15 2 40 20 39 528 10 26 | 16 0 40 20 94 535 10 27 | 17 0 45 20 394 909 10 28 | 18 44 5 20 218 571 10 29 | 19 42 10 40 85 542 10 30 | 20 42 15 10 391 802 10 31 | 21 40 5 10 45 517 10 32 | 22 40 15 40 229 640 10 33 | 23 38 5 30 45 523 10 34 | 24 38 15 10 389 914 10 35 | 25 35 5 20 386 904 10 36 | 37 | -------------------------------------------------------------------------------- /Instances/S-RC2-1000/RC21010.TXT: -------------------------------------------------------------------------------- 1 | rc21010 2 | 3 | VEHICLE 4 | NUMBER CAPACITY 5 | 250 1000 6 | 7 | CUSTOMER 8 | CUST NO. XCOORD. YCOORD. DEMAND READY TIME DUE DATE SERVICE TIME 9 | 10 | 0 250 250 0 0 7284 0 11 | 1 440 436 18 3328 3928 10 12 | 2 214 394 10 682 1282 10 13 | 3 476 483 10 1179 1779 10 14 | 4 352 487 27 3367 3967 10 15 | 5 230 197 40 246 846 10 16 | 6 175 239 23 75 675 10 17 | 7 133 202 33 1602 2202 10 18 | 8 328 458 17 2831 3431 10 19 | 9 25 499 10 1540 2140 10 20 | 10 226 423 15 548 1148 10 21 | 11 313 282 20 414 1014 10 22 | 12 60 454 10 1149 1749 10 23 | 13 239 486 3 5688 6288 10 24 | 14 102 264 10 295 895 10 25 | 15 408 452 10 848 1448 10 26 | 16 451 62 5 889 1489 10 27 | 17 203 390 40 395 995 10 28 | 18 92 233 10 655 1255 10 29 | 19 7 300 30 1139 1739 10 30 | 20 409 90 20 793 1393 10 31 | 21 307 108 10 710 1310 10 32 | 22 347 54 10 940 1540 10 33 | 23 406 87 10 1012 1612 10 34 | 24 371 332 14 1878 2478 10 35 | 25 116 466 20 764 1364 10 36 | 26 441 265 40 549 1149 10 37 | 27 130 140 17 536 1136 10 38 | 28 80 117 24 3057 3657 10 39 | 29 421 387 15 2965 3565 10 40 | 30 83 300 26 1759 2359 10 41 | 31 136 52 10 931 1531 10 42 | 32 18 462 20 1351 1951 10 43 | 33 390 120 24 3777 4377 10 44 | 34 188 119 44 3659 4259 10 45 | 35 467 114 10 1264 1864 10 46 | 36 440 292 24 3520 4120 10 47 | 37 268 400 20 733 1333 10 48 | 38 391 202 14 296 896 10 49 | 39 377 432 20 3086 3686 10 50 | 40 80 290 10 550 1150 10 51 | 41 439 15 20 1133 1733 10 52 | 42 307 52 23 3442 4042 10 53 | 43 111 192 11 4558 5158 10 54 | 44 131 56 10 783 1383 10 55 | 45 88 286 10 770 1370 10 56 | 46 69 414 6 4813 5413 10 57 | 47 41 232 16 581 1181 10 58 | 48 323 77 36 5380 5980 10 59 | 49 340 416 36 1044 1644 10 60 | 50 86 199 23 871 1471 10 61 | 51 314 124 20 684 1284 10 62 | 52 375 191 30 427 1027 10 63 | 53 226 175 23 6535 7135 10 64 | 54 242 106 28 4834 5434 10 65 | 55 417 417 10 1088 1688 10 66 | 56 419 459 20 1025 1625 10 67 | 57 389 11 20 1053 1653 10 68 | 58 450 416 25 2067 2667 10 69 | 59 246 255 10 210 810 10 70 | 60 71 333 10 535 1135 10 71 | 61 105 474 27 1643 2243 10 72 | 62 20 489 10 1293 1893 10 73 | 63 388 331 20 340 940 10 74 | 64 92 259 4 1358 1958 10 75 | 65 200 261 10 426 1026 10 76 | 66 400 288 30 319 919 10 77 | 67 299 285 3 4775 5375 10 78 | 68 378 199 10 589 1189 10 79 | 69 325 147 14 4507 5107 10 80 | 70 421 386 29 3057 3657 10 81 | 71 404 447 20 700 1300 10 82 | 72 412 478 7 3599 4199 10 83 | 73 26 67 15 5027 5627 10 84 | 74 358 183 20 695 1295 10 85 | 75 30 302 10 826 1426 10 86 | 76 176 470 14 1947 2547 10 87 | 77 96 270 20 409 1009 10 88 | 78 243 408 15 5495 6095 10 89 | 79 60 29 32 5211 5811 10 90 | 80 34 169 11 1698 2298 10 91 | 81 407 280 10 594 1194 10 92 | 82 277 403 10 459 1059 10 93 | 83 498 456 27 5384 5984 10 94 | 84 384 491 20 1151 1751 10 95 | 85 355 174 33 2621 3221 10 96 | 86 97 288 22 4896 5496 10 97 | 87 316 284 20 259 859 10 98 | 88 334 403 26 398 998 10 99 | 89 415 223 20 979 1579 10 100 | 90 230 320 8 4528 5128 10 101 | 91 432 199 7 2314 2914 10 102 | 92 92 18 8 4257 4857 10 103 | 93 273 300 30 55 655 10 104 | 94 269 112 19 4811 5411 10 105 | 95 429 389 18 1456 2056 10 106 | 96 371 71 21 907 1507 10 107 | 97 5 297 10 1085 1685 10 108 | 98 414 378 23 1739 2339 10 109 | 99 38 15 3 4124 4724 10 110 | 100 2 295 30 983 1583 10 111 | 101 237 254 20 93 693 10 112 | 102 54 445 10 992 1592 10 113 | 103 382 110 24 4210 4810 10 114 | 104 438 488 18 1069 1669 10 115 | 105 395 331 20 626 1226 10 116 | 106 230 487 20 4278 4878 10 117 | 107 249 407 10 455 1055 10 118 | 108 488 26 30 1491 2091 10 119 | 109 151 81 28 5992 6592 10 120 | 110 483 14 10 1213 1813 10 121 | 111 0 422 8 3044 3644 10 122 | 112 429 67 16 2689 3289 10 123 | 113 195 464 20 5925 6525 10 124 | 114 356 256 19 125 725 10 125 | 115 264 180 33 6483 7083 10 126 | 116 94 235 20 367 967 10 127 | 117 474 96 30 787 1387 10 128 | 118 268 52 10 982 1582 10 129 | 119 44 440 24 2915 3515 10 130 | 120 7 382 27 2842 3442 10 131 | 121 459 53 20 4249 4849 10 132 | 122 491 25 10 1394 1994 10 133 | 123 439 243 20 1014 1614 10 134 | 124 210 185 20 76 676 10 135 | 125 150 68 23 1451 2051 10 136 | 126 201 270 10 52 652 10 137 | 127 0 188 26 3488 4088 10 138 | 128 103 464 22 4852 5452 10 139 | 129 325 56 13 2946 3546 10 140 | 130 44 344 12 4078 4678 10 141 | 131 418 75 11 1552 2152 10 142 | 132 472 57 17 4939 5539 10 143 | 133 460 328 13 636 1236 10 144 | 134 89 270 10 574 1174 10 145 | 135 374 190 20 333 933 10 146 | 136 463 253 23 3948 4548 10 147 | 137 97 93 20 722 1322 10 148 | 138 163 472 9 2374 2974 10 149 | 139 29 336 22 1086 1686 10 150 | 140 84 453 19 4652 5252 10 151 | 141 294 421 26 6062 6662 10 152 | 142 343 62 10 1190 1790 10 153 | 143 371 193 20 235 835 10 154 | 144 142 372 18 352 952 10 155 | 145 66 88 2 3079 3679 10 156 | 146 395 332 10 582 1182 10 157 | 147 93 413 17 605 1205 10 158 | 148 267 394 10 797 1397 10 159 | 149 249 258 30 267 867 10 160 | 150 472 129 10 770 1370 10 161 | 151 87 3 13 5492 6092 10 162 | 152 62 326 20 905 1505 10 163 | 153 212 186 11 6600 7200 10 164 | 154 241 402 11 3859 4459 10 165 | 155 439 266 10 501 1101 10 166 | 156 79 80 19 5288 5888 10 167 | 157 62 453 10 939 1539 10 168 | 158 188 151 7 4947 5547 10 169 | 159 386 154 31 4164 4764 10 170 | 160 38 301 20 942 1542 10 171 | 161 192 265 10 257 857 10 172 | 162 371 192 30 279 879 10 173 | 163 64 294 12 4165 4765 10 174 | 164 381 494 10 1094 1694 10 175 | 165 437 12 20 1078 1678 10 176 | 166 186 135 24 2631 3231 10 177 | 167 459 10 10 1100 1700 10 178 | 168 175 422 24 5546 6146 10 179 | 169 274 48 10 605 1205 10 180 | 170 488 173 20 875 1475 10 181 | 171 398 97 10 596 1196 10 182 | 172 385 17 40 2995 3595 10 183 | 173 180 283 23 2735 3335 10 184 | 174 71 12 2 932 1532 10 185 | 175 343 49 10 820 1420 10 186 | 176 248 251 20 2 602 10 187 | 177 7 194 29 3565 4165 10 188 | 178 322 290 23 5676 6276 10 189 | 179 410 399 25 695 1295 10 190 | 180 398 103 30 874 1474 10 191 | 181 385 285 13 3232 3832 10 192 | 182 179 497 1 5404 6004 10 193 | 183 464 13 20 1299 1899 10 194 | 184 492 335 10 3073 3673 10 195 | 185 27 464 21 4924 5524 10 196 | 186 231 29 14 4665 5265 10 197 | 187 157 38 3 3951 4551 10 198 | 188 439 268 10 951 1551 10 199 | 189 149 214 7 1688 2288 10 200 | 190 187 73 18 928 1528 10 201 | 191 429 169 8 3371 3971 10 202 | 192 350 199 21 4566 5166 10 203 | 193 60 231 32 3864 4464 10 204 | 194 448 404 15 2156 2756 10 205 | 195 481 20 20 1148 1748 10 206 | 196 436 25 19 4889 5489 10 207 | 197 111 459 20 1195 1795 10 208 | 198 389 17 10 1223 1823 10 209 | 199 148 208 22 1866 2466 10 210 | 200 475 477 20 1378 1978 10 211 | 201 390 325 30 765 1365 10 212 | 202 346 354 8 3030 3630 10 213 | 203 91 266 10 690 1290 10 214 | 204 17 65 20 1067 1667 10 215 | 205 391 112 24 3761 4361 10 216 | 206 224 203 20 53 653 10 217 | 207 426 231 24 3874 4474 10 218 | 208 260 472 33 3904 4504 10 219 | 209 265 0 10 3344 3944 10 220 | 210 391 293 20 663 1263 10 221 | 211 411 421 20 1020 1620 10 222 | 212 132 30 20 1063 1663 10 223 | 213 475 480 30 1278 1878 10 224 | 214 286 244 31 4896 5496 10 225 | 215 436 237 20 446 1046 10 226 | 216 402 284 30 418 1018 10 227 | 217 287 397 12 2017 2617 10 228 | 218 272 420 7 5303 5903 10 229 | 219 477 120 10 1128 1728 10 230 | 220 145 434 20 692 1292 10 231 | 221 33 286 11 5944 6544 10 232 | 222 370 262 15 4158 4758 10 233 | 223 393 20 20 1323 1923 10 234 | 224 330 308 24 4442 5042 10 235 | 225 246 398 40 292 892 10 236 | 226 482 184 14 4187 4787 10 237 | 227 451 305 13 534 1134 10 238 | 228 226 316 21 70 670 10 239 | 229 110 459 30 1151 1751 10 240 | 230 244 250 10 6 606 10 241 | 231 458 16 20 952 1552 10 242 | 232 390 34 7 4001 4601 10 243 | 233 423 214 20 627 1227 10 244 | 234 219 215 32 46 646 10 245 | 235 326 118 10 351 951 10 246 | 236 365 74 24 3154 3754 10 247 | 237 331 356 13 2607 3207 10 248 | 238 210 398 10 577 1177 10 249 | 239 403 93 10 1123 1723 10 250 | 240 248 404 30 358 958 10 251 | 241 65 62 15 3666 4266 10 252 | 242 460 13 20 1047 1647 10 253 | 243 0 293 30 875 1475 10 254 | 244 211 248 26 39 639 10 255 | 245 484 174 10 818 1418 10 256 | 246 175 352 12 6420 7020 10 257 | 247 455 168 21 3227 3827 10 258 | 248 224 191 20 84 684 10 259 | 249 439 156 2 1863 2463 10 260 | 250 434 359 13 5329 5929 10 261 | 251 118 314 26 1110 1710 10 262 | 252 234 246 10 19 619 10 263 | 253 406 450 20 797 1397 10 264 | 254 75 118 21 1396 1996 10 265 | 255 115 395 11 3021 3621 10 266 | 256 329 456 19 756 1356 10 267 | 257 218 403 15 5037 5637 10 268 | 258 149 341 6 1376 1976 10 269 | 259 253 74 20 5160 5760 10 270 | 260 436 241 20 1069 1669 10 271 | 261 238 203 10 135 735 10 272 | 262 405 455 40 1123 1723 10 273 | 263 485 27 10 1544 2144 10 274 | 264 323 118 20 403 1003 10 275 | 265 330 371 1 1994 2594 10 276 | 266 25 65 10 1265 1865 10 277 | 267 406 96 20 623 1223 10 278 | 268 49 451 20 880 1480 10 279 | 269 307 249 10 5266 5866 10 280 | 270 178 135 21 5815 6415 10 281 | 271 299 353 34 156 756 10 282 | 272 236 213 20 39 639 10 283 | 273 355 177 20 257 857 10 284 | 274 394 23 20 1375 1975 10 285 | 275 306 235 25 57 657 10 286 | 276 90 477 18 811 1411 10 287 | 277 379 486 22 2447 3047 10 288 | 278 435 16 10 1230 1830 10 289 | 279 8 497 40 1391 1991 10 290 | 280 150 484 16 2261 2861 10 291 | 281 213 399 18 696 1296 10 292 | 282 391 18 10 1271 1871 10 293 | 283 111 392 18 4436 5036 10 294 | 284 330 281 14 5082 5682 10 295 | 285 344 203 14 429 1029 10 296 | 286 91 235 10 836 1436 10 297 | 287 346 60 10 1045 1645 10 298 | 288 483 27 20 1592 2192 10 299 | 289 382 498 10 997 1597 10 300 | 290 457 492 7 1792 2392 10 301 | 291 291 213 23 4791 5391 10 302 | 292 154 374 36 3508 4108 10 303 | 293 225 196 10 59 659 10 304 | 294 94 40 24 4032 4632 10 305 | 295 0 356 13 4105 4705 10 306 | 296 297 283 28 5158 5758 10 307 | 297 371 423 10 544 1144 10 308 | 298 417 217 30 514 1114 10 309 | 299 500 228 8 2887 3487 10 310 | 300 412 214 10 364 964 10 311 | 301 442 289 25 524 1124 10 312 | 302 157 269 31 6065 6665 10 313 | 303 440 241 10 965 1565 10 314 | 304 100 266 20 346 946 10 315 | 305 111 178 18 326 926 10 316 | 306 91 101 10 953 1553 10 317 | 307 25 307 10 758 1358 10 318 | 308 135 400 20 954 1554 10 319 | 309 58 458 10 1051 1651 10 320 | 310 133 26 10 1007 1607 10 321 | 311 211 386 20 266 866 10 322 | 312 94 97 20 616 1216 10 323 | 313 30 155 9 4882 5482 10 324 | 314 208 184 20 78 678 10 325 | 315 394 333 20 537 1137 10 326 | 316 355 180 30 309 909 10 327 | 317 241 180 13 6538 7138 10 328 | 318 21 485 30 1113 1713 10 329 | 319 80 251 14 974 1574 10 330 | 320 476 61 36 1555 2155 10 331 | 321 406 94 10 671 1271 10 332 | 322 364 71 5 5154 5754 10 333 | 323 418 221 10 925 1525 10 334 | 324 274 441 12 2538 3138 10 335 | 325 304 97 20 487 1087 10 336 | 326 297 102 10 369 969 10 337 | 327 250 405 20 406 1006 10 338 | 328 111 463 20 1046 1646 10 339 | 329 408 279 20 640 1240 10 340 | 330 263 418 25 874 1474 10 341 | 331 480 119 7 2274 2874 10 342 | 332 420 383 27 3688 4288 10 343 | 333 142 14 18 3101 3701 10 344 | 334 73 328 20 474 1074 10 345 | 335 50 438 20 1107 1707 10 346 | 336 441 7 20 1326 1926 10 347 | 337 462 14 20 1348 1948 10 348 | 338 360 294 9 5431 6031 10 349 | 339 58 39 12 4412 5012 10 350 | 340 58 391 16 3289 3889 10 351 | 341 410 285 20 531 1131 10 352 | 342 96 97 20 568 1168 10 353 | 343 21 64 20 1169 1769 10 354 | 344 238 210 30 295 895 10 355 | 345 479 121 10 991 1591 10 356 | 346 200 178 20 134 734 10 357 | 347 216 341 19 2376 2976 10 358 | 348 48 437 4 2975 3575 10 359 | 349 200 270 20 53 653 10 360 | 350 357 181 20 358 958 10 361 | 351 476 174 30 1057 1657 10 362 | 352 400 286 10 367 967 10 363 | 353 351 481 10 1047 1647 10 364 | 354 270 400 10 305 905 10 365 | 355 95 234 10 413 1013 10 366 | 356 128 113 22 1211 1811 10 367 | 357 133 455 25 2992 3592 10 368 | 358 16 463 20 1259 1859 10 369 | 359 59 388 20 2411 3011 10 370 | 360 376 190 30 381 981 10 371 | 361 481 122 30 942 1542 10 372 | 362 266 405 20 628 1228 10 373 | 363 374 232 33 201 801 10 374 | 364 398 20 20 836 1436 10 375 | 365 481 26 30 987 1587 10 376 | 366 63 444 20 1279 1879 10 377 | 367 89 290 20 430 1030 10 378 | 368 246 314 36 5541 6141 10 379 | 369 40 304 16 4339 4939 10 380 | 370 262 369 15 277 877 10 381 | 371 323 29 7 4310 4910 10 382 | 372 89 65 16 2641 3241 10 383 | 373 144 35 26 659 1259 10 384 | 374 200 265 10 370 970 10 385 | 375 436 264 20 446 1046 10 386 | 376 15 457 20 1054 1654 10 387 | 377 397 20 20 880 1480 10 388 | 378 328 491 21 2473 3073 10 389 | 379 399 175 13 2748 3348 10 390 | 380 432 2 20 1626 2226 10 391 | 381 63 336 20 825 1425 10 392 | 382 6 296 10 1039 1639 10 393 | 383 146 376 8 697 1297 10 394 | 384 295 247 12 4974 5574 10 395 | 385 235 33 30 5108 5708 10 396 | 386 233 204 20 49 649 10 397 | 387 142 360 20 5888 6488 10 398 | 388 177 156 25 429 1029 10 399 | 389 315 287 30 352 952 10 400 | 390 452 172 9 2193 2793 10 401 | 391 263 153 12 1410 2010 10 402 | 392 493 493 20 3186 3786 10 403 | 393 320 283 30 202 802 10 404 | 394 64 5 14 4276 4876 10 405 | 395 95 235 10 323 923 10 406 | 396 203 211 20 4986 5586 10 407 | 397 16 497 20 1463 2063 10 408 | 398 348 348 23 3499 4099 10 409 | 399 485 104 21 2938 3538 10 410 | 400 330 147 28 3154 3754 10 411 | 401 443 237 20 514 1114 10 412 | 402 316 286 30 307 907 10 413 | 403 335 46 18 5127 5727 10 414 | 404 381 495 20 1050 1650 10 415 | 405 364 173 30 481 1081 10 416 | 406 267 162 6 5557 6157 10 417 | 407 214 245 8 36 636 10 418 | 408 92 234 10 699 1299 10 419 | 409 347 459 25 1678 2278 10 420 | 410 30 7 23 4514 5114 10 421 | 411 120 37 28 2861 3461 10 422 | 412 397 153 29 3290 3890 10 423 | 413 210 29 13 3963 4563 10 424 | 414 87 285 30 724 1324 10 425 | 415 132 32 18 2898 3498 10 426 | 416 390 294 20 709 1309 10 427 | 417 67 451 5 4622 5222 10 428 | 418 24 68 20 1418 2018 10 429 | 419 146 439 10 797 1397 10 430 | 420 209 212 18 5871 6471 10 431 | 421 6 292 10 730 1330 10 432 | 422 18 63 10 1116 1716 10 433 | 423 149 98 4 4420 5020 10 434 | 424 91 268 10 738 1338 10 435 | 425 103 177 28 2266 2866 10 436 | 426 367 178 20 481 1081 10 437 | 427 225 269 30 4843 5443 10 438 | 428 443 246 20 679 1279 10 439 | 429 306 42 11 1667 2267 10 440 | 430 374 306 4 3736 4336 10 441 | 431 413 421 10 972 1572 10 442 | 432 470 405 17 3463 4063 10 443 | 433 33 278 18 5709 6309 10 444 | 434 149 458 13 4415 5015 10 445 | 435 257 57 18 4664 5264 10 446 | 436 272 403 30 519 1119 10 447 | 437 221 291 9 50 650 10 448 | 438 1 101 8 4789 5389 10 449 | 439 332 459 35 1235 1835 10 450 | 440 220 392 20 791 1391 10 451 | 441 253 50 27 663 1263 10 452 | 442 250 441 5 2783 3383 10 453 | 443 471 484 10 1119 1719 10 454 | 444 480 152 26 3846 4446 10 455 | 445 404 83 30 954 1554 10 456 | 446 476 94 20 839 1439 10 457 | 447 458 213 22 4273 4873 10 458 | 448 215 395 20 728 1328 10 459 | 449 85 288 20 488 1088 10 460 | 450 179 75 13 2720 3320 10 461 | 451 228 287 21 43 643 10 462 | 452 397 18 10 928 1528 10 463 | 453 238 204 20 179 779 10 464 | 454 488 3 3 1362 1962 10 465 | 455 407 88 10 1058 1658 10 466 | 456 459 14 20 1001 1601 10 467 | 457 120 17 30 876 1476 10 468 | 458 235 316 2 2383 2983 10 469 | 459 370 382 11 3295 3895 10 470 | 460 405 454 11 4972 5572 10 471 | 461 17 458 10 1492 2092 10 472 | 462 43 135 31 647 1247 10 473 | 463 318 497 21 3175 3775 10 474 | 464 199 268 20 54 654 10 475 | 465 111 467 20 908 1508 10 476 | 466 138 438 20 909 1509 10 477 | 467 172 314 9 1942 2542 10 478 | 468 494 468 31 1170 1770 10 479 | 469 35 303 20 586 1186 10 480 | 470 341 59 27 2919 3519 10 481 | 471 423 221 9 793 1393 10 482 | 472 395 295 20 605 1205 10 483 | 473 413 417 10 1184 1784 10 484 | 474 339 60 20 604 1204 10 485 | 475 277 428 7 1721 2321 10 486 | 476 176 199 28 89 689 10 487 | 477 265 240 9 18 618 10 488 | 478 365 190 22 5670 6270 10 489 | 479 133 53 20 878 1478 10 490 | 480 387 488 20 1208 1808 10 491 | 481 385 295 20 269 869 10 492 | 482 491 369 28 2678 3278 10 493 | 483 445 273 20 791 1391 10 494 | 484 195 273 22 59 659 10 495 | 485 313 493 20 4532 5132 10 496 | 486 495 227 20 1136 1736 10 497 | 487 241 403 10 641 1241 10 498 | 488 30 72 10 1486 2086 10 499 | 489 21 487 10 1161 1761 10 500 | 490 324 99 10 1112 1712 10 501 | 491 453 318 30 1255 1855 10 502 | 492 443 272 10 840 1440 10 503 | 493 447 184 27 1458 2058 10 504 | 494 366 288 29 2495 3095 10 505 | 495 440 284 25 3167 3767 10 506 | 496 13 314 14 735 1335 10 507 | 497 72 227 25 2015 2615 10 508 | 498 377 385 6 3225 3825 10 509 | 499 477 478 20 1329 1929 10 510 | 500 204 185 20 413 1013 10 511 | 501 226 191 20 132 732 10 512 | 502 330 138 18 4198 4798 10 513 | 503 185 434 9 2054 2654 10 514 | 504 483 22 10 1096 1696 10 515 | 505 71 282 29 2327 2927 10 516 | 506 60 5 18 3935 4535 10 517 | 507 189 402 10 1904 2504 10 518 | 508 134 211 35 242 842 10 519 | 509 146 313 22 4541 5141 10 520 | 510 21 146 21 1707 2307 10 521 | 511 37 281 17 1733 2333 10 522 | 512 416 417 20 1132 1732 10 523 | 513 44 311 27 1390 1990 10 524 | 514 361 181 20 548 1148 10 525 | 515 444 242 10 622 1222 10 526 | 516 444 271 10 742 1342 10 527 | 517 359 179 20 409 1009 10 528 | 518 388 334 20 392 992 10 529 | 519 401 164 13 2245 2845 10 530 | 520 499 316 18 2247 2847 10 531 | 521 399 106 20 967 1567 10 532 | 522 425 215 10 676 1276 10 533 | 523 407 98 10 574 1174 10 534 | 524 406 460 2 2637 3237 10 535 | 525 88 95 20 841 1441 10 536 | 526 95 64 4 2824 3424 10 537 | 527 306 229 10 5041 5641 10 538 | 528 273 55 20 485 1085 10 539 | 529 384 149 18 4549 5149 10 540 | 530 122 35 10 741 1341 10 541 | 531 308 199 14 5793 6393 10 542 | 532 390 301 10 421 1021 10 543 | 533 300 108 10 302 902 10 544 | 534 267 400 10 689 1289 10 545 | 535 8 300 10 1183 1783 10 546 | 536 105 181 19 5885 6485 10 547 | 537 398 325 30 693 1293 10 548 | 538 166 247 1 84 684 10 549 | 539 140 431 30 588 1188 10 550 | 540 253 118 19 1949 2549 10 551 | 541 359 246 18 5451 6051 10 552 | 542 321 277 10 75 675 10 553 | 543 168 59 6 1224 1824 10 554 | 544 406 285 20 475 1075 10 555 | 545 391 334 20 484 1084 10 556 | 546 437 19 15 3816 4416 10 557 | 547 201 278 13 56 656 10 558 | 548 435 267 20 1051 1651 10 559 | 549 245 408 10 575 1175 10 560 | 550 16 462 10 1303 1903 10 561 | 551 107 374 8 3417 4017 10 562 | 552 477 97 10 891 1491 10 563 | 553 346 57 20 993 1593 10 564 | 554 14 459 20 1103 1703 10 565 | 555 102 6 3 5594 6194 10 566 | 556 359 287 24 160 760 10 567 | 557 297 131 25 4422 5022 10 568 | 558 282 1 18 3930 4530 10 569 | 559 21 70 15 2845 3445 10 570 | 560 440 244 10 824 1424 10 571 | 561 482 104 19 2990 3590 10 572 | 562 120 261 5 2933 3533 10 573 | 563 125 29 30 893 1493 10 574 | 564 292 32 14 677 1277 10 575 | 565 262 92 25 2282 2882 10 576 | 566 68 160 21 4303 4903 10 577 | 567 405 276 20 697 1297 10 578 | 568 277 50 10 551 1151 10 579 | 569 32 319 21 1362 1962 10 580 | 570 344 70 24 4343 4943 10 581 | 571 481 84 17 1782 2382 10 582 | 572 21 68 20 1366 1966 10 583 | 573 441 244 10 868 1468 10 584 | 574 57 43 15 3854 4454 10 585 | 575 1 293 10 831 1431 10 586 | 576 481 96 20 948 1548 10 587 | 577 471 368 19 1472 2072 10 588 | 578 236 126 23 199 799 10 589 | 579 406 99 20 668 1268 10 590 | 580 303 186 10 5177 5777 10 591 | 581 225 369 38 186 786 10 592 | 582 412 453 10 948 1548 10 593 | 583 104 349 20 3797 4397 10 594 | 584 173 182 25 111 711 10 595 | 585 111 464 10 1002 1602 10 596 | 586 53 440 10 1052 1652 10 597 | 587 69 336 20 632 1232 10 598 | 588 359 182 20 597 1197 10 599 | 589 13 459 20 1147 1747 10 600 | 590 244 277 18 4965 5565 10 601 | 591 484 177 20 766 1366 10 602 | 592 452 206 31 1729 2329 10 603 | 593 22 483 30 1004 1604 10 604 | 594 452 110 14 1121 1721 10 605 | 595 347 192 18 5713 6313 10 606 | 596 95 92 20 771 1371 10 607 | 597 368 311 14 3464 4064 10 608 | 598 479 387 13 1350 1950 10 609 | 599 479 169 20 994 1594 10 610 | 600 497 266 25 2750 3350 10 611 | 601 66 336 10 773 1373 10 612 | 602 376 195 10 484 1084 10 613 | 603 401 281 20 804 1404 10 614 | 604 441 177 23 3765 4365 10 615 | 605 231 203 20 50 650 10 616 | 606 21 488 10 1205 1805 10 617 | 607 231 204 20 361 961 10 618 | 608 122 422 3 5587 6187 10 619 | 609 65 453 30 887 1487 10 620 | 610 206 261 10 490 1090 10 621 | 611 466 149 16 4504 5104 10 622 | 612 313 119 30 623 1223 10 623 | 613 90 274 20 477 1077 10 624 | 614 39 162 18 2021 2621 10 625 | 615 35 306 20 678 1278 10 626 | 616 437 15 30 1181 1781 10 627 | 617 307 412 8 1375 1975 10 628 | 618 79 291 10 595 1195 10 629 | 619 64 437 11 3433 4033 10 630 | 620 376 92 10 3722 4322 10 631 | 621 129 27 10 950 1550 10 632 | 622 196 489 23 3881 4481 10 633 | 623 51 286 14 5596 6196 10 634 | 624 20 488 10 1249 1849 10 635 | 625 13 455 10 1003 1603 10 636 | 626 170 347 15 1503 2103 10 637 | 627 92 230 20 515 1115 10 638 | 628 117 467 10 718 1318 10 639 | 629 413 217 20 416 1016 10 640 | 630 405 450 20 753 1353 10 641 | 631 394 322 12 3859 4459 10 642 | 632 125 61 26 2207 2807 10 643 | 633 238 123 24 2884 3484 10 644 | 634 11 403 18 1132 1732 10 645 | 635 89 272 10 526 1126 10 646 | 636 304 102 30 547 1147 10 647 | 637 478 121 40 1035 1635 10 648 | 638 408 84 10 897 1497 10 649 | 639 376 494 30 839 1439 10 650 | 640 20 73 10 861 1461 10 651 | 641 159 299 12 3822 4422 10 652 | 642 95 382 19 685 1285 10 653 | 643 352 63 6 4473 5073 10 654 | 644 365 274 14 170 770 10 655 | 645 30 301 10 870 1470 10 656 | 646 351 5 12 1744 2344 10 657 | 647 197 267 10 195 795 10 658 | 648 498 171 12 4786 5386 10 659 | 649 468 352 9 2833 3433 10 660 | 650 418 251 21 4547 5147 10 661 | 651 489 437 29 2587 3187 10 662 | 652 251 63 14 3710 4310 10 663 | 653 132 55 10 829 1429 10 664 | 654 281 96 1 4263 4863 10 665 | 655 333 293 27 2228 2828 10 666 | 656 255 487 19 1352 1952 10 667 | 657 207 400 20 522 1122 10 668 | 658 469 489 4 1982 2582 10 669 | 659 244 254 20 161 761 10 670 | 660 233 207 10 46 646 10 671 | 661 441 60 21 5595 6195 10 672 | 662 411 379 25 4533 5133 10 673 | 663 178 72 23 2787 3387 10 674 | 664 51 447 10 938 1538 10 675 | 665 478 118 20 1177 1777 10 676 | 666 141 426 23 1886 2486 10 677 | 667 295 89 23 2728 3328 10 678 | 668 112 433 29 700 1300 10 679 | 669 320 211 16 3730 4330 10 680 | 670 400 103 10 782 1382 10 681 | 671 408 453 10 892 1492 10 682 | 672 435 180 37 658 1258 10 683 | 673 432 66 30 4045 4645 10 684 | 674 374 116 9 2109 2709 10 685 | 675 478 102 10 1057 1657 10 686 | 676 335 57 30 544 1144 10 687 | 677 385 239 21 2902 3502 10 688 | 678 386 245 16 1676 2276 10 689 | 679 208 396 20 466 1066 10 690 | 680 380 489 20 1276 1876 10 691 | 681 380 498 10 949 1549 10 692 | 682 440 7 20 1015 1615 10 693 | 683 434 245 10 1127 1727 10 694 | 684 90 232 10 606 1206 10 695 | 685 389 334 20 436 1036 10 696 | 686 241 205 30 232 832 10 697 | 687 18 24 32 2273 2873 10 698 | 688 57 183 15 4161 4761 10 699 | 689 59 457 30 1097 1697 10 700 | 690 442 243 10 914 1514 10 701 | 691 402 281 20 760 1360 10 702 | 692 445 237 10 562 1162 10 703 | 693 441 273 20 889 1489 10 704 | 694 31 175 24 746 1346 10 705 | 695 234 202 10 79 679 10 706 | 696 52 303 25 1525 2125 10 707 | 697 167 445 7 5408 6008 10 708 | 698 179 286 8 1125 1725 10 709 | 699 269 48 20 882 1482 10 710 | 700 165 59 27 3531 4131 10 711 | 701 461 8 20 1236 1836 10 712 | 702 421 415 30 701 1301 10 713 | 703 59 459 20 1005 1605 10 714 | 704 24 492 10 1608 2208 10 715 | 705 55 449 20 814 1414 10 716 | 706 224 192 10 63 663 10 717 | 707 444 269 20 694 1294 10 718 | 708 491 20 20 1334 1934 10 719 | 709 313 126 10 733 1333 10 720 | 710 283 438 3 686 1286 10 721 | 711 352 241 5 2929 3529 10 722 | 712 398 476 25 1432 2032 10 723 | 713 442 247 10 724 1324 10 724 | 714 217 207 26 5290 5890 10 725 | 715 233 87 18 770 1370 10 726 | 716 479 127 20 839 1439 10 727 | 717 6 53 8 2108 2708 10 728 | 718 478 300 12 3318 3918 10 729 | 719 378 493 30 887 1487 10 730 | 720 303 78 12 420 1020 10 731 | 721 344 62 10 1146 1746 10 732 | 722 371 315 18 4423 5023 10 733 | 723 200 78 31 3731 4331 10 734 | 724 413 391 8 628 1228 10 735 | 725 415 216 10 465 1065 10 736 | 726 397 57 17 5664 6264 10 737 | 727 293 228 19 48 648 10 738 | 728 0 297 10 931 1531 10 739 | 729 435 20 20 1286 1886 10 740 | 730 195 111 15 3752 4352 10 741 | 731 417 218 10 872 1472 10 742 | 732 340 54 10 711 1311 10 743 | 733 132 57 20 738 1338 10 744 | 734 210 379 12 2595 3195 10 745 | 735 228 260 12 6182 6782 10 746 | 736 399 104 10 919 1519 10 747 | 737 95 277 20 858 1458 10 748 | 738 360 284 19 2426 3026 10 749 | 739 53 466 9 1100 1700 10 750 | 740 112 465 10 957 1557 10 751 | 741 313 391 5 358 958 10 752 | 742 93 235 10 745 1345 10 753 | 743 125 32 30 798 1398 10 754 | 744 215 282 21 5522 6122 10 755 | 745 224 320 36 4895 5495 10 756 | 746 134 428 20 992 1592 10 757 | 747 26 490 10 1659 2259 10 758 | 748 44 115 24 685 1285 10 759 | 749 438 127 2 3524 4124 10 760 | 750 239 15 2 2175 2775 10 761 | 751 342 54 20 759 1359 10 762 | 752 109 463 30 1094 1694 10 763 | 753 199 187 20 267 867 10 764 | 754 201 188 10 315 915 10 765 | 755 399 301 30 537 1137 10 766 | 756 484 171 10 933 1533 10 767 | 757 272 234 26 6121 6721 10 768 | 758 380 350 15 3226 3826 10 769 | 759 140 108 29 4045 4645 10 770 | 760 228 199 10 297 897 10 771 | 761 245 461 8 2357 2957 10 772 | 762 305 107 20 661 1261 10 773 | 763 231 195 20 197 797 10 774 | 764 450 265 10 625 1225 10 775 | 765 273 149 14 5771 6371 10 776 | 766 12 358 7 4657 5257 10 777 | 767 315 121 10 572 1172 10 778 | 768 420 213 10 574 1174 10 779 | 769 331 134 11 4255 4855 10 780 | 770 84 377 10 3465 4065 10 781 | 771 320 280 10 100 700 10 782 | 772 89 185 16 2159 2759 10 783 | 773 472 481 20 1066 1666 10 784 | 774 422 420 20 810 1410 10 785 | 775 475 267 7 2878 3478 10 786 | 776 470 125 20 712 1312 10 787 | 777 435 268 10 1007 1607 10 788 | 778 409 155 19 441 1041 10 789 | 779 243 248 30 7 607 10 790 | 780 488 96 22 4025 4625 10 791 | 781 341 72 9 2979 3579 10 792 | 782 58 449 30 1211 1811 10 793 | 783 16 460 20 1403 2003 10 794 | 784 480 136 22 727 1327 10 795 | 785 162 388 11 4264 4864 10 796 | 786 47 208 30 666 1266 10 797 | 787 324 127 30 274 874 10 798 | 788 87 96 30 887 1487 10 799 | 789 140 137 32 2039 2639 10 800 | 790 314 205 22 5867 6467 10 801 | 791 96 346 26 501 1101 10 802 | 792 321 280 30 77 677 10 803 | 793 245 251 10 5 605 10 804 | 794 436 295 11 1873 2473 10 805 | 795 274 261 20 6588 7188 10 806 | 796 271 128 12 1142 1742 10 807 | 797 275 45 20 658 1258 10 808 | 798 422 409 10 637 1237 10 809 | 799 146 188 6 4700 5300 10 810 | 800 93 96 20 662 1262 10 811 | 801 409 255 23 5850 6450 10 812 | 802 449 428 25 4747 5347 10 813 | 803 90 285 40 865 1465 10 814 | 804 415 95 15 4467 5067 10 815 | 805 88 287 30 814 1414 10 816 | 806 379 196 20 536 1136 10 817 | 807 368 452 16 2440 3040 10 818 | 808 202 186 20 364 964 10 819 | 809 435 11 40 949 1549 10 820 | 810 269 46 20 834 1434 10 821 | 811 7 292 10 686 1286 10 822 | 812 44 496 32 1367 1967 10 823 | 813 478 99 10 1005 1605 10 824 | 814 391 99 20 526 1126 10 825 | 815 132 477 25 1069 1669 10 826 | 816 24 65 10 1221 1821 10 827 | 817 130 247 17 180 780 10 828 | 818 133 273 20 177 777 10 829 | 819 347 62 10 1094 1694 10 830 | 820 404 140 8 4795 5395 10 831 | 821 416 420 20 919 1519 10 832 | 822 67 335 20 727 1327 10 833 | 823 92 270 20 787 1387 10 834 | 824 411 95 30 731 1331 10 835 | 825 132 479 11 730 1330 10 836 | 826 366 334 5 1401 2001 10 837 | 827 125 39 20 681 1281 10 838 | 828 419 422 20 865 1465 10 839 | 829 460 2 20 1172 1772 10 840 | 830 67 334 20 683 1283 10 841 | 831 448 414 23 4651 5251 10 842 | 832 46 163 8 3464 4064 10 843 | 833 77 465 11 804 1404 10 844 | 834 284 319 17 3027 3627 10 845 | 835 102 422 23 665 1265 10 846 | 836 240 34 28 5998 6598 10 847 | 837 141 428 20 535 1135 10 848 | 838 204 269 30 49 649 10 849 | 839 144 439 30 845 1445 10 850 | 840 470 417 11 2707 3307 10 851 | 841 404 103 20 726 1326 10 852 | 842 5 281 16 5246 5846 10 853 | 843 487 320 21 3191 3791 10 854 | 844 398 23 10 784 1384 10 855 | 845 90 296 20 366 966 10 856 | 846 386 13 10 1108 1708 10 857 | 847 115 465 10 809 1409 10 858 | 848 473 475 10 1429 2029 10 859 | 849 275 42 30 710 1310 10 860 | 850 286 356 30 148 748 10 861 | 851 15 69 10 927 1527 10 862 | 852 267 44 20 783 1383 10 863 | 853 243 399 10 699 1299 10 864 | 854 390 249 21 2087 2687 10 865 | 855 210 391 30 326 926 10 866 | 856 433 15 20 891 1491 10 867 | 857 24 259 19 1240 1840 10 868 | 858 12 463 20 1203 1803 10 869 | 859 237 213 10 348 948 10 870 | 860 182 480 31 1219 1819 10 871 | 861 409 88 20 841 1441 10 872 | 862 244 368 25 1416 2016 10 873 | 863 381 328 12 2629 3229 10 874 | 864 213 185 21 74 674 10 875 | 865 482 141 14 3803 4403 10 876 | 866 319 124 20 472 1072 10 877 | 867 141 431 30 632 1232 10 878 | 868 198 264 20 321 921 10 879 | 869 69 334 30 584 1184 10 880 | 870 299 98 30 427 1027 10 881 | 871 240 250 10 10 610 10 882 | 872 199 203 20 5589 6189 10 883 | 873 459 17 20 1405 2005 10 884 | 874 423 217 20 727 1327 10 885 | 875 477 179 20 651 1251 10 886 | 876 213 397 10 629 1229 10 887 | 877 405 187 34 4762 5362 10 888 | 878 269 402 20 571 1171 10 889 | 879 53 204 8 3980 4580 10 890 | 880 13 394 15 1250 1850 10 891 | 881 15 68 10 971 1571 10 892 | 882 56 268 28 4016 4616 10 893 | 883 360 184 10 646 1246 10 894 | 884 307 102 40 599 1199 10 895 | 885 130 57 40 690 1290 10 896 | 886 250 328 24 755 1355 10 897 | 887 91 231 30 561 1161 10 898 | 888 479 176 20 706 1306 10 899 | 889 420 224 10 1476 2076 10 900 | 890 461 182 13 2276 2876 10 901 | 891 418 218 20 828 1428 10 902 | 892 419 418 10 756 1356 10 903 | 893 336 493 20 5732 6332 10 904 | 894 389 300 10 375 975 10 905 | 895 92 76 4 4316 4916 10 906 | 896 476 102 20 1105 1705 10 907 | 897 418 399 20 1511 2111 10 908 | 898 109 56 27 659 1259 10 909 | 899 13 465 31 2854 3454 10 910 | 900 92 232 10 467 1067 10 911 | 901 394 47 5 1012 1612 10 912 | 902 16 287 12 843 1443 10 913 | 903 399 102 20 828 1428 10 914 | 904 143 158 12 310 910 10 915 | 905 18 484 10 1060 1660 10 916 | 906 250 411 30 512 1112 10 917 | 907 19 273 25 3826 4426 10 918 | 908 365 28 9 833 1433 10 919 | 909 387 297 10 321 921 10 920 | 910 433 447 20 2937 3537 10 921 | 911 214 274 24 5236 5836 10 922 | 912 489 338 17 5349 5949 10 923 | 913 130 494 6 2795 3395 10 924 | 914 23 67 30 1317 1917 10 925 | 915 374 489 20 777 1377 10 926 | 916 126 30 10 847 1447 10 927 | 917 112 467 10 864 1464 10 928 | 918 489 274 31 1895 2495 10 929 | 919 61 214 4 1127 1727 10 930 | 920 166 440 12 531 1131 10 931 | 921 56 75 24 5511 6111 10 932 | 922 210 276 5 47 647 10 933 | 923 80 286 10 656 1256 10 934 | 924 17 459 10 1448 2048 10 935 | 925 66 448 10 781 1381 10 936 | 926 351 128 15 4773 5373 10 937 | 927 352 176 20 204 804 10 938 | 928 490 286 29 1849 2449 10 939 | 929 247 219 17 31 631 10 940 | 930 86 268 10 629 1229 10 941 | 931 398 329 17 371 971 10 942 | 932 272 402 10 398 998 10 943 | 933 317 123 20 521 1121 10 944 | 934 408 318 15 2332 2932 10 945 | 935 66 31 25 3954 4554 10 946 | 936 425 448 9 2938 3538 10 947 | 937 35 304 30 630 1230 10 948 | 938 471 94 30 3755 4355 10 949 | 939 470 473 10 1484 2084 10 950 | 940 224 56 13 4506 5106 10 951 | 941 343 47 20 868 1468 10 952 | 942 52 18 28 3188 3788 10 953 | 943 16 68 20 1015 1615 10 954 | 944 195 185 20 209 809 10 955 | 945 92 236 20 791 1391 10 956 | 946 76 462 18 3584 4184 10 957 | 947 124 56 20 625 1225 10 958 | 948 481 454 14 1042 1642 10 959 | 949 477 483 20 1223 1823 10 960 | 950 481 124 10 894 1494 10 961 | 951 389 156 27 2622 3222 10 962 | 952 384 16 20 1162 1762 10 963 | 953 492 34 5 3002 3602 10 964 | 954 371 200 10 657 1257 10 965 | 955 153 235 10 98 698 10 966 | 956 428 202 24 3375 3975 10 967 | 957 257 391 22 6292 6892 10 968 | 958 421 218 10 776 1376 10 969 | 959 206 186 10 510 1110 10 970 | 960 393 301 30 473 1073 10 971 | 961 204 187 30 461 1061 10 972 | 962 468 475 10 953 1553 10 973 | 963 477 122 10 1080 1680 10 974 | 964 100 66 15 5359 5959 10 975 | 965 489 27 10 1445 2045 10 976 | 966 12 451 20 946 1546 10 977 | 967 197 270 30 143 743 10 978 | 968 311 422 29 3712 4312 10 979 | 969 489 17 10 1280 1880 10 980 | 970 13 214 21 5174 5774 10 981 | 971 440 247 20 772 1372 10 982 | 972 28 467 34 5130 5730 10 983 | 973 388 325 10 813 1413 10 984 | 974 270 401 20 349 949 10 985 | 975 5 445 30 1004 1604 10 986 | 976 198 271 20 97 697 10 987 | 977 480 131 5 2510 3110 10 988 | 978 437 98 16 4215 4815 10 989 | 979 131 246 17 3088 3688 10 990 | 980 49 437 7 1470 2070 10 991 | 981 270 49 30 928 1528 10 992 | 982 337 41 8 3769 4369 10 993 | 983 318 280 20 148 748 10 994 | 984 154 392 9 386 986 10 995 | 985 493 111 26 1924 2524 10 996 | 986 399 450 20 1195 1795 10 997 | 987 67 452 30 838 1438 10 998 | 988 34 239 16 636 1236 10 999 | 989 343 276 15 96 696 10 1000 | 990 393 12 10 997 1597 10 1001 | 991 236 247 20 14 614 10 1002 | 992 340 291 22 1642 2242 10 1003 | 993 3 292 20 782 1382 10 1004 | 994 209 68 27 6032 6632 10 1005 | 995 18 225 8 2525 3125 10 1006 | 996 147 435 20 740 1340 10 1007 | 997 335 99 25 4634 5234 10 1008 | 998 485 24 20 1045 1645 10 1009 | 999 470 475 30 1001 1601 10 1010 | 1000 341 58 10 655 1255 10 1011 | -------------------------------------------------------------------------------- /Instances/S-RC2-1000/RC210_1.TXT: -------------------------------------------------------------------------------- 1 | rc210_1 2 | 3 | VEHICLE 4 | NUMBER CAPACITY 5 | 250 1000 6 | 7 | CUSTOMER 8 | CUST NO. XCOORD. YCOORD. DEMAND READY TIME DUE DATE SERVICE TIME 9 | 10 | 0 250 250 0 0 7284 0 11 | 1 440 436 18 3568 3688 10 12 | 2 214 394 10 922 1042 10 13 | 3 476 483 10 1419 1539 10 14 | 4 352 487 27 3607 3727 10 15 | 5 230 197 40 486 606 10 16 | 6 175 239 23 243 363 10 17 | 7 133 202 33 1842 1962 10 18 | 8 328 458 17 3071 3191 10 19 | 9 25 499 10 1780 1900 10 20 | 10 226 423 15 788 908 10 21 | 11 313 282 20 654 774 10 22 | 12 60 454 10 1389 1509 10 23 | 13 239 486 3 5928 6048 10 24 | 14 102 264 10 535 655 10 25 | 15 408 452 10 1088 1208 10 26 | 16 451 62 5 1129 1249 10 27 | 17 203 390 40 635 755 10 28 | 18 92 233 10 895 1015 10 29 | 19 7 300 30 1379 1499 10 30 | 20 409 90 20 1033 1153 10 31 | 21 307 108 10 950 1070 10 32 | 22 347 54 10 1180 1300 10 33 | 23 406 87 10 1252 1372 10 34 | 24 371 332 14 2118 2238 10 35 | 25 116 466 20 1004 1124 10 36 | 26 441 265 40 789 909 10 37 | 27 130 140 17 776 896 10 38 | 28 80 117 24 3297 3417 10 39 | 29 421 387 15 3205 3325 10 40 | 30 83 300 26 1999 2119 10 41 | 31 136 52 10 1171 1291 10 42 | 32 18 462 20 1591 1711 10 43 | 33 390 120 24 4017 4137 10 44 | 34 188 119 44 3899 4019 10 45 | 35 467 114 10 1504 1624 10 46 | 36 440 292 24 3760 3880 10 47 | 37 268 400 20 973 1093 10 48 | 38 391 202 14 536 656 10 49 | 39 377 432 20 3326 3446 10 50 | 40 80 290 10 790 910 10 51 | 41 439 15 20 1373 1493 10 52 | 42 307 52 23 3682 3802 10 53 | 43 111 192 11 4798 4918 10 54 | 44 131 56 10 1023 1143 10 55 | 45 88 286 10 1010 1130 10 56 | 46 69 414 6 5053 5173 10 57 | 47 41 232 16 821 941 10 58 | 48 323 77 36 5620 5740 10 59 | 49 340 416 36 1284 1404 10 60 | 50 86 199 23 1111 1231 10 61 | 51 314 124 20 924 1044 10 62 | 52 375 191 30 667 787 10 63 | 53 226 175 23 6775 6895 10 64 | 54 242 106 28 5074 5194 10 65 | 55 417 417 10 1328 1448 10 66 | 56 419 459 20 1265 1385 10 67 | 57 389 11 20 1293 1413 10 68 | 58 450 416 25 2307 2427 10 69 | 59 246 255 10 450 570 10 70 | 60 71 333 10 775 895 10 71 | 61 105 474 27 1883 2003 10 72 | 62 20 489 10 1533 1653 10 73 | 63 388 331 20 580 700 10 74 | 64 92 259 4 1598 1718 10 75 | 65 200 261 10 666 786 10 76 | 66 400 288 30 559 679 10 77 | 67 299 285 3 5015 5135 10 78 | 68 378 199 10 829 949 10 79 | 69 325 147 14 4747 4867 10 80 | 70 421 386 29 3297 3417 10 81 | 71 404 447 20 940 1060 10 82 | 72 412 478 7 3839 3959 10 83 | 73 26 67 15 5267 5387 10 84 | 74 358 183 20 935 1055 10 85 | 75 30 302 10 1066 1186 10 86 | 76 176 470 14 2187 2307 10 87 | 77 96 270 20 649 769 10 88 | 78 243 408 15 5735 5855 10 89 | 79 60 29 32 5451 5571 10 90 | 80 34 169 11 1938 2058 10 91 | 81 407 280 10 834 954 10 92 | 82 277 403 10 699 819 10 93 | 83 498 456 27 5624 5744 10 94 | 84 384 491 20 1391 1511 10 95 | 85 355 174 33 2861 2981 10 96 | 86 97 288 22 5136 5256 10 97 | 87 316 284 20 499 619 10 98 | 88 334 403 26 638 758 10 99 | 89 415 223 20 1219 1339 10 100 | 90 230 320 8 4768 4888 10 101 | 91 432 199 7 2554 2674 10 102 | 92 92 18 8 4497 4617 10 103 | 93 273 300 30 160 280 10 104 | 94 269 112 19 5051 5171 10 105 | 95 429 389 18 1696 1816 10 106 | 96 371 71 21 1147 1267 10 107 | 97 5 297 10 1325 1445 10 108 | 98 414 378 23 1979 2099 10 109 | 99 38 15 3 4364 4484 10 110 | 100 2 295 30 1223 1343 10 111 | 101 237 254 20 333 453 10 112 | 102 54 445 10 1232 1352 10 113 | 103 382 110 24 4450 4570 10 114 | 104 438 488 18 1309 1429 10 115 | 105 395 331 20 866 986 10 116 | 106 230 487 20 4518 4638 10 117 | 107 249 407 10 695 815 10 118 | 108 488 26 30 1731 1851 10 119 | 109 151 81 28 6232 6352 10 120 | 110 483 14 10 1453 1573 10 121 | 111 0 422 8 3284 3404 10 122 | 112 429 67 16 2929 3049 10 123 | 113 195 464 20 6165 6285 10 124 | 114 356 256 19 365 485 10 125 | 115 264 180 33 6723 6843 10 126 | 116 94 235 20 607 727 10 127 | 117 474 96 30 1027 1147 10 128 | 118 268 52 10 1222 1342 10 129 | 119 44 440 24 3155 3275 10 130 | 120 7 382 27 3082 3202 10 131 | 121 459 53 20 4489 4609 10 132 | 122 491 25 10 1634 1754 10 133 | 123 439 243 20 1254 1374 10 134 | 124 210 185 20 245 365 10 135 | 125 150 68 23 1691 1811 10 136 | 126 201 270 10 192 312 10 137 | 127 0 188 26 3728 3848 10 138 | 128 103 464 22 5092 5212 10 139 | 129 325 56 13 3186 3306 10 140 | 130 44 344 12 4318 4438 10 141 | 131 418 75 11 1792 1912 10 142 | 132 472 57 17 5179 5299 10 143 | 133 460 328 13 876 996 10 144 | 134 89 270 10 814 934 10 145 | 135 374 190 20 573 693 10 146 | 136 463 253 23 4188 4308 10 147 | 137 97 93 20 962 1082 10 148 | 138 163 472 9 2614 2734 10 149 | 139 29 336 22 1326 1446 10 150 | 140 84 453 19 4892 5012 10 151 | 141 294 421 26 6302 6422 10 152 | 142 343 62 10 1430 1550 10 153 | 143 371 193 20 475 595 10 154 | 144 142 372 18 592 712 10 155 | 145 66 88 2 3319 3439 10 156 | 146 395 332 10 822 942 10 157 | 147 93 413 17 845 965 10 158 | 148 267 394 10 1037 1157 10 159 | 149 249 258 30 507 627 10 160 | 150 472 129 10 1010 1130 10 161 | 151 87 3 13 5732 5852 10 162 | 152 62 326 20 1145 1265 10 163 | 153 212 186 11 6886 7006 10 164 | 154 241 402 11 4099 4219 10 165 | 155 439 266 10 741 861 10 166 | 156 79 80 19 5528 5648 10 167 | 157 62 453 10 1179 1299 10 168 | 158 188 151 7 5187 5307 10 169 | 159 386 154 31 4404 4524 10 170 | 160 38 301 20 1182 1302 10 171 | 161 192 265 10 497 617 10 172 | 162 371 192 30 519 639 10 173 | 163 64 294 12 4405 4525 10 174 | 164 381 494 10 1334 1454 10 175 | 165 437 12 20 1318 1438 10 176 | 166 186 135 24 2871 2991 10 177 | 167 459 10 10 1340 1460 10 178 | 168 175 422 24 5786 5906 10 179 | 169 274 48 10 845 965 10 180 | 170 488 173 20 1115 1235 10 181 | 171 398 97 10 836 956 10 182 | 172 385 17 40 3235 3355 10 183 | 173 180 283 23 2975 3095 10 184 | 174 71 12 2 1172 1292 10 185 | 175 343 49 10 1060 1180 10 186 | 176 248 251 20 2 122 10 187 | 177 7 194 29 3805 3925 10 188 | 178 322 290 23 5916 6036 10 189 | 179 410 399 25 935 1055 10 190 | 180 398 103 30 1114 1234 10 191 | 181 385 285 13 3472 3592 10 192 | 182 179 497 1 5644 5764 10 193 | 183 464 13 20 1539 1659 10 194 | 184 492 335 10 3313 3433 10 195 | 185 27 464 21 5164 5284 10 196 | 186 231 29 14 4905 5025 10 197 | 187 157 38 3 4191 4311 10 198 | 188 439 268 10 1191 1311 10 199 | 189 149 214 7 1928 2048 10 200 | 190 187 73 18 1168 1288 10 201 | 191 429 169 8 3611 3731 10 202 | 192 350 199 21 4806 4926 10 203 | 193 60 231 32 4104 4224 10 204 | 194 448 404 15 2396 2516 10 205 | 195 481 20 20 1388 1508 10 206 | 196 436 25 19 5129 5249 10 207 | 197 111 459 20 1435 1555 10 208 | 198 389 17 10 1463 1583 10 209 | 199 148 208 22 2106 2226 10 210 | 200 475 477 20 1618 1738 10 211 | 201 390 325 30 1005 1125 10 212 | 202 346 354 8 3270 3390 10 213 | 203 91 266 10 930 1050 10 214 | 204 17 65 20 1307 1427 10 215 | 205 391 112 24 4001 4121 10 216 | 206 224 203 20 155 275 10 217 | 207 426 231 24 4114 4234 10 218 | 208 260 472 33 4144 4264 10 219 | 209 265 0 10 3584 3704 10 220 | 210 391 293 20 903 1023 10 221 | 211 411 421 20 1260 1380 10 222 | 212 132 30 20 1303 1423 10 223 | 213 475 480 30 1518 1638 10 224 | 214 286 244 31 5136 5256 10 225 | 215 436 237 20 686 806 10 226 | 216 402 284 30 658 778 10 227 | 217 287 397 12 2257 2377 10 228 | 218 272 420 7 5543 5663 10 229 | 219 477 120 10 1368 1488 10 230 | 220 145 434 20 932 1052 10 231 | 221 33 286 11 6184 6304 10 232 | 222 370 262 15 4398 4518 10 233 | 223 393 20 20 1563 1683 10 234 | 224 330 308 24 4682 4802 10 235 | 225 246 398 40 532 652 10 236 | 226 482 184 14 4427 4547 10 237 | 227 451 305 13 774 894 10 238 | 228 226 316 21 221 341 10 239 | 229 110 459 30 1391 1511 10 240 | 230 244 250 10 47 167 10 241 | 231 458 16 20 1192 1312 10 242 | 232 390 34 7 4241 4361 10 243 | 233 423 214 20 867 987 10 244 | 234 219 215 32 127 247 10 245 | 235 326 118 10 591 711 10 246 | 236 365 74 24 3394 3514 10 247 | 237 331 356 13 2847 2967 10 248 | 238 210 398 10 817 937 10 249 | 239 403 93 10 1363 1483 10 250 | 240 248 404 30 598 718 10 251 | 241 65 62 15 3906 4026 10 252 | 242 460 13 20 1287 1407 10 253 | 243 0 293 30 1115 1235 10 254 | 244 211 248 26 96 216 10 255 | 245 484 174 10 1058 1178 10 256 | 246 175 352 12 6660 6780 10 257 | 247 455 168 21 3467 3587 10 258 | 248 224 191 20 324 444 10 259 | 249 439 156 2 2103 2223 10 260 | 250 434 359 13 5569 5689 10 261 | 251 118 314 26 1350 1470 10 262 | 252 234 246 10 259 379 10 263 | 253 406 450 20 1037 1157 10 264 | 254 75 118 21 1636 1756 10 265 | 255 115 395 11 3261 3381 10 266 | 256 329 456 19 996 1116 10 267 | 257 218 403 15 5277 5397 10 268 | 258 149 341 6 1616 1736 10 269 | 259 253 74 20 5400 5520 10 270 | 260 436 241 20 1309 1429 10 271 | 261 238 203 10 375 495 10 272 | 262 405 455 40 1363 1483 10 273 | 263 485 27 10 1784 1904 10 274 | 264 323 118 20 643 763 10 275 | 265 330 371 1 2234 2354 10 276 | 266 25 65 10 1505 1625 10 277 | 267 406 96 20 863 983 10 278 | 268 49 451 20 1120 1240 10 279 | 269 307 249 10 5506 5626 10 280 | 270 178 135 21 6055 6175 10 281 | 271 299 353 34 396 516 10 282 | 272 236 213 20 98 218 10 283 | 273 355 177 20 497 617 10 284 | 274 394 23 20 1615 1735 10 285 | 275 306 235 25 172 292 10 286 | 276 90 477 18 1051 1171 10 287 | 277 379 486 22 2687 2807 10 288 | 278 435 16 10 1470 1590 10 289 | 279 8 497 40 1631 1751 10 290 | 280 150 484 16 2501 2621 10 291 | 281 213 399 18 936 1056 10 292 | 282 391 18 10 1511 1631 10 293 | 283 111 392 18 4676 4796 10 294 | 284 330 281 14 5322 5442 10 295 | 285 344 203 14 669 789 10 296 | 286 91 235 10 1076 1196 10 297 | 287 346 60 10 1285 1405 10 298 | 288 483 27 20 1832 1952 10 299 | 289 382 498 10 1237 1357 10 300 | 290 457 492 7 2032 2152 10 301 | 291 291 213 23 5031 5151 10 302 | 292 154 374 36 3748 3868 10 303 | 293 225 196 10 223 343 10 304 | 294 94 40 24 4272 4392 10 305 | 295 0 356 13 4345 4465 10 306 | 296 297 283 28 5398 5518 10 307 | 297 371 423 10 784 904 10 308 | 298 417 217 30 754 874 10 309 | 299 500 228 8 3127 3247 10 310 | 300 412 214 10 604 724 10 311 | 301 442 289 25 764 884 10 312 | 302 157 269 31 6305 6425 10 313 | 303 440 241 10 1205 1325 10 314 | 304 100 266 20 586 706 10 315 | 305 111 178 18 566 686 10 316 | 306 91 101 10 1193 1313 10 317 | 307 25 307 10 998 1118 10 318 | 308 135 400 20 1194 1314 10 319 | 309 58 458 10 1291 1411 10 320 | 310 133 26 10 1247 1367 10 321 | 311 211 386 20 506 626 10 322 | 312 94 97 20 856 976 10 323 | 313 30 155 9 5122 5242 10 324 | 314 208 184 20 294 414 10 325 | 315 394 333 20 777 897 10 326 | 316 355 180 30 549 669 10 327 | 317 241 180 13 6778 6898 10 328 | 318 21 485 30 1353 1473 10 329 | 319 80 251 14 1214 1334 10 330 | 320 476 61 36 1795 1915 10 331 | 321 406 94 10 911 1031 10 332 | 322 364 71 5 5394 5514 10 333 | 323 418 221 10 1165 1285 10 334 | 324 274 441 12 2778 2898 10 335 | 325 304 97 20 727 847 10 336 | 326 297 102 10 609 729 10 337 | 327 250 405 20 646 766 10 338 | 328 111 463 20 1286 1406 10 339 | 329 408 279 20 880 1000 10 340 | 330 263 418 25 1114 1234 10 341 | 331 480 119 7 2514 2634 10 342 | 332 420 383 27 3928 4048 10 343 | 333 142 14 18 3341 3461 10 344 | 334 73 328 20 714 834 10 345 | 335 50 438 20 1347 1467 10 346 | 336 441 7 20 1566 1686 10 347 | 337 462 14 20 1588 1708 10 348 | 338 360 294 9 5671 5791 10 349 | 339 58 39 12 4652 4772 10 350 | 340 58 391 16 3529 3649 10 351 | 341 410 285 20 771 891 10 352 | 342 96 97 20 808 928 10 353 | 343 21 64 20 1409 1529 10 354 | 344 238 210 30 535 655 10 355 | 345 479 121 10 1231 1351 10 356 | 346 200 178 20 374 494 10 357 | 347 216 341 19 2616 2736 10 358 | 348 48 437 4 3215 3335 10 359 | 349 200 270 20 236 356 10 360 | 350 357 181 20 598 718 10 361 | 351 476 174 30 1297 1417 10 362 | 352 400 286 10 607 727 10 363 | 353 351 481 10 1287 1407 10 364 | 354 270 400 10 545 665 10 365 | 355 95 234 10 653 773 10 366 | 356 128 113 22 1451 1571 10 367 | 357 133 455 25 3232 3352 10 368 | 358 16 463 20 1499 1619 10 369 | 359 59 388 20 2651 2771 10 370 | 360 376 190 30 621 741 10 371 | 361 481 122 30 1182 1302 10 372 | 362 266 405 20 868 988 10 373 | 363 374 232 33 441 561 10 374 | 364 398 20 20 1076 1196 10 375 | 365 481 26 30 1227 1347 10 376 | 366 63 444 20 1519 1639 10 377 | 367 89 290 20 670 790 10 378 | 368 246 314 36 5781 5901 10 379 | 369 40 304 16 4579 4699 10 380 | 370 262 369 15 517 637 10 381 | 371 323 29 7 4550 4670 10 382 | 372 89 65 16 2881 3001 10 383 | 373 144 35 26 899 1019 10 384 | 374 200 265 10 610 730 10 385 | 375 436 264 20 686 806 10 386 | 376 15 457 20 1294 1414 10 387 | 377 397 20 20 1120 1240 10 388 | 378 328 491 21 2713 2833 10 389 | 379 399 175 13 2988 3108 10 390 | 380 432 2 20 1866 1986 10 391 | 381 63 336 20 1065 1185 10 392 | 382 6 296 10 1279 1399 10 393 | 383 146 376 8 937 1057 10 394 | 384 295 247 12 5214 5334 10 395 | 385 235 33 30 5348 5468 10 396 | 386 233 204 20 217 337 10 397 | 387 142 360 20 6128 6248 10 398 | 388 177 156 25 669 789 10 399 | 389 315 287 30 592 712 10 400 | 390 452 172 9 2433 2553 10 401 | 391 263 153 12 1650 1770 10 402 | 392 493 493 20 3426 3546 10 403 | 393 320 283 30 442 562 10 404 | 394 64 5 14 4516 4636 10 405 | 395 95 235 10 563 683 10 406 | 396 203 211 20 5226 5346 10 407 | 397 16 497 20 1703 1823 10 408 | 398 348 348 23 3739 3859 10 409 | 399 485 104 21 3178 3298 10 410 | 400 330 147 28 3394 3514 10 411 | 401 443 237 20 754 874 10 412 | 402 316 286 30 547 667 10 413 | 403 335 46 18 5367 5487 10 414 | 404 381 495 20 1290 1410 10 415 | 405 364 173 30 721 841 10 416 | 406 267 162 6 5797 5917 10 417 | 407 214 245 8 85 205 10 418 | 408 92 234 10 939 1059 10 419 | 409 347 459 25 1918 2038 10 420 | 410 30 7 23 4754 4874 10 421 | 411 120 37 28 3101 3221 10 422 | 412 397 153 29 3530 3650 10 423 | 413 210 29 13 4203 4323 10 424 | 414 87 285 30 964 1084 10 425 | 415 132 32 18 3138 3258 10 426 | 416 390 294 20 949 1069 10 427 | 417 67 451 5 4862 4982 10 428 | 418 24 68 20 1658 1778 10 429 | 419 146 439 10 1037 1157 10 430 | 420 209 212 18 6111 6231 10 431 | 421 6 292 10 970 1090 10 432 | 422 18 63 10 1356 1476 10 433 | 423 149 98 4 4660 4780 10 434 | 424 91 268 10 978 1098 10 435 | 425 103 177 28 2506 2626 10 436 | 426 367 178 20 721 841 10 437 | 427 225 269 30 5083 5203 10 438 | 428 443 246 20 919 1039 10 439 | 429 306 42 11 1907 2027 10 440 | 430 374 306 4 3976 4096 10 441 | 431 413 421 10 1212 1332 10 442 | 432 470 405 17 3703 3823 10 443 | 433 33 278 18 5949 6069 10 444 | 434 149 458 13 4655 4775 10 445 | 435 257 57 18 4904 5024 10 446 | 436 272 403 30 759 879 10 447 | 437 221 291 9 184 304 10 448 | 438 1 101 8 5029 5149 10 449 | 439 332 459 35 1475 1595 10 450 | 440 220 392 20 1031 1151 10 451 | 441 253 50 27 903 1023 10 452 | 442 250 441 5 3023 3143 10 453 | 443 471 484 10 1359 1479 10 454 | 444 480 152 26 4086 4206 10 455 | 445 404 83 30 1194 1314 10 456 | 446 476 94 20 1079 1199 10 457 | 447 458 213 22 4513 4633 10 458 | 448 215 395 20 968 1088 10 459 | 449 85 288 20 728 848 10 460 | 450 179 75 13 2960 3080 10 461 | 451 228 287 21 112 232 10 462 | 452 397 18 10 1168 1288 10 463 | 453 238 204 20 419 539 10 464 | 454 488 3 3 1602 1722 10 465 | 455 407 88 10 1298 1418 10 466 | 456 459 14 20 1241 1361 10 467 | 457 120 17 30 1116 1236 10 468 | 458 235 316 2 2623 2743 10 469 | 459 370 382 11 3535 3655 10 470 | 460 405 454 11 5212 5332 10 471 | 461 17 458 10 1732 1852 10 472 | 462 43 135 31 887 1007 10 473 | 463 318 497 21 3415 3535 10 474 | 464 199 268 20 285 405 10 475 | 465 111 467 20 1148 1268 10 476 | 466 138 438 20 1149 1269 10 477 | 467 172 314 9 2182 2302 10 478 | 468 494 468 31 1410 1530 10 479 | 469 35 303 20 826 946 10 480 | 470 341 59 27 3159 3279 10 481 | 471 423 221 9 1033 1153 10 482 | 472 395 295 20 845 965 10 483 | 473 413 417 10 1424 1544 10 484 | 474 339 60 20 844 964 10 485 | 475 277 428 7 1961 2081 10 486 | 476 176 199 28 299 419 10 487 | 477 265 240 9 18 138 10 488 | 478 365 190 22 5910 6030 10 489 | 479 133 53 20 1118 1238 10 490 | 480 387 488 20 1448 1568 10 491 | 481 385 295 20 509 629 10 492 | 482 491 369 28 2918 3038 10 493 | 483 445 273 20 1031 1151 10 494 | 484 195 273 22 178 298 10 495 | 485 313 493 20 4772 4892 10 496 | 486 495 227 20 1376 1496 10 497 | 487 241 403 10 881 1001 10 498 | 488 30 72 10 1726 1846 10 499 | 489 21 487 10 1401 1521 10 500 | 490 324 99 10 1352 1472 10 501 | 491 453 318 30 1495 1615 10 502 | 492 443 272 10 1080 1200 10 503 | 493 447 184 27 1698 1818 10 504 | 494 366 288 29 2735 2855 10 505 | 495 440 284 25 3407 3527 10 506 | 496 13 314 14 975 1095 10 507 | 497 72 227 25 2255 2375 10 508 | 498 377 385 6 3465 3585 10 509 | 499 477 478 20 1569 1689 10 510 | 500 204 185 20 653 773 10 511 | 501 226 191 20 372 492 10 512 | 502 330 138 18 4438 4558 10 513 | 503 185 434 9 2294 2414 10 514 | 504 483 22 10 1336 1456 10 515 | 505 71 282 29 2567 2687 10 516 | 506 60 5 18 4175 4295 10 517 | 507 189 402 10 2144 2264 10 518 | 508 134 211 35 482 602 10 519 | 509 146 313 22 4781 4901 10 520 | 510 21 146 21 1947 2067 10 521 | 511 37 281 17 1973 2093 10 522 | 512 416 417 20 1372 1492 10 523 | 513 44 311 27 1630 1750 10 524 | 514 361 181 20 788 908 10 525 | 515 444 242 10 862 982 10 526 | 516 444 271 10 982 1102 10 527 | 517 359 179 20 649 769 10 528 | 518 388 334 20 632 752 10 529 | 519 401 164 13 2485 2605 10 530 | 520 499 316 18 2487 2607 10 531 | 521 399 106 20 1207 1327 10 532 | 522 425 215 10 916 1036 10 533 | 523 407 98 10 814 934 10 534 | 524 406 460 2 2877 2997 10 535 | 525 88 95 20 1081 1201 10 536 | 526 95 64 4 3064 3184 10 537 | 527 306 229 10 5281 5401 10 538 | 528 273 55 20 725 845 10 539 | 529 384 149 18 4789 4909 10 540 | 530 122 35 10 981 1101 10 541 | 531 308 199 14 6033 6153 10 542 | 532 390 301 10 661 781 10 543 | 533 300 108 10 542 662 10 544 | 534 267 400 10 929 1049 10 545 | 535 8 300 10 1423 1543 10 546 | 536 105 181 19 6125 6245 10 547 | 537 398 325 30 933 1053 10 548 | 538 166 247 1 276 396 10 549 | 539 140 431 30 828 948 10 550 | 540 253 118 19 2189 2309 10 551 | 541 359 246 18 5691 5811 10 552 | 542 321 277 10 244 364 10 553 | 543 168 59 6 1464 1584 10 554 | 544 406 285 20 715 835 10 555 | 545 391 334 20 724 844 10 556 | 546 437 19 15 4056 4176 10 557 | 547 201 278 13 166 286 10 558 | 548 435 267 20 1291 1411 10 559 | 549 245 408 10 815 935 10 560 | 550 16 462 10 1543 1663 10 561 | 551 107 374 8 3657 3777 10 562 | 552 477 97 10 1131 1251 10 563 | 553 346 57 20 1233 1353 10 564 | 554 14 459 20 1343 1463 10 565 | 555 102 6 3 5834 5954 10 566 | 556 359 287 24 400 520 10 567 | 557 297 131 25 4662 4782 10 568 | 558 282 1 18 4170 4290 10 569 | 559 21 70 15 3085 3205 10 570 | 560 440 244 10 1064 1184 10 571 | 561 482 104 19 3230 3350 10 572 | 562 120 261 5 3173 3293 10 573 | 563 125 29 30 1133 1253 10 574 | 564 292 32 14 917 1037 10 575 | 565 262 92 25 2522 2642 10 576 | 566 68 160 21 4543 4663 10 577 | 567 405 276 20 937 1057 10 578 | 568 277 50 10 791 911 10 579 | 569 32 319 21 1602 1722 10 580 | 570 344 70 24 4583 4703 10 581 | 571 481 84 17 2022 2142 10 582 | 572 21 68 20 1606 1726 10 583 | 573 441 244 10 1108 1228 10 584 | 574 57 43 15 4094 4214 10 585 | 575 1 293 10 1071 1191 10 586 | 576 481 96 20 1188 1308 10 587 | 577 471 368 19 1712 1832 10 588 | 578 236 126 23 439 559 10 589 | 579 406 99 20 908 1028 10 590 | 580 303 186 10 5417 5537 10 591 | 581 225 369 38 426 546 10 592 | 582 412 453 10 1188 1308 10 593 | 583 104 349 20 4037 4157 10 594 | 584 173 182 25 351 471 10 595 | 585 111 464 10 1242 1362 10 596 | 586 53 440 10 1292 1412 10 597 | 587 69 336 20 872 992 10 598 | 588 359 182 20 837 957 10 599 | 589 13 459 20 1387 1507 10 600 | 590 244 277 18 5205 5325 10 601 | 591 484 177 20 1006 1126 10 602 | 592 452 206 31 1969 2089 10 603 | 593 22 483 30 1244 1364 10 604 | 594 452 110 14 1361 1481 10 605 | 595 347 192 18 5953 6073 10 606 | 596 95 92 20 1011 1131 10 607 | 597 368 311 14 3704 3824 10 608 | 598 479 387 13 1590 1710 10 609 | 599 479 169 20 1234 1354 10 610 | 600 497 266 25 2990 3110 10 611 | 601 66 336 10 1013 1133 10 612 | 602 376 195 10 724 844 10 613 | 603 401 281 20 1044 1164 10 614 | 604 441 177 23 4005 4125 10 615 | 605 231 203 20 266 386 10 616 | 606 21 488 10 1445 1565 10 617 | 607 231 204 20 601 721 10 618 | 608 122 422 3 5827 5947 10 619 | 609 65 453 30 1127 1247 10 620 | 610 206 261 10 730 850 10 621 | 611 466 149 16 4744 4864 10 622 | 612 313 119 30 863 983 10 623 | 613 90 274 20 717 837 10 624 | 614 39 162 18 2261 2381 10 625 | 615 35 306 20 918 1038 10 626 | 616 437 15 30 1421 1541 10 627 | 617 307 412 8 1615 1735 10 628 | 618 79 291 10 835 955 10 629 | 619 64 437 11 3673 3793 10 630 | 620 376 92 10 3962 4082 10 631 | 621 129 27 10 1190 1310 10 632 | 622 196 489 23 4121 4241 10 633 | 623 51 286 14 5836 5956 10 634 | 624 20 488 10 1489 1609 10 635 | 625 13 455 10 1243 1363 10 636 | 626 170 347 15 1743 1863 10 637 | 627 92 230 20 755 875 10 638 | 628 117 467 10 958 1078 10 639 | 629 413 217 20 656 776 10 640 | 630 405 450 20 993 1113 10 641 | 631 394 322 12 4099 4219 10 642 | 632 125 61 26 2447 2567 10 643 | 633 238 123 24 3124 3244 10 644 | 634 11 403 18 1372 1492 10 645 | 635 89 272 10 766 886 10 646 | 636 304 102 30 787 907 10 647 | 637 478 121 40 1275 1395 10 648 | 638 408 84 10 1137 1257 10 649 | 639 376 494 30 1079 1199 10 650 | 640 20 73 10 1101 1221 10 651 | 641 159 299 12 4062 4182 10 652 | 642 95 382 19 925 1045 10 653 | 643 352 63 6 4713 4833 10 654 | 644 365 274 14 410 530 10 655 | 645 30 301 10 1110 1230 10 656 | 646 351 5 12 1984 2104 10 657 | 647 197 267 10 435 555 10 658 | 648 498 171 12 5026 5146 10 659 | 649 468 352 9 3073 3193 10 660 | 650 418 251 21 4787 4907 10 661 | 651 489 437 29 2827 2947 10 662 | 652 251 63 14 3950 4070 10 663 | 653 132 55 10 1069 1189 10 664 | 654 281 96 1 4503 4623 10 665 | 655 333 293 27 2468 2588 10 666 | 656 255 487 19 1592 1712 10 667 | 657 207 400 20 762 882 10 668 | 658 469 489 4 2222 2342 10 669 | 659 244 254 20 401 521 10 670 | 660 233 207 10 165 285 10 671 | 661 441 60 21 5835 5955 10 672 | 662 411 379 25 4773 4893 10 673 | 663 178 72 23 3027 3147 10 674 | 664 51 447 10 1178 1298 10 675 | 665 478 118 20 1417 1537 10 676 | 666 141 426 23 2126 2246 10 677 | 667 295 89 23 2968 3088 10 678 | 668 112 433 29 940 1060 10 679 | 669 320 211 16 3970 4090 10 680 | 670 400 103 10 1022 1142 10 681 | 671 408 453 10 1132 1252 10 682 | 672 435 180 37 898 1018 10 683 | 673 432 66 30 4285 4405 10 684 | 674 374 116 9 2349 2469 10 685 | 675 478 102 10 1297 1417 10 686 | 676 335 57 30 784 904 10 687 | 677 385 239 21 3142 3262 10 688 | 678 386 245 16 1916 2036 10 689 | 679 208 396 20 706 826 10 690 | 680 380 489 20 1516 1636 10 691 | 681 380 498 10 1189 1309 10 692 | 682 440 7 20 1255 1375 10 693 | 683 434 245 10 1367 1487 10 694 | 684 90 232 10 846 966 10 695 | 685 389 334 20 676 796 10 696 | 686 241 205 30 472 592 10 697 | 687 18 24 32 2513 2633 10 698 | 688 57 183 15 4401 4521 10 699 | 689 59 457 30 1337 1457 10 700 | 690 442 243 10 1154 1274 10 701 | 691 402 281 20 1000 1120 10 702 | 692 445 237 10 802 922 10 703 | 693 441 273 20 1129 1249 10 704 | 694 31 175 24 986 1106 10 705 | 695 234 202 10 319 439 10 706 | 696 52 303 25 1765 1885 10 707 | 697 167 445 7 5648 5768 10 708 | 698 179 286 8 1365 1485 10 709 | 699 269 48 20 1122 1242 10 710 | 700 165 59 27 3771 3891 10 711 | 701 461 8 20 1476 1596 10 712 | 702 421 415 30 941 1061 10 713 | 703 59 459 20 1245 1365 10 714 | 704 24 492 10 1848 1968 10 715 | 705 55 449 20 1054 1174 10 716 | 706 224 192 10 280 400 10 717 | 707 444 269 20 934 1054 10 718 | 708 491 20 20 1574 1694 10 719 | 709 313 126 10 973 1093 10 720 | 710 283 438 3 926 1046 10 721 | 711 352 241 5 3169 3289 10 722 | 712 398 476 25 1672 1792 10 723 | 713 442 247 10 964 1084 10 724 | 714 217 207 26 5530 5650 10 725 | 715 233 87 18 1010 1130 10 726 | 716 479 127 20 1079 1199 10 727 | 717 6 53 8 2348 2468 10 728 | 718 478 300 12 3558 3678 10 729 | 719 378 493 30 1127 1247 10 730 | 720 303 78 12 660 780 10 731 | 721 344 62 10 1386 1506 10 732 | 722 371 315 18 4663 4783 10 733 | 723 200 78 31 3971 4091 10 734 | 724 413 391 8 868 988 10 735 | 725 415 216 10 705 825 10 736 | 726 397 57 17 5904 6024 10 737 | 727 293 228 19 133 253 10 738 | 728 0 297 10 1171 1291 10 739 | 729 435 20 20 1526 1646 10 740 | 730 195 111 15 3992 4112 10 741 | 731 417 218 10 1112 1232 10 742 | 732 340 54 10 951 1071 10 743 | 733 132 57 20 978 1098 10 744 | 734 210 379 12 2835 2955 10 745 | 735 228 260 12 6422 6542 10 746 | 736 399 104 10 1159 1279 10 747 | 737 95 277 20 1098 1218 10 748 | 738 360 284 19 2666 2786 10 749 | 739 53 466 9 1340 1460 10 750 | 740 112 465 10 1197 1317 10 751 | 741 313 391 5 598 718 10 752 | 742 93 235 10 985 1105 10 753 | 743 125 32 30 1038 1158 10 754 | 744 215 282 21 5762 5882 10 755 | 745 224 320 36 5135 5255 10 756 | 746 134 428 20 1232 1352 10 757 | 747 26 490 10 1899 2019 10 758 | 748 44 115 24 925 1045 10 759 | 749 438 127 2 3764 3884 10 760 | 750 239 15 2 2415 2535 10 761 | 751 342 54 20 999 1119 10 762 | 752 109 463 30 1334 1454 10 763 | 753 199 187 20 507 627 10 764 | 754 201 188 10 555 675 10 765 | 755 399 301 30 777 897 10 766 | 756 484 171 10 1173 1293 10 767 | 757 272 234 26 6361 6481 10 768 | 758 380 350 15 3466 3586 10 769 | 759 140 108 29 4285 4405 10 770 | 760 228 199 10 537 657 10 771 | 761 245 461 8 2597 2717 10 772 | 762 305 107 20 901 1021 10 773 | 763 231 195 20 437 557 10 774 | 764 450 265 10 865 985 10 775 | 765 273 149 14 6011 6131 10 776 | 766 12 358 7 4897 5017 10 777 | 767 315 121 10 812 932 10 778 | 768 420 213 10 814 934 10 779 | 769 331 134 11 4495 4615 10 780 | 770 84 377 10 3705 3825 10 781 | 771 320 280 10 340 460 10 782 | 772 89 185 16 2399 2519 10 783 | 773 472 481 20 1306 1426 10 784 | 774 422 420 20 1050 1170 10 785 | 775 475 267 7 3118 3238 10 786 | 776 470 125 20 952 1072 10 787 | 777 435 268 10 1247 1367 10 788 | 778 409 155 19 681 801 10 789 | 779 243 248 30 96 216 10 790 | 780 488 96 22 4265 4385 10 791 | 781 341 72 9 3219 3339 10 792 | 782 58 449 30 1451 1571 10 793 | 783 16 460 20 1643 1763 10 794 | 784 480 136 22 967 1087 10 795 | 785 162 388 11 4504 4624 10 796 | 786 47 208 30 906 1026 10 797 | 787 324 127 30 514 634 10 798 | 788 87 96 30 1127 1247 10 799 | 789 140 137 32 2279 2399 10 800 | 790 314 205 22 6107 6227 10 801 | 791 96 346 26 741 861 10 802 | 792 321 280 30 296 416 10 803 | 793 245 251 10 5 125 10 804 | 794 436 295 11 2113 2233 10 805 | 795 274 261 20 6828 6948 10 806 | 796 271 128 12 1382 1502 10 807 | 797 275 45 20 898 1018 10 808 | 798 422 409 10 877 997 10 809 | 799 146 188 6 4940 5060 10 810 | 800 93 96 20 902 1022 10 811 | 801 409 255 23 6090 6210 10 812 | 802 449 428 25 4987 5107 10 813 | 803 90 285 40 1105 1225 10 814 | 804 415 95 15 4707 4827 10 815 | 805 88 287 30 1054 1174 10 816 | 806 379 196 20 776 896 10 817 | 807 368 452 16 2680 2800 10 818 | 808 202 186 20 604 724 10 819 | 809 435 11 40 1189 1309 10 820 | 810 269 46 20 1074 1194 10 821 | 811 7 292 10 926 1046 10 822 | 812 44 496 32 1607 1727 10 823 | 813 478 99 10 1245 1365 10 824 | 814 391 99 20 766 886 10 825 | 815 132 477 25 1309 1429 10 826 | 816 24 65 10 1461 1581 10 827 | 817 130 247 17 420 540 10 828 | 818 133 273 20 417 537 10 829 | 819 347 62 10 1334 1454 10 830 | 820 404 140 8 5035 5155 10 831 | 821 416 420 20 1159 1279 10 832 | 822 67 335 20 967 1087 10 833 | 823 92 270 20 1027 1147 10 834 | 824 411 95 30 971 1091 10 835 | 825 132 479 11 970 1090 10 836 | 826 366 334 5 1641 1761 10 837 | 827 125 39 20 921 1041 10 838 | 828 419 422 20 1105 1225 10 839 | 829 460 2 20 1412 1532 10 840 | 830 67 334 20 923 1043 10 841 | 831 448 414 23 4891 5011 10 842 | 832 46 163 8 3704 3824 10 843 | 833 77 465 11 1044 1164 10 844 | 834 284 319 17 3267 3387 10 845 | 835 102 422 23 905 1025 10 846 | 836 240 34 28 6238 6358 10 847 | 837 141 428 20 775 895 10 848 | 838 204 269 30 139 259 10 849 | 839 144 439 30 1085 1205 10 850 | 840 470 417 11 2947 3067 10 851 | 841 404 103 20 966 1086 10 852 | 842 5 281 16 5486 5606 10 853 | 843 487 320 21 3431 3551 10 854 | 844 398 23 10 1024 1144 10 855 | 845 90 296 20 606 726 10 856 | 846 386 13 10 1348 1468 10 857 | 847 115 465 10 1049 1169 10 858 | 848 473 475 10 1669 1789 10 859 | 849 275 42 30 950 1070 10 860 | 850 286 356 30 388 508 10 861 | 851 15 69 10 1167 1287 10 862 | 852 267 44 20 1023 1143 10 863 | 853 243 399 10 939 1059 10 864 | 854 390 249 21 2327 2447 10 865 | 855 210 391 30 566 686 10 866 | 856 433 15 20 1131 1251 10 867 | 857 24 259 19 1480 1600 10 868 | 858 12 463 20 1443 1563 10 869 | 859 237 213 10 588 708 10 870 | 860 182 480 31 1459 1579 10 871 | 861 409 88 20 1081 1201 10 872 | 862 244 368 25 1656 1776 10 873 | 863 381 328 12 2869 2989 10 874 | 864 213 185 21 239 359 10 875 | 865 482 141 14 4043 4163 10 876 | 866 319 124 20 712 832 10 877 | 867 141 431 30 872 992 10 878 | 868 198 264 20 561 681 10 879 | 869 69 334 30 824 944 10 880 | 870 299 98 30 667 787 10 881 | 871 240 250 10 150 270 10 882 | 872 199 203 20 5829 5949 10 883 | 873 459 17 20 1645 1765 10 884 | 874 423 217 20 967 1087 10 885 | 875 477 179 20 891 1011 10 886 | 876 213 397 10 869 989 10 887 | 877 405 187 34 5002 5122 10 888 | 878 269 402 20 811 931 10 889 | 879 53 204 8 4220 4340 10 890 | 880 13 394 15 1490 1610 10 891 | 881 15 68 10 1211 1331 10 892 | 882 56 268 28 4256 4376 10 893 | 883 360 184 10 886 1006 10 894 | 884 307 102 40 839 959 10 895 | 885 130 57 40 930 1050 10 896 | 886 250 328 24 995 1115 10 897 | 887 91 231 30 801 921 10 898 | 888 479 176 20 946 1066 10 899 | 889 420 224 10 1716 1836 10 900 | 890 461 182 13 2516 2636 10 901 | 891 418 218 20 1068 1188 10 902 | 892 419 418 10 996 1116 10 903 | 893 336 493 20 5972 6092 10 904 | 894 389 300 10 615 735 10 905 | 895 92 76 4 4556 4676 10 906 | 896 476 102 20 1345 1465 10 907 | 897 418 399 20 1751 1871 10 908 | 898 109 56 27 899 1019 10 909 | 899 13 465 31 3094 3214 10 910 | 900 92 232 10 707 827 10 911 | 901 394 47 5 1252 1372 10 912 | 902 16 287 12 1083 1203 10 913 | 903 399 102 20 1068 1188 10 914 | 904 143 158 12 550 670 10 915 | 905 18 484 10 1300 1420 10 916 | 906 250 411 30 752 872 10 917 | 907 19 273 25 4066 4186 10 918 | 908 365 28 9 1073 1193 10 919 | 909 387 297 10 561 681 10 920 | 910 433 447 20 3177 3297 10 921 | 911 214 274 24 5476 5596 10 922 | 912 489 338 17 5589 5709 10 923 | 913 130 494 6 3035 3155 10 924 | 914 23 67 30 1557 1677 10 925 | 915 374 489 20 1017 1137 10 926 | 916 126 30 10 1087 1207 10 927 | 917 112 467 10 1104 1224 10 928 | 918 489 274 31 2135 2255 10 929 | 919 61 214 4 1367 1487 10 930 | 920 166 440 12 771 891 10 931 | 921 56 75 24 5751 5871 10 932 | 922 210 276 5 131 251 10 933 | 923 80 286 10 896 1016 10 934 | 924 17 459 10 1688 1808 10 935 | 925 66 448 10 1021 1141 10 936 | 926 351 128 15 5013 5133 10 937 | 927 352 176 20 444 564 10 938 | 928 490 286 29 2089 2209 10 939 | 929 247 219 17 65 185 10 940 | 930 86 268 10 869 989 10 941 | 931 398 329 17 611 731 10 942 | 932 272 402 10 638 758 10 943 | 933 317 123 20 761 881 10 944 | 934 408 318 15 2572 2692 10 945 | 935 66 31 25 4194 4314 10 946 | 936 425 448 9 3178 3298 10 947 | 937 35 304 30 870 990 10 948 | 938 471 94 30 3995 4115 10 949 | 939 470 473 10 1724 1844 10 950 | 940 224 56 13 4746 4866 10 951 | 941 343 47 20 1108 1228 10 952 | 942 52 18 28 3428 3548 10 953 | 943 16 68 20 1255 1375 10 954 | 944 195 185 20 449 569 10 955 | 945 92 236 20 1031 1151 10 956 | 946 76 462 18 3824 3944 10 957 | 947 124 56 20 865 985 10 958 | 948 481 454 14 1282 1402 10 959 | 949 477 483 20 1463 1583 10 960 | 950 481 124 10 1134 1254 10 961 | 951 389 156 27 2862 2982 10 962 | 952 384 16 20 1402 1522 10 963 | 953 492 34 5 3242 3362 10 964 | 954 371 200 10 897 1017 10 965 | 955 153 235 10 333 453 10 966 | 956 428 202 24 3615 3735 10 967 | 957 257 391 22 6532 6652 10 968 | 958 421 218 10 1016 1136 10 969 | 959 206 186 10 750 870 10 970 | 960 393 301 30 713 833 10 971 | 961 204 187 30 701 821 10 972 | 962 468 475 10 1193 1313 10 973 | 963 477 122 10 1320 1440 10 974 | 964 100 66 15 5599 5719 10 975 | 965 489 27 10 1685 1805 10 976 | 966 12 451 20 1186 1306 10 977 | 967 197 270 30 383 503 10 978 | 968 311 422 29 3952 4072 10 979 | 969 489 17 10 1520 1640 10 980 | 970 13 214 21 5414 5534 10 981 | 971 440 247 20 1012 1132 10 982 | 972 28 467 34 5370 5490 10 983 | 973 388 325 10 1053 1173 10 984 | 974 270 401 20 589 709 10 985 | 975 5 445 30 1244 1364 10 986 | 976 198 271 20 337 457 10 987 | 977 480 131 5 2750 2870 10 988 | 978 437 98 16 4455 4575 10 989 | 979 131 246 17 3328 3448 10 990 | 980 49 437 7 1710 1830 10 991 | 981 270 49 30 1168 1288 10 992 | 982 337 41 8 4009 4129 10 993 | 983 318 280 20 388 508 10 994 | 984 154 392 9 626 746 10 995 | 985 493 111 26 2164 2284 10 996 | 986 399 450 20 1435 1555 10 997 | 987 67 452 30 1078 1198 10 998 | 988 34 239 16 876 996 10 999 | 989 343 276 15 326 446 10 1000 | 990 393 12 10 1237 1357 10 1001 | 991 236 247 20 210 330 10 1002 | 992 340 291 22 1882 2002 10 1003 | 993 3 292 20 1022 1142 10 1004 | 994 209 68 27 6272 6392 10 1005 | 995 18 225 8 2765 2885 10 1006 | 996 147 435 20 980 1100 10 1007 | 997 335 99 25 4874 4994 10 1008 | 998 485 24 20 1285 1405 10 1009 | 999 470 475 30 1241 1361 10 1010 | 1000 341 58 10 895 1015 10 1011 | -------------------------------------------------------------------------------- /Point.cpp: -------------------------------------------------------------------------------- 1 | #include "Point.h" 2 | #include 3 | 4 | 5 | double Point::distance(Point* p) 6 | { 7 | return sqrt(pow(p->x - this->x, 2) + pow(p->y - this->y, 2)); 8 | } 9 | 10 | Point::Point() 11 | { 12 | } 13 | 14 | 15 | Point::~Point() 16 | { 17 | } 18 | -------------------------------------------------------------------------------- /Point.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class Vehicle; 6 | class Solution; 7 | 8 | class Point 9 | { 10 | public: 11 | int id; 12 | int x; 13 | int y; 14 | int demand; 15 | int ready_time; 16 | int due_date; 17 | int service_time; 18 | 19 | 20 | /** 21 | * Every point is attended by a vehicle in a solution 22 | */ 23 | std::unordered_map> state; 24 | 25 | 26 | Point(int id, int x, int y, int demand, int ready_time, int due_date, int service_time) 27 | : id(id), 28 | x(x), 29 | y(y), 30 | demand(demand), 31 | ready_time(ready_time), 32 | due_date(due_date), 33 | service_time(service_time) 34 | { 35 | } 36 | 37 | double distance(Point* p); 38 | Point(); 39 | ~Point(); 40 | }; 41 | 42 | -------------------------------------------------------------------------------- /SAnnealing.cpp: -------------------------------------------------------------------------------- 1 | #include "SAnnealing.h" 2 | #include "Utils.h" 3 | #include 4 | #include 5 | 6 | 7 | Solution* SAnnealing::run(double initial_temp, double final_temp, double t_decrese) 8 | { 9 | auto candidate = Utils::pfih(); 10 | auto best_solution = candidate->clone(); 11 | auto current_temp = initial_temp; 12 | while(current_temp > final_temp) 13 | { 14 | auto next_solution = candidate->clone(); 15 | next_solution->mutate(); 16 | auto delta = next_solution->weight - candidate->weight; 17 | if(delta < 0 || exp(-delta/current_temp) > Utils::random_0_1()) 18 | { 19 | 20 | delete candidate; 21 | candidate = next_solution; 22 | std::cout << "SA -> Next solution: " << candidate->weight << ", T: " << current_temp << ", " << "Best: " << best_solution->weight << ", Delta: " << delta << "\n"; 23 | 24 | 25 | if (best_solution->weight > candidate->weight) { 26 | delete best_solution; 27 | best_solution = candidate->clone(); 28 | } 29 | }else 30 | { 31 | delete next_solution; 32 | } 33 | current_temp -= t_decrese; 34 | //std::cout << "T: " << current_temp << "\n"; 35 | } 36 | return best_solution; 37 | } 38 | -------------------------------------------------------------------------------- /SAnnealing.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Solution.h" 3 | 4 | class SAnnealing 5 | { 6 | public: 7 | static Solution* run(double initial_temp, double final_temp, double t_decrese); 8 | }; 9 | -------------------------------------------------------------------------------- /Solution.cpp: -------------------------------------------------------------------------------- 1 | #include "Solution.h" 2 | #include "Vehicle.h" 3 | #include "Utils.h" 4 | #include "SubCandidate.h" 5 | #include "Point.h" 6 | #include "Utils.h" 7 | #include "VehicleState.h" 8 | #include 9 | #include 10 | 11 | double Solution::total_weight() { 12 | double ret = 0; 13 | for (auto vehicle: vehicles) { 14 | ret += vehicle->get_weight(); 15 | } 16 | weight = ret; 17 | return ret; 18 | } 19 | 20 | void Solution::validate() { 21 | for (auto vehicle: vehicles) { 22 | auto i = 0; 23 | for (auto it = vehicle->nodes.begin(); it != vehicle->nodes.end(); ++it) { 24 | auto vs = *it; 25 | auto pos = vs->p->state[this].second; 26 | if (i != pos) { 27 | std::cout << "invalid state"; 28 | } 29 | i++; 30 | } 31 | } 32 | } 33 | 34 | 35 | void Solution::mutate1(bool &improved) { 36 | Point *p = nullptr; 37 | int ec = 0; 38 | double new_weight, original_weight = this->total_weight(); 39 | 40 | int index = (rand() % (Utils::raw_rows.size() - 1)) + 1; // We do this to avoid targetting the depot point (id == 0 point) 41 | 42 | auto it = Utils::raw_rows.begin(); 43 | 44 | while (index-- > 0) 45 | ++it; 46 | 47 | p = *it; 48 | 49 | if (p->state.find(this) == p->state.end()) { 50 | std::cerr << "Solution has no instance of point " << p->id << std::endl; 51 | exit(0); 52 | } 53 | 54 | auto original_vehicle = p->state[this].first; 55 | int original_pos = p->state[this].second; 56 | //std::cout << "Mutating " << p->id << "\n"; 57 | original_vehicle->remove_node(original_pos); 58 | 59 | /** 60 | * These two lines bellow are just for test, We are trying to remove node from a vehicle route 61 | * then insert into a new one, if this insertion provides a valid solution and it is better than the previous one 62 | * then that solution becomes the base solution. 63 | * 64 | * The thing is, most of the times, that insertion will fail, and then we need to put the node back 65 | * where it once was. This happens in this function down bellow: candidate.v->add_node(p, candidate.pos, ec); 66 | * But, sadly it is not working. 67 | * 68 | * Those commented two lines down bellow this comment are here just for test, after calling ->add_node() ec should 69 | * be == 0 because we are just inserting a node that we just removed. This bugs happens because Vehicle::validate_states 70 | * are not implemented correctly. I'll leave a comment there if you want to see. 71 | */ 72 | // ec = 0; 73 | // original_vehicle->add_node(p, original_pos, ec); 74 | 75 | SubCandidate candidate(original_weight, original_pos, original_vehicle); 76 | 77 | for (auto vehicle: this->vehicles) { 78 | //std::cout << "Vehicle " << vehicle->id << "\n"; 79 | for (int i = 0; i <= vehicle->nodes.size(); ++i) { 80 | //std::cout << "Node " << i << "\n"; 81 | ec = 0; 82 | vehicle->add_node(p, i, ec); 83 | if (!ec) { 84 | new_weight = this->total_weight(); 85 | if (new_weight < candidate.weight) { 86 | candidate.weight = new_weight; 87 | candidate.v = vehicle; 88 | candidate.pos = i; 89 | //std::cout << "Best position for node " << p->id << ", vehicle " << candidate.v->id << " position " << candidate.pos << ", total weight " << candidate.weight << "\n"; 90 | improved = true; 91 | 92 | return; 93 | } 94 | vehicle->remove_node(i); 95 | } 96 | //validate(); 97 | } 98 | } 99 | 100 | ec = 0; 101 | 102 | // Add the node back to its original vehicle 103 | candidate.v->add_node(p, candidate.pos, ec); 104 | improved = false; 105 | } 106 | 107 | /** 108 | * Insertion mutate operator, it can be intra-route or inter-route 109 | * 110 | */ 111 | void Solution::mutate_insertion() { 112 | auto vit = vehicles.begin(); 113 | Vehicle *v1; 114 | Vehicle *v2; 115 | std::advance(vit, rand() % vehicles.size()); 116 | v1 = *vit; 117 | 118 | if (v1->nodes.size() == 1) 119 | return; 120 | 121 | vit = vehicles.begin(); 122 | std::advance(vit, rand() % vehicles.size()); 123 | v2 = *vit; 124 | 125 | auto nid = v1->nodes.begin(); 126 | std::advance(nid, rand() % v1->nodes.size()); 127 | auto node = (*nid)->p; 128 | auto original_position = node->state[this].second; 129 | 130 | v1->remove_node(original_position); 131 | //tries to insert at a random position 132 | auto ec = 0; 133 | v2->add_node(node, rand() % v2->nodes.size(), ec); 134 | if (ec != 0)//Error 135 | { 136 | ec = 0; 137 | v1->add_node(node, original_position, ec); 138 | } 139 | } 140 | 141 | void Solution::mutate_swap() { 142 | 143 | Vehicle *v1; 144 | Vehicle *v2; 145 | 146 | auto off = rand() % (vehicles.size() - 2 + 1) + 1; 147 | auto vit = vehicles.begin(); 148 | std::advance(vit, off); 149 | v1 = *vit; 150 | 151 | vit = vehicles.begin(); 152 | std::advance(vit, rand() % off); 153 | v2 = *vit; 154 | 155 | auto nid = v1->nodes.begin(); 156 | 157 | std::advance(nid, rand() % v1->nodes.size()); 158 | auto node1 = (*nid)->p; 159 | nid = v2->nodes.begin(); 160 | std::advance(nid, rand() % v2->nodes.size()); 161 | auto node2 = (*nid)->p; 162 | 163 | auto node1_original_position = node1->state[this].second; 164 | v1->remove_node(node1_original_position); 165 | 166 | auto node2_original_position = node2->state[this].second; 167 | v2->remove_node(node2_original_position); 168 | 169 | auto ec = 0; 170 | v2->add_node(node1, node2_original_position, ec); 171 | if (ec == 0) { 172 | v1->add_node(node2, node1_original_position, ec); 173 | if (ec == 0)//Success 174 | return; 175 | else { 176 | v2->remove_node(node2_original_position); 177 | } 178 | } 179 | //error state 180 | ec = 0; 181 | v1->add_node(node1, node1_original_position, ec); 182 | v2->add_node(node2, node2_original_position, ec); 183 | } 184 | 185 | void Solution::mutate_inversion() { 186 | auto vit = vehicles.begin(); 187 | std::advance(vit, rand() % vehicles.size()); 188 | auto v1 = *vit; 189 | 190 | if (v1->nodes.size() < 3) 191 | return; 192 | auto range_max = rand() % (v1->nodes.size() - 2) + 2; 193 | auto range_min = rand() % range_max; 194 | 195 | auto nit = v1->nodes.begin(); 196 | std::advance(nit, range_min); 197 | auto nit2 = v1->nodes.begin(); 198 | std::advance(nit2, range_max); 199 | 200 | std::list> points_list; 201 | 202 | while (nit++ != nit2) { 203 | auto p = (*nit)->p; 204 | points_list.push_back(std::pair(p, p->state[this].second)); 205 | //v1->remove_node(p->state[this].second);//invalidate iterators 206 | } 207 | 208 | int remove_pos = (*points_list.begin()).second; 209 | for (auto pair: points_list) { 210 | v1->remove_node(remove_pos); 211 | } 212 | 213 | auto i = 0; 214 | for (auto rit = points_list.rbegin(); rit != points_list.rend(); ++rit) { 215 | auto p = (*rit).first; 216 | auto ec = 0; 217 | v1->add_node(p, range_min + i++, ec); 218 | if (ec != 0) {//Error, repair route 219 | ec = 0; 220 | while (--i > 0) { 221 | v1->remove_node(range_min); 222 | } 223 | for (auto pair: points_list) { 224 | v1->add_node(pair.first, pair.second, ec); 225 | } 226 | break; 227 | } 228 | } 229 | 230 | 231 | } 232 | 233 | 234 | void Solution::mutate() { 235 | auto improvement = false; 236 | auto r_operator = rand() % 4; 237 | //auto r_operator = 3; 238 | 239 | switch (r_operator) { 240 | default: 241 | case 0: //Insertion 242 | mutate1(improvement); 243 | break; 244 | case 1: 245 | mutate_insertion();//leak 246 | break; 247 | case 2: 248 | mutate_swap();//leak 249 | break; 250 | case 3: 251 | mutate_inversion();//leak 252 | break; 253 | } 254 | //mutate1(improvement); 255 | 256 | auto it = vehicles.begin(); 257 | double ret = 0; 258 | while (it != vehicles.end()) { 259 | auto v = *it; 260 | ret += v->get_weight(); 261 | auto pit = it++; 262 | if (v->nodes.empty()) { 263 | vehicles.erase(pit); 264 | delete v; 265 | } 266 | 267 | } 268 | weight = ret; 269 | 270 | } 271 | 272 | bool Solution::has_node(Point *p) { 273 | for (auto vehicle: vehicles) { 274 | if (vehicle->is_point_on_vehicle(p)) 275 | return true; 276 | } 277 | return false; 278 | } 279 | 280 | 281 | Solution::~Solution() { 282 | for (auto vehicle: vehicles) { 283 | delete vehicle; 284 | } 285 | for (auto p: Utils::raw_rows) { 286 | p->state.erase(this); 287 | } 288 | } 289 | 290 | 291 | void Solution::print() { 292 | for (auto point: Utils::raw_rows) { 293 | point->state.erase(this); 294 | } 295 | 296 | for (auto vehicle: vehicles) { 297 | for (auto node: vehicle->nodes) { 298 | std::cout << node->p->id << " "; 299 | } 300 | std::cout << "\n"; 301 | } 302 | } 303 | 304 | 305 | Solution *Solution::clone() { 306 | auto s = new Solution(); 307 | for (auto vehicle: this->vehicles) { 308 | s->vehicles.push_back(vehicle->clone(s)); 309 | } 310 | s->weight = this->weight; 311 | return s; 312 | } 313 | -------------------------------------------------------------------------------- /Solution.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class Vehicle; 5 | class Point; 6 | class Solution 7 | { 8 | public: 9 | std::list vehicles; 10 | double weight; 11 | 12 | double total_weight(); 13 | 14 | /** 15 | * improved is a boolean value, at the end of this function, it teels if the mutation was a success or a failure 16 | */ 17 | void mutate1(bool& improved); 18 | void mutate(); 19 | void validate(); 20 | 21 | void mutate_insertion(); 22 | void mutate_swap(); 23 | void mutate_inversion(); 24 | 25 | 26 | void print(); 27 | 28 | bool has_node(Point* p); 29 | Solution* clone(); 30 | 31 | ~Solution(); 32 | 33 | }; 34 | -------------------------------------------------------------------------------- /SubCandidate.cpp: -------------------------------------------------------------------------------- 1 | #include "SubCandidate.h" 2 | 3 | SubCandidate::SubCandidate() 4 | { 5 | } 6 | 7 | 8 | SubCandidate::~SubCandidate() 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /SubCandidate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class Vehicle; 3 | 4 | class SubCandidate 5 | { 6 | public: 7 | double weight; 8 | int pos; 9 | Vehicle* v; 10 | 11 | 12 | SubCandidate(double weight, int pos, Vehicle* v) 13 | : weight(weight), 14 | pos(pos), 15 | v(v) 16 | { 17 | } 18 | 19 | bool operator < (const SubCandidate& inst) const{ 20 | return weight < inst.weight; 21 | } 22 | 23 | bool operator > (const SubCandidate& inst) const { 24 | return weight > inst.weight; 25 | } 26 | 27 | SubCandidate(); 28 | ~SubCandidate(); 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /Utils.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "Utils.h" 8 | #include "Point.h" 9 | #include "Vehicle.h" 10 | #include "SubCandidate.h" 11 | #include "VehicleState.h" 12 | #include "Solution.h" 13 | #include 14 | 15 | #define _USE_MATH_DEFINES 16 | 17 | #include 18 | 19 | std::shared_ptr Utils::origin; 20 | std::list Utils::raw_rows; 21 | double **Utils::distances; 22 | 23 | void Utils::read_file() { 24 | std::ifstream inst; 25 | 26 | inst.open("../Instances/RC208.txt"); 27 | //inst.open("../Instances/S-RC2-1000/RC21010.TXT"); 28 | //inst.open("../Instances/C101.TXT"); 29 | //inst.open("../Instances/RC105.txt"); 30 | if (inst.is_open()) { 31 | std::string line; 32 | std::regex e("([0-9]+)"); 33 | std::smatch sm; 34 | auto line_count = 0; 35 | while (std::getline(inst, line)) { 36 | line_count++; 37 | if (line_count > 9) // Ignore all lines until the points data 38 | { 39 | std::vector aux; 40 | aux.reserve(7); 41 | while (std::regex_search(line, sm, e)) { 42 | auto s = sm.str(); 43 | aux.push_back(static_cast(strtol(s.data(), nullptr, 10))); 44 | line = sm.suffix(); 45 | } 46 | 47 | if (aux.size() == 7) { // We expect exactly 7 elements in this array 48 | Utils::raw_rows.push_back(new Point(aux[0], aux[1], aux[2], aux[3], aux[4], aux[5], aux[6])); 49 | } 50 | } 51 | } 52 | Utils::origin = std::make_shared(*Utils::raw_rows.begin()); 53 | Utils::distances = (double **) malloc(sizeof(double *) * Utils::raw_rows.size()); 54 | for (int i = 0; i < Utils::raw_rows.size(); ++i) { 55 | Utils::distances[i] = (double *) malloc(sizeof(double) * Utils::raw_rows.size()); 56 | } 57 | inst.close(); 58 | } else { 59 | std::cout << "Unable to open file"; 60 | exit(1); 61 | } 62 | } 63 | 64 | void Utils::calculate_distances() { 65 | for (Point *point: Utils::raw_rows) { 66 | for (Point *point2: Utils::raw_rows) { 67 | Utils::distances[point->id][point2->id] = point->distance(point2); 68 | } 69 | } 70 | } 71 | 72 | /** 73 | * Push forward insert heuristic algorithm 74 | * @return 75 | */ 76 | Solution *Utils::pfih() { 77 | std::vector> points( 78 | Utils::raw_rows.size() - 1 79 | ); // -1 since we do not count the depot (id == 0 point) 80 | 81 | auto it = Utils::raw_rows.begin(); 82 | auto origin = *it; 83 | int ec = 0; 84 | ++it; 85 | 86 | Point *curr; 87 | double degreesdeposit = atan2(origin->y, origin->x) * (180.0 / M_PI); 88 | double newdegree = 0; 89 | while (it != Utils::raw_rows.end()) { 90 | curr = *it; 91 | newdegree = atan2(curr->y, curr->x) * (180.0 / M_PI); 92 | double d = Utils::distances[0][curr->id]; 93 | points[curr->id - 1] = std::pair(curr, (d * -0.7) + (0.1 * curr->due_date) + 94 | (0.2 * (newdegree - degreesdeposit) / 360 * d)); 95 | ++it; 96 | } 97 | 98 | 99 | std::sort(points.begin(), points.end(), Utils::pfih_comparator()); 100 | 101 | 102 | //Creates a solution 103 | auto solution = new Solution(); 104 | 105 | auto v = new Vehicle(solution); 106 | v->id = 0; 107 | solution->vehicles.push_back(v); 108 | v->add_node(points[0].first, 0, ec); 109 | std::list candidates; 110 | 111 | for (auto it = ++points.begin(); it != points.end(); ++it) { 112 | auto point = *it; 113 | for (auto vit = solution->vehicles.begin(); vit != solution->vehicles.end(); ++vit) { 114 | auto vehicle = *vit; 115 | for (int i = 0; i <= vehicle->nodes.size(); i++) { 116 | ec = 0; 117 | vehicle->add_node(point.first, i, ec); 118 | if (ec == 0) { 119 | SubCandidate sb(solution->total_weight(), i, vehicle); 120 | candidates.push_back(sb); 121 | vehicle->remove_node(i); 122 | } 123 | } 124 | } 125 | 126 | if (!candidates.empty()) { 127 | candidates.sort(); 128 | auto chosen_one = *(candidates.begin()); 129 | ec = 0; 130 | chosen_one.v->add_node(point.first, chosen_one.pos, ec); 131 | point.first->state.insert({solution, std::pair(chosen_one.v, chosen_one.pos)}); 132 | candidates.clear(); 133 | } else { 134 | auto nv = new Vehicle(solution); 135 | nv->id = solution->vehicles.size(); 136 | solution->vehicles.push_back(nv); 137 | ec = 0; 138 | nv->add_node(point.first, 0, ec); 139 | point.first->state.insert({solution, std::pair(nv, 0)}); 140 | } 141 | } 142 | 143 | return solution; 144 | } 145 | 146 | Solution *Utils::random_solution() { 147 | auto solution = new Solution; 148 | auto v = new Vehicle(solution); 149 | solution->vehicles.push_back(v); 150 | 151 | auto point_pool = Utils::raw_rows; 152 | point_pool.erase(point_pool.begin()); 153 | while (!point_pool.empty()) { 154 | auto pit = point_pool.begin(); 155 | std::advance(pit, rand() % point_pool.size()); 156 | auto p = *pit; 157 | point_pool.erase(pit); 158 | auto ec = 0; 159 | for (auto vehicle: solution->vehicles) { 160 | for (auto i = 0; i <= vehicle->nodes.size(); ++i) { 161 | ec = 0; 162 | vehicle->add_node(p, i, ec); 163 | if (ec == 0) 164 | goto leave; 165 | } 166 | } 167 | 168 | if (ec != 0) { 169 | v = new Vehicle(solution); 170 | solution->vehicles.push_back(v); 171 | auto ec = 0; 172 | v->add_node(p, 0, ec); 173 | } 174 | leave:; 175 | } 176 | solution->total_weight(); 177 | return solution; 178 | } -------------------------------------------------------------------------------- /Utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | 6 | class VehicleState; 7 | class Point; 8 | class Vehicle; 9 | class Solution; 10 | 11 | class Utils 12 | { 13 | public: 14 | static std::shared_ptr origin; 15 | static std::list raw_rows; 16 | static double** distances; 17 | 18 | struct pfih_comparator 19 | { 20 | inline bool operator() (const std::pair& inst1, std::pair& inst2){ 21 | return inst1.second < inst2.second; 22 | } 23 | }; 24 | 25 | 26 | static void read_file(); 27 | static void calculate_distances(); 28 | static Solution* pfih(); 29 | static Solution* random_solution(); 30 | static double random_0_1(); 31 | 32 | }; 33 | 34 | -------------------------------------------------------------------------------- /Vehicle.cpp: -------------------------------------------------------------------------------- 1 | #include "Vehicle.h" 2 | #include "Utils.h" 3 | #include 4 | #include "Utils.h" 5 | #include "VehicleState.h" 6 | #include "Point.h" 7 | 8 | /*void Vehicle::valdebug() 9 | { 10 | int i = 0; 11 | for (auto node : nodes) 12 | { 13 | if(node->p->state[solution].second != i++) 14 | { 15 | std::cout << "erro"; 16 | } 17 | } 18 | }*/ 19 | void Vehicle::reevaluate_route(int start, int end) { 20 | std::list>::iterator li; 21 | std::shared_ptr last; 22 | //start = 0; 23 | //end = nodes.size(); 24 | 25 | if (start == 0) { 26 | li = nodes.begin(); 27 | last = Utils::origin; 28 | } else { 29 | li = nodes.begin(); 30 | int tmp_start = start; 31 | while (tmp_start-- > 0) 32 | ++li; 33 | last = *std::prev(li); 34 | 35 | } 36 | std::shared_ptr curr; 37 | while (++start <= end && li != nodes.end()) { 38 | curr = *li; 39 | li++; 40 | curr->current_cargo = last->current_cargo - curr->p->demand; 41 | curr->current_distance = last->current_distance + Utils::distances[last->p->id][curr->p->id]; 42 | curr->current_time = last->current_time + Utils::distances[last->p->id][curr->p->id]; 43 | curr->p->state[solution].second = start - 1; 44 | 45 | if (curr->current_time < curr->p->ready_time) { 46 | curr->current_time = curr->p->ready_time; 47 | } 48 | curr->current_time += curr->p->service_time; 49 | 50 | last = curr; 51 | } 52 | } 53 | 54 | bool Vehicle::is_point_on_vehicle(Point *p) { 55 | for (auto value_: nodes) { 56 | if (value_->p->id == p->id) { 57 | return true; 58 | } 59 | } 60 | return false; 61 | } 62 | 63 | void Vehicle::validate_states(std::shared_ptr possible_state, int position, int &ec) { 64 | /** 65 | * So, here we are, validate_states should take a "possible_state" that is basically a point (or a customer) 66 | * and try to insert into the current vehicle's route. it should return ec == 0 if it is possible to add the point 67 | * into the route, otherwise it should return ec != 0 68 | */ 69 | if (!nodes.empty()) { 70 | std::list>::iterator li; 71 | std::shared_ptr last_state; 72 | 73 | int last_state_position; 74 | if (position == 0) { 75 | li = nodes.begin(); 76 | last_state = Utils::origin; 77 | last_state_position = -1; 78 | } else { 79 | li = nodes.begin(); 80 | int tmp_position = position; 81 | while (tmp_position-- > 0) 82 | ++li; 83 | 84 | last_state = *std::prev(li); 85 | last_state_position = last_state->p->state[solution].second; 86 | } 87 | int iter_num = position; 88 | double dist; 89 | 90 | std::shared_ptr current_state; 91 | /** 92 | * This iteration bellow is causing the problems, sadly im not able to fix it. 93 | * But the idea is that I need to add the possible_point into the vehicle route 94 | * and then, for each point that is after the inserted, calculate its constraints and 95 | * determine if the route is feasible. 96 | */ 97 | for (; li != nodes.end(); ++li) { 98 | current_state = *li; 99 | dist = Utils::distances[last_state->p->id][current_state->p->id]; 100 | current_state->current_distance = last_state->current_distance + dist; 101 | current_state->current_time = last_state->current_time + dist; 102 | 103 | if (current_state->current_time > current_state->p->due_date) { 104 | if (iter_num > 0) { 105 | reevaluate_route(position, iter_num); 106 | } 107 | ec = 1; 108 | return; 109 | } 110 | 111 | current_state->current_cargo = last_state->current_cargo - current_state->p->demand; 112 | 113 | if (current_state->current_time < 114 | current_state->p->ready_time) { // Arrived early, need to wait for the point to become active 115 | current_state->current_time = current_state->p->ready_time; 116 | } 117 | if (current_state->current_cargo < 0) { 118 | if (iter_num > 0) { 119 | reevaluate_route(position, iter_num); 120 | } 121 | ec = 4; 122 | return; 123 | } 124 | 125 | current_state->current_time += current_state->p->service_time; 126 | current_state->p->state[solution].second = last_state_position + 1; 127 | last_state_position = current_state->p->state[solution].second; 128 | last_state = current_state; 129 | iter_num++; 130 | } 131 | } else { 132 | possible_state->current_distance = Utils::distances[Utils::origin->p->id][possible_state->p->id]; 133 | possible_state->current_time = possible_state->current_distance; 134 | if (possible_state->current_time > possible_state->p->due_date) { 135 | ec = 2; 136 | return; 137 | } 138 | if (possible_state->current_time < possible_state->p->ready_time) { 139 | possible_state->current_time = possible_state->p->ready_time; 140 | } 141 | possible_state->current_cargo -= possible_state->p->demand; 142 | possible_state->current_time += possible_state->p->service_time; 143 | possible_state->p->state[solution].second = 0; 144 | } 145 | 146 | if(this->nodes.empty()) 147 | return; // I guess it's safe to simply return here if there are no nodes 148 | 149 | if (get_last_node()->current_time + Utils::distances[get_last_node()->p->id][Utils::origin->p->id] > 150 | Utils::origin->p->due_date) { 151 | ec = 3; 152 | return; 153 | } 154 | 155 | } 156 | 157 | void Vehicle::add_node(Point *p, int pos, int &ec) { 158 | 159 | auto possible_state = std::make_shared(p); 160 | validate_states(possible_state, pos, ec); 161 | if (ec) 162 | return; 163 | 164 | auto it = nodes.begin(); 165 | auto tmp_pos = pos; 166 | while (tmp_pos-- > 0) 167 | ++it; 168 | 169 | nodes.insert(it, possible_state); 170 | p->state[solution].first = this; 171 | } 172 | 173 | void Vehicle::remove_node(int pos) { 174 | auto li = nodes.begin(); 175 | 176 | std::shared_ptr last; 177 | 178 | int c_pos = pos; 179 | while (c_pos-- > 0) 180 | ++li; 181 | 182 | if (pos == 0) { 183 | last = Utils::origin; 184 | } else { 185 | last = *std::prev(li); 186 | } 187 | 188 | nodes.erase(li++); 189 | 190 | std::shared_ptr curr; 191 | while (li != nodes.end()) { 192 | curr = *li; 193 | curr->current_cargo = last->current_cargo - curr->p->demand; 194 | curr->current_distance = last->current_distance + Utils::distances[last->p->id][curr->p->id]; 195 | curr->current_time = last->current_time + Utils::distances[last->p->id][curr->p->id]; 196 | 197 | if (curr->current_time < curr->p->ready_time) { 198 | curr->current_time = curr->p->ready_time; 199 | } 200 | curr->current_time += curr->p->service_time; 201 | 202 | curr->p->state[solution].second = curr->p->state[solution].second - 1; 203 | last = curr; 204 | ++li; 205 | } 206 | } 207 | 208 | double Vehicle::get_weight() 209 | const { 210 | return this->get_last_node()->current_distance + Utils::distances[get_last_node()->p->id][Utils::origin->p->id]; 211 | } 212 | 213 | Vehicle::Vehicle(Solution *s) { 214 | solution = s; 215 | } 216 | 217 | 218 | Vehicle *Vehicle::clone(Solution *s) { 219 | auto v = new Vehicle(s); 220 | v->id = this->id; 221 | std::shared_ptr ln = nullptr; 222 | for (auto node: this->nodes) { 223 | auto clone = node->clone(); 224 | ln = clone; 225 | clone->p->state[s] = {v, node->p->state[this->solution].second}; 226 | v->nodes.push_back(clone); 227 | } 228 | return v; 229 | } 230 | -------------------------------------------------------------------------------- /Vehicle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | class Point; 5 | class VehicleState; 6 | class Solution; 7 | 8 | class Vehicle 9 | { 10 | public: 11 | int id; 12 | std::list> nodes; 13 | Solution* solution; 14 | 15 | std::shared_ptr get_last_node() const { 16 | if(nodes.empty()) 17 | return nullptr; 18 | 19 | return nodes.back(); 20 | } 21 | void reevaluate_route(int start, int end); 22 | bool is_point_on_vehicle(Point* p); 23 | void validate_states(std::shared_ptr possible_state, int position, int &ec); 24 | void add_node(Point* p, int pos, int &ec); 25 | void remove_node(int pos); 26 | double get_weight() const; 27 | Vehicle* clone(Solution* s); 28 | 29 | 30 | Vehicle(Solution * s); 31 | }; 32 | 33 | -------------------------------------------------------------------------------- /VehicleState.cpp: -------------------------------------------------------------------------------- 1 | #include "VehicleState.h" 2 | #include "Point.h" 3 | 4 | 5 | VehicleState::VehicleState() 6 | { 7 | } 8 | 9 | 10 | VehicleState::~VehicleState() 11 | { 12 | } 13 | 14 | 15 | std::shared_ptr VehicleState::clone() 16 | const { 17 | auto vs = std::make_shared(); 18 | vs->p = this->p; 19 | 20 | vs->current_cargo = this->current_cargo; 21 | vs->current_time = this->current_time; 22 | vs->current_distance = this->current_distance; 23 | return vs; 24 | } 25 | -------------------------------------------------------------------------------- /VehicleState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | class Point; 4 | 5 | class VehicleState 6 | { 7 | public: 8 | Point* p; 9 | int current_cargo = 1000; 10 | double current_time = 0; 11 | double current_distance = 0; 12 | std::shared_ptr clone() const; 13 | 14 | 15 | 16 | explicit VehicleState(Point* p) 17 | : p(p) 18 | { 19 | } 20 | 21 | 22 | 23 | VehicleState(); 24 | ~VehicleState(); 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #define CORE_NUM 1 2 | #define DETERMINISTIC 3 | 4 | #include 5 | #include 6 | #include "Utils.h" 7 | #include "Hillclimbing.h" 8 | #include "Genetic.h" 9 | #include "Solution.h" 10 | #include 11 | #include 12 | #include 13 | #include "SAnnealing.h" 14 | 15 | 16 | int main() 17 | { 18 | Utils::read_file(); 19 | std::cout << "File has been loaded\n"; 20 | 21 | Utils::calculate_distances(); 22 | std::cout << "Distances have been calculated\n"; 23 | 24 | //Hillclimbing::run(); 25 | srand(time(nullptr)); 26 | 27 | std::vector threads; 28 | for (auto i = 0; i < CORE_NUM; ++i) 29 | { 30 | threads.push_back(std::thread([]() 31 | { 32 | #ifdef DETERMINISTIC 33 | auto seed = 1; 34 | #else 35 | int seed = time(nullptr); 36 | #endif 37 | srand(seed); 38 | //Hillclimbing 39 | /*std::cout << "Seed: " << seed << "\n"; 40 | std::cout << "Hilclimbing, 200 solutions, max_fails: 10000\n"; 41 | for (auto j = 0; j < 1000; ++j) 42 | { 43 | auto solution = Hillclimbing::run(10000); 44 | std::cout << solution->weight << ", "; 45 | delete solution; 46 | }*/ 47 | 48 | //Genetic algorithm 49 | std::cout << "\nGenetic algorithm, 200 solutions, population limit: 10; max_iter: 10000\n"; 50 | for(auto j = 0; j < 200; ++j) 51 | { 52 | Genetic::population_limit = 20; 53 | auto solution = Genetic::run(-1); 54 | std::cout << solution->weight << ", "; 55 | Genetic::clear(); 56 | } 57 | 58 | //Simulated annealing 59 | /*std::cout << "\nSimulated annealing, 200 solutions, temp: 100; min_temp: 0; tmp_lost_per_it: 0.01\n"; 60 | for (auto j = 0; j < 1; ++j) 61 | { 62 | auto solution = SAnnealing::run(100, 0, 0.00001); 63 | std::cout << solution->weight << ", "; 64 | delete solution; 65 | }*/ 66 | } 67 | )); 68 | } 69 | for (auto it = threads.begin(); it != threads.end(); ++it) 70 | { 71 | (*it).join(); 72 | } 73 | 74 | 75 | std::cout << "\nEnd.\n"; 76 | system("pause"); 77 | } 78 | --------------------------------------------------------------------------------