Training ff nn using backpropagation - c#

I have encountered some difficulties while training my nn. When I use, lets say, 10 training sets, at the end of training procces neural network is trained just for the last two. I'm entering same values that I have used to train network and I am getting wrong results save for the last two. It seems to me that new nn memory suppresses older memory. I'm using 64 input neurons, 42 neurons in hidden layer and one output neuron. Sigmoid function is used for activating neurons. Training inputs and expected outputs are in 0 to 1 range. Does anyone have any clue what might be causing the problem?
Neuron b = new Neuron();
Fft f = new Fft();
float e = 2.71828f;
float eta = 0.05f;
float alpha = 0.05f;
float[] saw = new float[42];
float[] dh = new float[42];
float error = 0;
float dto = 0;
Random broj = new Random();
TextReader br = new StreamReader("d:/trening.txt");
TextReader ir = new StreamReader("d:\\input.txt");
float NextFloat(Random rng, float min, float max)
{
return (float)(min + (rng.NextDouble() * (max - min)));
}
public void load()//load memory
{
int i, j;
byte[] floatBytes;
BinaryReader br = new BinaryReader(File.Open("d:/memorija.txt", FileMode.Open));
for (j = 0; j <= 41; j++)
{
for (i = 0; i <= 64; i++)
{
floatBytes = br.ReadBytes(4);
b.w12[i][j] = BitConverter.ToSingle(floatBytes, 0);
}
}
for (j = 0; j <= 1; j++)
{
for (i = 0; i <= 41; i++)
{
floatBytes = br.ReadBytes(4);
b.w23[i][j] = BitConverter.ToSingle(floatBytes, 0);
}
}
br.Close();
}
public void trening()//Get training inputs and expected outputs
{ //Calls process methode
int i, n,ct=0;
using (TextReader tr = new StreamReader("d:/trening.txt"))
{
do
{
ct++;
} while (tr.ReadLine() != null);
tr.Close();
}
for (n = 0; n < (ct-1)/65; n++)
{
for (i = 1; i <= 65; i++)
b.input[i] = Convert.ToSingle(br.ReadLine());
process(b.input[65]);
target.Text = ((b.input[65]).ToString());
}
}
public void process(double t)//Trains nn using backpropagation
{
error = 0;
do
{
int i, j, k;
BinaryWriter bw = new BinaryWriter(File.Open("d:\\memorija.txt", FileMode.Create));
i = k = j = 0;
for (j = 1; j <= 41; j++)
{
b.ulaz2[j] = b.w12[0][j];
for (i = 1; i <= 64; i++)
{
b.ulaz2[j] += b.input[i] * b.w12[i][j];
} b.izlaz2[j] = (float)(1.0 / (1.0 + Math.Pow(e, -b.ulaz2[j])));
if (b.izlaz2[j] < 0)
MessageBox.Show(b.izlaz2[j].ToString());
}
for (k = 1; k <= 1; k++)
{
b.ulaz3 = b.w23[0][k];
for (j = 1; j <= 41; j++)
{
b.ulaz3 += b.izlaz2[j] * b.w23[j][k];
} b.izlaz = (float)(1.0 / (1.0 + Math.Pow(e, -b.ulaz3)));
error += (float)(0.5 * (t - b.izlaz) * (t - b.izlaz));
dto = (float)(t - b.izlaz) * b.izlaz * (1 - b.izlaz);
}
for (j = 1; j <= 41; j++)
{
saw[j] = 0;
for (k = 1; k <= 1; k++)
{
saw[j] += dto * b.izlaz2[j];
} dh[j] = saw[j] * b.izlaz2[j] * (1 - b.izlaz2[j]);
}
for (j = 1; j <= 41; j++)
{
b.w12d[0][j] = eta * dh[j] + alpha * b.w12d[0][j];
b.w12[0][j] += b.w12d[0][j];
for (i = 1; i <= 64; i++)
{
b.w12d[i][j] = eta * b.input[i] * dh[j] + alpha * b.w12d[i][j];
b.w12[i][j] += b.w12d[i][j];
}
}
for (k = 1; k <= 1; k++)
{
b.w23d[0][k] = eta * dto + alpha * b.w23d[0][k];
b.w23[0][k] += b.w23d[0][k];
for (j = 1; j <= 41; j++)
{
b.w23d[j][k] = eta * b.izlaz2[j] * dto + alpha * b.w23d[j][k];
b.w23[j][k] += b.w23d[j][k];
}
}
for (j = 0; j <= 41; j++)
{
for (i = 0; i <= 64; i++)
bw.Write(b.w12[i][j]);
}
for (j = 0; j <= 1; j++)
{
for (i = 0; i <= 41; i++)
bw.Write(b.w23[i][j]);
}
bw.Close();
izlazb.Text = Convert.ToString(b.izlaz);
errorl.Text = Convert.ToString(Math.Abs(b.izlaz - b.input[64]));
} while (Math.Abs(b.izlaz - t) > 0.03);
}
public void test()//This methode gets input values and gives output based on previous training
{
int i = 0, j = 0, k = 0;
for (i = 1; i < 65; i++)
b.input[i] = (float)Convert.ToDouble(ir.ReadLine());
for (j = 1; j <= 41; j++)
{
b.ulaz2[j] = b.w12[0][j];
for (i = 1; i <= 64; i++)
{
b.ulaz2[j] += b.input[i] * b.w12[i][j];
} b.izlaz2[j] = (float)(1.0 / (1.0 + Math.Pow(e, -b.ulaz2[j])));
}
for (k = 1; k <= 1; k++)
{
b.ulaz3 = b.w23[0][k];
for (j = 1; j <= 41; j++)
{
b.ulaz3 += b.izlaz2[j] * b.w23[j][k];
} b.izlaz = (float)(1.0 / (1.0 + Math.Pow(e, -b.ulaz3)));
} izlazb.Text = Convert.ToString(b.izlaz);
target.Text = "/";
errorl.Text = "/";
}
public void reset()//Resets memory
{
BinaryWriter fw = new BinaryWriter(File.Open("d:\\memorija.txt", FileMode.Create));
int i = 0;
int j = 0;
Random broj = new Random();
for (j = 0; j <= 41; j++)
{
for (i = 0; i <= 64; i++)
{
b.w12[i][j] = 0;
b.w12[i][j] = 2 * (NextFloat(broj, -0.5f, 0.5f));
fw.Write(b.w12[i][j]);
}
}
for (j = 0; j <= 1; j++)
{
for (i = 0; i <= 41; i++)
{
b.w23[i][j] = 0;
b.w23[i][j] = 2 * (NextFloat(broj, -0.5f, 0.5f));
fw.Write(b.w23[i][j]);
}
}
fw.Close();
}
}
}
And neuron class
public class Neuron
{
public float[][] w12 = new float[65][];//(65, 42);
public float[][] w12d = new float[65][];//(65, 42);
public float[][] w23 = new float[42][];//(42,2);
public float[][] w23d = new float[42][];//(42, 2);
public float[] ulaz2 = new float[42];
public float[] izlaz2 = new float[42];
public float ulaz3;
public float[] input =new float[66];
public static float[] ioutput;
public float izlaz;
public void arrayInit()
{
int i, j;
for (i = 0; i <=64; i++)
{
w12[i] = new float[42];
w12d[i] = new float[42];
}
for (i = 0; i <42; i++)
{
w23[i] = new float[2];
w23d[i] = new float[2];
}
for (j = 0; j < 42; j++)
for (i = 0; i <=64; i++)
{
w12[i][j] = 0;
w12d[i][j] = 0;
}
for (j = 0; j < 2; j++)
for (i = 0; i < 42; i++)
{
w23[i][j] = 0;
w23d[i][j] = 0;
}
}
}

I found out what the problem was. I didn't mix training arrays, I was introducing one array to nn until it was trained for it, instead of introducing all arrays in cyclic manner. I hope this will be useful for someone.

Related

C# Neural Network Always Outputting the Same Thing

I am writing a neural network based on this guide (https://learn.microsoft.com/en-us/archive/msdn-magazine/2012/october/test-run-neural-network-back-propagation-for-programmers), and no matter what the inputs, desired outputs, or layer sizes are, it always outputs one:
using System;
namespace Neural_Network_Test
{
internal class Program
{
private int numInput;
private int numHidden;
private int numOutput;
private float[,] inputNodes;
private float[,] weightsIH;
private float[,] weightsHO;
private float[,] outputsIH;
private float[,] outputsHO;
private float[,] sumIH;
private float[,] sumHO;
private float[,] biasIH;
private float[,] biasHO;
private float[,] gradientsO;
private float[,] gradientsH;
private float[,] prevWeightsDeltaIH;
private float[,] prevBiasesDeltaIH;
private float[,] prevWeightsDeltaHO;
private float[,] prevBiasesDeltaHO;
private float[,] rawIH;
private float[,] desiredOutputs;
private float eta = 0.9f;
private float momentum = 0.4f;
private int iteration = 0;
private static void Main(string[] args)
{
Program program = new Program();
program.numInput = 3;
program.numHidden = 4;
program.numOutput = 2;
program.desiredOutputs = new float[program.numOutput, 1];
for (int i = 0; i < program.numOutput; i++)
{
Console.Write("Output " + (i + 1).ToString() + ": ");
program.desiredOutputs[i, 0] = Convert.ToInt32(Console.ReadLine());
}
Console.Write("Enter Iterations: ");
int numIterations = 0;
numIterations = Convert.ToInt32(Console.ReadLine());
program.SetMisc();
program.SetNodes();
program.SetWeights();
for (int i = 0; i < numIterations; i++)
{
program.ComputeOutputs();
program.BackPropagation();
program.AddDeltas();
Console.WriteLine("Outputs: ");
for (int j = 0; j < program.numOutput; j++)
{
Console.WriteLine("Output " + (j + 1).ToString() + ": " + program.outputsHO[j, 0].ToString());
}
float cost = 0f;
for (int w = 0; w < program.numOutput; w++)
{
cost += 0.5f * (float)Math.Pow(program.desiredOutputs[w, 0] - program.outputsHO[w, 0], 2);
}
Console.WriteLine("Cost: " + cost.ToString());
program.iteration++;
}
}
private void SetNodes()
{
Random rnd = new Random();
for (int i = 0; i < numInput; i++)
{
inputNodes[i, 0] = (float)rnd.NextDouble();
}
}
private void SetWeights()
{
Random rnd = new Random();
weightsIH = new float[numInput, numHidden];
for(int i = 0; i < numInput; i++)
{
for(int j = 0; j < numHidden; j++)
{
if (rnd.NextDouble() > 0.5)
{
weightsIH[i, j] = (float)rnd.NextDouble();
}
else
{
weightsIH[i, j] = (float)rnd.NextDouble() * -1;
}
weightsIH[i, j] = 1f;
}
}
weightsHO = new float[numHidden, numOutput];
for (int i = 0; i < numHidden; i++)
{
for (int j = 0; j < numOutput; j++)
{
if (rnd.NextDouble() > 0.5)
{
weightsHO[i, j] = (float)rnd.NextDouble();
}
else
{
weightsHO[i, j] = (float)rnd.NextDouble() * -1;
}
weightsHO[i, j] = 1f;
}
}
for(int i = 0; i < numHidden; i++)
{
biasIH[i, 0] = rnd.Next(20) - 10;
}
for (int i = 0; i < numOutput; i++)
{
biasHO[i, 0] = rnd.Next(20) - 10;
}
for(int i = 0; i < numHidden; i++)
{
biasIH[i, 0] = 0;
}
for(int i = 0; i < numOutput; i++)
{
biasHO[i, 0] = 0;
}
weightsIH = new float[numInput, numHidden];
weightsHO = new float[numHidden, numOutput];
float value = 0.1f;
for (int i = 0; i < numInput; i++)
{
for (int j = 0; j < numHidden; j++)
{
weightsIH[i, j] = (float)Math.Round(value, 2);
value += 0.1f;
}
}
for (int i = 0; i < numHidden; i++)
{
for (int j = 0; j < numOutput; j++)
{
weightsHO[i, j] = value;
value += 0.1f;
}
}
}
private void SetMisc()
{
sumIH = new float[numHidden, 1];
biasIH = new float[numHidden, 1];
sumHO = new float[numOutput, 1];
biasHO = new float[numOutput, 1];
gradientsO = new float[numOutput, 1];
gradientsH = new float[numHidden, 1];
prevWeightsDeltaIH = new float[numInput, numHidden];
prevWeightsDeltaHO = new float[numHidden, numOutput];
prevBiasesDeltaIH = new float[numHidden, 1];
prevBiasesDeltaHO = new float[numOutput, 1];
outputsIH = new float[numHidden, 1];
outputsHO = new float[numOutput, 1];
rawIH = new float[numHidden, 1];
inputNodes = new float[numHidden, 1];
}
private void ComputeOutputs()
{
//Hidden
for (int i = 0; i < numHidden; i++)
{
for (int j = 0; j < numInput; j++)
{
sumIH[i, 0] += inputNodes[j, 0] * weightsIH[j, i]; //
}
sumIH[i, 0] += biasIH[i, 0];
rawIH[i, 0] = sumIH[i, 0];
outputsIH[i, 0] = SigmoidFunction(sumIH[i, 0]);
}
//Output
for (int i = 0; i < numOutput; i++)
{
for (int j = 0; j < numHidden; j++)
{
sumHO[i, 0] += outputsIH[j, 0] * weightsHO[j, i];
}
sumHO[i, 0] += biasHO[i, 0];
outputsHO[i, 0] = HyperTanFunction(sumHO[i, 0]);
}
}
private void BackPropagation()
{
//Outputs
for (int i = 0; i < numOutput; i++)
{
gradientsO[i, 0] = (desiredOutputs[i, 0] - outputsHO[i, 0]) * (1 - outputsHO[i, 0]) * (1 + outputsHO[i, 0]);
}
//Hidden
for (int i = 0; i < numHidden; i++)
{
float outputComp = 0;
for (int j = 0; j < numOutput; j++)
{
outputComp += gradientsO[j, 0] * weightsHO[i, j];
}
gradientsH[i, 0] = (outputsIH[i, 0]) * (1 - outputsIH[i, 0]) * outputComp;
}
//Delta IH
for (int i = 0; i < numInput; i++)
{
for (int j = 0; j < numHidden; j++)
{
prevWeightsDeltaIH[i, j] = eta * gradientsH[j, 0] * inputNodes[i, 0];
}
}
//Delta HO
for (int i = 0; i < numHidden; i++)
{
for (int j = 0; j < numOutput; j++)
{
}
}
//Bias IH
for (int i = 0; i < numHidden; i++)
{
biasIH[i, 0] = eta * gradientsH[i, 0] * 1;
}
//Bias HO
for (int i = 0; i < numOutput; i++)
{
biasHO[i, 0] = eta * gradientsO[i, 0] * 1;
}
}
private void AddDeltas()
{
if (iteration > 0)
{
for (int i = 0; i < numInput; i++)
{
for (int j = 0; j < numHidden; j++)
{
weightsIH[i, j] += prevWeightsDeltaIH[i, j] + (prevWeightsDeltaIH[i, j] * momentum);
}
}
for (int i = 0; i < numHidden; i++)
{
for (int j = 0; j < numOutput; j++)
{
weightsHO[i, j] += prevWeightsDeltaHO[i, j] + (prevWeightsDeltaHO[i, j] * momentum);
}
}
for (int i = 0; i < numHidden; i++)
{
biasIH[i, 0] += prevBiasesDeltaIH[i, 0] + (prevBiasesDeltaIH[i, 0] * momentum);
}
for (int i = 0; i < numOutput; i++)
{
biasHO[i, 0] += prevBiasesDeltaHO[i, 0] + (prevBiasesDeltaHO[i, 0] * momentum);
}
}
else
{
for (int i = 0; i < numInput; i++)
{
for (int j = 0; j < numHidden; j++)
{
weightsIH[i, j] += prevWeightsDeltaIH[i, j];
}
}
for (int i = 0; i < numHidden; i++)
{
for (int j = 0; j < numOutput; j++)
{
weightsHO[i, j] += prevWeightsDeltaHO[i, j];
}
}
for (int i = 0; i < numHidden; i++)
{
biasIH[i, 0] += prevBiasesDeltaIH[i, 0];
}
for (int i = 0; i < numOutput; i++)
{
biasHO[i, 0] += prevBiasesDeltaHO[i, 0];
}
}
}
private static float SigmoidFunction(float x)
{
if (x < -45.0f) return 0.0f;
else if (x > 45.0) return 1.0f;
else return (float)(1.0f / (1.0f + Math.Exp(-x)));
}
private static float HyperTanFunction(float x)
{
if (x < -10.0) return -1.0f;
else if (x > 10.0) return 1.0f;
else return (float)(Math.Tanh(x));
}
}
}
I have tried changing the values of the input layer, the desired values, layer sizes, checked the backpropagation code, and many other things, but it always outputs one.

Trying to perform 2D Cross correlation on 2 images without using Matlab/Numpy/etc

I am trying to perform Cross Correlation on these 2 images in C#:
Image, Template
Matlab says the result is supposed to look like: Matlab result
But this is my result: My result
Here is my Cross Correlation function:
public static Signal2D CrossCorrelation2D(Signal2D signal, Signal2D pulse) {
return InverseFFT2D(FFT2D(signal) * FFT2D(pulse).GetConjugate());
}
Here is my FFT2D:
public static Signal2D FFT2D(Signal2D signal) {
Signal2D result = new Signal2D(signal.Height, signal.Width);
for (int i = 0; i < result.Height; i++)
result[i] = new ComplexNumber[signal[i].Length];
//rows
for (int n = 0; n < signal.Height; n++) {
result[n] = FFT(signal[n]);
}
//columns
for (int i = 0; i < signal[0].Length; i++) {
ComplexNumber[] col = new ComplexNumber[signal.Height];
for (int j = 0; j < col.Length; j++) {
col[j] = result[j][i];
}
col = FFT(col);
for (int j = 0; j < col.Length; j++) {
result[j][i] = col[j];
}
}
return result;
}
Here is my FFT:
public static Signal FFT(Signal signal) {
int N = signal.Length;
if (N == 1)
return signal;
if ((N & (N - 1)) != 0)
throw new ArgumentOutOfRangeException("signal length must be a power of 2");
Signal evenArr = new Signal(N / 2);
Signal oddArr = new Signal(N / 2);
for (int i = 0; i < N / 2; i++) {
evenArr[i] = signal[2 * i];
}
evenArr = FFT(evenArr);
for (int i = 0; i < N / 2; i++) {
oddArr[i] = signal[2 * i + 1];
}
oddArr = FFT(oddArr);
Signal result = new Signal(N);
for (int k = 0; k < N / 2; k++) {
double w = -2.0 * k * Math.PI / N;
ComplexNumber wk = new ComplexNumber(Math.Cos(w), Math.Sin(w));
ComplexNumber even = evenArr[k];
ComplexNumber odd = oddArr[k];
result[k] = even + (wk * odd);
result[k + N / 2] = even - (wk * odd);
}
return result;
}
Here is my Signal multiplication (using pointwise multiplication):
public static Signal2D operator* (Signal2D a, Signal2D b) {
if (a.Height != b.Height || a.Width != b.Width)
throw new ArgumentException("Sizes must be equal");
Signal2D result = new Signal2D(a.Height, a.Width);
for (int y = 0; y < a.Height; y++) {
for (int x = 0; x < a.Width; x++) {
result[y][x] = a[y][x] * b[y][x];
}
}
return result;
}
Any help is appreciated, thanks.
Edit: I left the matlab image at the original size of 1023 by 1023 and overlayed my result. It looks like I may already be at the result, I am just not sure how Matlab pads the image. Overlayed results (The red is the white part from my result, the grey is the black part from my result. Black/white is from Matlab)

complex valued neural network back propogation

i am working oncomplex valued neural networks, rvnn ok but when convert it to cvnn error is not decreases, and i cant figure out where is mistake, my code is here
public bool Train(List<Complex> input, List<Complex> output)
{
if ((input.Count != this.Layers[0].Neurons.Count) || (output.Count != this.Layers[this.Layers.Count - 1].Neurons.Count)) return false;
Run(input);
error = 0;
for(int i = 0; i < this.Layers[this.Layers.Count - 1].Neurons.Count; i++)
{
Neuron neuron = this.Layers[this.Layers.Count - 1].Neurons[i];
neuron.Delta = dSigmoid(neuron.Value) * (output[i] - neuron.Value);
error += (output[i] - neuron.Value).Magnitude;
for(int j = this.Layers.Count - 2; j > 2; j--)
{
for(int k = 0; k < this.Layers[j].Neurons.Count; k++)
{
Neuron n = this.Layers[j].Neurons[k];
n.Delta = dSigmoid(n.Value)*
this.Layers[j + 1].Neurons[i].Dendrites[k].Weight *
this.Layers[j + 1].Neurons[i].Delta;
}
}
}
for(int i = this.Layers.Count - 1; i > 1; i--)
{
for(int j=0; j < this.Layers[i].Neurons.Count; j++)
{
Neuron n = this.Layers[i].Neurons[j];
n.Bias = n.Bias + (this.LearningRate * n.Delta);
for (int k = 0; k < n.Dendrites.Count; k++)
n.Dendrites[k].Weight = n.Dendrites[k].Weight + (this.LearningRate * this.Layers[i - 1].Neurons[k].Value * n.Delta);
}
}
return true;
}

Counting Sort Implementation in C#

I am implementing counting sort But some thing is wrong with my code
I am new in Programming Please help me to find an error.
I am implenting it step by step .
namespace ConsoleApplication1
{
class Program
{
public static int[] a = { 0,0,0,5,4,8,9,9,7,3, 3, 2, 1 };
public static void Sorting()
{
int j = 0, i = 0, smallestvalue = 0, largestvalue = 0, n = a.Length, lengthof_B = 0, temp = 0, anothersmallestvalue;
smallestvalue = largestvalue = a[0];
for (i = 0; i < n; i++)
{
if (smallestvalue > a[i])
{
smallestvalue = a[i];
}
else if (largestvalue < a[i])
{
largestvalue = a[i];
}
}
int x = anothersmallestvalue = smallestvalue;
lengthof_B = largestvalue - smallestvalue + 1;
int[] b = new int[lengthof_B];
for (i = 0; i < lengthof_B && smallestvalue <= largestvalue; i++)
{
for (j = 0; j < n; j++)
{
if (smallestvalue == a[j])
{
b[i] = b[i] + 1;
}
}
b[i] = temp + b[i];
temp = b[i];
smallestvalue++;
}
int[] c = new int[a.Length];
// I think error here
for (i = n - 1; i >= 0; i--)
{
anothersmallestvalue = x;
for (j = 0; j <= lengthof_B ; j++)
{
if (a[i] == anothersmallestvalue)
{
temp = b[j];
c[temp - 1] = anothersmallestvalue;
b[j] = b[j];
}
anothersmallestvalue++;
}
}
for (i = 0; i < c.Length; i++)
{
Console.WriteLine("c[i] : " + c[i]);
}
}
}
class Demo
{
static void Main(string[] args)
{
Program.Sorting();
Console.ReadLine();
}
}
}
Desired Output is
000123457899
But output of my program is
000120457809
This Is Your Code Here I found a mistake.
And your Code is too complex Please Go through your code Once more.
for (i = n - 1; i >= 0; i--)
{
anothersmallestvalue = x;
for (j = 0; j <= lengthof_B ; j++)
{
if (a[i] == anothersmallestvalue)
{
temp = b[j];
c[temp - 1] = anothersmallestvalue;
b[j] = b[j] -1 ;// Possible Mistake I think here
}
anothersmallestvalue++;
}
}
the very simple and stylish way is described and shown here.
en.wikipedia.org/wiki/Counting_sort#The_algorithm
Normal sorting your two loops should look like this
for (i = 0; i < lengthof_B - 1; i++)
{
for (j = i + 1; j < lengthof_B; j++)
{
}
}​

NSGA:assigned_fitness negative values

I have a problem with NSGA. When I have 100 pop, 2 objectives, sigma_share=0.01, epsilon=0.22 and run N times with NSGA then the assigned_fitness values are not negative.
When I have above 200 pop, 2 objectives, sigma_share=0.01, epsilon=0.22 and run with N=5 or N=6 times, then the assigned_fitness and shared_fitness are negative values.
How do I fix this?
public void Compute_Assigned_fitness()
{
//Np is 200, epsilon=0.22
double Fmin = this.Np + epsilon;
double fmin_temp=Fmin;
for (int i = 0; i < Front_id.Count; i++)
{
for (int j = 0; j < Front_id[i].Front_item.Count; j++)
{
Front_id[i].Front_item[j].Assigned_fitness = Fmin - epsilon;
double niche = 0;
for (int k = 0; k < Front_id[i].Front_item.Count; k++)
{
double d = Front_id[i].Front_item[j].distances_to(Front_id[i].Front_item[k]);
if (d <= sigma_share)
{
double shd = 1 - (d / sigma_share) * (d / sigma_share);
niche += shd;
}
Front_id[i].Front_item[j].Niche = niche;
}
Front_id[i].Front_item[j].Shared_fitness = Front_id[i].Front_item[j].Assigned_fitness / niche;
niche = 0;
if (fmin_temp > Front_id[i].Front_item[j].Shared_fitness)
fmin_temp = Front_id[i].Front_item[j].Shared_fitness;
}
Fmin = fmin_temp;
}
for (int i = 0; i < Front_id.Count; i++)
{
for (int j = 0; j < Front_id[i].Front_item.Count; j++)
{
P.Add(Front_id[i].Front_item[j]);
}
}
}

Categories