Changeset 40
- Timestamp:
- 03/05/08 02:08:02 (17 years ago)
- Location:
- trunk/sources
- Files:
-
- 13 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Constraints/AndConstraint.cs
r2 r40 29 29 namespace HeuristicLab.Constraints { 30 30 public class AndConstraint : ConstraintBase, IViewable { 31 private ItemList clauses;32 public ItemList Clauses {31 private ItemList<IConstraint> clauses; 32 public ItemList<IConstraint> Clauses { 33 33 get { return clauses; } 34 34 set { … … 45 45 46 46 public AndConstraint() { 47 clauses = new ItemList(); 48 clauses.ItemType = typeof(IConstraint); 47 clauses = new ItemList<IConstraint>(); 49 48 } 50 49 … … 52 51 bool result = true; 53 52 for (int i = 0 ; i < clauses.Count ; i++) { 54 result = ((IConstraint)clauses[i]).Check(data);53 result = clauses[i].Check(data); 55 54 if (!result) return false; 56 55 } … … 65 64 AndConstraint clone = new AndConstraint(); 66 65 clonedObjects.Add(Guid, clone); 67 clone.Clauses = (ItemList )Auxiliary.Clone(Clauses, clonedObjects);66 clone.Clauses = (ItemList<IConstraint>)Auxiliary.Clone(Clauses, clonedObjects); 68 67 return clone; 69 68 } … … 84 83 public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) { 85 84 base.Populate(node, restoredObjects); 86 clauses = (ItemList )PersistenceManager.Restore(node.SelectSingleNode("Clauses"), restoredObjects);85 clauses = (ItemList<IConstraint>)PersistenceManager.Restore(node.SelectSingleNode("Clauses"), restoredObjects); 87 86 } 88 87 #endregion persistence -
trunk/sources/HeuristicLab.Constraints/AndConstraintView.Designer.cs
r2 r40 46 46 /// </summary> 47 47 private void InitializeComponent() { 48 this.clausesItemListView = new HeuristicLab.Data.ItemListView ();48 this.clausesItemListView = new HeuristicLab.Data.ItemListView<HeuristicLab.Core.IConstraint>(); 49 49 this.SuspendLayout(); 50 50 // … … 73 73 #endregion 74 74 75 private HeuristicLab.Data.ItemListView clausesItemListView;75 private HeuristicLab.Data.ItemListView<HeuristicLab.Core.IConstraint> clausesItemListView; 76 76 77 77 } -
trunk/sources/HeuristicLab.Constraints/ItemTypeConstraint.cs
r2 r40 81 81 XmlNode node = base.GetXmlNode(name, document, persistedObjects); 82 82 XmlAttribute itemTypeAttribute = document.CreateAttribute("ItemType"); 83 string typeString = Type.AssemblyQualifiedName; 84 string[] tokens = typeString.Split(new string[] { ", " }, StringSplitOptions.None); 85 typeString = tokens[0] + ", " + tokens[1]; 86 itemTypeAttribute.Value = typeString; 83 itemTypeAttribute.Value = PersistenceManager.BuildTypeString(Type); 87 84 node.Attributes.Append(itemTypeAttribute); 88 85 return node; -
trunk/sources/HeuristicLab.Constraints/OrConstraint.cs
r2 r40 29 29 namespace HeuristicLab.Constraints { 30 30 public class OrConstraint : ConstraintBase, IViewable { 31 private ItemList clauses;32 public ItemList Clauses {31 private ItemList<IConstraint> clauses; 32 public ItemList<IConstraint> Clauses { 33 33 get { return clauses; } 34 34 set { … … 45 45 46 46 public OrConstraint() { 47 clauses = new ItemList(); 48 clauses.ItemType = typeof(IConstraint); 47 clauses = new ItemList<IConstraint>(); 49 48 } 50 49 … … 52 51 bool result = false; 53 52 for (int i = 0 ; i < clauses.Count ; i++) { 54 result = ((IConstraint)clauses[i]).Check(data);53 result = clauses[i].Check(data); 55 54 if (result) return true; 56 55 } … … 65 64 OrConstraint clone = new OrConstraint(); 66 65 clonedObjects.Add(Guid, clone); 67 clone.Clauses = (ItemList )Auxiliary.Clone(Clauses, clonedObjects);66 clone.Clauses = (ItemList<IConstraint>)Auxiliary.Clone(Clauses, clonedObjects); 68 67 return clone; 69 68 } … … 85 84 public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) { 86 85 base.Populate(node, restoredObjects); 87 clauses = (ItemList )PersistenceManager.Restore(node.SelectSingleNode("Clauses"), restoredObjects);86 clauses = (ItemList<IConstraint>)PersistenceManager.Restore(node.SelectSingleNode("Clauses"), restoredObjects); 88 87 } 89 88 #endregion persistence -
trunk/sources/HeuristicLab.Constraints/OrConstraintView.Designer.cs
r2 r40 46 46 /// </summary> 47 47 private void InitializeComponent() { 48 this.clausesItemListView = new HeuristicLab.Data.ItemListView ();48 this.clausesItemListView = new HeuristicLab.Data.ItemListView<HeuristicLab.Core.IConstraint>(); 49 49 this.SuspendLayout(); 50 50 // … … 73 73 #endregion 74 74 75 private HeuristicLab.Data.ItemListView clausesItemListView;75 private HeuristicLab.Data.ItemListView<HeuristicLab.Core.IConstraint> clausesItemListView; 76 76 } 77 77 } -
trunk/sources/HeuristicLab.Core/PersistenceManager.cs
r22 r40 82 82 return PersistenceManager.Restore(doc.ChildNodes[1], new Dictionary<Guid, IStorable>()); 83 83 } 84 85 public static string BuildTypeString(Type type) { 86 string assembly = type.Assembly.FullName; 87 assembly = assembly.Split(new string[] { ", " }, StringSplitOptions.None)[0]; 88 89 StringBuilder builder = new StringBuilder(); 90 builder.Append(type.Namespace); 91 builder.Append("."); 92 builder.Append(type.Name); 93 Type[] args = type.GetGenericArguments(); 94 if (args.Length > 0) { 95 builder.Append("[["); 96 builder.Append(BuildTypeString(args[0])); 97 builder.Append("]"); 98 for (int i = 1; i < args.Length; i++) { 99 builder.Append(",["); 100 builder.Append(BuildTypeString(args[i])); 101 builder.Append("]"); 102 } 103 builder.Append("]"); 104 } 105 builder.Append(", "); 106 builder.Append(assembly); 107 return builder.ToString(); 108 } 84 109 } 85 110 } -
trunk/sources/HeuristicLab.Core/StorableBase.cs
r2 r40 47 47 public virtual XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) { 48 48 XmlNode node = document.CreateNode(XmlNodeType.Element, name, null); 49 Type type = this.GetType();50 string typeString = type.AssemblyQualifiedName;51 string[] tokens = typeString.Split(new string[] { ", " }, StringSplitOptions.None);52 typeString = tokens[0] + ", " + tokens[1];53 49 XmlAttribute typeAttribute = document.CreateAttribute("Type"); 54 typeAttribute.Value = typeString;50 typeAttribute.Value = PersistenceManager.BuildTypeString(this.GetType()); 55 51 node.Attributes.Append(typeAttribute); 56 52 XmlAttribute guidAttribute = document.CreateAttribute("GUID"); -
trunk/sources/HeuristicLab.Core/VariableInfo.cs
r2 r40 124 124 125 125 XmlAttribute dataTypeAttribute = document.CreateAttribute("DataType"); 126 string typeString = DataType.AssemblyQualifiedName; 127 string[] tokens = typeString.Split(new string[] { ", " }, StringSplitOptions.None); 128 typeString = tokens[0] + ", " + tokens[1]; 129 dataTypeAttribute.Value = typeString; 126 dataTypeAttribute.Value = PersistenceManager.BuildTypeString(DataType); 130 127 node.Attributes.Append(dataTypeAttribute); 131 128 -
trunk/sources/HeuristicLab.Data/HeuristicLab.Data.csproj
r30 r40 150 150 <Compile Include="IObjectData.cs" /> 151 151 <Compile Include="IObjectDataVisitor.cs" /> 152 <Compile Include="ItemList.cs" /> 153 <Compile Include="ItemListView.cs"> 154 <SubType>UserControl</SubType> 155 </Compile> 156 <Compile Include="ItemListView.Designer.cs"> 157 <DependentUpon>ItemListView.cs</DependentUpon> 152 <Compile Include="ItemListView_T.cs"> 153 <SubType>UserControl</SubType> 154 </Compile> 155 <Compile Include="ItemListView_T.Designer.cs"> 156 <DependentUpon>ItemListView_T.cs</DependentUpon> 157 </Compile> 158 <Compile Include="ItemList_T.cs"> 159 <SubType>UserControl</SubType> 158 160 </Compile> 159 161 <Compile Include="MatrixDataBaseView.cs"> … … 223 225 <SubType>Designer</SubType> 224 226 </EmbeddedResource> 225 <EmbeddedResource Include="ItemListView .resx">226 <DependentUpon>ItemListView .cs</DependentUpon>227 <EmbeddedResource Include="ItemListView_T.resx"> 228 <DependentUpon>ItemListView_T.cs</DependentUpon> 227 229 <SubType>Designer</SubType> 228 230 </EmbeddedResource> -
trunk/sources/HeuristicLab.Data/ItemListView_T.Designer.cs
r38 r40 25 25 26 26 namespace HeuristicLab.Data { 27 partial class ItemListView {27 partial class ItemListView<T> { 28 28 /// <summary> 29 29 /// Required designer variable. … … 60 60 this.detailsGroupBox = new System.Windows.Forms.GroupBox(); 61 61 this.itemTypeLabel = new System.Windows.Forms.Label(); 62 this.setTypeButton = new System.Windows.Forms.Button();63 62 this.typeTextBox = new System.Windows.Forms.TextBox(); 64 63 this.splitContainer.Panel1.SuspendLayout(); … … 86 85 this.splitContainer.Size = new System.Drawing.Size(423, 246); 87 86 this.splitContainer.SplitterDistance = 198; 88 this.splitContainer.TabIndex = 3;87 this.splitContainer.TabIndex = 2; 89 88 // 90 89 // itemsGroupBox … … 167 166 this.itemTypeLabel.Text = "&Item Type:"; 168 167 // 169 // setTypeButton170 //171 this.setTypeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));172 this.setTypeButton.Location = new System.Drawing.Point(380, 0);173 this.setTypeButton.Name = "setTypeButton";174 this.setTypeButton.Size = new System.Drawing.Size(43, 20);175 this.setTypeButton.TabIndex = 1;176 this.setTypeButton.Text = "&Set...";177 this.setTypeButton.UseVisualStyleBackColor = true;178 this.setTypeButton.Click += new System.EventHandler(this.setTypeButton_Click);179 //180 168 // typeTextBox 181 169 // … … 185 173 this.typeTextBox.Name = "typeTextBox"; 186 174 this.typeTextBox.ReadOnly = true; 187 this.typeTextBox.Size = new System.Drawing.Size(3 08, 20);188 this.typeTextBox.TabIndex = 2;175 this.typeTextBox.Size = new System.Drawing.Size(357, 20); 176 this.typeTextBox.TabIndex = 1; 189 177 // 190 178 // ItemListView … … 193 181 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 194 182 this.Controls.Add(this.typeTextBox); 195 this.Controls.Add(this.setTypeButton);196 183 this.Controls.Add(this.itemTypeLabel); 197 184 this.Controls.Add(this.splitContainer); … … 217 204 private System.Windows.Forms.ColumnHeader columnHeader1; 218 205 private Label itemTypeLabel; 219 private Button setTypeButton;220 206 private TextBox typeTextBox; 221 207 -
trunk/sources/HeuristicLab.Data/ItemListView_T.cs
r38 r40 27 27 using System.Text; 28 28 using System.Windows.Forms; 29 using HeuristicLab.PluginInfrastructure;30 29 using HeuristicLab.Core; 31 30 32 31 namespace HeuristicLab.Data { 33 public partial class ItemListView : ViewBase{32 public partial class ItemListView<T> : ViewBase where T : IItem { 34 33 private ChooseItemDialog chooseItemDialog; 35 34 36 public ItemList ItemList {37 get { return (ItemList )Item; }35 public ItemList<T> ItemList { 36 get { return (ItemList<T>)Item; } 38 37 set { base.Item = value; } 39 38 } … … 43 42 itemsListView.Columns[0].Width = Math.Max(0, itemsListView.Width - 25); 44 43 } 45 public ItemListView(ItemList itemList)44 public ItemListView(ItemList<T> itemList) 46 45 : this() { 47 46 ItemList = itemList; … … 49 48 50 49 protected override void RemoveItemEvents() { 51 ItemList.ItemTypeChanged -= new EventHandler(ItemList_ItemTypeChanged);52 50 ItemList.ItemAdded -= new EventHandler<ItemIndexEventArgs>(ItemList_ItemInserted); 53 51 ItemList.ItemRemoved -= new EventHandler<ItemIndexEventArgs>(ItemList_ItemRemoved); … … 57 55 protected override void AddItemEvents() { 58 56 base.AddItemEvents(); 59 ItemList.ItemTypeChanged += new EventHandler(ItemList_ItemTypeChanged);60 57 ItemList.ItemAdded += new EventHandler<ItemIndexEventArgs>(ItemList_ItemInserted); 61 58 ItemList.ItemRemoved += new EventHandler<ItemIndexEventArgs>(ItemList_ItemRemoved); … … 70 67 if (ItemList == null) { 71 68 typeTextBox.Text = ""; 72 setTypeButton.Enabled = false;73 69 splitContainer.Enabled = false; 74 70 } else { 75 typeTextBox.Text = ItemList.ItemType.FullName; 76 setTypeButton.Enabled = true; 71 typeTextBox.Text = typeof(T).FullName; 77 72 splitContainer.Enabled = true; 78 73 foreach (ListViewItem item in itemsListView.Items) { … … 125 120 126 121 #region Button Events 127 private void setTypeButton_Click(object sender, EventArgs e) {128 ChooseTypeDialog dialog = new ChooseTypeDialog();129 dialog.Caption = "Set Item Type";130 if (dialog.ShowDialog(this) == DialogResult.OK) {131 try {132 ItemList.ItemType = dialog.Type;133 }134 catch (Exception ex) {135 Auxiliary.ShowErrorMessageBox(ex);136 }137 }138 dialog.Dispose();139 }140 122 private void addButton_Click(object sender, EventArgs e) { 141 123 if (chooseItemDialog == null) { 142 chooseItemDialog = new ChooseItemDialog( ItemList.ItemType);124 chooseItemDialog = new ChooseItemDialog(typeof(T)); 143 125 chooseItemDialog.Caption = "Add Item"; 144 126 } 145 127 if (chooseItemDialog.ShowDialog(this) == DialogResult.OK) { 146 128 try { 147 ItemList.Add( chooseItemDialog.Item);129 ItemList.Add((T)chooseItemDialog.Item); 148 130 } 149 131 catch (Exception ex) { … … 193 175 if (item != null) { 194 176 int index = item.Index; 195 ItemList.Remove( data);196 ItemList.Insert(index, data);177 ItemList.Remove((T)data); 178 ItemList.Insert(index, (T)data); 197 179 itemsListView.SelectedIndices.Clear(); 198 180 itemsListView.SelectedIndices.Add(index); … … 204 186 205 187 #region Item and Item List Events 206 private void ItemList_ItemTypeChanged(object sender, EventArgs e) {207 if (InvokeRequired)208 Invoke(new EventHandler(ItemList_ItemTypeChanged), sender, e);209 else {210 typeTextBox.Text = ItemList.ItemType.FullName;211 if (chooseItemDialog != null) chooseItemDialog.Dispose();212 chooseItemDialog = new ChooseItemDialog(ItemList.ItemType);213 chooseItemDialog.Caption = "Add Item";214 }215 }216 188 private void ItemList_ItemInserted(object sender, ItemIndexEventArgs e) { 217 189 if (InvokeRequired) -
trunk/sources/HeuristicLab.Data/ItemList_T.cs
r38 r40 28 28 29 29 namespace HeuristicLab.Data { 30 public class ItemList : ItemBase, IList<IItem> { 31 private List<IItem> list; 32 33 private Type myItemType; 34 public Type ItemType { 35 get { return myItemType; } 36 set { 37 if (value == null) value = typeof(IItem); 38 if (value != myItemType) { 39 if (!typeof(IItem).IsAssignableFrom(value)) 40 throw new InvalidOperationException("Cannot set item type. Only types compatible to IItem are allowed."); 41 foreach (IItem item in list) { 42 if (!value.IsAssignableFrom(item.GetType())) 43 throw new InvalidOperationException("Cannot set item type. Items are incompatible."); 44 } 45 myItemType = value; 46 OnItemTypeChanged(); 47 } 48 } 49 } 30 public class ItemList<T> : ItemBase, IList<T> where T : IItem { 31 private List<T> list; 50 32 51 33 public ItemList() { 52 list = new List<IItem>(); 53 myItemType = typeof(IItem); 34 list = new List<T>(); 54 35 } 55 36 56 37 public override IView CreateView() { 57 return new ItemListView (this);38 return new ItemListView<T>(this); 58 39 } 59 40 60 41 public override object Clone(IDictionary<Guid, object> clonedObjects) { 61 ItemList clone = new ItemList();42 ItemList<T> clone = new ItemList<T>(); 62 43 clonedObjects.Add(Guid, clone); 63 clone.myItemType = ItemType;64 44 for (int i = 0; i < list.Count; i++) 65 clone.list.Add(( IItem)Auxiliary.Clone(list[i], clonedObjects));45 clone.list.Add((T)Auxiliary.Clone(list[i], clonedObjects)); 66 46 return clone; 67 47 } … … 69 49 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) { 70 50 XmlNode node = base.GetXmlNode(name, document, persistedObjects); 71 if (ItemType != null) {72 XmlAttribute itemTypeAttribute = document.CreateAttribute("ItemType");73 string typeString = ItemType.AssemblyQualifiedName;74 string[] tokens = typeString.Split(new string[] { ", " }, StringSplitOptions.None);75 typeString = tokens[0] + ", " + tokens[1];76 itemTypeAttribute.Value = typeString;77 node.Attributes.Append(itemTypeAttribute);78 }79 51 for (int i = 0; i < list.Count; i++) 80 52 node.AppendChild(PersistenceManager.Persist(list[i], document, persistedObjects)); … … 83 55 public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) { 84 56 base.Populate(node, restoredObjects); 85 XmlAttribute itemTypeAttribute = node.Attributes["ItemType"];86 if (itemTypeAttribute != null)87 myItemType = Type.GetType(itemTypeAttribute.Value);88 57 for (int i = 0; i < node.ChildNodes.Count; i++) 89 list.Add(( IItem)PersistenceManager.Restore(node.ChildNodes[i], restoredObjects));58 list.Add((T)PersistenceManager.Restore(node.ChildNodes[i], restoredObjects)); 90 59 } 91 60 … … 104 73 } 105 74 106 #region IList< IItem> Members107 public int IndexOf( IItemitem) {75 #region IList<T> Members 76 public int IndexOf(T item) { 108 77 return list.IndexOf(item); 109 78 } 110 public void Insert(int index, IItem item) { 111 if ((ItemType != null) && (!ItemType.IsAssignableFrom(item.GetType()))) 112 throw new InvalidOperationException("item type is incompatible to required item type"); 79 public void Insert(int index, T item) { 113 80 list.Insert(index, item); 114 81 OnItemAdded(item, index); … … 119 86 OnItemRemoved(item, index); 120 87 } 121 public IItemthis[int index] {88 public T this[int index] { 122 89 get { return list[index]; } 123 set { 124 if ((ItemType != null) && (!ItemType.IsAssignableFrom(value.GetType()))) 125 throw new InvalidOperationException("item type is incompatible to required item type"); 126 list[index] = value; 127 } 90 set { list[index] = value; } 128 91 } 129 92 #endregion 130 93 131 #region ICollection<IItem> Members 132 public void Add(IItem item) { 133 if ((ItemType != null) && (!ItemType.IsAssignableFrom(item.GetType()))) 134 throw new InvalidOperationException("item type is incompatible to required item type"); 94 #region ICollection<T> Members 95 public void Add(T item) { 135 96 list.Add(item); 136 97 OnItemAdded(item, list.Count - 1); … … 140 101 OnCleared(); 141 102 } 142 public bool Contains( IItemitem) {103 public bool Contains(T item) { 143 104 return list.Contains(item); 144 105 } 145 public void CopyTo( IItem[] array, int arrayIndex) {106 public void CopyTo(T[] array, int arrayIndex) { 146 107 list.CopyTo(array, arrayIndex); 147 108 } … … 152 113 get { return false; } 153 114 } 154 public bool Remove( IItemitem) {115 public bool Remove(T item) { 155 116 int index = list.IndexOf(item); 156 117 if (list.Remove(item)) { … … 163 124 #endregion 164 125 165 #region IEnumerable< IItem> Members166 public IEnumerator< IItem> GetEnumerator() {126 #region IEnumerable<T> Members 127 public IEnumerator<T> GetEnumerator() { 167 128 return list.GetEnumerator(); 168 129 } … … 175 136 #endregion 176 137 177 public event EventHandler ItemTypeChanged;178 protected virtual void OnItemTypeChanged() {179 if (ItemTypeChanged != null)180 ItemTypeChanged(this, new EventArgs());181 OnChanged();182 }183 138 public event EventHandler<ItemIndexEventArgs> ItemAdded; 184 139 protected virtual void OnItemAdded(IItem item, int index) { … … 200 155 } 201 156 } 157 158 public class ItemList : ItemList<IItem> { } 159 public class ItemListView : ItemListView<IItem> { 160 public ItemListView() { } 161 public ItemListView(ItemList itemList) 162 : this() { 163 ItemList = itemList; 164 } 165 } 202 166 } -
trunk/sources/HeuristicLab.Evolutionary/SubScopesStorer.cs
r2 r40 36 36 : base() { 37 37 AddVariableInfo(new VariableInfo("SubScopes", "Number of sub-scopes that should be available", typeof(IntData), VariableKind.In)); 38 AddVariableInfo(new VariableInfo("SubScopesStore", "Temporarily stored sub-scopes", typeof(ItemList ), VariableKind.New | VariableKind.In | VariableKind.Out | VariableKind.Deleted));38 AddVariableInfo(new VariableInfo("SubScopesStore", "Temporarily stored sub-scopes", typeof(ItemList<IScope>), VariableKind.New | VariableKind.In | VariableKind.Out | VariableKind.Deleted)); 39 39 } 40 40 41 41 public override IOperation Apply(IScope scope) { 42 42 IntData subScopes = GetVariableValue<IntData>("SubScopes", scope, true); 43 ItemList subScopesStore = GetVariableValue<ItemList>("SubScopesStore", scope, false);43 ItemList<IScope> subScopesStore = GetVariableValue<ItemList<IScope>>("SubScopesStore", scope, false); 44 44 45 45 if (subScopesStore == null) { 46 subScopesStore = new ItemList(); 47 subScopesStore.ItemType = typeof(IScope); 46 subScopesStore = new ItemList<IScope>(); 48 47 IVariableInfo info = GetVariableInfo("SubScopesStore"); 49 48 if (info.Local) … … 60 59 // restore sub-scopes 61 60 for (int i = 0; i < subScopesStore.Count; i++) { 62 right.AddSubScope( (IScope)subScopesStore[i]);61 right.AddSubScope(subScopesStore[i]); 63 62 IVariableInfo info = GetVariableInfo("SubScopesStore"); 64 63 if (info.Local) -
trunk/sources/HeuristicLab.Operators/CombinedOperator.cs
r2 r40 47 47 GetVariableInfo("InjectSubOperators").Local = true; 48 48 AddVariable(new Variable("InjectSubOperators", new BoolData(false))); 49 AddVariableInfo(new VariableInfo("SubOperatorNames", "Variable names for injecting the sub-operators", typeof(ItemList ), VariableKind.In));49 AddVariableInfo(new VariableInfo("SubOperatorNames", "Variable names for injecting the sub-operators", typeof(ItemList<StringData>), VariableKind.In)); 50 50 GetVariableInfo("SubOperatorNames").Local = true; 51 ItemList subOperatorNames = new ItemList(); 52 subOperatorNames.ItemType = typeof(StringData); 51 ItemList<StringData> subOperatorNames = new ItemList<StringData>(); 53 52 AddVariable(new Variable("SubOperatorNames", subOperatorNames)); 54 53 } … … 75 74 bool inject = GetVariableValue<BoolData>("InjectSubOperators", scope, false).Data; 76 75 if (inject) { 77 ItemList names = GetVariableValue<ItemList>("SubOperatorNames", scope, false);76 ItemList<StringData> names = GetVariableValue<ItemList<StringData>>("SubOperatorNames", scope, false); 78 77 for (int i = 0; i < SubOperators.Count; i++) { 79 if (scope.GetVariable(names[i]. ToString()) != null)80 scope.RemoveVariable(names[i]. ToString());81 scope.AddVariable(new Variable(names[i]. ToString(), SubOperators[i]));78 if (scope.GetVariable(names[i].Data) != null) 79 scope.RemoveVariable(names[i].Data); 80 scope.AddVariable(new Variable(names[i].Data, SubOperators[i])); 82 81 } 83 82 } -
trunk/sources/HeuristicLab.Operators/DataCollector.cs
r2 r40 33 33 34 34 public DataCollector() { 35 IVariableInfo variableNamesVariableInfo = new VariableInfo("VariableNames", "Names of variables whose values should be collected", typeof(ItemList ), VariableKind.In);35 IVariableInfo variableNamesVariableInfo = new VariableInfo("VariableNames", "Names of variables whose values should be collected", typeof(ItemList<StringData>), VariableKind.In); 36 36 variableNamesVariableInfo.Local = true; 37 37 AddVariableInfo(variableNamesVariableInfo); 38 ItemList variableNames = new ItemList(); 39 variableNames.ItemType = typeof(StringData); 38 ItemList<StringData> variableNames = new ItemList<StringData>(); 40 39 AddVariable(new Variable("VariableNames", variableNames)); 41 40 AddVariableInfo(new VariableInfo("Values", "Collected values", typeof(ItemList), VariableKind.New | VariableKind.In | VariableKind.Out)); … … 43 42 44 43 public override IOperation Apply(IScope scope) { 45 ItemList names = GetVariableValue<ItemList>("VariableNames", scope, false);44 ItemList<StringData> names = GetVariableValue<ItemList<StringData>>("VariableNames", scope, false); 46 45 ItemList values = GetVariableValue<ItemList>("Values", scope, false, false); 47 46 if (values == null) { … … 56 55 ItemList currentValues = new ItemList(); 57 56 for (int i = 0; i < names.Count; i++) 58 currentValues.Add((IItem)scope.GetVariableValue( ((StringData)names[i]).Data, true).Clone());57 currentValues.Add((IItem)scope.GetVariableValue(names[i].Data, true).Clone()); 59 58 values.Add(currentValues); 60 59 return null; -
trunk/sources/HeuristicLab.Selection.OffspringSelection/OffspringSelector.cs
r2 r40 38 38 AddVariableInfo(new VariableInfo("SelectionPressure", "Current selection pressure", typeof(DoubleData), VariableKind.New | VariableKind.Out)); 39 39 AddVariableInfo(new VariableInfo("SuccessRatio", "Current success ratio", typeof(DoubleData), VariableKind.New | VariableKind.Out)); 40 AddVariableInfo(new VariableInfo("GoodChildren", "Temporarily store successful children", typeof(ItemList ), VariableKind.New | VariableKind.Out | VariableKind.In | VariableKind.Deleted));41 AddVariableInfo(new VariableInfo("BadChildren", "Temporarily store unsuccessful children", typeof(ItemList ), VariableKind.New | VariableKind.Out | VariableKind.In | VariableKind.Deleted));40 AddVariableInfo(new VariableInfo("GoodChildren", "Temporarily store successful children", typeof(ItemList<IScope>), VariableKind.New | VariableKind.Out | VariableKind.In | VariableKind.Deleted)); 41 AddVariableInfo(new VariableInfo("BadChildren", "Temporarily store unsuccessful children", typeof(ItemList<IScope>), VariableKind.New | VariableKind.Out | VariableKind.In | VariableKind.Deleted)); 42 42 } 43 43 … … 50 50 51 51 // retrieve good and bad children 52 ItemList goodChildren = GetVariableValue<ItemList>("GoodChildren", scope, false, false);52 ItemList<IScope> goodChildren = GetVariableValue<ItemList<IScope>>("GoodChildren", scope, false, false); 53 53 if (goodChildren == null) { 54 goodChildren = new ItemList(); 55 goodChildren.ItemType = typeof(IScope); 54 goodChildren = new ItemList<IScope>(); 56 55 IVariableInfo goodChildrenInfo = GetVariableInfo("GoodChildren"); 57 56 if (goodChildrenInfo.Local) … … 60 59 scope.AddVariable(new Variable(goodChildrenInfo.ActualName, goodChildren)); 61 60 } 62 ItemList badChildren = GetVariableValue<ItemList>("BadChildren", scope, false, false);61 ItemList<IScope> badChildren = GetVariableValue<ItemList<IScope>>("BadChildren", scope, false, false); 63 62 if (badChildren == null) { 64 badChildren = new ItemList(); 65 badChildren.ItemType = typeof(IScope); 63 badChildren = new ItemList<IScope>(); 66 64 IVariableInfo badChildrenInfo = GetVariableInfo("BadChildren"); 67 65 if (badChildrenInfo.Local)
Note: See TracChangeset
for help on using the changeset viewer.