• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python poly_line.PolyLine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create_electric_demand_curve

 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,代码行数:7,代码来源:agent.py


示例2: create_demand_curve

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,代码行数:9,代码来源:test_poly_line.py


示例3: create_supply_curve

 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,代码行数:9,代码来源:agent.py


示例4: create_supply_curve

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,代码行数:9,代码来源:test_poly_line.py


示例5: create_air_supply_curve

 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,代码行数:9,代码来源:agent.py


示例6: create_demand_curve

    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
开发者ID:Kisensum,项目名称:volttron,代码行数:12,代码来源:agent.py


示例7: settle

    def settle(self):
        enough_buys = len(self._buy_offers) > 0
        enough_sells = len(self._sell_offers) > 0
        if enough_buys:
            demand_curve = self._aggregate(self._buy_offers)
        else:
            _log.debug("There are no buy offers.")
        if enough_sells:
            supply_curve = self._aggregate(self._sell_offers)
        else:
            _log.debug("There are no sell offers.")

        if enough_buys and enough_sells:
            intersection = PolyLine.intersection(demand_curve, supply_curve)
        else:
            intersection = None, None, {}

        quantity = intersection[0]
        price = intersection[1]
        aux = PolyLine.compare(demand_curve, supply_curve)

        return quantity, price, aux
开发者ID:Kisensum,项目名称:volttron,代码行数:22,代码来源:offer_manager.py


示例8: test_poly_line_sum_first_none

def test_poly_line_sum_first_none():
    sum = PolyLine.sum(None,2)
    assert sum == 2
开发者ID:VOLTTRON,项目名称:volttron,代码行数:3,代码来源:test_poly_line.py


示例9: test_poly_line_max_second_none

def test_poly_line_max_second_none():
    max = PolyLine.max(1,None)
    assert max == 1
开发者ID:VOLTTRON,项目名称:volttron,代码行数:3,代码来源:test_poly_line.py


示例10: test_poly_line_sum

def test_poly_line_sum():
    sum = PolyLine.sum(1,2)
    assert sum == 3
开发者ID:VOLTTRON,项目名称:volttron,代码行数:3,代码来源:test_poly_line.py


示例11: test_poly_line_max

def test_poly_line_max():
    max = PolyLine.max(1,2)
    assert max == 2
开发者ID:VOLTTRON,项目名称:volttron,代码行数:3,代码来源:test_poly_line.py


示例12: test_poly_line_max_first_none

def test_poly_line_max_first_none():
    max = PolyLine.max(None,2)
    assert max == 2
开发者ID:VOLTTRON,项目名称:volttron,代码行数:3,代码来源:test_poly_line.py


示例13: fromTupples

 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,代码行数:6,代码来源:poly_line_factory.py


示例14: test_poly_line_min_second_none

def test_poly_line_min_second_none():
    min = PolyLine.min(1,None)
    assert min == 1
开发者ID:VOLTTRON,项目名称:volttron,代码行数:3,代码来源:test_poly_line.py


示例15: test_poly_line_sum_second_none

def test_poly_line_sum_second_none():
    sum = PolyLine.sum(1,None)
    assert sum == 1
开发者ID:VOLTTRON,项目名称:volttron,代码行数:3,代码来源:test_poly_line.py


示例16: test_poly_line_add_two_points

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,代码行数:5,代码来源:test_poly_line.py


示例17: LightAgent

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,代码行数:98,代码来源:agent.py


示例18: test_poly_line_no_intersection

def test_poly_line_no_intersection():
    demand1 = create_demand_curve()
    demand2 = create_demand_curve()
    intersection = PolyLine.intersection(demand1, demand2)
    assert len(intersection) == 2
开发者ID:VOLTTRON,项目名称:volttron,代码行数:5,代码来源:test_poly_line.py


示例19: test_poly_line_intersection_yeilds_two

def test_poly_line_intersection_yeilds_two():
    demand = create_demand_curve()
    supply = create_supply_curve()
    intersection = PolyLine.intersection(demand, supply)
    assert len(intersection) == 2
开发者ID:VOLTTRON,项目名称:volttron,代码行数:5,代码来源:test_poly_line.py


示例20: test_poly_line_intersection_not_none

def test_poly_line_intersection_not_none():
    demand = create_demand_curve()
    supply = create_supply_curve()
    intersection = PolyLine.intersection(demand, supply)
    assert intersection is not None
开发者ID:VOLTTRON,项目名称:volttron,代码行数:5,代码来源:test_poly_line.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.default_main函数代码示例发布时间:2022-05-26
下一篇:
Python platform.get_services_core函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap