Changes in branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ParameterConfigurationTree.cs [8535:8574]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ParameterConfigurationTree.cs
r8535 r8574 166 166 get { return parameters; } 167 167 set { parameters = value; } 168 }169 170 [Storable]171 private double experimentGenerationProgress;172 public double ExperimentGenerationProgress {173 get { return experimentGenerationProgress; }174 private set {175 if (experimentGenerationProgress != value) {176 experimentGenerationProgress = value;177 OnExperimentGenerationProgressChanged();178 }179 }180 168 } 181 169 … … 291 279 CombinationsCount = GetCombinationCount(0); 292 280 } 293 294 public event EventHandler ExperimentGenerationProgressChanged;295 private void OnExperimentGenerationProgressChanged() {296 var handler = ExperimentGenerationProgressChanged;297 if (handler != null) handler(this, EventArgs.Empty);298 }299 281 #endregion 300 282 … … 308 290 309 291 algorithm.CollectParameterValues(this.Parameters); 310 }311 312 public Experiment GenerateExperiment(IAlgorithm algorithm, bool createBatchRuns, int repetitions, Dictionary<IProblemInstanceProvider, HashSet<IDataDescriptor>> problemInstances, CancellationToken ct) {313 Experiment experiment = new Experiment();314 var algorithms = new List<IAlgorithm>(1 + problemInstances.Values.Count) { (IAlgorithm)algorithm.Clone() };315 foreach (var provider in problemInstances) {316 foreach (var descriptor in provider.Value) {317 var alg = (IAlgorithm)algorithm.Clone();318 ProblemInstanceManager.LoadData(provider.Key, descriptor, (IProblemInstanceConsumer)alg.Problem);319 algorithms.Add(alg);320 }321 }322 ExperimentGenerationProgress = 0;323 foreach (var alg in algorithms) {324 foreach (ParameterizedValueConfiguration combination in this) {325 ct.ThrowIfCancellationRequested();326 var clonedAlg = (IAlgorithm)alg.Clone();327 clonedAlg.Name = combination.ParameterInfoString;328 combination.Parameterize(clonedAlg);329 clonedAlg.StoreAlgorithmInEachRun = false;330 if (createBatchRuns) {331 BatchRun batchRun = new BatchRun(string.Format("BatchRun: {0}", combination.ParameterInfoString));332 batchRun.Optimizer = clonedAlg;333 batchRun.Repetitions = repetitions;334 experiment.Optimizers.Add(batchRun);335 } else {336 experiment.Optimizers.Add(clonedAlg);337 }338 ExperimentGenerationProgress = (double)experiment.Optimizers.Count / (this.GetCombinationCount(0) * algorithms.Count);339 }340 }341 return experiment;342 }343 344 public Experiment GenerateExperiment(IAlgorithm algorithm) {345 return GenerateExperiment(algorithm, false, 0, null, CancellationToken.None);346 }347 348 public Experiment GenerateExperiment(IAlgorithm algorithm, bool createBatchRuns, int repetitions) {349 return GenerateExperiment(algorithm, createBatchRuns, repetitions, null, CancellationToken.None);350 292 } 351 293
Note: See TracChangeset
for help on using the changeset viewer.