Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis.Base/Erc/ErcOptions.cs @ 18061

Last change on this file since 18061 was 14952, checked in by pkimmesw, 7 years ago

#2665 Added IsNoop to Expression, Made Expressions storable, Fixed Debugger, Fixed and improved problem data and result visualisation, Added custom ErcOption view, Added problem difficulty to problem data name

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