Free cookie consent management tool by TermsFeed Policy Generator

source: branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/DecisionListInput.cs @ 9334

Last change on this file since 9334 was 9334, checked in by sforsten, 11 years ago

#1980:

  • added Algorithms.GAssist
  • adapted Problems.DecisionListClassification and Encodings.DecisionList
File size: 2.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Encodings.DecisionList {
31  [StorableClass]
32  [Item("DecisionListInput", "")]
33  public class DecisionListInput : Item {
34
35    [Storable]
36    private Dictionary<string, string> inputDictionary;
37    public Dictionary<string, string> InputDictionary {
38      get { return inputDictionary; }
39      protected set {
40        inputDictionary = value;
41      }
42    }
43
44    public IOrderedEnumerable<string> Order { get { return InputDictionary.Keys.OrderBy(x => x); } }
45
46    [StorableConstructor]
47    protected DecisionListInput(bool deserializing) { }
48    protected DecisionListInput(DecisionListInput original, Cloner cloner) {
49      InputDictionary = new Dictionary<string, string>(original.InputDictionary.Count);
50      foreach (var item in original.InputDictionary) {
51        InputDictionary.Add(item.Key, item.Value);
52      }
53    }
54    public DecisionListInput()
55      : base() {
56      InputDictionary = new Dictionary<string, string>();
57    }
58    public DecisionListInput(int capacity)
59      : base() {
60      InputDictionary = new Dictionary<string, string>(capacity);
61    }
62    public DecisionListInput(IDictionary<string, string> dictionary)
63      : base() {
64      InputDictionary = new Dictionary<string, string>(dictionary);
65    }
66    public override IDeepCloneable Clone(Cloner cloner) {
67      return new DecisionListInput(this, cloner);
68    }
69
70    public override string ToString() {
71      StringBuilder sb = new StringBuilder();
72      bool first = true;
73      foreach (var item in InputDictionary) {
74        if (first) {
75          first = false;
76        } else {
77          sb.Append("; ");
78        }
79        sb.Append(String.Format("{0}: {1}", item.Key, item.Value));
80      }
81      return sb.ToString();
82    }
83  }
84}
Note: See TracBrowser for help on using the repository browser.