本文整理汇总了Python中volttron.platform.agent.base_market_agent.poly_line.PolyLine.max方法的典型用法代码示例。如果您正苦于以下问题:Python PolyLine.max方法的具体用法?Python PolyLine.max怎么用?Python PolyLine.max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类volttron.platform.agent.base_market_agent.poly_line.PolyLine
的用法示例。
在下文中一共展示了PolyLine.max方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: combine
# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import max [as 别名]
def combine(lines, increment):
# we return a new PolyLine which is a composite (summed horizontally) of inputs
composite = PolyLine()
# find the range defined by the curves
minY = None
maxY = None
for l in lines:
minY = PolyLine.min(minY, l.min_y())
maxY = PolyLine.max(maxY, l.max_y())
# special case if the lines are already horizontal or None
if minY == maxY:
minSumX = None
maxSumX = None
for line in lines:
minX = None
maxX = None
for point in line.points:
minX = PolyLine.min(minX, point.x)
maxX = PolyLine.max(maxX, point.x)
minSumX = PolyLine.sum(minSumX, minX)
maxSumX = PolyLine.sum(maxSumX, maxX)
composite.add(Point(minSumX, minY))
if minX != maxX:
composite.add(Point(maxSumX, maxY))
return composite
# create an array of ys in equal increments, with highest first
# this is assuming that price decreases with increase in demand (buyers!)
# but seems to work with multiple suppliers?
ys = sorted(np.linspace(minY, maxY, num=increment), reverse=True)
# print ys
# print minY, maxY
# now find the cumulative x associated with each y in the array
# starting with the highest y
for y in ys:
xt = None
for line in lines:
x = line.x(y, left=np.nan)
# print x, y
if x is not None:
xt = x if xt is None else xt + x
composite.add(Point(xt, y))
return composite
示例2: test_poly_line_max_second_none
# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import max [as 别名]
def test_poly_line_max_second_none():
max = PolyLine.max(1,None)
assert max == 1
示例3: test_poly_line_max_first_none
# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import max [as 别名]
def test_poly_line_max_first_none():
max = PolyLine.max(None,2)
assert max == 2
示例4: test_poly_line_max
# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import max [as 别名]
def test_poly_line_max():
max = PolyLine.max(1,2)
assert max == 2