Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/05/11 02:03:20 (14 years ago)
Author:
cneumuel
Message:

#1215

  • added normalization for quality values of individuals
Location:
branches/HeuristicLab.MetaOptimization
Files:
7 edited

Legend:

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

    r5207 r5212  
    116116      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Data.Views-3.3.dll</HintPath>
    117117    </Reference>
     118    <Reference Include="HeuristicLab.DataAccess-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     119      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.DataAccess-3.3.dll</HintPath>
     120    </Reference>
    118121    <Reference Include="HeuristicLab.Encodings.BinaryVectorEncoding-3.3">
    119122      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.dll</HintPath>
     
    136139    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.3">
    137140      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.3.dll</HintPath>
     141    </Reference>
     142    <Reference Include="HeuristicLab.Hive.Contracts-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     143      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Contracts-3.3.dll</HintPath>
     144    </Reference>
     145    <Reference Include="HeuristicLab.Hive.ExperimentManager-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     146      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.ExperimentManager-3.3.dll</HintPath>
     147    </Reference>
     148    <Reference Include="HeuristicLab.Hive.ExperimentManager.Views-3.3">
     149      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.ExperimentManager.Views-3.3.dll</HintPath>
     150    </Reference>
     151    <Reference Include="HeuristicLab.Hive.JobBase-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     152      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.JobBase-3.3.dll</HintPath>
     153    </Reference>
     154    <Reference Include="HeuristicLab.Hive.Server.Console-3.3">
     155      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Server.Console-3.3.dll</HintPath>
     156    </Reference>
     157    <Reference Include="HeuristicLab.Hive.Server.Core-3.3">
     158      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Server.Core-3.3.dll</HintPath>
     159    </Reference>
     160    <Reference Include="HeuristicLab.Hive.Server.DataAccess-3.3">
     161      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Server.DataAccess-3.3.dll</HintPath>
     162    </Reference>
     163    <Reference Include="HeuristicLab.Hive.Server.LINQDataAccess-3.3">
     164      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Server.LINQDataAccess-3.3.dll</HintPath>
     165    </Reference>
     166    <Reference Include="HeuristicLab.Hive.Slave.Common-3.3">
     167      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Slave.Common-3.3.dll</HintPath>
     168    </Reference>
     169    <Reference Include="HeuristicLab.Hive.Slave.Communication-3.3">
     170      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Slave.Communication-3.3.dll</HintPath>
     171    </Reference>
     172    <Reference Include="HeuristicLab.Hive.Slave.Console-3.3">
     173      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Slave.Console-3.3.dll</HintPath>
     174    </Reference>
     175    <Reference Include="HeuristicLab.Hive.Slave.Core-3.3">
     176      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Slave.Core-3.3.dll</HintPath>
     177    </Reference>
     178    <Reference Include="HeuristicLab.Hive.Slave.ExecutionEngine-3.3">
     179      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Slave.ExecutionEngine-3.3.dll</HintPath>
     180    </Reference>
     181    <Reference Include="HeuristicLab.Hive.Tracing-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     182      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Tracing-3.3.dll</HintPath>
     183    </Reference>
     184    <Reference Include="HeuristicLab.HiveEngine-3.3">
     185      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.HiveEngine-3.3.dll</HintPath>
    138186    </Reference>
    139187    <Reference Include="HeuristicLab.LibSVM-1.6.3">
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/Program.cs

    r5207 r5212  
    2121using System.Diagnostics;
    2222using HeuristicLab.Encodings.RealVectorEncoding;
     23using HeuristicLab.Hive.ExperimentManager;
    2324
    2425namespace HeuristicLab.MetaOptimization.Test {
    2526  class Program {
    26     private static int metaAlgorithmPopulationSize = 50;
    27     private static int metaAlgorithmMaxGenerations = 30;
    28     private static int metaProblemRepetitions = 5;
    29     private static int baseAlgorithmMaxGenerations = 1000;
    30 
    31     //private static int metaAlgorithmPopulationSize = 10;
    32     //private static int metaAlgorithmMaxGenerations = 20;
    33     //private static int metaProblemRepetitions = 3;
    34     //private static int baseAlgorithmMaxGenerations = 10;
     27    //private static int metaAlgorithmPopulationSize = 50;
     28    //private static int metaAlgorithmMaxGenerations = 30;
     29    //private static int metaProblemRepetitions = 5;
     30    //private static int baseAlgorithmMaxGenerations = 1000;
     31
     32    private static int metaAlgorithmPopulationSize = 10;
     33    private static int metaAlgorithmMaxGenerations = 20;
     34    private static int metaProblemRepetitions = 3;
     35    private static int baseAlgorithmMaxGenerations = 10;
    3536
    3637    static void Main(string[] args) {
     
    5354      MetaOptimizationProblem metaOptimizationProblem = new MetaOptimizationProblem();
    5455      metaOptimizationProblem.Repetitions = new IntValue(metaProblemRepetitions);
    55       //GeneticAlgorithm metaLevelAlgorithm = GetMetaGA(metaOptimizationProblem);
    56       GeneticAlgorithm metaLevelAlgorithm = GetParallelMetaGA(metaOptimizationProblem);
     56      GeneticAlgorithm metaLevelAlgorithm = GetMetaGA(metaOptimizationProblem);
     57      //GeneticAlgorithm metaLevelAlgorithm = GetParallelMetaGA(metaOptimizationProblem);
     58      //GeneticAlgorithm metaLevelAlgorithm = GetHiveParallelMetaGA(metaOptimizationProblem);
     59
    5760      //EvolutionStrategy metaLevelAlgorithm = GetMetaES(metaOptimizationProblem);
    5861
     
    304307    private static GeneticAlgorithm GetParallelMetaGA(MetaOptimizationProblem metaOptimizationProblem) {
    305308      GeneticAlgorithm metaLevelAlgorithm = GetMetaGA(metaOptimizationProblem);
    306 
    307       UniformSubScopesProcessor uniformSubScopesProcessor =
    308         (HeuristicLab.Operators.UniformSubScopesProcessor)
    309         ((HeuristicLab.Operators.AlgorithmOperator)metaLevelAlgorithm.OperatorGraph.Operators.ElementAt(2)).OperatorGraph.Operators.ElementAt(8);
    310       uniformSubScopesProcessor.Parallel.Value = true;
    311 
    312309      metaLevelAlgorithm.Engine = new ParallelEngine.ParallelEngine();
    313 
     310      return metaLevelAlgorithm;
     311    }
     312
     313    private static GeneticAlgorithm GetHiveParallelMetaGA(MetaOptimizationProblem metaOptimizationProblem) {
     314      GeneticAlgorithm metaLevelAlgorithm = GetParallelMetaGA(metaOptimizationProblem);
     315      metaLevelAlgorithm.Engine = new HiveEngine.HiveEngine();
     316      ServiceLocator.Instance.ClientFacadePool.UserName = "cneumuel";
     317      ServiceLocator.Instance.ClientFacadePool.Password = "cneumuel";
     318      ServiceLocator.Instance.StreamedClientFacadePool.UserName = "cneumuel";
     319      ServiceLocator.Instance.StreamedClientFacadePool.Password = "cneumuel";
    314320      return metaLevelAlgorithm;
    315321    }
     
    337343      metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() {
    338344        Evaluator = new GriewankEvaluator(),
     345        ProblemSize = new IntValue(5)
     346      });
     347      metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() {
     348        Evaluator = new GriewankEvaluator(),
     349        ProblemSize = new IntValue(50)
     350      });
     351      metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() {
     352        Evaluator = new GriewankEvaluator(),
    339353        ProblemSize = new IntValue(500)
    340354      });
    341       //metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() {
    342       //  Evaluator = new GriewankEvaluator(),
    343       //  ProblemSize = new IntValue(1000)
    344       //});
    345 
    346       ConfigurePopulationSize(algorithmVc, 0, 100, 1);
     355
     356      ConfigurePopulationSize(algorithmVc, 12, 100, 1);
    347357      ConfigureMutationRate(algorithmVc, 0.0, 1.0, 0.01);
    348       ConfigureMutationOperator(algorithmVc);
     358      //ConfigureMutationOperator(algorithmVc);
    349359      ConfigureElites(algorithmVc, 0, 10, 1);
    350       ConfigureSelectionOperator(algorithmVc, true);
     360      //ConfigureSelectionOperator(algorithmVc, true);
    351361      return algorithmVc;
    352362    }
     
    541551              if (result.Name == "Population") {
    542552                RunCollection rc = (RunCollection)result.Value;
    543                 var orderedRuns = rc.OrderBy(x => x.Results["RunsAverageQuality"]);
    544 
    545                 TableBuilder tb = new TableBuilder("AvgQual", "AvgET", "PoSi", "MutRa", "Eli", "SelOp", "MutOp", "NrSelSubScopes");
     553                var orderedRuns = rc.OrderBy(x => x.Results["AverageQualityNormalized"]);
     554
     555                TableBuilder tb = new TableBuilder("QNorm", "PoSi", "MutRa", "Eli", "SelOp", "MutOp", "NrSelSubScopes");
    546556                foreach (IRun run in orderedRuns) {
    547557                  string selector;
     
    553563
    554564                  tb.AppendRow(
    555                     ((DoubleValue)run.Results["RunsAverageQuality"]).Value.ToString("#0.00"),
    556                     run.Results["RunsAverageExecutionTime"].ToString(),
     565                    ((DoubleValue)run.Results["AverageQualityNormalized"]).Value.ToString("#0.00"),
    557566                    ((IntValue)run.Parameters["PopulationSize"]).Value.ToString(),
    558567                    ((DoubleValue)run.Parameters["MutationProbability"]).Value.ToString("0.00"),
     
    584593    private static void metaLevelAlgorithm_ExceptionOccurred(object sender, EventArgs<Exception> e) {
    585594      Console.WriteLine("metaLevelAlgorithm_ExceptionOccurred");
     595      Console.WriteLine(e.Value.ToString());
     596      if (e.Value.InnerException != null) {
     597        Console.WriteLine(e.Value.InnerException.ToString());
     598      }
    586599    }
    587600
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/app.config

    r5184 r5212  
    11<?xml version="1.0"?>
    22<configuration>
    3   <runtime>
    4     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    5       <dependentAssembly>
    6         <assemblyIdentity name="HeuristicLab.Tracing-3.3" publicKeyToken="BA48961D6F65DCEC" culture="neutral"/>
    7         <bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0"/>
    8       </dependentAssembly>
    9       <dependentAssembly>
    10         <assemblyIdentity name="HeuristicLab.Common.Resources-3.3" publicKeyToken="BA48961D6F65DCEC" culture="neutral"/>
    11         <bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0"/>
    12       </dependentAssembly>
    13     </assemblyBinding>
    14   </runtime>
    15 <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
     3  <configSections>
     4  </configSections>
     5
     6  <system.serviceModel>
     7
     8    <bindings>
     9      <netTcpBinding>
     10        <binding name="ClientTcpStreamedEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:30:00" transactionFlow="false" transferMode="Streamed" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="314572800">
     11          <readerQuotas maxDepth="32" maxStringContentLength="104857600" maxArrayLength="104857600" maxBytesPerRead="104857600" maxNameTableCharCount="104857600"/>
     12          <reliableSession ordered="true" inactivityTimeout="00:30:00" enabled="false"/>
     13          <security mode="TransportWithMessageCredential">
     14            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
     15            <message clientCredentialType="UserName" algorithmSuite="Default"/>
     16          </security>
     17        </binding>
     18      </netTcpBinding>
     19      <wsHttpBinding>
     20        <binding name="ClientHttpEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:30:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="314572800" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
     21          <readerQuotas maxDepth="32" maxStringContentLength="104857600" maxArrayLength="104857600" maxBytesPerRead="104857600" maxNameTableCharCount="104857600"/>
     22          <reliableSession ordered="true" inactivityTimeout="00:30:00" enabled="false"/>
     23          <security mode="Message">
     24            <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
     25            <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default"/>
     26          </security>
     27        </binding>
     28      </wsHttpBinding>
     29    </bindings>
     30    <client>
     31      <endpoint address="net.tcp://christoph:9001/Hive-3.3/ClientService.svc" binding="netTcpBinding" bindingConfiguration="ClientTcpStreamedEndpoint" contract="HeuristicLab.Hive.Contracts.Interfaces.IClientFacade" name="ClientTcpStreamedEndpoint">
     32        <identity>
     33          <dns value="localhost"/>
     34        </identity>
     35      </endpoint>
     36      <endpoint address="http://christoph/Hive-3.3/ClientService.svc" binding="wsHttpBinding" bindingConfiguration="ClientHttpEndpoint" contract="HeuristicLab.Hive.Contracts.Interfaces.IClientFacade" name="ClientHttpEndpoint">
     37        <identity>
     38          <certificate encodedValue="AwAAAAEAAAAUAAAAozaKcSPdw1Cdd57hw9mr3eCjxTIgAAAAAQAAAPIBAAAwggHuMIIBW6ADAgECAhBhrVLVbjrtvUe4zWuGbVeuMAkGBSsOAwIdBQAwFDESMBAGA1UEAxMJbG9jYWxob3N0MB4XDTEwMTAxMjA2NTYyNloXDTM5MTIzMTIzNTk1OVowFDESMBAGA1UEAxMJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDFM6bQUgvCnsnBO9TZnOrC6x1riE2pXUzU6H38GYot674WNfir82fMh9+ojWSY/CiMzExcNWFtC3i8BG7giLYVwSanuwQ8QyRFYq3g5UMqdlm4/aof/4QMmS+SuRDsa8F4lbvdS9zBVFiyyUNYzlzO/rY08DrkCgx4X2IQGOvixwIDAQABo0kwRzBFBgNVHQEEPjA8gBCjMn9uvzNhU2c//E3RSYmUoRYwFDESMBAGA1UEAxMJbG9jYWxob3N0ghBhrVLVbjrtvUe4zWuGbVeuMAkGBSsOAwIdBQADgYEADIf8as2VBfZEpwb/GuVifvPTR0Ud+dTCwTjBdMymqjNR5NTSi408DifssSTBVGIi7xkWbQDlQQHOZmVqVFoqfNbGrtm9w1MSK24HAEMXr0WFBltvldGKCvtYnZqf377qU5gq7IBXcJZi87bZ2l1M3icr6RJo4fIbnZOa5M430aw="/>
     39        </identity>
     40      </endpoint>
     41    </client>
     42
     43  </system.serviceModel>
     44</configuration>
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Analyzers/BestParameterConfigurationAnalyzer.cs

    r5087 r5212  
    4040    }
    4141
     42    // stores the medians of the qualities of each problem
     43    public LookupParameter<DoubleArray> ProblemQualityMediansParameter {
     44      get { return (LookupParameter<DoubleArray>)Parameters["ProblemQualityMedians"]; }
     45    }
     46    public LookupParameter<ConstrainedItemList<ISingleObjectiveProblem>> ProblemsParameter {
     47      get { return (LookupParameter<ConstrainedItemList<ISingleObjectiveProblem>>)Parameters[MetaOptimizationProblem.ProblemsParameterName]; }
     48    }
     49
    4250    public BestParameterConfigurationAnalyzer()
    4351      : base() {
     
    4957      Parameters.Add(new LookupParameter<IRun>("BestKnownSolution", "TODO The best known solution of this TSP instance."));
    5058      Parameters.Add(new LookupParameter<RunCollection>("Population", "TODO The best known solution of this TSP instance."));
     59      Parameters.Add(new LookupParameter<DoubleArray>("ProblemQualityMedians", ""));
     60      Parameters.Add(new LookupParameter<ConstrainedItemList<ISingleObjectiveProblem>>(MetaOptimizationProblem.ProblemsParameterName));
    5161    }
    5262
     
    6575
    6676      int idxBest = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).First().index;
    67 
    6877
    6978      ParameterConfigurationTree best = (ParameterConfigurationTree)parameterTrees[idxBest];
     
    8796
    8897      // population
    89 
    9098      int i = 0;
    9199      RunCollection rc = new RunCollection();
    92       foreach (ParameterConfigurationTree pt in parameterTrees.OrderByDescending(x => x.BestQuality.Value)) { // todo: respect Maximization:true/false
     100      foreach (ParameterConfigurationTree pt in parameterTrees.OrderBy(x => x.AverageQualityNormalized)) { // todo: respect Maximization:true/false
    93101        IRun run = new Run();
    94102        run.Name = string.Format("Individuum ({0})", i);
     
    106114      }
    107115
     116      // medians for the problems
     117      DoubleArray medians = new DoubleArray(ProblemsParameter.ActualValue.Count);
     118      for (int pi = 0; pi < ProblemsParameter.ActualValue.Count; pi++) {
     119        double[] values = new double[rc.Count];
     120        for (int ri = 0; ri < rc.Count; ri++) {
     121          values[ri] = ((DoubleArray)rc.ElementAt(ri).Results["RunsAverageQualities"])[pi];
     122        }
     123        medians[pi] = values.Median();
     124      }
     125      ProblemQualityMediansParameter.ActualValue = medians;
     126
     127      if (results.ContainsKey("ProblemsAverageQualityMedians")) {
     128        results["ProblemsAverageQualityMedians"].Value = medians;
     129      } else {
     130        results.Add(new Result("ProblemsAverageQualityMedians", medians));
     131      }
     132
    108133      return base.Apply();
    109134    }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurationTree.cs

    r5207 r5212  
    1414  [StorableClass]
    1515  public class ParameterConfigurationTree : ValueConfiguration, IEnumerable {
    16     [Storable]
    17     private DoubleValue bestQuality;
    18     public DoubleValue BestQuality {
    19       get { return bestQuality; }
     16
     17    [Storable]
     18    private DoubleValue averageQualityNormalized;
     19    public DoubleValue AverageQualityNormalized {
     20      get { return averageQualityNormalized; }
    2021      set {
    21         if (bestQuality != value) {
    22           if (bestQuality != null) DeregisterQualityEvents();
    23           bestQuality = value;
    24           if (bestQuality != null) RegisterQualityEvents();
     22        if (averageQualityNormalized != value) {
     23          averageQualityNormalized = value;
    2524          OnQualityChanged();
    2625        }
     
    2928
    3029    [Storable]
    31     private DoubleValue averageQuality;
    32     public DoubleValue AverageQuality {
    33       get { return averageQuality; }
    34       set { averageQuality = value; }
    35     }
    36 
    37     [Storable]
    38     private DoubleValue worstQuality;
    39     public DoubleValue WorstQuality {
    40       get { return worstQuality; }
    41       set { worstQuality = value; }
    42     }
    43 
    44     [Storable]
    45     private DoubleValue qualityVariance;
    46     public DoubleValue QualityVariance {
    47       get { return qualityVariance; }
    48       set { qualityVariance = value; }
    49     }
    50 
    51     [Storable]
    52     private DoubleValue qualityStandardDeviation;
    53     public DoubleValue QualityStandardDeviation {
    54       get { return qualityStandardDeviation; }
    55       set { qualityStandardDeviation = value; }
    56     }
    57 
    58     [Storable]
    59     private TimeSpanValue averageExecutionTime;
    60     public TimeSpanValue AverageExecutionTime {
    61       get { return averageExecutionTime; }
    62       set { averageExecutionTime = value; }
     30    private DoubleArray qualitiesNormalized;
     31    public DoubleArray QualitiesNormalized {
     32      get { return qualitiesNormalized; }
     33      set {
     34        if (qualitiesNormalized != value) {
     35          qualitiesNormalized = value;
     36        }
     37      }
     38    }
     39
     40    [Storable]
     41    private DoubleArray bestQualities;
     42    public DoubleArray BestQualities {
     43      get { return bestQualities; }
     44      set {
     45        if (bestQualities != value) {
     46          bestQualities = value;
     47        }
     48      }
     49    }
     50
     51    [Storable]
     52    private DoubleArray averageQualities;
     53    public DoubleArray AverageQualities {
     54      get { return averageQualities; }
     55      set { averageQualities = value; }
     56    }
     57
     58    [Storable]
     59    private DoubleArray worstQualities;
     60    public DoubleArray WorstQualities {
     61      get { return worstQualities; }
     62      set { worstQualities = value; }
     63    }
     64
     65    [Storable]
     66    private DoubleArray qualityVariances;
     67    public DoubleArray QualityVariances {
     68      get { return qualityVariances; }
     69      set { qualityVariances = value; }
     70    }
     71
     72    [Storable]
     73    private DoubleArray qualityStandardDeviations;
     74    public DoubleArray QualityStandardDeviations {
     75      get { return qualityStandardDeviations; }
     76      set { qualityStandardDeviations = value; }
     77    }
     78
     79    [Storable]
     80    private ItemList<TimeSpanValue> averageExecutionTimes;
     81    public ItemList<TimeSpanValue> AverageExecutionTimes {
     82      get { return averageExecutionTimes; }
     83      set { averageExecutionTimes = value; }
    6384    }
    6485
     
    88109      : base(null, algorithm.GetType()) {
    89110      this.Optimize = true; // root must always be optimized
    90       this.BestQuality = new DoubleValue();
    91111      this.parameters = new Dictionary<string, IItem>();
    92112
    93113      PopulateParameterConfigurations(algorithm);
    94       Initialize();
    95114    }
    96115    public ParameterConfigurationTree() {
    97       Initialize();
    98116    }
    99117    [StorableConstructor]
     
    101119    protected ParameterConfigurationTree(ParameterConfigurationTree original, Cloner cloner)
    102120      : base(original, cloner) {
    103       this.bestQuality = cloner.Clone(original.BestQuality);
    104       this.averageQuality = cloner.Clone(original.averageQuality);
    105       this.worstQuality = cloner.Clone(original.worstQuality);
    106       this.qualityStandardDeviation = cloner.Clone(original.qualityStandardDeviation);
    107       this.qualityVariance = cloner.Clone(original.qualityVariance);
    108       this.averageExecutionTime = cloner.Clone(original.averageExecutionTime);
     121      this.bestQualities = cloner.Clone(original.BestQualities);
     122      this.averageQualities = cloner.Clone(original.averageQualities);
     123      this.worstQualities = cloner.Clone(original.worstQualities);
     124      this.qualityStandardDeviations = cloner.Clone(original.qualityStandardDeviations);
     125      this.qualityVariances = cloner.Clone(original.qualityVariances);
     126      this.averageExecutionTimes = cloner.Clone(original.averageExecutionTimes);
    109127      this.repetitions = cloner.Clone(original.repetitions);
    110128      this.runs = cloner.Clone(original.runs);
     
    113131        this.parameters.Add(p.Key, cloner.Clone(p.Value));
    114132      }
    115       Initialize();
    116133    }
    117134    public override IDeepCloneable Clone(Cloner cloner) {
     
    120137    [StorableHook(HookType.AfterDeserialization)]
    121138    private void AfterDeserialization() {
    122       Initialize();
    123139    }
    124140    #endregion
    125141
    126     private void Initialize() {
    127       //if (algorithm != null) RegisterAlgorithmEvents();
    128       if (bestQuality != null) RegisterQualityEvents();
    129     }
    130 
    131142    public virtual void CollectResultValues(IDictionary<string, IItem> values) {
    132       values.Add("RunsAverageExecutionTime", AverageExecutionTime);
     143      values.Add("RunsAverageExecutionTimes", AverageExecutionTimes);
    133144      values.Add("Repetitions", Repetitions);
    134       values.Add("RunsBestQuality", BestQuality);
    135       values.Add("RunsAverageQuality", AverageQuality);
    136       values.Add("RunsWorstQuality", WorstQuality);
    137       values.Add("RunsQualityVariance", QualityVariance);
    138       values.Add("RunsQualityStandardDeviation", QualityStandardDeviation);
     145      values.Add("RunsBestQualities", BestQualities);
     146      values.Add("RunsAverageQualities", AverageQualities);
     147      values.Add("RunsWorstQualities", WorstQualities);
     148      values.Add("RunsQualityVariances", QualityVariances);
     149      values.Add("RunsQualityStandardDeviations", QualityStandardDeviations);
     150      values.Add("QualitiesNormalized", QualitiesNormalized);
     151      values.Add("AverageQualityNormalized", AverageQualityNormalized);
    139152      values.Add("Runs", Runs);
    140153    }
     
    147160
    148161    #region Events
    149     //public event EventHandler AlgorithmChanged;
    150     //private void OnAlgorithmChanged() {
    151     //  var handler = AlgorithmChanged;
    152     //  if (handler != null) handler(this, EventArgs.Empty);
    153     //}
    154162    public event EventHandler QualityChanged;
    155163    private void OnQualityChanged() {
    156164      var handler = QualityChanged;
    157165      if (handler != null) handler(this, EventArgs.Empty);
    158     }
    159 
    160     //private void RegisterAlgorithmEvents() {
    161 
    162     //}
    163     //private void DeregisterAlgorithmEvents() {
    164 
    165     //}
    166     private void RegisterQualityEvents() {
    167       BestQuality.ValueChanged += new EventHandler(Quality_ValueChanged);
    168     }
    169     private void DeregisterQualityEvents() {
    170       BestQuality.ValueChanged -= new EventHandler(Quality_ValueChanged);
    171166    }
    172167
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/ParameterConfigurationEvaluator.cs

    r5207 r5212  
    4040    }
    4141
     42    public LookupParameter<DoubleArray> ProblemQualityMediansParameter {
     43      get { return (LookupParameter<DoubleArray>)Parameters["ProblemQualityMedians"]; }
     44    }
     45
    4246    public IntValue Repetitions {
    4347      get { return RepetitionsParameter.ActualValue; }
     
    5155      Parameters.Add(new LookupParameter<ParameterConfigurationTree>("ParameterConfigurationTree", "Missing description."));
    5256      Parameters.Add(new LookupParameter<IntValue>(MetaOptimizationProblem.RepetitionsParameterName, "Number of evaluations on one problem."));
     57      Parameters.Add(new LookupParameter<DoubleArray>("ProblemQualityMedians", ""));
    5358    }
    5459
     
    6671      IItemList<ISingleObjectiveProblem> problems = ProblemsParameter.ActualValue;
    6772
     73      double[] medians;
     74      if (ProblemQualityMediansParameter.ActualValue == null) {
     75        // this is generation zero. no reference qualities for scaling have been calculated yet. calculate a random individuum to get reference values
     76        medians = new double[problems.Count]; // todo
     77        for (int i = 0; i < medians.Length; i++) {
     78          medians[i] = 10;
     79        }
     80      } else {
     81        medians = ProblemQualityMediansParameter.ActualValue.ToArray();
     82      }
     83
    6884      // set parameters
    6985      ParameterConfigurationParameter.ActualValue.Parameterize(algorithm);
    7086      algorithm.StoreAlgorithmInEachRun = false;
    7187
    72       List<double> qualities = new List<double>();
    73       List<TimeSpan> executionTimes = new List<TimeSpan>();
     88      List<List<double>> qualities = new List<List<double>>();
     89      List<List<TimeSpan>> executionTimes = new List<List<TimeSpan>>();
    7490      algorithm.Engine = new SequentialEngine.SequentialEngine();
    7591      algorithm.Prepare(true);
     
    7793      foreach (ISingleObjectiveProblem problem in problems) {
    7894        algorithm.Problem = (IProblem)problem.Clone();
     95        var problemQualities = new List<double>();
     96        var problemExecutionTimes = new List<TimeSpan>();
    7997
    8098        for (int i = 0; i < Repetitions.Value; i++) {
     
    86104          if (algorithm.ExecutionState == ExecutionState.Paused) {
    87105            // this parametercombination was bad. set penalty for this solution
    88             qualities.Add(PenaltyQuality); // todo: respect Maximization; problem: this messes up average value; solution: use currently worst quality*2
    89             executionTimes.Add(algorithm.ExecutionTime);
     106            problemQualities.Add(PenaltyQuality); // todo: respect Maximization; problem: this messes up average value; solution: use currently worst quality*2
     107            problemExecutionTimes.Add(algorithm.ExecutionTime);
    90108          } else {
    91             qualities.Add(((DoubleValue)algorithm.Results["BestQuality"].Value).Value);
    92             executionTimes.Add(algorithm.ExecutionTime);
     109            problemQualities.Add(((DoubleValue)algorithm.Results["BestQuality"].Value).Value);
     110            problemExecutionTimes.Add(algorithm.ExecutionTime);
    93111
    94112            // parameters will be stored in ParameterConfigurationTree anyway. they would be redundant in runs
     
    98116          }
    99117        }
     118        qualities.Add(problemQualities);
     119        executionTimes.Add(problemExecutionTimes);
    100120      }
    101121      algorithm.Prepare();
    102122
    103       qualities = qualities.OrderBy(x => x).ToList();  // todo: respect Maximization:true/false
    104 
    105       ParameterConfigurationParameter.ActualValue.AverageExecutionTime = new TimeSpanValue(TimeSpan.FromMilliseconds(executionTimes.Average(t => t.TotalMilliseconds)));
     123      ParameterConfigurationParameter.ActualValue.AverageExecutionTimes = new ItemList<TimeSpanValue>(executionTimes.Select(t => new TimeSpanValue(TimeSpan.FromMilliseconds(t.Average(ts => ts.TotalMilliseconds)))));
    106124      ParameterConfigurationParameter.ActualValue.Repetitions = (IntValue)Repetitions.Clone();
    107       ParameterConfigurationParameter.ActualValue.BestQuality = new DoubleValue(qualities.First());
    108       ParameterConfigurationParameter.ActualValue.AverageQuality = new DoubleValue(qualities.Average());
    109       ParameterConfigurationParameter.ActualValue.WorstQuality = new DoubleValue(qualities.Last());
    110       ParameterConfigurationParameter.ActualValue.QualityVariance = new DoubleValue(qualities.Variance());
    111       ParameterConfigurationParameter.ActualValue.QualityStandardDeviation = new DoubleValue(qualities.StandardDeviation());
     125      ParameterConfigurationParameter.ActualValue.BestQualities = new DoubleArray(qualities.Select(q => q.Min()).ToArray()); // todo: respect Maximization:true/false
     126      ParameterConfigurationParameter.ActualValue.AverageQualities = new DoubleArray(qualities.Select(q => q.Average()).ToArray());
     127      ParameterConfigurationParameter.ActualValue.WorstQualities = new DoubleArray(qualities.Select(q => q.Max()).ToArray()); // todo: respect Maximization:true/false
     128      ParameterConfigurationParameter.ActualValue.QualityVariances = new DoubleArray(qualities.Select(q => q.Variance()).ToArray());
     129      ParameterConfigurationParameter.ActualValue.QualityStandardDeviations = new DoubleArray(qualities.Select(q => q.StandardDeviation()).ToArray());
    112130      ParameterConfigurationParameter.ActualValue.Runs = (RunCollection)algorithm.Runs.Clone();
    113131
    114       double quality = ParameterConfigurationParameter.ActualValue.AverageQuality.Value; // todo: also include other measures (executiontime, variance)
    115       this.QualityParameter.ActualValue = new DoubleValue(quality);
     132      // normalize qualities
     133      double[] qualitiesNormalized = new double[problems.Count];
     134      for (int i = 0; i < problems.Count; i++) {
     135        qualitiesNormalized[i] = qualities[i].Average() / medians[i];
     136      }
     137      ParameterConfigurationParameter.ActualValue.QualitiesNormalized = new DoubleArray(qualitiesNormalized);
     138      ParameterConfigurationParameter.ActualValue.AverageQualityNormalized = new DoubleValue(qualitiesNormalized.Average());
     139
     140      this.QualityParameter.ActualValue = ParameterConfigurationParameter.ActualValue.AverageQualityNormalized;
    116141
    117142      return base.Apply();
     
    129154  }
    130155
     156  /// <summary>
     157  /// Can execute an algorithm synchronously
     158  /// </summary>
    131159  public class AlgorithmExecutor {
    132160    private EngineAlgorithm algorithm;
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/MetaOptimizationProblem.cs

    r5184 r5212  
    109109      var validIntManipulators = new ItemSet<IIntValueManipulator>( ApplicationManager.Manager.GetInstances<IIntValueManipulator>());
    110110      var validDoubleManipulators = new ItemSet<IDoubleValueManipulator>(ApplicationManager.Manager.GetInstances<IDoubleValueManipulator>());
    111       Parameters.Add(new ConstrainedValueParameter<IIntValueManipulator>(IntValueManipulatorParameterName, "", validIntManipulators, new UniformIntValueManipulator()));
    112       Parameters.Add(new ConstrainedValueParameter<IDoubleValueManipulator>(DoubleValueManipulatorParameterName, "", validDoubleManipulators, new NormalDoubleValueManipulator()));
     111      Parameters.Add(new ConstrainedValueParameter<IIntValueManipulator>(IntValueManipulatorParameterName, "", validIntManipulators, validIntManipulators.First()));
     112      Parameters.Add(new ConstrainedValueParameter<IDoubleValueManipulator>(DoubleValueManipulatorParameterName, "", validDoubleManipulators, validDoubleManipulators.First()));
    113113
    114114      Maximization = new BoolValue(false);
Note: See TracChangeset for help on using the changeset viewer.