Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/03/15 00:03:18 (9 years ago)
Author:
aballeit
Message:

#2283 limit parallelism

Location:
branches/HeuristicLab.Problems.GrammaticalOptimization/Evaluation
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Evaluation/MainWindow.xaml

    r12824 r12832  
    7373                <TextBlock Margin="2" Grid.Column="0" Grid.Row="1" VerticalAlignment="Center">MaxIterations:</TextBlock>
    7474                <TextBox Name="TextBoxMaxIterations" Margin="2" Grid.Column="1" Grid.Row="1" Width="100" VerticalAlignment="Center" TextAlignment="Right" Text="{Binding MaxIterations}"></TextBox>
     75                <TextBlock Margin="2" Grid.Column="2" Grid.Row="1" VerticalAlignment="Center">MaxThreads:</TextBlock>
     76                <TextBox Name="MaxThreads" Margin="2" Grid.Column="3" Grid.Row="1" Width="100" VerticalAlignment="Center" TextAlignment="Right" Text="{Binding MaxThreads}"></TextBox>
    7577                <TextBlock Margin="2" Grid.Column="2" Grid.Row="0" VerticalAlignment="Center">MaxLen:</TextBlock>
    7678                <TextBox Name="TextBoxMaxLen" Margin="2" Grid.Column="3" Grid.Row="0" Width="100" VerticalAlignment="Center" TextAlignment="Right" Text="{Binding MaxLen}"></TextBox>
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Evaluation/MainWindow.xaml.cs

    r12830 r12832  
    33using System.Text;
    44using System.Threading;
     5using System.Threading.Tasks;
    56using System.Windows.Documents;
    67using System.Xml.Serialization;
     
    4546            vm.MaxIterations = 500000;
    4647            vm.NrRuns = 20;
     48            vm.MaxThreads = 5;
    4749        }
    4850
     
    126128                    //    File.WriteAllBytes(run.SvgFile, mctsSolver.GenerateSvg());
    127129                    //}
     130                    mctsSolver.FreeAll();
    128131                }
    129132            }
     
    183186            }
    184187
     188
     189
    185190            for (int i = 0; i < vm.NrRuns; i++)
    186191            {
     
    218223
    219224                vm.Runs.Add(run);
    220 
    221                 ThreadPool.QueueUserWorkItem(DoRun, run);
    222             }
     225            }
     226            Task.Run(() =>
     227                Parallel.For(0, vm.NrRuns, new ParallelOptions {MaxDegreeOfParallelism = vm.MaxThreads},
     228                    i => DoRun(vm.Runs[i])));
    223229        }
    224230
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Evaluation/ViewModel/EvaluationViewModel.cs

    r12815 r12832  
    107107                this.maxIterations = value;
    108108                this.OnPropertyChanged("MaxIterations");
     109            }
     110        }
     111
     112        private int maxThreads;
     113
     114        public int MaxThreads
     115        {
     116            get { return this.maxThreads; }
     117            set
     118            {
     119                this.maxThreads = value;
     120                this.OnPropertyChanged("MaxThreads");
    109121            }
    110122        }
Note: See TracChangeset for help on using the changeset viewer.