Sequential route based nearest distance point

Hi,
Is there any method that could perform a sequential output based on closest distance in each point from set of data?

For illustration as below:
image

I’m not an expert on topic just recommend you to look at this node

1 Like

What you want to do could be described as the “Traveling salesman problem

There are several discussions and solutions for that. One is implemented in Python.


Traveling salesperson

examples in a Jupyter notebook

Hi @izaychik63
Thank you for the response

Hi @mlauber71
Is there any ways I can implement this TSP on knime? maybe not exactly the same but somewhat similar. Based on the article you share, this based on Phyton.

Yes that is possible. I first put the example into a Jupyter notebook that you can also find in the KNWF file attached to this entry.

You need a working Python installation and make Python Known to KNIME, and also several packages.

This set of coordinates should be turned into an optimal way. The results should be stored and the image turned into a PNG.

I put the steps from the notebook into KNIME (since this is a KNIME forum) and made the necessary connections.

Also the optimal route (itinerary_rank) will be stored together with the coordinates for further reference.

Please note: at the heart of the operation is the mlrose package by Genevieve Hayes.

I implemented the ‘Example 3’ from this Jupyter notebook of examples. Other tasks might need other settings. You might adapt the other examples in the same manner and see if they can help you.

kn_example_traveling_salesman_problem_python.knwf (145.1 KB)

5 Likes

Thanks for your solution! this really helps me :slight_smile:

2 Likes

Hi @mlauber71

May I know how did you install mlrose module? I tried running it but got the error in console like this. Thanks in advance :slight_smile:

ERROR Python Script (1⇒2) 0:7 Execute failed: Traceback (most recent call last):
File “C:\Users\yunan.ay\KNIME_DEPLOYMENT\knime_bin\plugins\org.knime.python2_3.7.2.v201904170931\py\PythonKernelBase.py”, line 278, in execute
exec(source_code, self._exec_env, self._exec_env)
File “”, line 1, in
ModuleNotFoundError: No module named ‘mlrose’

Just using pip at the Anaconda prompt should do it. You could also start the command in the Jupyter notebook.

pip install mlrose

1 Like

Thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.