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); }
public override void run() { if (log) { Console.WriteLine("Hibrido:"); Console.Out.WriteLine($"{id} -> Inicio Evolutivo"); } _evolutivo.run(); solEHibrido = _evolutivo.getBest(); _trepaColinas.setSolInit(solEHibrido); if (log) { Console.Out.WriteLine($"{id} -> Inicio Trepa-Colinas"); } _trepaColinas.run(); solTrepaColinas = _trepaColinas.getBest(); bestSol = solTrepaColinas; if (log) { Console.Out.WriteLine($"{id} -> Terminou"); } }
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); }