Changeset 17382 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean
- Timestamp:
- 12/18/19 16:11:21 (5 years ago)
- Location:
- branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/EvenParityProblem.cs
r17320 r17382 29 29 using HeuristicLab.Data; 30 30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 31 using HeuristicLab.Optimization; 31 32 using HeuristicLab.Parameters; 32 33 … … 104 105 105 106 106 public override doubleEvaluate(ISymbolicExpressionTree tree, IRandom random, CancellationToken cancellationToken) {107 public override ISingleObjectiveEvaluationResult Evaluate(ISymbolicExpressionTree tree, IRandom random, CancellationToken cancellationToken) { 107 108 if (NumberOfBits <= 0) throw new NotSupportedException("Number of bits must be larger than zero."); 108 109 if (NumberOfBits > 10) throw new NotSupportedException("Even parity does not support problems with number of bits > 10."); … … 110 111 var targets = bs.Select(b => CalcTarget(b, NumberOfBits)); 111 112 var pred = Interpret(tree, bs); 112 return targets.Zip(pred, (t, p) => t == p ? 1 : 0).Sum(); // count number of correct predictions 113 var quality = targets.Zip(pred, (t, p) => t == p ? 1 : 0).Sum(); // count number of correct predictions 114 115 return new SingleObjectiveEvaluationResult(quality); 113 116 } 114 117 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/MultiplexerProblem.cs
r17320 r17382 30 30 using HeuristicLab.Data; 31 31 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 32 using HeuristicLab.Optimization; 32 33 using HeuristicLab.Parameters; 33 34 … … 118 119 119 120 120 public override doubleEvaluate(ISymbolicExpressionTree tree, IRandom random, CancellationToken cancellationToken) {121 public override ISingleObjectiveEvaluationResult Evaluate(ISymbolicExpressionTree tree, IRandom random, CancellationToken cancellationToken) { 121 122 if (NumberOfBits <= 0) throw new NotSupportedException("Number of bits must be larger than zero."); 122 123 if (NumberOfBits > 37) throw new NotSupportedException("Multiplexer does not support problems with number of bits > 37."); … … 126 127 var targets = bs.Select(b => CalcTarget(b, addrBits, inputBits)); 127 128 var pred = Interpret(tree, bs, (byte)addrBits); 128 return targets.Zip(pred, (t, p) => t == p ? 1 : 0).Sum(); // count number of correct predictions 129 var quality = targets.Zip(pred, (t, p) => t == p ? 1 : 0).Sum(); // count number of correct predictions 130 131 return new SingleObjectiveEvaluationResult(quality); 129 132 } 130 133
Note: See TracChangeset
for help on using the changeset viewer.