Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/17/18 04:47:09 (6 years ago)
Author:
hmaislin
Message:

#2929: Fixed result error

File:
1 edited

Legend:

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

    r16212 r16231  
    3737
    3838    [DllImport("go-pge.dll", EntryPoint = "stepW", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
    39     public static extern void StepW();
     39    public static extern int StepW();
    4040
    4141    [DllImport("go-pge.dll", EntryPoint = "getStepResult", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
     
    278278
    279279    protected override void Run(CancellationToken cancellationToken) {
    280 
    281280      // TODO: the following is potentially problematic for other go processes run on the same machine at the same time
     281      // shouldn't be problematic bc is inherited only, normally only child processes are affected
    282282      Environment.SetEnvironmentVariable("GOGC", "off");
    283283      Environment.SetEnvironmentVariable("GODEBUG", "cgocheck=0");
    284284      Environment.SetEnvironmentVariable("CGO_ENABLED", "1");
    285 
     285      Environment.SetEnvironmentVariable("PGEDEBUG", "0");
    286286
    287287
     
    301301      IntPtr testData = GetData(problemData.Dataset, variables, problemData.TestIndices, out nTestData);
    302302
     303      nTrainData = Problem.ProblemData.TrainingPartition.Size;
     304      nTestData = Problem.ProblemData.TestPartition.Size;
     305
    303306      var inputVariableNames = string.Join(" ", problemData.AllowedInputVariables);
    304307      // TODO: does this work when input variables contain spaces?
     
    322325
    323326
    324 
    325327      AddTestData(cIndepNames, cDependentNames, testData, nTestData);
    326328
     
    343345        curItersItem.Value = iter;
    344346
    345         StepW();  // TODO: alg crashes here
    346 
    347         for (int iPeel = 0; iPeel < PeelCnt; iPeel++) {
     347        int nResults = StepW();
     348
     349        for (int iResult = 0; iResult < nResults; iResult++) {
    348350          int nobestpush = 0;       //bool
    349351          int bestNewMinError = 0;  //bool
     
    357359          string eqnStr = Marshal.PtrToStringAnsi(eqn);
    358360
    359           if (nobestpush == 1)
    360           {
    361             Console.WriteLine("No best push");
    362           } else {
    363             Console.WriteLine("Push/Pop (" + bestlen1 + "," + bestlen2 + ") " + eqnStr);
    364 
    365             StringBuilder sb = new StringBuilder("");
    366             for (int iCoeff = 0; iCoeff < nCoeff; iCoeff++) {
    367               double coeffVal = GetCoeffResult();
    368               Console.WriteLine("Coeff: " + coeffVal);
    369               sb.Append(coeffVal + "; ");
    370             }
    371 
    372             var curItersResult = new Result("Iteration " + iter + " " + iPeel, curItersItem);
    373             var coeffItersResult = new Result("Coeff " + iter + " " + iPeel, new StringValue(sb.ToString()));
    374 
    375             var bestQualityItem = new StringValue(eqnStr);
    376             var bestQualityResult = new Result("Best quality " + iter + " " + iPeel, bestQualityItem);
    377             Results.Add(curItersResult);
    378             Results.Add(coeffItersResult);
    379             Results.Add(bestQualityResult);
    380    
     361          Console.WriteLine("Push/Pop (" + bestlen1 + "," + bestlen2 + ") " + eqnStr);
     362          StringBuilder sb = new StringBuilder("");
     363          for (int iCoeff = 0; iCoeff < nCoeff; iCoeff++) {
     364            double coeffVal = GetCoeffResult();
     365            Console.WriteLine("Coeff: " + coeffVal);
     366            sb.Append(coeffVal + "; ");
    381367          }
    382368
     369          var curItersResult = new Result("Iteration " + iter + " " + iResult, curItersItem);
     370          var coeffItersResult = new Result("Coeff " + iter + " " + iResult, new StringValue(sb.ToString()));
     371
     372          var bestQualityItem = new StringValue(eqnStr);
     373          var bestQualityResult = new Result("Best quality " + iter + " " + iResult, bestQualityItem);
     374          Results.Add(curItersResult);
     375          Results.Add(coeffItersResult);
     376          Results.Add(bestQualityResult);
    383377        }
    384378
     
    389383      Marshal.FreeHGlobal(trainData);
    390384      Marshal.FreeHGlobal(testData);
     385
     386      Marshal.FreeHGlobal(cIndepNames);
     387      Marshal.FreeHGlobal(cDependentNames);
     388
     389      Marshal.FreeHGlobal(cInitMethod);
     390      Marshal.FreeHGlobal(cGrowMethod);
     391
     392      Marshal.FreeHGlobal(cRoots);
     393      Marshal.FreeHGlobal(cNodes);
     394      Marshal.FreeHGlobal(cNonTrig);
     395      Marshal.FreeHGlobal(cLeafs);
     396
     397      Marshal.FreeHGlobal(cName);
     398      Marshal.FreeHGlobal(cProblemTypeString);
     399
    391400      // Results.Add(new Result("Execution time", new TimeSpanValue(this.ExecutionTime)));
    392401    }
Note: See TracChangeset for help on using the changeset viewer.