Changeset 10984


Ignore:
Timestamp:
06/11/14 14:02:11 (5 years ago)
Author:
gkronber
Message:

#2109: retry until a unique constant is sampled when creating constants in the GE symbolic regression grammar

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicExpressionGrammar.cs

    r10975 r10984  
    7777      var constants = new List<Constant>(nConstants);
    7878      for (int i = 0; i < nConstants; i++) {
    79         var constVal = rand.NextDouble() * 20.0 - 10.0;
    8079        var constant = new Constant();
    81         constant.Name = string.Format("{0:0.000}", constVal);
    82         constant.MinValue = constVal;
    83         constant.MaxValue = constVal;
    84         constant.ManipulatorSigma = 0.0;
    85         constant.ManipulatorMu = 0.0;
    86         constant.MultiplicativeManipulatorSigma = 0.0;
     80        do {
     81          var constVal = rand.NextDouble() * 20.0 - 10.0;
     82          constant.Name = string.Format("{0:0.000}", constVal);
     83          constant.MinValue = constVal;
     84          constant.MaxValue = constVal;
     85          constant.ManipulatorSigma = 0.0;
     86          constant.ManipulatorMu = 0.0;
     87          constant.MultiplicativeManipulatorSigma = 0.0;
     88        } while (constants.Any(c => c.Name == constant.Name)); // unlikely, but it could happen that the same constant value is sampled twice. so we resample if necessary.
    8789        constants.Add(constant);
    8890      }
Note: See TracChangeset for help on using the changeset viewer.