in reply to Closed geometry: a train track problem

I can't help but notice the family resemblance this has to the Travelling Salesman Problem. One imperfect but nevertheless useful approach to that type of problem is the neural network. I'd start by defining the trackset as a set of vectors (x,y) and use Math::Combinatorics to generate the permutations. Then generate a target shape starting with a thin long oblong layout (meant to represent only an approximation to the flattest possible) of target circumference, and generate track solutions for which the sum of distances between the endpoints of the track pieces and the target shape approximates to a target value (+ or - a tolerance value). Change both the target value and tolerance to iterate (working with the same permutation until it succeeds for the iterated targets or the iteration exhausts and then getting the next permutation), using 1/4 unit steps. Permutations can be eliminated as soon the distance sum goes out of tolerance or if pieces run out before connecting back to the first piece (*update: can eliminate also if the distance from the nearest point on the target shape to the home point is already too great to get home for the remaining pieces). Overachievers are thus eliminated early and no solutions will need to exhaust the pieces to underachieve the target provided the target deviance is iterated in ascending order, making elimination relatively fast. A maximum total deviation of say three times the template circumference of the starting target shape would also assist the elimination speed and is anyway essential to prevent impossible permutations from being tried out for an infinite number of trial deviations.

Update: *could pre-compute the scalar value of each piece (using Pythagorus: sqr. root of the sum of the two components of the vector) and store them alongside the shapes rather than compute them every time the piece is used.

  • Comment on Re: Closed geometry: a train track problem