def create_demand_curve(self, load_index, index):
     demand_curve = PolyLine()
     price_min, price_max = self.determine_prices()
     try:
         if len(self.market_name) > 1:
             qMin = self.q_uc[load_index]
             qMax = self.q_uc[load_index]
         else:
             qMin = self.single_timestep_power
             qMax = self.single_timestep_power
         demand_curve.add(
             Point(price=max(price_min, price_max),
                   quantity=min(qMin, qMax)))
         demand_curve.add(
             Point(price=min(price_min, price_max),
                   quantity=max(qMin, qMax)))
     except:
         demand_curve.add(
             Point(price=max(price_min, price_max), quantity=0.1))
         demand_curve.add(
             Point(price=min(price_min, price_max), quantity=0.1))
     topic_suffix = "/".join([self.agent_name, "DemandCurve"])
     message = {
         "MarketIndex": index,
         "Curve": demand_curve.tuppleize(),
         "Commodity": "Electric"
     }
     self.publish_record(topic_suffix, message)
     _log.debug("{} debug demand_curve - curve: {}".format(
         self.agent_name, demand_curve.points))
     return demand_curve
Beispiel #2
0
    def create_demand_curve(self, market_index, sched_index, occupied):
        """
        Create demand curve.  market_index (0-23) where next hour is 0
        (or for single market 0 for next market).  sched_index (0-23) is hour
        of day corresponding to market that demand_curve is being created.
        :param market_index: int; current market index where 0 is the next hour.
        :param sched_index: int; 0-23 corresponding to hour of day
        :param occupied: bool; true if occupied
        :return:
        """
        _log.debug("%s create_demand_curve - index: %s - sched: %s",
                   self.core.identity, market_index, sched_index)
        demand_curve = PolyLine()
        prices = self.determine_prices()
        self.update_prediction_error()
        for control, price in zip(self.ct_flexibility, prices):
            if occupied:
                _set = control
            else:
                _set = self.off_setpoint
            q = self.get_q(_set, sched_index, market_index, occupied)
            demand_curve.add(Point(price=price, quantity=q))

        topic_suffix = "DemandCurve"
        message = {
            "MarketIndex": market_index,
            "Curve": demand_curve.tuppleize(),
            "Commodity": self.commodity
        }
        _log.debug("%s debug demand_curve - curve: %s", self.core.identity,
                   demand_curve.points)
        self.publish_record(topic_suffix, message)
        return demand_curve
Beispiel #3
0
    def create_demand_curve(self, market_index, sched_index, occupied):
        _log.debug("{} debug demand_curve - index: {} - sched: {}".format(self.agent_name,
                                                                          market_index,
                                                                          sched_index))
        demand_curve = PolyLine()
        prices = self.determine_prices()
        ct_flx = []
        for i in range(len(prices)):
            if occupied:
                _set = self.ct_flexibility[i]
            else:
                _set = self.off_setpoint
            ct_flx.append(_set)
            q = self.get_q(_set, sched_index, market_index, occupied)
            demand_curve.add(Point(price=prices[i], quantity=q))

        ct_flx = [min(ct_flx), max(ct_flx)] if ct_flx else []
        topic_suffix = "/".join([self.agent_name, "DemandCurve"])
        message = {"MarketIndex": market_index, "Curve": demand_curve.tuppleize(), "Commodity": self.commodity}
        _log.debug("{} debug demand_curve - curve: {}".format(self.agent_name, demand_curve.points))
        self.publish_record(topic_suffix, message)
        return demand_curve