public override List <S> Crossover(P pop, params S[] parents) { List <S> results = new List <S>(); int dimension_count = pop.Problem.GetDimensionCount(); IMOOProblem problem = pop.Problem; double crossover_rate = pop.CrossoverRate; int ccount = parents.Length; S child1, parent1, parent2, parent3; for (int i = 0; i < ccount; i += 4) { int child1_index = i; int parent1_index = (i + 1) % ccount; int parent2_index = (i + 2) % ccount; int parent3_index = (i + 3) % ccount; child1 = parents[child1_index].Clone() as S; parent1 = parents[parent1_index]; parent2 = parents[parent2_index]; parent3 = parents[parent3_index]; int jrand = DistributionModel.NextInt(dimension_count); for (int j = 0; j < dimension_count; j++) { if ((DistributionModel.GetUniform() <= crossover_rate) || (j == jrand)) { double v1 = parent1[j]; double v2 = parent2[j]; double v3 = parent3[j]; double y = v3 + mF * (v1 - v2); if (y < problem.GetLowerBound(j)) { y = problem.GetLowerBound(j); } if (y > problem.GetUpperBound(j)) { y = problem.GetUpperBound(j); } child1[j] = y; } } results.Add(child1); } return(results); }
public override void Initialize() { if (mIsInitialized) { return; } mIsInitialized = true; int dimension_count = mProblem.GetDimensionCount(); for (int objective_index = 0; objective_index != dimension_count; objective_index++) { mEliteDesignVariables[objective_index] = mProblem.GetLowerBound(objective_index) + DistributionModel.GetUniform() * (mProblem.GetUpperBound(objective_index) - mProblem.GetLowerBound(objective_index)); } int objective_count = mProblem.GetObjectiveCount(); int design_variable_count_per_objective = dimension_count / objective_count; //Initialize the NashNodes for (int objective_index = 0; objective_index < objective_count; objective_index++) { Dictionary <int, double> ellite_design_variables = new Dictionary <int, double>(); Dictionary <int, int> design_variable_local_mapping = new Dictionary <int, int>(); int starting_design_variable_index = objective_index * design_variable_count_per_objective; int ending_design_variable_index = (objective_index + 1) * design_variable_count_per_objective; for (int j = 0; j < dimension_count; ++j) { if (j >= starting_design_variable_index && j < ending_design_variable_index) { design_variable_local_mapping[j] = j - starting_design_variable_index; } else { ellite_design_variables[j] = mEliteDesignVariables[j]; } } NashNode <S> nash_node = new NashNode <S>(mProblem, mConfig, ellite_design_variables, design_variable_local_mapping, objective_index); mNashNodes.Add(nash_node); mNashNodes[objective_index].Initialize(); } //Initialize the ParetoNode and Fixed Array mParetoNode = new ParetoNode <S>(mProblem); mParetoNode.Population.Config.Copy(mConfig); mParetoNode.Initialize(); }
public double GetUpperBound(int dimension_index) { return(mOriginalProblem.GetUpperBound(mDesignVariableLocal2GlobalMapping[dimension_index])); }