Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/22/11 10:56:48 (14 years ago)
Author:
cneumuel
Message:

#1215

  • reduced significance of NormalCrossovers
  • small fixes
Location:
branches/HeuristicLab.MetaOptimization
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/Program.cs

    r6024 r6038  
    6363      //TestDoubleSampling(); return;
    6464      //TestTypeDiscovery();
    65       //TestOperators();
     65      TestOperators(); return;
    6666      //TestCombinations();
    6767      //TestCombinations2();
     
    598598      IRandom random = new MersenneTwister();
    599599
    600       var doubleRange = new DoubleValueRange(new DoubleValue(0), new DoubleValue(100), new DoubleValue(0.1));
     600      var doubleRange = new DoubleValueRange(new DoubleValue(0), new DoubleValue(1), new DoubleValue(0.001));
    601601      using (var sw = new StreamWriter("out-DoubleValue.txt")) {
    602602        for (int i = 0; i < 10000; i++) {
    603           var val = new DoubleValue(90);
     603          var val = new DoubleValue(0.0);
    604604          NormalDoubleValueManipulator.ApplyStatic(random, val, doubleRange);
    605605
    606606          sw.WriteLine(val);
     607          Debug.Assert(val.Value >= 0.0 && val.Value <= 1.0);
    607608        }
    608609      }
     
    623624          UniformIntValueManipulator.ApplyStatic(random, val, intRange);
    624625          sw.WriteLine(val);
     626        }
     627      }
     628
     629      using (var sw = new StreamWriter("out-DoubleValueCrossed.txt")) {
     630        for (int i = 0; i < 10000; i++) {
     631          var val1 = new DoubleValue(0.0);
     632          var val2 = new DoubleValue(0.5);
     633          var val3 = NormalDoubleValueCrossover.ApplyStatic(random, val1, val2, doubleRange);
     634
     635          sw.WriteLine(val3);
     636          Debug.Assert(val3.Value >= 0.0 && val3.Value <= 1.0);
    625637        }
    626638      }
     
    10711083
    10721084    private static void TestDoubleSampling() {
    1073       System.Random rand = new System.Random();
    1074       double lower = 2;
    1075       double upper = 3;
    1076       double stepsize = 0.6;
    1077       for (int i = 0; i < 100; i++) {
    1078         double val;
    1079         do {
    1080           val = Math.Round((rand.NextDouble() * (upper - lower) + lower) / stepsize, 0) * stepsize;
    1081         } while (val < lower || val > upper);
    1082         Console.WriteLine(val);
     1085      var random = new MersenneTwister();
     1086      double lower = 0;
     1087      double upper = 1;
     1088      double stepsize = 0.0000001;
     1089      DoubleValueRange range = new DoubleValueRange(new DoubleValue(lower), new DoubleValue(upper), new DoubleValue(stepsize));
     1090
     1091      using (var sw = new StreamWriter("out-DoubleValue.txt")) {
     1092        for (int i = 0; i < 10000; i++) {
     1093          var val = range.GetRandomValue(random);
     1094          Debug.Assert(val.Value >= lower && val.Value <= upper);
     1095          sw.WriteLine(val);
     1096        }
    10831097      }
    10841098    }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/AlgorithmRunsAnalyzer.cs

    r6018 r6038  
    5959    [StorableConstructor]
    6060    protected AlgorithmRunsAnalyzer(bool deserializing) : base(deserializing) { }
    61     public AlgorithmRunsAnalyzer() : base() {
     61    public AlgorithmRunsAnalyzer()
     62      : base() {
    6263      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used to initialize the new random permutation."));
    6364      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The evaluated quality of the ParameterVector."));
     
    134135        parameterConfiguration.AverageQualities = new DoubleArray(qualities.Select(q => q.Average()).ToArray());
    135136
    136         if(maximization)
     137        if (maximization)
    137138          parameterConfiguration.BestQualities = new DoubleArray(qualities.Select(q => q.Max()).ToArray());
    138139        else
    139140          parameterConfiguration.BestQualities = new DoubleArray(qualities.Select(q => q.Min()).ToArray());
    140        
     141
    141142        if (maximization)
    142143          parameterConfiguration.WorstQualities = new DoubleArray(qualities.Select(q => q.Min()).ToArray());
     
    148149        parameterConfiguration.Runs = runs;
    149150
    150         this.QualityParameter.ActualValue = new DoubleValue(MetaOptimizationUtil.Normalize(parameterConfiguration, referenceQualityAverages, referenceQualityDeviations, referenceEvaluatedSolutionAverages, 1, 1, 1, maximization));
     151        this.QualityParameter.ActualValue = new DoubleValue(MetaOptimizationUtil.Normalize(parameterConfiguration, referenceQualityAverages, referenceQualityDeviations, referenceEvaluatedSolutionAverages, 1, 0.1, 1, maximization));
    151152      } else {
    152153        // something terrible happened -> most probably due to invalid parameters.
    153154        // penalty with worst quality from latest generation!
    154 
    155         double penaltyValue = results.ContainsKey("CurrentWorstQuality") ? ((DoubleValue)results["CurrentWorstQuality"]).Value : referenceQualityAverages.Max(); // todo: respect min/max
     155        double penaltyValue;
     156        if (maximization)
     157          penaltyValue = results.ContainsKey("CurrentWorstQuality") ? ((DoubleValue)results["CurrentWorstQuality"]).Value : referenceQualityAverages.Min();
     158        else
     159          penaltyValue = results.ContainsKey("CurrentWorstQuality") ? ((DoubleValue)results["CurrentWorstQuality"]).Value : referenceQualityAverages.Max();
    156160        this.QualityParameter.ActualValue = new DoubleValue(penaltyValue);
    157161      }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Crossovers/DoubleValue/NormalDoubleValueCrossover.cs

    r6017 r6038  
    11using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
     2using HeuristicLab.Common;
     3using HeuristicLab.Core;
     4using HeuristicLab.Data;
    55using HeuristicLab.Operators;
    66using HeuristicLab.Optimization;
     7using HeuristicLab.Parameters;
    78using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    8 using HeuristicLab.Core;
    9 using HeuristicLab.Parameters;
    10 using HeuristicLab.Common;
    11 using HeuristicLab.Data;
    129using HeuristicLab.Random;
    1310
     
    1916    }
    2017
    21     public NormalDoubleValueCrossover() : base() {
     18    public NormalDoubleValueCrossover()
     19      : base() {
    2220    }
    2321    [StorableConstructor]
     
    3533
    3634    public static DoubleValue ApplyStatic(IRandom random, DoubleValue better, DoubleValue worse, DoubleValueRange range) {
    37       NormalDistributedRandom N = new NormalDistributedRandom(random, better.Value, Math.Abs(better.Value - worse.Value));
     35      NormalDistributedRandom N = new NormalDistributedRandom(random, better.Value, Math.Abs(better.Value - worse.Value) / 3);
    3836      var offspring = new DoubleValue();
    3937      do {
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Crossovers/IntValue/NormalIntValueCrossover.cs

    r6017 r6038  
    11using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
     2using HeuristicLab.Common;
     3using HeuristicLab.Core;
     4using HeuristicLab.Data;
    55using HeuristicLab.Operators;
    66using HeuristicLab.Optimization;
     7using HeuristicLab.Parameters;
    78using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    8 using HeuristicLab.Core;
    9 using HeuristicLab.Parameters;
    10 using HeuristicLab.Common;
    11 using HeuristicLab.Data;
    129using HeuristicLab.Random;
    1310
     
    3431
    3532    public static IntValue ApplyStatic(IRandom random, IntValue better, IntValue worse, IntValueRange range) {
    36       NormalDistributedRandom N = new NormalDistributedRandom(random, better.Value, Math.Abs(better.Value - worse.Value));
     33      NormalDistributedRandom N = new NormalDistributedRandom(random, better.Value, Math.Abs(better.Value - worse.Value) / 3);
    3734      var offspring = new IntValue();
    3835      do {
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Manipulators/DoubleValue/NormalDoubleValueManipulator.cs

    r6017 r6038  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
     1using HeuristicLab.Common;
     2using HeuristicLab.Core;
     3using HeuristicLab.Data;
     4using HeuristicLab.Encodings.RealVectorEncoding;
    55using HeuristicLab.Operators;
    66using HeuristicLab.Optimization;
     7using HeuristicLab.Parameters;
    78using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    8 using HeuristicLab.Core;
    9 using HeuristicLab.Parameters;
    10 using HeuristicLab.Common;
    11 using HeuristicLab.Encodings.RealVectorEncoding;
    12 using HeuristicLab.Data;
    139
    1410namespace HeuristicLab.Problems.MetaOptimization {
     
    3632
    3733    public static void ApplyStatic(IRandom random, DoubleValue value, DoubleValueRange range) {
    38       bool ok = false;
    3934      var strategy = new RealVector(new double[] { (range.UpperBound.Value - range.LowerBound.Value) / 10}); // todo: add strategy parameter
    4035      var vector = new RealVector(1);
    4136      double val = value.Value;
    4237
    43       while (!ok) {
     38      do {
    4439        vector[0] = val;
    4540        NormalAllPositionsManipulator.Apply(random, vector, strategy);
    4641        value.Value = vector[0];
    4742        value.Value = range.ApplyStepSize(value.Value);
    48         ok = range.IsInRange(value.Value);
    49       }
     43      } while(!range.IsInRange(value.Value));
    5044    }
    5145  }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Manipulators/DoubleValue/UniformDoubleValueManipulator.cs

    r6017 r6038  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
     1using HeuristicLab.Common;
     2using HeuristicLab.Core;
     3using HeuristicLab.Data;
     4using HeuristicLab.Encodings.RealVectorEncoding;
    55using HeuristicLab.Operators;
    66using HeuristicLab.Optimization;
     7using HeuristicLab.Parameters;
    78using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    8 using HeuristicLab.Core;
    9 using HeuristicLab.Parameters;
    10 using HeuristicLab.Common;
    11 using HeuristicLab.Encodings.RealVectorEncoding;
    12 using HeuristicLab.Data;
    139
    1410namespace HeuristicLab.Problems.MetaOptimization {
     
    3632
    3733    public static void ApplyStatic(IRandom random, DoubleValue value, DoubleValueRange range) {
    38       bool ok = false;
    3934      var vector = new RealVector(1);
    4035      var bounds = new DoubleMatrix(1, 2);
     
    4338      double val = value.Value;
    4439
    45       while (!ok) {
     40      do {
    4641        vector[0] = val;
    4742        UniformOnePositionManipulator.Apply(random, vector, bounds);
    4843        value.Value = vector[0];
    4944        value.Value = range.ApplyStepSize(value.Value);
    50         ok = range.IsInRange(value.Value);
    51       }
     45      } while (!range.IsInRange(value.Value));
    5246    }
    5347  }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Manipulators/IntValue/NormalIntValueManipulator.cs

    r6017 r6038  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
     1using HeuristicLab.Common;
     2using HeuristicLab.Core;
     3using HeuristicLab.Data;
     4using HeuristicLab.Encodings.RealVectorEncoding;
    55using HeuristicLab.Operators;
    66using HeuristicLab.Optimization;
     7using HeuristicLab.Parameters;
    78using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    8 using HeuristicLab.Core;
    9 using HeuristicLab.Parameters;
    10 using HeuristicLab.Common;
    11 using HeuristicLab.Encodings.IntegerVectorEncoding;
    12 using HeuristicLab.Data;
    13 using HeuristicLab.Encodings.RealVectorEncoding;
    149
    1510namespace HeuristicLab.Problems.MetaOptimization {
     
    3833
    3934    public static void ApplyStatic(IRandom random, IntValue value, IntValueRange range) {
    40       bool ok = false;
    4135      var strategy = new RealVector(new double[] { (range.UpperBound.Value - range.LowerBound.Value) / 10 }); // todo: add strategy parameter
    4236      var vector = new RealVector(new double[] { value.Value });
    4337      int val = value.Value;
    4438
    45       while (!ok) {
     39      do {
    4640        vector[0] = val;
    4741        NormalAllPositionsManipulator.Apply(random, vector, strategy);
    4842        value.Value = (int)vector[0];
    4943        value.Value = range.ApplyStepSize(value.Value);
    50         ok = range.IsInRange(value.Value);
    51       }
     44      } while (!range.IsInRange(value.Value));
    5245    }
    5346  }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Manipulators/IntValue/UniformIntValueManipulator.cs

    r6017 r6038  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
     1using HeuristicLab.Common;
     2using HeuristicLab.Core;
     3using HeuristicLab.Data;
     4using HeuristicLab.Encodings.IntegerVectorEncoding;
    55using HeuristicLab.Operators;
    66using HeuristicLab.Optimization;
     7using HeuristicLab.Parameters;
    78using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    8 using HeuristicLab.Core;
    9 using HeuristicLab.Parameters;
    10 using HeuristicLab.Common;
    11 using HeuristicLab.Encodings.IntegerVectorEncoding;
    12 using HeuristicLab.Data;
    139
    1410namespace HeuristicLab.Problems.MetaOptimization {
     
    3733
    3834    public static void ApplyStatic(IRandom random, IntValue value, IntValueRange range) {
    39       bool ok = false;
    4035      var vector = new IntegerVector(new int[] { value.Value });
    4136      int val = value.Value;
    4237
    43       while (!ok) {
     38      do {
    4439        vector[0] = val;
    4540        UniformOnePositionManipulator.Apply(random, vector, range.LowerBound, new IntValue(range.UpperBound.Value + 1));
    4641        value.Value = vector[0];
    4742        value.Value = range.ApplyStepSize(value.Value);
    48         ok = range.IsInRange(value.Value);
    49       }
     43      } while (!range.IsInRange(value.Value));
    5044    }
    5145  }
Note: See TracChangeset for help on using the changeset viewer.