Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2895_PushGP_GenealogyAnalysis/HeuristicLab.Problems.ProgramSynthesis/Push.Base/Erc/ErcOptions.cs @ 17511

Last change on this file since 17511 was 15771, checked in by bburlacu, 7 years ago

#2895: Add solution skeleton for PushGP with genealogy analysis.

File size: 4.4 KB
Line 
1using System.Collections.Generic;
2using HeuristicLab.Common;
3using HeuristicLab.Core;
4using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
5
6namespace HeuristicLab.Problems.ProgramSynthesis {
7  [StorableClass]
8  public class ErcOptions : NamedItem, IReadOnlyErcOptions {
9
10    public ErcOptions() {
11      Name = "ERC Options";
12
13      ErcProbability = 0d;
14      IntegerErcOptions = new IntegerErcOptions();
15      FloatErcOptions = new FloatErcOptions();
16      BooleanErcOptions = new BooleanErcOptions();
17      CharErcOptions = new CharErcOptions();
18      StringErcOptions = new StringErcOptions();
19      NameErcOptions = new NameErcOptions();
20      IntegerVectorErcOptions = new IntegerVectorErcOptions();
21      StringVectorErcOptions = new StringVectorErcOptions();
22      FloatVectorErcOptions = new FloatVectorErcOptions();
23    }
24
25    [StorableConstructor]
26    protected ErcOptions(bool deserializing)
27      : base(deserializing) {
28    }
29
30    public ErcOptions(ErcOptions origin, Cloner cloner)
31      : base(origin, cloner) {
32      ErcProbability = origin.ErcProbability;
33      IntegerErcOptions = cloner.Clone(origin.IntegerErcOptions);
34      FloatErcOptions = cloner.Clone(origin.FloatErcOptions);
35      BooleanErcOptions = cloner.Clone(origin.BooleanErcOptions);
36      CharErcOptions = cloner.Clone(origin.CharErcOptions);
37      StringErcOptions = cloner.Clone(origin.StringErcOptions);
38      NameErcOptions = cloner.Clone(origin.NameErcOptions);
39      IntegerVectorErcOptions = cloner.Clone(origin.IntegerVectorErcOptions);
40      StringVectorErcOptions = cloner.Clone(origin.StringVectorErcOptions);
41      FloatVectorErcOptions = cloner.Clone(origin.FloatVectorErcOptions);
42    }
43
44    [Storable]
45    public double ErcProbability { get; set; }
46
47
48    [Storable]
49    public IntegerErcOptions IntegerErcOptions { get; set; }
50    [Storable]
51    public FloatErcOptions FloatErcOptions { get; set; }
52
53    /// <summary>
54    ///   Integer represents ASCII value
55    /// </summary>
56    [Storable]
57    public CharErcOptions CharErcOptions { get; set; }
58    [Storable]
59    public BooleanErcOptions BooleanErcOptions { get; set; }
60    [Storable]
61    public StringErcOptions StringErcOptions { get; set; }
62    [Storable]
63    public NameErcOptions NameErcOptions { get; set; }
64    [Storable]
65    public IntegerVectorErcOptions IntegerVectorErcOptions { get; set; }
66    [Storable]
67    public StringVectorErcOptions StringVectorErcOptions { get; set; }
68    [Storable]
69    public FloatVectorErcOptions FloatVectorErcOptions { get; set; }
70
71    IErcItem<int> IReadOnlyErcOptions.IntegerErcOptions {
72      get {
73        return IntegerErcOptions;
74      }
75    }
76
77    IErcItem<double> IReadOnlyErcOptions.FloatErcOptions {
78      get {
79        return FloatErcOptions;
80      }
81    }
82
83    IErcItem<bool> IReadOnlyErcOptions.BooleanErcOptions {
84      get {
85        return BooleanErcOptions;
86      }
87    }
88
89    IErcItem<char> IReadOnlyErcOptions.CharErcOptions {
90      get {
91        return CharErcOptions;
92      }
93    }
94
95    IErcItem<string> IReadOnlyErcOptions.StringErcOptions {
96      get {
97        return StringErcOptions;
98      }
99    }
100
101    IErcItem<string> IReadOnlyErcOptions.NameErcOptions {
102      get {
103        return NameErcOptions;
104      }
105    }
106
107    IErcItem<IReadOnlyList<int>> IReadOnlyErcOptions.IntegerVectorErcOptions {
108      get {
109        return IntegerVectorErcOptions;
110      }
111    }
112
113    IErcItem<IReadOnlyList<double>> IReadOnlyErcOptions.FloatVectorErcOptions {
114      get {
115        return FloatVectorErcOptions;
116      }
117    }
118
119    IErcItem<IReadOnlyList<string>> IReadOnlyErcOptions.StringVectorErcOptions {
120      get {
121        return StringVectorErcOptions;
122      }
123    }
124
125    public override IDeepCloneable Clone(Cloner cloner) {
126      return new ErcOptions(this, cloner);
127    }
128
129    public void DisableAllOptions() {
130      SetOptionsState(false);
131    }
132
133    public void EnableAllOptions() {
134      SetOptionsState(true);
135    }
136
137    public void SetOptionsState(bool state) {
138      IntegerErcOptions.IsEnabled = state;
139      FloatErcOptions.IsEnabled = state;
140      CharErcOptions.IsEnabled = state;
141      BooleanErcOptions.IsEnabled = state;
142      StringErcOptions.IsEnabled = state;
143      NameErcOptions.IsEnabled = state;
144      IntegerVectorErcOptions.IsEnabled = state;
145      FloatVectorErcOptions.IsEnabled = state;
146      StringVectorErcOptions.IsEnabled = state;
147    }
148  }
149}
Note: See TracBrowser for help on using the repository browser.