Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the following Python code that calculates the Pareto Front of a specific list of 2-d vectors:

def pareto_frontier(Xs, Ys, maxX = True, maxY = True):
myList = sorted([[Xs[i], Ys[i]] for i in range(len(Xs))], reverse=maxX)
p_front = [myList[0]]    
for pair in myList[1:]:
    if maxY: 
        if pair[1] >= p_front[-1][1]:
            p_front.append(pair)
    else:
        if pair[1] <= p_front[-1][1]:
            p_front.append(pair)
p_frontX = [pair[0] for pair in p_front]
p_frontY = [pair[1] for pair in p_front]
return p_frontX, p_frontY


My goal is to convert this function into a ranking problem. I have read about the skyline ranking, and I would like to apply this ranking algorithm to a list of 100 5-d vectors (by minimising all variables). Since this is a fairly small list of vectors, I am not really interested in efficiency. As reference, these papers seem to present my desired goal:

https://www.sciencedirect.com/science/article/pii/S0169023X10000480

http://cgi.di.uoa.gr/~gvalk/pubs/dp-idp.pdf

https://www.sciencedirect.com/science/article/pii/S0306437911000421

What I have tried:

<pre>def pareto_frontier(Xs, Ys, maxX = True, maxY = True):
myList = sorted([[Xs[i], Ys[i]] for i in range(len(Xs))], reverse=maxX)
p_front = [myList[0]]    
for pair in myList[1:]:
    if maxY: 
        if pair[1] >= p_front[-1][1]:
            p_front.append(pair)
    else:
        if pair[1] <= p_front[-1][1]:
            p_front.append(pair)
p_frontX = [pair[0] for pair in p_front]
p_frontY = [pair[1] for pair in p_front]
return p_frontX, p_frontY
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900