Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/28/18 16:56:41 (6 years ago)
Author:
bburlacu
Message:

#2886: address additional serialization issues, make Production implement IList<T> instead of deriving from List<T>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Grammar.cs

    r15974 r15975  
    2424    public Symbol StartSymbol { get; private set; }
    2525
    26     public Hasher<int> Hasher { get; }
     26    public Hasher<int> Hasher { get; private set; }
    2727
    2828    #region Symbols
     
    7777    public Grammar(string[] variables) : this(variables, Enum.GetValues(typeof(GrammarRule)).Cast<GrammarRule>()) { }
    7878
     79    [StorableConstructor]
     80    protected Grammar(bool deserializing) {
     81      InitTreeParser();
     82    }
     83
    7984    protected Grammar(Grammar original, Cloner cloner) : base(original, cloner) {
    8085      infixExpressionFormatter = cloner.Clone(original.infixExpressionFormatter);
     
    8388      VarTerminals = original.VarTerminals.Select(cloner.Clone).ToList();
    8489
    85       Var = cloner.Clone(original.Var);
    86       Expr = cloner.Clone(original.Expr);
    87       Term = cloner.Clone(original.Term);
    88       Factor = cloner.Clone(original.Factor);
    89       LogFactor = cloner.Clone(original.LogFactor);
    90       ExpFactor = cloner.Clone(original.ExpFactor);
    91       SinFactor = cloner.Clone(original.SinFactor);
    92       SimpleExpr = cloner.Clone(original.SimpleExpr);
    93       SimpleTerm = cloner.Clone(original.SimpleTerm);
    94       InvExpr = cloner.Clone(original.InvExpr);
    95       InvTerm = cloner.Clone(original.InvTerm);
    96 
    97       Addition = cloner.Clone(original.Addition);
    98       Multiplication = cloner.Clone(original.Multiplication);
    99       Log = cloner.Clone(original.Log);
    100       Exp = cloner.Clone(original.Exp);
    101       Sin = cloner.Clone(original.Sin);
    102       Inv = cloner.Clone(original.Inv);
    103       Const = cloner.Clone(original.Const);
     90      Var = (NonterminalSymbol)cloner.Clone(original.Var);
     91      Expr = (NonterminalSymbol)cloner.Clone(original.Expr);
     92      Term = (NonterminalSymbol)cloner.Clone(original.Term);
     93      Factor = (NonterminalSymbol)cloner.Clone(original.Factor);
     94      LogFactor = (NonterminalSymbol)cloner.Clone(original.LogFactor);
     95      ExpFactor = (NonterminalSymbol)cloner.Clone(original.ExpFactor);
     96      SinFactor = (NonterminalSymbol)cloner.Clone(original.SinFactor);
     97      SimpleExpr = (NonterminalSymbol)cloner.Clone(original.SimpleExpr);
     98      SimpleTerm = (NonterminalSymbol)cloner.Clone(original.SimpleTerm);
     99      InvExpr = (NonterminalSymbol)cloner.Clone(original.InvExpr);
     100      InvTerm = (NonterminalSymbol)cloner.Clone(original.InvTerm);
     101
     102      Addition = (TerminalSymbol)cloner.Clone(original.Addition);
     103      Multiplication = (TerminalSymbol)cloner.Clone(original.Multiplication);
     104      Log = (TerminalSymbol)cloner.Clone(original.Log);
     105      Exp = (TerminalSymbol)cloner.Clone(original.Exp);
     106      Sin = (TerminalSymbol)cloner.Clone(original.Sin);
     107      Inv = (TerminalSymbol)cloner.Clone(original.Inv);
     108      Const = (TerminalSymbol)cloner.Clone(original.Const);
    104109
    105110      StartSymbol = Expr;
     
    240245    public double EvaluatePhrase(SymbolString s, IRegressionProblemData problemData, bool optimizeConstants) {
    241246      SymbolicExpressionTree tree = ParseSymbolicExpressionTree(s);
     247
    242248      return RSquaredEvaluator.Evaluate(problemData, tree, optimizeConstants);
    243249    }
Note: See TracChangeset for help on using the changeset viewer.