Exemplo n.º 1
0
 public UnitTest()
 {
     httpClient   = new HttpClient();
     RouteService = new CachedGoogleMatrixService(httpClient);
 }
Exemplo n.º 2
0
        public async static Task <IEnumerable <Result> > RunTest(string filename)
        {
            var ret          = new List <Result>();
            var http         = new HttpClient();
            var routeService = new CachedGoogleMatrixService(http);

            foreach (MutateEnum mut in Enum.GetValues(typeof(MutateEnum)))
            {
                foreach (CrossoverEnum cro in Enum.GetValues(typeof(CrossoverEnum)))
                {
                    var settings = new GASettings
                    {
                        // Altera a configuração do GA
                        Mutation  = mut,
                        Crossover = cro
                    };

                    for (int i = 0; i < 10; i++)
                    {
                        var file = Path.GetFileName(filename);
                        Console.WriteLine($"A:{file} I:{i} M:{mut} C:{cro}");
                        var config = await PRVJTFinder.GetConfigByFile(filename, routeService, settings);

                        // Carrega a configuração do roteiro
                        var finder = new PRVJTFinder(config, routeService);
                        // Executa a divisão de rotas

                        routeService.LoadCache();
                        var result = await finder.Run();

                        routeService.SaveCache();

                        if (result.Erro)
                        {
                            ret.Add(new Result(
                                        result.TipoErro,
                                        i,
                                        filename,
                                        result.ListEntregadores.Count(),
                                        mut,
                                        cro,
                                        result.BestGenome.Fitness
                                        ));
                            continue;
                        }

                        ret.Add(new Result(
                                    result.TipoErro,
                                    i,
                                    filename,
                                    result.ListEntregadores.Count(),
                                    mut,
                                    cro,
                                    result.BestGenome.Fitness
                                    ));
                    }
                }
            }
            http.Dispose();
            return(ret);
        }