有人可以帮助我解决这个传奇问题吗?
任何专家可以帮助我合并以下传奇吗? 我希望将所有两个传说合并在一起,
可以帮助我合并以下传奇吗? 我希望所有两个传说合并
def dominates(bestRouteTime, num_buses):
dominating = False
for i in range(len(bestRouteTime)):
if bestRouteTime[i] > num_buses[i]:
return False
if bestRouteTime[i] < num_buses[i]:
dominating = True
return dominating
def is_dominated(bestRouteTime,front):
for num_buses in front:
if dominates(num_buses,bestRouteTime):
return True
return False
def pareto_front(cand):
front = set([])
for i in cand:
add_i = True
for j in list(front):
if dominates(i,j):
front.remove(j)
if dominates(j,i):
add_i = False
if add_i:
front.add(i)
front = list(front)
front.sort()
return front
if __name__ == "__main__":
import random
#random.seed(1)
cand = [(random.random()**.25,random.random()**.25) for i in range(1000)]
fig, ax = plt.subplots(figsize=(10, 8))
ax.xlabel = "Travel Time (seconds)"
ax.ylabel = "Number of Walking Buses"
for (bestRouteTime, num_buses) in cand:
x,y = (bestRouteTime*360, num_buses*10)
ax.plot(x,y,"bo")
front = pareto_front(cand)
ax.plot([x for (x,y) in front], [y for (x,y) in front], "ro", label="Pareto Font")
fig.canvas.draw()
ax.set_ylabel('Number of Walking Buses')
ax.set_xlabel('Travel Time (seconds)')
plt.title = ("Pareto Optimal Fronts (TSPTW))")
legend = ax.legend(loc='best', shadow=True, fontsize='large')
plt.show()
Can any expert help me merge the following legend?
I would like all the two legends to be merged
Can any expert help me merge the following legend?
I would like all the two legends to be merged
def dominates(bestRouteTime, num_buses):
dominating = False
for i in range(len(bestRouteTime)):
if bestRouteTime[i] > num_buses[i]:
return False
if bestRouteTime[i] < num_buses[i]:
dominating = True
return dominating
def is_dominated(bestRouteTime,front):
for num_buses in front:
if dominates(num_buses,bestRouteTime):
return True
return False
def pareto_front(cand):
front = set([])
for i in cand:
add_i = True
for j in list(front):
if dominates(i,j):
front.remove(j)
if dominates(j,i):
add_i = False
if add_i:
front.add(i)
front = list(front)
front.sort()
return front
if __name__ == "__main__":
import random
#random.seed(1)
cand = [(random.random()**.25,random.random()**.25) for i in range(1000)]
fig, ax = plt.subplots(figsize=(10, 8))
ax.xlabel = "Travel Time (seconds)"
ax.ylabel = "Number of Walking Buses"
for (bestRouteTime, num_buses) in cand:
x,y = (bestRouteTime*360, num_buses*10)
ax.plot(x,y,"bo")
front = pareto_front(cand)
ax.plot([x for (x,y) in front], [y for (x,y) in front], "ro", label="Pareto Font")
fig.canvas.draw()
ax.set_ylabel('Number of Walking Buses')
ax.set_xlabel('Travel Time (seconds)')
plt.title = ("Pareto Optimal Fronts (TSPTW))")
legend = ax.legend(loc='best', shadow=True, fontsize='large')
plt.show()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在不使我的生活变得过多复杂的情况下,我会捕获line艺术家(
line1,line2
在下面的代码中),并将其在传说中使用。特别是使用蓝点的最后一位艺术家:Without complicating my life too much, I would capture the line artists (
line1, line2
in the code below) and use them on the legend. In particular, use the last artist of the blue dots:新输出
New output