Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/29/17 21:22:21 (7 years ago)
Author:
gkronber
Message:

#2796 fixed hashing of expressions and unit tests for expression enumeration

Location:
branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4
Files:
1 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis.MCTSSymbReg.csproj

    r15438 r15440  
    104104    <Compile Include="MctsSymbolicRegression\Disassembler.cs" />
    105105    <Compile Include="MctsSymbolicRegression\ExpressionEvaluator.cs" />
     106    <Compile Include="MctsSymbolicRegression\ExprHashSymbolic.cs" />
    106107    <Compile Include="MctsSymbolicRegression\MctsSymbolicRegressionAlgorithm.cs" />
    107108    <Compile Include="MctsSymbolicRegression\MctsSymbolicRegressionStatic.cs" />
    108109    <Compile Include="MctsSymbolicRegression\OpCodes.cs" />
    109     <Compile Include="MctsSymbolicRegression\ExprHash.cs" />
    110110    <Compile Include="MctsSymbolicRegression\SymbolicExpressionGenerator.cs" />
    111111    <Compile Include="MctsSymbolicRegression\Tree.cs" />
  • branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/Automaton.cs

    r15438 r15440  
    424424        v == StateLogTFEnd ||
    425425        v == StateInvTFEnd ||
    426         v == StateExpFEnd
     426        v == StateExpFEnd ||
     427        v == StateLogTEnd ||
     428        v == StateInvTEnd ||
     429        v == StateTermEnd
    427430        ;
    428431    }
  • branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/MctsSymbolicRegressionStatic.cs

    r15439 r15440  
    587587            // for selected states (EvalStates) we introduce state unification (detection of equivalent states)
    588588            if (automaton.IsEvalState(possibleFollowStates[i])) {
    589               var hc = Hashcode(automaton) * (ulong)tree.state; // TODO fix unit test for structure enumeration
     589              var hc = Hashcode(automaton);
     590              hc = ((hc << 5) + hc) ^ (ulong)tree.state; // TODO fix unit test for structure enumeration
    590591              if (!state.nodes.TryGetValue(hc, out child)) {
     592                // Console.WriteLine("New expression (hash: {0}, state: {1})", Hashcode(automaton), automaton.stateNames[possibleFollowStates[i]]);
    591593                child = new Tree() {
    592594                  state = possibleFollowStates[i],
     
    598600              // only allow forward edges (don't add the child if we would go back in the graph)
    599601              else if (child.level > tree.level) {
     602                // Console.WriteLine("Existing expression (hash: {0}, state: {1})", Hashcode(automaton), automaton.stateNames[possibleFollowStates[i]]);
    600603                // whenever we join paths we need to propagate back the statistics of the existing node through the newly created link
    601604                // to all parents
    602605                BackpropagateStatistics(tree, state, child.visits);
    603606              } else {
     607                // Console.WriteLine("Cycle (hash: {0}, state: {1})", Hashcode(automaton), automaton.stateNames[possibleFollowStates[i]]);
    604608                // prevent cycles
    605609                Debug.Assert(child.level <= tree.level);
     
    688692      int nParams;
    689693      automaton.GetCode(out code, out nParams);
    690       return ExprHash.GetHash(code, nParams);
     694      return (ulong)ExprHashSymbolic.GetHash(code, nParams);
    691695    }
    692696
Note: See TracChangeset for help on using the changeset viewer.