Last change
on this file since 15866 was
15771,
checked in by bburlacu, 7 years ago
|
#2895: Add solution skeleton for PushGP with genealogy analysis.
|
File size:
1.7 KB
|
Line | |
---|
1 | namespace HeuristicLab.Problems.ProgramSynthesis { |
---|
2 | using System;
|
---|
3 |
|
---|
4 | using HeuristicLab.Common;
|
---|
5 | using HeuristicLab.Core;
|
---|
6 | using HeuristicLab.Data;
|
---|
7 | using HeuristicLab.Parameters;
|
---|
8 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
9 |
|
---|
10 | [StorableClass]
|
---|
11 | public abstract class WeightedErcItem<T> : ParameterizedNamedItem, IWeightedErcItem<T> {
|
---|
12 | private const string WeightParameterName = "Weight";
|
---|
13 |
|
---|
14 | [Storable]
|
---|
15 | protected bool isEnabled;
|
---|
16 |
|
---|
17 | public event EventHandler<bool> EnabledChanged;
|
---|
18 |
|
---|
19 | protected WeightedErcItem() : this(false, 1d) { }
|
---|
20 |
|
---|
21 | protected WeightedErcItem(bool isEnabled, double weigth) {
|
---|
22 | this.isEnabled = isEnabled;
|
---|
23 | Parameters.Add(new FixedValueParameter<DoubleValue>(WeightParameterName, new DoubleValue(weigth)));
|
---|
24 | }
|
---|
25 |
|
---|
26 | [StorableConstructor]
|
---|
27 | protected WeightedErcItem(bool deserializing) : base(deserializing) { }
|
---|
28 |
|
---|
29 | protected WeightedErcItem(WeightedErcItem<T> origin, Cloner cloner)
|
---|
30 | : base(origin, cloner) {
|
---|
31 | isEnabled = origin.IsEnabled;
|
---|
32 | }
|
---|
33 |
|
---|
34 | public IValueParameter<DoubleValue> WeightParameter
|
---|
35 | {
|
---|
36 | get { return (IValueParameter<DoubleValue>)Parameters[WeightParameterName]; }
|
---|
37 | }
|
---|
38 |
|
---|
39 | public double Weight
|
---|
40 | {
|
---|
41 | get { return WeightParameter.Value.Value; }
|
---|
42 | set { WeightParameter.Value.Value = value; }
|
---|
43 | }
|
---|
44 |
|
---|
45 | public bool IsEnabled
|
---|
46 | {
|
---|
47 | get { return isEnabled; }
|
---|
48 | set
|
---|
49 | {
|
---|
50 | if (value == isEnabled)
|
---|
51 | return;
|
---|
52 |
|
---|
53 | isEnabled = value;
|
---|
54 |
|
---|
55 | if (EnabledChanged != null)
|
---|
56 | EnabledChanged(this, value);
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | public abstract T GetErcValue(IRandom random);
|
---|
61 | }
|
---|
62 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.