Skip to content

Resource Management Algorithm Interface

Manuel Peuster edited this page Jul 28, 2014 · 2 revisions

The algorithm plugin is implemented as a Python class which inherits from "base.BaseAlgorithm". It should overwrite the compute(...) method which is called when something is changed in the system (e.g. UE position update). This method gets two lists as its arguments.

  • The first list contains all UEs which are currently registered in the system. Each UE is represented by a dict which has the same structure like the JSON responses of the public REST API (see: ). So, each UE dict contains the complete state information of a UE.

  • The second list contains all access points which are currently connected to the controller. Again, each AP in the list is represented by a dict with the same structure like the JSON responses of the public REST API (see: ).

This method returns a tuple of two dictionaries: (power_states_dict, assignment_dict)

  • power_states_dict: Contains the power state of all access points (on/off).
  • assignment_dict: Contains the assignment between the UEs and the APs. With UE uuid as key and the uuid of the assigned AP as the value.

The result is separated in these two dicts, so that a management algorithm can switch on (or keep switched on) access points even when there are no UEs assigned to them. When the result is returned, the controller will change the system state and trigger e.g. AP power on/off actions.

class SimpleNearestApAlgorithm(base.BaseAlgorithm):

    def __init__(self):
        """
        Some initialization work.
        """
        pass

    def compute(self, ue_list, ap_list, requesting_ue):
        """
        Computes the assignment of UE to APs and power state for the APs.

        Input:
            - list of UE dicts (structured like REST API JSON return)
            - list of AP dicts (structured like REST API JSON return)
            - uuid of UE which has triggered this algorithm run

        Result:
            Tuple(power_states_dict, assignment_dict)
            - power_states_dict: AP uuid -> power state (True/False)
                e.g. {"ap_uuid": True, "ap_uuid2": False}
            - assignment_dict: UE uuid -> AP uuid / None
                e.g. {"ue_uuid1": "ap_uuid2", "ue_uuid2": None}
        """
        # TODO: Implement real algorithm
        logging.info("Running SimpleNearestApAlgorithm...")

        power_states_dict = {}
        assignment_dict = {}

        # switch on all APs
        for ap in ap_list:
            power_states_dict[ap["uuid"]] = True

        # assign ap1 to all UE
        for ue in ue_list:
            if len(ap_list) > 0:
                assignment_dict[ue["uuid"]] = ap_list[0]["uuid"]

        return (power_states_dict, assignment_dict)
Clone this wiki locally