Free cookie consent management tool by TermsFeed Policy Generator

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

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

File:
1 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: {
Note: See TracChangeset for help on using the changeset viewer.