Example #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
Example #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
Example #3
0
 def get_all_function_values(self, target_allocation):
     targets = []
     for a in target_allocation:
         targets = targets + [a.target]
     goal = self.robots[0].goal
     x_0 = [r.x_0 for r in self.robots]
     instrument = Instrument()
     instrument.start()
     V_ret, Mu, V = self.path_planner.get_solution(targets, goal, x_0)
     t_eval = instrument.stop()
     return V_ret, Mu, V, t_eval
    # Load the personalities.  User can specify several cams to be loaded
    # on the command line.  Also, cams can be given aliases.
    for (alias, cam) in camlist:
        simcam.loadPersonality(cam, alias=alias)

    # Load the paradirs
    if len(paradirs) > 0:
        simcam.loadParaDirs(paradirs)
        
    try:
        try:
            logger.debug("Starting threadPool ...")
            threadPool.startall(wait=True)
            
            logger.info("Starting instrument %s ..." % maincam)
            simcam.start()
            
            # Subscribe our mini-monitor to the main monitor, if one was specified
            if options.monitor:
                import remoteObjects as ro
                ro.init()

                minimon = daqtk.get_monitor()
                minimon.subscribe(options.monitor, daqtk.monchannels, None)

            # Run off and do my GUI here...
            simcam.ui(main_alias, options, args, ev_quit)

        except KeyboardInterrupt:
            logger.error("Keyboard interrupt!")
Example #5
0
class Function_Frame(DMatrix):
    def __init__(self, parameters, path_planner):
        super().__init__()
        self.robots = parameters.robots
        self.tasks = parameters.tasks
        self.path_planner = path_planner
        self.calculating_function_frame()

    def calculating_function_frame(self):
        print("Calculating function frame...")
        self.instrument = Instrument()
        self.instrument.start()

        task_subsets = []
        for i in range(len(self.tasks) + 1):
            task_subsets = task_subsets + [
                Set(list(e)) for e in itertools.combinations(self.tasks, i)
            ]
        task_subsets = Set(task_subsets)

        domain_robots = [e.id for e in self.robots]
        domain_tasks = [set([ee.id for ee in e]) for e in task_subsets]
        self.domain_dict = ["value", "time"]
        self.domain_matrix = [domain_robots, domain_tasks]
        self["value"] = Matrix(
            self.domain_matrix,
            np.zeros((len(domain_robots), len(domain_tasks))))
        self["time"] = Matrix(
            self.domain_matrix,
            np.zeros((len(domain_robots), len(domain_tasks))))

        N = len(task_subsets)
        progress_bar = ProgressBar(N)
        for i_allocation, target_allocation in enumerate(task_subsets):
            progress_bar.progress(i_allocation)
            V_ret, Mu, V, t_eval = self.get_all_function_values(
                target_allocation)
            #save Mu and V ???
            self["value"].matrix[:, i_allocation] = V_ret
            self["time"].matrix[:, i_allocation] = t_eval * np.ones(len(V_ret))
        progress_bar.progress(N, 'Finished!\n')
        calculation_time = self.instrument.stop()
        self.instrument.save_measurement("calculation_time", calculation_time)
        print("Calculation time [s]:")
        print(self.instrument.data)
        print("Finished calculating function frame!\n")

    def get_all_function_values(self, target_allocation):
        targets = []
        for a in target_allocation:
            targets = targets + [a.target]
        goal = self.robots[0].goal
        x_0 = [r.x_0 for r in self.robots]
        instrument = Instrument()
        instrument.start()
        V_ret, Mu, V = self.path_planner.get_solution(targets, goal, x_0)
        t_eval = instrument.stop()
        return V_ret, Mu, V, t_eval

    def get_value(self, r_id, S_r_id):
        return self["value"].get([r_id,
                                  S_r_id]), self["time"].get([r_id, S_r_id])