Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/20/09 20:14:47 (15 years ago)
Author:
gkronber
Message:

Implemented #302 (Show variable names instead of var<index> in GP function trees).

  • Added a new operator that chooses a random value from a list of possible values.
  • Changed mutation operator for variables and differentials
  • Changed internal linear representation of function trees to support different types for local data.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Variable.cs

    r2166 r2174  
    3838    public const string INDEX = "Variable";
    3939
    40     private int minIndex;
    41     private int maxIndex;
    4240    private int minOffset;
    4341    private int maxOffset;
     
    5351    public Variable()
    5452      : base() {
    55       AddVariableInfo(new VariableInfo(INDEX, "Index of the variable in the dataset representing this feature", typeof(ConstrainedIntData), VariableKind.None));
     53      AddVariableInfo(new VariableInfo(INDEX, "The variable name", typeof(StringData), VariableKind.None));
    5654      GetVariableInfo(INDEX).Local = true;
    57       AddVariableInfo(new VariableInfo(WEIGHT, "Weight is multiplied to the feature value", typeof(ConstrainedDoubleData), VariableKind.None));
     55      AddVariableInfo(new VariableInfo(WEIGHT, "Weight is multiplied to the feature value", typeof(DoubleData), VariableKind.None));
    5856      GetVariableInfo(WEIGHT).Local = true;
    5957      AddVariableInfo(new VariableInfo(OFFSET, "SampleOffset is added to the sample index", typeof(ConstrainedIntData), VariableKind.None));
     
    6765      AddVariable(new HeuristicLab.Core.Variable(WEIGHT, weight));
    6866
    69       ConstrainedIntData variable = new ConstrainedIntData();
     67      StringData variable = new StringData();
    7068      AddVariable(new HeuristicLab.Core.Variable(INDEX, variable));
    71       minIndex = 0; maxIndex = 1000;
    7269
    7370      ConstrainedIntData sampleOffset = new ConstrainedIntData();
     
    8481      CombinedOperator combinedOp = new CombinedOperator();
    8582      SequentialProcessor seq = new SequentialProcessor();
    86       UniformRandomizer indexRandomizer = new UniformRandomizer();
    87       indexRandomizer.Min = minIndex;
    88       indexRandomizer.Max = maxIndex + 1; // uniform randomizer generates numbers in the range [min, max[
    89       indexRandomizer.GetVariableInfo("Value").ActualName = INDEX;
    90       indexRandomizer.Name = "Index Randomizer";
     83      UniformItemChooser variableRandomizer = new UniformItemChooser();
     84      variableRandomizer.GetVariableInfo("Value").ActualName = INDEX;
     85      variableRandomizer.GetVariableInfo("Values").ActualName = "InputVariables";
     86      variableRandomizer.Name = "Variable randomizer";
    9187      NormalRandomizer weightRandomizer = new NormalRandomizer();
    9288      weightRandomizer.Mu = 0.0;
     
    10197
    10298      combinedOp.OperatorGraph.AddOperator(seq);
    103       combinedOp.OperatorGraph.AddOperator(indexRandomizer);
     99      combinedOp.OperatorGraph.AddOperator(variableRandomizer);
    104100      combinedOp.OperatorGraph.AddOperator(weightRandomizer);
    105101      combinedOp.OperatorGraph.AddOperator(offsetRandomizer);
    106102      combinedOp.OperatorGraph.InitialOperator = seq;
    107       seq.AddSubOperator(indexRandomizer);
     103      seq.AddSubOperator(variableRandomizer);
    108104      seq.AddSubOperator(weightRandomizer);
    109105      seq.AddSubOperator(offsetRandomizer);
     
    120116      CombinedOperator combinedOp = new CombinedOperator();
    121117      SequentialProcessor seq = new SequentialProcessor();
    122       UniformRandomizer indexRandomizer = new UniformRandomizer();
    123       indexRandomizer.Min = minIndex;
    124       indexRandomizer.Max = maxIndex + 1;
    125       indexRandomizer.GetVariableInfo("Value").ActualName = INDEX;
    126       indexRandomizer.Name = "Index Randomizer";
     118      UniformItemChooser variableRandomizer = new UniformItemChooser();
     119      variableRandomizer.GetVariableInfo("Value").ActualName = INDEX;
     120      variableRandomizer.GetVariableInfo("Values").ActualName = "InputVariables";
     121      variableRandomizer.Name = "Variable randomizer";
    127122      NormalRandomAdder weightRandomAdder = new NormalRandomAdder();
    128123      weightRandomAdder.Mu = 0.0;
     
    137132
    138133      combinedOp.OperatorGraph.AddOperator(seq);
    139       combinedOp.OperatorGraph.AddOperator(indexRandomizer);
     134      combinedOp.OperatorGraph.AddOperator(variableRandomizer);
    140135      combinedOp.OperatorGraph.AddOperator(weightRandomAdder);
    141136      combinedOp.OperatorGraph.AddOperator(offsetRandomAdder);
    142137      combinedOp.OperatorGraph.InitialOperator = seq;
    143       seq.AddSubOperator(indexRandomizer);
     138      seq.AddSubOperator(variableRandomizer);
    144139      seq.AddSubOperator(weightRandomAdder);
    145140      seq.AddSubOperator(offsetRandomAdder);
     
    152147    }
    153148
    154     public void SetConstraints(int minInputIndex, int maxInputIndex, int minSampleOffset, int maxSampleOffset) {
     149    public void SetConstraints(int minSampleOffset, int maxSampleOffset) {
    155150      ConstrainedIntData offset = GetVariableValue<ConstrainedIntData>(OFFSET, null, false);
    156151      IntBoundedConstraint offsetConstraint = new IntBoundedConstraint();
     
    165160      offset.AddConstraint(offsetConstraint);
    166161
    167       ConstrainedIntData index = GetVariableValue<ConstrainedIntData>(INDEX, null, false);
    168       IntBoundedConstraint indexConstraint = new IntBoundedConstraint();
    169       minIndex = minInputIndex;
    170       maxIndex = maxInputIndex;
    171       indexConstraint.LowerBound = minInputIndex;
    172       indexConstraint.LowerBoundEnabled = true;
    173       indexConstraint.LowerBoundIncluded = true;
    174       indexConstraint.UpperBound = maxInputIndex;
    175       indexConstraint.UpperBoundEnabled = true;
    176       indexConstraint.UpperBoundIncluded = true;
    177       index.AddConstraint(indexConstraint);
     162      //ConstrainedIntData index = GetVariableValue<ConstrainedIntData>(INDEX, null, false);
     163      //IntBoundedConstraint indexConstraint = new IntBoundedConstraint();
     164      //minIndex = minInputIndex;
     165      //maxIndex = maxInputIndex;
     166      //indexConstraint.LowerBound = minInputIndex;
     167      //indexConstraint.LowerBoundEnabled = true;
     168      //indexConstraint.LowerBoundIncluded = true;
     169      //indexConstraint.UpperBound = maxInputIndex;
     170      //indexConstraint.UpperBoundEnabled = true;
     171      //indexConstraint.UpperBoundIncluded = true;
     172      //index.AddConstraint(indexConstraint);
    178173
    179174      SetupInitialization();
Note: See TracChangeset for help on using the changeset viewer.