private static IEnumerable <PartialSolutionTail> CreateNewPartialSolution(PartialSolutionTail tail, Point[] points) { var newPartialSolutions = new PartialSolutionTail[points.Length]; for (int i = 0; i < newPartialSolutions.Length; i++) { newPartialSolutions[i] = new PartialSolutionTail(tail, points[i]); } return(newPartialSolutions); }
public PartialSolution(PartialSolution paritalSolution, PartialSolutionTail partialSolutionTail, int id) { this.Id = id; var points = paritalSolution.Points.ToList(); points.AddRange(partialSolutionTail.Points); this.Points = points.ToArray(); var length = this.Points.Length; this.DistanceClosed += partialSolutionTail.ClosedDistance; this.DistanceOpen = paritalSolution.DistanceOpen + partialSolutionTail.DistanceOpen; this.LastPoint = partialSolutionTail.LastPoint; }
public SolutionSet GetNextSolutionSet(SolutionSet solution, IEnumerable <Point> points, int beamDepth) { var tails = new PartialSolutionTail[solution.ParitalSolutionList.Length]; for (int i = 0; i < solution.ParitalSolutionList.Length; i++) { tails[i] = new PartialSolutionTail(solution.ParitalSolutionList[i]); } var tempPartialSolutions = Repete(tails, points, beamDepth); var ordered = tempPartialSolutions .OrderBy(ps => ps.ClosedDistance) .Take(SolutionSet.BeamWith); solution.Attach(ordered.ToArray()); //solution.Set(ordered.ToArray()); return(solution); }
public PartialSolutionTail(PartialSolutionTail fromTail, Point point) { var points = fromTail.Points.ToList(); if (points.Any() == false) { this.tailLenght += fromTail.Head.LastPoint.CalculateDistanceTo(point); } else { this.tailLenght = fromTail.tailLenght + fromTail.LastPoint.CalculateDistanceTo(point); } points.Add(point); this.Points = points.ToArray(); this.Head = fromTail.Head; this.LastPoint = point; }