package ec.gp.semantic.geometry;

import ec.EvolutionState;
import ec.app.semanticGP.func.classification.If;
import ec.gp.GPNode;

/**
 * Geometry provider for classification problems.
 */
public class ClassifierGeometryProvider implements IGeometryProvider {
	@Override
	public GPNode combine(EvolutionState state, GPNode parent1, GPNode parent2, GPNode randomTree) {
		return this.combine(state, new GPNode[]{parent1, parent2}, new GPNode[]{randomTree});
	}

	@Override
	public GPNode combine(EvolutionState state, GPNode[] parents, GPNode[] randomTrees) {
		if (parents.length != 2 || randomTrees.length != 1) {
			throw new UnsupportedOperationException("not implemented");
		}

		If _if = new If();
		_if.children = new GPNode[]{randomTrees[0], parents[0], parents[1]};

		return _if;
	}

	@Override
	public GPNode differencingCombine(EvolutionState state, GPNode parent, GPNode random1, GPNode random2) {
		If _if = new If();
		_if.children = new GPNode[]{random1, random2, parent};

		return _if;
	}
}
