code: def bids_to_pwl(self, bids):
          
          assert self.is_load
          # Apply only those bids associated with this dispatchable load.
          vl_bids = [bid for bid in bids if bid.vLoad == self]
          # Filter out zero quantity bids.
          gt_zero = [bid for bid in vl_bids if round(bid.quantity, 4) > 0.0]
          # Ignore withheld offers.
          valid_bids = [bid for bid in gt_zero if not bid.withheld]
  
          p_bids = [v for v in valid_bids if not v.reactive]
          q_bids = [v for v in valid_bids if v.reactive]
  
          if p_bids:
              self.p_cost = self._offbids_to_points(p_bids, True)
              self.pcost_model = PW_LINEAR
              self.online = True
          else:
              self.p_cost = [(0.0, 0.0), (self.p_max, 0.0)]
              self.pcost_model = PW_LINEAR
              logger.info("No valid active power bids for dispatchable load "
                          "[%s], shutting down." % self.name)
              self.online = False
  
          if q_bids:
              self.q_cost = self._offbids_to_points(q_bids, True)
              self.qcost_model = PW_LINEAR
              self.online = True
          else:
              self.q_cost = [(self.q_min, 0.0), (0.0, 0.0), (self.q_max, 0.0)]
              self.qcost_model = PW_LINEAR
  #            logger.info("No valid bids for dispatchable load, shutting down.")
  #            self.online = False
  
          self._adjust_limits()
docs: Updates the piece-wise linear total cost function using the given
          bid blocks.
  
          Based on off2case.m from MATPOWER by Ray Zimmerman, developed at PSERC
          Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more info.