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


Python PolyLine.add方法代码示例

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


在下文中一共展示了PolyLine.add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_electric_demand_curve

# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import add [as 别名]
 def create_electric_demand_curve(self, aggregate_air_demand):
     curve = PolyLine()
     for point in aggregate_air_demand.points:
         curve.add(Point(price=point.y, quantity=self.calcTotalLoad(point.x)))
     self.buyBidCurve = curve
     _log.debug("Report aggregated curve : {}".format(curve.points))
     return curve
开发者ID:Kisensum,项目名称:volttron,代码行数:9,代码来源:agent.py

示例2: create_supply_curve

# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import add [as 别名]
 def create_supply_curve(self):
     supply_curve = PolyLine()
     price = self.price
     quantity = self.infinity
     supply_curve.add(Point(price=price, quantity=quantity))
     price = self.price
     quantity = 0
     supply_curve.add(Point(price=price, quantity=quantity))
     return supply_curve
开发者ID:Kisensum,项目名称:volttron,代码行数:11,代码来源:agent.py

示例3: create_demand_curve

# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import add [as 别名]
def create_demand_curve():
    demand_curve = PolyLine()
    price = 0
    quantity = 1000
    demand_curve.add(Point(price,quantity))
    price = 1000
    quantity = 0
    demand_curve.add(Point(price,quantity))
    return demand_curve
开发者ID:VOLTTRON,项目名称:volttron,代码行数:11,代码来源:test_poly_line.py

示例4: create_supply_curve

# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import add [as 别名]
def create_supply_curve():
    supply_curve = PolyLine()
    price = 0
    quantity = 0
    supply_curve.add(Point(price,quantity))
    price = 1000
    quantity = 1000
    supply_curve.add(Point(price,quantity))
    return supply_curve
开发者ID:VOLTTRON,项目名称:volttron,代码行数:11,代码来源:test_poly_line.py

示例5: create_air_supply_curve

# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import add [as 别名]
 def create_air_supply_curve(self, electric_price, electric_quantity):
     supply_curve = PolyLine()
     price = 65
     quantity = 100000
     supply_curve.add(Point(price=price,quantity=quantity))
     price = 65
     quantity = 0 # negative quantities are not real -1*10000
     supply_curve.add(Point(price=price,quantity=quantity))
     return supply_curve
开发者ID:Kisensum,项目名称:volttron,代码行数:11,代码来源:agent.py

示例6: combine

# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import add [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

示例7: test_poly_line_add_two_points

# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import add [as 别名]
def test_poly_line_add_two_points():
    line = PolyLine()
    line.add(Point(4,8))
    line.add(Point(2,4))
    assert len(line.points) == 2
开发者ID:VOLTTRON,项目名称:volttron,代码行数:7,代码来源:test_poly_line.py

示例8: test_poly_line_add_one_point

# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import add [as 别名]
def test_poly_line_add_one_point():
    line = PolyLine()
    line.add(Point(4,8))
    assert len(line.points) == 1
开发者ID:VOLTTRON,项目名称:volttron,代码行数:6,代码来源:test_poly_line.py

示例9: test_poly_line_add_points_is_sorted

# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import add [as 别名]
def test_poly_line_add_points_is_sorted():
    line = PolyLine()
    line.add(Point(4,8))
    line.add(Point(2,4))
    assert line.points[0].x == 2
开发者ID:VOLTTRON,项目名称:volttron,代码行数:7,代码来源:test_poly_line.py

示例10: LightAgent

# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import add [as 别名]
class LightAgent(MarketAgent, FirstOrderZone):
    """
    The SampleElectricMeterAgent serves as a sample of an electric meter that
    sells electricity for a single building at a fixed price.
    """
    def __init__(self, market_name,agent_name,k,qmax,Pabsnom,nonResponsive,verbose_logging,subscribing_topic, **kwargs):
        super(LightAgent, self).__init__(verbose_logging, **kwargs)
        self.market_name = market_name
        self.agent_name = agent_name        
        self.k = k
        self.qmax = qmax
        self.Pabsnom=Pabsnom        
        self.nonResponsive = nonResponsive
        self.iniState()
        self.subscribing_topic=subscribing_topic
        self.join_market(self.market_name, BUYER, None, self.offer_callback, None, self.price_callback, self.error_callback)

    @Core.receiver('onstart')
    def setup(self, sender, **kwargs):
        _log.debug('Subscribing to '+'devices/CAMPUS/BUILDING1/AHU1/all')
        self.vip.pubsub.subscribe(peer='pubsub',
                                  prefix='devices/CAMPUS/BUILDING1/AHU1/all',
                                  callback=self.updateState)

    def offer_callback(self, timestamp, market_name, buyer_seller):
        result,message=self.make_offer(market_name, buyer_seller, self.create_demand_curve())
        _log.debug("results of the make offer {}".format(result))
        if not result:
            _log.debug("the new lightingt (maintain{}".format(self.qMax))
            gevent.sleep(random.random())
            self.vip.rpc.call('platform.actuator','set_point', self.agent_name,self.subscribing_topic+'/'+self.agent_name,round(self.qNorm,2)).get(timeout=6)

    def create_demand_curve(self):
        self.demand_curve = PolyLine()
        pMin = 10
        pMax = 100

        if (self.hvacAvail > 0):
            self.demand_curve.add(Point(price=min(pMin, pMax),quantity=max(self.qMin, self.qMax)*self.Pabsnom))
            self.demand_curve.add(Point(price=max(pMin, pMax),quantity=min(self.qMin, self.qMax)*self.Pabsnom))
        else:
            self.demand_curve.add(Point(price=max(pMin, pMax), quantity=0))
            self.demand_curve.add(Point(price=min(pMin, pMax),quantity=0))
        return self.demand_curve

    def iniState(self):
        self.hvacAvail = 1
        self.pClear = None
        self.qMin = 0.7
        self.qMax = self.qmax
        self.qNorm=self.qMax
        self.qClear=self.qNorm
 

    def updateState(self, peer, sender, bus, topic, headers, message):
        '''Subscribe to device data from message bus
        '''
        _log.debug('Received one new dataset')
        info = {}
        for key, value in message[0].items():
                  info[key] = value
        self.hvacAvail = info['SupplyFanStatus']
        if (self.hvacAvail > 0):
              self.qNorm=self.qMax  
        else:
              self.qNorm=0


    def updateSet(self):
        if self.pClear is not None and not self.nonResponsive and self.hvacAvail:
            self.qClear = self.clamp(self.demand_curve.x(self.pClear), self.qMax, self.qMin)
        else:
            self.qClear = 0
#        if self.qClear is None:
#            self.qClear = 0.

    def clamp(self, value, x1, x2):
        minValue = min(x1, x2)
        maxValue = max(x1, x2)
        return min(max(value, minValue), maxValue)        
                        
    def price_callback(self, timestamp, market_name, buyer_seller, price, quantity):
        _log.debug("the price is {}".format(price))
        self.pClear=price
        if self.pClear is not None: 
            self.updateSet()
            _log.debug("the new lightingt is {}".format(self.qClear))
            gevent.sleep(random.random())
            self.vip.rpc.call('platform.actuator','set_point', self.agent_name,self.subscribing_topic+'/'+self.agent_name,round(self.qClear,2)).get(timeout=5)


    def error_callback(self, timestamp, market_name, buyer_seller,  error_code, error_message, aux):
        _log.debug("the new lightingt is {}".format(self.qNorm))
        self.vip.rpc.call('platform.actuator','set_point', self.agent_name,self.subscribing_topic+'/'+self.agent_name,round(self.qNorm,2)).get(timeout=5)
        

    def ease(self, target, current, limit):
        return current - np.sign(current-target)*min(abs(current-target), abs(limit))        
开发者ID:Kisensum,项目名称:volttron,代码行数:100,代码来源:agent.py

示例11: fromTupples

# 需要导入模块: from volttron.platform.agent.base_market_agent.poly_line import PolyLine [as 别名]
# 或者: from volttron.platform.agent.base_market_agent.poly_line.PolyLine import add [as 别名]
 def fromTupples(points):
     polyLine = PolyLine()
     for p in points:
         if p is not None and len(p) == 2:
             polyLine.add(Point(p[0], p[1]))
     return polyLine
开发者ID:Kisensum,项目名称:volttron,代码行数:8,代码来源:poly_line_factory.py


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