I am trying to find the distance to a point (in 4 dimensions, only 2 are shown here) (any colored crosses in the figure) to the supposed Pareto border (black line). This line represents the best representation of the Pareto boundaries in the optimization process.
Pareto = [[0.3875575798354123, -2.4122340425531914], [0.37707675586149786, -2.398936170212766], [0.38176077842761763, -2.4069148936170213], [0.4080534133844003, -2.4914285714285715], [0.35963459448268725, -2.3631532329495126], [0.34395217638838566, -2.3579931972789114], [0.32203302106516224, -2.344858156028369], [0.36742404637441123, -2.3886054421768708], [0.40461156254852226, -2.4141156462585034], [0.36387868122767975, -2.375], [0.3393199109776927, -2.348404255319149]]
Right now, I am calculating the distance from any point to the Pareto border as follows:
def dominates(row, rowCandidate): return all(r >= rc for r, rc in zip(row, rowCandidate)) def dist2Pareto(pareto,candidate): listDist = [] dominateN = 0 dominatePoss = 0 if len(pareto) >= 2: for i in pareto: if i != candidate: dominatePoss += 1 dominate = dominates(candidate,i) if dominate == True: dominateN += 1 listDist.append(np.linalg.norm(np.array(i)-np.array(candidate))) listDist.sort() if dominateN == len(pareto): print "beyond" return listDist[0] else: return listDist[0]
Where I calculate the distance to each point of the black line and get the shortest distance (distance to the nearest point of a known border).
However, I believe that I should calculate the distance to the nearest line segment. How can I achieve this?
