Changeset 13267 for trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/EvenParityProblem.cs
- Timestamp:
- 11/18/15 22:29:17 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/EvenParityProblem.cs
r13163 r13267 38 38 39 39 #region parameter names 40 41 40 private const string NumberOfBitsParameterName = "NumberOfBits"; 42 43 41 #endregion 44 42 … … 47 45 get { return (IFixedValueParameter<IntValue>)Parameters[NumberOfBitsParameterName]; } 48 46 } 49 50 47 #endregion 51 48 52 49 #region Properties 53 54 50 public int NumberOfBits { 55 51 get { return NumberOfBitsParameter.Value.Value; } 56 52 set { NumberOfBitsParameter.Value.Value = value; } 57 53 } 58 59 60 54 #endregion 61 55 … … 110 104 } 111 105 112 113 106 private static IEnumerable<bool> InterpretRec(ISymbolicExpressionTreeNode node, IEnumerable<int> bs) { 114 Func<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode, Func<bool, bool, bool>, IEnumerable<bool>> eval2=107 Func<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode, Func<bool, bool, bool>, IEnumerable<bool>> binaryEval = 115 108 (left, right, f) => InterpretRec(left, bs).Zip(InterpretRec(right, bs), f); 116 109 117 110 switch (node.Symbol.Name) { 118 case "AND": return eval2(node.GetSubtree(0), node.GetSubtree(1), (x, y) => x & y);119 case "OR": return eval2(node.GetSubtree(0), node.GetSubtree(1), (x, y) => x | y);120 case "NAND": return eval2(node.GetSubtree(0), node.GetSubtree(1), (x, y) => !(x & y));121 case "NOR": return eval2(node.GetSubtree(0), node.GetSubtree(1), (x, y) => !(x | y));111 case "AND": return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => x & y); 112 case "OR": return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => x | y); 113 case "NAND": return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => !(x & y)); 114 case "NOR": return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => !(x | y)); 122 115 default: { 123 116 byte bitPos; … … 154 147 155 148 #region events 156 157 149 private void RegisterEventHandlers() { 158 150 NumberOfBitsParameter.Value.ValueChanged += (sender, args) => UpdateGrammar();
Note: See TracChangeset
for help on using the changeset viewer.