Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10082


Ignore:
Timestamp:
10/24/13 10:14:02 (11 years ago)
Author:
ascheibe
Message:

#1886 correction of LPHull Func

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/LPHull.cs

    r10081 r10082  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using HeuristicLab.Common;
    2625
    2726namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers {
     
    118117
    119118      for (int i = 0; i < K; i++) {
    120         init[i] = 1.0 / K;
     119        init[i] = 0.0;
    121120        lowerBound[i] = 0.0;
    122121        upperBound[i] = double.MaxValue;
    123122      }
     123      init[aIdx] = 1.0;
    124124
    125125      //last column gets b
     
    143143      alglib.minbleicsetlc(state, c, ct);
    144144      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);
    146146      alglib.minbleicresults(state, out x, out rep);
    147147
    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;
    149151    }
    150152
    151153    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;
    156155
    157       //well, this seems to work but is probably not correct
     156      func = x[aIdx];
    158157      for (int i = 0; i < grad.Length; i++) {
    159158        grad[i] = 0;
    160159      }
    161160      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       }
    169161    }
    170162  }
Note: See TracChangeset for help on using the changeset viewer.