Hi all,
i try to write a TSP-Solver to generate a toolpath for milling and after first results i need some advice how to optimize code and how structure it to prevent rhino crashes.
The script work like this.
- Take given startpoint (stpt)
- Copy the given Points for the path
- Find nearest points (clpt) to startpoint (first tried pointcompare and switched to ktree)
- create vectors (vec) between stpt and clpt
- take the vec with smallest 1 > |X| (clspt) > |Y| (switch X and Y change apth direction)
- the endpoint of the the shortest (clspt) is the new startpoint
- if (clspt) is empty take just the shortest distance point
- remove old startpoint from pointlist
Code
pic
Maybe someone can give me advice to store data or split it to avoid a crash when the point count increas.
I will delete every second point in the x direction to reduce the amount.
Any idea where i can invest my research is very welcome