Free cookie consent management tool by TermsFeed Policy Generator

source: branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVectorInput.cs @ 11881

Last change on this file since 11881 was 9242, checked in by sforsten, 12 years ago

#1980:

  • fixed several bugs (crossover, subsumption, serialization etc.)
  • added ModuloOperator
  • CombinedIntegerVectorClassificationProblem\Data and VariableVectorClassificationProblem\Data inherit from ConditionActionClassificationProblem\Data
  • it can now be set how often the analyzers have to be executed
  • VariableVectorAction, VariableVectorCondition and VariableVectorInput now inherit from Item
File size: 2.9 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.Encodings.ConditionActionEncoding;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30
31namespace HeuristicLab.Encodings.VariableVector {
32  [StorableClass]
33  [Item("VariableVectorInput", "")]
34  public class VariableVectorInput : Item, IInput {
35
36    [Storable]
37    private Dictionary<string, string> inputDictionary;
38    public Dictionary<string, string> InputDictionary {
39      get { return inputDictionary; }
40      protected set {
41        inputDictionary = value;
42      }
43    }
44
45    public IOrderedEnumerable<string> Order { get { return InputDictionary.Keys.OrderBy(x => x); } }
46
47    [StorableConstructor]
48    protected VariableVectorInput(bool deserializing) { }
49    protected VariableVectorInput(VariableVectorInput original, Cloner cloner) {
50      InputDictionary = new Dictionary<string, string>(original.InputDictionary.Count);
51      foreach (var item in original.InputDictionary) {
52        InputDictionary.Add(item.Key, item.Value);
53      }
54    }
55    public VariableVectorInput()
56      : base() {
57      InputDictionary = new Dictionary<string, string>();
58    }
59    public VariableVectorInput(int capacity)
60      : base() {
61      InputDictionary = new Dictionary<string, string>(capacity);
62    }
63    public VariableVectorInput(IDictionary<string, string> dictionary)
64      : base() {
65      InputDictionary = new Dictionary<string, string>(dictionary);
66    }
67    public override IDeepCloneable Clone(Cloner cloner) {
68      return new VariableVectorInput(this, cloner);
69    }
70
71    public override string ToString() {
72      StringBuilder sb = new StringBuilder();
73      bool first = true;
74      foreach (var item in InputDictionary) {
75        if (first) {
76          first = false;
77        } else {
78          sb.Append("; ");
79        }
80        sb.Append(String.Format("{0}: {1}", item.Key, item.Value));
81      }
82      return sb.ToString();
83    }
84  }
85}
Note: See TracBrowser for help on using the repository browser.