Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10910


Ignore:
Timestamp:
05/28/14 15:19:54 (10 years ago)
Author:
mkommend
Message:

#2177: Merged r10774 and r10788:10791 into stable.

Location:
stable
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs

    r9456 r10910  
    9999      var or = new Or();
    100100      var not = new Not();
     101      var xor = new Xor();
    101102
    102103      var timeLag = new TimeLag();
     
    122123      var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, square, pow, sqrt, root, exp,
    123124        airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral,
    124         @if, gt, lt, and, or, not, timeLag, integral, derivative, constant, variableSymbol, laggedVariable,autoregressiveVariable, variableCondition };
     125        @if, gt, lt, and, or, not,xor, timeLag, integral, derivative, constant, variableSymbol, laggedVariable,autoregressiveVariable, variableCondition };
    125126      var unaryFunctionSymbols = new List<Symbol>() { square, sqrt, sin, cos, tan, log, exp, not, timeLag, integral, derivative,
    126127        airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral
     
    128129
    129130      var binaryFunctionSymbols = new List<Symbol>() { pow, root, gt, lt, variableCondition };
    130       var ternarySymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or };
     131      var ternarySymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or, xor };
    131132      var terminalSymbols = new List<Symbol>() { variableSymbol, constant, laggedVariable, autoregressiveVariable };
    132133
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs

    r10020 r10910  
    9393      var or = new Or();
    9494      var not = new Not();
     95      var xor = new Xor();
    9596      var variableCondition = new VariableCondition();
    9697
     
    120121      var conditionSymbols = new GroupSymbol(ConditionsName, new List<ISymbol> { @if, variableCondition });
    121122      var comparisonSymbols = new GroupSymbol(ComparisonsName, new List<ISymbol> { gt, lt });
    122       var booleanOperationSymbols = new GroupSymbol(BooleanOperatorsName, new List<ISymbol> { and, or, not });
     123      var booleanOperationSymbols = new GroupSymbol(BooleanOperatorsName, new List<ISymbol> { and, or, not, xor });
    123124      var conditionalSymbols = new GroupSymbol(ConditionalSymbolsName, new List<ISymbol> { conditionSymbols, comparisonSymbols, booleanOperationSymbols });
    124125
     
    148149      SetSubtreeCount(or, 2, 2);
    149150      SetSubtreeCount(not, 1, 1);
     151      SetSubtreeCount(xor, 2, 2);
    150152
    151153      SetSubtreeCount(timeLag, 1, 1);
     
    237239      Symbols.First(s => s is Average).Enabled = false;
    238240      Symbols.First(s => s is VariableCondition).Enabled = false;
     241      Symbols.First(s => s is Xor).Enabled = false;
    239242      Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false;
    240243      Symbols.First(s => s.Name == ExponentialFunctionsName).Enabled = false;
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r9976 r10910  
    178178    <Compile Include="Symbols\AiryB.cs" />
    179179    <Compile Include="Symbols\Bessel.cs" />
     180    <Compile Include="Symbols\Xor.cs" />
    180181    <Compile Include="Symbols\Erf.cs" />
    181182    <Compile Include="Symbols\Norm.cs" />
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs

    r9456 r10910  
    4646    public const byte OR = 14;
    4747    public const byte NOT = 15;
     48    public const byte XOR = 45;
    4849
    4950
     
    99100      { typeof(Or), OpCodes.OR },
    100101      { typeof(Not), OpCodes.NOT},
     102      { typeof(Xor),OpCodes.XOR},
    101103      { typeof(Average), OpCodes.Average},
    102104      { typeof(InvokeFunction), OpCodes.Call },
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs

    r9976 r10910  
    447447            il.Emit(System.Reflection.Emit.OpCodes.Sub);
    448448            il.Emit(System.Reflection.Emit.OpCodes.Neg); // * -1
     449            return;
     450          }
     451        case OpCodes.XOR: {
     452            CompileInstructions(il, state, ds);
     453            il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0);
     454            il.Emit(System.Reflection.Emit.OpCodes.Cgt);// > 0
     455
     456            for (int i = 1; i < nArgs; i++) {
     457              CompileInstructions(il, state, ds);
     458              il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0);
     459              il.Emit(System.Reflection.Emit.OpCodes.Cgt);// > 0
     460              il.Emit(System.Reflection.Emit.OpCodes.Xor);
     461            }
     462            il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 2.0); // * 2
     463            il.Emit(System.Reflection.Emit.OpCodes.Mul);
     464            il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 1.0); // - 1
     465            il.Emit(System.Reflection.Emit.OpCodes.Sub);
    449466            return;
    450467          }
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs

    r9976 r10910  
    344344            return Evaluate(dataset, ref row, state) > 0.0 ? -1.0 : 1.0;
    345345          }
     346        case OpCodes.XOR: {
     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;
     354          }
    346355        case OpCodes.GT: {
    347356            double x = Evaluate(dataset, ref row, state);
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs

    r9976 r10910  
    311311        } else if (instr.opCode == OpCodes.NOT) {
    312312          instr.value = code[instr.childIndex].value > 0.0 ? -1.0 : 1.0;
     313        } else if (instr.opCode == OpCodes.XOR) {
     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;
    313319        } else if (instr.opCode == OpCodes.GT) {
    314320          double x = code[instr.childIndex].value;
  • stable/HeuristicLab.Tests

  • stable/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeInterpreterTest.cs

    r9979 r10910  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Diagnostics;
    2524using System.Globalization;
    2625using System.Linq;
    27 using System.Linq.Expressions;
    2826using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2927using HeuristicLab.Random;
     
    319317      Evaluate(interpreter, ds, "(and (log -1.0)  1.0)", 0, -1.0); // (and NaN 1.0)
    320318
    321 
    322319      // OR
    323320      Evaluate(interpreter, ds, "(or -1.0 -2.0)", 0, -1.0);
     
    330327      Evaluate(interpreter, ds, "(or (log -1.0))", 0, -1.0); // (or NaN)
    331328      Evaluate(interpreter, ds, "(or (log -1.0)  1.0)", 0, -1.0); // (or NaN 1.0)
     329
     330      // XOR
     331      Evaluate(interpreter, ds, "(xor -1.0 -2.0)", 0, -1.0);
     332      Evaluate(interpreter, ds, "(xor -1.0 2.0)", 0, 1.0);
     333      Evaluate(interpreter, ds, "(xor 1.0 -2.0)", 0, 1.0);
     334      Evaluate(interpreter, ds, "(xor 1.0 2.0)", 0, -1.0);
     335      Evaluate(interpreter, ds, "(xor 0.0 0.0)", 0, -1.0);
     336      Evaluate(interpreter, ds, "(xor -1.0 -2.0 -3.0)", 0, -1.0);
     337      Evaluate(interpreter, ds, "(xor -1.0 -2.0 3.0)", 0, 1.0);
     338      Evaluate(interpreter, ds, "(xor -1.0 2.0 3.0)", 0, -1.0);
     339      Evaluate(interpreter, ds, "(xor 1.0 2.0 3.0)", 0, 1.0);
     340      Evaluate(interpreter, ds, "(xor (log -1.0))", 0, -1.0);
     341      Evaluate(interpreter, ds, "(xor (log -1.0)  1.0)", 0, 1.0);
    332342
    333343      // sin, cos, tan
  • stable/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicExpressionImporter.cs

    r9885 r10910  
    7070        {"OR", new Or()},
    7171        {"NOT", new Not()},
     72        {"XOR", new Xor()},
    7273        {"DIFF", new Derivative()},
    7374        {"PROG", new ProgramRootSymbol()},
Note: See TracChangeset for help on using the changeset viewer.