evodef.SearchSpaceUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of NTBEA Show documentation
Show all versions of NTBEA Show documentation
Parameter optimisation with the N-Tuple Bandit Evolutionary Algorithm
package evodef;
import java.util.Arrays;
import java.util.Random;
/**
* Created by simonmarklucas on 24/10/2016.
*/
public class SearchSpaceUtil {
public static double size(SearchSpace space) {
double size = 1;
for (int i=0; i=0; i--) {
p[i] = ix % space.nValues(i);
ix /= space.nValues(i);
}
return p;
}
public static int indexOf(SearchSpace space, int[] p) {
int fac = 1;
int tot = 0;
for (int i=p.length-1; i>=0; i--) {
tot += p[i] * fac;
fac *= space.nValues(i);
}
return tot;
}
}