/// <summary> /// Load problem from TSP file /// </summary> /// <param name="tspFile">TSP file instance</param> /// <returns>Loaded problem</returns> private static HamiltonianCycleProblem FromTspFile(TspFile tspFile) { if (tspFile.Type != FileType.HCP) { throw new ArgumentOutOfRangeException("tspFile"); } TspFileDataExtractor extractor = new TspFileDataExtractor(tspFile); var nodeProvider = extractor.MakeNodeProvider(); var nodes = nodeProvider.GetNodes(); var edgeProvider = extractor.MakeEdgeProvider(nodes); var edgeWeightsProvider = new NodeAdjacencyBasedWeightProvider(edgeProvider, 1, 2); var fixedEdgesProvider = extractor.MakeFixedEdgesProvider(nodes); return(new HamiltonianCycleProblem(tspFile.Name, tspFile.Comment, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider)); }
/// <summary> /// Load problem from TSP file /// </summary> /// <param name="tspFile">TSP file instance</param> /// <returns>Loaded problem</returns> private static HamiltonianCycleProblem FromTspFile(TspFile tspFile) { if (tspFile.Type != FileType.HCP) { throw new ArgumentOutOfRangeException("tspFile"); } TspFileDataExtractor extractor = new TspFileDataExtractor(tspFile); var nodeProvider = extractor.MakeNodeProvider(); var nodes = nodeProvider.GetNodes(); var edgeProvider = extractor.MakeEdgeProvider(nodes); var edgeWeightsProvider = new NodeAdjacencyBasedWeightProvider(edgeProvider, 1, 2); var fixedEdgesProvider = extractor.MakeFixedEdgesProvider(nodes); return new HamiltonianCycleProblem(tspFile.Name, tspFile.Comment, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider); }