code: def getReward(self):
          
          on = self.env.case.online_generators
          generators = [g for g in on if g.bus.type != REFERENCE]
  
          cost = sum([g.total_cost() for g in generators])
  
  
          ref_penalty = 1000.0
          refs = [g for g in on if g.bus.type == REFERENCE]
          for g in refs:
              # Do not receive payment for negative Pg at slack bus.
              if g.p > 0.0:
                  cost += g.total_cost()
              # Add a penalty if the output of the slack generator is infeasible.
              if not (g.p_min <= g.p <= g.p_max):
                  cost += ref_penalty
  #                logger.info("Infeasible slack generator output: %.3f" % g.p)
  
  #        logger.info("Cost: %.3f" % cost)
  
          return -cost
docs: Returns the reward corresponding to the last action performed.