mrprajesh

GenerateCVRP2

Jul 23rd, 2022 (edited)
609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. //~~~START:Sat, 23-Jul-2022, 09:15:54 IST
  2. //~~~Author:Rajesh Pandian M | mrprajesh.co.in
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5. int main(int argc, char* argv[]){
  6.     //~ std::random_device rd{};
  7.     //~ std::mt19937 gen{rd()};.
  8.     srand(time(0));
  9.  
  10.   //~ int n = 10;
  11.  
  12.   int n = 100000;
  13.   //~ int LimitLeft   = -30000;
  14.   cerr << "n? ";
  15.   cin >> n;
  16.   int LimitRight  =  30000;
  17.  
  18.   cout<< "NAME : GenN"<< n/1000 << " KC200.vrp" << '\n';
  19.  
  20.   cout<< "COMMENT : Generated       " << '\n';
  21.   cout<< "TYPE : CVRP               " << '\n';
  22.   cout<< "DIMENSION : " << n          << '\n';
  23.   cout<< "EDGE_WEIGHT_TYPE : EUC_2D " << '\n';
  24.   cout<< "CAPACITY : 200            " << '\n';
  25.   cout<< "NODE_COORD_SECTION        " << '\n';
  26.  
  27.  
  28.   //~ std::cout<< "COORD" << '\n';
  29.   for (int i=0; i < n; ++i){
  30.     bool isPosLeft = rand()%2;
  31.     bool isPosRight = rand()%2;
  32.     std::cout<< i+1 << " " << (isPosLeft? 1 : -1)*(rand()%LimitRight) << " " << (isPosRight? 1 : -1)*(rand()%LimitRight) << '\n';
  33.   }
  34.   std::cout<< "DEMAND_SECTION" << '\n';
  35.   std::cout<< "1 0" << '\n';
  36.   for (int i=2; i <= n; ++i){
  37.     std::cout<< i << " " << 1+(rand()%10) << '\n';
  38.   }
  39.  
  40.   cout << "DEPOT_SECTION" << '\n';
  41.   cout << "1" << '\n';
  42.   cout << "-1" << '\n';
  43.   cout << "EOF" << '\n';
  44.  
  45.  
  46.   return 0;
  47. }
  48.  
Add Comment
Please, Sign In to add comment