Changeset 5337 for branches/HeuristicLab.MetaOptimization
- Timestamp:
- 01/20/11 01:30:44 (14 years ago)
- Location:
- branches/HeuristicLab.MetaOptimization
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/MetaOptimizationProblemView.cs
r5328 r5337 72 72 73 73 if (dlgResult == DialogResult.OK) { 74 EngineAlgorithm algorithm = Content.Algorithm;74 IAlgorithm algorithm = Content.Algorithm; 75 75 if(Content.Problems.Count > 0) algorithm.Problem = Content.Problems.First(); 76 76 Experiment experiment; … … 93 93 Type type = e.Data.GetData("Type") as Type; 94 94 if ((type != null) && (Content.AlgorithmType.ValidTypes.Contains(type))) { 95 EngineAlgorithm algorithm = e.Data.GetData("Value") as EngineAlgorithm;96 if (algorithm .Problem == null || Content.ProblemType.ValidTypes.Contains(algorithm.Problem.GetType())) {95 IAlgorithm algorithm = e.Data.GetData("Value") as IAlgorithm; 96 if (algorithm != null && algorithm.Problem == null || Content.ProblemType.ValidTypes.Contains(algorithm.Problem.GetType())) { 97 97 e.Effect = DragDropEffects.Copy; 98 98 } … … 101 101 protected void parameterCollectionView_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { 102 102 if (e.Effect != DragDropEffects.None) { 103 EngineAlgorithm algorithm = e.Data.GetData("Value") as EngineAlgorithm;103 IAlgorithm algorithm = e.Data.GetData("Value") as IAlgorithm; 104 104 Content.ImportAlgorithm(algorithm); 105 105 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/ObjectSelectorDialog.Designer.cs
r5110 r5337 46 46 this.itemsListView.MultiSelect = false; 47 47 this.itemsListView.Name = "itemsListView"; 48 this.itemsListView.Size = new System.Drawing.Size( 387, 501);48 this.itemsListView.Size = new System.Drawing.Size(653, 360); 49 49 this.itemsListView.TabIndex = 2; 50 50 this.itemsListView.UseCompatibleStateImageBehavior = false; … … 72 72 this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 73 73 this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; 74 this.cancelButton.Location = new System.Drawing.Point( 324, 519);74 this.cancelButton.Location = new System.Drawing.Point(590, 378); 75 75 this.cancelButton.Name = "cancelButton"; 76 76 this.cancelButton.Size = new System.Drawing.Size(75, 23); … … 84 84 this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; 85 85 this.okButton.Enabled = false; 86 this.okButton.Location = new System.Drawing.Point( 243, 519);86 this.okButton.Location = new System.Drawing.Point(509, 378); 87 87 this.okButton.Name = "okButton"; 88 88 this.okButton.Size = new System.Drawing.Size(75, 23); … … 98 98 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 99 99 this.CancelButton = this.cancelButton; 100 this.ClientSize = new System.Drawing.Size( 411, 554);100 this.ClientSize = new System.Drawing.Size(677, 413); 101 101 this.Controls.Add(this.cancelButton); 102 102 this.Controls.Add(this.okButton); -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/ObjectSelectorDialog.resx
r4516 r5337 113 113 </resheader> 114 114 <resheader name="reader"> 115 <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>115 <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 116 116 </resheader> 117 117 <resheader name="writer"> 118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 119 119 </resheader> 120 120 </root> -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Analyzers/BestParameterConfigurationAnalyzer.cs
r5293 r5337 42 42 get { return (LookupParameter<DoubleArray>)Parameters["ProblemQualityReferences"]; } 43 43 } 44 public LookupParameter<ConstrainedItemList<I SingleObjectiveProblem>> ProblemsParameter {45 get { return (LookupParameter<ConstrainedItemList<I SingleObjectiveProblem>>)Parameters[MetaOptimizationProblem.ProblemsParameterName]; }44 public LookupParameter<ConstrainedItemList<IProblem>> ProblemsParameter { 45 get { return (LookupParameter<ConstrainedItemList<IProblem>>)Parameters[MetaOptimizationProblem.ProblemsParameterName]; } 46 46 } 47 47 … … 56 56 Parameters.Add(new LookupParameter<RunCollection>("Population", "")); 57 57 Parameters.Add(new LookupParameter<DoubleArray>("ProblemQualityReferences", "")); 58 Parameters.Add(new LookupParameter<ConstrainedItemList<I SingleObjectiveProblem>>(MetaOptimizationProblem.ProblemsParameterName));58 Parameters.Add(new LookupParameter<ConstrainedItemList<IProblem>>(MetaOptimizationProblem.ProblemsParameterName)); 59 59 } 60 60 -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Analyzers/ReferenceQualityAnalyzer.cs
r5293 r5337 30 30 get { return (LookupParameter<DoubleArray>)Parameters["ProblemQualityReferences"]; } 31 31 } 32 public LookupParameter<ConstrainedItemList<I SingleObjectiveProblem>> ProblemsParameter {33 get { return (LookupParameter<ConstrainedItemList<I SingleObjectiveProblem>>)Parameters[MetaOptimizationProblem.ProblemsParameterName]; }32 public LookupParameter<ConstrainedItemList<IProblem>> ProblemsParameter { 33 get { return (LookupParameter<ConstrainedItemList<IProblem>>)Parameters[MetaOptimizationProblem.ProblemsParameterName]; } 34 34 } 35 35 … … 40 40 Parameters.Add(new ScopeTreeLookupParameter<ParameterConfigurationTree>("ParameterConfigurationTree", "")); 41 41 Parameters.Add(new LookupParameter<DoubleArray>("ProblemQualityReferences", "")); 42 Parameters.Add(new LookupParameter<ConstrainedItemList<I SingleObjectiveProblem>>(MetaOptimizationProblem.ProblemsParameterName, ""));42 Parameters.Add(new LookupParameter<ConstrainedItemList<IProblem>>(MetaOptimizationProblem.ProblemsParameterName, "")); 43 43 } 44 44 -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Analyzers/RunsAnalyzer.cs
r5303 r5337 30 30 get { return (LookupParameter<DoubleArray>)Parameters["ProblemQualityReferences"]; } 31 31 } 32 public LookupParameter<ConstrainedItemList<I SingleObjectiveProblem>> ProblemsParameter {33 get { return (LookupParameter<ConstrainedItemList<I SingleObjectiveProblem>>)Parameters[MetaOptimizationProblem.ProblemsParameterName]; }32 public LookupParameter<ConstrainedItemList<IProblem>> ProblemsParameter { 33 get { return (LookupParameter<ConstrainedItemList<IProblem>>)Parameters[MetaOptimizationProblem.ProblemsParameterName]; } 34 34 } 35 35 public ValueLookupParameter<ItemDictionary<StringValue, RunCollection>> RunsParameter { … … 43 43 Parameters.Add(new ScopeTreeLookupParameter<ParameterConfigurationTree>("ParameterConfigurationTree", "")); 44 44 Parameters.Add(new LookupParameter<DoubleArray>("ProblemQualityReferences", "")); 45 Parameters.Add(new LookupParameter<ConstrainedItemList<I SingleObjectiveProblem>>(MetaOptimizationProblem.ProblemsParameterName, ""));45 Parameters.Add(new LookupParameter<ConstrainedItemList<IProblem>>(MetaOptimizationProblem.ProblemsParameterName, "")); 46 46 Parameters.Add(new ValueLookupParameter<ItemDictionary<StringValue, RunCollection>>("Runs", "", new ItemDictionary<StringValue, RunCollection>())); 47 47 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/ConstrainedTypeValue.cs
r5328 r5337 13 13 [Item("ConstrainedTypeValue", "Represents a type with constraints.")] 14 14 [StorableClass] 15 public abstractclass ConstrainedTypeValue : TypeValue {15 public class ConstrainedTypeValue : TypeValue { 16 16 17 17 [Storable] … … 42 42 this.validTypes = new List<Type>(original.validTypes); 43 43 } 44 public override IDeepCloneable Clone(Cloner cloner) { 45 return new ConstrainedTypeValue(this, cloner); 46 } 44 47 } 45 48 … … 56 59 this.Value = value; 57 60 } 61 [StorableConstructor] 62 protected ConstrainedTypeValue(bool deserializing) : base(deserializing) { } 58 63 protected ConstrainedTypeValue(ConstrainedTypeValue original, Cloner cloner) : base(original, cloner) { } 59 64 public override IDeepCloneable Clone(Cloner cloner) { -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurationTree.cs
r5328 r5337 113 113 114 114 #region constructors and cloning 115 public ParameterConfigurationTree( EngineAlgorithm algorithm)115 public ParameterConfigurationTree(IAlgorithm algorithm) 116 116 : base(null, algorithm.GetType()) { 117 117 this.Optimize = true; // root must always be optimized -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs
r5313 r5337 217 217 } 218 218 219 private IEnumerable<Type> GetValidTypes(IValueParameter parameter) {219 private static IEnumerable<Type> GetValidTypes(IValueParameter parameter) { 220 220 // in case of IOperator return empty list, otherwise hundreds of types would be returned. this mostly occurs for Successor which will never be optimized 221 221 if (parameter.DataType == typeof(IOperator)) 222 222 return new List<Type>(); 223 223 224 // return only one type for ValueTypeValues<> (Int, Double, Percent, Bool). Otherwise 2 types would be returned for DoubleValue (PercentValue which is derived) 225 if (IsSubclassOfRawGeneric(typeof(ValueTypeValue<>), parameter.DataType)) 226 return new List<Type> { parameter.DataType }; 227 224 228 if (IsSubclassOfRawGeneric(typeof(OptionalConstrainedValueParameter<>), parameter.GetType())) { 229 // use existing validvalues if known 225 230 var parameterValidValues = (IEnumerable)parameter.GetType().GetProperty("ValidValues").GetValue(parameter, new object[] { }); 226 231 return parameterValidValues.Cast<object>().Select(x => x.GetType()); 227 232 } else { 228 return ApplicationManager.Manager.GetTypes(valueDataType, true); 233 // otherwise use all assignable types 234 return ApplicationManager.Manager.GetTypes(parameter.DataType, true); 229 235 } 230 236 } … … 273 279 return true; 274 280 } 275 toCheck = toCheck.BaseType; 281 toCheck = toCheck.BaseType; // baseType is null when toCheck is an Interface 282 if (toCheck == null) 283 return false; 276 284 } 277 285 return false; -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/DoubleValueRange.cs
r5207 r5337 29 29 } 30 30 31 public void ApplyStepSize(DoubleValue value) {32 value.Value = ((int)Math.Round(value.Value / this.StepSize.Value, 0)) * this.StepSize.Value;31 public double ApplyStepSize(double value) { 32 return (Math.Round(value / this.StepSize.Value, 0)) * this.StepSize.Value; 33 33 } 34 34 … … 44 44 solutions.Add(new DoubleValue(value)); 45 45 value += StepSize.Value; 46 value = ApplyStepSize(value); 46 47 } 47 48 return solutions; -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/IntValueRange.cs
r5207 r5337 29 29 } 30 30 31 public void ApplyStepSize(IntValuevalue) {32 value.Value = ((int)Math.Round(value.Value / (double)this.StepSize.Value, 0)) * this.StepSize.Value;31 public int ApplyStepSize(int value) { 32 return ((int)Math.Round(value / (double)this.StepSize.Value, 0)) * this.StepSize.Value; 33 33 } 34 34 -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/PercentValueRange.cs
r5207 r5337 33 33 } 34 34 35 public void ApplyStepSize(PercentValue value) {36 value.Value = ((int)Math.Round(value.Value / this.StepSize.Value, 0)) * this.StepSize.Value;35 public double ApplyStepSize(double value) { 36 return ((int)Math.Round(value / this.StepSize.Value, 0)) * this.StepSize.Value; 37 37 } 38 38 … … 48 48 solutions.Add(new PercentValue(value)); 49 49 value += StepSize.Value; 50 value = ApplyStepSize(value); 50 51 } 51 52 return solutions; -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/AlgorithmExecutor.cs
r5281 r5337 11 11 /// </summary> 12 12 public class AlgorithmExecutor { 13 private EngineAlgorithm algorithm;13 private IAlgorithm algorithm; 14 14 private AutoResetEvent waitHandle = new AutoResetEvent(false); 15 15 16 public AlgorithmExecutor( EngineAlgorithm algorithm) {16 public AlgorithmExecutor(IAlgorithm algorithm) { 17 17 this.algorithm = algorithm; 18 18 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/ParameterConfigurationEvaluator.cs
r5313 r5337 30 30 get { return (ILookupParameter<TypeValue>)Parameters[MetaOptimizationProblem.AlgorithmTypeParameterName]; } 31 31 } 32 public ILookupParameter<IItemList<I SingleObjectiveProblem>> ProblemsParameter {33 get { return (ILookupParameter<IItemList<I SingleObjectiveProblem>>)Parameters[MetaOptimizationProblem.ProblemsParameterName]; }32 public ILookupParameter<IItemList<IProblem>> ProblemsParameter { 33 get { return (ILookupParameter<IItemList<IProblem>>)Parameters[MetaOptimizationProblem.ProblemsParameterName]; } 34 34 } 35 35 public ILookupParameter<ParameterConfigurationTree> ParameterConfigurationParameter { … … 58 58 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The evaluated quality of the ParameterVector.")); 59 59 Parameters.Add(new LookupParameter<TypeValue>(MetaOptimizationProblem.AlgorithmTypeParameterName, "Missing description.")); 60 Parameters.Add(new LookupParameter<IItemList<I SingleObjectiveProblem>>(MetaOptimizationProblem.ProblemsParameterName, "Missing description."));60 Parameters.Add(new LookupParameter<IItemList<IProblem>>(MetaOptimizationProblem.ProblemsParameterName, "Missing description.")); 61 61 Parameters.Add(new LookupParameter<ParameterConfigurationTree>("ParameterConfigurationTree", "Missing description.")); 62 62 Parameters.Add(new LookupParameter<IntValue>(MetaOptimizationProblem.RepetitionsParameterName, "Number of evaluations on one problem.")); … … 77 77 public override IOperation Apply() { 78 78 ParameterConfigurationTree parameterConfiguration = ParameterConfigurationParameter.ActualValue; 79 EngineAlgorithm algorithm = (EngineAlgorithm)Activator.CreateInstance(AlgorithmTypeParameter.ActualValue.Value);80 IItemList<I SingleObjectiveProblem> problems = ProblemsParameter.ActualValue;79 IAlgorithm algorithm = (IAlgorithm)Activator.CreateInstance(AlgorithmTypeParameter.ActualValue.Value); 80 IItemList<IProblem> problems = ProblemsParameter.ActualValue; 81 81 ItemDictionary<StringValue, RunCollection> runsCache = ResultsParameter.ActualValue.ContainsKey("Runs") ? (ItemDictionary<StringValue, RunCollection>)ResultsParameter.ActualValue["Runs"].Value : null; 82 82 double[] referenceQualities = GetReferenceQualities(problems); … … 113 113 } 114 114 115 private double[] GetReferenceQualities(IItemList<I SingleObjectiveProblem> problems) {115 private double[] GetReferenceQualities(IItemList<IProblem> problems) { 116 116 double[] referenceQualities; 117 117 if (ProblemQualityReferencesParameter.ActualValue == null) { … … 127 127 } 128 128 129 private RunCollection ExecuteAlgorithm(ParameterConfigurationTree parameterConfiguration, EngineAlgorithm algorithm, IItemList<ISingleObjectiveProblem> problems) {130 EngineAlgorithm algorithmClone = (EngineAlgorithm)algorithm.Clone();129 private RunCollection ExecuteAlgorithm(ParameterConfigurationTree parameterConfiguration, IAlgorithm algorithm, IItemList<IProblem> problems) { 130 IAlgorithm algorithmClone = (IAlgorithm)algorithm.Clone(); 131 131 132 132 // set parameters … … 134 134 algorithmClone.StoreAlgorithmInEachRun = false; 135 135 136 algorithmClone.Engine = new SequentialEngine.SequentialEngine(); 136 if (algorithmClone is EngineAlgorithm) { 137 ((EngineAlgorithm)algorithmClone).Engine = new SequentialEngine.SequentialEngine(); 138 } 137 139 algorithmClone.Prepare(true); 138 140 139 foreach (I SingleObjectiveProblem problem in problems) {141 foreach (IProblem problem in problems) { 140 142 algorithmClone.Problem = (IProblem)problem.Clone(); 141 143 -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/MetaOptimizationProblem.cs
r5328 r5337 49 49 50 50 #region Parameter Properties 51 public IValueParameter<ConstrainedTypeValue< EngineAlgorithm>> AlgorithmTypeParameter {52 get { return (ValueParameter<ConstrainedTypeValue< EngineAlgorithm>>)Parameters[AlgorithmTypeParameterName]; }53 } 54 public IValueParameter<ConstrainedTypeValue<I SingleObjectiveProblem>> ProblemTypeParameter {55 get { return (ValueParameter<ConstrainedTypeValue<I SingleObjectiveProblem>>)Parameters[ProblemTypeParameterName]; }56 } 57 public IValueParameter<ConstrainedItemList<I SingleObjectiveProblem>> ProblemsParameter {58 get { return (ValueParameter<ConstrainedItemList<I SingleObjectiveProblem>>)Parameters[ProblemsParameterName]; }51 public IValueParameter<ConstrainedTypeValue<IAlgorithm>> AlgorithmTypeParameter { 52 get { return (ValueParameter<ConstrainedTypeValue<IAlgorithm>>)Parameters[AlgorithmTypeParameterName]; } 53 } 54 public IValueParameter<ConstrainedTypeValue<IProblem>> ProblemTypeParameter { 55 get { return (ValueParameter<ConstrainedTypeValue<IProblem>>)Parameters[ProblemTypeParameterName]; } 56 } 57 public IValueParameter<ConstrainedItemList<IProblem>> ProblemsParameter { 58 get { return (ValueParameter<ConstrainedItemList<IProblem>>)Parameters[ProblemsParameterName]; } 59 59 } 60 60 public IValueParameter<ParameterConfigurationTree> ParameterConfigurationTreeParameter { … … 75 75 76 76 #region Properties 77 public EngineAlgorithm Algorithm {77 public IAlgorithm Algorithm { 78 78 get { return CreateAlgorithm(AlgorithmType.Value, ProblemType.Value); } 79 79 } 80 public ConstrainedTypeValue< EngineAlgorithm> AlgorithmType {80 public ConstrainedTypeValue<IAlgorithm> AlgorithmType { 81 81 get { return AlgorithmTypeParameter.Value; } 82 82 set { AlgorithmTypeParameter.Value = value; } 83 83 } 84 public ConstrainedTypeValue<I SingleObjectiveProblem> ProblemType {84 public ConstrainedTypeValue<IProblem> ProblemType { 85 85 get { return ProblemTypeParameter.Value; } 86 86 set { ProblemTypeParameter.Value = value; } 87 87 } 88 public ConstrainedItemList<I SingleObjectiveProblem> Problems {88 public ConstrainedItemList<IProblem> Problems { 89 89 get { return ProblemsParameter.Value; } 90 90 set { ProblemsParameter.Value = value; } … … 111 111 public MetaOptimizationProblem() 112 112 : base() { 113 Parameters.Add(new ValueParameter<ConstrainedTypeValue< EngineAlgorithm>>(AlgorithmTypeParameterName, "The algorithm which's parameters should be optimized.", new ConstrainedTypeValue<EngineAlgorithm>(typeof(GeneticAlgorithm))));114 Parameters.Add(new ValueParameter<ConstrainedTypeValue<I SingleObjectiveProblem>>(ProblemTypeParameterName, "The problem type.", new ConstrainedTypeValue<ISingleObjectiveProblem>(typeof(SingleObjectiveTestFunctionProblem))));115 Parameters.Add(new ValueParameter<ConstrainedItemList<I SingleObjectiveProblem>>(ProblemsParameterName, "The problems that should be evaluated.", new ConstrainedItemList<ISingleObjectiveProblem>()));113 Parameters.Add(new ValueParameter<ConstrainedTypeValue<IAlgorithm>>(AlgorithmTypeParameterName, "The algorithm which's parameters should be optimized.", new ConstrainedTypeValue<IAlgorithm>(typeof(GeneticAlgorithm)))); 114 Parameters.Add(new ValueParameter<ConstrainedTypeValue<IProblem>>(ProblemTypeParameterName, "The problem type.", new ConstrainedTypeValue<IProblem>())); 115 Parameters.Add(new ValueParameter<ConstrainedItemList<IProblem>>(ProblemsParameterName, "The problems that should be evaluated.", new ConstrainedItemList<IProblem>())); 116 116 Parameters.Add(new ValueParameter<ParameterConfigurationTree>(ParameterConfigurationTreeParameterName, "Tree of algorithm parameters that should be optimized.")); 117 117 Parameters.Add(new ValueParameter<IntValue>(RepetitionsParameterName, "The number of evaluations for each problem.", new IntValue(3))); … … 137 137 ParameterizeOperators(); 138 138 139 ProblemTypeParameter_ValueChanged(this, EventArgs.Empty);139 AlgorithmTypeParameter_ValueChanged(this, EventArgs.Empty); 140 140 } 141 141 … … 222 222 223 223 private void AlgorithmType_ValueChanged(object sender, EventArgs e) { 224 IAlgorithm instance = (IAlgorithm)Activator.CreateInstance(AlgorithmType.Value); 225 this.ProblemType.ValidTypes = ApplicationManager.Manager.GetTypes(instance.ProblemType, true).ToList(); 226 this.ProblemType.Value = this.ProblemType.ValidTypes.First(); 224 227 ParameterConfigurationTreeParameter.ActualValue = new ParameterConfigurationTree(CreateAlgorithm(AlgorithmType.Value, ProblemType.Value)); 225 228 } … … 236 239 #endregion 237 240 238 private EngineAlgorithm CreateAlgorithm(Type algorithmType, Type problemType) {239 EngineAlgorithm algorithm = (EngineAlgorithm)Activator.CreateInstance(algorithmType);241 private IAlgorithm CreateAlgorithm(Type algorithmType, Type problemType) { 242 IAlgorithm algorithm = (IAlgorithm)Activator.CreateInstance(algorithmType); 240 243 algorithm.Problem = (IProblem)Activator.CreateInstance(problemType); 241 244 return algorithm; 242 245 } 243 246 244 public void ImportAlgorithm( EngineAlgorithm algorithm) {247 public void ImportAlgorithm(IAlgorithm algorithm) { 245 248 AlgorithmType.Value = algorithm.GetType(); 246 if (algorithm.Problem != null) ProblemType.Value = algorithm.Problem.GetType();249 if (algorithm.Problem != null) ProblemType.Value = algorithm.Problem.GetType(); 247 250 ParameterConfigurationTreeParameter.ActualValue = new ParameterConfigurationTree(algorithm); 248 if (algorithm.Problem != null) Problems.Add((ISingleObjectiveProblem)algorithm.Problem);251 if (algorithm.Problem != null) Problems.Add((IProblem)algorithm.Problem); 249 252 } 250 253 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Crossovers/AverageDoubleValueCrossover.cs
r5277 r5337 34 34 public static void ApplyStatic(IRandom random, DoubleValue value, DoubleValue other, DoubleValueRange range) { 35 35 value.Value = (value.Value + other.Value) / 2; 36 range.ApplyStepSize(value);36 value.Value = range.ApplyStepSize(value.Value); 37 37 } 38 38 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Crossovers/NormalDoubleValueCrossover.cs
r5293 r5337 39 39 do { 40 40 offspring.Value = N.NextDouble(); 41 range.ApplyStepSize(offspring);41 offspring.Value = range.ApplyStepSize(offspring.Value); 42 42 } while (!range.IsInRange(offspring.Value)); 43 43 return offspring; -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Crossovers/NormalIntValueCrossover.cs
r5293 r5337 38 38 do { 39 39 offspring.Value = (int)N.NextDouble(); 40 range.ApplyStepSize(offspring);40 offspring.Value = range.ApplyStepSize(offspring.Value); 41 41 } while (!range.IsInRange(offspring.Value)); 42 42 return offspring; -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Manipulators/NormalDoubleValueManipulator.cs
r5293 r5337 45 45 NormalAllPositionsManipulator.Apply(random, vector, strategy); 46 46 value.Value = vector[0]; 47 range.ApplyStepSize(value);47 value.Value = range.ApplyStepSize(value.Value); 48 48 ok = range.IsInRange(value.Value); 49 49 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Manipulators/NormalIntValueManipulator.cs
r5293 r5337 47 47 NormalAllPositionsManipulator.Apply(random, vector, strategy); 48 48 value.Value = (int)vector[0]; 49 range.ApplyStepSize(value);49 value.Value = range.ApplyStepSize(value.Value); 50 50 ok = range.IsInRange(value.Value); 51 51 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Manipulators/UniformDoubleValueManipulator.cs
r5207 r5337 47 47 UniformOnePositionManipulator.Apply(random, vector, bounds); 48 48 value.Value = vector[0]; 49 range.ApplyStepSize(value);49 value.Value = range.ApplyStepSize(value.Value); 50 50 ok = range.IsInRange(value.Value); 51 51 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Manipulators/UniformIntValueManipulator.cs
r5207 r5337 45 45 UniformOnePositionManipulator.Apply(random, vector, range.LowerBound, new IntValue(range.UpperBound.Value + 1)); 46 46 value.Value = vector[0]; 47 range.ApplyStepSize(value);47 value.Value = range.ApplyStepSize(value.Value); 48 48 ok = range.IsInRange(value.Value); 49 49 }
Note: See TracChangeset
for help on using the changeset viewer.