示例#1
0
        public void run()
        {
            CSVFile csvFile = new CSVFile();
            var     evo     = getNewIntace();

            csvFile.Write(0, 0, evo.descricao());
            csvFile.addCabecalhoE(data);
            Hipotese best = null;

            for (int i = 0; i < tests; i++)
            {
                evo = getNewIntace();
                evo.run();
                Hipotese hip = evo.getBest();
                if (best == null || best.eval > hip.eval) // guardar a melhor
                {
                    best = new Hipotese(hip, "Melhor", hip.interacao);
                    best.evaluate();
                }

                csvFile.addBestEvolutivo(evo);
            }

            best.evaluate();
            csvFile.addHipoteseE(best);
            csvFile.toFile(outputfile);
        }
示例#2
0
        public void run()
        {
            CSVFile csvFile = new CSVFile();
            var     evo     = getNewIntace();

            csvFile.Write(0, 0, evo.descricao());
            csvFile.addCabecalhoH(data);
            Hipotese bestE = null;
            Hipotese bestT = null;

            for (int i = 0; i < tests; i++)
            {
                evo = getNewIntace();
                evo.run();
                Hipotese hip = evo.getBest();
                if (bestT == null || bestT.eval > hip.eval) // guardar a melhor
                {
                    bestT = new Hipotese(evo.solTrepaColinas, "Melhor", i);
                    bestE = new Hipotese(evo.solEHibrido, "Melhor", i);
                    bestT.evaluate();
                    bestE.evaluate();
                }

                csvFile.addBestHibrido(evo);
            }

            bestE.evaluate(); bestT.evaluate();
            csvFile.addHipoteseH(bestE, bestT);
            csvFile.toFile(outputfile);
        }
示例#3
0
        public override void run()
        {
            if (log)
            {
                Console.WriteLine("TrepaColinas:");
            }

            Hipotese hip = bestSol;

            hip.evaluate();
            if (Program.debug)
            {
                imprimeHipotese(hip);
            }

            for (iteracao = 0; iteracao < data.MaxIteracoes; ++iteracao)
            {
                hip = gera_vizinho(hip);
                hip.evaluate();

                if (Program.debug)
                {
                    imprimeHipotese(hip);
                }

                if (bestSol.compareTo(hip) < 0)
                {
                    bestSol = hip;
                }
                if (hip.valido == 0)
                {
                    if (log)
                    {
                        Console.Out.WriteLine("Solução encontrada, Iteração: " + iteracao);
                    }
                    break;
                }
            }
        }
示例#4
0
        public void run()
        {
            CSVFile      csvFile = new CSVFile();
            TrepaColinas tr      = getNewIntace();

            csvFile.Write(0, 0, tr.descricao());
            csvFile.addCabecalhoTC(data);
            Hipotese best = null;

            for (int i = 0; i < tests; i++)
            {
                tr = getNewIntace();
                tr.run();
                Hipotese hip = tr.getBest();
                if ((best == null || best.eval > hip.eval) && hip.valido == 0) // guardar a melhor
                {
                    best = new Hipotese(hip, "Melhor", hip.interacao);
                    best.evaluate();
                }

                //Console.Out.WriteLine(hip.ToString2() + " : " + hip.ToString());
                //System.Threading.Thread.Sleep(100);

                csvFile.addBestTrepaColinas(tr);
            }
            if (best != null)
            {
                best.evaluate();
                csvFile.addHipoteseTC(best);
            }
            else
            {
                csvFile.Write(0, -1, "Nao foi encontrada nenhuma solucao");
            }
            csvFile.toFile(outputfile);
        }