VRPH
1.0
|
00001 00002 // // 00003 // This file is part of the VRPH C/C++ package for // 00004 // solving the Vehicle Routing Problem by Chris Groer // 00005 // Code is free for use by academic researchers. // 00006 // For other purposes, contact cgroer@gmail.com // 00007 // // 00009 00010 #include "VRPH.h" 00011 00012 void generate_li_vrp(int A, int B, int Q, int L, const char *outfile) 00013 { 00018 00019 int i,w,k,n,g,q; 00020 double x,y; 00021 FILE *out; 00022 00023 if( (out=fopen(outfile,"w"))==NULL) 00024 { 00025 fprintf(stderr,"Error opening %s for writing\n",outfile); 00026 report_error("%s: Error in generate_li_vrp\n",__FUNCTION__); 00027 } 00028 00029 n= A*B; 00030 00031 fprintf(out,"NAME: Li_Benchmark_%d_%d.vrp\n",A,B); 00032 fprintf(out,"COMMENT: None\n"); 00033 fprintf(out,"TYPE: CVRP\n"); 00034 fprintf(out,"DIMENSION: %d\n",n+1); 00035 fprintf(out,"CAPACITY: %d\n",Q); 00036 fprintf(out,"DISTANCE: %d\n",L); 00037 fprintf(out,"EDGE_WEIGHT_TYPE: FUNCTION\n"); 00038 fprintf(out,"EDGE_WEIGHT_FORMAT: EUC_2D\n"); 00039 fprintf(out,"NODE_COORD_TYPE: TWOD_COORDS\n"); 00040 fprintf(out,"NODE_COORD_SECTION\n"); 00041 00042 // Now print the coordinates 00043 w=0; 00044 for(k=1;k<=B;k++) 00045 { 00046 g = 30 * k; 00047 for(i=1;i<=A;i++) 00048 { 00049 w++; 00050 x = ((double)g) * cos(2.0*(((double)i)-1)*PI/((double)A)); 00051 y = ((double)g) * sin(2.0*(((double)i)-1)*PI/((double)A)); 00052 fprintf(out,"%d %2.4f %2.4f\n",w,x,y); 00053 } 00054 } 00055 00056 fprintf(out,"DEMAND_SECTION\n"); 00057 00058 // Now print the demands 00059 w=0; 00060 for(k=1;k<=B;k++) 00061 { 00062 g = 30 * k; 00063 for(i=1;i<=A;i++) 00064 { 00065 w++; 00066 if(i%4==2 || i%4==3) 00067 q=30; 00068 else 00069 q=10; 00070 fprintf(out,"%d %d\n",w,q); 00071 } 00072 } 00073 fprintf(out,"DEPOT_SECTION\n"); 00074 fprintf(out,"1\n"); 00075 fprintf(out,"-1\n"); 00076 fprintf(out,"EOF\n"); 00077 00078 fclose(out); 00079 return; 00080 } 00081