Changeset 13269
- Timestamp:
- 11/19/15 09:57:06 (9 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/ArtificialAnt/Interpreter.cs
r12911 r13269 32 32 public int FoodEaten { get; private set; } 33 33 public BoolMatrix World { get; private set; } 34 35 34 public ISymbolicExpressionTree Expression { get; private set; } 36 35 36 public int ElapsedTime { get; set; } 37 37 38 public int ElapsedTime { get; set; }39 38 private int currentDirection; 40 39 private int currentAntLocationRow; -
trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/ArtificialAnt/Problem.cs
r13055 r13269 22 22 using System; 23 23 using System.Diagnostics.Contracts; 24 using System.Drawing.Text;25 24 using System.Linq; 26 25 using HeuristicLab.Common; … … 103 102 } 104 103 104 #region item cloning and persistence 105 // persistence 106 [StorableConstructor] 107 private Problem(bool deserializing) : base(deserializing) { } 108 [StorableHook(HookType.AfterDeserialization)] 109 private void AfterDeserialization() { } 110 111 // cloning 112 private Problem(Problem original, Cloner cloner) : base(original, cloner) { } 113 public override IDeepCloneable Clone(Cloner cloner) { 114 return new Problem(this, cloner); 115 } 116 #endregion 117 105 118 public Problem() 106 119 : base() { … … 136 149 } 137 150 138 // persistence139 [StorableConstructor]140 private Problem(bool deserializing) : base(deserializing) { }141 [StorableHook(HookType.AfterDeserialization)]142 private void AfterDeserialization() {143 }144 145 // cloning146 private Problem(Problem original, Cloner cloner)147 : base(original, cloner) {148 }149 public override IDeepCloneable Clone(Cloner cloner) {150 return new Problem(this, cloner);151 }152 153 151 #region helpers 154 152 private bool[,] ToBoolMatrix(char[][] ch) { -
trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/ArtificialAnt/Trail.cs
r12911 r13269 20 20 #endregion 21 21 22 using System;23 22 using System.Drawing; 24 23 using HeuristicLab.Common; … … 54 53 } 55 54 55 #region item cloning and persistence 56 56 [StorableConstructor] 57 57 private Solution(bool deserializing) : base(deserializing) { } … … 70 70 return new Solution(this, cloner); 71 71 } 72 #endregion 72 73 } 73 74 } -
trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/BasicSymbolicRegression/Problem.cs
r13267 r13269 39 39 40 40 #region parameter names 41 42 41 private const string ProblemDataParameterName = "ProblemData"; 43 44 42 #endregion 45 46 public event EventHandler ProblemDataChanged;47 43 48 44 #region Parameter Properties … … 52 48 get { return (IValueParameter<IRegressionProblemData>)Parameters[ProblemDataParameterName]; } 53 49 } 54 55 50 #endregion 56 51 57 52 #region Properties 58 59 53 public IRegressionProblemData ProblemData { 60 54 get { return ProblemDataParameter.Value; } … … 62 56 } 63 57 IDataAnalysisProblemData IDataAnalysisProblem.ProblemData { get { return ProblemData; } } 58 #endregion 64 59 65 66 #endregion 60 public event EventHandler ProblemDataChanged; 67 61 68 62 public override bool Maximization { 69 63 get { return true; } 70 64 } 65 66 #region item cloning and persistence 67 // persistence 68 [StorableConstructor] 69 private Problem(bool deserializing) : base(deserializing) { } 70 [StorableHook(HookType.AfterDeserialization)] 71 private void AfterDeserialization() { 72 RegisterEventHandlers(); 73 } 74 75 // cloning 76 private Problem(Problem original, Cloner cloner) 77 : base(original, cloner) { 78 RegisterEventHandlers(); 79 } 80 public override IDeepCloneable Clone(Cloner cloner) { return new Problem(this, cloner); } 81 #endregion 71 82 72 83 public Problem() … … 102 113 return InterpretRec(tree.Root.GetSubtree(0).GetSubtree(0), dataset, rows); 103 114 } 104 115 105 116 private IEnumerable<double> InterpretRec(ISymbolicExpressionTreeNode node, IDataset dataset, IEnumerable<int> rows) { 106 117 Func<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode, Func<double, double, double>, IEnumerable<double>> binaryEval = 107 (left, right, f) => InterpretRec(left, dataset, rows).Zip(InterpretRec(right, dataset, rows), f);118 (left, right, f) => InterpretRec(left, dataset, rows).Zip(InterpretRec(right, dataset, rows), f); 108 119 109 120 switch (node.Symbol.Name) { … … 124 135 } 125 136 126 #region item cloning and persistence127 // persistence128 [StorableConstructor]129 private Problem(bool deserializing) : base(deserializing) { }130 131 [StorableHook(HookType.AfterDeserialization)]132 private void AfterDeserialization() {133 RegisterEventHandlers();134 }135 136 // cloning137 private Problem(Problem original, Cloner cloner)138 : base(original, cloner) {139 RegisterEventHandlers();140 }141 public override IDeepCloneable Clone(Cloner cloner) {142 return new Problem(this, cloner);143 }144 #endregion145 137 146 138 #region events 147 148 139 private void RegisterEventHandlers() { 149 140 ProblemDataParameter.ValueChanged += new EventHandler(ProblemDataParameter_ValueChanged); … … 188 179 Encoding.Grammar = g; 189 180 } 190 191 181 #endregion 192 182 -
trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/EvenParityProblem.cs
r13267 r13269 58 58 } 59 59 60 #region item cloning and persistence 61 // persistence 62 [StorableConstructor] 63 private EvenParityProblem(bool deserializing) : base(deserializing) { } 64 [StorableHook(HookType.AfterDeserialization)] 65 private void AfterDeserialization() { 66 RegisterEventHandlers(); 67 } 68 69 // cloning 70 private EvenParityProblem(EvenParityProblem original, Cloner cloner) 71 : base(original, cloner) { 72 RegisterEventHandlers(); 73 } 74 public override IDeepCloneable Clone(Cloner cloner) { 75 return new EvenParityProblem(this, cloner); 76 } 77 #endregion 78 60 79 public EvenParityProblem() 61 80 : base() { … … 109 128 110 129 switch (node.Symbol.Name) { 111 case "AND": 112 case "OR": 130 case "AND": return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => x & y); 131 case "OR": return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => x | y); 113 132 case "NAND": return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => !(x & y)); 114 case "NOR": 133 case "NOR": return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => !(x | y)); 115 134 default: { 116 135 byte bitPos; … … 126 145 } 127 146 128 #region item cloning and persistence129 // persistence130 [StorableConstructor]131 private EvenParityProblem(bool deserializing) : base(deserializing) { }132 133 [StorableHook(HookType.AfterDeserialization)]134 private void AfterDeserialization() {135 RegisterEventHandlers();136 }137 138 // cloning139 private EvenParityProblem(EvenParityProblem original, Cloner cloner)140 : base(original, cloner) {141 RegisterEventHandlers();142 }143 public override IDeepCloneable Clone(Cloner cloner) {144 return new EvenParityProblem(this, cloner);145 }146 #endregion147 148 147 #region events 149 148 private void RegisterEventHandlers() { -
trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/MultiplexerProblem.cs
r13267 r13269 59 59 get { return true; } 60 60 } 61 62 #region item cloning and persistence 63 // persistence 64 [StorableConstructor] 65 private MultiplexerProblem(bool deserializing) : base(deserializing) { } 66 [StorableHook(HookType.AfterDeserialization)] 67 private void AfterDeserialization() { 68 RegisterEventHandlers(); 69 } 70 71 // cloning 72 private MultiplexerProblem(MultiplexerProblem original, Cloner cloner) 73 : base(original, cloner) { 74 RegisterEventHandlers(); 75 } 76 public override IDeepCloneable Clone(Cloner cloner) { 77 return new MultiplexerProblem(this, cloner); 78 } 79 #endregion 80 61 81 62 82 public MultiplexerProblem() … … 134 154 switch (node.Symbol.Name) { 135 155 case "AND": return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => x & y); 136 case "OR": 156 case "OR": return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => x | y); 137 157 case "NOT": return unaryEval(node.GetSubtree(0), (x) => !x); 138 case "IF": 158 case "IF": return EvalIf(node.GetSubtree(0), node.GetSubtree(1), node.GetSubtree(2), bs, addrBits); 139 159 default: { 140 160 if (node.Symbol.Name[0] == 'a') { … … 171 191 } 172 192 173 #region item cloning and persistence174 // persistence175 [StorableConstructor]176 private MultiplexerProblem(bool deserializing) : base(deserializing) { }177 178 [StorableHook(HookType.AfterDeserialization)]179 private void AfterDeserialization() {180 RegisterEventHandlers();181 }182 183 // cloning184 private MultiplexerProblem(MultiplexerProblem original, Cloner cloner)185 : base(original, cloner) {186 RegisterEventHandlers();187 }188 public override IDeepCloneable Clone(Cloner cloner) {189 return new MultiplexerProblem(this, cloner);190 }191 #endregion192 193 193 #region events 194 194 private void RegisterEventHandlers() { -
trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/LawnMower/Problem.cs
r13267 r13269 50 50 } 51 51 52 #region item cloning and persistence 52 53 [StorableConstructor] 53 54 protected Problem(bool deserializing) : base(deserializing) { } … … 59 60 return new Problem(this, cloner); 60 61 } 62 #endregion 61 63 62 64 public Problem() -
trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/LawnMower/Solution.cs
r13267 r13269 37 37 public double Quality { get; private set; } 38 38 39 #region item cloning and persistence 39 40 [StorableConstructor] 40 41 private Solution(bool deserializing) : base(deserializing) { } … … 52 53 return new Solution(this, cloner); 53 54 } 55 #endregion 54 56 55 57 public Solution(ISymbolicExpressionTree tree, int length, int width, double quality)
Note: See TracChangeset
for help on using the changeset viewer.