public override object Clone() { var c = (InternalCrossoverPipeline)(base.Clone()); // deep-cloned stuff c.NodeSelect0 = (IGPNodeSelector)(NodeSelect0.Clone()); c.NodeSelect1 = (IGPNodeSelector)(NodeSelect1.Clone()); return(c); }
public override object Clone() { SizeFairCrossoverPipeline c = (SizeFairCrossoverPipeline)(base.Clone()); // deep-cloned stuff c.NodeSelect1 = (IGPNodeSelector)NodeSelect1.Clone(); c.NodeSelect2 = (IGPNodeSelector)NodeSelect2.Clone(); c.Parents = Parents.ToList(); return(c); }
public void Setup(IEvolutionState state, Parameter paramBase) { base.Setup(state, paramBase); IParameter def = DefaultBase; IParameter p = paramBase.Push(P_NODESELECTOR).Push("0"); IParameter d = def.Push(P_NODESELECTOR).Push("0"); NodeSelect1 = (IGPNodeSelector)state.Parameters.GetInstanceForParameter(p, d, typeof(IGPNodeSelector)); NodeSelect1.Setup(state, p); p = paramBase.Push(P_NODESELECTOR).Push("1"); d = def.Push(P_NODESELECTOR).Push("1"); if (state.Parameters.ParameterExists(p, d) && state.Parameters.GetString(p, d).Equals(V_SAME)) { // can't just copy it this time; the selectors // use internal caches. So we have to clone it no matter what NodeSelect2 = (IGPNodeSelector)NodeSelect1.Clone(); } else { NodeSelect2 = (IGPNodeSelector)state.Parameters.GetInstanceForParameter(p, d, typeof(IGPNodeSelector)); NodeSelect2.Setup(state, p); } NumTries = state.Parameters.GetInt(paramBase.Push(P_NUM_TRIES), def.Push(P_NUM_TRIES), 1); if (NumTries == 0) { state.Output.Fatal("GPCrossover Pipeline has an invalid number of tries (it must be >= 1).", paramBase.Push(P_NUM_TRIES), def.Push(P_NUM_TRIES)); } MaxDepth = state.Parameters.GetInt(paramBase.Push(P_MAXDEPTH), def.Push(P_MAXDEPTH), 1); if (MaxDepth == 0) { state.Output.Fatal("GPCrossover Pipeline has an invalid maximum depth (it must be >= 1).", paramBase.Push(P_MAXDEPTH), def.Push(P_MAXDEPTH)); } Tree1 = TREE_UNFIXED; if (state.Parameters.ParameterExists(paramBase.Push(P_TREE).Push("" + 0), def.Push(P_TREE).Push("" + 0))) { Tree1 = state.Parameters.GetInt(paramBase.Push(P_TREE).Push("" + 0), def.Push(P_TREE).Push("" + 0), 0); if (Tree1 == -1) { state.Output.Fatal("Tree fixed value, if defined, must be >= 0"); } } Tree2 = TREE_UNFIXED; if (state.Parameters.ParameterExists(paramBase.Push(P_TREE).Push("" + 1), def.Push(P_TREE).Push("" + 1))) { Tree2 = state.Parameters.GetInt(paramBase.Push(P_TREE).Push("" + 1), def.Push(P_TREE).Push("" + 1), 0); if (Tree2 == -1) { state.Output.Fatal("Tree fixed value, if defined, must be >= 0"); } } TossSecondParent = state.Parameters.GetBoolean(paramBase.Push(P_TOSS), def.Push(P_TOSS), false); if (state.Parameters.ParameterExists(paramBase.Push(P_HOMOLOGOUS), null)) { //get the parameter Homologous = state.Parameters.GetBoolean(paramBase.Push(P_HOMOLOGOUS), null, false); } }