int find_loc(double[] eval)
{
// find the grid location of a solution given a vector of its objective values
int loc = 0;
int d;
int n = 1;
int i;
int[] inc = new int[10]; //MAX_OBJ
double[] width = new double[10];
// if the solution is out of range on any objective, return 1 more than the maximum possible grid location number
for (i = 0; i < objectives; i++)
{
if ((eval[i] < gl_offset[i]) || (eval[i] > gl_offset[i] + gl_range[i]))
// return ((int)Math.Pow(2, (objectives * depth)));
return ((int)Math.Pow((objectives * depth),4));
}
for (i = 0; i < objectives; i++)
{
inc[i] = n;
n *= 2;
width[i] = gl_range[i];
}
for (d = 1; d <= depth; d++)
{
for (i = 0; i < objectives; i++)
{
if (eval[i] < width[i] / 2 + gl_offset[i])
loc += inc[i];
else
gl_offset[i] += width[i] / 2;
}
for (i = 0; i < objectives; i++)
{
inc[i] *= (objectives * 2);
width[i] /= 2;
}
}
return (loc);
}