Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/18/15 22:29:17 (9 years ago)
Author:
mkommend
Message:

#2472: Minor code improvements in HL.Problems.GP (typos, code organization, code unification).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/EvenParityProblem.cs

    r13163 r13267  
    3838
    3939    #region parameter names
    40 
    4140    private const string NumberOfBitsParameterName = "NumberOfBits";
    42 
    4341    #endregion
    4442
     
    4745      get { return (IFixedValueParameter<IntValue>)Parameters[NumberOfBitsParameterName]; }
    4846    }
    49 
    5047    #endregion
    5148
    5249    #region Properties
    53 
    5450    public int NumberOfBits {
    5551      get { return NumberOfBitsParameter.Value.Value; }
    5652      set { NumberOfBitsParameter.Value.Value = value; }
    5753    }
    58 
    59 
    6054    #endregion
    6155
     
    110104    }
    111105
    112 
    113106    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 =
    115108        (left, right, f) => InterpretRec(left, bs).Zip(InterpretRec(right, bs), f);
    116109
    117110      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));
    122115        default: {
    123116            byte bitPos;
     
    154147
    155148    #region events
    156 
    157149    private void RegisterEventHandlers() {
    158150      NumberOfBitsParameter.Value.ValueChanged += (sender, args) => UpdateGrammar();
Note: See TracChangeset for help on using the changeset viewer.