def _get_cost_matrix(self, hosts, filter_properties):
        num_hosts = len(hosts)
        num_instances = filter_properties.get('num_instances', 1)
        solver_cache = filter_properties['solver_cache']
        # initialize cost matrix
        cost_matrix = [[0 for j in xrange(num_instances + 1)]
                        for i in xrange(num_hosts)]
        solver_cache['cost_matrix'] = cost_matrix
        cost_objects = [cost() for cost in self.cost_classes]
        cost_objects.sort(key=lambda cost: cost.precedence)
        precedence_level = 0
        for cost_object in cost_objects:
            if cost_object.precedence > precedence_level:
                # update cost matrix in the solver cache
                solver_cache['cost_matrix'] = cost_matrix
                precedence_level = cost_object.precedence
            cost_multiplier = cost_object.cost_multiplier()
            this_cost_mat = cost_object.get_extended_cost_matrix(hosts,
                                                        filter_properties)
            if not this_cost_mat:
                continue
            cost_matrix = [[cost_matrix[i][j] +
                    this_cost_mat[i][j] * cost_multiplier
                    for j in xrange(num_instances + 1)]
                    for i in xrange(num_hosts)]
        # update cost matrix in the solver cache
        solver_cache['cost_matrix'] = cost_matrix

        return cost_matrix
dataset/ETHPy150Open openstack/nova-solver-scheduler/nova_solverscheduler/scheduler/solvers/pulp_solver.py/PulpSolver._get_cost_matrix/original