Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/10/13 15:15:13 (11 years ago)
Author:
sforsten
Message:

#1980:

  • added DecisionListView
  • added event handlers in *ProblemData
  • renamed project Problems.XCS.Views to Problems.lCS.Views and Problems.Instances.ConditionActionClassification to Problems.Instances.LCS
  • integrated niching in GAssist and added NichingTournamentSelector
  • minor code improvements and property changes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Action/IntAction.cs

    r9334 r9352  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
     27using HeuristicLab.Optimization.Operators.LCS;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2829
     
    3132  [Item("IntAction", "")]
    3233  public class IntAction : Item, IAction<int> {
     34
     35    public static IEqualityComparer<IGAssistNiche> Comparer {
     36      get { return new DecisionListNicheComparer(); }
     37    }
     38    IEqualityComparer<IGAssistNiche> IGAssistNiche.Comparer {
     39      get { return Comparer; }
     40    }
    3341
    3442    [Storable]
     
    8896    }
    8997
     98    public void Randomize(IRandom random, IEnumerable<IAction> except) {
     99      if (except.Count() == 0) {
     100        Randomize(random);
     101        return;
     102      }
     103      try {
     104        var exceptInt = except.Cast<IntAction>().Select(x => x.currentAction);
     105        var newPossibleFeatures = possibleFeatures.Except(exceptInt);
     106        currentAction = newPossibleFeatures.ElementAt(random.Next(0, newPossibleFeatures.Count()));
     107      }
     108      catch (InvalidCastException) {
     109        throw new InvalidCastException("Actions have to be of type IntAction");
     110      }
     111    }
     112
    90113    public bool Match(IAction action) {
    91114      var targetCast = action as IntAction;
     
    103126
    104127    public override string ToString() {
    105       return currentAction.ToString();
     128      return variableName + ": " + currentAction.ToString();
     129    }
     130
     131    public bool SameNiche(IGAssistNiche niche) {
     132      return Match(niche as IAction);
     133    }
     134
     135    public int GetNicheHashCode() {
     136      int result = 1;
     137      result = 37 * result + currentAction;
     138      result = 37 * result + variableName.GetHashCode();
     139      foreach (var feature in possibleFeatures) {
     140        result = 37 * result + feature;
     141      }
     142      return result;
    106143    }
    107144  }
Note: See TracChangeset for help on using the changeset viewer.