linspace ( 0, 1, len ( r1 )) # position of the nth Red sample within the range 0 to 1 g2 = g1 # value of Green at the nth sample g0 = np. array ( c ) # value of Blue for the nth sample r2 = r1 # value of Red at the nth sample r0 = np. array ( c ) # value of Green for the nth sample b1 = np. array ( c ) # value of Red for the nth sample g1 = np. Using a dark-blue-magenta end pointĪaaanyway, Adding this point allows us to start the TSP there, because it will move to the next nearest point - I think. If I include the third idea - choose the dark-bluest end-point candidate - I think it should do better than it is now. (Only 0.25 red because if it's a toss-up between blue and red, I want blue.) So if we figure out the median (say) smallest non-zero point distance, we can make this estimate.īlending the first two ideas, I am now starting at (0.25, 0, 0.5). Most points have two points about the same distance away (one on either side). We might be able to guess where it is: the ends of the line should be the only two points for which the second-closest point is roughly twice as far away as the very closest point. At the cool end: we tend to map cool colours.At the end nearest black: we tend to map darker colours to lower values.We need to start the traversal of the locus somewhere. Note that you need to add the Concorde and LKH libs to PATH as mentioned in the docs for pytsp. LKH and Concorde can be used via the TSP Python package (but note that it used to be called pyconcorde so you need to change the names of some functions - look at the source or use my fork. Concorde (I followed these instructions for installing concorde on my Mac.).Other than creating a naive TSP solver in Python – let's face it, it'll be broken or slow or non-optimal - there are three good TSP solver options: Then squareform casts it into a square symmetric matrix, which is what we need for our TSP solver. This is just a norm, but there's a convenient function for finding distance pairs in n-space. To start with, we need the distances between all points. Find the shortest tour from black (see below) to 'the other end'. We can solve this problem as the travelling salesman problem. This will make a nice organized sequence of codes - in our case, this will be the colourmap. I propose starting at the dark end (the end of the line nearest black) and crawling aling the line of points from there.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |