Ignore:
Timestamp:
06/12/14 13:26:18 (5 years ago)
Author:
pfleck
Message:
  • Merged trunk into preprocessing branch.
Location:
branches/DataPreprocessing
Files:
16 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing

  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisAlleleFrequencyAnalyzer.cs

    r9456 r11009  
    7575    public static Allele[] CalculateAlleles(ISymbolicExpressionTree solution, int alleleTreedepth) {
    7676      return GetAllSubtreesOfDepth(solution, alleleTreedepth)
    77         .AsParallel()
    7877        .Select(t => GetAlleleFromSubtreeOfDepth(t, alleleTreedepth))
    7978        .ToArray();
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveValidationBestSolutionAnalyzer.cs

    r9456 r11009  
    121121
    122122      var qualities = tree
    123         .AsParallel()
    124123        .Select(t => evaluator.Evaluate(childContext, t, problemData, rows))
    125124        .ToArray();
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectivePruningAnalyzer.cs

    r10538 r11009  
    148148      if (end > count) end = count;
    149149
     150      if (PopulationSlice.Start > 1 || PopulationSlice.End > 1) throw new ArgumentOutOfRangeException("The slice bounds should be expressed as unit percentages.");
    150151      if (start >= end) throw new ArgumentOutOfRangeException("Invalid PopulationSlice bounds.");
    151152      return new IntRange(start, end);
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer.cs

    r9456 r11009  
    3535  [Item("SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer", "An operator that analyzes the training best symbolic data analysis solution for single objective symbolic data analysis problems.")]
    3636  [StorableClass]
    37   public abstract class SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer<T> : SymbolicDataAnalysisSingleObjectiveAnalyzer
     37  public abstract class SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer<T> : SymbolicDataAnalysisSingleObjectiveAnalyzer, IIterationBasedOperator
     38
    3839    where T : class, ISymbolicDataAnalysisSolution {
    3940    private const string TrainingBestSolutionParameterName = "Best training solution";
    4041    private const string TrainingBestSolutionQualityParameterName = "Best training solution quality";
     42    private const string TrainingBestSolutionGenerationParameterName = "Best training solution generation";
    4143    private const string UpdateAlwaysParameterName = "Always update best solution";
     44    private const string IterationsParameterName = "Iterations";
     45    private const string MaximumIterationsParameterName = "Maximum Iterations";
    4246
    4347    #region parameter properties
     
    4852      get { return (ILookupParameter<DoubleValue>)Parameters[TrainingBestSolutionQualityParameterName]; }
    4953    }
     54    public ILookupParameter<IntValue> TrainingBestSolutionGenerationParameter {
     55      get { return (ILookupParameter<IntValue>)Parameters[TrainingBestSolutionGenerationParameterName]; }
     56    }
    5057    public IFixedValueParameter<BoolValue> UpdateAlwaysParameter {
    5158      get { return (IFixedValueParameter<BoolValue>)Parameters[UpdateAlwaysParameterName]; }
     59    }
     60    public ILookupParameter<IntValue> IterationsParameter {
     61      get { return (ILookupParameter<IntValue>)Parameters[IterationsParameterName]; }
     62    }
     63    public IValueLookupParameter<IntValue> MaximumIterationsParameter {
     64      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumIterationsParameterName]; }
    5265    }
    5366    #endregion
     
    7386      Parameters.Add(new LookupParameter<T>(TrainingBestSolutionParameterName, "The training best symbolic data analyis solution."));
    7487      Parameters.Add(new LookupParameter<DoubleValue>(TrainingBestSolutionQualityParameterName, "The quality of the training best symbolic data analysis solution."));
     88      Parameters.Add(new LookupParameter<IntValue>(TrainingBestSolutionGenerationParameterName, "The generation in which the best training solution was found."));
    7589      Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best training solution should always be updated regardless of its quality.", new BoolValue(false)));
     90      Parameters.Add(new LookupParameter<IntValue>(IterationsParameterName, "The number of performed iterations."));
     91      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumIterationsParameterName, "The maximum number of performed iterations.") { Hidden = true });
    7692      UpdateAlwaysParameter.Hidden = true;
    7793    }
     
    8399        UpdateAlwaysParameter.Hidden = true;
    84100      }
     101      if (!Parameters.ContainsKey(TrainingBestSolutionGenerationParameterName))
     102        Parameters.Add(new LookupParameter<IntValue>(TrainingBestSolutionGenerationParameterName, "The generation in which the best training solution was found."));
     103      if (!Parameters.ContainsKey(IterationsParameterName))
     104        Parameters.Add(new LookupParameter<IntValue>(IterationsParameterName, "The number of performed iterations."));
     105      if (!Parameters.ContainsKey(MaximumIterationsParameterName))
     106        Parameters.Add(new ValueLookupParameter<IntValue>(MaximumIterationsParameterName, "The maximum number of performed iterations.") { Hidden = true });
    85107    }
    86108
     
    104126        TrainingBestSolution = CreateSolution(bestTree, bestQuality);
    105127        TrainingBestSolutionQuality = new DoubleValue(bestQuality);
     128        if (IterationsParameter.ActualValue != null)
     129          TrainingBestSolutionGenerationParameter.ActualValue = new IntValue(IterationsParameter.ActualValue.Value);
    106130
    107131        if (!results.ContainsKey(TrainingBestSolutionParameter.Name)) {
    108132          results.Add(new Result(TrainingBestSolutionParameter.Name, TrainingBestSolutionParameter.Description, TrainingBestSolution));
    109133          results.Add(new Result(TrainingBestSolutionQualityParameter.Name, TrainingBestSolutionQualityParameter.Description, TrainingBestSolutionQuality));
     134          if (TrainingBestSolutionGenerationParameter.ActualValue != null)
     135            results.Add(new Result(TrainingBestSolutionGenerationParameter.Name, TrainingBestSolutionGenerationParameter.Description, TrainingBestSolutionGenerationParameter.ActualValue));
    110136        } else {
    111137          results[TrainingBestSolutionParameter.Name].Value = TrainingBestSolution;
    112138          results[TrainingBestSolutionQualityParameter.Name].Value = TrainingBestSolutionQuality;
     139          if (TrainingBestSolutionGenerationParameter.ActualValue != null)
     140            results[TrainingBestSolutionGenerationParameter.Name].Value = TrainingBestSolutionGenerationParameter.ActualValue;
     141
    113142        }
    114143      }
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer.cs

    r9456 r11009  
    3737  [Item("SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer", "An operator that analyzes the validation best symbolic data analysis solution for single objective symbolic data analysis problems.")]
    3838  [StorableClass]
    39   public abstract class SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer<S, T, U> : SymbolicDataAnalysisSingleObjectiveValidationAnalyzer<T, U>
     39  public abstract class SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer<S, T, U> : SymbolicDataAnalysisSingleObjectiveValidationAnalyzer<T, U>, IIterationBasedOperator
    4040    where S : class, ISymbolicDataAnalysisSolution
    4141    where T : class, ISymbolicDataAnalysisSingleObjectiveEvaluator<U>
     
    4343    private const string ValidationBestSolutionParameterName = "Best validation solution";
    4444    private const string ValidationBestSolutionQualityParameterName = "Best validation solution quality";
     45    private const string ValidationBestSolutionGenerationParameterName = "Best validation solution generation";
    4546    private const string UpdateAlwaysParameterName = "Always update best solution";
     47    private const string IterationsParameterName = "Iterations";
     48    private const string MaximumIterationsParameterName = "Maximum Iterations";
    4649
    4750    #region parameter properties
     
    5255      get { return (ILookupParameter<DoubleValue>)Parameters[ValidationBestSolutionQualityParameterName]; }
    5356    }
     57    public ILookupParameter<IntValue> ValidationBestSolutionGenerationParameter {
     58      get { return (ILookupParameter<IntValue>)Parameters[ValidationBestSolutionGenerationParameterName]; }
     59    }
    5460    public IFixedValueParameter<BoolValue> UpdateAlwaysParameter {
    5561      get { return (IFixedValueParameter<BoolValue>)Parameters[UpdateAlwaysParameterName]; }
     62    }
     63    public ILookupParameter<IntValue> IterationsParameter {
     64      get { return (ILookupParameter<IntValue>)Parameters[IterationsParameterName]; }
     65    }
     66    public IValueLookupParameter<IntValue> MaximumIterationsParameter {
     67      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumIterationsParameterName]; }
    5668    }
    5769    #endregion
     
    7789      Parameters.Add(new LookupParameter<S>(ValidationBestSolutionParameterName, "The validation best symbolic data analyis solution."));
    7890      Parameters.Add(new LookupParameter<DoubleValue>(ValidationBestSolutionQualityParameterName, "The quality of the validation best symbolic data analysis solution."));
     91      Parameters.Add(new LookupParameter<IntValue>(ValidationBestSolutionGenerationParameterName, "The generation in which the best validation solution was found."));
    7992      Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best validation solution should always be updated regardless of its quality.", new BoolValue(false)));
     93      Parameters.Add(new LookupParameter<IntValue>(IterationsParameterName, "The number of performed iterations."));
     94      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumIterationsParameterName, "The maximum number of performed iterations.") { Hidden = true });
    8095      UpdateAlwaysParameter.Hidden = true;
    8196    }
     
    8499    private void AfterDeserialization() {
    85100      if (!Parameters.ContainsKey(UpdateAlwaysParameterName)) {
    86         Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best training solution should always be updated regardless of its quality.", new BoolValue(false)));
     101        Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best validation solution should always be updated regardless of its quality.", new BoolValue(false)));
    87102        UpdateAlwaysParameter.Hidden = true;
    88103      }
     104      if (!Parameters.ContainsKey(ValidationBestSolutionGenerationParameterName))
     105        Parameters.Add(new LookupParameter<IntValue>(ValidationBestSolutionGenerationParameterName, "The generation in which the best validation solution was found."));
     106      if (!Parameters.ContainsKey(IterationsParameterName))
     107        Parameters.Add(new LookupParameter<IntValue>(IterationsParameterName, "The number of performed iterations."));
     108      if (!Parameters.ContainsKey(MaximumIterationsParameterName))
     109        Parameters.Add(new ValueLookupParameter<IntValue>(MaximumIterationsParameterName, "The maximum number of performed iterations.") { Hidden = true });
    89110    }
    90111
     
    121142      var quality = tree
    122143        .Take(topN)
    123         .AsParallel()
    124144        .Select(t => evaluator.Evaluate(childContext, t, problemData, rows))
    125145        .ToArray();
     
    138158        ValidationBestSolution = CreateSolution(bestTree, bestValidationQuality);
    139159        ValidationBestSolutionQuality = new DoubleValue(bestValidationQuality);
     160        if (IterationsParameter.ActualValue != null)
     161          ValidationBestSolutionGenerationParameter.ActualValue = new IntValue(IterationsParameter.ActualValue.Value);
    140162
    141163        if (!results.ContainsKey(ValidationBestSolutionParameter.Name)) {
    142164          results.Add(new Result(ValidationBestSolutionParameter.Name, ValidationBestSolutionParameter.Description, ValidationBestSolution));
    143165          results.Add(new Result(ValidationBestSolutionQualityParameter.Name, ValidationBestSolutionQualityParameter.Description, ValidationBestSolutionQuality));
     166          if (ValidationBestSolutionGenerationParameter.ActualValue != null)
     167            results.Add(new Result(ValidationBestSolutionGenerationParameter.Name, ValidationBestSolutionGenerationParameter.Description, ValidationBestSolutionGenerationParameter.ActualValue));
    144168        } else {
    145169          results[ValidationBestSolutionParameter.Name].Value = ValidationBestSolution;
    146170          results[ValidationBestSolutionQualityParameter.Name].Value = ValidationBestSolutionQuality;
     171          if (ValidationBestSolutionGenerationParameter.ActualValue != null)
     172            results[ValidationBestSolutionGenerationParameter.Name].Value = ValidationBestSolutionGenerationParameter.ActualValue;
    147173        }
    148174      }
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationParetoBestSolutionAnalyzer.cs

    r9456 r11009  
    120120        .Select(i => tree[i])
    121121        .Take(topN)
    122         .AsParallel()
    123122        .Select(t => evaluator.Evaluate(childContext, t, problemData, rows))
    124123        .ToArray();
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisVariableFrequencyAnalyzer.cs

    r9456 r11009  
    131131
    132132      var variableFrequencies = trees
    133         .AsParallel()
    134133        .SelectMany(t => GetVariableReferences(t, aggregateLaggedVariables))
    135134        .GroupBy(pair => pair.Key, pair => pair.Value)
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs

    r9456 r11009  
    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
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs

    r9992 r11009  
    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;
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r10925 r11009  
    126126      <SubType>Code</SubType>
    127127    </Compile>
     128    <Compile Include="Matching\SymbolicExpressionTreeCanonicalSorter.cs" />
     129    <Compile Include="Matching\SymbolicExpressionTreeEqualityComparer.cs" />
     130    <Compile Include="Matching\SymbolicExpressionTreeMatching.cs" />
     131    <Compile Include="Matching\SymbolicExpressionTreeMaxCommonSequenceCalculator.cs" />
     132    <Compile Include="Matching\SymbolicExpressionTreeNodeComparer.cs" />
     133    <Compile Include="Matching\SymbolicExpressionTreeNodeSimilarityComparer.cs" />
    128134    <Compile Include="SymbolicExpressionTreeBacktransformator.cs" />
    129135    <Compile Include="SymbolicDataAnalysisExpressionPruningOperator.cs" />
     
    181187    <Compile Include="Symbols\AiryB.cs" />
    182188    <Compile Include="Symbols\Bessel.cs" />
     189    <Compile Include="Symbols\Xor.cs" />
    183190    <Compile Include="Symbols\Erf.cs" />
    184191    <Compile Include="Symbols\Norm.cs" />
     
    324331      <Project>{2e257a94-d1af-435c-99b4-5ac00eadfd6a}</Project>
    325332      <Name>HeuristicLab.Problems.DataAnalysis.Transformations-3.4</Name>
     333      <Private>False</Private>
    326334    </ProjectReference>
    327335    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj">
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs

    r9456 r11009  
    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 },
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs

    r9828 r11009  
    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          }
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs

    r9828 r11009  
    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);
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs

    r9944 r11009  
    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;
Note: See TracChangeset for help on using the changeset viewer.