Changeset 10082 for branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers
- Timestamp:
- 10/24/13 10:14:02 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/LPHull.cs
r10081 r10082 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Common;26 25 27 26 namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers { … … 118 117 119 118 for (int i = 0; i < K; i++) { 120 init[i] = 1.0 / K;119 init[i] = 0.0; 121 120 lowerBound[i] = 0.0; 122 121 upperBound[i] = double.MaxValue; 123 122 } 123 init[aIdx] = 1.0; 124 124 125 125 //last column gets b … … 143 143 alglib.minbleicsetlc(state, c, ct); 144 144 alglib.minbleicsetcond(state, 0.0, 0.0, 0.0, 0); 145 alglib.minbleicoptimize(state, Func, null, new Tuple<List<double[]>, double[], int>(A, alpha, aIdx));145 alglib.minbleicoptimize(state, Func, null, aIdx); 146 146 alglib.minbleicresults(state, out x, out rep); 147 147 148 return x.Count(y => y.IsAlmost(1.0)) == 1; 148 if (rep.terminationtype < 0) throw new ArgumentException("minbleic terminated with error"); 149 if (rep.terminationtype == 5) Console.WriteLine("max number of iterations reached in minbleic"); 150 return x[aIdx] >= 1.0; 149 151 } 150 152 151 153 private static void Func(double[] x, ref double func, double[] grad, object obj) { 152 Tuple<List<double[]>, double[], int> data = obj as Tuple<List<double[]>, double[], int>; 153 int aIdx = data.Item3; 154 double[] alpha = data.Item2; 155 List<double[]> A = data.Item1; 154 int aIdx = (int)obj; 156 155 157 //well, this seems to work but is probably not correct156 func = x[aIdx]; 158 157 for (int i = 0; i < grad.Length; i++) { 159 158 grad[i] = 0; 160 159 } 161 160 grad[aIdx] = 1; 162 163 func = 0.0;164 for (int i = 0; i < A.Count; i++) {165 for (int j = 0; j < A[i].Length; j++) {166 func += A[i][j] * x[i];167 }168 }169 161 } 170 162 }
Note: See TracChangeset
for help on using the changeset viewer.