using System; using System.Collections.Generic; using System.Linq; using System.Text; using HeuristicLab.Core; using HeuristicLab.Problems.TravelingSalesman; namespace HeuristicLab.Services.Optimization.ControllerService.Parameters.HL { public class PathTSPParameterHandler : IParameterHandler { public Type HandledType { get { return typeof(PathTSPTour); } } public Model.Parameter Map(IItem item) { var tour = item as PathTSPTour; var parameter = new Model.Parameter(); var resultMatrix = new Model.DecimalMatrix(); // simply create a matrix which contains all the coordinates in correct order // the client may now display them as table double[][] matrix = new double[tour.Permutation.Length][]; for (var i=0; i < tour.Permutation.Length; i++) { matrix[i] = new double[2]; matrix[i][0] = tour.Coordinates[tour.Permutation[i], 0]; matrix[i][1] = tour.Coordinates[tour.Permutation[i], 1]; } parameter.Value = new Model.DecimalMatrix() { Value = matrix }; return parameter; } } }