diff --git a/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/MainLan b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/MainLan new file mode 100755 index 0000000000000000000000000000000000000000..bc5e86310934e7ed0adeeb03456725e6acd06bf7 Binary files /dev/null and b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/MainLan differ diff --git a/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/MainSeq b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/MainSeq new file mode 100755 index 0000000000000000000000000000000000000000..27509881455ad758848df6c0739ecf3640f9295f Binary files /dev/null and b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/MainSeq differ diff --git a/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/MainSeq.o b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/MainSeq.o new file mode 100644 index 0000000000000000000000000000000000000000..435df98be624edd02d886117232c15e4b09d2e4e Binary files /dev/null and b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/MainSeq.o differ diff --git a/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/ejercicio2.py b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/ejercicio2.py old mode 100644 new mode 100755 index 6705a027263a0079907ffb4f8b9905db20c4001a..cef6759d08dcb25addcb7419f6aaa27c659b5798 --- a/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/ejercicio2.py +++ b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/ejercicio2.py @@ -9,7 +9,7 @@ import os try: #Sanity check if (len(sys.argv)<4): - print "Ejecutar con la siguiente linea: ./ejercicio2 <ruta_tareas> <ruta_empleados> <ruta_solucion>" + print ("Ejecutar con la siguiente linea: ./ejercicio2 <ruta_tareas> <ruta_empleados> <ruta_solucion>") sys.exit(1) ruta_tareas=sys.argv[1] @@ -128,4 +128,4 @@ try: """ except IOError as error: - print error + print (error) diff --git a/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/newGA.req.cc b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/newGA.req.cc index 2c41bdf4986a94282370a8978294ae49d93f6174..86dcac12356d0e09846a9433e3e827020f096d9e 100644 --- a/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/newGA.req.cc +++ b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/newGA.req.cc @@ -44,7 +44,18 @@ skeleton newGA split(s, delim, std::back_inserter(elems)); return elems; } + + */ + + std::string trim(std::string const& str) + { + std::string word; + std::stringstream stream(str); + stream >> word; + return word; + } + istream& operator>> (istream& is, Problem& pbm) { @@ -78,8 +89,9 @@ skeleton newGA string line2; getline(inFile,line2); + line2 = trim(line2); pbm._cantColumnas = stoi(line2); - + cout << pbm._cantColumnas; for(int c = 0; c < pbm.cantColumnas(); c++) { getline(inFile, line2); @@ -91,11 +103,20 @@ skeleton newGA int t=0; int z=0; for(int i=0; i<=line2.length(); i++) - { + { + //cout << line2.length() << "LENGTH LINEA 2" << endl; if(line2[i] == ' '|| i==line2.length()) - { + { string rr = line2.substr(z,len); - divided.push_back(stoi(rr)); + if (rr != "") + { + //cout << rr << "ANTES DE TRIM" << endl; + rr = trim(rr); + cout << "columna" << c << rr << endl; + //cout << rr << "LUEGO DE TRIM" << endl; + divided.push_back(stoi(rr)); + } + //cout << rr << " "; t=t+1; z=i+1; @@ -103,6 +124,7 @@ skeleton newGA //s.erase(i,1); } else len=len+1; + } pbm._datosColumnas.push_back(divided); pbm._cantGruposColumna.push_back(divided.size()); @@ -121,8 +143,9 @@ skeleton newGA //string line2; getline(inFile2,line2); + line2 = trim(line2); pbm._cantFilas = stoi(line2); - + cout << "CANT FILAS" << pbm._cantFilas << endl; for(int c = 0; c < pbm.cantFilas(); c++) { getline(inFile2, line2); @@ -138,7 +161,15 @@ skeleton newGA if(line2[i] == ' '|| i==line2.length()) { string rr = line2.substr(z,len); - divided.push_back(stoi(rr)); + if (rr != "") + { + //cout << rr << "ANTES DE TRIM" << endl; + rr = trim(rr); + cout << "linea" << c << rr << endl; + //cout << rr << "LUEGO DE TRIM" << endl; + divided.push_back(stoi(rr)); + } + //cout << rr << " "; t=t+1; z=i+1; @@ -151,6 +182,7 @@ skeleton newGA pbm._cantGruposFila.push_back(divided.size()); } + exit; inFile2.close(); /* string x; @@ -398,6 +430,12 @@ skeleton newGA return !(*this == pbm); } + Direction Problem::direction() const + { + //return maximize; + return minimize; + } + int Problem::cantColumnas() const { return _cantColumnas; @@ -539,13 +577,19 @@ skeleton newGA void Solution::initialize() { + //cout << "ESTOY ENTRANDO A INITIALIZE" << endl; + _var = Rarray<Rarray<int>>(_pbm.cantColumnas()); for (int x = 0; x < _pbm.cantColumnas(); x++) { + //cout<<"x=" << x << endl; + _var[x] = Rarray<int>(_pbm.cantFilas()); for (int y = 0; y < _pbm.cantFilas(); y++) { + //cout<<"y=" << y << endl; _var[x][y] = 0; } } + //cout << "MID1" << endl; for (int i=0;i<_pbm.cantColumnas();i++) { int _firstPossible = 0; @@ -570,10 +614,12 @@ skeleton newGA _firstPossible = _endPosition + 1; } } + // cout << "ESTOY SALIENDO A INITIALIZE" << endl; } double Solution::fitness () { + //cout << "ESTOY ENTRANDO A FITNESS" << endl; double fitness = 0.0; std::vector<std::vector<int>> datosDeFilas = _pbm.datosFilas(); std::vector<int> cantGruposDeFila = _pbm.cantGruposFila(); @@ -618,6 +664,7 @@ skeleton newGA { currentBestFitness = fitness; } + //cout << "ESTOY SALIENDO DE FITNESS" << endl; return fitness; } @@ -661,7 +708,11 @@ skeleton newGA } Solution::~Solution() - {} + { /* + cout << "ESTOY EN DESTRUCTOR" << endl; + _var.~Rarray<Rarray<int>>(); + cout << "SALGO DEL DESTRUCTOR" << endl; */ + } // UserStatistics ------------------------------------------------------- @@ -767,9 +818,10 @@ skeleton newGA } void Crossover::cross(Solution& sol1,Solution& sol2) const // dadas dos soluciones de la poblacion, las cruza - { + { //cout << "ESTOY ENTRANDO A CROSSOVER" << endl; //Usamos cruzamiento de dos puntos (2PX) - int i=0; + + int i=0; Rarray<Rarray<int>> aux(sol1.pbm().cantColumnas()); aux=sol2.array_var(); int limit=rand_int((sol1.pbm().cantColumnas()/2)+1,sol1.pbm().cantColumnas()-1); @@ -783,6 +835,8 @@ skeleton newGA sol2.var(i)=sol1.var(i); for (i=limit;i<sol1.pbm().cantColumnas();i++) sol1.var(i)=aux[i]; + + //cout << "ESTOY SALIENDO DE CROSSOVER" << endl; } void Crossover::execute(Rarray<Solution*>& sols) const @@ -830,7 +884,7 @@ skeleton newGA } void Mutation::mutate(Solution& sol) const - { + { //cout << "ESTOY ENTRANDO A MUTATION" << endl; std::vector<std::vector<int>> _grupos = sol.pbm().datosColumnas(); for (int i=0;i<sol.pbm().cantColumnas();i++) { @@ -872,6 +926,8 @@ skeleton newGA } } } + + //cout << "ESTOY SALIENDO DE MUTATION" << endl; } void Mutation::execute(Rarray<Solution*>& sols) const diff --git a/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/newGA.req.o b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/newGA.req.o index 20940d938f1dec2308aa4970a4f3cf4f1c359e1a..4eacedabe8c04f47f5e906c7bdb40b72bc5fc5c1 100644 Binary files a/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/newGA.req.o and b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/newGA.req.o differ diff --git a/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/res/sol.txt b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/res/sol.txt index 94d8af392a9a33d04b7d961d7eabcdded57dc43a..c5fa78c4585fab685bb547318ff89a35a8612c2c 100644 --- a/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/res/sol.txt +++ b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/res/sol.txt @@ -3,14 +3,14 @@ STATISTICS OF TRIALS ------------------------------------------------------------------ -1 10029.7 210883 1060 10 1591 14184 -2 10010.4 210882 5560 55 6233 12361 -3 10010.4 210656 4160 41 8672 14731 -4 10009.9 210921 160 1 106 9399 -5 10010.4 210807 4660 46 4349 9349 -6 10010.4 210921 760 7 657 9224 -7 10016.5 210990 3060 30 5449 11825 -8 10015.4 210452 4960 49 5341 10215 -9 10035.1 210876 5960 59 5591 9491 -10 10017.7 210873 360 3 295 9422 +1 0 0 60 0 0 0 +2 0 0 60 0 0 0 +3 0 0 60 0 0 0 +4 0 0 60 0 0 0 +5 0 0 60 0 0 0 +6 0 0 60 0 0 0 +7 0 0 60 0 0 0 +8 0 0 60 0 0 0 +9 0 0 60 0 0 0 +10 0 0 60 0 0 0 ------------------------------------------------------------------ diff --git a/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/solution b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/solution index 534d0b7a1dbc05e068cc2ef7d4af1f20ef8ed28c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/solution +++ b/ProyectoFinal/AlgoritmoGenetico/malva/rep/GA/solution @@ -1,3 +0,0 @@ -e1 t3 t1 -e3 t5 t6 t4 -e4 t8 t2 t7