public IProblemFactory WithGaussianScaling() { var original = new ProblemSource(baseDataSet).GetProblem(); transform = GaussianTransform.Compute(original); return(this); }
/// <summary> /// Scales a problem using the provided range. This will not affect the parameter. /// </summary> /// <param name="prob">The problem to scale</param> /// <param name="range">The Range transform to use in scaling</param> /// <returns>The Scaled problem</returns> public static Problem Scale(this IRangeTransform range, Problem prob) { double[,] normalizedVector = new double[prob.Count, prob.MaxIndex]; //prob.count = num of rows, prob.maxindex = num of columns Problem scaledProblem = new Problem(prob.Count, new double[prob.Count], new Node[prob.Count][], prob.MaxIndex); FireFlyAlgorithm ff = new FireFlyAlgorithm(); //convert the original vector values from jagged array to a 2D array - take note that the vector values from the file is already scalled down for (int k = 0; k < prob.Count; k++) { for (int l = 0; l < prob.MaxIndex; l++) { normalizedVector[k, l] = (prob.X[k][l]).Value; } } for (int i = 0; i < scaledProblem.Count; i++) { scaledProblem.X[i] = new Node[prob.X[i].Length]; for (int j = 0; j < scaledProblem.X[i].Length; j++) { //scaledProblem.X[i][j] = new Node(prob.X[i][j].Index, range.Transform(normalizedVector, i, j)); scaledProblem.X[i][j] = new Node(prob.X[i][j].Index, range.Transform(prob.X[i][j].Value, prob.X[i][j].Index)); } scaledProblem.Y[i] = prob.Y[i]; } return(scaledProblem); }
/// <summary> /// Scales a problem using the provided range. This will not affect the parameter. /// </summary> /// <param name="prob">The problem to scale</param> /// <param name="range">The Range transform to use in scaling</param> /// <returns>The Scaled problem</returns> public static Problem Scale(this IRangeTransform range, Problem prob) { Problem scaledProblem = new Problem(prob.Count, new double[prob.Count], new Node[prob.Count][], prob.MaxIndex); for (int i = 0; i < scaledProblem.Count; i++) { scaledProblem.X[i] = new Node[prob.X[i].Length]; for (int j = 0; j < scaledProblem.X[i].Length; j++) { scaledProblem.X[i][j] = new Node(prob.X[i][j].Index, range.Transform(prob.X[i][j].Value, prob.X[i][j].Index)); } scaledProblem.Y[i] = prob.Y[i]; } return(scaledProblem); }