Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis.Base/Erc/StringVectorErcOptions.cs @ 14875

Last change on this file since 14875 was 14875, checked in by pkimmesw, 8 years ago

#2665 BenchmarkSuite, all examples, partially tested, VectorExpressions added

File size: 1.7 KB
Line 
1using System.Linq;
2
3namespace HeuristicLab.Problems.ProgramSynthesis.Base.Erc {
4  using System.Collections.Generic;
5
6  using Common;
7  using Core;
8  using Data;
9
10  using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Interfaces;
11  using Parameters;
12  using Persistence.Default.CompositeSerializers.Storable;
13
14  [StorableClass]
15  public class StringVectorErcOptions : ErcOption, IReadOnlyVectorErcOptions<string> {
16    private const string ConstantsParameterName = "Constants";
17
18    public StringVectorErcOptions() : this(new string[0][]) {
19    }
20
21    public StringVectorErcOptions(string[][] constants) {
22      IsEnabled = true;
23      var mappedConstants = constants.Select(c => new StringArray(c));
24      Parameters.Add(new ValueParameter<ItemArray<StringArray>>(ConstantsParameterName, new ItemArray<StringArray>(mappedConstants)));
25    }
26
27    [StorableConstructor]
28    private StringVectorErcOptions(bool deserializing) : base(deserializing) { }
29
30    public StringVectorErcOptions(StringVectorErcOptions origin, Cloner cloner) : base(origin, cloner) { }
31
32    public IValueParameter<ItemArray<StringArray>> ConstantsParameter
33    {
34      get { return (IValueParameter<ItemArray<StringArray>>)Parameters[ConstantsParameterName]; }
35    }
36
37    public IEnumerable<IReadOnlyList<string>> Constants
38    {
39      get { return ConstantsParameter.Value.Select(v => v.ToArray()); }
40      set
41      {
42        var mappedConstants = value.Select(c => new StringArray(c.ToArray()));
43        ConstantsParameter.Value = new ItemArray<StringArray>(mappedConstants);
44      }
45    }
46
47    public override IDeepCloneable Clone(Cloner cloner) {
48      return new StringVectorErcOptions(this, cloner);
49    }
50  }
51}
Note: See TracBrowser for help on using the repository browser.