Beispiel #1
0
    def __init__(self, problem, delta=0.01):
        self._delta = delta
        self._problem = problem
        U, H = problem.user_num, problem.host_num

        # intermediate matrices and vectors
        self._x_mat = new_matrix(U, H, defval=0)
        self._lambda_mat = new_matrix(H, problem.resource_num, defval=0)
        self._remain_mat = copy.deepcopy(problem.resource_matrix)
        self._share_vec = new_vector(U, defval=0)
        self._user_vec = new_vector(U, defval=True)
        self._user_mat = new_matrix(U, H, defval=True)
Beispiel #2
0
    def evaluate_utilization(self, problem):
        util_mat = new_matrix(problem.host_num, problem.resource_num, defval=0.0)

        # calculate utilization matrix
        for user, user_vec in enumerate(self._share_matrix):
            for host, host_jobs in enumerate(user_vec):
                for res in range(problem.resource_num):
                    res_util = host_jobs * problem.demand_matrix[user][res]
                    util_mat[host][res] += res_util

        # calculate global resource amount
        glb_res_vec = new_vector(problem.resource_num, defval=0.0)
        for res_vec in problem.resource_matrix:
            for i in range(problem.resource_num):
                glb_res_vec[i] += res_vec[i]

        # calculate global utilization amount
        glb_util_vec = new_vector(problem.resource_num, defval=0.0)
        for util_vec in util_mat:
            for i in range(problem.resource_num):
                glb_util_vec[i] += util_vec[i]

        return [1.0 * glb_util_vec[i] / glb_res_vec[i] for i in range(problem.resource_num)]