Index: /branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/MultiTest.ps1
===================================================================
--- /branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/MultiTest.ps1	(revision 16616)
+++ /branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/MultiTest.ps1	(revision 16617)
@@ -1,19 +1,15 @@
 [cmdletbinding()]
 param(
-    [int] $WaitToStep = 200,
+    [int] $WaitToStep = 500,
     [int] $PeelCnt = 3,
     [int] $EvalCnt = 3,
     [ValidateSet("method1","method2", "method3")][string] $InitMethod = "method1",
     [ValidateSet("method1","method2", "method3")][string] $GrowMethod = "method1",
-    [int] $MaxJobs = 30,
-    [switch] $Clear
+    [int] $MaxJobs = 10,
+    [switch] $NoClear,
+    [switch] $UseExisting
 )
 
 $BenchmarksPath = Resolve-Path -Relative "go-code\go-pge\data\benchmark"
-
-$Clean = $false
-if($Clear) {
-    $Clean = $true
-}
 
 $BenchFiles = Get-ChildItem -Path $BenchmarksPath -File
@@ -26,8 +22,9 @@
     }
     $ActiveJobs[$BenchName] = Start-Job -ScriptBlock {
-        param($PSPath, $WaitToStep, $BenchName, $PeelCnt, $EvalCnt, $InitMethod, $GrowMethod, $Clear)
+        param($PSPath, $WaitToStep, $BenchName, $PeelCnt, $EvalCnt, $InitMethod, $GrowMethod, $NoClear, $UseExisting)
         Set-Location -Path $PSPath
-        ./TestResults -WaitToStep $WaitToStep -BenchName $BenchName -PeelCnt $PeelCnt -EvalCnt $EvalCnt -InitMethod $InitMethod -GrowMethod $GrowMethod *>&1
-    } -ArgumentList $(Resolve-Path $PSScriptRoot), $WaitToStep, $BenchName, $PeelCnt, $EvalCnt, $InitMethod, $GrowMethod, $Clean
+        ./TestResults -WaitToStep $WaitToStep -BenchName $BenchName -PeelCnt $PeelCnt -EvalCnt $EvalCnt -InitMethod $InitMethod -GrowMethod $GrowMethod -NoClear:$NoClear -UseExisting:$UseExisting *>&1
+        Write-Output "Gen-Return: $LASTEXITCODE"
+    } -ArgumentList $(Resolve-Path $PSScriptRoot), $WaitToStep, $BenchName, $PeelCnt, $EvalCnt, $InitMethod, $GrowMethod, $NoClear.IsPresent, $UseExisting.IsPresent
     Write-Host "Started job for $BenchName"
 }
@@ -37,13 +34,21 @@
     $Job = $ActiveJobs[$BenchName]
     $Res = $Job | Receive-Job
+    $ReturnLine = $Res | Select-String -SimpleMatch "Gen-Return: "
+    if($ReturnLine -match "Gen-Return: (\d+)") {
+        if($Matches[0] -ne 0) {
+            Write-Error "$($BenchName): An error occurred! Return-Code $($Matches[0])"
+            continue
+        }
+    }
     $Succeeded = ($Res | Select-String -Pattern "^[0-9]+\sOK").Count
     $Failed = ($Res | Select-String -Pattern "^[0-9]+\sfailed!").Count
     if($($Succeeded + $Failed) -ne $WaitToStep ) {
-        Write-Error "Something went wrong!? Please check manuelly"
+        $Missing = $WaitToStep - ($Succeeded + $Failed)
+        Write-Error "$($BenchName): $Missing steps missing, or something went wrong!? Please check manuelly"
     }
     if($Succeeded -eq $WaitToStep) {
-        Write-Host "$($BenchName): $Succeeded / $WaitToStep tests succeeded"
+        Write-Host "$($BenchName): $Succeeded / $WaitToStep `ttests succeeded"
     } else {
-        Write-Warning "$($BenchName): $Failed / $WaitToStep tests failed!"
+        Write-Warning "$($BenchName): $Failed / $WaitToStep `ttests failed!"
     }
 }
Index: /branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/TestResults.ps1
===================================================================
--- /branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/TestResults.ps1	(revision 16616)
+++ /branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/TestResults.ps1	(revision 16617)
@@ -1,5 +1,5 @@
 ﻿[cmdletbinding()]
 param(
-    [int] $WaitToStep = 200,
+    [int] $WaitToStep = 30,
     [string] $BenchName = "Pagie_1",
     [int] $PeelCnt = 3,
@@ -7,19 +7,49 @@
     [ValidateSet("method1","method2", "method3")][string] $InitMethod = "method1",
     [ValidateSet("method1","method2", "method3")][string] $GrowMethod = "method1",
-    [bool] $Clear
+    [switch] $NoClear,
+    [switch] $UseExisting
 )
 
-$GenerateNew = $true
-
-$CLog = Join-Path -Path $(Resolve-Path $PSScriptRoot) -ChildPath "CGen_$($BenchName).log"
-$GoLog = Join-Path -Path $(Resolve-Path $PSScriptRoot) -ChildPath "GoOut_$($BenchName).log"
-
-$CLogError = Join-Path -Path $(Resolve-Path $PSScriptRoot) -ChildPath "CGen_$($BenchName).err"
-$GoLogError = Join-Path -Path $(Resolve-Path $PSScriptRoot) -ChildPath "GoOut_$($BenchName).err"
+$GenerateNew = -not $UseExisting.IsPresent
+$MaxSecondsTimeout = 90
+
+$LogFolder = Join-Path -Path $(Resolve-Path $PSScriptRoot) -ChildPath "tmplog"
+
+$CLog = Join-Path -Path $LogFolder -ChildPath "CGen_$($BenchName).log"
+$GoLog = Join-Path -Path $LogFolder -ChildPath "GoOut_$($BenchName).log"
+
+$CLogError = Join-Path -Path $LogFolder -ChildPath "CGen_$($BenchName).err"
+$GoLogError = Join-Path -Path $LogFolder -ChildPath "GoOut_$($BenchName).err"
 
 $CExecutable = Join-Path -Path $(Resolve-Path $PSScriptRoot) -ChildPath 'testmulti.exe'
 $GoExecutable = Join-Path -Path $(Resolve-Path $PSScriptRoot) -ChildPath 'go-code\go-pge\go-pge.exe'
 
+$BenchData = Join-Path -Path $(Resolve-Path $PSScriptRoot) -ChildPath 'go-code\go-pge\data\benchmark'
+$TestDataFile = Join-Path -Path $BenchData -ChildPath "$($BenchName).trn"
+$TrainDataFile = Join-Path -Path $BenchData -ChildPath "$($BenchName).tst"
+
+$ConfigData =  Join-Path -Path $(Resolve-Path $PSScriptRoot) -ChildPath 'go-code\go-pge\config\prob\bench'
+$ConfigDataFile = Join-Path -Path $ConfigData -ChildPath "$($BenchName).cfg"
+
+if(-not $(Test-Path -Path $TestDataFile -PathType Leaf) -or -not $(Test-Path -Path $TrainDataFile -PathType Leaf)) {
+    Write-Error "Train/test file does't exist for benchmark: $TestDataFile"
+    exit 4
+}
+if(-not $(Test-Path -Path $ConfigDataFile -PathType Leaf)) {
+    Write-Error "Configfile doesn't exist for benchmark: $ConfigDataFile"
+    exit 4
+}
+
+if($NoClear.IsPresent) {
+    $Clear = $false
+} else {
+    $Clear = $GenerateNew   
+}
+
 if($GenerateNew) {
+    if(-not $(Test-Path $LogFolder -Type Container)) {
+        New-Item -Path $LogFolder -ItemType Directory -Force
+    }
+
 	if(Test-Path $GoLog -Type Leaf) {
 		Remove-Item -Path $GoLog
@@ -37,4 +67,6 @@
     $CGenProc = Start-Process -FilePath $CExecutable -ArgumentList "$BenchName -evals=$($EvalCnt) -peel=$($PeelCnt) -iter=$($WaitToStep) -init=$($InitMethod) -grow=$($GrowMethod)" -RedirectStandardOutput $CLog -RedirectStandardError $CLogError -WorkingDirectory $PSScriptRoot -PassThru
     $StepReached = $false
+    $LastLogLength = 0
+    $Timeout = $MaxSecondsTimeout
     while(-not $StepReached) {
         $CGenCont = Get-Content $CLog
@@ -42,5 +74,16 @@
             $StepReached = $true
         }
+        if($LastLogLength -eq $CGenCont.Length) {
+            $Timeout--
+        } else {
+            $Timeout = $MaxSecondsTimeout
+        }
+        if($Timeout -le 0) {
+            $CGenProc | Stop-Process -ErrorAction SilentlyContinue -Force
+            Write-Error "C-data generation timed out!"
+            exit 2
+        }
         Start-Sleep -Seconds 1
+        $LastLogLength = $CGenCont.Length
     }
 
@@ -52,4 +95,6 @@
     $GoGenProc = Start-Process -FilePath $GoExecutable -ArgumentList "-pcfg=prob/bench/$($BenchName).cfg -evals=$($EvalCnt) -peel=$($PeelCnt) -iter=$($WaitToStep) -init=$($InitMethod) -grow=$($GrowMethod)"  -RedirectStandardOutput $GoLog -RedirectStandardError $GoLogError -WorkingDirectory $(Split-Path -Path $GoExecutable -Parent) -PassThru
     $StepReached = $false
+    $Timeout = $MaxSecondsTimeout
+    $LastLogLength = 0
     while(-not $StepReached) {
         $GoGenCont = Get-Content $GoLog
@@ -57,5 +102,16 @@
             $StepReached = $true
         }
+        if($LastLogLength -eq $CGenCont.Length) {
+            $Timeout--
+        } else {
+            $Timeout = $MaxSecondsTimeout
+        }
+        if($Timeout -le 0) {
+            $GoGenProc | Stop-Process -ErrorAction SilentlyContinue -Force
+            Write-Error "Go-data generation timed out!"
+            exit 3
+        }
         Start-Sleep -Seconds 1
+        $LastLogLength = $CGenCont.Length
     }
     $GoGenProc | Stop-Process -ErrorAction SilentlyContinue
@@ -122,30 +178,26 @@
 $ParseGo = Get-GoSteps -Content $GoContent
 
-foreach($StepNr in $($ParseGo.Keys | Sort-Object | Where-Object { $_ -ne 0 -and $_ -le $WaitToStep})) {
+for($StepNr = 1; $StepNr -le $WaitToStep; $StepNr++) {
     $GoResult = $ParseGo[$StepNr]
     [System.Collections.ArrayList]$CResult = $ParseC[$StepNr]
-
-    if($null -eq $CResult -or $CResult.Count -lt 1) {
-        Write-Warning "Missing CStep nr. $StepNr"
-        continue
-    }
-    if($null -eq $GoResult -or $GoResult.Count -lt 1) {
-        Write-Warning "Missing GoStep nr. $StepNr"
-        continue
-    }
-
-    $StepResult = $true
-    foreach($GoRes in $GoResult) {            # Step Results
-        $State = $false
-        foreach($CRes in $CResult.Clone()) {  # Compare every Result with every Step Result
-            Write-Output "$($GoRes) with $($CRes)"
-            if(Compare-Results -First $GoRes -Second $CRes) {
-                $State = $true
-                $CResult.Remove($CRes)
-                break
+    if($null -eq $GoResult -or $null -eq $CResult) {
+        $StepResult = $false
+    } else {
+        $StepResult = $CResult.Count -eq $GoResult.Count
+    }
+    if($StepResult) {    
+        foreach($GoRes in $GoResult) {            # Step Results
+            $State = $false
+            foreach($CRes in $CResult.Clone()) {  # Compare every Result with every Step Result
+                Write-Debug "$($GoRes) with $($CRes)"
+                if(Compare-Results -First $GoRes -Second $CRes) {
+                    $State = $true
+                    $CResult.Remove($CRes)
+                    break
+                }
             }
-        }
-        if(-not $State) {
-            $StepResult = $false
+            if(-not $State) {
+                $StepResult = $false
+            }
         }
     }
