agregator.py
def _recompute_decision_operation_due_to_new_costs(self, time):
        """
        Re-compute the decision operation if a new costs vector has been sent

        :param time: Time of computation
        """

        self._cost_has_changed = False

        debug("+ Decision time {}".format(int(time / self.decision_time)))

        # Maximum time for the current or future optimization
        ForecastController.target_time = int(time + self.decision_time + 1 * self.delta_time)

        nb_slots_optimization = len(self._cost)

        # Conditions to minimize errors correction
        if self.count_error > 0:
            admissible_error = self.total_absolute_error / self.count_error

            #
            # Absolute error is too big
            #
            if admissible_error > ForecastController.MAX_TOTAL_ABSOLUTE_ERROR / self.delta_time:
                debug("| + absolute error override")
                self._current_correction, fountBetterCorrection = self.__check_correction()
                if fountBetterCorrection:
                    self._historic_for_correction = []

            #
            # Need a significant historic to recompute
            #
            if admissible_error > ForecastController.MAX_TOTAL_ABSOLUTE_ERROR \
                    / (self.delta_time * ForecastController.MAX_DAY_HISTORIC) \
                    and len(self._historic_for_correction) \
                    > (ForecastController.MAX_DAY_HISTORIC * nb_slots_optimization):

                debug("| + full historic")
                self._current_correction, fountBetterCorrection = self.__check_correction()
                self._historic_for_correction = []

            self.total_absolute_error = 0.0
            self.total_error = 0.0
            self.count_error = 0

        #
        # Optimize process
        #
        if int(time) not in self._power_on.keys():
            self._power_on[int(time)] = 0

        self._power_on, self.temperature_optimal = self.__optimize(
            cost=self._cost,
            first_decision=self._power_on[int(time)],
            correction=self._current_correction)

        debug("| + classic optimized")

        #
        # Statistics and historic
        #
        self.countOptimization += 1
        if len(self._history_temperature) > 0:
            self._history_temperature = self._history_temperature[-96:]
            self.average_temperature = units(numpy.mean(self._history_temperature), units.degC)
            debug("| | + Mean: {}".format(self.average_temperature))

        Re-compute the decision operation if a new costs vector has been sent

        :param time: Time of computation
        
Re-compute the decision operation if a new costs vector has been sent
Re - compute the decision operation if a new costs vector has been sent
def _recompute_decision_operation_due_to_new_costs(self, time):
        self._cost_has_changed = False
        debug("+ Decision time {}".format(int(time / self.decision_time)))
        ForecastController.target_time = int(time + self.decision_time + 1 * self.delta_time)
        nb_slots_optimization = len(self._cost)
        if self.count_error > 0:
            admissible_error = self.total_absolute_error / self.count_error
             Absolute error is too big
            if admissible_error > ForecastController.MAX_TOTAL_ABSOLUTE_ERROR / self.delta_time:
                debug("| + absolute error override")
                self._current_correction, fountBetterCorrection = self.__check_correction()
                if fountBetterCorrection:
                    self._historic_for_correction = []
             Need a significant historic to recompute
            if admissible_error > ForecastController.MAX_TOTAL_ABSOLUTE_ERROR \
                    / (self.delta_time * ForecastController.MAX_DAY_HISTORIC) \
                    and len(self._historic_for_correction) \
                    > (ForecastController.MAX_DAY_HISTORIC * nb_slots_optimization):
                debug("| + full historic")
                self._current_correction, fountBetterCorrection = self.__check_correction()
                self._historic_for_correction = []
            self.total_absolute_error = 0.0
            self.total_error = 0.0
            self.count_error = 0
         Optimize process
        if int(time) not in self._power_on.keys():
            self._power_on[int(time)] = 0
        self._power_on, self.temperature_optimal = self.__optimize(
            cost=self._cost,
            first_decision=self._power_on[int(time)],
            correction=self._current_correction)
        debug("| + classic optimized")
         Statistics and historic
        self.countOptimization += 1
        if len(self._history_temperature) > 0:
            self._history_temperature = self._history_temperature[-96:]
            self.average_temperature = units(numpy.mean(self._history_temperature), units.degC)
            debug("| | + Mean: {}".format(self.average_temperature))
def _recompute_decision_operation_due_to_new_costs ( self , time ) : self . _cost_has_changed = False debug ( "+ Decision time {}" . format ( int ( time / self . decision_time ) ) ) ForecastController . target_time = int ( time + self . decision_time + 1 * self . delta_time ) nb_slots_optimization = len ( self . _cost ) if self . count_error > 0 : admissible_error = self . total_absolute_error / self . count_error if admissible_error > ForecastController . MAX_TOTAL_ABSOLUTE_ERROR / self . delta_time : debug ( "| + absolute error override" ) self . _current_correction , fountBetterCorrection = self . __check_correction ( ) if fountBetterCorrection : self . _historic_for_correction = [ ] if admissible_error > ForecastController . MAX_TOTAL_ABSOLUTE_ERROR / ( self . delta_time * ForecastController . MAX_DAY_HISTORIC ) and len ( self . _historic_for_correction ) > ( ForecastController . MAX_DAY_HISTORIC * nb_slots_optimization ) : debug ( "| + full historic" ) self . _current_correction , fountBetterCorrection = self . __check_correction ( ) self . _historic_for_correction = [ ] self . total_absolute_error = 0.0 self . total_error = 0.0 self . count_error = 0 if int ( time ) not in self . _power_on . keys ( ) : self . _power_on [ int ( time ) ] = 0 self . _power_on , self . temperature_optimal = self . __optimize ( cost = self . _cost , first_decision = self . _power_on [ int ( time ) ] , correction = self . _current_correction ) debug ( "| + classic optimized" ) self . countOptimization += 1 if len ( self . _history_temperature ) > 0 : self . _history_temperature = self . _history_temperature [ - 96 : ] self . average_temperature = units ( numpy . mean ( self . _history_temperature ) , units . degC ) debug ( "| | + Mean: {}" . format ( self . average_temperature ) )
Re-compute the decision operation if a new costs vector has been sent
Re - compute the decision operation if a new costs vector has been sent
"""
        Re-compute the decision operation if a new costs vector has been sent

        :param time: Time of computation
        """ # Maximum time for the current or future optimization # Conditions to minimize errors correction # # Absolute error is too big # # # Need a significant historic to recompute # # # Optimize process # # # Statistics and historic #
self
time
Time of computation
Time of computation