Skip to content
Snippets Groups Projects
Commit cbcac453 authored by Lucas Hernan Bruzzone Rodriguez's avatar Lucas Hernan Bruzzone Rodriguez
Browse files

Update newGA.req.cc

parent ec73b562
No related branches found
No related tags found
No related merge requests found
......@@ -20,12 +20,16 @@ skeleton newGA
istream& operator>> (istream& is, Problem& pbm)
{
FILE* stream = fopen("ejercicio1_cantidad_tareas", "r");
char buffer[MAX_BUFFER];
int i;
is.getline(buffer,MAX_BUFFER,'\n');
is.getline(buffer,MAX_BUFFER,'\n');
sscanf(buffer,"%d",&pbm._dimension);
cout << buffer[3] << buffer[4] << endl;
assert(false);
return is;
}
......@@ -42,19 +46,31 @@ skeleton newGA
Direction Problem::direction() const
{
return maximize;
//return minimize;
//return maximize;
return minimize;
}
int Problem::dimension() const
{
return _dimension;
}
int Problem::cantEmpleados() const
{
return _cantEmpleados;
}
Problem::~Problem()
{
}
Rarray<Empleado>& Problem::empleadoss()
{
return _empleados;
}
Rarray<int>& Problem::tareasDiass()
{
return _tareasDias;
}
// Solution --------------------------------------------------------------
Solution::Solution (const Problem& pbm):_pbm(pbm),_var(pbm.dimension())
......@@ -120,16 +136,18 @@ skeleton newGA
void Solution::initialize()
{
for (int i=0;i<_pbm.dimension();i++)
_var[i]=rand_int(0,1);
iSecret = rand() % 10 + 1;
_var[i]=rand() % EMPLEADOS + 1;//numero random entre 1 y CANT EMPLEADOS
}
double Solution::fitness ()
{
double fitness = 0.0;
for (int i=0;i<_var.size();i++)
fitness += _var[i];
for (int i=0;i<_var.size();i++) {
int tipo = _var[i];
fitness += tipo.getSueldo()*dias[i];
}
return fitness;
}
......@@ -340,8 +358,9 @@ skeleton newGA
{
if (rand01()<=probability[1])
{
if (sol.var(i)==1) sol.var(i)=0;
else sol.var(i)=1;
sol.var(i) = rand() % EMPLEADOS + 1;
//if (sol.var(i)==1) sol.var(i)=0;
//else sol.var(i)=1;
}
}
}
......@@ -409,4 +428,3 @@ skeleton newGA
}
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment