Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 14875 was 14875, checked in by pkimmesw, 7 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  using Parameters;
10  using Persistence.Default.CompositeSerializers.Storable;
11  using Problems.ProgramSynthesis.Base.Erc.Interfaces;
12
13  [StorableClass]
14  public class IntegerVectorErcOptions : ErcOption, IReadOnlyVectorErcOptions<int> {
15    private const string ConstantsParameterName = "Constants";
16
17    public IntegerVectorErcOptions() : this(new int[0][]) {
18    }
19
20    public IntegerVectorErcOptions(int[][] constants) {
21      IsEnabled = true;
22      var mappedConstants = constants.Select(c => new IntArray(c));
23      Parameters.Add(new ValueParameter<ItemArray<IntArray>>(ConstantsParameterName, new ItemArray<IntArray>(mappedConstants)));
24    }
25
26    [StorableConstructor]
27    private IntegerVectorErcOptions(bool deserializing) : base(deserializing) { }
28
29    public IntegerVectorErcOptions(IntegerVectorErcOptions origin, Cloner cloner) : base(origin, cloner) { }
30
31    public IValueParameter<ItemArray<IntArray>> ConstantsParameter
32    {
33      get { return (IValueParameter<ItemArray<IntArray>>)Parameters[ConstantsParameterName]; }
34    }
35
36    public IEnumerable<IReadOnlyList<int>> Constants
37    {
38      get { return ConstantsParameter.Value.Select(v => v.Data); }
39      set
40      {
41        var mappedConstants = value.Select(c => new IntArray(c.ToArray()));
42        ConstantsParameter.Value = new ItemArray<IntArray>(mappedConstants);
43      }
44    }
45
46    public override IDeepCloneable Clone(Cloner cloner) {
47      return new IntegerVectorErcOptions(this, cloner);
48    }
49  }
50}
Note: See TracBrowser for help on using the repository browser.