Changeset 3413
- Timestamp:
- 04/19/10 17:33:12 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 3 deleted
- 7 edited
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab 3.3.sln
r3384 r3413 30 30 EndProject 31 31 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Operators.Programmable-3.3", "HeuristicLab.Operators.Programmable\3.3\HeuristicLab.Operators.Programmable-3.3.csproj", "{6A5F8C2D-B0C3-4B36-BC20-9B1A91EE6DB6}" 32 EndProject33 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Selection.OffspringSelection-3.3", "HeuristicLab.Selection.OffspringSelection\3.3\HeuristicLab.Selection.OffspringSelection-3.3.csproj", "{81609E8A-9757-4865-8B89-0B6603F769E8}"34 32 EndProject 35 33 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.ThreadParallelEngine-3.3", "HeuristicLab.ThreadParallelEngine\3.3\HeuristicLab.ThreadParallelEngine-3.3.csproj", "{C2E99CCE-9FB0-456F-9BA0-57900E4AA799}" … … 77 75 {4ABA047D-46DD-4608-9E4A-41C5F92FDBB1} = {4ABA047D-46DD-4608-9E4A-41C5F92FDBB1} 78 76 {70DFD984-B1D9-46FE-8EB7-4DE92D71A9FC} = {70DFD984-B1D9-46FE-8EB7-4DE92D71A9FC} 79 {81609E8A-9757-4865-8B89-0B6603F769E8} = {81609E8A-9757-4865-8B89-0B6603F769E8}80 77 {8FA6898D-E4B0-4E08-A6D6-F9F520E7959F} = {8FA6898D-E4B0-4E08-A6D6-F9F520E7959F} 81 78 {D767C38D-8014-46B0-9A32-03A3AECCE34A} = {D767C38D-8014-46B0-9A32-03A3AECCE34A} … … 415 412 {6A5F8C2D-B0C3-4B36-BC20-9B1A91EE6DB6}.Services|x64.ActiveCfg = Release|x64 416 413 {6A5F8C2D-B0C3-4B36-BC20-9B1A91EE6DB6}.Services|x86.ActiveCfg = Release|x86 417 {81609E8A-9757-4865-8B89-0B6603F769E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU418 {81609E8A-9757-4865-8B89-0B6603F769E8}.Debug|Any CPU.Build.0 = Debug|Any CPU419 {81609E8A-9757-4865-8B89-0B6603F769E8}.Debug|x64.ActiveCfg = Debug|x64420 {81609E8A-9757-4865-8B89-0B6603F769E8}.Debug|x64.Build.0 = Debug|x64421 {81609E8A-9757-4865-8B89-0B6603F769E8}.Debug|x86.ActiveCfg = Debug|x86422 {81609E8A-9757-4865-8B89-0B6603F769E8}.Release|Any CPU.ActiveCfg = Release|Any CPU423 {81609E8A-9757-4865-8B89-0B6603F769E8}.Release|Any CPU.Build.0 = Release|Any CPU424 {81609E8A-9757-4865-8B89-0B6603F769E8}.Release|x64.ActiveCfg = Release|x64425 {81609E8A-9757-4865-8B89-0B6603F769E8}.Release|x64.Build.0 = Release|x64426 {81609E8A-9757-4865-8B89-0B6603F769E8}.Release|x86.ActiveCfg = Release|x86427 {81609E8A-9757-4865-8B89-0B6603F769E8}.Release|x86.Build.0 = Release|x86428 {81609E8A-9757-4865-8B89-0B6603F769E8}.Services|Any CPU.ActiveCfg = Release|Any CPU429 {81609E8A-9757-4865-8B89-0B6603F769E8}.Services|Any CPU.Build.0 = Release|Any CPU430 {81609E8A-9757-4865-8B89-0B6603F769E8}.Services|x64.ActiveCfg = Release|x64431 {81609E8A-9757-4865-8B89-0B6603F769E8}.Services|x64.Build.0 = Release|x64432 {81609E8A-9757-4865-8B89-0B6603F769E8}.Services|x86.ActiveCfg = Release|x86433 {81609E8A-9757-4865-8B89-0B6603F769E8}.Services|x86.Build.0 = Release|x86434 414 {C2E99CCE-9FB0-456F-9BA0-57900E4AA799}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 435 415 {C2E99CCE-9FB0-456F-9BA0-57900E4AA799}.Debug|Any CPU.Build.0 = Debug|Any CPU -
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs
r3379 r3413 362 362 private void ParameterizeComparisonFactorModifiers() { 363 363 foreach (IDiscreteDoubleValueModifier modifier in comparisonFactorModifiers) { 364 modifier.IndexParameter.ActualName = "Generations"; // FIXME: hmmm, not so good, this variable is defined within the main loop364 modifier.IndexParameter.ActualName = "Generations"; 365 365 modifier.EndIndexParameter.ActualName = MaximumGenerationsParameter.Name; 366 366 modifier.EndValueParameter.ActualName = ComparisonFactorUpperBoundParameter.Name; 367 367 modifier.StartIndexParameter.Value = new IntValue(0); 368 368 modifier.StartValueParameter.ActualName = ComparisonFactorLowerBoundParameter.Name; 369 modifier.ValueParameter.ActualName = "ComparisonFactor"; // FIXME: hmmm, not so good, this variable is defined within the main loop369 modifier.ValueParameter.ActualName = "ComparisonFactor"; 370 370 } 371 371 } … … 386 386 private void UpdateComparisonFactorModifiers() { 387 387 IDiscreteDoubleValueModifier oldModifier = ComparisonFactorModifier; 388 if (oldModifier == null) oldModifier = new LinearDiscreteDoubleValueModifier(); 389 388 390 ComparisonFactorModifierParameter.ValidValues.Clear(); 389 391 foreach (IDiscreteDoubleValueModifier modifier in comparisonFactorModifiers) 390 392 ComparisonFactorModifierParameter.ValidValues.Add(modifier); 391 if (oldModifier != null) { 392 IDiscreteDoubleValueModifier modifier = ComparisonFactorModifierParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldModifier.GetType()); 393 if (modifier != null) ComparisonFactorModifierParameter.Value = modifier; 394 } else if (ComparisonFactorModifierParameter.ValidValues.Count > 0) ComparisonFactorModifierParameter.Value = ComparisonFactorModifierParameter.ValidValues.First(); 393 394 IDiscreteDoubleValueModifier mod = ComparisonFactorModifierParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldModifier.GetType()); 395 if (mod != null) ComparisonFactorModifierParameter.Value = mod; 395 396 } 396 397 private void UpdateCrossovers() { -
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithmMainLoop.cs
r3379 r3413 152 152 ConditionalBranch osBeforeMutationBranch = new ConditionalBranch(); 153 153 Placeholder evaluator1 = new Placeholder(); 154 ParentsQualityComparator qualityComparer1 = newParentsQualityComparator();154 WeightedParentsQualityComparator qualityComparer1 = new WeightedParentsQualityComparator(); 155 155 StochasticBranch mutationBranch1 = new StochasticBranch(); 156 156 Placeholder mutator1 = new Placeholder(); … … 159 159 Placeholder mutator2 = new Placeholder(); 160 160 Placeholder evaluator3 = new Placeholder(); 161 ParentsQualityComparator qualityComparer2 = newParentsQualityComparator();161 WeightedParentsQualityComparator qualityComparer2 = new WeightedParentsQualityComparator(); 162 162 SubScopesRemover subScopesRemover = new SubScopesRemover(); 163 ConditionalSelector conditionalSelector = new ConditionalSelector(); 163 164 OffspringSelector offspringSelector = new OffspringSelector(); 164 165 SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor(); … … 281 282 subScopesRemover.RemoveAllSubScopes = true; 282 283 284 conditionalSelector.CopySelected = new BoolValue(false); 285 conditionalSelector.ConditionParameter.ActualName = "SuccessfulOffspring"; 286 283 287 offspringSelector.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio"; 284 288 offspringSelector.LuckyLosersParameter.ActualName = "OSLuckyLosers"; … … 286 290 offspringSelector.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name; 287 291 offspringSelector.SelectionPressureParameter.ActualName = "SelectionPressure"; 288 offspringSelector.SuccessfulOffspringParameter.ActualName = "SuccessfulOffspring";289 292 offspringSelector.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name; 290 293 offspringSelector.WinnersParameter.ActualName = "OSWinners"; … … 369 372 childrenCreator.Successor = uniformSubScopesProcessor; 370 373 uniformSubScopesProcessor.Operator = crossover; 371 uniformSubScopesProcessor.Successor = null;374 uniformSubScopesProcessor.Successor = conditionalSelector; 372 375 crossover.Successor = osBeforeMutationBranch; 373 376 osBeforeMutationBranch.TrueBranch = evaluator1; -
trunk/sources/HeuristicLab.Optimization.Operators/3.3/HeuristicLab.Optimization.Operators-3.3.csproj
r3384 r3413 81 81 </ItemGroup> 82 82 <ItemGroup> 83 <Compile Include="OffspringSelector.cs" />84 <Compile Include="ParentsQualityComparator.cs" />85 83 <Compile Include="ProbabilisticQualityComparator.cs" /> 86 84 <Compile Include="ResultsCollector.cs" /> … … 96 94 <Compile Include="SolutionsCreator.cs" /> 97 95 <Compile Include="UnidirectionalRingMigrator.cs" /> 96 <Compile Include="WeightedParentsQualityComparator.cs" /> 98 97 </ItemGroup> 99 98 <ItemGroup> -
trunk/sources/HeuristicLab.Optimization.Operators/3.3/WeightedParentsQualityComparator.cs
r3407 r3413 30 30 31 31 namespace HeuristicLab.Optimization.Operators { 32 [Item(" ParentsQualityComparator", "Compares the quality against that of its parents (assumes the parents are subscopes to the child scope). This operator works with any number of subscopes > 0.")]32 [Item("WeightedParentsQualityComparator", "Compares the quality against that of its parents (assumes the parents are subscopes to the child scope). This operator works with any number of subscopes > 0.")] 33 33 [StorableClass] 34 public class ParentsQualityComparator : SingleSuccessorOperator, ISubScopesQualityComparator {34 public class WeightedParentsQualityComparator : SingleSuccessorOperator, ISubScopesQualityComparator { 35 35 public IValueLookupParameter<BoolValue> MaximizationParameter { 36 36 get { return (IValueLookupParameter<BoolValue>)Parameters["Maximization"]; } … … 49 49 } 50 50 51 public ParentsQualityComparator()51 public WeightedParentsQualityComparator() 52 52 : base() { 53 53 Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, false otherwise")); -
trunk/sources/HeuristicLab.Parameters/3.3/HeuristicLab.Parameters-3.3.csproj
r3384 r3413 86 86 <None Include="HeuristicLabParametersPlugin.cs.frame" /> 87 87 <Compile Include="ConstrainedValueParameter.cs" /> 88 <Compile Include="SelectedSubScopesLookupParameter.cs" />89 88 <Compile Include="OptionalConstrainedValueParameter.cs" /> 90 89 <Compile Include="ValueParameter.cs" /> -
trunk/sources/HeuristicLab.Selection/3.3/ConditionalSelector.cs
r3407 r3413 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Text;25 24 using HeuristicLab.Core; 26 25 using HeuristicLab.Data; 27 26 using HeuristicLab.Selection; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Parameters; 28 29 29 namespace HeuristicLab.Scheduling.JSSP { 30 public class ConditionalSelector : SelectorBase { 31 public override string Description { 32 get { return @"TODO\r\nOperator description still missing ..."; } 30 namespace HeuristicLab.Selection { 31 [Item("ConditionalSelector", "Selects sub-scopes where a certain boolean variable is true.")] 32 [StorableClass] 33 public class ConditionalSelector : Selector { 34 public SubScopesLookupParameter<BoolValue> ConditionParameter { 35 get { return (SubScopesLookupParameter<BoolValue>)Parameters["Condition"]; } 36 } 37 public ValueParameter<BoolValue> CopySelectedParameter { 38 get { return (ValueParameter<BoolValue>)Parameters["CopySelected"]; } 39 } 40 41 public BoolValue CopySelected { 42 get { return CopySelectedParameter.Value; } 43 set { CopySelectedParameter.Value = value; } 33 44 } 34 45 35 46 public ConditionalSelector() 36 47 : base() { 37 AddVariableInfo(new VariableInfo("Condition", "Input condition", typeof(BoolData), VariableKind.In)); 48 Parameters.Add(new SubScopesLookupParameter<BoolValue>("Condition", "The boolean variable based on which the scopes are selected into a true scope-branch and a false scope-branch.")); 49 Parameters.Add(new ValueParameter<BoolValue>("CopySelected", "The parameter that decides whether the selected scopes should be copied or moved.", new BoolValue(true))); 38 50 } 39 51 40 private int GetFirstSelectedScopeIndex(IScope source) { 41 for (int i = 0; i < source.SubScopes.Count; i++) { 42 bool condition = GetVariableValue<BoolData>("Condition", source.SubScopes[i], true).Data; 43 if (condition) { 44 return i; 45 } 46 } 47 return -1; 48 } 49 50 protected override void Select(IScope source, IScope target, bool copySelected) { 51 if (copySelected) { 52 for (int i = 0; i < source.SubScopes.Count; i++) { 53 IScope selectedScope = source.SubScopes[i]; 54 bool condition = GetVariableValue<BoolData>("Condition", source.SubScopes[i], true).Data; 55 if (condition) { 56 target.AddSubScope((IScope)selectedScope.Clone()); 52 protected override IScope[] Select(List<IScope> scopes) { 53 ItemArray<BoolValue> conditions = ConditionParameter.ActualValue; 54 List<IScope> selected = new List<IScope>(); 55 if (CopySelected.Value) { 56 for (int i = 0; i < scopes.Count; i++) { 57 if (conditions[i].Value) { 58 selected.Add((IScope)scopes[i].Clone()); 57 59 } 58 60 } 59 61 } else { 60 int removeAt = GetFirstSelectedScopeIndex(source);61 while (removeAt != -1) {62 IScope selectedScope = source.SubScopes[removeAt];63 target.AddSubScope(selectedScope);64 source.RemoveSubScope(selectedScope);65 removeAt = GetFirstSelectedScopeIndex(source);62 for (int i = 0; i < scopes.Count; i++) { 63 if (conditions[i + selected.Count].Value) { 64 selected.Add(scopes[i]); 65 scopes.RemoveAt(i); 66 i--; 67 } 66 68 } 67 69 } 70 return selected.ToArray(); 68 71 } 69 72 } -
trunk/sources/HeuristicLab.Selection/3.3/GenderSpecificSelector.cs
r3404 r3413 36 36 [StorableClass] 37 37 public class GenderSpecificSelector : AlgorithmOperator, ISingleObjectiveSelector, IStochasticOperator { 38 private List<ISelector> femaleSelectors;39 private List<ISelector> maleSelectors;40 41 38 #region Parameters 42 39 public IValueLookupParameter<BoolValue> MaximizationParameter { … … 55 52 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } 56 53 } 57 public ConstrainedValueParameter<ISelector> FemaleSelectorParameter {58 get { return ( ConstrainedValueParameter<ISelector>)Parameters["FemaleSelector"]; }54 public ValueParameter<ISelector> FemaleSelectorParameter { 55 get { return (ValueParameter<ISelector>)Parameters["FemaleSelector"]; } 59 56 } 60 public ConstrainedValueParameter<ISelector> MaleSelectorParameter {61 get { return ( ConstrainedValueParameter<ISelector>)Parameters["MaleSelector"]; }57 public ValueParameter<ISelector> MaleSelectorParameter { 58 get { return (ValueParameter<ISelector>)Parameters["MaleSelector"]; } 62 59 } 63 60 #endregion … … 96 93 Parameters.Add(new ValueLookupParameter<BoolValue>("CopySelected", "True if the scopes should be copied, false if they should be moved.", new BoolValue(true))); 97 94 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use.")); 98 Parameters.Add(new ConstrainedValueParameter<ISelector>("FemaleSelector", "The selection operator to select the first parent."));99 Parameters.Add(new ConstrainedValueParameter<ISelector>("MaleSelector", "The selection operator to select the second parent."));95 Parameters.Add(new ValueParameter<ISelector>("FemaleSelector", "The selection operator to select the first parent.")); 96 Parameters.Add(new ValueParameter<ISelector>("MaleSelector", "The selection operator to select the second parent.")); 100 97 #endregion 101 98 … … 140 137 } 141 138 139 #region Events 140 private void SelectorParameter_ValueChanged(object sender, EventArgs e) { 141 IValueParameter<ISelector> selectorParam = (sender as IValueParameter<ISelector>); 142 if (selectorParam != null) 143 ParameterizeSelector(selectorParam.Value); 144 } 145 #endregion 146 142 147 #region Helpers 143 148 [StorableHook(HookType.AfterDeserialization)] 144 149 private void Initialize() { 145 InitializeSelectors(); 146 UpdateSelectors(); 150 FemaleSelectorParameter.ValueChanged += new EventHandler(SelectorParameter_ValueChanged); 151 MaleSelectorParameter.ValueChanged += new EventHandler(SelectorParameter_ValueChanged); 152 if (FemaleSelector == null) FemaleSelector = new ProportionalSelector(); 153 if (MaleSelector == null) MaleSelector = new RandomSelector(); 147 154 } 148 149 private void InitializeSelectors() { 150 femaleSelectors = new List<ISelector>(); 151 maleSelectors = new List<ISelector>(); 152 IEnumerable<Type> types = ApplicationManager.Manager.GetTypes(typeof(ISelector)).OrderBy(x => x.FullName); 153 foreach (Type type in types) { 154 if (type != typeof(IMultiObjectiveSelector) && type != typeof(GenderSpecificSelector)) { 155 femaleSelectors.Add((ISelector)Activator.CreateInstance(type)); 156 maleSelectors.Add((ISelector)Activator.CreateInstance(type)); 157 } 155 private void ParameterizeSelector(ISelector selector) { 156 selector.CopySelected = new BoolValue(true); 157 IStochasticOperator stoOp = (selector as IStochasticOperator); 158 if (stoOp != null) stoOp.RandomParameter.ActualName = RandomParameter.Name; 159 ISingleObjectiveSelector soSelector = (selector as ISingleObjectiveSelector); 160 if (soSelector != null) { 161 soSelector.MaximizationParameter.ActualName = MaximizationParameter.Name; 162 soSelector.QualityParameter.ActualName = QualityParameter.Name; 158 163 } 159 ParameterizeSelectors(femaleSelectors);160 ParameterizeSelectors(maleSelectors);161 }162 private void ParameterizeSelectors(List<ISelector> selectors) {163 foreach (ISelector selector in selectors) {164 selector.CopySelected = new BoolValue(true);165 }166 foreach (IStochasticOperator op in selectors.OfType<IStochasticOperator>()) {167 op.RandomParameter.ActualName = RandomParameter.Name;168 }169 foreach (ISingleObjectiveSelector selector in selectors.OfType<ISingleObjectiveSelector>()) {170 selector.MaximizationParameter.ActualName = MaximizationParameter.Name;171 selector.QualityParameter.ActualName = QualityParameter.Name;172 }173 }174 private void UpdateSelectors() {175 ISelector oldFemaleSelector = FemaleSelector;176 FemaleSelectorParameter.ValidValues.Clear();177 foreach (ISelector selector in femaleSelectors)178 FemaleSelectorParameter.ValidValues.Add(selector);179 if (oldFemaleSelector == null) oldFemaleSelector = new ProportionalSelector();180 ISelector femaleSelector = FemaleSelectorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldFemaleSelector.GetType());181 if (femaleSelector != null) FemaleSelectorParameter.Value = femaleSelector;182 183 ISelector oldMaleSelector = MaleSelector;184 MaleSelectorParameter.ValidValues.Clear();185 foreach (ISelector selector in maleSelectors)186 MaleSelectorParameter.ValidValues.Add(selector);187 if (oldMaleSelector == null) oldMaleSelector = new RandomSelector();188 ISelector maleSelector = MaleSelectorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMaleSelector.GetType());189 if (maleSelector != null) MaleSelectorParameter.Value = maleSelector;190 164 } 191 165 #endregion -
trunk/sources/HeuristicLab.Selection/3.3/HeuristicLab.Selection-3.3.csproj
r3404 r3413 83 83 <None Include="HeuristicLabSelectionPlugin.cs.frame" /> 84 84 <Compile Include="BestSelector.cs" /> 85 <Compile Include="ConditionalSelector.cs" /> 85 86 <Compile Include="GenderSpecificSelector.cs" /> 87 <Compile Include="OffspringSelector.cs" /> 86 88 <Compile Include="RightChildReducer.cs" /> 87 89 <Compile Include="SingleObjectiveSelector.cs" />
Note: See TracChangeset
for help on using the changeset viewer.