//defines an objective measure of whether one position is better than another position abstract class Environment { Tuple upper_bounds; Tuple lower_bounds; Environment(int max_dimension) { upper_bounds = new Tuple(max_dimension); lower_bounds = new Tuple(max_dimension); for(int i = 0; i < max_dimension; i++) { setBounds(0, 1, i); } } public void setBounds(float lower_bound, float upper_bound, int dimension) { upper_bounds.setValue(upper_bound, dimension); lower_bounds.setValue(lower_bound, dimension); } public float getLowerBound(int dimension) { return lower_bounds.getValue(dimension); } public float getUpperBound(int dimension) { return upper_bounds.getValue(dimension); } abstract public boolean isBetterPosition(Tuple pos1, Tuple pos2); public Tuple getRandomPosition() { Tuple t = new Tuple(upper_bounds.getMaxDimension()); float lower_bound, upper_bound; for(int i = 0; i < max_dimension; i++) { lower_bound = lower_bounds.getValue(i); upper_bound = upper_bounds.getValue(i); t.setValue(random(lower_bound, upper_bound), i); } return t; } }