当前位置: 首页>>代码示例>>Python>>正文


Python PolyLine.min方法代码示例

本文整理汇总了Python中volttron.platform.agent.base_market_agent.poly_line.PolyLine.min方法的典型用法代码示例。如果您正苦于以下问题:Python PolyLine.min方法的具体用法?Python PolyLine.min怎么用?Python PolyLine.min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在volttron.platform.agent.base_market_agent.poly_line.PolyLine的用法示例。


在下文中一共展示了PolyLine.min方法的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 min [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
开发者ID:Kisensum,项目名称:volttron,代码行数:50,代码来源:poly_line_factory.py

示例2: test_poly_line_min_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 min [as 别名]
def test_poly_line_min_second_none():
    min = PolyLine.min(1,None)
    assert min == 1
开发者ID:VOLTTRON,项目名称:volttron,代码行数:5,代码来源:test_poly_line.py

示例3: test_poly_line_min_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 min [as 别名]
def test_poly_line_min_first_none():
    min = PolyLine.min(None,2)
    assert min == 2
开发者ID:VOLTTRON,项目名称:volttron,代码行数:5,代码来源:test_poly_line.py

示例4: test_poly_line_min

# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import min [as 别名]
def test_poly_line_min():
    min = PolyLine.min(1,2)
    assert min == 1
开发者ID:VOLTTRON,项目名称:volttron,代码行数:5,代码来源:test_poly_line.py


注:本文中的volttron.platform.agent.base_market_agent.poly_line.PolyLine.min方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。