Beispiel #1
0
        public Hibrido(Data data, Evolutivo evolutivo, TrepaColinas trepaColinas, int id = 0) : base(data)
        {
            _evolutivo    = evolutivo;
            _trepaColinas = trepaColinas;

            this.id = id;
        }
Beispiel #2
0
        public int addBestTrepaColinas(TrepaColinas tr, int x = 0)
        {
            var hip = tr.getBest();

            if (x == 0)
            {
                ++lastLine;
            }
            Write(x++, lastLine, hip.getSource());
            Write(x++, lastLine, hip.interacao.ToString());

            for (var i = 0; i < hip.NCMoedas.Count; ++i, ++x)
            {
                Write(x, lastLine, $"{hip.NCMoedas[i]}");
            }
            Write(x++, lastLine, hip.sum.ToString());
            Write(x++, lastLine, hip.eval.ToString());
            Write(x++, lastLine, tr.getData().MaxIteracoes.ToString());
            return(x);
        }
Beispiel #3
0
        private TrepaColinas getNewIntace()
        {
            TrepaColinas instace;

            switch (v)
            {
            case 1:
                instace = new TrepaColinasV2(data.Clone());
                break;

            case 2:
                instace = new TrepaColinasV3(data.Clone());
                break;

            default:
                instace = new TrepaColinas(data.Clone());
                break;
            }
            instace.log = false;
            return(instace);
        }
Beispiel #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);
        }
Beispiel #5
0
 public Hibrido(Data data, int id = 0) : base(data)
 {
     _evolutivo    = new EvolutivoV2(data);
     _trepaColinas = new TrepaColinasV3(data, solEHibrido);
     this.id       = id;
 }