Changeset 16231 for branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/PGE.cs
- Timestamp:
- 10/17/18 04:47:09 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/PGE.cs
r16212 r16231 37 37 38 38 [DllImport("go-pge.dll", EntryPoint = "stepW", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] 39 public static extern voidStepW();39 public static extern int StepW(); 40 40 41 41 [DllImport("go-pge.dll", EntryPoint = "getStepResult", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] … … 278 278 279 279 protected override void Run(CancellationToken cancellationToken) { 280 281 280 // 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 282 282 Environment.SetEnvironmentVariable("GOGC", "off"); 283 283 Environment.SetEnvironmentVariable("GODEBUG", "cgocheck=0"); 284 284 Environment.SetEnvironmentVariable("CGO_ENABLED", "1"); 285 285 Environment.SetEnvironmentVariable("PGEDEBUG", "0"); 286 286 287 287 … … 301 301 IntPtr testData = GetData(problemData.Dataset, variables, problemData.TestIndices, out nTestData); 302 302 303 nTrainData = Problem.ProblemData.TrainingPartition.Size; 304 nTestData = Problem.ProblemData.TestPartition.Size; 305 303 306 var inputVariableNames = string.Join(" ", problemData.AllowedInputVariables); 304 307 // TODO: does this work when input variables contain spaces? … … 322 325 323 326 324 325 327 AddTestData(cIndepNames, cDependentNames, testData, nTestData); 326 328 … … 343 345 curItersItem.Value = iter; 344 346 345 StepW(); // TODO: alg crashes here346 347 for (int i Peel = 0; iPeel < PeelCnt; iPeel++) {347 int nResults = StepW(); 348 349 for (int iResult = 0; iResult < nResults; iResult++) { 348 350 int nobestpush = 0; //bool 349 351 int bestNewMinError = 0; //bool … … 357 359 string eqnStr = Marshal.PtrToStringAnsi(eqn); 358 360 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 + "; "); 381 367 } 382 368 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); 383 377 } 384 378 … … 389 383 Marshal.FreeHGlobal(trainData); 390 384 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 391 400 // Results.Add(new Result("Execution time", new TimeSpanValue(this.ExecutionTime))); 392 401 }
Note: See TracChangeset
for help on using the changeset viewer.