Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5023


Ignore:
Timestamp:
12/04/10 18:08:43 (14 years ago)
Author:
cneumuel
Message:

#1215 worked on metaoptimization

Location:
branches/HeuristicLab.MetaOptimization
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/HeuristicLab.MetaOptimization.Test.csproj

    r4997 r5023  
    6969    </Reference>
    7070    <Reference Include="HeuristicLab.Algorithms.GeneticAlgorithm-3.3">
    71       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll</HintPath>
     71      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll</HintPath>
    7272    </Reference>
    7373    <Reference Include="HeuristicLab.Algorithms.LocalSearch-3.3">
     
    9696    </Reference>
    9797    <Reference Include="HeuristicLab.Collections-3.3">
    98       <HintPath>..\..\HeuristicLab.Hive\sources\HeuristicLab.Hive\HeuristicLab.Hive.Slave.Core\3.3\bin\Debug\HeuristicLab.Collections-3.3.dll</HintPath>
     98      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Collections-3.3.dll</HintPath>
    9999    </Reference>
    100100    <Reference Include="HeuristicLab.Common-3.3">
    101       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
     101      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
    102102    </Reference>
    103103    <Reference Include="HeuristicLab.Common.Resources-3.3">
     
    105105    </Reference>
    106106    <Reference Include="HeuristicLab.Core-3.3">
    107       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Core-3.3.dll</HintPath>
     107      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Core-3.3.dll</HintPath>
    108108    </Reference>
    109109    <Reference Include="HeuristicLab.Core.Views-3.3">
     
    111111    </Reference>
    112112    <Reference Include="HeuristicLab.Data-3.3">
    113       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Data-3.3.dll</HintPath>
     113      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Data-3.3.dll</HintPath>
    114114    </Reference>
    115115    <Reference Include="HeuristicLab.Data.Views-3.3">
    116116      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Data.Views-3.3.dll</HintPath>
    117117    </Reference>
     118    <Reference Include="HeuristicLab.DebugEngine-3.3">
     119      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.DebugEngine-3.3.dll</HintPath>
     120    </Reference>
    118121    <Reference Include="HeuristicLab.Encodings.BinaryVectorEncoding-3.3">
    119       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.dll</HintPath>
    120     </Reference>
    121     <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    122       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.IntegerVectorEncoding-3.3.dll</HintPath>
     122      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.dll</HintPath>
     123    </Reference>
     124    <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3">
     125      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.IntegerVectorEncoding-3.3.dll</HintPath>
    123126    </Reference>
    124127    <Reference Include="HeuristicLab.Encodings.PermutationEncoding-3.3">
    125       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.PermutationEncoding-3.3.dll</HintPath>
     128      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.PermutationEncoding-3.3.dll</HintPath>
    126129    </Reference>
    127130    <Reference Include="HeuristicLab.Encodings.PermutationEncoding.Views-3.3">
    128       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.PermutationEncoding.Views-3.3.dll</HintPath>
    129     </Reference>
    130     <Reference Include="HeuristicLab.Encodings.RealVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    131       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.RealVectorEncoding-3.3.dll</HintPath>
     131      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.PermutationEncoding.Views-3.3.dll</HintPath>
     132    </Reference>
     133    <Reference Include="HeuristicLab.Encodings.RealVectorEncoding-3.3">
     134      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.RealVectorEncoding-3.3.dll</HintPath>
    132135    </Reference>
    133136    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3">
     
    152155      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Netron-3.0.2672.12446.dll</HintPath>
    153156    </Reference>
    154     <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    155       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Operators-3.3.dll</HintPath>
     157    <Reference Include="HeuristicLab.Operators-3.3">
     158      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Operators-3.3.dll</HintPath>
    156159    </Reference>
    157160    <Reference Include="HeuristicLab.Operators.Programmable-3.3">
     
    164167      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Operators.Views.GraphVisualization-3.3.dll</HintPath>
    165168    </Reference>
    166     <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    167       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Optimization-3.3.dll</HintPath>
     169    <Reference Include="HeuristicLab.Optimization-3.3">
     170      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Optimization-3.3.dll</HintPath>
    168171    </Reference>
    169172    <Reference Include="HeuristicLab.Optimization.Operators-3.3">
     
    174177    </Reference>
    175178    <Reference Include="HeuristicLab.Optimizer-3.3">
    176       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Optimizer-3.3.dll</HintPath>
    177     </Reference>
    178     <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    179       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Parameters-3.3.dll</HintPath>
     179      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Optimizer-3.3.dll</HintPath>
     180    </Reference>
     181    <Reference Include="HeuristicLab.Parameters-3.3">
     182      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Parameters-3.3.dll</HintPath>
    180183    </Reference>
    181184    <Reference Include="HeuristicLab.Parameters.Views-3.3">
    182185      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Parameters.Views-3.3.dll</HintPath>
    183186    </Reference>
    184     <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    185       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Persistence-3.3.dll</HintPath>
     187    <Reference Include="HeuristicLab.Persistence-3.3">
     188      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Persistence-3.3.dll</HintPath>
    186189    </Reference>
    187190    <Reference Include="HeuristicLab.Persistence.GUI-3.3">
    188191      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Persistence.GUI-3.3.dll</HintPath>
    189192    </Reference>
    190     <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    191       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     193    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
     194      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
    192195    </Reference>
    193196    <Reference Include="HeuristicLab.Problems.ArtificialAnt-3.3">
     
    230233      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.Knapsack.Views-3.3.dll</HintPath>
    231234    </Reference>
     235    <Reference Include="HeuristicLab.Problems.MetaOptimization-3.3">
     236      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.MetaOptimization-3.3.dll</HintPath>
     237    </Reference>
     238    <Reference Include="HeuristicLab.Problems.MetaOptimization.Views-3.3">
     239      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.MetaOptimization.Views-3.3.dll</HintPath>
     240    </Reference>
    232241    <Reference Include="HeuristicLab.Problems.OneMax-3.3">
    233242      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.OneMax-3.3.dll</HintPath>
     
    237246    </Reference>
    238247    <Reference Include="HeuristicLab.Problems.TestFunctions-3.3">
    239       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.TestFunctions-3.3.dll</HintPath>
     248      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.TestFunctions-3.3.dll</HintPath>
    240249    </Reference>
    241250    <Reference Include="HeuristicLab.Problems.TestFunctions.Views-3.3">
     
    257266      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.ProtobufCS-0.9.1.dll</HintPath>
    258267    </Reference>
    259     <Reference Include="HeuristicLab.Random-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    260       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Random-3.3.dll</HintPath>
    261     </Reference>
    262     <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    263       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Selection-3.3.dll</HintPath>
     268    <Reference Include="HeuristicLab.Random-3.3">
     269      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Random-3.3.dll</HintPath>
     270    </Reference>
     271    <Reference Include="HeuristicLab.Selection-3.3">
     272      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Selection-3.3.dll</HintPath>
    264273    </Reference>
    265274    <Reference Include="HeuristicLab.SequentialEngine-3.3">
    266       <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.SequentialEngine-3.3.dll</HintPath>
     275      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.SequentialEngine-3.3.dll</HintPath>
    267276    </Reference>
    268277    <Reference Include="HeuristicLab.SharpDevelop-3.1.1.5327">
     
    311320      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\WeifenLuo.WinFormsUI.Docking-2.3.1.dll</HintPath>
    312321    </Reference>
     322    <Reference Include="ZedGraph">
     323      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\ZedGraph.dll</HintPath>
     324    </Reference>
    313325  </ItemGroup>
    314326  <ItemGroup>
    315327    <Compile Include="Program.cs" />
    316328    <Compile Include="Properties\AssemblyInfo.cs" />
    317   </ItemGroup>
    318   <ItemGroup>
    319     <ProjectReference Include="..\HeuristicLab.Problems.MetaOptimization\3.3\HeuristicLab.Problems.MetaOptimization-3.3.csproj">
    320       <Project>{ABBC1DF6-FCC6-4F86-AB75-B6B3A72E7D17}</Project>
    321       <Name>HeuristicLab.Problems.MetaOptimization-3.3</Name>
    322     </ProjectReference>
    323329  </ItemGroup>
    324330  <ItemGroup>
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/Program.cs

    r5009 r5023  
    1212using HeuristicLab.Random;
    1313using HeuristicLab.Optimization;
     14using HeuristicLab.Common;
     15using System.IO;
     16using HeuristicLab.Problems.TestFunctions;
     17using System.Text;
     18using HeuristicLab.Selection;
    1419
    1520namespace HeuristicLab.MetaOptimization.Test {
    1621  class Program {
    17     private static int metaAlgorithmPopulationSize = 20;
    18     private static int metaAlgorithmMaxGenerations = 100;
    19 
    20     private static int baseAlgorithmPopulationSize = 20;
    21     private static int baseAlgorithmMaxGenerations = 30;
     22    private static int metaAlgorithmPopulationSize = 40;
     23    private static int metaAlgorithmMaxGenerations = 30;
     24
     25    private static int baseAlgorithmMaxGenerations = 100;
    2226
    2327    static void Main(string[] args) {
     
    3135      IValueConfiguration algorithmVc = SetupAlgorithm(baseLevelAlgorithm, metaOptimizationProblem);
    3236
    33       Console.WriteLine("Press enter to start");
    34       Console.ReadLine();
    35       TestConfiguration(algorithmVc, baseLevelAlgorithm);
    36 
    37       Console.WriteLine("Press enter to start");
    38       Console.ReadLine();
     37      //Console.WriteLine("Press enter to start");
     38      //Console.ReadLine();
     39      //TestConfiguration(algorithmVc, baseLevelAlgorithm);
     40
     41      //Console.WriteLine("Press enter to start");
     42      //Console.ReadLine();
    3943      TestOptimization(metaLevelAlgorithm);
    4044
     
    5054      Console.ReadLine();
    5155
     56      var clones = new List<object>();
    5257      for (int i = 0; i < 1000; i++) {
    5358        var clone = algorithmVc.Clone();
     59        clones.Add(clone);
    5460      }
    5561
     
    7076      metaLevelAlgorithm.Problem = metaOptimizationProblem;
    7177      metaLevelAlgorithm.Engine = new SequentialEngine.SequentialEngine();
     78
     79      metaLevelAlgorithm.Mutator = new ParameterConfigurationManipulator();
     80      metaLevelAlgorithm.MutationProbability.Value = 0.15;
     81
    7282      return metaLevelAlgorithm;
    7383    }
    7484
    7585    private static IValueConfiguration SetupAlgorithm(GeneticAlgorithm baseLevelAlgorithm, MetaOptimizationProblem metaOptimizationProblem) {
    76       baseLevelAlgorithm.Problem = new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { ProblemSize = new IntValue(2000) };
    77       baseLevelAlgorithm.PopulationSize.Value = baseAlgorithmPopulationSize;
     86      baseLevelAlgorithm.Problem = new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() {
     87        Evaluator = new GriewankEvaluator(),
     88        ProblemSize = new IntValue(1000)
     89      };
    7890      baseLevelAlgorithm.MaximumGenerations.Value = baseAlgorithmMaxGenerations;
    7991
     
    8597      ConfigureMutationRate(algorithmVc);
    8698      ConfigureMutationOperator(algorithmVc);
     99      ConfigureElites(algorithmVc);
     100      ConfigureSelectionOperator(algorithmVc);
    87101      return algorithmVc;
    88102    }
    89103
    90104    private static void TestConfiguration(IValueConfiguration algorithmVc, GeneticAlgorithm baseLevelAlgorithm) {
    91       IRandom rand = new MersenneTwister();
     105      IRandom rand = new FastRandom(0);
    92106      // set random values
    93107      for (int i = 0; i < 10; i++) {
     
    99113        Console.WriteLine(string.Format("MutRate: original: {0}, randomized: {1}", baseLevelAlgorithm.MutationProbability, newAlg.MutationProbability));
    100114        Console.WriteLine(string.Format("MutOp: original: {0}, randomized: {1}", baseLevelAlgorithm.Mutator, newAlg.Mutator));
    101       }
    102 
     115        Console.WriteLine(string.Format("SelOp: original: {0}, randomized: {1}", baseLevelAlgorithm.Selector, newAlg.Selector));
     116        Console.WriteLine(string.Format("GrSi: original: {0}, randomized: {1}", "?", ((TournamentSelector)newAlg.Selector).GroupSizeParameter.Value));
     117        Console.WriteLine("---");
     118      }
     119
     120      Console.WriteLine("=======================");
     121      algorithmVc.Randomize(rand);
     122      algorithmVc.Parameterize(baseLevelAlgorithm);
    103123      // mutate
    104124      for (int i = 0; i < 10; i++) {
     
    110130        Console.WriteLine(string.Format("MutRate: original: {0}, mutated: {1}", baseLevelAlgorithm.MutationProbability, newAlg.MutationProbability));
    111131        Console.WriteLine(string.Format("MutOp: original: {0}, mutated: {1}", baseLevelAlgorithm.Mutator, newAlg.Mutator));
    112       }
    113 
     132        Console.WriteLine(string.Format("SelOp: original: {0}, mutated: {1}", baseLevelAlgorithm.Selector, newAlg.Selector));
     133        Console.WriteLine(string.Format("GrSi: original: {0}, mutated: {1}", ((TournamentSelector)baseLevelAlgorithm.Selector).GroupSizeParameter.Value, ((TournamentSelector)newAlg.Selector).GroupSizeParameter.Value));
     134        Console.WriteLine("---");
     135      }
     136
     137      Console.WriteLine("=======================");
    114138      // cross
    115139      for (int i = 0; i < 10; i++) {
    116140        IValueConfiguration clonedVc1 = (IValueConfiguration)algorithmVc.Clone();
     141        IValueConfiguration clonedVc2 = (IValueConfiguration)algorithmVc.Clone();
     142
     143        GeneticAlgorithm first = (GeneticAlgorithm)clonedVc1.ActualValue.Value.Clone();
     144        GeneticAlgorithm second = (GeneticAlgorithm)clonedVc2.ActualValue.Value.Clone();
     145
    117146        clonedVc1.Randomize(rand);
    118         clonedVc1.Parameterize(baseLevelAlgorithm);
    119 
    120         IValueConfiguration clonedVc2 = (IValueConfiguration)algorithmVc.Clone();
    121         GeneticAlgorithm first = (GeneticAlgorithm)clonedVc1.ActualValue.Value;
    122         GeneticAlgorithm second = (GeneticAlgorithm)clonedVc2.ActualValue.Value;
     147        clonedVc1.Parameterize(first);
     148
     149        clonedVc2.Randomize(rand);
     150        clonedVc2.Parameterize(second);
    123151
    124152        var popSizeBefore = first.PopulationSize.Value;
    125153        var mutRateBefore = first.MutationProbability.Value;
    126154        var mutOpBefore = first.Mutator;
     155        var selOpBefore = first.Selector;
     156        var groupSizeBefore = ((TournamentSelector)first.Selector).GroupSizeParameter.Value.Value;
    127157
    128158        clonedVc1.Cross(clonedVc2, rand);
    129         clonedVc1.Parameterize((GeneticAlgorithm)clonedVc2.ActualValue.Value);
     159        clonedVc1.Parameterize(first);
    130160
    131161        Console.WriteLine(string.Format("PopSize: first: {0}, second: {1}, crossed: {2}", popSizeBefore, second.PopulationSize, first.PopulationSize));
    132162        Console.WriteLine(string.Format("MutRate: first: {0}, second: {1}, crossed: {2}", mutRateBefore, second.MutationProbability, first.MutationProbability));
    133         Console.WriteLine(string.Format("MutRate: first: {0}, second: {1}, crossed: {2}", mutOpBefore, second.Mutator, first.Mutator));
    134       }
     163        Console.WriteLine(string.Format("MutOp: first: {0}, second: {1}, crossed: {2}", mutOpBefore, second.Mutator, first.Mutator));
     164        Console.WriteLine(string.Format("SelOp: first: {0}, second: {1}, crossed: {2}", selOpBefore, second.Selector, first.Selector));
     165        Console.WriteLine(string.Format("GrSi: first: {0}, second: {1}, crossed: {2}", groupSizeBefore, ((TournamentSelector)second.Selector).GroupSizeParameter.Value, ((TournamentSelector)first.Selector).GroupSizeParameter.Value));
     166        Console.WriteLine("---");
     167      }
     168      Console.WriteLine("=======================");
    135169    }
    136170
     
    144178        mutationOperator.ValueConfigurations.SetItemCheckedState(multiMutator, false);
    145179      }
     180    }
     181
     182    private static void ConfigureSelectionOperator(IValueConfiguration algorithmVc) {
     183      var selectionOperatorPc = algorithmVc.ParameterConfigurations.Where(x => x.Name == "Selector").SingleOrDefault();
     184      selectionOperatorPc.Optimize = true;
     185
     186      foreach (var vc in selectionOperatorPc.ValueConfigurations) {
     187        if (vc.ActualValue.ValueDataType == typeof(TournamentSelector)) {
     188          selectionOperatorPc.ValueConfigurations.SetItemCheckedState(vc, true);
     189          vc.Optimize = true;
     190          ConfigureTournamentGroupSize(vc);
     191        } else {
     192          selectionOperatorPc.ValueConfigurations.SetItemCheckedState(vc, false);
     193        }
     194      }
     195    }
     196
     197    private static void ConfigureTournamentGroupSize(IValueConfiguration tournamentVc) {
     198      var groupSizePc = tournamentVc.ParameterConfigurations.Where(x => x.ParameterName == "GroupSize").SingleOrDefault();
     199      groupSizePc.Optimize = true;
     200
     201      groupSizePc.ValueConfigurations.First().Optimize = true;
     202      groupSizePc.ValueConfigurations.First().RangeConstraint.LowerBound = new IntValue(0);
     203      groupSizePc.ValueConfigurations.First().RangeConstraint.UpperBound = new IntValue(100);
     204      groupSizePc.ValueConfigurations.First().RangeConstraint.StepSize = new IntValue(1);
    146205    }
    147206
     
    151210      var populationSizeVc = populationSizePc.ValueConfigurations.First();
    152211      populationSizeVc.Optimize = true;
    153       populationSizeVc.RangeConstraint.LowerBound = new IntValue(0);
     212      populationSizeVc.RangeConstraint.LowerBound = new IntValue(20);
    154213      populationSizeVc.RangeConstraint.UpperBound = new IntValue(100);
    155214      populationSizeVc.RangeConstraint.StepSize = new IntValue(1);
     
    166225    }
    167226
     227    private static void ConfigureElites(IValueConfiguration algorithmVc) {
     228      var elitesPc = algorithmVc.ParameterConfigurations.Where(x => x.Name == "Elites").SingleOrDefault();
     229      elitesPc.Optimize = true;
     230      var elitesVc = elitesPc.ValueConfigurations.First();
     231      elitesVc.Optimize = true;
     232      elitesVc.RangeConstraint.LowerBound = new IntValue(0);
     233      elitesVc.RangeConstraint.UpperBound = new IntValue(20);
     234      elitesVc.RangeConstraint.StepSize = new IntValue(1);
     235    }
     236
    168237    private static void TestOptimization(GeneticAlgorithm metaLevelAlgorithm) {
    169       metaLevelAlgorithm.Start();
    170       do {
    171         Thread.Sleep(1000);
    172         Console.Clear();
    173         try {
    174           foreach (var result in metaLevelAlgorithm.Results) {
    175             Console.WriteLine(result.ToString());
    176             if (result.Name == "Population") {
    177               RunCollection rc = (RunCollection)result.Value;
    178               var orderedRuns = rc.OrderBy(x => x.Results["BestQuality"]);
    179               foreach (IRun run in orderedRuns) {
    180                 Console.WriteLine("Q: {0} PoSi: {1} MuRa: {2} MuOp: {3}",
    181                   ((DoubleValue)run.Results["BestQuality"]).Value.ToString("0.00").PadLeft(4, ' '),
    182                   ((IntValue)run.Parameters["PopulationSize"]).Value.ToString().PadLeft(3, ' '),
    183                   ((DoubleValue)run.Parameters["MutationProbability"]).Value.ToString("0.00").PadRight(3, ' '),
    184                   run.Parameters["Mutator"]);
    185               }
    186             }
     238      ContentManager.Initialize(new PersistenceContentManager());
     239      string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Results");
     240      if(!Directory.Exists(path))
     241        Directory.CreateDirectory(path);
     242      string id = DateTime.Now.ToString("MM.dd.yy - HH;mm;ss,ffff");
     243      string resultPath = Path.Combine(path, string.Format("Test - {0} - Result.hl", id));
     244      string outputPath = Path.Combine(path, string.Format("Test - {0} - Console.txt", id));
     245
     246      using (var sw = new StreamWriter(outputPath)) {
     247        metaLevelAlgorithm.Start();
     248        int i = 0;
     249        int currentGeneration = -1;
     250        do {
     251          Thread.Sleep(500);
     252          try {
     253            if (metaLevelAlgorithm.Results.ContainsKey("Generations") && ((IntValue)metaLevelAlgorithm.Results["Generations"].Value).Value != currentGeneration) {
     254              StringBuilder sb = new StringBuilder();
     255              sb.AppendLine(DateTime.Now.ToLongTimeString());
     256              sb.AppendLine("=================================");
     257
     258              foreach (var result in metaLevelAlgorithm.Results) {
     259                sb.AppendLine(result.ToString());
     260                if (result.Name == "Population") {
     261                  RunCollection rc = (RunCollection)result.Value;
     262                  var orderedRuns = rc.OrderBy(x => x.Results["BestQuality"]);
     263                 
     264                  sb.AppendLine("Qality PoSi MutRa Eli GrSi MutOp");
     265                  foreach (IRun run in orderedRuns) {
     266                    sb.AppendLine(string.Format("{0} {1} {2} {3} {4} {5}",
     267                      ((DoubleValue)run.Results["BestQuality"]).Value.ToString("#0.00").PadLeft(7, ' '),
     268                      ((IntValue)run.Parameters["PopulationSize"]).Value.ToString().PadLeft(3, ' ').PadRight(3, ' '),
     269                      ((DoubleValue)run.Parameters["MutationProbability"]).Value.ToString("0.00").PadLeft(5, ' '),
     270                      ((IntValue)run.Parameters["Elites"]).Value.ToString().PadLeft(3, ' '),
     271                      ((TournamentSelector)run.Parameters["Selector"]).GroupSizeParameter.Value.ToString().PadLeft(4, ' '),
     272                      run.Parameters["Mutator"]));
     273                  }
     274                }
     275              } // foreach
     276              Console.Clear();
     277              Console.WriteLine(sb.ToString());
     278              sw.WriteLine(sb.ToString());
     279              sw.Flush();
     280              currentGeneration = ((IntValue)metaLevelAlgorithm.Results["Generations"].Value).Value;
     281            } // if
     282            if (i % 30 == 0) GC.Collect();
     283            i++;
    187284          }
    188         }
    189         catch { }
    190       } while (metaLevelAlgorithm.ExecutionState != ExecutionState.Stopped);
    191 
     285          catch { }
     286        } while (metaLevelAlgorithm.ExecutionState != ExecutionState.Stopped);
     287      }
     288
     289      Console.WriteLine();
     290      Console.WriteLine("Storing...");
     291
     292      ContentManager.Save(metaLevelAlgorithm, resultPath, true);
    192293      Console.WriteLine("Finished");
    193294    }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.sln

    r4997 r5023  
    5656    {0E232F46-FD0B-4FEA-8C22-AF18DE0D151E}.Debug|x86.ActiveCfg = Debug|x86
    5757    {0E232F46-FD0B-4FEA-8C22-AF18DE0D151E}.Debug|x86.Build.0 = Debug|x86
    58     {0E232F46-FD0B-4FEA-8C22-AF18DE0D151E}.Release|Any CPU.ActiveCfg = Release|x86
     58    {0E232F46-FD0B-4FEA-8C22-AF18DE0D151E}.Release|Any CPU.ActiveCfg = Release|Any CPU
     59    {0E232F46-FD0B-4FEA-8C22-AF18DE0D151E}.Release|Any CPU.Build.0 = Release|Any CPU
    5960    {0E232F46-FD0B-4FEA-8C22-AF18DE0D151E}.Release|Mixed Platforms.ActiveCfg = Release|x86
    6061    {0E232F46-FD0B-4FEA-8C22-AF18DE0D151E}.Release|Mixed Platforms.Build.0 = Release|x86
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/HeuristicLab.Problems.MetaOptimization.Views-3.3.csproj

    r4984 r5023  
    5555    </Reference>
    5656    <Reference Include="HeuristicLab.Data-3.3">
    57       <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Data-3.3.dll</HintPath>
     57      <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Data-3.3.dll</HintPath>
    5858    </Reference>
    5959    <Reference Include="HeuristicLab.Data.Views-3.3">
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Analyzers/BestParameterConfigurationAnalyzer.cs

    r5009 r5023  
    1717  [StorableClass]
    1818  public sealed class BestParameterConfigurationAnalyzer : SingleSuccessorOperator, IAnalyzer {
    19     // Wagner: Spezielle View für die Lösungen (ParameterConfigurations): So wie bei Runs: die zu Optimierenden Parameter(-werte) der besten solution anzeigen
    2019
    2120    public ScopeTreeLookupParameter<ParameterConfigurationTree> ParameterConfigurationParameter {
     
    6261      ResultCollection results = ResultsParameter.ActualValue;
    6362      DoubleValue bestKnownQuality = BestKnownQualityParameter.ActualValue;
    64       ItemArray<ParameterConfigurationTree> parameterConfigurations = ParameterConfigurationParameter.ActualValue;
     63      ItemArray<ParameterConfigurationTree> parameterTrees = ParameterConfigurationParameter.ActualValue;
    6564
    6665      int i = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).First().index;
    6766
    68       EngineAlgorithm bestAlg = ((EngineAlgorithm)((ParameterConfigurationTree)parameterConfigurations[i]).ActualValue.Value);
     67      EngineAlgorithm bestAlg = ((EngineAlgorithm)((ParameterConfigurationTree)parameterTrees[i]).ActualValue.Value);
    6968      Run bestRun = new Run(bestAlg);
     69      ((ParameterConfigurationTree)parameterTrees[i]).CollectResultValues(bestRun.Results);
    7070
    71       if (bestKnownQuality == null || qualities[i].Value < bestKnownQuality.Value) {
     71      if (bestKnownQuality == null || qualities[i].Value < bestKnownQuality.Value) { // todo: respect Maximization:true/false
    7272        BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[i].Value);
    7373        BestKnownSolutionParameter.ActualValue = bestRun;
     
    8383      }
    8484
     85      // population
    8586      RunCollection rc = new RunCollection();
    86      
    87       foreach (ParameterConfigurationTree pc in parameterConfigurations.OrderBy(x => x.Quality.Value*-1)) {
    88         IAlgorithm alg = (IAlgorithm)pc.ActualValue.Value;
     87      foreach (ParameterConfigurationTree pt in parameterTrees.OrderByDescending(x => x.BestQuality.Value)) { // todo: respect Maximization:true/false
     88        IAlgorithm alg = (IAlgorithm)pt.ActualValue.Value;
    8989        alg.StoreAlgorithmInEachRun = false;
    9090        IRun run = new Run(alg);
     91        pt.CollectResultValues(run.Results);
    9192        rc.Add(run);
    9293      }
     
    9899        results["Population"].Value = rc;
    99100      }
    100       GC.Collect();
    101101
    102102      return base.Apply();
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/ParameterConfigurationTree.cs

    r5009 r5023  
    1313  [StorableClass]
    1414  public class ParameterConfigurationTree : ValueConfiguration {
    15     //[Storable]
    16     //protected EngineAlgorithm algorithm;
    17     //public EngineAlgorithm Algorithm {
    18     //  get { return algorithm; }
    19     //  set {
    20     //    if (algorithm != value) {
    21     //      if (algorithm != null) DeregisterAlgorithmEvents();
    22     //      algorithm = value;
    23     //      if (algorithm != null) RegisterAlgorithmEvents();
    24     //      OnAlgorithmChanged();
    25     //    }
    26     //  }
    27     //}
     15    [Storable]
     16    public EngineAlgorithm Algorithm {
     17      get { return (EngineAlgorithm)base.ActualValue.Value; }
     18      set {
     19        base.ActualValue.Value = value;
     20      }
     21    }
    2822
    2923    [Storable]
    30     private DoubleValue quality;
    31     public DoubleValue Quality {
    32       get { return quality; }
     24    private DoubleValue bestQuality;
     25    public DoubleValue BestQuality {
     26      get { return bestQuality; }
    3327      set {
    34         if (quality != value) {
    35           if (quality != null) DeregisterQualityEvents();
    36           quality = value;
    37           if (quality != null) RegisterQualityEvents();
     28        if (bestQuality != value) {
     29          if (bestQuality != null) DeregisterQualityEvents();
     30          bestQuality = value;
     31          if (bestQuality != null) RegisterQualityEvents();
    3832          OnQualityChanged();
    3933        }
     
    4135    }
    4236
     37    [Storable]
     38    private DoubleValue averageQuality;
     39    public DoubleValue AverageQuality {
     40      get { return averageQuality; }
     41      set { averageQuality = value; }
     42    }
     43
     44    [Storable]
     45    private DoubleValue worstQuality;
     46    public DoubleValue WorstQuality {
     47      get { return worstQuality; }
     48      set { worstQuality = value; }
     49    }
     50   
     51    [Storable]
     52    private DoubleValue qualityVariance;
     53    public DoubleValue QualityVariance {
     54      get { return qualityVariance; }
     55      set { qualityVariance = value; }
     56    }
     57   
     58    [Storable]
     59    private DoubleValue qualityStandardDeviation;
     60    public DoubleValue QualityStandardDeviation {
     61      get { return qualityStandardDeviation; }
     62      set { qualityStandardDeviation = value; }
     63    }
     64   
     65    [Storable]
     66    private TimeSpanValue averageExecutionTime;
     67    public TimeSpanValue AverageExecutionTime {
     68      get { return averageExecutionTime; }
     69      set { averageExecutionTime = value; }
     70    }
     71
     72    [Storable]
     73    private IntValue repetitions;
     74    public IntValue Repetitions {
     75      get { return repetitions; }
     76      set { repetitions = value; }
     77    }
     78
     79    [Storable]
     80    public RunCollection Runs { get; set; }
     81   
    4382    #region constructors and cloning
    4483    public ParameterConfigurationTree(EngineAlgorithm algorithm) : base(algorithm, algorithm.GetType()) {
    4584      this.Optimize = true; // root must always be optimized
    46       this.Quality = new DoubleValue();
    47       //this.algorithm = algorithm;
     85      this.BestQuality = new DoubleValue();
    4886    }
    4987    public ParameterConfigurationTree() {
     
    5391    protected ParameterConfigurationTree(bool deserializing) : base(deserializing) { }
    5492    protected ParameterConfigurationTree(ParameterConfigurationTree original, Cloner cloner) : base(original, cloner) {
    55       this.quality = cloner.Clone(original.Quality);
     93      this.bestQuality = cloner.Clone(original.BestQuality);
     94      this.Algorithm.Prepare();
     95      this.Algorithm.Runs.Clear();
    5696      Initialize();
    5797    }
     
    67107    private void Initialize() {
    68108      //if (algorithm != null) RegisterAlgorithmEvents();
    69       if (quality != null) RegisterQualityEvents();
     109      if (bestQuality != null) RegisterQualityEvents();
     110    }
     111
     112    public virtual void CollectResultValues(IDictionary<string, IItem> values) {
     113      values.Add("RunsAverageExecutionTime", AverageExecutionTime);
     114      values.Add("Repetitions", Repetitions);
     115      values.Add("RunsBestQuality", BestQuality);
     116      values.Add("RunsAverageQuality", AverageQuality);
     117      values.Add("RunsWorstQuality", WorstQuality);
     118      values.Add("RunsQualityVariance", QualityVariance);
     119      values.Add("RunsQualityStandardDeviation", QualityStandardDeviation);
     120      values.Add("Runs", Runs);
    70121    }
    71122
     
    89140    //}
    90141    private void RegisterQualityEvents() {
    91       Quality.ValueChanged += new EventHandler(Quality_ValueChanged);
     142      BestQuality.ValueChanged += new EventHandler(Quality_ValueChanged);
    92143    }
    93144    private void DeregisterQualityEvents() {
    94       Quality.ValueChanged -= new EventHandler(Quality_ValueChanged);
     145      BestQuality.ValueChanged -= new EventHandler(Quality_ValueChanged);
    95146    }
    96147
     
    99150    }
    100151    #endregion
     152
    101153  }
    102154}
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/ParameterConfigurations/ParameterConfiguration.cs

    r5009 r5023  
    127127      this.ActualValue = cloner.Clone(original.ActualValue);
    128128      this.optimize = original.optimize;
     129      this.actualValueConfigurationIndex = original.actualValueConfigurationIndex;
    129130      if (this.valueConfigurations != null) RegisterValueConfigurationEvents();
    130131    }
     
    270271
    271272    public void Parameterize(IValueParameter parameter) {
    272       parameter.ActualValue = this.ActualValue.Value;
     273      if (Optimize) {
     274        if (this.ActualValue.Value is IParameterizedItem) {
     275          this.ValueConfigurations.CheckedItems.ElementAt(actualValueConfigurationIndex).Parameterize((IParameterizedItem)this.ActualValue.Value);
     276        }
     277      }
     278      parameter.Value = this.ActualValue.Value;
    273279    }
    274280
     
    298304          this.ValueConfigurations.ElementAt(i).Cross(otherPc.ValueConfigurations.ElementAt(i), random);
    299305        }
     306        if (random.NextDouble() > 0.5) {
     307          actualValueConfigurationIndex = ((ParameterConfiguration)other).actualValueConfigurationIndex;
     308        }
    300309        this.ActualValue = this.ValueConfigurations.CheckedItems.ElementAt(actualValueConfigurationIndex).ActualValue;
    301310      }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/RangeConstraints/DoubleValueRange.cs

    r5009 r5023  
    2121    }
    2222
    23     public override DoubleValue GetRandomValue(IRandom random) {
     23    protected override DoubleValue GetRandomSample(IRandom random) {
    2424      double val;
    2525      do {
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/RangeConstraints/IntValueRange.cs

    r5009 r5023  
    2121    }
    2222
    23     public override IntValue GetRandomValue(IRandom random) {
     23    protected override IntValue GetRandomSample(IRandom random) {
    2424      int val;
    2525      do {
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/RangeConstraints/PercentValueRange.cs

    r5009 r5023  
    2121    }
    2222
    23     public override PercentValue GetRandomValue(IRandom random) {
     23    protected override PercentValue GetRandomSample(IRandom random) {
    2424      double val;
    2525      do {
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/RangeConstraints/Range.cs

    r5009 r5023  
    191191    #endregion
    192192
    193     public abstract T GetRandomValue(IRandom random);
     193    public T GetRandomValue(IRandom random) {
     194      // by a chance return the extreme values of this range to intensify search in those regions
     195      if (random.NextDouble() < 0.1) {
     196        if (random.NextDouble() < 0.5) {
     197          return LowerBound;
     198        } else {
     199          return UpperBound;
     200        }
     201      }
     202
     203      // otherwise sample a random value from the range
     204      return GetRandomSample(random);
     205    }
     206
     207    protected abstract T GetRandomSample(IRandom random);
    194208
    195209    IItem IRange.GetRandomValue(IRandom random) {
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/ValueConfigurations/ValueConfiguration.cs

    r5009 r5023  
    66using HeuristicLab.Data;
    77using System.Drawing;
     8using HeuristicLab.Encodings.RealVectorEncoding;
     9using HeuristicLab.Encodings.IntegerVectorEncoding;
    810
    911namespace HeuristicLab.Problems.MetaOptimization {
     
    9294    [StorableConstructor]
    9395    protected ValueConfiguration(bool deserializing) { }
    94     protected ValueConfiguration(ValueConfiguration original, Cloner cloner) : base(original, cloner) {
     96    protected ValueConfiguration(ValueConfiguration original, Cloner cloner)
     97      : base(original, cloner) {
    9598      this.ParameterConfigurations = cloner.Clone(original.parameterConfigurations);
    9699      this.actualValue = cloner.Clone(original.ActualValue);
     
    228231        if (rangeConstraint != null) {
    229232          if (this.actualValue.ValueDataType == typeof(IntValue)) {
    230             this.actualValue.Value = new IntValue((((IntValue)this.actualValue.Value).Value + ((IntValue)other.ActualValue.Value).Value) / 2);
     233            //this.actualValue.Value = new IntValue((((IntValue)this.actualValue.Value).Value + ((IntValue)other.ActualValue.Value).Value) / 2);
     234
     235            IntegerVector[] parents = new IntegerVector[2];
     236            parents[0] = new IntegerVector(new int[] { ((IntValue)this.actualValue.Value).Value });
     237            parents[1] = new IntegerVector(new int[] { ((IntValue)other.ActualValue.Value).Value });
     238
     239            this.actualValue.Value = new IntValue(HeuristicLab.Encodings.IntegerVectorEncoding.DiscreteCrossover.Apply(random, parents[0], parents[1]).First());
     240
    231241          } else if (this.actualValue.ValueDataType == typeof(DoubleValue)) {
    232             this.actualValue.Value = new DoubleValue((((DoubleValue)this.actualValue.Value).Value + ((DoubleValue)other.ActualValue.Value).Value) / 2);
     242            //this.actualValue.Value = new DoubleValue((((DoubleValue)this.actualValue.Value).Value + ((DoubleValue)other.ActualValue.Value).Value) / 2);
     243            RealVector[] parents = new RealVector[2];
     244            parents[0] = new RealVector( new double[] {((DoubleValue)this.actualValue.Value).Value} );
     245            parents[1] = new RealVector( new double[] {((DoubleValue)other.ActualValue.Value).Value} );
     246
     247            if (random.NextDouble() < 0.5) {
     248              this.actualValue.Value = new DoubleValue(AverageCrossover.Apply(random, new ItemArray<RealVector>(parents)).First());
     249            } else {
     250              this.actualValue.Value = new DoubleValue(HeuristicLab.Encodings.RealVectorEncoding.DiscreteCrossover.Apply(random, new ItemArray<RealVector>(parents)).First());
     251            }
     252            //this.actualValue.Value = new DoubleValue(AverageCrossover.Apply(random, new ItemArray<RealVector>(parents)).First());
     253           
    233254          } else if (this.actualValue.ValueDataType == typeof(PercentValue)) {
    234             this.actualValue.Value = new PercentValue((((PercentValue)this.actualValue.Value).Value + ((PercentValue)other.ActualValue.Value).Value) / 2);
     255            //this.actualValue.Value = new PercentValue((((PercentValue)this.actualValue.Value).Value + ((PercentValue)other.ActualValue.Value).Value) / 2);
     256
     257            RealVector[] parents = new RealVector[2];
     258            parents[0] = new RealVector(new double[] { ((PercentValue)this.actualValue.Value).Value });
     259            parents[1] = new RealVector(new double[] { ((PercentValue)other.ActualValue.Value).Value });
     260
     261            if (random.NextDouble() < 0.5) {
     262              this.actualValue.Value = new PercentValue(AverageCrossover.Apply(random, new ItemArray<RealVector>(parents)).First());
     263            } else {
     264              this.actualValue.Value = new PercentValue(HeuristicLab.Encodings.RealVectorEncoding.DiscreteCrossover.Apply(random, new ItemArray<RealVector>(parents)).First());
     265            }
     266
    235267          } else if (this.actualValue.ValueDataType == typeof(BoolValue)) {
    236             bool first = ((BoolValue)this.actualValue.Value).Value;
    237             bool second = ((BoolValue)other.ActualValue.Value).Value;
    238             if (first && second) {
    239               this.actualValue.Value = new BoolValue(true);
    240             } else if (!first && !second) {
    241               this.actualValue.Value = new BoolValue(false);
    242             } else {
    243               if (random.NextDouble() > 0.5)
    244                 this.actualValue.Value = new BoolValue(true);
    245               else
    246                 this.actualValue.Value = new BoolValue(false);
    247             }
     268            if (random.NextDouble() > 0.5)
     269              this.actualValue.Value = this.actualValue.Value;
     270            else
     271              this.actualValue.Value = other.ActualValue.Value;
    248272          } else {
    249273            throw new NotImplementedException();
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/MetaOptimizationEvaluator.cs

    r5009 r5023  
    11using System;
     2using System.Linq;
    23using System.Threading;
    34using HeuristicLab.Common;
     
    89using HeuristicLab.Parameters;
    910using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     11using System.Collections.Generic;
    1012
    1113namespace HeuristicLab.Problems.MetaOptimization {
     
    6971      algorithm.Stopped += new EventHandler(ActualValue_Stopped);
    7072
    71       double qualitySum = 0;
     73      List<double> qualities = new List<double>();
     74      List<TimeSpan> executionTimes = new List<TimeSpan>();
     75      algorithm.Prepare(true);
    7276
    73       //foreach (ISingleObjectiveProblem problem in ProblemsParameter.ActualValue) {
    74       algorithm.Engine = new SequentialEngine.SequentialEngine();
    75       //algorithm.Problem = problem;
    76       algorithm.Prepare();
    77       algorithm.Start();
    78       while (!algorithmStopped) {
    79         Thread.Sleep(1000); // wait for algorithm to complete; do not rely on Algorithm.ExecutionState here, because change of ExecutionState happens before Run is added (which causes problems because Algorithm might get cloned when its started already)
     77      for (int i = 0; i < Repetitions.Value; i++) {
     78        algorithm.Engine = new SequentialEngine.SequentialEngine();
     79        algorithm.Prepare();
     80        algorithm.Start();
     81        while (!algorithmStopped) {
     82          Thread.Sleep(200); // wait for algorithm to complete; do not rely on Algorithm.ExecutionState here, because change of ExecutionState happens before Run is added (which causes problems because Algorithm might get cloned when its started already)
     83        }
     84        qualities.Add(((DoubleValue)algorithm.Results["BestQuality"].Value).Value);
     85        executionTimes.Add(algorithm.ExecutionTime);
     86
     87        algorithmStopped = false;
    8088      }
    81       double quality = ((DoubleValue)algorithm.Results["BestQuality"].Value).Value;
    82       ParameterConfigurationParameter.ActualValue.Quality.Value = quality;
    83       qualitySum += quality;
    84       //}
    85 
    8689      algorithm.Stopped -= new EventHandler(ActualValue_Stopped);
    8790
    88       //double qualityAvg = qualitySum / ProblemsParameter.ActualValue.Count;
    89       //this.QualityParameter.ActualValue = new DoubleValue(qualityAvg);
     91      qualities = qualities.OrderBy(x => x).ToList();  // todo: respect Maximization:true/false
     92     
     93      ParameterConfigurationParameter.ActualValue.AverageExecutionTime = new TimeSpanValue(TimeSpan.FromMilliseconds(executionTimes.Average(t => t.TotalMilliseconds)));
     94      ParameterConfigurationParameter.ActualValue.Repetitions = Repetitions;
     95      ParameterConfigurationParameter.ActualValue.BestQuality = new DoubleValue(qualities.First());
     96      ParameterConfigurationParameter.ActualValue.AverageQuality = new DoubleValue(qualities.Average());
     97      ParameterConfigurationParameter.ActualValue.WorstQuality = new DoubleValue(qualities.Last());
     98      ParameterConfigurationParameter.ActualValue.QualityVariance = new DoubleValue(qualities.Variance());
     99      ParameterConfigurationParameter.ActualValue.QualityStandardDeviation = new DoubleValue(qualities.StandardDeviation());
     100      ParameterConfigurationParameter.ActualValue.Runs = algorithm.Runs;
     101
     102      double quality = ParameterConfigurationParameter.ActualValue.AverageQuality.Value; // todo: also include other measures (executiontime, variance)
    90103      this.QualityParameter.ActualValue = new DoubleValue(quality);
     104     
     105      return base.Apply();
     106    }
    91107
    92       return base.Apply();
     108    public static double Variance(IEnumerable<double> source) {
     109      double avg = source.Average();
     110      double d = source.Aggregate(0.0, (total, next) => total += Math.Pow(next - avg, 2));
     111      return d / (source.Count() - 1);
     112    }
     113
     114    public static double StandardDeviation(IEnumerable<double> source) {
     115      return Math.Sqrt(source.Variance());
    93116    }
    94117
     
    96119      algorithmStopped = true;
    97120    }
    98 
    99     //private void ParameterizeAlgorithm() {
    100     //  foreach (IParameterConfiguration parameter in ParameterVectorParameter.ActualValue) {
    101     //    if (typeof(IAlgorithm).IsAssignableFrom(parameter.OperatorType)) {
    102     //      this.AlgorithmParameter.ActualValue.Parameters[parameter.Parameter.Name].ActualValue = parameter.Parameter.ActualValue;
    103     //    } else if (typeof(IProblem).IsAssignableFrom(parameter.OperatorType)) {
    104     //      this.AlgorithmParameter.ActualValue.Problem.Parameters[parameter.Parameter.Name].ActualValue = parameter.Parameter.ActualValue;
    105     //    }
    106     //  }
    107     //}
    108121  }
    109122}
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/HeuristicLab.Problems.MetaOptimization-3.3.csproj

    r5009 r5023  
    9191  <ItemGroup>
    9292    <Compile Include="Analyzers\BestParameterConfigurationAnalyzer.cs" />
     93    <None Include="ClassDiagram1.cd" />
    9394    <None Include="Properties\AssemblyInfo.cs.frame" />
    9495    <None Include="HeuristicLabProblemsMetaOptimizationPlugin.cs.frame" />
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IOptimizable.cs

    r5009 r5023  
    1515    void Mutate(IRandom random);
    1616    void Cross(IOptimizable other, IRandom random);
    17 
     17   
    1818    event EventHandler IsOptimizableChanged;
    1919    event EventHandler OptimizeChanged;
Note: See TracChangeset for help on using the changeset viewer.