Changeset 2924
- Timestamp:
- 03/04/10 04:52:28 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 added
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab 3.3.sln
r2914 r2924 59 59 {1849A92E-DCFC-4E05-BB0A-D7B7A3DAFCFB} = {1849A92E-DCFC-4E05-BB0A-D7B7A3DAFCFB} 60 60 {0E27A536-1C4A-4624-A65E-DC4F4F23E3E1} = {0E27A536-1C4A-4624-A65E-DC4F4F23E3E1} 61 {446C4F3D-1A12-465A-9128-97D0F47140C9} = {446C4F3D-1A12-465A-9128-97D0F47140C9} 61 62 {678E2145-8152-4E19-9646-07D439D00301} = {678E2145-8152-4E19-9646-07D439D00301} 62 63 {BB994448-2B21-4564-BB2E-38D8FFF8CF18} = {BB994448-2B21-4564-BB2E-38D8FFF8CF18} -
trunk/sources/HeuristicLab.Algorithms.SGA/3.3/SGA.cs
r2917 r2924 52 52 get { return (ConstrainedValueParameter<ICrossover>)Parameters["Crossover"]; } 53 53 } 54 private ConstrainedValueParameter<IManipulator> MutatorParameter {55 get { return ( ConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; }54 private OptionalConstrainedValueParameter<IManipulator> MutatorParameter { 55 get { return (OptionalConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; } 56 56 } 57 57 private ValueParameter<IntData> ElitesParameter { … … 75 75 Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.")); 76 76 Parameters.Add(new ValueParameter<DoubleData>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new DoubleData(0.05))); 77 Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));77 Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 78 78 Parameters.Add(new ValueParameter<IntData>("Elites", "The numer of elite solutions which are kept in each generation.", new IntData(1))); 79 79 Parameters.Add(new ValueParameter<IntData>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntData(1000))); -
trunk/sources/HeuristicLab.Algorithms.SGA/3.3/SGAOperator.cs
r2908 r2924 97 97 #region Create operator graph 98 98 VariableCreator variableCreator = new VariableCreator(); 99 ResultsCollector resultsCollector 1= new ResultsCollector();99 ResultsCollector resultsCollector = new ResultsCollector(); 100 100 SubScopesSorter subScopesSorter1 = new SubScopesSorter(); 101 101 Placeholder selector = new Placeholder(); … … 116 116 Comparator comparator = new Comparator(); 117 117 BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator = new BestAverageWorstQualityCalculator(); 118 ResultsCollector resultsCollector2 = new ResultsCollector();119 118 DataTableValuesCollector dataTableValuesCollector = new DataTableValuesCollector(); 120 119 ConditionalBranch conditionalBranch = new ConditionalBranch(); … … 122 121 OperatorGraph.InitialOperator = variableCreator; 123 122 123 variableCreator.CollectedValues.Add(new ValueParameter<IntData>("Generations", new IntData(0))); 124 variableCreator.CollectedValues.Add(new ValueParameter<DoubleData>("Best Quality", new DoubleData(0))); 125 variableCreator.CollectedValues.Add(new ValueParameter<DoubleData>("Average Quality", new DoubleData(0))); 126 variableCreator.CollectedValues.Add(new ValueParameter<DoubleData>("Worst Quality", new DoubleData(0))); 124 127 variableCreator.CollectedValues.Add(new ValueParameter<DataTable>("Qualities", new DataTable("Qualities"))); 125 variableCreator.Successor = resultsCollector1; 126 127 LookupParameter<DataTable> qualities = new LookupParameter<DataTable>("Qualities"); 128 qualities.ActualName = "Qualities"; 129 resultsCollector1.CollectedValues.Add(qualities); 130 resultsCollector1.ResultsParameter.ActualName = "Results"; 131 resultsCollector1.Successor = subScopesSorter1; 128 variableCreator.Successor = resultsCollector; 129 130 resultsCollector.CollectedValues.Add(new LookupParameter<IntData>("Generations")); 131 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleData>("Best Quality")); 132 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleData>("Average Quality")); 133 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleData>("Worst Quality")); 134 resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Qualities")); 135 resultsCollector.ResultsParameter.ActualName = "Results"; 136 resultsCollector.Successor = subScopesSorter1; 132 137 133 138 subScopesSorter1.DescendingParameter.ActualName = "Maximization"; … … 196 201 comparator.Successor = bestAverageWorstQualityCalculator; 197 202 198 bestAverageWorstQualityCalculator.AverageQualityParameter.ActualName = "Average Quality";199 bestAverageWorstQualityCalculator.BestQualityParameter.ActualName = "Best Quality";203 bestAverageWorstQualityCalculator.AverageQualityParameter.ActualName = "Average Quality"; 204 bestAverageWorstQualityCalculator.BestQualityParameter.ActualName = "Best Quality"; 200 205 bestAverageWorstQualityCalculator.MaximizationParameter.ActualName = "Maximization"; 201 206 bestAverageWorstQualityCalculator.QualityParameter.ActualName = "Quality"; 202 bestAverageWorstQualityCalculator.WorstQualityParameter.ActualName = "Worst Quality";207 bestAverageWorstQualityCalculator.WorstQualityParameter.ActualName = "Worst Quality"; 203 208 bestAverageWorstQualityCalculator.Successor = dataTableValuesCollector; 204 209 205 LookupParameter<DoubleData> bestQuality = new LookupParameter<DoubleData>("BestQuality"); 206 bestQuality.ActualName = "BestQuality"; 207 dataTableValuesCollector.CollectedValues.Add(bestQuality); 208 LookupParameter<DoubleData> averageQuality = new LookupParameter<DoubleData>("AverageQuality"); 209 averageQuality.ActualName = "AverageQuality"; 210 dataTableValuesCollector.CollectedValues.Add(averageQuality); 211 LookupParameter<DoubleData> worstQuality = new LookupParameter<DoubleData>("WorstQuality"); 212 worstQuality.ActualName = "WorstQuality"; 213 dataTableValuesCollector.CollectedValues.Add(worstQuality); 210 dataTableValuesCollector.CollectedValues.Add(new LookupParameter<DoubleData>("Best Quality")); 211 dataTableValuesCollector.CollectedValues.Add(new LookupParameter<DoubleData>("Average Quality")); 212 dataTableValuesCollector.CollectedValues.Add(new LookupParameter<DoubleData>("Worst Quality")); 214 213 dataTableValuesCollector.DataTableParameter.ActualName = "Qualities"; 215 dataTableValuesCollector.Successor = resultsCollector2; 216 217 bestQuality = new LookupParameter<DoubleData>("BestQuality"); 218 bestQuality.ActualName = "BestQuality"; 219 resultsCollector2.CollectedValues.Add(bestQuality); 220 averageQuality = new LookupParameter<DoubleData>("AverageQuality"); 221 averageQuality.ActualName = "AverageQuality"; 222 resultsCollector2.CollectedValues.Add(averageQuality); 223 worstQuality = new LookupParameter<DoubleData>("WorstQuality"); 224 worstQuality.ActualName = "WorstQuality"; 225 resultsCollector2.CollectedValues.Add(worstQuality); 226 resultsCollector2.ResultsParameter.ActualName = "Results"; 227 resultsCollector2.Successor = conditionalBranch; 214 dataTableValuesCollector.Successor = conditionalBranch; 228 215 229 216 conditionalBranch.ConditionParameter.ActualName = "Terminate"; -
trunk/sources/HeuristicLab.Analysis/3.3/BestAverageWorstQualityCalculator.cs
r2891 r2924 76 76 max = temp; 77 77 } 78 BestQualityParameter.ActualValue = new DoubleData(max); 79 AverageQualityParameter.ActualValue = new DoubleData(sum / qualities.Length); 80 WorstQualityParameter.ActualValue = new DoubleData(min); 78 79 DoubleData best = BestQualityParameter.ActualValue; 80 if (best == null) BestQualityParameter.ActualValue = new DoubleData(max); 81 else best.Value = max; 82 DoubleData average = AverageQualityParameter.ActualValue; 83 if (average == null) AverageQualityParameter.ActualValue = new DoubleData(sum / qualities.Length); 84 else average.Value = sum / qualities.Length; 85 DoubleData worst = WorstQualityParameter.ActualValue; 86 if (worst == null) WorstQualityParameter.ActualValue = new DoubleData(min); 87 else worst.Value = min; 81 88 } 82 89 return base.Apply(); -
trunk/sources/HeuristicLab.Core.Views/3.3/CreateParameterDialog.Designer.cs
r2796 r2924 162 162 | System.Windows.Forms.AnchorStyles.Left) 163 163 | System.Windows.Forms.AnchorStyles.Right))); 164 this.parameterTypeSelector.Caption = "Available &Parameters";164 this.parameterTypeSelector.Caption = "Available Parameters"; 165 165 this.parameterTypeSelector.Location = new System.Drawing.Point(12, 12); 166 166 this.parameterTypeSelector.Name = "parameterTypeSelector"; -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.Designer.cs
r2796 r2924 158 158 this.detailsGroupBox.TabIndex = 0; 159 159 this.detailsGroupBox.TabStop = false; 160 this.detailsGroupBox.Text = " &Details";160 this.detailsGroupBox.Text = "Details"; 161 161 // 162 162 // viewHost … … 180 180 this.itemsGroupBox.TabIndex = 0; 181 181 this.itemsGroupBox.TabStop = false; 182 this.itemsGroupBox.Text = " &Items";182 this.itemsGroupBox.Text = "Items"; 183 183 // 184 184 // ItemArrayView -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.Designer.cs
r2796 r2924 185 185 this.detailsGroupBox.TabIndex = 0; 186 186 this.detailsGroupBox.TabStop = false; 187 this.detailsGroupBox.Text = " &Details";187 this.detailsGroupBox.Text = "Details"; 188 188 // 189 189 // viewHost … … 207 207 this.itemsGroupBox.TabIndex = 0; 208 208 this.itemsGroupBox.TabStop = false; 209 this.itemsGroupBox.Text = " &Items";209 this.itemsGroupBox.Text = "Items"; 210 210 // 211 211 // ItemCollectionView -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs
r2917 r2924 122 122 if (!listViewItem.Text.Equals(listViewItem.Tag.ToString())) { 123 123 listViewItem.Text = listViewItem.Tag.ToString(); 124 itemsListView.Sort();125 124 } 126 125 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.Designer.cs
r2796 r2924 183 183 this.detailsGroupBox.TabIndex = 0; 184 184 this.detailsGroupBox.TabStop = false; 185 this.detailsGroupBox.Text = " &Details";185 this.detailsGroupBox.Text = "Details"; 186 186 // 187 187 // viewHost … … 205 205 this.itemsGroupBox.TabIndex = 0; 206 206 this.itemsGroupBox.TabStop = false; 207 this.itemsGroupBox.Text = " &Items";207 this.itemsGroupBox.Text = "Items"; 208 208 // 209 209 // ItemListView -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorCollectionView.cs
r2917 r2924 16 16 InitializeComponent(); 17 17 Caption = "Operator Collection"; 18 itemsGroupBox.Text = " &Operators";18 itemsGroupBox.Text = "Operators"; 19 19 } 20 20 /// <summary> … … 32 32 if (typeSelectorDialog == null) { 33 33 typeSelectorDialog = new TypeSelectorDialog(); 34 typeSelectorDialog.TypeSelector.Caption = " &Available Operators";34 typeSelectorDialog.TypeSelector.Caption = "Available Operators"; 35 35 typeSelectorDialog.TypeSelector.Configure(typeof(IOperator), false, false); 36 36 } -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorGraphView.Designer.cs
r2801 r2924 118 118 this.graphGroupBox.TabIndex = 0; 119 119 this.graphGroupBox.TabStop = false; 120 this.graphGroupBox.Text = "Operator &Graph";120 this.graphGroupBox.Text = "Operator Graph"; 121 121 // 122 122 // viewHost -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorListView.cs
r2917 r2924 16 16 InitializeComponent(); 17 17 Caption = "Operator List"; 18 itemsGroupBox.Text = " &Operators";18 itemsGroupBox.Text = "Operators"; 19 19 } 20 20 /// <summary> … … 32 32 if (typeSelectorDialog == null) { 33 33 typeSelectorDialog = new TypeSelectorDialog(); 34 typeSelectorDialog.TypeSelector.Caption = " &Available Operators";34 typeSelectorDialog.TypeSelector.Caption = "Available Operators"; 35 35 typeSelectorDialog.TypeSelector.Configure(typeof(IOperator), false, false); 36 36 } -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorSetView.cs
r2917 r2924 16 16 InitializeComponent(); 17 17 Caption = "Operator Set"; 18 itemsGroupBox.Text = " &Operators";18 itemsGroupBox.Text = "Operators"; 19 19 } 20 20 /// <summary> … … 32 32 if (typeSelectorDialog == null) { 33 33 typeSelectorDialog = new TypeSelectorDialog(); 34 typeSelectorDialog.TypeSelector.Caption = " &Available Operators";34 typeSelectorDialog.TypeSelector.Caption = "Available Operators"; 35 35 typeSelectorDialog.TypeSelector.Configure(typeof(IOperator), false, false); 36 36 } -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorsSidebar.Designer.cs
r2790 r2924 50 50 // typeSelector 51 51 // 52 this.typeSelector.Caption = " &Available Operators";52 this.typeSelector.Caption = "Available Operators"; 53 53 this.typeSelector.Dock = System.Windows.Forms.DockStyle.Fill; 54 54 this.typeSelector.Location = new System.Drawing.Point(0, 0); -
trunk/sources/HeuristicLab.Core.Views/3.3/ParameterCollectionView.cs
r2917 r2924 37 37 InitializeComponent(); 38 38 Caption = "ParameterCollection"; 39 itemsGroupBox.Text = " &Parameters";39 itemsGroupBox.Text = "Parameters"; 40 40 } 41 41 /// <summary> -
trunk/sources/HeuristicLab.Core.Views/3.3/ScopeListView.cs
r2917 r2924 13 13 InitializeComponent(); 14 14 Caption = "ScopeList"; 15 itemsGroupBox.Text = " &Scopes";15 itemsGroupBox.Text = "Scopes"; 16 16 } 17 17 /// <summary> -
trunk/sources/HeuristicLab.Core.Views/3.3/ScopeView.Designer.cs
r2790 r2924 104 104 this.scopesGroupBox.TabIndex = 0; 105 105 this.scopesGroupBox.TabStop = false; 106 this.scopesGroupBox.Text = " &Scopes";106 this.scopesGroupBox.Text = "Scopes"; 107 107 // 108 108 // variableCollectionView -
trunk/sources/HeuristicLab.Core.Views/3.3/TypeSelector.Designer.cs
r2790 r2924 89 89 this.typesGroupBox.TabIndex = 0; 90 90 this.typesGroupBox.TabStop = false; 91 this.typesGroupBox.Text = " &Available Types";91 this.typesGroupBox.Text = "Available Types"; 92 92 // 93 93 // splitContainer -
trunk/sources/HeuristicLab.Core.Views/3.3/TypeSelectorDialog.Designer.cs
r2790 r2924 75 75 | System.Windows.Forms.AnchorStyles.Left) 76 76 | System.Windows.Forms.AnchorStyles.Right))); 77 this.typeSelector.Caption = " &Available Types";77 this.typeSelector.Caption = "Available Types"; 78 78 this.typeSelector.Location = new System.Drawing.Point(12, 12); 79 79 this.typeSelector.Name = "typeSelector"; -
trunk/sources/HeuristicLab.Core.Views/3.3/TypeSelectorDialog.cs
r2818 r2924 51 51 public TypeSelectorDialog() { 52 52 InitializeComponent(); 53 okButton.Enabled = typeSelector.SelectedType != null; 53 54 } 54 55 -
trunk/sources/HeuristicLab.Core.Views/3.3/ValueParameterCollectionView.cs
r2917 r2924 37 37 InitializeComponent(); 38 38 Caption = "ValueParameterCollection"; 39 itemsGroupBox.Text = " &Parameters";39 itemsGroupBox.Text = "Parameters"; 40 40 } 41 41 /// <summary> -
trunk/sources/HeuristicLab.Core.Views/3.3/VariableCollectionView.cs
r2917 r2924 13 13 InitializeComponent(); 14 14 Caption = "VariableCollection"; 15 itemsGroupBox.Text = " &Variables";15 itemsGroupBox.Text = "Variables"; 16 16 } 17 17 /// <summary> -
trunk/sources/HeuristicLab.Core.Views/3.3/VariableView.Designer.cs
r2917 r2924 100 100 this.valueGroupBox.TabIndex = 7; 101 101 this.valueGroupBox.TabStop = false; 102 this.valueGroupBox.Text = " &Value:";102 this.valueGroupBox.Text = "Value"; 103 103 // 104 104 // valuePanel -
trunk/sources/HeuristicLab.Optimization/3.3/EngineAlgorithm.cs
r2917 r2924 96 96 protected EngineAlgorithm() 97 97 : base() { 98 globalScope = new Scope( );98 globalScope = new Scope("Global Scope"); 99 99 globalScope.Variables.Add(new Variable("Results", new VariableCollection())); 100 100 OperatorGraph = new OperatorGraph(); … … 103 103 protected EngineAlgorithm(string name) 104 104 : base(name) { 105 globalScope = new Scope( );105 globalScope = new Scope("Global Scope"); 106 106 globalScope.Variables.Add(new Variable("Results", new VariableCollection())); 107 107 OperatorGraph = new OperatorGraph(); … … 110 110 protected EngineAlgorithm(string name, ParameterCollection parameters) 111 111 : base(name, parameters) { 112 globalScope = new Scope( );112 globalScope = new Scope("Global Scope"); 113 113 globalScope.Variables.Add(new Variable("Results", new VariableCollection())); 114 114 OperatorGraph = new OperatorGraph(); … … 117 117 protected EngineAlgorithm(string name, string description) 118 118 : base(name, description) { 119 globalScope = new Scope( );119 globalScope = new Scope("Global Scope"); 120 120 globalScope.Variables.Add(new Variable("Results", new VariableCollection())); 121 121 OperatorGraph = new OperatorGraph(); … … 124 124 protected EngineAlgorithm(string name, string description, ParameterCollection parameters) 125 125 : base(name, description, parameters) { 126 globalScope = new Scope( );126 globalScope = new Scope("Global Scope"); 127 127 globalScope.Variables.Add(new Variable("Results", new VariableCollection())); 128 128 OperatorGraph = new OperatorGraph(); -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ConstrainedValueParameterView.Designer.cs
r2917 r2924 85 85 this.valueGroupBox.TabIndex = 6; 86 86 this.valueGroupBox.TabStop = false; 87 this.valueGroupBox.Text = " &Value:";87 this.valueGroupBox.Text = "Value"; 88 88 // 89 89 // viewHost … … 135 135 #endregion 136 136 137 pr ivateSystem.Windows.Forms.GroupBox valueGroupBox;138 pr ivateHeuristicLab.Core.Views.ViewHost viewHost;139 pr ivateSystem.Windows.Forms.ComboBox valueComboBox;137 protected System.Windows.Forms.GroupBox valueGroupBox; 138 protected HeuristicLab.Core.Views.ViewHost viewHost; 139 protected System.Windows.Forms.ComboBox valueComboBox; 140 140 } 141 141 } -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ConstrainedValueParameterView.cs
r2917 r2924 21 21 22 22 using System; 23 using System. Collections.Generic;23 using System.Linq; 24 24 using HeuristicLab.Collections; 25 25 using HeuristicLab.Core; … … 33 33 [View("ConstrainedValueParameter View")] 34 34 [Content(typeof(ConstrainedValueParameter<>), true)] 35 public sealed partial class ConstrainedValueParameterView<T> : ParameterView where T : class, IItem { 36 private List<T> valueComboBoxItems; 37 35 public partial class ConstrainedValueParameterView<T> : ParameterView where T : class, IItem { 38 36 /// <summary> 39 37 /// Gets or sets the variable to represent visually. … … 52 50 InitializeComponent(); 53 51 Caption = "ConstrainedValueParameter"; 54 valueComboBoxItems = new List<T>();55 52 } 56 53 /// <summary> … … 104 101 105 102 private void FillValueComboBox() { 106 valueComboBox Items.Clear();107 valueComboBox Items.Add(null);103 valueComboBox.SelectedIndexChanged -= new EventHandler(valueComboBox_SelectedIndexChanged); 104 valueComboBox.DataSource = null; 108 105 if (Content != null) { 109 foreach (T item in Content.ValidValues) 110 valueComboBoxItems.Add(item); 106 valueComboBox.DataSource = Content.ValidValues.ToList(); 107 valueComboBox.Enabled = valueComboBox.Items.Count > 0; 108 valueComboBox.SelectedItem = Content.Value; 111 109 } 112 valueComboBox.Items.Clear(); 113 foreach (T item in valueComboBoxItems) 114 valueComboBox.Items.Add(item == null ? "-" : item.ToString()); 115 if (Content != null) valueComboBox.SelectedIndex = valueComboBoxItems.IndexOf(Content.Value); 110 valueComboBox.SelectedIndexChanged += new EventHandler(valueComboBox_SelectedIndexChanged); 116 111 } 117 112 … … 121 116 Invoke(new EventHandler(Content_ValueChanged), sender, e); 122 117 else { 123 valueComboBox.SelectedI ndex = valueComboBoxItems.IndexOf(Content.Value);118 valueComboBox.SelectedItem = Content.Value; 124 119 viewHost.Content = Content.Value; 125 120 } … … 128 123 if (InvokeRequired) 129 124 Invoke(new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsAdded), sender, e); 130 else { 131 foreach (T item in e.Items) { 132 valueComboBoxItems.Add(item); 133 valueComboBox.Items.Add(item == null ? "-" : item.ToString()); 134 } 135 } 125 else 126 FillValueComboBox(); 136 127 } 137 128 private void ValidValues_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<T> e) { 138 129 if (InvokeRequired) 139 130 Invoke(new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsRemoved), sender, e); 140 else { 141 foreach (T item in e.Items) { 142 int index = valueComboBoxItems.IndexOf(item); 143 valueComboBoxItems.RemoveAt(index); 144 valueComboBox.Items.RemoveAt(index); 145 } 146 } 131 else 132 FillValueComboBox(); 147 133 } 148 134 private void ValidValues_CollectionReset(object sender, CollectionItemsChangedEventArgs<T> e) { … … 155 141 156 142 private void valueComboBox_SelectedIndexChanged(object sender, EventArgs e) { 157 Content.Value = valueComboBoxItems[valueComboBox.SelectedIndex];143 Content.Value = (T)valueComboBox.SelectedItem; 158 144 } 159 145 } -
trunk/sources/HeuristicLab.Parameters.Views/3.3/HeuristicLab.Parameters.Views-3.3.csproj
r2900 r2924 91 91 <Compile Include="ConstrainedValueParameterView.Designer.cs"> 92 92 <DependentUpon>ConstrainedValueParameterView.cs</DependentUpon> 93 </Compile> 94 <Compile Include="OptionalConstrainedValueParameterView.cs"> 95 <SubType>UserControl</SubType> 96 </Compile> 97 <Compile Include="OptionalConstrainedValueParameterView.Designer.cs"> 98 <DependentUpon>OptionalConstrainedValueParameterView.cs</DependentUpon> 93 99 </Compile> 94 100 <Compile Include="OptionalValueParameterView.cs"> -
trunk/sources/HeuristicLab.Parameters.Views/3.3/OptionalValueParameterView.Designer.cs
r2917 r2924 90 90 this.valueGroupBox.TabIndex = 6; 91 91 this.valueGroupBox.TabStop = false; 92 this.valueGroupBox.Text = " &Value:";92 this.valueGroupBox.Text = "Value"; 93 93 // 94 94 // valuePanel -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueLookupParameterView.Designer.cs
r2917 r2924 100 100 this.valueGroupBox.TabIndex = 8; 101 101 this.valueGroupBox.TabStop = false; 102 this.valueGroupBox.Text = " &Value:";102 this.valueGroupBox.Text = "Value"; 103 103 // 104 104 // valuePanel -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueParameterView.Designer.cs
r2917 r2924 85 85 this.valueGroupBox.TabIndex = 6; 86 86 this.valueGroupBox.TabStop = false; 87 this.valueGroupBox.Text = " &Value:";87 this.valueGroupBox.Text = "Value"; 88 88 // 89 89 // valuePanel -
trunk/sources/HeuristicLab.Parameters/3.3/ConstrainedValueParameter.cs
r2852 r2924 21 21 22 22 using System; 23 using HeuristicLab.Common; 23 using System.Linq; 24 using HeuristicLab.Collections; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 27 28 namespace HeuristicLab.Parameters { 28 29 /// <summary> 29 /// A parameter whose value has to be chosen from a set of valid values which is defined it the parameter itself.30 /// A parameter whose value has to be chosen from a set of valid values. 30 31 /// </summary> 31 [Item("ConstrainedValueParameter<T>", "A parameter whose value has to be chosen from a set of valid values which is defined it the parameter itself.")] 32 public sealed class ConstrainedValueParameter<T> : Parameter, IValueParameter<T> where T : class, IItem { 33 private ItemSet<T> validValues; 34 [Storable] 35 public ItemSet<T> ValidValues { 36 get { return validValues; } 37 private set { 38 DeregisterValidValuesEvents(); 39 validValues = value; 40 RegisterValidValuesEvents(); 32 [Item("ConstrainedValueParameter<T>", "A parameter whose value has to be chosen from a set of valid values.")] 33 [EmptyStorableClass] 34 public class ConstrainedValueParameter<T> : OptionalConstrainedValueParameter<T> where T : class, IItem { 35 public override T Value { 36 get { return base.Value; } 37 set { 38 if ((value == null) && (ValidValues.Count > 0)) throw new ArgumentNullException(); 39 base.Value = value; 41 40 } 42 41 } 43 42 44 private T value; 45 [Storable] 46 public T Value { 47 get { return this.value; } 48 set { 49 if (value != this.value) { 50 if ((value != null) && !validValues.Contains(value)) throw new ArgumentException("Invalid value."); 51 this.value = value; 52 OnValueChanged(); 53 } 54 } 43 public ConstrainedValueParameter() : base() { } 44 public ConstrainedValueParameter(string name) : base(name) { } 45 public ConstrainedValueParameter(string name, ItemSet<T> validValues) : base(name, validValues) { } 46 public ConstrainedValueParameter(string name, ItemSet<T> validValues, T value) : base(name, validValues, value) { } 47 public ConstrainedValueParameter(string name, string description) : base(name, description) { } 48 public ConstrainedValueParameter(string name, string description, ItemSet<T> validValues) : base(name, description, validValues) { } 49 public ConstrainedValueParameter(string name, string description, ItemSet<T> validValues, T value) : base(name, description, validValues, value) { } 50 51 protected override void validValues_ItemsAdded(object sender, CollectionItemsChangedEventArgs<T> e) { 52 if (Value == null) Value = ValidValues.First(); 55 53 } 56 IItem IValueParameter.Value { 57 get { return Value; } 58 set { 59 T val = value as T; 60 if ((value != null) && (val == null)) 61 throw new InvalidOperationException( 62 string.Format("Type mismatch. Value is not a \"{0}\".", 63 typeof(T).GetPrettyName()) 64 ); 65 Value = val; 66 } 54 protected override void ValidValues_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<T> e) { 55 if ((Value != null) && !ValidValues.Contains(Value)) Value = ValidValues.FirstOrDefault(); 67 56 } 68 69 public ConstrainedValueParameter() 70 : base("Anonymous", typeof(T)) { 71 ValidValues = new ItemSet<T>(); 72 } 73 public ConstrainedValueParameter(string name) 74 : base(name, typeof(T)) { 75 ValidValues = new ItemSet<T>(); 76 } 77 public ConstrainedValueParameter(string name, ItemSet<T> validValues) 78 : base(name, typeof(T)) { 79 ValidValues = validValues; 80 } 81 public ConstrainedValueParameter(string name, ItemSet<T> validValues, T value) 82 : base(name, typeof(T)) { 83 ValidValues = validValues; 84 Value = value; 85 } 86 public ConstrainedValueParameter(string name, string description) 87 : base(name, description, typeof(T)) { 88 ValidValues = new ItemSet<T>(); 89 } 90 public ConstrainedValueParameter(string name, string description, ItemSet<T> validValues) 91 : base(name, description, typeof(T)) { 92 ValidValues = validValues; 93 } 94 public ConstrainedValueParameter(string name, string description, ItemSet<T> validValues, T value) 95 : base(name, description, typeof(T)) { 96 ValidValues = validValues; 97 Value = value; 98 } 99 100 public override IDeepCloneable Clone(Cloner cloner) { 101 ConstrainedValueParameter<T> clone = (ConstrainedValueParameter<T>)base.Clone(cloner); 102 clone.ValidValues = (ItemSet<T>)cloner.Clone(validValues); 103 clone.Value = (T)cloner.Clone(value); 104 return clone; 105 } 106 107 public override string ToString() { 108 return string.Format("{0}: {1} ({2})", Name, Value != null ? Value.ToString() : "null", DataType.GetPrettyName()); 109 } 110 111 protected override IItem GetActualValue() { 112 return Value; 113 } 114 protected override void SetActualValue(IItem value) { 115 ((IValueParameter)this).Value = value; 116 } 117 118 public event EventHandler ValueChanged; 119 private void OnValueChanged() { 120 if (ValueChanged != null) 121 ValueChanged(this, EventArgs.Empty); 122 OnChanged(); 123 } 124 125 private void RegisterValidValuesEvents() { 126 if (validValues != null) { 127 validValues.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<T>(ValidValues_ItemsRemoved); 128 validValues.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<T>(ValidValues_CollectionReset); 129 validValues.Changed += new ChangedEventHandler(ValidValues_Changed); 130 } 131 } 132 private void DeregisterValidValuesEvents() { 133 if (validValues != null) { 134 validValues.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<T>(ValidValues_ItemsRemoved); 135 validValues.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<T>(ValidValues_CollectionReset); 136 validValues.Changed -= new ChangedEventHandler(ValidValues_Changed); 137 } 138 } 139 140 private void ValidValues_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<T> e) { 141 if ((Value != null) && !validValues.Contains(Value)) Value = null; 142 } 143 private void ValidValues_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<T> e) { 144 if ((Value != null) && !validValues.Contains(Value)) Value = null; 145 } 146 private void ValidValues_Changed(object sender, ChangedEventArgs e) { 147 OnChanged(e); 57 protected override void ValidValues_CollectionReset(object sender, CollectionItemsChangedEventArgs<T> e) { 58 if ((Value != null) && !ValidValues.Contains(Value)) Value = ValidValues.FirstOrDefault(); 148 59 } 149 60 } -
trunk/sources/HeuristicLab.Parameters/3.3/HeuristicLab.Parameters-3.3.csproj
r2900 r2924 85 85 <None Include="HeuristicLabParametersPlugin.cs.frame" /> 86 86 <Compile Include="ConstrainedValueParameter.cs" /> 87 <Compile Include="OptionalConstrainedValueParameter.cs" /> 87 88 <Compile Include="ValueParameter.cs" /> 88 89 <Compile Include="LookupParameter.cs" /> -
trunk/sources/HeuristicLab.Parameters/3.3/OptionalValueParameter.cs
r2891 r2924 33 33 private T value; 34 34 [Storable] 35 public T Value {35 public virtual T Value { 36 36 get { return this.value; } 37 37 set { -
trunk/sources/HeuristicLab.Parameters/3.3/ValueParameter.cs
r2891 r2924 30 30 /// </summary> 31 31 [Item("ValueParameter<T>", "A parameter whose value is defined it the parameter itself.")] 32 public sealed class ValueParameter<T> : Parameter, IValueParameter<T> where T : class, IItem { 33 private T value; 34 [Storable] 35 public T Value { 36 get { return this.value; } 32 [EmptyStorableClass] 33 public class ValueParameter<T> : OptionalValueParameter<T> where T : class, IItem { 34 public override T Value { 35 get { return base.Value; } 37 36 set { 38 37 if (value == null) throw new ArgumentNullException(); 39 if (value != this.value) { 40 if (this.value != null) this.value.Changed -= new ChangedEventHandler(Value_Changed); 41 this.value = value; 42 this.value.Changed += new ChangedEventHandler(Value_Changed); 43 OnValueChanged(); 44 } 45 } 46 } 47 IItem IValueParameter.Value { 48 get { return Value; } 49 set { 50 if (value == null) throw new ArgumentNullException(); 51 T val = value as T; 52 if (val == null) 53 throw new InvalidOperationException( 54 string.Format("Type mismatch. Value is not a \"{0}\".", 55 typeof(T).GetPrettyName()) 56 ); 57 Value = val; 38 base.Value = value; 58 39 } 59 40 } 60 41 61 private ValueParameter() 62 : base("Anonymous", typeof(T)) { 63 } 64 public ValueParameter(string name, T value) 65 : base(name, typeof(T)) { 66 Value = value; 67 } 68 public ValueParameter(string name, string description, T value) 69 : base(name, description, typeof(T)) { 70 Value = value; 71 } 42 private ValueParameter() : base() { } 43 public ValueParameter(string name, T value) : base(name, value) { } 44 public ValueParameter(string name, string description, T value) : base(name, description, value) { } 72 45 73 46 public override IDeepCloneable Clone(Cloner cloner) { 74 ValueParameter<T> clone = new ValueParameter<T>(name, description, value);47 ValueParameter<T> clone = new ValueParameter<T>(name, description, Value); 75 48 cloner.RegisterClonedObject(this, clone); 76 clone.Value = (T)cloner.Clone( value);49 clone.Value = (T)cloner.Clone(Value); 77 50 return clone; 78 }79 80 public override string ToString() {81 return string.Format("{0}: {1} ({2})", Name, Value.ToString(), DataType.GetPrettyName());82 }83 84 protected override IItem GetActualValue() {85 return Value;86 }87 protected override void SetActualValue(IItem value) {88 ((IValueParameter)this).Value = value;89 }90 91 public event EventHandler ValueChanged;92 private void OnValueChanged() {93 if (ValueChanged != null)94 ValueChanged(this, EventArgs.Empty);95 OnChanged();96 }97 private void Value_Changed(object sender, ChangedEventArgs e) {98 OnChanged(e);99 51 } 100 52 } -
trunk/sources/HeuristicLab.Random/3.3/RandomCreator.cs
r2834 r2924 28 28 namespace HeuristicLab.Operators { 29 29 /// <summary> 30 /// An operator which creates a new pseudo random number generator.30 /// An operator which creates a new Mersenne Twister pseudo random number generator. 31 31 /// </summary> 32 [Item("RandomCreator", "An operator which creates a new pseudo random number generator.")]32 [Item("RandomCreator", "An operator which creates a new Mersenne Twister pseudo random number generator.")] 33 33 [EmptyStorableClass] 34 34 [Creatable("Test")] -
trunk/sources/HeuristicLab.SequentialEngine/3.3/SequentialEngine.cs
r2851 r2924 30 30 /// </summary> 31 31 [EmptyStorableClass] 32 [Creatable("Engines")]33 32 [Item("Sequential Engine", "Engine for sequential execution of algorithms.")] 34 33 public class SequentialEngine : Engine {
Note: See TracChangeset
for help on using the changeset viewer.