Free cookie consent management tool by TermsFeed Policy Generator

source: branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/SimpleConstraintHandler.cs @ 15414

Last change on this file since 15414 was 15414, checked in by gkronber, 7 years ago

#2796 worked on MCTS

File size: 1.6 KB
Line 
1
2using HeuristicLab.Algorithms.DataAnalysis.MctsSymbolicRegression;
3
4namespace HeuristicLab.Algorithms.DataAnalysis.MctsSymbolicRegression {
5  // only counts the number of variable references
6  internal class SimpleConstraintHandler : IConstraintHandler {
7    private int maxVariables;
8    private int numVariables;
9
10    public bool IsInvalidExpression {
11      get {
12        return numVariables > maxVariables;
13      }
14    }
15
16    public SimpleConstraintHandler(int maxVars) {
17      this.maxVariables = maxVars;
18    }
19
20    public void AddVarToCurrentFactor(int state) {
21      numVariables++;
22    }
23
24    public void EndFactor() {
25      // ignore
26    }
27
28    public void EndTerm() {
29      // ignore
30    }
31
32    public bool IsAllowedFollowState(int currentState, int followState) {
33      return numVariables < maxVariables ||
34        // going to the final state is always allowed (smaller states are closer to the final state)
35        currentState > followState;
36        // (
37        // followState != Automaton.StateExpFactorStart &&
38        // followState != Automaton.StateFactorStart &&
39        // followState != Automaton.StateTermStart &&
40        // followState != Automaton.StateLogTStart &&
41        // followState != Automaton.StateLogTFStart &&
42        // followState != Automaton.StateInvTStart &&
43        // followState != Automaton.StateInvTFStart);
44    }
45
46    public void Reset() {
47      numVariables = 0;     
48    }
49
50    public void StartFactor(int state) {
51      // ignore
52    }
53
54    public void StartNewTermInPoly() {
55      // ignore
56    }
57
58    public void StartTerm() {
59      // ignore
60    }
61  }
62}
Note: See TracBrowser for help on using the repository browser.