package ec.gp.syntactic.simplification.numeric;

import ec.EvolutionState;
import ec.app.semanticGP.func.IConstant;
import ec.app.semanticGP.func.numeric.Sum;
import ec.gp.GPNode;
import ec.gp.syntactic.simplification.IRule;
import ec.util.Parameter;

class SumSumTwoConst implements IRule {

	private EvolutionState state;

	@Override
	public void setup(EvolutionState state, Parameter base) {
		this.state = state;
	}

	@Override
	public boolean match(GPNode subtree) {
		if (!(subtree instanceof Sum))
			return false;

		if (!(subtree.children[0] instanceof Sum))
			return false;

		if (!(subtree.children[1] instanceof IConstant))
			return false;

		return subtree.children[0].children[0] instanceof IConstant
				||
				subtree.children[0].children[1] instanceof IConstant;
	}

	@Override
	public GPNode replace(GPNode subtree) {
		assert match(subtree) : "Tree does not has structure (p1 + const) + const";

		throw new UnsupportedOperationException("Not implemented");
	}

}
