Esempio n. 1
0
 def test_invalid_file_extension(self):
     try:
         reader = CSVDatasetReader()
         _ = reader.read('./random/dataset.txt')
         self.fail('Invalid file extension should not be accepted')
     except ValueError:
         pass
Esempio n. 2
0
 def test_empty_path(self):
     try:
         reader = CSVDatasetReader()
         _ = reader.read('')
         self.fail('Empty path should not be accepted')
     except ValueError:
         pass
Esempio n. 3
0
 def test_empty_content(self):
     try:
         reader = CSVDatasetReader()
         _ = reader.read('../../resource/emptyFile.csv')
         self.fail('Invalid dataset should not be accepted')
     except InvalidFileContentError:
         pass
Esempio n. 4
0
 def test_invalid_path(self):
     try:
         reader = CSVDatasetReader()
         _ = reader.read('./random/dataset.csv')
         self.fail('Invalid path should not be accepted')
     except ValueError:
         pass
Esempio n. 5
0
    def test_file_content(self):
        try:
            writer = CSVDatasetWriter()
            reader = CSVDatasetReader()
            generator = BaseDatasetGenerator()
            dataset = generator.make('test123', 30, 5, 5)
            writer.write('../../resource/', 'test_file_content', dataset)
            new_dataset = reader.read('../../resource/test_file_content.csv')
            is_valid = True

            if dataset.title != new_dataset.title:
                is_valid = False

            if dataset.total_packages != new_dataset.total_packages:
                is_valid = False

            if dataset.total_stations != new_dataset.total_stations:
                is_valid = False

            if dataset.width != new_dataset.width or dataset.height != new_dataset.height:
                is_valid = False

            if len(dataset.packages) != len(new_dataset.packages):
                is_valid = False

            self.assertEqual(True, is_valid)

        except ValueError as e:
            self.fail(e)
        finally:
            delete_if_exists('../../resource/test_file_content.csv')
Esempio n. 6
0
    def test_valid_content(self):
        try:
            reader = CSVDatasetReader()
            dataset = reader.read('../../resource/testSet.csv')

            self.assertEqual('TestSet1', dataset.title)
            self.assertEqual(120, dataset.total_packages)
            self.assertEqual(6, dataset.total_stations)
            self.assertEqual(15, dataset.width)
            self.assertEqual(15, dataset.height)

        except Exception as e:
            self.fail(e)
Esempio n. 7
0
 def test_valid_file_extension(self):
     try:
         reader = CSVDatasetReader()
         _ = reader.read('../../resource/testSet.csv')
     except ValueError:
         self.fail('Valid file extension should be accepted')
Esempio n. 8
0
 def test_valid_path(self):
     try:
         reader = CSVDatasetReader()
         _ = reader.read('../../resource/testSet.csv')
     except ValueError:
         self.fail('Valid path should be accepted')
Esempio n. 9
0
        new_ds = generator.make(title='testSet3',
                                pack_c=225,
                                stat_n=5,
                                cargo_dim=10)
        csv_writer.write(dir_path='../datasets',
                         file_name='testSet3',
                         dataset=new_ds)
    except Exception as error:
        print(str(error))


if __name__ == '__main__':
    # generate_data_set()
    try:
        config_data = json.load(open(configFile, 'r'))
        dataset = CSVDatasetReader().read(config_data['dataset'])

        result_dir_path = os.path.join(
            config_data['saveToDir'],
            datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))
        os.mkdir(path=result_dir_path)

        simulation = Simulation(dataset=dataset,
                                n_fes=config_data['n_fes'],
                                np=config_data['np'],
                                save_to_dir=result_dir_path)

        for algorithm in config_data['algorithms']:
            simulation.add_algorithm(algorithm)

        save_opt_configs = [