Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/11/15 03:01:59 (10 years ago)
Author:
gkronber
Message:

#2283 commit for 'realistic' (same settings for ant and symbreg) experiment

Location:
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/SequentialDecisionPolicies/GenericFunctionApproximationGrammarPolicy.cs

    r11976 r11977  
    6262
    6363
    64       /*
    65       const double beta = 1;
     64     
     65      const double beta = 20;
    6666      var w = from idx in Enumerable.Range(0, maxIdx)
    6767              let afterStateQ = activeAfterStates[idx]
     
    7171      selectedStateIdx = actionIndexMap[bestAction];
    7272      Debug.Assert(selectedStateIdx >= 0);
    73       */
    74 
    75 
     73     
     74
     75      /*
    7676      if (random.NextDouble() < 0.2) {
    7777        selectedStateIdx = actionIndexMap[random.Next(maxIdx)];
     
    9191        selectedStateIdx = actionIndexMap[bestIdxs[random.Next(bestIdxs.Count)]];
    9292      }
    93 
    94 
    95 
    96 
     93      */
    9794      return true;
    9895    }
     
    132129
    133130    public double GetValue(string state) {
    134       return problem.GetFeatures(state).Average(feature => GetWeight(feature));
     131      return problem.GetFeatures(state).Sum(feature => GetWeight(feature));
    135132    }
    136133
     
    142139    private void UpdateWeights(string state, double reward) {
    143140      double delta = reward - GetValue(state);
    144       delta /= problem.GetFeatures(state).Count();
    145       const double alpha = 0.001;
     141      // delta /= problem.GetFeatures(state).Count();
     142      //const double alpha = 0.01;
    146143      foreach (var feature in problem.GetFeatures(state)) {
    147144        featureTries[feature.Id] = GetFeatureTries(feature.Id) + 1;
    148145        Debug.Assert(GetFeatureTries(feature.Id) >= 1);
    149         //double alpha = 1.0 / GetFeatureTries(feature.Id);
    150         //alpha = Math.Max(alpha, 0.01);
     146        double alpha = 1.0 / GetFeatureTries(feature.Id);
     147        alpha = Math.Max(alpha, 0.001);
    151148
    152149        double w;
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/Solvers/SequentialSearch.cs

    r11976 r11977  
    6262    }
    6363
     64    public bool StopRequested {
     65      get;
     66      set;
     67    }
     68
    6469    public override void Run(int maxIterations) {
    6570      Reset();
    6671
    67       for (int i = 0; /*!bestQuality.IsAlmost(1.0) && */!Done() && i < maxIterations; i++) {
     72      for (int i = 0; !StopRequested && !Done() && i < maxIterations; i++) {
    6873        var phrase = SampleSentence(problem.Grammar);
    6974        // can fail on the last sentence
     
    171176
    172177    private void Reset() {
     178      StopRequested = false;
    173179      behaviourPolicy.Reset();
    174180      greedyPolicy.Reset();
     
    238244    }
    239245    #endregion
    240  
     246
    241247  }
    242248}
Note: See TracChangeset for help on using the changeset viewer.