Ronjomp,
If my assumptions are right, what you are trying to achieve is: Given a set of instruments, find a route that will minimize the length of conduits/wire to connect them all.
This leads you to
Minimum Spanning Tree (MST).
You also probably want your conduits to run parrallel to the building lines. So you are now looking for:
Rectilinear Minimum Spanning Tree (RMST).
For this the problem is tractable. Look at the following link:
Efficient minimum spanning tree construction without Delaunay triangulationIn there you’ll find some pseudocode describing an efficient way to go about it. What you would do is simply select all the blocks without any connections (No need for LWPolyline joining the blocks) and you could generate the RMST.
However your problem does not stop there. Because by inserting junction boxes on your conduits network, you still can minimize the length of it. So this leads you to another beast that they call:
Rectilinear Steiner Minimum Tree (RSMT)There the problem becomes very difficult. Here is a quote from the next paper I propose to you:
However, Garey and Johnson [3] prove that the RSMT problem is NP-complete, indicating that a polynomial-time algorithm to compute an optimal RSMT is unlikely to exist.
It does not mean that the problem cannot be resolved but that a closed solution in reasonable computing time probably does not exist. However some heuristic can approach the solution in computable time.
In this paper:
An Efficient Rectilinear Steiner Minimum Tree Algorithm Based on Ant Colony OptimizationThey managed with their Aco-Steiner procedure to get a near optimal solution in about 50 iterations. They also give some pseudocode for achieving it.
Now enough Blah, Blah you got some coding to do
.
ymg