public void AlgGen(int iter) { int i = 0; Poblacion Q = new Poblacion (); Poblacion H = new Poblacion (); m_pop.init (m_tp, 5, m_func); Stopwatch sw = Stopwatch.StartNew (); while(i < iter){ //Console.WriteLine ("Time: " + sw.Elapsed); Q = m_sel.doSel (m_pop); //Q.showPPL(); //Console.WriteLine ("Time: " + sw.Elapsed); H = m_crux.cruceP (Q); //Console.WriteLine ("Time: " + sw.Elapsed); m_pop = H; //Console.WriteLine ("Time: " + sw.Elapsed); m_pop.setFits (m_func); m_pop.setStats (); m_pop.showPPL (); //m_pop.showRun (); i++; } Console.WriteLine ("Time: " + sw.Elapsed); }
public void AlgGen(int iter) { int i = 0; Poblacion Q = new Poblacion (); Poblacion H = new Poblacion (); m_pop.init (m_tp, 5, m_func); Stopwatch sw = new Stopwatch(); while(i < iter){ //Console.WriteLine (TimeSpan.FromSeconds ((double) lol)); Q = m_sel.doSel (m_pop); //Console.WriteLine (TimeSpan.FromSeconds ((double) lol)); H = m_crux.cruceP (Q); //Console.WriteLine (TimeSpan.FromSeconds ((double) lol)); m_pop = H; //Console.WriteLine (TimeSpan.FromSeconds ((double) lol)); m_pop.setStats (); m_pop.showRun (); i++; } Console.WriteLine(sw.Elapsed); }
public HillEvo(int tp, AlgSelection sel, CruceYMutacion crux, MahFunc func) { m_sel = sel; m_crux = crux; m_func = func; m_tp = tp; m_pop = new Poblacion(tp); }
public Poblacion doSel(Poblacion pob) { Poblacion _pob = new Poblacion (pob.TamPob ()); List<Individuo> _ind; for (int i = 0; i < pob.TamPob (); i++) { _ind = new List<Individuo> (4); for (int j = 0; j < 4; j++) { _ind.Add (pob.getIndi ((int) (RNG.RandomNumber () * pob.TamPob ()))); //Console.WriteLine ((int) (RNG.RandomNumber() * pob.TamPob())); } _pob.addIndi (doTurney (_ind)); } //Console.WriteLine ("Torneo ------>>>> TAMAÑO DE LA POBLACION!!! --> " + _pob.TamPob() ); return _pob; }
public Poblacion cruceP(Poblacion p) { Poblacion H = new Poblacion(p.TamPob ()); List<Individuo> ind; for(int i = 0; i < p.TamPob (); i+=2) { ind = new List<Individuo>(2); if (RNG.RandomNumber () < pCruce) { ind = cruceI (p.getIndi (i), p.getIndi (i + 1)); } else { ind.Add (p.getIndi (i)); ind.Add (p.getIndi (i + 1)); } mutacion (ind); H.addIndis (ind); } return H; }
public Poblacion doSel(Poblacion pA, Poblacion pB) { List<Individuo> _ind; Poblacion _pob = new Poblacion (pA.TamPob ()); for (int i = 0; i < pA.TamPob (); i += 2) { _ind = new List<Individuo> (2); if (pA.getIndi (i).getFit () < pB.getIndi (i).getFit ()) { _ind.Add (pA.getIndi (i)); } else { _ind.Add (pB.getIndi (i)); } if (pA.getIndi (i+1).getFit () < pB.getIndi (i+1).getFit ()) { _ind.Add (pA.getIndi (i+1)); } else { _ind.Add (pB.getIndi (i+1)); } _pob.addIndis (_ind); } return _pob; }
public Poblacion cruceP(Poblacion p) { Poblacion H = new Poblacion(p.TamPob ()); //Console.WriteLine ("Cruce ------>>>> TAMAÑO DE LA POBLACION!!! --> " + p.TamPob() ); List<Individuo> ind; for(int i = 0; i < p.TamPob (); i+=2) { ind = new List<Individuo> (2); if (RNG.RandomNumber () < pCruce) { ind = cruceI (p.getIndi (i), p.getIndi (i + 1)); } else { ind.Add (p.getIndi (i)); ind.Add (p.getIndi (i + 1)); } //Console.WriteLine ("---->> " + ind.Count); mutacion (ind); H.addIndis (ind); //Console.WriteLine (i + " ---->>>>> " + p.TamPob() + " -----> " + H.TamPob()); //Console.WriteLine ("CruceFinal ------>>>> TAMAÑO DE LA POBLACION!!! --> " + H.TamPob() ); } return H; }
public void AlgGen(int iter) { int i = 0; Poblacion Q = new Poblacion (); Poblacion H = new Poblacion (); m_pop.init (m_tp, 5, m_func); int lol = DateTime.Now.TimeOfDay.Seconds; while(i < iter){ Console.WriteLine (TimeSpan.FromSeconds ((double) lol)); Q = m_sel.doSel (m_pop); Console.WriteLine (TimeSpan.FromSeconds ((double) lol)); H = m_crux.cruceP (Q); Console.WriteLine (TimeSpan.FromSeconds ((double) lol)); m_pop = H; Console.WriteLine (TimeSpan.FromSeconds ((double) lol)); m_pop.setStats (); m_pop.showRun (); i++; } }
public Poblacion doSel(Poblacion pA, Poblacion pB) { return new Poblacion (); }
public Poblacion doSel(Poblacion pob) { return new Poblacion (); }