00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #include "VRPH.h"
00014
00015
00016 int main(int argc, char *argv[])
00017 {
00022
00023 VRPH_version();
00024
00025 char in[VRPH_STRING_SIZE], plotfile[VRPH_STRING_SIZE],pdffile[VRPH_STRING_SIZE],
00026 solfile[VRPH_STRING_SIZE];
00027
00028 int i,n;
00029 int orientation=1;
00030 bool do_pdf=false;
00031
00032
00033 if(argc<7 )
00034 {
00035 fprintf(stderr,"Usage: %s -f <vrp_file> -s <sol_file> -p <plot_file> [-e -w -r]\n",argv[0]);
00036 fprintf(stderr,"\t <plot_file> must be .ps format\n");
00037 fprintf(stderr,"\t .pdf format requires the epstopdf executable\n");
00038 fprintf(stderr,"\t -pdf <pdf_file> will also create a .pdf image of the solution\n");
00039 fprintf(stderr,"\t -e will not show the depot edges\n");
00040 fprintf(stderr,"\t -w will weight the size of the non-depot nodes by their demand\n");
00041 fprintf(stderr,"\t -o will rotate 90 degrees\n");
00042 exit(-1);
00043 }
00044
00045
00046 int options=VRPH_DEFAULT_PLOT;
00047
00048 bool has_filename=false;
00049 for(i=1;i<argc;i++)
00050 {
00051 if(strcmp(argv[i],"-f")==0)
00052 {
00053
00054 has_filename=true;
00055 strcpy(in,argv[i+1]);
00056 }
00057
00058 if(strcmp(argv[i],"-s")==0)
00059 {
00060
00061 strcpy(solfile,argv[i+1]);
00062 }
00063
00064 if(strcmp(argv[i],"-p")==0)
00065 {
00066
00067 strcpy(plotfile,argv[i+1]);
00068
00069 }
00070
00071 if(strcmp(argv[i],"-pdf")==0)
00072 {
00073 do_pdf=true;
00074 strncpy(pdffile,argv[i+1],strlen(argv[i+1]));
00075 pdffile[strlen(argv[i+1])]='\0';
00076 }
00077
00078 if(strcmp(argv[i],"-e")==0)
00079 options+=VRPH_NO_DEPOT_EDGES;
00080
00081 if(strcmp(argv[i],"-w")==0)
00082 options+=VRPH_WEIGHTED;
00083
00084 if(strcmp(argv[i],"-r")==0)
00085 {
00086
00087 orientation=0;
00088
00089 }
00090
00091 }
00092
00093 if(!has_filename)
00094 report_error("No file name given!\n");
00095
00096 n=VRPGetDimension(in);
00097 VRP V(n);
00098
00099
00100 V.read_TSPLIB_file(in);
00101
00102 printf("Imported instance\n");
00103
00104 V.read_solution_file(solfile);
00105 int *sol;
00106 sol=new int[V.get_num_nodes()+2];
00107 V.export_canonical_solution_buff(sol);
00108 V.import_solution_buff(sol);
00109 printf("Imported solution\n");
00110
00111
00112 V.summary();
00113
00114 printf("Plotfile is %s\n",plotfile);
00115 V.plot(plotfile,options,orientation);
00116
00117 if(do_pdf)
00118 {
00119
00120 char command[VRPH_STRING_SIZE];
00121 sprintf(command,"%s %s --outfile=%s\n",VRPH_EPS_EXE,plotfile,pdffile);
00122 system(command);
00123 }
00124
00125 delete [] sol;
00126
00127 return 0;
00128
00129 }
00130
00131