Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/19/19 05:05:24 (5 years ago)
Author:
hmaislin
Message:

#2929: Fixed result bug, added multitest C / Powershell, passed pagie_1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/PGE.cs

    r16515 r16614  
    3434
    3535    [DllImport("go-pge.dll", EntryPoint = "initTreeParams", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
    36     public static extern void InitTreeParams(IntPtr roots, IntPtr nodes, IntPtr nonTrig, IntPtr leafs, IntPtr usableVars, int numUsableVars, int maxSize, int minSize, int maxDepth, int minDepth);
     36    public static extern void InitTreeParams(IntPtr roots, IntPtr nodes, IntPtr nonTrig, IntPtr leafs, int numUsableVars, int maxSize, int minSize, int maxDepth, int minDepth);
    3737
    3838    [DllImport("go-pge.dll", EntryPoint = "initProblem", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
     
    4343
    4444    [DllImport("go-pge.dll", EntryPoint = "getStepResult", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
    45     public static extern IntPtr GetStepResult(out int noBestPush, out int bestNewMinErr, out int bestlen1, out int bestlen2, out int testscore, out int nCoeff);
     45    public static extern IntPtr GetStepResult(out int testscore, out int nCoeff);
    4646
    4747    [DllImport("go-pge.dll", EntryPoint = "getCoeffResult", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
     
    345345
    346346      int numberOfUseableVariables = problemData.AllowedInputVariables.Count();
    347       IntPtr cUseableVars = GetUsableVars(numberOfUseableVariables);
    348347
    349348      InitSearch(MaxGen, PgeRptEpoch, PgeRptCount, PgeArchiveCap, PeelCnt, EvalrCount, ZeroEpsilon, cInitMethod, cGrowMethod, sortType);
    350349
    351350      // cUsableVars: list of indices into independent variables
    352       InitTreeParams(cRoots, cNodes, cNonTrig, cLeafs, cUseableVars, numberOfUseableVariables, MaxSize, MinSize, MaxDepth, MinDepth);
    353 
    354      
     351      InitTreeParams(cRoots, cNodes, cNonTrig, cLeafs, numberOfUseableVariables, MaxSize, MinSize, MaxDepth, MinDepth);
     352
    355353      InitProblem(cName, MaxIterations, HitRatio,
    356354        searchVar: 0,  // SearchVar: index of dependent variables (this is always zero because we only have one target variable)
     
    364362
    365363        for (int iResult = 0; iResult < nResults; iResult++) {
    366           int nobestpush = 0;       //bool
    367           int bestNewMinError = 0;  //bool
    368           int bestlen1 = 0;
    369           int bestlen2 = 0;
    370364          int nCoeff = 0;
    371365          int testScore = 0;
    372366
    373           IntPtr eqn = GetStepResult(out nobestpush, out bestNewMinError, out bestlen1, out bestlen2, out testScore, out nCoeff);
     367          IntPtr eqn = GetStepResult(out testScore, out nCoeff);
    374368          string eqnStr = Marshal.PtrToStringAnsi(eqn);
    375369
     
    378372            coeff[iCoeff] = GetCoeffResult();
    379373          }
    380           log.LogMessage("Push/Pop (" + iResult + ", " + bestlen1 + ", " + bestlen2 + ", " + testScore + ", noBestPush: " + (nobestpush > 0) + ", bestNewMin: " + (bestNewMinError > 0) + ") " + eqnStr + " coeff: " + string.Join(" ", coeff));
    381 
    382           if (!string.IsNullOrEmpty(eqnStr) && (testScore < bestTestScore || bestNewMinError > 0)) {
     374          log.LogMessage("Push/Pop (" + iResult + ", " + testScore + ") " + eqnStr + " coeff: " + string.Join(" ", coeff));
     375
     376          if (!string.IsNullOrEmpty(eqnStr) && (testScore < bestTestScore)) {
    383377            // update best quality
    384378            bestTestScore = testScore;
     
    389383          bestTestScoreRow.Values.Add(bestTestScoreResult.Value); // always add the current best test score to data row
    390384          curTestScoreRow.Values.Add(testScore);
    391           len1Row.Values.Add(bestlen1);
    392           len2Row.Values.Add(bestlen2);
    393385        }
    394386
     
    396388      }
    397389
    398       Marshal.FreeHGlobal(cUseableVars);
    399390      Marshal.FreeHGlobal(trainData);
    400391      Marshal.FreeHGlobal(testData);
     
    453444    }
    454445
    455     private static IntPtr GetUsableVars(int n) {
    456       long[] vars = new long[n];
    457 
    458       for (int i = 0; i < n; i++) {
    459         vars[i] = i;
    460       }
    461 
    462       IntPtr usableVars = Marshal.AllocHGlobal(sizeof(long) * n);
    463       Marshal.Copy(vars, 0, usableVars, n);
    464 
    465       return usableVars;
    466     }
    467 
    468446    private static IntPtr GetData(IDataset ds, IEnumerable<string> variableNames, IEnumerable<int> rows, out int n) {
    469447
Note: See TracChangeset for help on using the changeset viewer.