package ec.gp.semantic.breed.nguyen;

import ec.EvolutionState;
import ec.gp.breed.GPBreedDefaults;
import ec.gp.semantic.ISemantics;
import ec.util.Parameter;
import ec.util.ParameterDatabase;

public class SAM extends SSM {
	private static final Parameter DEFAULT_BASE = GPBreedDefaults.base().push("SAM");

	private static final String SENSITIVITY = "sensitivity";

	private double sensitivity = 12;

	@Override
	public Parameter defaultBase() {
		return DEFAULT_BASE;
	}

	@Override
	public void setup(final EvolutionState state, final Parameter base) {
		super.setup(state, base);

		ParameterDatabase db = state.parameters;
		Parameter defaultBase = this.defaultBase();

		this.sensitivity = db.getDouble(base.push(SENSITIVITY), defaultBase.push(SENSITIVITY));
	}

	@Override
	protected boolean isInSensitivityRange(final ISemantics semantics1, final ISemantics semantics2) {
		double diff = semantics1.distanceTo(semantics2);

		return diff > this.sensitivity;
	}

}
