def update_energy_levels(self, parameter): """ Update the battery & virtual energy level according to the involution expression \eqref{10}. :param parameter: the instance of class Parameter :return: no return """ for i in range(self.__user_num): self.__battery_energy_levels[i] = self.__battery_energy_levels[i] - ToolFunction.obtain_transmit_energys( self.edge_selections[i], parameter, self.__connectable_distances[i]) - \ parameter.get_local_exe_energy() + self.obtain_harvested_energy(parameter) self.__virtual_energy_levels[i] = self.__battery_energy_levels[ i] - parameter.get_perturbation_para()
def sub_problem_es(self, parameter): """ Calculate the optimization goal of sub-problem $\mathcal{P}_2^{es}$. :param parameter: the instance of class Parameter :return: the optimization goal of $\mathcal{P}_2^{es}$ """ distances = self.get_connectable_distances() optimization_goals = 0 for i in range(len(self.edge_selections)): edge_selection = self.edge_selections[i] distance = distances[i] optimization_goal = parameter.get_v() * self.obtain_overall_costs(parameter) - \ parameter.get_local_exe_energy() - ToolFunction.obtain_transmit_energys( edge_selection, parameter, distance) optimization_goals += optimization_goal return optimization_goals
def obtain_overall_costs(self, parameter): """ Calculate 'V * overall_costs + Lyapunov_drift', which is the sum of it of each mobile device. :param parameter: the instance of class Parameter :return: V * overall costs + \Delta(\Theta) """ overall_costs = 0 for i in range(len(self.edge_selections)): transmit_times = ToolFunction.obtain_transmit_times( self.edge_selections[i], parameter, self.__connectable_distances[i]) edge_exe_times = ToolFunction.obtain_edge_exe_times( self.edge_selections[i], parameter) edge_times = transmit_times + edge_exe_times division = sum(self.edge_selections[i]) is_dropped = False if division else True overall_cost = max(edge_times) + parameter.get_local_exe_time() + parameter.get_coordinate_cost() * \ sum(self.edge_selections[i]) + is_dropped * parameter.get_drop_penalty() neg_lyapunov_drift = (parameter.get_local_exe_energy() + ToolFunction.obtain_transmit_energys( self.edge_selections[i], parameter, self.get_connectable_distances()[i])) * \ self.get_virtual_energy_levels()[i] overall_costs += overall_cost - neg_lyapunov_drift return overall_costs