コード例 #1
0
    def get_gamma_G(self, K):
        robot_ids = Set([e.id for e in self.robots])
        task_ids = Set([e.id for e in self.tasks])
        V = Set.descartes_product(robot_ids, task_ids)
        V_K = Set([Set(e) for e in itertools.combinations(V, K)])

        print("...Calculating gamma_G...")
        gamma_G = float('inf')
        N = len(self.history) * len(V_K)
        progress_bar = ProgressBar(N)
        instrument = Instrument()
        instrument.start()
        k = 0
        for t in range(len(self.history)):
            S_t = Allocation(self.history[0:t])
            for Omega in V_K:
                progress_bar.progress(k)
                k = k + 1
                lhs = 0
                for omega in Omega.setminus(Set(S_t)):
                    lhs = lhs + S_t.get_derivative(Set([omega]))
                rhs = S_t.get_derivative(Omega)
                frac = rhs / lhs
                if frac < gamma_G and rhs != 0 and lhs != 0:
                    gamma_G = frac
        progress_bar.progress(N, 'Finished!\n')
        calculation_time = instrument.stop()
        print("Calculation time [s]:", calculation_time)
        print("Finished calculating gamma_G!\n")
        return gamma_G
コード例 #2
0
    def get_alpha_G(self, K):
        robot_ids = Set([e.id for e in self.robots])
        task_ids = Set([e.id for e in self.tasks])
        V = Set.descartes_product(robot_ids, task_ids)
        V_K = Set([Set(e) for e in itertools.combinations(V, K)])
        S_K = self.history
        S_K_1 = Set(self.history[:-1])

        print("...Calculating alpha_G...")
        alpha_G = -float('inf')
        N = len(V_K)
        progress_bar = ProgressBar(N)
        instrument = Instrument()
        instrument.start()
        k = 0
        for Omega in V_K:
            progress_bar.progress(k)
            k = k + 1
            for j_i in S_K_1.setminus(Omega):
                i = S_K.index(j_i)
                S_i_1 = Allocation(self.history[0:i])
                lhs = Allocation(S_i_1.union(Omega)).get_derivative(Set([j_i]))
                rhs = S_i_1.get_derivative(Set([j_i]))
                frac = (lhs - rhs) / lhs
                if frac > alpha_G and rhs != 0 and lhs != 0:
                    alpha_G = frac
        progress_bar.progress(N, 'Finished!\n')
        calculation_time = instrument.stop()
        print("Calculation time [s]:", calculation_time)
        print("Finished calculating alpha_G!\n")
        return alpha_G
コード例 #3
0
ファイル: QX_set.py プロジェクト: TihanyiD/multi_alloc
 def __init__(self, path_planner):
     self.Q = path_planner.Q
     self.X = path_planner.X
     QX = Set.descartes_product(self.Q, self.X)
     super(QX_set, self).__init__(QX)