<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _oneInteraction(self):
 """ Does one interaction between the task and the agent. """

        if self.doOptimization:
            raise Exception('When using a black-box learning algorithm, only full episodes can be done.')
        else:
            self.stepid += 1
            self.agent.integrateObservation(self.task.getObservation())
            self.task.performAction(self.agent.getAction())

            # Save the cumulative sum of set-points for each period.
            for i, g in enumerate(self.task.env.case.online_generators):
                self.Pg[i, self.stepid - 1] = self.Pg[i, self.stepid - 1] + g.p

            reward = self.task.getReward()
            self.agent.giveReward(reward)
            return reward