[4516] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Linq;
|
---|
[5654] | 24 | using HeuristicLab.Algorithms.GeneticAlgorithm;
|
---|
[5655] | 25 | using HeuristicLab.Collections;
|
---|
[4839] | 26 | using HeuristicLab.Common;
|
---|
[4516] | 27 | using HeuristicLab.Core;
|
---|
[4839] | 28 | using HeuristicLab.Data;
|
---|
[4516] | 29 | using HeuristicLab.Optimization;
|
---|
| 30 | using HeuristicLab.Parameters;
|
---|
[4839] | 31 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[4516] | 32 | using HeuristicLab.PluginInfrastructure;
|
---|
[5655] | 33 | using HeuristicLab.Problems.DataAnalysis;
|
---|
[5110] | 34 | using HeuristicLab.Problems.TestFunctions;
|
---|
[4516] | 35 |
|
---|
| 36 | namespace HeuristicLab.Problems.MetaOptimization {
|
---|
| 37 | [Item("Meta Optimization Problem", "Represents a Meta Optimization Problem.")]
|
---|
| 38 | [Creatable("Problems")]
|
---|
| 39 | [StorableClass]
|
---|
[5927] | 40 | public sealed class MetaOptimizationProblem : SingleObjectiveHeuristicOptimizationProblem<IParameterConfigurationEvaluator, IParameterConfigurationCreator>, IStorableContent {
|
---|
[5654] | 41 | public string Filename { get; set; }
|
---|
[5927] | 42 |
|
---|
[5110] | 43 | public const string AlgorithmTypeParameterName = "AlgorithmType";
|
---|
| 44 | public const string ProblemTypeParameterName = "ProblemType";
|
---|
| 45 | public const string ProblemsParameterName = "Problems";
|
---|
[5328] | 46 | public const string ParameterConfigurationTreeParameterName = "ParameterConfiguration";
|
---|
[5110] | 47 | public const string RepetitionsParameterName = "Repetitions";
|
---|
[4516] | 48 |
|
---|
[5111] | 49 | public const string IntValueManipulatorParameterName = "IntValueManipulator";
|
---|
| 50 | public const string DoubleValueManipulatorParameterName = "DoubleValueManipulator";
|
---|
| 51 | public const string IntValueCrossoverParameterName = "IntValueCrossover";
|
---|
| 52 | public const string DoubleValueCrossoverParameterName = "DoubleValueCrossover";
|
---|
| 53 |
|
---|
[4516] | 54 | #region Parameter Properties
|
---|
[5337] | 55 | public IValueParameter<ConstrainedTypeValue<IAlgorithm>> AlgorithmTypeParameter {
|
---|
| 56 | get { return (ValueParameter<ConstrainedTypeValue<IAlgorithm>>)Parameters[AlgorithmTypeParameterName]; }
|
---|
[4516] | 57 | }
|
---|
[5337] | 58 | public IValueParameter<ConstrainedTypeValue<IProblem>> ProblemTypeParameter {
|
---|
| 59 | get { return (ValueParameter<ConstrainedTypeValue<IProblem>>)Parameters[ProblemTypeParameterName]; }
|
---|
[4516] | 60 | }
|
---|
[5337] | 61 | public IValueParameter<ConstrainedItemList<IProblem>> ProblemsParameter {
|
---|
| 62 | get { return (ValueParameter<ConstrainedItemList<IProblem>>)Parameters[ProblemsParameterName]; }
|
---|
[4516] | 63 | }
|
---|
[5144] | 64 | public IValueParameter<ParameterConfigurationTree> ParameterConfigurationTreeParameter {
|
---|
| 65 | get { return (ValueParameter<ParameterConfigurationTree>)Parameters[ParameterConfigurationTreeParameterName]; }
|
---|
[5110] | 66 | }
|
---|
| 67 | public IValueParameter<IntValue> RepetitionsParameter {
|
---|
| 68 | get { return (ValueParameter<IntValue>)Parameters[RepetitionsParameterName]; }
|
---|
| 69 | }
|
---|
[5111] | 70 |
|
---|
| 71 | public IValueParameter<IIntValueManipulator> IntValueManipulatorParameter {
|
---|
| 72 | get { return (ValueParameter<IIntValueManipulator>)Parameters[IntValueManipulatorParameterName]; }
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | public IValueParameter<IDoubleValueManipulator> DoubleValueManipulatorParameter {
|
---|
| 76 | get { return (ValueParameter<IDoubleValueManipulator>)Parameters[DoubleValueManipulatorParameterName]; }
|
---|
| 77 | }
|
---|
[4516] | 78 | #endregion
|
---|
| 79 |
|
---|
| 80 | #region Properties
|
---|
[5337] | 81 | public IAlgorithm Algorithm {
|
---|
[5655] | 82 | get { return CreateAlgorithm(AlgorithmType.Value, Problems.FirstOrDefault()); }
|
---|
[5313] | 83 | }
|
---|
[5337] | 84 | public ConstrainedTypeValue<IAlgorithm> AlgorithmType {
|
---|
[5110] | 85 | get { return AlgorithmTypeParameter.Value; }
|
---|
| 86 | set { AlgorithmTypeParameter.Value = value; }
|
---|
[4516] | 87 | }
|
---|
[5337] | 88 | public ConstrainedTypeValue<IProblem> ProblemType {
|
---|
[5110] | 89 | get { return ProblemTypeParameter.Value; }
|
---|
| 90 | set { ProblemTypeParameter.Value = value; }
|
---|
| 91 | }
|
---|
[5337] | 92 | public ConstrainedItemList<IProblem> Problems {
|
---|
[4830] | 93 | get { return ProblemsParameter.Value; }
|
---|
| 94 | set { ProblemsParameter.Value = value; }
|
---|
[4516] | 95 | }
|
---|
[5144] | 96 | public ParameterConfigurationTree ParameterConfigurationTree {
|
---|
| 97 | get { return ParameterConfigurationTreeParameter.Value; }
|
---|
| 98 | set { ParameterConfigurationTreeParameter.Value = value; }
|
---|
[4516] | 99 | }
|
---|
[5110] | 100 | public IntValue Repetitions {
|
---|
| 101 | get { return RepetitionsParameter.Value; }
|
---|
| 102 | set { RepetitionsParameter.Value = value; }
|
---|
| 103 | }
|
---|
[5184] | 104 | private BestParameterConfigurationAnalyzer BestParameterConfigurationAnalyzer {
|
---|
| 105 | get { return Operators.OfType<BestParameterConfigurationAnalyzer>().FirstOrDefault(); }
|
---|
| 106 | }
|
---|
[5293] | 107 | private ReferenceQualityAnalyzer ReferenceQualityAnalyzer {
|
---|
| 108 | get { return Operators.OfType<ReferenceQualityAnalyzer>().FirstOrDefault(); }
|
---|
[5281] | 109 | }
|
---|
[5359] | 110 | private SolutionCacheAnalyzer RunsAnalyzer {
|
---|
| 111 | get { return Operators.OfType<SolutionCacheAnalyzer>().FirstOrDefault(); }
|
---|
[5303] | 112 | }
|
---|
[5522] | 113 | private PMOPopulationDiversityAnalyzer PMOPopulationDiversityAnalyzer {
|
---|
| 114 | get { return Operators.OfType<PMOPopulationDiversityAnalyzer>().FirstOrDefault(); }
|
---|
[5576] | 115 | }
|
---|
| 116 | private PMOProblemQualitiesAnalyzer PMOProblemQualitiesAnalyzer {
|
---|
| 117 | get { return Operators.OfType<PMOProblemQualitiesAnalyzer>().FirstOrDefault(); }
|
---|
| 118 | }
|
---|
| 119 | private PMOBestSolutionHistoryAnalyzer PMOBestSolutionHistoryAnalyzer {
|
---|
| 120 | get { return Operators.OfType<PMOBestSolutionHistoryAnalyzer>().FirstOrDefault(); }
|
---|
| 121 | }
|
---|
[4516] | 122 | #endregion
|
---|
| 123 |
|
---|
[5303] | 124 | public MetaOptimizationProblem()
|
---|
| 125 | : base() {
|
---|
[5337] | 126 | Parameters.Add(new ValueParameter<ConstrainedTypeValue<IAlgorithm>>(AlgorithmTypeParameterName, "The algorithm which's parameters should be optimized.", new ConstrainedTypeValue<IAlgorithm>(typeof(GeneticAlgorithm))));
|
---|
| 127 | Parameters.Add(new ValueParameter<ConstrainedTypeValue<IProblem>>(ProblemTypeParameterName, "The problem type.", new ConstrainedTypeValue<IProblem>()));
|
---|
| 128 | Parameters.Add(new ValueParameter<ConstrainedItemList<IProblem>>(ProblemsParameterName, "The problems that should be evaluated.", new ConstrainedItemList<IProblem>()));
|
---|
[5184] | 129 | Parameters.Add(new ValueParameter<ParameterConfigurationTree>(ParameterConfigurationTreeParameterName, "Tree of algorithm parameters that should be optimized."));
|
---|
[5110] | 130 | Parameters.Add(new ValueParameter<IntValue>(RepetitionsParameterName, "The number of evaluations for each problem.", new IntValue(3)));
|
---|
| 131 |
|
---|
[5303] | 132 | var validIntManipulators = new ItemSet<IIntValueManipulator>(ApplicationManager.Manager.GetInstances<IIntValueManipulator>());
|
---|
[5111] | 133 | var validDoubleManipulators = new ItemSet<IDoubleValueManipulator>(ApplicationManager.Manager.GetInstances<IDoubleValueManipulator>());
|
---|
[5277] | 134 | var validIntCrossovers = new ItemSet<IIntValueCrossover>(ApplicationManager.Manager.GetInstances<IIntValueCrossover>());
|
---|
| 135 | var validDoubleCrossovers = new ItemSet<IDoubleValueCrossover>(ApplicationManager.Manager.GetInstances<IDoubleValueCrossover>());
|
---|
[5293] | 136 | Parameters.Add(new ConstrainedValueParameter<IIntValueManipulator>(IntValueManipulatorParameterName, "", validIntManipulators, validIntManipulators.Where(x => x.GetType() == typeof(NormalIntValueManipulator)).SingleOrDefault()));
|
---|
| 137 | Parameters.Add(new ConstrainedValueParameter<IDoubleValueManipulator>(DoubleValueManipulatorParameterName, "", validDoubleManipulators, validDoubleManipulators.Where(x => x.GetType() == typeof(NormalDoubleValueManipulator)).SingleOrDefault()));
|
---|
| 138 | Parameters.Add(new ConstrainedValueParameter<IIntValueCrossover>(IntValueCrossoverParameterName, "", validIntCrossovers, validIntCrossovers.Where(x => x.GetType() == typeof(NormalIntValueCrossover)).SingleOrDefault()));
|
---|
| 139 | Parameters.Add(new ConstrainedValueParameter<IDoubleValueCrossover>(DoubleValueCrossoverParameterName, "", validDoubleCrossovers, validDoubleCrossovers.Where(x => x.GetType() == typeof(NormalDoubleValueCrossover)).SingleOrDefault()));
|
---|
[5111] | 140 |
|
---|
[4830] | 141 | Maximization = new BoolValue(false);
|
---|
| 142 | SolutionCreator = new RandomParameterConfigurationCreator();
|
---|
[5653] | 143 | Evaluator = new PMOEvaluator();
|
---|
[4516] | 144 |
|
---|
[4830] | 145 | InitializeOperators();
|
---|
| 146 | RegisterParameterEvents();
|
---|
[5184] | 147 | ParameterizeAnalyzer();
|
---|
[4516] | 148 | ParameterizeSolutionCreator();
|
---|
| 149 | ParameterizeEvaluator();
|
---|
[4830] | 150 | ParameterizeOperators();
|
---|
[5110] | 151 |
|
---|
[5337] | 152 | AlgorithmTypeParameter_ValueChanged(this, EventArgs.Empty);
|
---|
[4516] | 153 | }
|
---|
| 154 |
|
---|
[4830] | 155 | [StorableConstructor]
|
---|
| 156 | private MetaOptimizationProblem(bool deserializing) : base(deserializing) { }
|
---|
[5303] | 157 | private MetaOptimizationProblem(MetaOptimizationProblem original, Cloner cloner)
|
---|
| 158 | : base(original, cloner) {
|
---|
[4830] | 159 | this.RegisterParameterEvents();
|
---|
[4516] | 160 | }
|
---|
[4830] | 161 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 162 | return new MetaOptimizationProblem(this, cloner);
|
---|
| 163 | }
|
---|
[4516] | 164 |
|
---|
| 165 | #region Helpers
|
---|
| 166 | [StorableHook(HookType.AfterDeserialization)]
|
---|
| 167 | private void AfterDeserializationHook() {
|
---|
[4830] | 168 | RegisterParameterEvents();
|
---|
[4516] | 169 | }
|
---|
[4830] | 170 | private void RegisterParameterEvents() {
|
---|
[4516] | 171 | SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
|
---|
| 172 | EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
|
---|
| 173 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
[5110] | 174 | AlgorithmTypeParameter.ValueChanged += new EventHandler(AlgorithmTypeParameter_ValueChanged);
|
---|
[5313] | 175 | AlgorithmType.ValueChanged += new EventHandler(AlgorithmType_ValueChanged);
|
---|
[5110] | 176 | ProblemTypeParameter.ValueChanged += new EventHandler(ProblemTypeParameter_ValueChanged);
|
---|
[5313] | 177 | ProblemType.ValueChanged += new EventHandler(ProblemType_ValueChanged);
|
---|
[5655] | 178 | Problems.ItemsAdded += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<IProblem>>(Problems_ItemsAdded);
|
---|
| 179 | Problems.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<IProblem>>(Problems_ItemsRemoved);
|
---|
[4516] | 180 | }
|
---|
[5303] | 181 |
|
---|
[4516] | 182 | private void InitializeOperators() {
|
---|
[4830] | 183 | Operators.AddRange(ApplicationManager.Manager.GetInstances<IParameterConfigurationOperator>().Cast<IOperator>());
|
---|
| 184 | Operators.Add(new BestParameterConfigurationAnalyzer());
|
---|
[5293] | 185 | Operators.Add(new ReferenceQualityAnalyzer());
|
---|
[5359] | 186 | Operators.Add(new SolutionCacheAnalyzer());
|
---|
[5522] | 187 | Operators.Add(new PMOPopulationDiversityAnalyzer());
|
---|
[5576] | 188 | Operators.Add(new PMOProblemQualitiesAnalyzer());
|
---|
| 189 | Operators.Add(new PMOBestSolutionHistoryAnalyzer());
|
---|
[4516] | 190 | }
|
---|
| 191 | private void ParameterizeSolutionCreator() {
|
---|
| 192 | }
|
---|
| 193 | private void ParameterizeEvaluator() {
|
---|
[5653] | 194 | ((PMOEvaluator)Evaluator).ParameterConfigurationParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ParameterConfigurationParameter.ActualName;
|
---|
[4516] | 195 | }
|
---|
| 196 | private void ParameterizeAnalyzer() {
|
---|
[5184] | 197 | if (BestParameterConfigurationAnalyzer != null) {
|
---|
| 198 | BestParameterConfigurationAnalyzer.ParameterConfigurationParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ParameterConfigurationParameter.ActualName;
|
---|
| 199 | }
|
---|
[5293] | 200 | if (ReferenceQualityAnalyzer != null) {
|
---|
| 201 | ReferenceQualityAnalyzer.ParameterConfigurationParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ParameterConfigurationParameter.ActualName;
|
---|
[5281] | 202 | }
|
---|
[5303] | 203 | if (RunsAnalyzer != null) {
|
---|
| 204 | RunsAnalyzer.ParameterConfigurationParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ParameterConfigurationParameter.ActualName;
|
---|
[5522] | 205 | }
|
---|
| 206 | if (PMOPopulationDiversityAnalyzer != null) {
|
---|
| 207 | PMOPopulationDiversityAnalyzer.SolutionParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ParameterConfigurationParameter.ActualName;
|
---|
| 208 | PMOPopulationDiversityAnalyzer.StoreHistoryParameter.Value.Value = true;
|
---|
[5303] | 209 | }
|
---|
[5576] | 210 | if (PMOProblemQualitiesAnalyzer != null) {
|
---|
| 211 | PMOProblemQualitiesAnalyzer.ParameterConfigurationParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ParameterConfigurationParameter.ActualName;
|
---|
| 212 | }
|
---|
| 213 | if (PMOBestSolutionHistoryAnalyzer != null) {
|
---|
| 214 | PMOBestSolutionHistoryAnalyzer.ParameterConfigurationParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ParameterConfigurationParameter.ActualName;
|
---|
| 215 | }
|
---|
[4516] | 216 | }
|
---|
| 217 | private void ParameterizeOperators() {
|
---|
[5184] | 218 | foreach (IParameterConfigurationCrossover op in Operators.OfType<IParameterConfigurationCrossover>()) {
|
---|
| 219 | op.ParentsParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ParameterConfigurationParameter.ActualName;
|
---|
| 220 | op.ChildParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ParameterConfigurationParameter.ActualName;
|
---|
| 221 | }
|
---|
| 222 | foreach (IParameterConfigurationManipulator op in Operators.OfType<IParameterConfigurationManipulator>()) {
|
---|
| 223 | op.ParameterConfigurationTreeParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ParameterConfigurationParameter.ActualName;
|
---|
| 224 | }
|
---|
[4516] | 225 | }
|
---|
| 226 |
|
---|
| 227 | #endregion
|
---|
| 228 |
|
---|
| 229 | #region Events
|
---|
| 230 |
|
---|
| 231 | private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 232 | ParameterizeSolutionCreator();
|
---|
| 233 | ParameterizeEvaluator();
|
---|
| 234 | ParameterizeAnalyzer();
|
---|
| 235 | ParameterizeOperators();
|
---|
| 236 | OnSolutionCreatorChanged();
|
---|
| 237 | }
|
---|
| 238 | private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 239 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
| 240 | ParameterizeEvaluator();
|
---|
| 241 | ParameterizeAnalyzer();
|
---|
| 242 | OnEvaluatorChanged();
|
---|
| 243 | }
|
---|
| 244 | private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
| 245 | ParameterizeAnalyzer();
|
---|
| 246 | }
|
---|
[5313] | 247 | private void AlgorithmTypeParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 248 | AlgorithmType_ValueChanged(sender, e);
|
---|
[4516] | 249 | }
|
---|
[5313] | 250 |
|
---|
| 251 | private void AlgorithmType_ValueChanged(object sender, EventArgs e) {
|
---|
[5337] | 252 | IAlgorithm instance = (IAlgorithm)Activator.CreateInstance(AlgorithmType.Value);
|
---|
| 253 | this.ProblemType.ValidTypes = ApplicationManager.Manager.GetTypes(instance.ProblemType, true).ToList();
|
---|
[5653] | 254 | this.ProblemType.Value = this.ProblemType.ValidTypes.SingleOrDefault(t => t == typeof(SingleObjectiveTestFunctionProblem)) ?? this.ProblemType.ValidTypes.Where(t => t != typeof(MetaOptimizationProblem)).FirstOrDefault();
|
---|
[5655] | 255 | // ProblemType_ValueChanged will add one problem and create ParameterConfigurationTree
|
---|
[4516] | 256 | }
|
---|
[5313] | 257 |
|
---|
| 258 | private void ProblemTypeParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 259 | ProblemType_ValueChanged(sender, e);
|
---|
| 260 | }
|
---|
| 261 |
|
---|
| 262 | private void ProblemType_ValueChanged(object sender, EventArgs e) {
|
---|
| 263 | Problems.Clear();
|
---|
| 264 | Problems.Type = ProblemType.Value;
|
---|
[5655] | 265 | Problems.Add((IProblem)Activator.CreateInstance(this.ProblemType.Value));
|
---|
[5313] | 266 | }
|
---|
[5655] | 267 |
|
---|
| 268 | private void Problems_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IProblem>> e) {
|
---|
| 269 | // the first problem in the list is always the instance for the algorithm - this way some basic wiring between problem and algorithm can be sustained
|
---|
| 270 | if (e.Items.Single().Index == 0) {
|
---|
[5665] | 271 | ParameterConfigurationTreeParameter.ActualValue = new ParameterConfigurationTree(CreateAlgorithm(AlgorithmType.Value, e.Items.Single().Value), e.Items.Single().Value);
|
---|
[5655] | 272 |
|
---|
| 273 | // special for DataAnalysisProblem: Because of wiring between algorithm and problem, ParameterConfigurationTree needs to be recreated on Reset event
|
---|
[5927] | 274 | var dap = e.Items.Single().Value as IDataAnalysisProblem;
|
---|
[5655] | 275 | if (dap != null) {
|
---|
| 276 | dap.Reset += new EventHandler(DataAnalysisProblem_Reset);
|
---|
| 277 | }
|
---|
| 278 | }
|
---|
| 279 | }
|
---|
| 280 |
|
---|
| 281 | private void Problems_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IProblem>> e) {
|
---|
| 282 | if (e.Items.Single().Index == 0) {
|
---|
| 283 | ParameterConfigurationTreeParameter.ActualValue = null;
|
---|
| 284 |
|
---|
[5927] | 285 | var dap = e.Items.Single().Value as IDataAnalysisProblem;
|
---|
[5655] | 286 | if (dap != null) {
|
---|
| 287 | dap.Reset -= new EventHandler(DataAnalysisProblem_Reset);
|
---|
| 288 | }
|
---|
| 289 | }
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 | private void DataAnalysisProblem_Reset(object sender, EventArgs e) {
|
---|
[5665] | 293 | ParameterConfigurationTreeParameter.ActualValue = new ParameterConfigurationTree(CreateAlgorithm(AlgorithmType.Value, Problems.First()), Problems.First());
|
---|
[5655] | 294 | }
|
---|
[4516] | 295 | #endregion
|
---|
[5313] | 296 |
|
---|
[5655] | 297 | private IAlgorithm CreateAlgorithm(Type algorithmType, IProblem problem) {
|
---|
[5337] | 298 | IAlgorithm algorithm = (IAlgorithm)Activator.CreateInstance(algorithmType);
|
---|
[5655] | 299 | algorithm.Problem = problem;
|
---|
[5313] | 300 | return algorithm;
|
---|
| 301 | }
|
---|
| 302 |
|
---|
[5337] | 303 | public void ImportAlgorithm(IAlgorithm algorithm) {
|
---|
[5313] | 304 | AlgorithmType.Value = algorithm.GetType();
|
---|
[5337] | 305 | if (algorithm.Problem != null) ProblemType.Value = algorithm.Problem.GetType();
|
---|
[5665] | 306 | if (algorithm.Problem != null) {
|
---|
| 307 | Problems.Clear();
|
---|
| 308 | Problems.Add((IProblem)algorithm.Problem);
|
---|
| 309 | }
|
---|
| 310 | ParameterConfigurationTreeParameter.ActualValue = new ParameterConfigurationTree(algorithm, Problems.First());
|
---|
| 311 |
|
---|
[5313] | 312 | }
|
---|
[4516] | 313 | }
|
---|
| 314 | }
|
---|