Exemple #1
0
def main():
    # instance_prefix = 'R3D2T3F150Tmax600Iter'
    instance_prefix = 'R3D3T7F150Tmax600Iter'
    no_of_instances = 5
    for i in range(no_of_instances):
        instance_name = instance_prefix + str(i)
        instance = InstanceReader(instance_name)
        sol = Solution_Reader(instance_name)
        # pprint(sol.nodesInOrder)
        sol_info = SolutionInformationExtractor(instance, sol)
        sol_info.recharge_recharge_task_frequency()
        # print(sol_info.recharge_recharge_count)
        # print(sol_info.recharge_task_count)
        # curr_instance_filename = instance_prefix + 'Iter' + str(i) + '.json'
        # file_path = os.path.normpath(instance_folder_path + curr_instance_filename)

        distance_travelled = sol_info.distance_travelled_calculator()

        with open('analysis/data.csv', 'a') as csvFile:
            writer = csv.writer(csvFile)
            row = [
                instance_name, sol_info.recharge_task_count,
                sol_info.recharge_recharge_count
            ]
            for x in distance_travelled:
                row.append(x)
            writer.writerow(row)
        csvFile.close()
Exemple #2
0
    def __init__(self, instance_string):
        self.instance_string = instance_string
        self.instance = InstanceReader(instance_string)
        self.sol = Solution_Reader(instance_string)
        self.instance_plotter_obj = Instance_Plotter(instance_string)
        self.solution_plotter_obj = SolutionPlotter(instance_string)

        self.fig = plt.figure()
        self.ax = plt.axes(xlim=(0, 100), ylim=(0, 100))
        self.ax.grid(True, lw=0.5)
        plt.title(instance_string)
        self.line, = self.ax.plot([], [], 'k*', markersize=8)
        self.edge, = self.ax.plot([], [])
        self.edge_trace = {
            k: {
                'x': [],
                'y': [],
                'c': 'w'
            }
            for k in self.instance.K
        }
        self.expanded_trace = {k: {'x': [], 'y': []} for k in self.instance.K}
        self.node_list = {k: [] for k in self.instance.K}
        self.ann_list = []
        self.fuel_box = []
        self.plot_base()
Exemple #3
0
    def __init__(self,
                 formulations_list,
                 no_of_robots,
                 no_of_depots_list,
                 no_of_tasks_list,
                 delta_param_list,
                 Tmax_param_list,
                 iterations_list,
                 path_to_data_folder=os.getcwd()):

        self.formulations_list = formulations_list
        self.no_of_robots = no_of_robots
        self.no_of_depots_list = no_of_depots_list
        self.no_of_tasks_list = no_of_tasks_list
        self.delta_param_list = delta_param_list
        self.Tmax_param_list = Tmax_param_list
        self.iterations_list = iterations_list

        self.solution_runtimes = {}
        for f in self.formulations_list:
            self.solution_runtimes['F' + str(f)] = {}
            for r in self.no_of_robots:
                self.solution_runtimes['F' + str(f)]['R' + str(r)] = {}
                for d in self.no_of_depots_list:
                    self.solution_runtimes['F' + str(f)]['R' +
                                                         str(r)]['D' +
                                                                 str(d)] = {}
                    for t in self.no_of_tasks_list:
                        self.solution_runtimes['F' + str(f)]['R' + str(r)][
                            'D' + str(d)]['T' + str(t)] = {}
                        for delta in self.delta_param_list:
                            self.solution_runtimes['F' + str(f)]['R' + str(r)][
                                'D' + str(d)]['T' + str(t)]['delta' +
                                                            str(delta)] = {}
                            for tmax in self.Tmax_param_list:
                                self.solution_runtimes['F' + str(f)][
                                    'R' + str(r)]['D' + str(d)]['T' + str(t)][
                                        'delta' + str(delta)]['Tmax' +
                                                              str(tmax)] = {}
                                for i in self.iterations_list:
                                    this_instance_string = 'F' + str(f) + \
                                        'R' + str(r) + 'D' + str(d) + \
                                        'T' + str(t) + 'delta' + str(delta) + \
                                        'Tmax' + str(tmax) + 'Iter' + str(i)
                                    this_sol = Solution_Reader(
                                        this_instance_string)
                                    self.solution_runtimes['F' + str(f)][
                                        'R' +
                                        str(r)]['D' + str(d)]['T' + str(t)][
                                            'delta' +
                                            str(delta)]['Tmax' + str(tmax)][
                                                'Iter' +
                                                str(i)] = this_sol.runtime
 def compare_single_problem(self, problem_string):
     # Compares all the formulations for a single problem
     # and writes the results in a file
     # The results should show only the problem instances that have
     # different objective values and, if so, what are those, and
     # what are the resulting arcs.
     obj_val_list = []
     row = [problem_string]
     for f in self.formulations_list:
         instance_string = 'F' + str(f) + problem_string
         sol = Solution_Reader(instance_string)
         obj_val_list.append(float('%.5f' % (sol.objective_val)))
     if obj_val_list[1:] != obj_val_list[:-1]:
         with open('CheckNeeded.csv', 'a') as the_file:
             the_file.write('{},{},{},{},{}\n'.format(
                 problem_string, obj_val_list[0], obj_val_list[1],
                 obj_val_list[2], obj_val_list[3]))
 def compare_single_problem(self, problem_string):
     # Compares all the formulations for a single problem
     # and writes the results in a file
     # The results should show only the problem instances that have
     # different objective values and, if so, what are those, and
     # what are the resulting arcs.
     runtimes_list = []
     row = [problem_string]
     for f in self.formulations_list:
         instance_string = 'F' + str(f) + problem_string
         sol = Solution_Reader(instance_string)
         runtimes_list.append(sol.runtime)
     with open('Runtimes.csv', 'a') as the_file:
         the_file.write('{},{},{},{},{}\n'.format(problem_string,
                                                  runtimes_list[0],
                                                  runtimes_list[1],
                                                  runtimes_list[2],
                                                  runtimes_list[3]))
Exemple #6
0
 def __init__(self, instance_string, path_to_data_folder=os.getcwd()):
     self.instance_string = instance_string
     self.instance = InstanceReader(instance_string[2:])
     self.sol = Solution_Reader(instance_string)
     self.instance_plotter_obj = Instance_Plotter(instance_string[2:])
     self.compute_path_lengths()