Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10788 for trunk


Ignore:
Timestamp:
04/24/14 09:23:18 (11 years ago)
Author:
mkommend
Message:

#2177: Corrected evaluation of the xor symbol in the interpreters.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs

    r10774 r10788  
    345345          }
    346346        case OpCodes.XOR: {
    347             double firstArgument = Evaluate(dataset, ref row, state);
    348             double result = 1.0;
    349             for (int i = 1; i < currentInstr.nArguments; i++) {
    350               if (result <= 0.0) {
    351                 state.SkipInstructions();
    352               } else {
    353                 double evalutationResult = Evaluate(dataset, ref row, state);
    354                 if (firstArgument <= 0 && evalutationResult > 0) result = -1.0;
    355                 else if (firstArgument > 0 && evalutationResult <= 0) result = -1.0;
    356               }
    357             }
    358             return result > 0.0 ? 1.0 : -1.0;
     347            //mkommend: XOR on multiple inputs is defined as true if the number of positive signals is odd
     348            // this is equal to a consecutive execution of binary XOR operations.
     349            int positiveSignals = 0;
     350            for (int i = 0; i < currentInstr.nArguments; i++) {
     351              if (Evaluate(dataset, ref row, state) > 0.0) positiveSignals++;
     352            }
     353            return positiveSignals % 2 != 0 ? 1.0 : -1.0;
    359354          }
    360355        case OpCodes.GT: {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs

    r10774 r10788  
    312312          instr.value = code[instr.childIndex].value > 0.0 ? -1.0 : 1.0;
    313313        } else if (instr.opCode == OpCodes.XOR) {
    314           double firstArgument = code[instr.childIndex].value;
    315           instr.value = 1.0;
    316           for (int j = 1; j < instr.nArguments; j++) {
    317             if (instr.value > 0.0) {
    318               if (firstArgument <= 0 && code[instr.childIndex + j].value > 0) instr.value = -1.0;
    319               if (firstArgument > 0 && code[instr.childIndex + j].value <= 0) instr.value = -1.0;
    320             } else break;
    321           }
    322           instr.value = instr.value > 0.0 ? 1.0 : -1.0;
     314          int positiveSignals = 0;
     315          for (int j = 0; j < instr.nArguments; j++) {
     316            if (code[instr.childIndex + j].value > 0.0) positiveSignals++;
     317          }
     318          instr.value = positiveSignals % 2 != 0 ? 1.0 : -1.0;
    323319        } else if (instr.opCode == OpCodes.GT) {
    324320          double x = code[instr.childIndex].value;
Note: See TracChangeset for help on using the changeset viewer.