示例#1
0
 /// <summary>
 /// Initializes a new instance of <see cref="TSPLIBParser"/> with the given <paramref name="path"/>.
 /// </summary>
 /// <exception cref="ArgumentException">Thrown if the input file is not a TSPLIB TSP file (*.vrp)
 /// </exception>
 /// <param name="path">The path where the VRP is stored.</param>
 public GoldenParser()
 {
     comment    = string.Empty;
     vertices   = null;
     weightType = GoldenEdgeWeightType.UNDEFINED;
     capacity   = -1;
     vehicles   = -1;
     distance   = -1;
     demands    = null;
 }
示例#2
0
        private void ReadWeightFormat(string str)
        {
            string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
            string   format = tokens[tokens.Length - 1].Trim();

            if (format.Equals("euc_2d", StringComparison.OrdinalIgnoreCase))
            {
                weightType = GoldenEdgeWeightType.EUC_2D;
            }
            else if (format.Equals("geo", StringComparison.OrdinalIgnoreCase))
            {
                weightType = GoldenEdgeWeightType.GEO;
            }
            else
            {
                throw new InvalidDataException("Input file contains an unsupported edge weight format.");
            }
        }
示例#3
0
    private void ReadWeightFormat(string str) {
      string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
      string format = tokens[tokens.Length - 1].Trim();

      if (format.Equals("euc_2d", StringComparison.OrdinalIgnoreCase))
        weightType = GoldenEdgeWeightType.EUC_2D;
      else if (format.Equals("geo", StringComparison.OrdinalIgnoreCase))
        weightType = GoldenEdgeWeightType.GEO;
      else
        throw new InvalidDataException("Input file contains an unsupported edge weight format.");
    }
示例#4
0
    private void ReadWeightType(string str) {
      string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
      string type = tokens[tokens.Length - 1].Trim();

      if (type.Equals("euc_2d", StringComparison.OrdinalIgnoreCase))
        weightType = GoldenEdgeWeightType.EUC_2D;
      else if (type.Equals("geo", StringComparison.OrdinalIgnoreCase))
        weightType = GoldenEdgeWeightType.GEO;
      else if (type.Equals("function", StringComparison.OrdinalIgnoreCase)) {
        weightType = GoldenEdgeWeightType.UNDEFINED;
      } else
        throw new InvalidDataException("Input file contains an unsupported edge weight format (only \"EUC_2D\" and \"GEO\" are supported).");
    }
示例#5
0
 /// <summary>
 /// Initializes a new instance of <see cref="TSPLIBParser"/> with the given <paramref name="path"/>.
 /// </summary>
 /// <exception cref="ArgumentException">Thrown if the input file is not a TSPLIB TSP file (*.vrp)
 /// </exception>
 /// <param name="path">The path where the VRP is stored.</param>
 public GoldenParser() {
   comment = string.Empty;
   vertices = null;
   weightType = GoldenEdgeWeightType.UNDEFINED;
   capacity = -1;
   vehicles = -1;
   distance = -1;
   demands = null;
 }