Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17465


Ignore:
Timestamp:
03/02/20 16:35:29 (4 years ago)
Author:
pfleck
Message:

#3040 Simplified default vector grammar.

Location:
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentVectorExpressionGrammar.cs

    r17463 r17465  
    185185      AddAllowedChildSymbol(vectorroot, constant, 1);
    186186      #endregion
     187
     188      #region default enabled/disabled
     189      var disabledByDefault = new[] {
     190        TrigonometricFunctionsName, ExponentialFunctionsName, PowerFunctionsName,
     191        VectorTrigonometricFunctionsName, VectorExponentialFunctionsName, VectorPowerFunctionsName
     192      };
     193      foreach (var grp in Symbols.Where(sym => disabledByDefault.Contains(sym.Name)))
     194        grp.Enabled = false;
     195      #endregion
    187196    }
    188197
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeVectorInterpreter.cs

    r17463 r17465  
    152152
    153153      public DoubleVector Vector { get; }
    154       public bool IsVector => Vector != null;
    155       //public bool IsVector => !(Vector.Count == 1 && double.IsNaN(Vector[0]));
     154      public bool IsVector => !(Vector.Count == 1 && double.IsNaN(Vector[0]));
    156155
    157156      public bool IsNaN => !IsScalar && !IsVector;
     
    159158      public EvaluationResult(double scalar) {
    160159        Scalar = scalar;
    161         //Vector = NaNVector;
    162         Vector = null;
     160        Vector = NaNVector;
    163161      }
    164162      public EvaluationResult(DoubleVector vector) {
     
    174172      }
    175173
     174      private static readonly DoubleVector NaNVector = DoubleVector.Build.Dense(1, double.NaN);
    176175      public static readonly EvaluationResult NaN = new EvaluationResult(double.NaN);
    177       //private static readonly DoubleVector NaNVector = DoubleVector.Build.Dense(1, double.NaN);
    178176    }
    179177
     
    188186      if (lhs.IsVector && rhs.IsVector && vvFunc != null) return new EvaluationResult(vvFunc(lhs.Vector, rhs.Vector));
    189187      return EvaluationResult.NaN;
    190       //throw new NotSupportedException($"Unsupported combination of argument types: ({lhs}) / ({rhs})");
    191188    }
    192189
     
    197194      if (val.IsVector && vFunc != null) return new EvaluationResult(vFunc(val.Vector));
    198195      return EvaluationResult.NaN;
    199       //throw new NotSupportedException($"Unsupported argument type ({val})");
    200196    }
    201197    private static EvaluationResult AggregateApply(EvaluationResult val,
     
    205201      if (val.IsVector && vFunc != null) return new EvaluationResult(vFunc(val.Vector));
    206202      return EvaluationResult.NaN;
    207       //throw new NotSupportedException($"Unsupported argument type ({val})");
    208203    }
    209204
Note: See TracChangeset for help on using the changeset viewer.