private static double[] tethaGradientValue(Individual tetha2, List<Individual> population) { Individual result = new Individual(tetha2 / Math.Pow(sigma, 2)); ; for (int row = 0; row < population.Count; row++) { for (int col = row; col < population.Count; col++) { if (row == col) continue; Individual secondTerm = new Individual(new Individual(population[row] - population[col]) * (double)(numberOfGames - 2 * population[row].Labels[col])); result = new Individual(result + secondTerm); Individual difference = new Individual(population[row] - population[col]); double vValue = difference.DotProduct(tetha2.Weights); Individual gOfXY = new Individual(difference * ((Math.Exp(vValue) - Math.Exp(-vValue)) / (Math.Exp(vValue) + Math.Exp(-vValue)))); result = new Individual(result + gOfXY); } } return result.Weights; }
private static double xStarFunctionValue(Individual xStar2, List<Individual> population) { Individual result = new Individual(xStar2 * (double)population.Count); Individual sum = new Individual(new double[numberOfFeatures]); double gOfXY = 0; for (int index = 1; index < population.Count; index++) { sum = new Individual(sum + population[index]); Individual newIndiv = new Individual(xStar2 - population[index]); double localValue = newIndiv.DotProduct(tetha.Weights); gOfXY += Math.Log(Math.Exp(localValue) + Math.Exp(-localValue)); } result = new Individual(sum - result); return result.DotProduct(tetha.Weights) + gOfXY; }
private static double tethaFunctionValue(Individual tetha2, List<Individual> population) { double result = 0; result += Math.Pow(tetha2.EuclideanNorm(),2) / 2 * Math.Pow(sigma, 2); for (int row = 0; row < population.Count; row++) { for (int col = row; col < population.Count; col++) { if (row == col) continue; Individual newIndiv = new Individual(population[row] - population[col]); double localValue = newIndiv.DotProduct(tetha2.Weights); double gOfXY = Math.Log(Math.Exp(localValue) + Math.Exp(-localValue)); localValue = localValue * (double)(numberOfGames - 2 * population[row].Labels[col]) + (double)numberOfGames * gOfXY; result += localValue; } } return result; }