Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6938


Ignore:
Timestamp:
10/26/11 23:36:10 (13 years ago)
Author:
abeham
Message:

#1663

  • Added an *Operators* parameter in Problem
  • Adapted KnapsackProblem, OnemaxProblem, SingleObjectiveTestFunctionProblem, TravelingSalesmanProblem, and VehicleRoutingProblem to derive from SingleObjectiveHeuristicOptimizationProblem<U, V>, renamed and marked old list as obsolete. Note that QuadraticAssignmentProblem, as well as the new DataAnalysisProblems already derived from that class. ArtificialAntProblem was not yet modified.
  • Added some test lists and adapted SamplesTest
  • Added plugin dependencies that the unit test was complaining about
Location:
trunk/sources
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab 3.3.vsmdi

    r4066 r6938  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<TestLists xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
     3  <TestList name="Create Samples Tests" id="12acbb59-0ff6-4a9a-8f98-201e7d9412f9" parentListId="8c43106b-9dc1-4907-a29f-aa66a61bf5b6">
     4    <TestLinks>
     5      <TestLink id="fc406b79-142c-bb12-8287-0bc768acd728" name="CreateIslandGaTspSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     6      <TestLink id="77c479e4-8f9a-5474-b026-e5c0811c8eb0" name="CreateLocalSearchKnapsackSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     7      <TestLink id="45db65d6-d6b2-67e4-1bec-293528739529" name="CreateEsGriewankSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     8      <TestLink id="74b708a9-14d0-3cc3-d72e-139d1a27f5ef" name="CreateGaTspSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     9      <TestLink id="5c5fb63e-d219-6818-bba2-9f66dbe4d727" name="CreateGpSymbolicRegressionSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     10      <TestLink id="6c054fba-432a-4fe2-507f-e2083c998056" name="CreatePsoSchwefelSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     11      <TestLink id="0b6b45a4-99ea-b020-805a-1652f0f5b5a7" name="CreateSimulatedAnnealingRastriginSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     12      <TestLink id="51e968a7-120f-dd28-9514-ad35d3ee66d2" name="CreateGaVrpSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     13      <TestLink id="0d883f66-2fc5-99fc-eabb-2dff566104f5" name="CreateTabuSearchTspSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     14      <TestLink id="c8ea68e8-b9d7-24cb-5540-655f58da13bf" name="CreateGpArtificialAntSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     15      <TestLink id="e6f3ab8a-1630-560c-c8b9-4e8ce2522172" name="CreateVnsTspSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     16      <TestLink id="29257c28-7dfb-f227-00a4-776d74b02a7b" name="CreateGpSymbolicClassificationSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     17    </TestLinks>
     18  </TestList>
     19  <TestList name="Basic Tests" id="3f8b3bd5-248c-46a8-84cf-7d035eb3c815" parentListId="8c43106b-9dc1-4907-a29f-aa66a61bf5b6">
     20    <TestLinks>
     21      <TestLink id="36916402-ba0c-751d-366b-380dac87dcef" name="CheckPluginDependenciesForReferencedAssemblies" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     22      <TestLink id="29ead60b-2ae7-821a-ccc3-e5e4769661b7" name="TestStorableConstructor" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     23      <TestLink id="2028e687-d144-bb6f-bb05-ac86eaec07ee" name="TestCloningAllDeepCloneables" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     24      <TestLink id="3983eb26-fd15-5b88-1fd7-07b363511b10" name="TestCloningConstructor" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     25      <TestLink id="34ed65f1-46f7-d2e6-64cc-c2d958294d8b" name="CheckReferenceAssembliesForPluginDependencies" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     26      <TestLink id="ec4d1ddf-ed6b-9f9e-29a0-d9e558856af1" name="ContentViewAttributeTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     27    </TestLinks>
     28  </TestList>
     29  <TestList name="Run Samples Tests" id="40b94fb3-06ad-41f8-bb3f-dc90c2510684" parentListId="8c43106b-9dc1-4907-a29f-aa66a61bf5b6">
     30    <TestLinks>
     31      <TestLink id="8bb23f49-5206-4245-08b9-471f543b3e21" name="RunGpSymbolicRegressionSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     32      <TestLink id="1f743a89-461d-5650-31ba-e68c02f0fbad" name="RunGaVrpSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     33      <TestLink id="f8489a03-acca-11d3-53cb-8e24d5f2bc12" name="RunIslandGaTspSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     34      <TestLink id="0f7f90f7-e380-ff65-538e-ae559774092a" name="RunPsoSchwefelSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     35      <TestLink id="53547167-fc2b-4954-b200-2cc27b4c4951" name="RunVnsTspSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     36      <TestLink id="7512aa68-9dbe-f891-d1da-99dc94661142" name="RunEsGriewankSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     37      <TestLink id="433a86f1-0126-5281-1c23-90b47f066d94" name="RunGpSymbolicClassificationSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     38      <TestLink id="eec82cf0-dae7-63c8-a469-6dd84d49a935" name="RunGaTspSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     39      <TestLink id="7d7f6024-f783-1c71-db60-2d6746653109" name="RunSimulatedAnnealingRastriginSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     40      <TestLink id="29188193-8d50-0c61-c6fa-4d5b608a72e8" name="RunGpArtificialAntSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     41      <TestLink id="95278ae9-832c-bef9-0bbc-4432195e63fa" name="RunTabuSearchTspSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     42      <TestLink id="21f1371d-8c47-9588-d8fa-cf45fd1d81eb" name="RunLocalSearchKnapsackSampleTest" storage="heuristiclab.tests\bin\release\heuristiclab.tests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     43    </TestLinks>
     44  </TestList>
    345  <TestList name="Lists of Tests" id="8c43106b-9dc1-4907-a29f-aa66a61bf5b6">
    446    <RunConfiguration id="f9392825-866f-4434-be36-358db28f0c59" name="Local Test Run" storage="localtestrun.testrunconfig" type="Microsoft.VisualStudio.TestTools.Common.TestRunConfiguration, Microsoft.VisualStudio.QualityTools.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  • trunk/sources/HeuristicLab.Optimization/3.3/Problems/Problem.cs

    r5954 r6938  
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Core;
     28using HeuristicLab.Parameters;
    2829using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2930
     
    3233  [StorableClass]
    3334  public abstract class Problem : ParameterizedNamedItem, IProblem {
     35    private static readonly string OperatorsParameterName = "Operators";
     36
     37    public IFixedValueParameter<OperatorCollection> OperatorsParameter {
     38      get { return (IFixedValueParameter<OperatorCollection>)Parameters[OperatorsParameterName]; }
     39    }
     40
    3441    public override Image ItemImage {
    3542      get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
     
    3744
    3845    [StorableConstructor]
    39     protected Problem(bool deserializing) : base(deserializing) { }
     46    protected Problem(bool deserializing)
     47      : base(deserializing) {
     48      operators = new OperatorCollection(); // operators must never be null
     49    }
    4050    protected Problem(Problem original, Cloner cloner)
    4151      : base(original, cloner) {
     
    4757      : base() {
    4858      operators = new OperatorCollection();
     59      Parameters.Add(new FixedValueParameter<OperatorCollection>(OperatorsParameterName, "The operators that the problem provides to the algorithms.", operators, false));
     60      OperatorsParameter.Hidden = true;
    4961      RegisterEventHandlers();
    5062    }
     
    5264    [StorableHook(HookType.AfterDeserialization)]
    5365    private void AfterDeserialization() {
     66      // BackwardsCompatibility3.3
     67      #region Backwards compatible code, remove with 3.4
     68      if (!Parameters.ContainsKey(OperatorsParameterName)) {
     69        Parameters.Add(new FixedValueParameter<OperatorCollection>(OperatorsParameterName, "The operators that the problem provides to the algorithms.", operators, false));
     70        OperatorsParameter.Hidden = true;
     71      }
     72      #endregion
    5473      RegisterEventHandlers();
    5574    }
  • trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs

    r6476 r6938  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Drawing;
    2524using System.Linq;
    2625using HeuristicLab.Common;
     
    3736  [Creatable("Problems")]
    3837  [StorableClass]
    39   public sealed class KnapsackProblem : ParameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent {
     38  public sealed class KnapsackProblem : SingleObjectiveHeuristicOptimizationProblem<IKnapsackEvaluator, IBinaryVectorCreator>, IStorableContent {
    4039    public string Filename { get; set; }
    4140
    42     public override Image ItemImage {
    43       get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
    44     }
    45 
    4641    #region Parameter Properties
    47     public ValueParameter<BoolValue> MaximizationParameter {
    48       get { return (ValueParameter<BoolValue>)Parameters["Maximization"]; }
    49     }
    50     IParameter ISingleObjectiveHeuristicOptimizationProblem.MaximizationParameter {
    51       get { return MaximizationParameter; }
    52     }
    5342    public ValueParameter<IntValue> KnapsackCapacityParameter {
    5443      get { return (ValueParameter<IntValue>)Parameters["KnapsackCapacity"]; }
     
    6352      get { return (ValueParameter<DoubleValue>)Parameters["Penalty"]; }
    6453    }
    65     public ValueParameter<IBinaryVectorCreator> SolutionCreatorParameter {
    66       get { return (ValueParameter<IBinaryVectorCreator>)Parameters["SolutionCreator"]; }
    67     }
    68     IParameter IHeuristicOptimizationProblem.SolutionCreatorParameter {
    69       get { return SolutionCreatorParameter; }
    70     }
    71     public ValueParameter<IKnapsackEvaluator> EvaluatorParameter {
    72       get { return (ValueParameter<IKnapsackEvaluator>)Parameters["Evaluator"]; }
    73     }
    74     IParameter IHeuristicOptimizationProblem.EvaluatorParameter {
    75       get { return EvaluatorParameter; }
    76     }
    77     public OptionalValueParameter<DoubleValue> BestKnownQualityParameter {
    78       get { return (OptionalValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
    79     }
    80     IParameter ISingleObjectiveHeuristicOptimizationProblem.BestKnownQualityParameter {
    81       get { return BestKnownQualityParameter; }
    82     }
    8354    public OptionalValueParameter<BinaryVector> BestKnownSolutionParameter {
    8455      get { return (OptionalValueParameter<BinaryVector>)Parameters["BestKnownSolution"]; }
     
    8758
    8859    #region Properties
    89     public BoolValue Maximization {
    90       get { return MaximizationParameter.Value; }
    91       set { MaximizationParameter.Value = value; }
    92     }
    9360    public IntValue KnapsackCapacity {
    9461      get { return KnapsackCapacityParameter.Value; }
     
    10774      set { PenaltyParameter.Value = value; }
    10875    }
    109     public IBinaryVectorCreator SolutionCreator {
    110       get { return SolutionCreatorParameter.Value; }
    111       set { SolutionCreatorParameter.Value = value; }
    112     }
    113     ISolutionCreator IHeuristicOptimizationProblem.SolutionCreator {
    114       get { return SolutionCreatorParameter.Value; }
    115     }
    116     public IKnapsackEvaluator Evaluator {
    117       get { return EvaluatorParameter.Value; }
    118       set { EvaluatorParameter.Value = value; }
    119     }
    120     ISingleObjectiveEvaluator ISingleObjectiveHeuristicOptimizationProblem.Evaluator {
    121       get { return EvaluatorParameter.Value; }
    122     }
    123     IEvaluator IHeuristicOptimizationProblem.Evaluator {
    124       get { return EvaluatorParameter.Value; }
    125     }
    126     public DoubleValue BestKnownQuality {
    127       get { return BestKnownQualityParameter.Value; }
    128       set { BestKnownQualityParameter.Value = value; }
    129     }
    13076    public BinaryVector BestKnownSolution {
    13177      get { return BestKnownSolutionParameter.Value; }
    13278      set { BestKnownSolutionParameter.Value = value; }
    13379    }
    134     public IEnumerable<IOperator> Operators {
    135       get { return operators.Cast<IOperator>(); }
    136     }
    13780    private BestKnapsackSolutionAnalyzer BestKnapsackSolutionAnalyzer {
    138       get { return operators.OfType<BestKnapsackSolutionAnalyzer>().FirstOrDefault(); }
    139     }
    140     #endregion
    141 
    142     [Storable]
    143     private List<IOperator> operators;
     81      get { return Operators.OfType<BestKnapsackSolutionAnalyzer>().FirstOrDefault(); }
     82    }
     83    #endregion
     84
     85    // BackwardsCompatibility3.3
     86    #region Backwards compatible code, remove with 3.4
     87    [Obsolete]
     88    [Storable(Name = "operators")]
     89    private IEnumerable<IOperator> oldOperators {
     90      get { return null; }
     91      set {
     92        if (value != null && value.Any())
     93          Operators.AddRange(value);
     94      }
     95    }
     96    #endregion
    14497
    14598    [StorableConstructor]
     
    147100    private KnapsackProblem(KnapsackProblem original, Cloner cloner)
    148101      : base(original, cloner) {
    149       this.operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
    150102      AttachEventHandlers();
    151103    }
     
    154106    }
    155107    public KnapsackProblem()
    156       : base() {
    157       RandomBinaryVectorCreator creator = new RandomBinaryVectorCreator();
    158       KnapsackEvaluator evaluator = new KnapsackEvaluator();
    159 
    160       Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to true as the Knapsack Problem is a maximization problem.", new BoolValue(true)));
     108      : base(new KnapsackEvaluator(), new RandomBinaryVectorCreator()) {
    161109      Parameters.Add(new ValueParameter<IntValue>("KnapsackCapacity", "Capacity of the Knapsack.", new IntValue(0)));
    162110      Parameters.Add(new ValueParameter<IntArray>("Weights", "The weights of the items.", new IntArray(5)));
    163111      Parameters.Add(new ValueParameter<IntArray>("Values", "The values of the items.", new IntArray(5)));
    164112      Parameters.Add(new ValueParameter<DoubleValue>("Penalty", "The penalty value for each unit of overweight.", new DoubleValue(1)));
    165       Parameters.Add(new ValueParameter<IBinaryVectorCreator>("SolutionCreator", "The operator which should be used to create new Knapsack solutions.", creator));
    166       Parameters.Add(new ValueParameter<IKnapsackEvaluator>("Evaluator", "The operator which should be used to evaluate Knapsack solutions.", evaluator));
    167       Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this Knapsack instance."));
    168113      Parameters.Add(new OptionalValueParameter<BinaryVector>("BestKnownSolution", "The best known solution of this Knapsack instance."));
    169114
    170       creator.BinaryVectorParameter.ActualName = "KnapsackSolution";
     115      Maximization.Value = true;
     116
     117      SolutionCreator.BinaryVectorParameter.ActualName = "KnapsackSolution";
    171118
    172119      InitializeRandomKnapsackInstance();
     
    180127
    181128    #region Events
    182     public event EventHandler SolutionCreatorChanged;
    183     private void OnSolutionCreatorChanged() {
    184       EventHandler handler = SolutionCreatorChanged;
    185       if (handler != null) handler(this, EventArgs.Empty);
    186     }
    187     public event EventHandler EvaluatorChanged;
    188     private void OnEvaluatorChanged() {
    189       EventHandler handler = EvaluatorChanged;
    190       if (handler != null) handler(this, EventArgs.Empty);
    191     }
    192     public event EventHandler OperatorsChanged;
    193     private void OnOperatorsChanged() {
    194       EventHandler handler = OperatorsChanged;
    195       if (handler != null) handler(this, EventArgs.Empty);
    196     }
    197     public event EventHandler Reset;
    198     private void OnReset() {
    199       EventHandler handler = Reset;
    200       if (handler != null) handler(this, EventArgs.Empty);
    201     }
    202 
    203     private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
     129    protected override void OnSolutionCreatorChanged() {
     130      base.OnSolutionCreatorChanged();
    204131      SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_BinaryVectorParameter_ActualNameChanged);
    205132      ParameterizeSolutionCreator();
     
    207134      ParameterizeAnalyzer();
    208135      ParameterizeOperators();
    209       OnSolutionCreatorChanged();
     136    }
     137    protected override void OnEvaluatorChanged() {
     138      base.OnEvaluatorChanged();
     139      ParameterizeEvaluator();
     140      ParameterizeAnalyzer();
    210141    }
    211142    private void SolutionCreator_BinaryVectorParameter_ActualNameChanged(object sender, EventArgs e) {
     
    214145      ParameterizeOperators();
    215146    }
    216     private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
    217       ParameterizeEvaluator();
    218       ParameterizeAnalyzer();
    219       OnEvaluatorChanged();
    220     }
    221     void KnapsackCapacityParameter_ValueChanged(object sender, EventArgs e) {
    222       ParameterizeEvaluator();
    223       ParameterizeAnalyzer();
    224     }
    225     void WeightsParameter_ValueChanged(object sender, EventArgs e) {
     147    private void KnapsackCapacityParameter_ValueChanged(object sender, EventArgs e) {
     148      ParameterizeEvaluator();
     149      ParameterizeAnalyzer();
     150    }
     151    private void WeightsParameter_ValueChanged(object sender, EventArgs e) {
    226152      ParameterizeEvaluator();
    227153      ParameterizeAnalyzer();
     
    230156      WeightsParameter.Value.Reset += new EventHandler(WeightsValue_Reset);
    231157    }
    232     void WeightsValue_Reset(object sender, EventArgs e) {
     158    private void WeightsValue_Reset(object sender, EventArgs e) {
    233159      ParameterizeSolutionCreator();
    234160
     
    236162        ((IStringConvertibleArray)ValuesParameter.Value).Length = WeightsParameter.Value.Length;
    237163    }
    238     void ValuesParameter_ValueChanged(object sender, EventArgs e) {
     164    private void ValuesParameter_ValueChanged(object sender, EventArgs e) {
    239165      ParameterizeEvaluator();
    240166      ParameterizeAnalyzer();
     
    243169      ValuesParameter.Value.Reset += new EventHandler(ValuesValue_Reset);
    244170    }
    245     void ValuesValue_Reset(object sender, EventArgs e) {
     171    private void ValuesValue_Reset(object sender, EventArgs e) {
    246172      ParameterizeSolutionCreator();
    247173
     
    249175        ((IStringConvertibleArray)WeightsParameter.Value).Length = ValuesParameter.Value.Length;
    250176    }
    251     void PenaltyParameter_ValueChanged(object sender, EventArgs e) {
    252       ParameterizeEvaluator();
    253     }
    254     void OneBitflipMoveParameter_ActualNameChanged(object sender, EventArgs e) {
     177    private void PenaltyParameter_ValueChanged(object sender, EventArgs e) {
     178      ParameterizeEvaluator();
     179    }
     180    private void OneBitflipMoveParameter_ActualNameChanged(object sender, EventArgs e) {
    255181      string name = ((ILookupParameter<OneBitflipMove>)sender).ActualName;
    256182      foreach (IOneBitflipMoveOperator op in Operators.OfType<IOneBitflipMoveOperator>()) {
     
    265191      // BackwardsCompatibility3.3
    266192      #region Backwards compatible code (remove with 3.4)
    267       if (operators == null) InitializeOperators();
     193      if (Operators.Count > 0) InitializeOperators();
    268194      #endregion
    269195      AttachEventHandlers();
     
    271197
    272198    private void AttachEventHandlers() {
    273       SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    274199      SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_BinaryVectorParameter_ActualNameChanged);
    275       EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
    276200      KnapsackCapacityParameter.ValueChanged += new EventHandler(KnapsackCapacityParameter_ValueChanged);
    277201      WeightsParameter.ValueChanged += new EventHandler(WeightsParameter_ValueChanged);
     
    319243    }
    320244    private void InitializeOperators() {
    321       operators = new List<IOperator>();
    322       operators.Add(new BestKnapsackSolutionAnalyzer());
     245      Operators.Add(new BestKnapsackSolutionAnalyzer());
    323246      ParameterizeAnalyzer();
    324247      foreach (IBinaryVectorOperator op in ApplicationManager.Manager.GetInstances<IBinaryVectorOperator>()) {
    325248        if (!(op is ISingleObjectiveMoveEvaluator) || (op is IKnapsackMoveEvaluator)) {
    326           operators.Add(op);
     249          Operators.Add(op);
    327250        }
    328251      }
  • trunk/sources/HeuristicLab.Problems.OneMax/3.3/OnemaxProblem.cs

    r6042 r6938  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Drawing;
    2524using System.Linq;
    2625using HeuristicLab.Common;
     
    3736  [Creatable("Problems")]
    3837  [StorableClass]
    39   public sealed class OneMaxProblem : ParameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent {
     38  public sealed class OneMaxProblem : SingleObjectiveHeuristicOptimizationProblem<IOneMaxEvaluator, IBinaryVectorCreator>, IStorableContent {
    4039    public string Filename { get; set; }
    4140
    42     public override Image ItemImage {
    43       get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
    44     }
    45 
    4641    #region Parameter Properties
    47     public ValueParameter<BoolValue> MaximizationParameter {
    48       get { return (ValueParameter<BoolValue>)Parameters["Maximization"]; }
    49     }
    50     IParameter ISingleObjectiveHeuristicOptimizationProblem.MaximizationParameter {
    51       get { return MaximizationParameter; }
    52     }
    5342    public ValueParameter<IntValue> LengthParameter {
    5443      get { return (ValueParameter<IntValue>)Parameters["Length"]; }
    55     }
    56     public ValueParameter<IBinaryVectorCreator> SolutionCreatorParameter {
    57       get { return (ValueParameter<IBinaryVectorCreator>)Parameters["SolutionCreator"]; }
    58     }
    59     IParameter IHeuristicOptimizationProblem.SolutionCreatorParameter {
    60       get { return SolutionCreatorParameter; }
    61     }
    62     public ValueParameter<IOneMaxEvaluator> EvaluatorParameter {
    63       get { return (ValueParameter<IOneMaxEvaluator>)Parameters["Evaluator"]; }
    64     }
    65     IParameter IHeuristicOptimizationProblem.EvaluatorParameter {
    66       get { return EvaluatorParameter; }
    67     }
    68     public ValueParameter<DoubleValue> BestKnownQualityParameter {
    69       get { return (ValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
    70     }
    71     IParameter ISingleObjectiveHeuristicOptimizationProblem.BestKnownQualityParameter {
    72       get { return BestKnownQualityParameter; }
    7344    }
    7445    #endregion
     
    7950      set { LengthParameter.Value = value; }
    8051    }
    81     public IBinaryVectorCreator SolutionCreator {
    82       get { return SolutionCreatorParameter.Value; }
    83       set { SolutionCreatorParameter.Value = value; }
    84     }
    85     ISolutionCreator IHeuristicOptimizationProblem.SolutionCreator {
    86       get { return SolutionCreatorParameter.Value; }
    87     }
    88     public IOneMaxEvaluator Evaluator {
    89       get { return EvaluatorParameter.Value; }
    90       set { EvaluatorParameter.Value = value; }
    91     }
    92     ISingleObjectiveEvaluator ISingleObjectiveHeuristicOptimizationProblem.Evaluator {
    93       get { return EvaluatorParameter.Value; }
    94     }
    95     IEvaluator IHeuristicOptimizationProblem.Evaluator {
    96       get { return EvaluatorParameter.Value; }
    97     }
    98     public DoubleValue BestKnownQuality {
    99       get { return BestKnownQualityParameter.Value; }
    100     }
    101     public IEnumerable<IOperator> Operators {
    102       get { return operators.Cast<IOperator>(); }
    103     }
    10452    private BestOneMaxSolutionAnalyzer BestOneMaxSolutionAnalyzer {
    105       get { return operators.OfType<BestOneMaxSolutionAnalyzer>().FirstOrDefault(); }
     53      get { return Operators.OfType<BestOneMaxSolutionAnalyzer>().FirstOrDefault(); }
    10654    }
    10755    #endregion
    10856
    109     [Storable]
    110     private List<IOperator> operators;
     57    // BackwardsCompatibility3.3
     58    #region Backwards compatible code, remove with 3.4
     59    [Obsolete]
     60    [Storable(Name = "operators")]
     61    private IEnumerable<IOperator> oldOperators {
     62      get { return null; }
     63      set {
     64        if (value != null && value.Any())
     65          Operators.AddRange(value);
     66      }
     67    }
     68    #endregion
    11169
    11270    [StorableConstructor]
     
    11472    private OneMaxProblem(OneMaxProblem original, Cloner cloner)
    11573      : base(original, cloner) {
    116       operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
    11774      AttachEventHandlers();
    11875    }
    11976    public OneMaxProblem()
    120       : base() {
    121       RandomBinaryVectorCreator creator = new RandomBinaryVectorCreator();
    122       OneMaxEvaluator evaluator = new OneMaxEvaluator();
     77      : base(new OneMaxEvaluator(), new RandomBinaryVectorCreator()) {
     78      Parameters.Add(new ValueParameter<IntValue>("Length", "The length of the BinaryVector.", new IntValue(5)));
     79      BestKnownQuality.Value = 5;
    12380
    124       Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to true as the OneMax Problem is a maximization problem.", new BoolValue(true)));
    125       Parameters.Add(new ValueParameter<IntValue>("Length", "The length of the BinaryVector.", new IntValue(5)));
    126       Parameters.Add(new ValueParameter<IBinaryVectorCreator>("SolutionCreator", "The operator which should be used to create new OneMax solutions.", creator));
    127       Parameters.Add(new ValueParameter<IOneMaxEvaluator>("Evaluator", "The operator which should be used to evaluate OneMax solutions.", evaluator));
    128       Parameters.Add(new ValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this OneMax instance.", new DoubleValue(5)));
    129 
    130       creator.BinaryVectorParameter.ActualName = "OneMaxSolution";
    131       evaluator.QualityParameter.ActualName = "NumberOfOnes";
     81      SolutionCreator.BinaryVectorParameter.ActualName = "OneMaxSolution";
     82      Evaluator.QualityParameter.ActualName = "NumberOfOnes";
    13283      ParameterizeSolutionCreator();
    13384      ParameterizeEvaluator();
     
    14293
    14394    #region Events
    144     public event EventHandler SolutionCreatorChanged;
    145     private void OnSolutionCreatorChanged() {
    146       EventHandler handler = SolutionCreatorChanged;
    147       if (handler != null) handler(this, EventArgs.Empty);
    148     }
    149     public event EventHandler EvaluatorChanged;
    150     private void OnEvaluatorChanged() {
    151       EventHandler handler = EvaluatorChanged;
    152       if (handler != null) handler(this, EventArgs.Empty);
    153     }
    154     public event EventHandler OperatorsChanged;
    155     private void OnOperatorsChanged() {
    156       EventHandler handler = OperatorsChanged;
    157       if (handler != null) handler(this, EventArgs.Empty);
    158     }
    159     public event EventHandler Reset;
    160     private void OnReset() {
    161       EventHandler handler = Reset;
    162       if (handler != null) handler(this, EventArgs.Empty);
    163     }
    164 
    165     private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
     95    protected override void OnSolutionCreatorChanged() {
     96      base.OnSolutionCreatorChanged();
    16697      SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_BinaryVectorParameter_ActualNameChanged);
    16798      ParameterizeSolutionCreator();
     
    169100      ParameterizeAnalyzer();
    170101      ParameterizeOperators();
    171       OnSolutionCreatorChanged();
     102    }
     103    protected override void OnEvaluatorChanged() {
     104      base.OnEvaluatorChanged();
     105      ParameterizeEvaluator();
     106      ParameterizeAnalyzer();
    172107    }
    173108    private void SolutionCreator_BinaryVectorParameter_ActualNameChanged(object sender, EventArgs e) {
     
    176111      ParameterizeOperators();
    177112    }
    178     private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
    179       ParameterizeEvaluator();
    180       ParameterizeAnalyzer();
    181       OnEvaluatorChanged();
    182     }
    183     void LengthParameter_ValueChanged(object sender, EventArgs e) {
     113    private void LengthParameter_ValueChanged(object sender, EventArgs e) {
    184114      ParameterizeSolutionCreator();
    185115      LengthParameter.Value.ValueChanged += new EventHandler(Length_ValueChanged);
    186116      BestKnownQualityParameter.Value.Value = Length.Value;
    187117    }
    188     void Length_ValueChanged(object sender, EventArgs e) {
     118    private void Length_ValueChanged(object sender, EventArgs e) {
    189119      BestKnownQualityParameter.Value.Value = Length.Value;
    190120    }
    191     void BestKnownQualityParameter_ValueChanged(object sender, EventArgs e) {
     121    private void BestKnownQualityParameter_ValueChanged(object sender, EventArgs e) {
    192122      BestKnownQualityParameter.Value.Value = Length.Value;
    193123    }
    194     void OneBitflipMoveParameter_ActualNameChanged(object sender, EventArgs e) {
     124    private void OneBitflipMoveParameter_ActualNameChanged(object sender, EventArgs e) {
    195125      string name = ((ILookupParameter<OneBitflipMove>)sender).ActualName;
    196126      foreach (IOneBitflipMoveOperator op in Operators.OfType<IOneBitflipMoveOperator>()) {
     
    205135      // BackwardsCompatibility3.3
    206136      #region Backwards compatible code (remove with 3.4)
    207       if (operators == null) InitializeOperators();
     137      if (Operators.Count == 0) InitializeOperators();
    208138      #endregion
    209139      AttachEventHandlers();
     
    211141
    212142    private void AttachEventHandlers() {
    213       SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    214143      SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_BinaryVectorParameter_ActualNameChanged);
    215       EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
    216144      LengthParameter.ValueChanged += new EventHandler(LengthParameter_ValueChanged);
    217145      LengthParameter.Value.ValueChanged += new EventHandler(Length_ValueChanged);
     
    233161    }
    234162    private void InitializeOperators() {
    235       operators = new List<IOperator>();
    236       operators.Add(new BestOneMaxSolutionAnalyzer());
     163      Operators.Add(new BestOneMaxSolutionAnalyzer());
    237164      ParameterizeAnalyzer();
    238165      foreach (IBinaryVectorOperator op in ApplicationManager.Manager.GetInstances<IBinaryVectorOperator>()) {
    239166        if (!(op is ISingleObjectiveMoveEvaluator) || (op is IOneMaxMoveEvaluator)) {
    240           operators.Add(op);
     167          Operators.Add(op);
    241168        }
    242169      }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs

    r6051 r6938  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Drawing;
    2524using System.Linq;
    2625using HeuristicLab.Common;
     
    3736  [StorableClass]
    3837  [Creatable("Problems")]
    39   public sealed class SingleObjectiveTestFunctionProblem : ParameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent {
     38  public sealed class SingleObjectiveTestFunctionProblem : SingleObjectiveHeuristicOptimizationProblem<ISingleObjectiveTestFunctionProblemEvaluator, IRealVectorCreator>, IStorableContent {
    4039    public string Filename { get; set; }
    4140
     
    4746    private StdDevStrategyVectorManipulator strategyVectorManipulator;
    4847
    49     public override Image ItemImage {
    50       get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
    51     }
    52 
    5348    #region Parameter Properties
    54     public ValueParameter<BoolValue> MaximizationParameter {
    55       get { return (ValueParameter<BoolValue>)Parameters["Maximization"]; }
    56     }
    57     IParameter ISingleObjectiveHeuristicOptimizationProblem.MaximizationParameter {
    58       get { return MaximizationParameter; }
    59     }
    6049    public ValueParameter<DoubleMatrix> BoundsParameter {
    6150      get { return (ValueParameter<DoubleMatrix>)Parameters["Bounds"]; }
     
    6453      get { return (ValueParameter<IntValue>)Parameters["ProblemSize"]; }
    6554    }
    66     public ValueParameter<IRealVectorCreator> SolutionCreatorParameter {
    67       get { return (ValueParameter<IRealVectorCreator>)Parameters["SolutionCreator"]; }
    68     }
    69     IParameter IHeuristicOptimizationProblem.SolutionCreatorParameter {
    70       get { return SolutionCreatorParameter; }
    71     }
    72     public ValueParameter<ISingleObjectiveTestFunctionProblemEvaluator> EvaluatorParameter {
    73       get { return (ValueParameter<ISingleObjectiveTestFunctionProblemEvaluator>)Parameters["Evaluator"]; }
    74     }
    75     IParameter IHeuristicOptimizationProblem.EvaluatorParameter {
    76       get { return EvaluatorParameter; }
    77     }
    78     public OptionalValueParameter<DoubleValue> BestKnownQualityParameter {
    79       get { return (OptionalValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
    80     }
    81     IParameter ISingleObjectiveHeuristicOptimizationProblem.BestKnownQualityParameter {
    82       get { return BestKnownQualityParameter; }
    83     }
    8455    public OptionalValueParameter<RealVector> BestKnownSolutionParameter {
    8556      get { return (OptionalValueParameter<RealVector>)Parameters["BestKnownSolution"]; }
     
    8859
    8960    #region Properties
    90     public BoolValue Maximization {
    91       get { return MaximizationParameter.Value; }
    92       set { MaximizationParameter.Value = value; }
    93     }
    9461    public DoubleMatrix Bounds {
    9562      get { return BoundsParameter.Value; }
     
    10067      set { ProblemSizeParameter.Value = value; }
    10168    }
    102     public IRealVectorCreator SolutionCreator {
    103       get { return SolutionCreatorParameter.Value; }
    104       set { SolutionCreatorParameter.Value = value; }
    105     }
    106     ISolutionCreator IHeuristicOptimizationProblem.SolutionCreator {
    107       get { return SolutionCreatorParameter.Value; }
    108     }
    109     public ISingleObjectiveTestFunctionProblemEvaluator Evaluator {
    110       get { return EvaluatorParameter.Value; }
    111       set { EvaluatorParameter.Value = value; }
    112     }
    113     ISingleObjectiveEvaluator ISingleObjectiveHeuristicOptimizationProblem.Evaluator {
    114       get { return EvaluatorParameter.Value; }
    115     }
    116     IEvaluator IHeuristicOptimizationProblem.Evaluator {
    117       get { return EvaluatorParameter.Value; }
    118     }
    119     public DoubleValue BestKnownQuality {
    120       get { return BestKnownQualityParameter.Value; }
    121       set { BestKnownQualityParameter.Value = value; }
    122     }
    123     public IEnumerable<IOperator> Operators {
    124       get { return operators; }
    125     }
    12669    private BestSingleObjectiveTestFunctionSolutionAnalyzer BestSingleObjectiveTestFunctionSolutionAnalyzer {
    127       get { return operators.OfType<BestSingleObjectiveTestFunctionSolutionAnalyzer>().FirstOrDefault(); }
    128     }
    129     #endregion
    130 
    131     [Storable]
    132     private List<IOperator> operators;
     70      get { return Operators.OfType<BestSingleObjectiveTestFunctionSolutionAnalyzer>().FirstOrDefault(); }
     71    }
     72    #endregion
     73
     74    // BackwardsCompatibility3.3
     75    #region Backwards compatible code, remove with 3.4
     76    [Obsolete]
     77    [Storable(Name = "operators")]
     78    private IEnumerable<IOperator> oldOperators {
     79      get { return null; }
     80      set {
     81        if (value != null && value.Any())
     82          Operators.AddRange(value);
     83      }
     84    }
     85    #endregion
    13386
    13487    [StorableConstructor]
     
    13689    private SingleObjectiveTestFunctionProblem(SingleObjectiveTestFunctionProblem original, Cloner cloner)
    13790      : base(original, cloner) {
    138       operators = original.operators.Where(x => original.IsNotFieldReferenced(x)).Select(x => cloner.Clone(x)).ToList();
    13991      strategyVectorCreator = cloner.Clone(original.strategyVectorCreator);
    140       operators.Add(strategyVectorCreator);
    14192      strategyVectorCrossover = cloner.Clone(original.strategyVectorCrossover);
    142       operators.Add(strategyVectorCrossover);
    14393      strategyVectorManipulator = cloner.Clone(original.strategyVectorManipulator);
    144       operators.Add(strategyVectorManipulator);
    14594      AttachEventHandlers();
    14695    }
    14796    public SingleObjectiveTestFunctionProblem()
    148       : base() {
    149       UniformRandomRealVectorCreator creator = new UniformRandomRealVectorCreator();
    150       AckleyEvaluator evaluator = new AckleyEvaluator();
    151 
    152       Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to false as most test functions are minimization problems.", new BoolValue(evaluator.Maximization)));
    153       Parameters.Add(new ValueParameter<DoubleMatrix>("Bounds", "The lower and upper bounds in each dimension.", evaluator.Bounds));
     97      : base(new AckleyEvaluator(), new UniformRandomRealVectorCreator()) {
     98      Parameters.Add(new ValueParameter<DoubleMatrix>("Bounds", "The lower and upper bounds in each dimension.", Evaluator.Bounds));
    15499      Parameters.Add(new ValueParameter<IntValue>("ProblemSize", "The dimension of the problem.", new IntValue(2)));
    155       Parameters.Add(new ValueParameter<IRealVectorCreator>("SolutionCreator", "The operator which should be used to create new test function solutions.", creator));
    156       Parameters.Add(new ValueParameter<ISingleObjectiveTestFunctionProblemEvaluator>("Evaluator", "The operator which should be used to evaluate test function solutions.", evaluator));
    157       Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this test function.", new DoubleValue(evaluator.BestKnownQuality)));
    158100      Parameters.Add(new OptionalValueParameter<RealVector>("BestKnownSolution", "The best known solution for this test function instance."));
    159101
     
    165107      strategyVectorManipulator.GeneralLearningRateParameter.Value = new DoubleValue(0.5);
    166108
    167       creator.RealVectorParameter.ActualName = "Point";
     109      SolutionCreator.RealVectorParameter.ActualName = "Point";
    168110      ParameterizeSolutionCreator();
    169111      ParameterizeEvaluator();
     
    185127
    186128    #region Events
    187     public event EventHandler SolutionCreatorChanged;
    188     private void OnSolutionCreatorChanged() {
    189       EventHandler handler = SolutionCreatorChanged;
    190       if (handler != null) handler(this, EventArgs.Empty);
    191     }
    192     public event EventHandler EvaluatorChanged;
    193     private void OnEvaluatorChanged() {
    194       EventHandler handler = EvaluatorChanged;
    195       if (handler != null) handler(this, EventArgs.Empty);
    196     }
    197     public event EventHandler OperatorsChanged;
    198     private void OnOperatorsChanged() {
    199       EventHandler handler = OperatorsChanged;
    200       if (handler != null) handler(this, EventArgs.Empty);
    201     }
    202     public event EventHandler Reset;
    203     private void OnReset() {
    204       EventHandler handler = Reset;
    205       if (handler != null) handler(this, EventArgs.Empty);
    206     }
    207 
    208     private void ProblemSizeParameter_ValueChanged(object sender, EventArgs e) {
    209       ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged);
    210       ProblemSize_ValueChanged(null, EventArgs.Empty);
    211     }
    212     private void ProblemSize_ValueChanged(object sender, EventArgs e) {
    213       if (ProblemSize.Value < 1) ProblemSize.Value = 1;
    214       ParameterizeSolutionCreator();
    215       ParameterizeEvaluator();
    216       strategyVectorManipulator.GeneralLearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * ProblemSize.Value));
    217       strategyVectorManipulator.LearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * Math.Sqrt(ProblemSize.Value)));
    218       OnReset();
    219     }
    220     private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
     129    protected override void OnSolutionCreatorChanged() {
     130      base.OnSolutionCreatorChanged();
    221131      ParameterizeSolutionCreator();
    222132      ParameterizeAnalyzers();
     133      SolutionCreator.RealVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_RealVectorParameter_ActualNameChanged);
    223134      SolutionCreator_RealVectorParameter_ActualNameChanged(null, EventArgs.Empty);
    224       OnSolutionCreatorChanged();
    225     }
    226     private void SolutionCreator_RealVectorParameter_ActualNameChanged(object sender, EventArgs e) {
    227       ParameterizeEvaluator();
    228       ParameterizeOperators();
    229       ParameterizeAnalyzers();
    230     }
    231     private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
     135    }
     136    protected override void OnEvaluatorChanged() {
     137      base.OnEvaluatorChanged();
    232138      ParameterizeEvaluator();
    233139      UpdateMoveEvaluators();
     
    242148      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    243149      Evaluator_QualityParameter_ActualNameChanged(null, EventArgs.Empty);
    244       OnEvaluatorChanged();
    245150      OnReset();
     151    }
     152    private void ProblemSizeParameter_ValueChanged(object sender, EventArgs e) {
     153      ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged);
     154      ProblemSize_ValueChanged(null, EventArgs.Empty);
     155    }
     156    private void ProblemSize_ValueChanged(object sender, EventArgs e) {
     157      if (ProblemSize.Value < 1) ProblemSize.Value = 1;
     158      ParameterizeSolutionCreator();
     159      ParameterizeEvaluator();
     160      strategyVectorManipulator.GeneralLearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * ProblemSize.Value));
     161      strategyVectorManipulator.LearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * Math.Sqrt(ProblemSize.Value)));
     162      OnReset();
     163    }
     164    private void SolutionCreator_RealVectorParameter_ActualNameChanged(object sender, EventArgs e) {
     165      ParameterizeEvaluator();
     166      ParameterizeOperators();
     167      ParameterizeAnalyzers();
    246168    }
    247169    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
     
    305227      // BackwardsCompatibility3.3
    306228      #region Backwards compatible code (remove with 3.4)
    307       if (operators == null) InitializeOperators();
     229      if (Operators.Count == 0) InitializeOperators();
    308230      #endregion
    309231      AttachEventHandlers();
     
    316238      Bounds.ToStringChanged += new EventHandler(Bounds_ToStringChanged);
    317239      Bounds.ItemChanged += new EventHandler<EventArgs<int, int>>(Bounds_ItemChanged);
    318       SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    319240      SolutionCreator.RealVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_RealVectorParameter_ActualNameChanged);
    320       EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
    321241      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    322242      strategyVectorCreator.BoundsParameter.ValueChanged += new EventHandler(strategyVectorCreator_BoundsParameter_ValueChanged);
     
    334254    }
    335255    private void InitializeOperators() {
    336       operators = new List<IOperator>();
    337       operators.Add(new BestSingleObjectiveTestFunctionSolutionAnalyzer());
     256      Operators.Add(new BestSingleObjectiveTestFunctionSolutionAnalyzer());
    338257      ParameterizeAnalyzers();
    339       operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>().Cast<IOperator>());
    340       operators.Add(strategyVectorCreator);
    341       operators.Add(strategyVectorCrossover);
    342       operators.Add(strategyVectorManipulator);
     258      Operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>().Cast<IOperator>());
     259      Operators.Add(strategyVectorCreator);
     260      Operators.Add(strategyVectorCrossover);
     261      Operators.Add(strategyVectorManipulator);
    343262      UpdateMoveEvaluators();
    344263      ParameterizeOperators();
     
    354273    private void UpdateMoveEvaluators() {
    355274      foreach (ISingleObjectiveTestFunctionMoveEvaluator op in Operators.OfType<ISingleObjectiveTestFunctionMoveEvaluator>().ToList())
    356         operators.Remove(op);
     275        Operators.Remove(op);
    357276      foreach (ISingleObjectiveTestFunctionMoveEvaluator op in ApplicationManager.Manager.GetInstances<ISingleObjectiveTestFunctionMoveEvaluator>())
    358277        if (op.EvaluatorType == Evaluator.GetType()) {
    359           operators.Add(op);
     278          Operators.Add(op);
    360279          #region Synchronize evaluator specific parameters with the parameters of the corresponding move evaluators
    361280          if (op is ISphereMoveEvaluator) {
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman.Views/3.3/Plugin.cs.frame

    r6866 r6938  
    3636  [PluginDependency("HeuristicLab.MainForm", "3.3")]
    3737  [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
     38  [PluginDependency("HeuristicLab.Optimization", "3.3")]
    3839  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    3940  [PluginDependency("HeuristicLab.Problems.TravelingSalesman", "3.3")]
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs

    r6051 r6938  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Drawing;
    2524using System.IO;
    2625using System.Linq;
     
    3837  [Creatable("Problems")]
    3938  [StorableClass]
    40   public sealed class TravelingSalesmanProblem : ParameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent {
     39  public sealed class TravelingSalesmanProblem : SingleObjectiveHeuristicOptimizationProblem<ITSPEvaluator, IPermutationCreator>, IStorableContent {
    4140    public string Filename { get; set; }
    4241
    43     public override Image ItemImage {
    44       get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
    45     }
    46 
    4742    #region Parameter Properties
    48     public ValueParameter<BoolValue> MaximizationParameter {
    49       get { return (ValueParameter<BoolValue>)Parameters["Maximization"]; }
    50     }
    51     IParameter ISingleObjectiveHeuristicOptimizationProblem.MaximizationParameter {
    52       get { return MaximizationParameter; }
    53     }
    5443    public ValueParameter<DoubleMatrix> CoordinatesParameter {
    5544      get { return (ValueParameter<DoubleMatrix>)Parameters["Coordinates"]; }
     
    6049    public ValueParameter<BoolValue> UseDistanceMatrixParameter {
    6150      get { return (ValueParameter<BoolValue>)Parameters["UseDistanceMatrix"]; }
    62     }
    63     public ValueParameter<IPermutationCreator> SolutionCreatorParameter {
    64       get { return (ValueParameter<IPermutationCreator>)Parameters["SolutionCreator"]; }
    65     }
    66     IParameter IHeuristicOptimizationProblem.SolutionCreatorParameter {
    67       get { return SolutionCreatorParameter; }
    68     }
    69     public ValueParameter<ITSPEvaluator> EvaluatorParameter {
    70       get { return (ValueParameter<ITSPEvaluator>)Parameters["Evaluator"]; }
    71     }
    72     IParameter IHeuristicOptimizationProblem.EvaluatorParameter {
    73       get { return EvaluatorParameter; }
    74     }
    75     public OptionalValueParameter<DoubleValue> BestKnownQualityParameter {
    76       get { return (OptionalValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
    77     }
    78     IParameter ISingleObjectiveHeuristicOptimizationProblem.BestKnownQualityParameter {
    79       get { return BestKnownQualityParameter; }
    8051    }
    8152    public OptionalValueParameter<Permutation> BestKnownSolutionParameter {
     
    9768      set { UseDistanceMatrixParameter.Value = value; }
    9869    }
    99     public IPermutationCreator SolutionCreator {
    100       get { return SolutionCreatorParameter.Value; }
    101       set { SolutionCreatorParameter.Value = value; }
    102     }
    103     ISolutionCreator IHeuristicOptimizationProblem.SolutionCreator {
    104       get { return SolutionCreatorParameter.Value; }
    105     }
    106     public ITSPEvaluator Evaluator {
    107       get { return EvaluatorParameter.Value; }
    108       set { EvaluatorParameter.Value = value; }
    109     }
    110     ISingleObjectiveEvaluator ISingleObjectiveHeuristicOptimizationProblem.Evaluator {
    111       get { return EvaluatorParameter.Value; }
    112     }
    113     IEvaluator IHeuristicOptimizationProblem.Evaluator {
    114       get { return EvaluatorParameter.Value; }
    115     }
    116     public DoubleValue BestKnownQuality {
    117       get { return BestKnownQualityParameter.Value; }
    118       set { BestKnownQualityParameter.Value = value; }
    119     }
    12070    public Permutation BestKnownSolution {
    12171      get { return BestKnownSolutionParameter.Value; }
    12272      set { BestKnownSolutionParameter.Value = value; }
    12373    }
    124     public IEnumerable<IOperator> Operators {
    125       get { return operators; }
    126     }
    12774    private BestTSPSolutionAnalyzer BestTSPSolutionAnalyzer {
    128       get { return operators.OfType<BestTSPSolutionAnalyzer>().FirstOrDefault(); }
     75      get { return Operators.OfType<BestTSPSolutionAnalyzer>().FirstOrDefault(); }
    12976    }
    13077    private TSPAlleleFrequencyAnalyzer TSPAlleleFrequencyAnalyzer {
    131       get { return operators.OfType<TSPAlleleFrequencyAnalyzer>().FirstOrDefault(); }
     78      get { return Operators.OfType<TSPAlleleFrequencyAnalyzer>().FirstOrDefault(); }
    13279    }
    13380    private TSPPopulationDiversityAnalyzer TSPPopulationDiversityAnalyzer {
    134       get { return operators.OfType<TSPPopulationDiversityAnalyzer>().FirstOrDefault(); }
    135     }
    136     #endregion
    137 
    138     [Storable]
    139     private List<IOperator> operators;
     81      get { return Operators.OfType<TSPPopulationDiversityAnalyzer>().FirstOrDefault(); }
     82    }
     83    #endregion
     84
     85    // BackwardsCompatibility3.3
     86    #region Backwards compatible code, remove with 3.4
     87    [Obsolete]
     88    [Storable(Name = "operators")]
     89    private IEnumerable<IOperator> oldOperators {
     90      get { return null; }
     91      set {
     92        if (value != null && value.Any())
     93          Operators.AddRange(value);
     94      }
     95    }
     96    #endregion
    14097
    14198    [StorableConstructor]
     
    143100    private TravelingSalesmanProblem(TravelingSalesmanProblem original, Cloner cloner)
    144101      : base(original, cloner) {
    145       this.operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
    146102      AttachEventHandlers();
    147103    }
     
    150106    }
    151107    public TravelingSalesmanProblem()
    152       : base() {
    153       RandomPermutationCreator creator = new RandomPermutationCreator();
    154       TSPRoundedEuclideanPathEvaluator evaluator = new TSPRoundedEuclideanPathEvaluator();
    155 
    156       Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to false as the Traveling Salesman Problem is a minimization problem.", new BoolValue(false)));
     108      : base(new TSPRoundedEuclideanPathEvaluator(), new RandomPermutationCreator()) {
     109
    157110      Parameters.Add(new ValueParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the cities."));
    158111      Parameters.Add(new OptionalValueParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));
    159112      Parameters.Add(new ValueParameter<BoolValue>("UseDistanceMatrix", "True if a distance matrix should be calculated and used for evaluation, otherwise false.", new BoolValue(true)));
    160       Parameters.Add(new ValueParameter<IPermutationCreator>("SolutionCreator", "The operator which should be used to create new TSP solutions.", creator));
    161       Parameters.Add(new ValueParameter<ITSPEvaluator>("Evaluator", "The operator which should be used to evaluate TSP solutions.", evaluator));
    162       Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this TSP instance."));
    163113      Parameters.Add(new OptionalValueParameter<Permutation>("BestKnownSolution", "The best known solution of this TSP instance."));
    164114
     
    173123      });
    174124
    175       creator.PermutationParameter.ActualName = "TSPTour";
    176       evaluator.QualityParameter.ActualName = "TSPTourLength";
     125      SolutionCreator.PermutationParameter.ActualName = "TSPTour";
     126      Evaluator.QualityParameter.ActualName = "TSPTourLength";
    177127      ParameterizeSolutionCreator();
    178128      ParameterizeEvaluator();
     
    183133
    184134    #region Events
    185     public event EventHandler SolutionCreatorChanged;
    186     private void OnSolutionCreatorChanged() {
    187       EventHandler handler = SolutionCreatorChanged;
    188       if (handler != null) handler(this, EventArgs.Empty);
    189     }
    190     public event EventHandler EvaluatorChanged;
    191     private void OnEvaluatorChanged() {
    192       EventHandler handler = EvaluatorChanged;
    193       if (handler != null) handler(this, EventArgs.Empty);
    194     }
    195     public event EventHandler OperatorsChanged;
    196     private void OnOperatorsChanged() {
    197       EventHandler handler = OperatorsChanged;
    198       if (handler != null) handler(this, EventArgs.Empty);
    199     }
    200     public event EventHandler Reset;
    201     private void OnReset() {
    202       EventHandler handler = Reset;
    203       if (handler != null) handler(this, EventArgs.Empty);
    204     }
    205 
     135    protected override void OnSolutionCreatorChanged() {
     136      base.OnSolutionCreatorChanged();
     137      SolutionCreator.PermutationParameter.ActualNameChanged += new EventHandler(SolutionCreator_PermutationParameter_ActualNameChanged);
     138      ParameterizeSolutionCreator();
     139      ParameterizeEvaluator();
     140      ParameterizeAnalyzers();
     141      ParameterizeOperators();
     142    }
     143    protected override void OnEvaluatorChanged() {
     144      base.OnEvaluatorChanged();
     145      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
     146      ParameterizeEvaluator();
     147      UpdateMoveEvaluators();
     148      ParameterizeAnalyzers();
     149      ClearDistanceMatrix();
     150    }
    206151    private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
    207152      Coordinates.ItemChanged += new EventHandler<EventArgs<int, int>>(Coordinates_ItemChanged);
     
    217162      ClearDistanceMatrix();
    218163    }
    219     private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
    220       SolutionCreator.PermutationParameter.ActualNameChanged += new EventHandler(SolutionCreator_PermutationParameter_ActualNameChanged);
    221       ParameterizeSolutionCreator();
    222       ParameterizeEvaluator();
    223       ParameterizeAnalyzers();
    224       ParameterizeOperators();
    225       OnSolutionCreatorChanged();
    226     }
    227164    private void SolutionCreator_PermutationParameter_ActualNameChanged(object sender, EventArgs e) {
    228165      ParameterizeEvaluator();
     
    230167      ParameterizeOperators();
    231168    }
    232     private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
    233       Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    234       ParameterizeEvaluator();
    235       UpdateMoveEvaluators();
    236       ParameterizeAnalyzers();
    237       ClearDistanceMatrix();
    238       OnEvaluatorChanged();
    239     }
    240169    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
    241170      ParameterizeAnalyzers();
    242     }
    243     private void MoveGenerator_InversionMoveParameter_ActualNameChanged(object sender, EventArgs e) {
    244       string name = ((ILookupParameter<InversionMove>)sender).ActualName;
    245       foreach (IPermutationInversionMoveOperator op in Operators.OfType<IPermutationInversionMoveOperator>()) {
    246         op.InversionMoveParameter.ActualName = name;
    247       }
    248     }
    249     private void MoveGenerator_TranslocationMoveParameter_ActualNameChanged(object sender, EventArgs e) {
    250       string name = ((ILookupParameter<TranslocationMove>)sender).ActualName;
    251       foreach (IPermutationTranslocationMoveOperator op in Operators.OfType<IPermutationTranslocationMoveOperator>()) {
    252         op.TranslocationMoveParameter.ActualName = name;
    253       }
    254171    }
    255172    #endregion
     
    277194      }
    278195
    279       if (operators == null) InitializeOperators();
     196      if (Operators.Count == 0) InitializeOperators();
    280197      #endregion
    281198      AttachEventHandlers();
     
    286203      Coordinates.ItemChanged += new EventHandler<EventArgs<int, int>>(Coordinates_ItemChanged);
    287204      Coordinates.Reset += new EventHandler(Coordinates_Reset);
    288       SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    289205      SolutionCreator.PermutationParameter.ActualNameChanged += new EventHandler(SolutionCreator_PermutationParameter_ActualNameChanged);
    290       EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
    291206      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    292207    }
    293208
    294209    private void InitializeOperators() {
    295       operators = new List<IOperator>();
    296       operators.Add(new BestTSPSolutionAnalyzer());
    297       operators.Add(new TSPAlleleFrequencyAnalyzer());
    298       operators.Add(new TSPPopulationDiversityAnalyzer());
    299       ParameterizeAnalyzers();
    300       operators.AddRange(ApplicationManager.Manager.GetInstances<IPermutationOperator>().Cast<IOperator>());
     210      Operators.Add(new BestTSPSolutionAnalyzer());
     211      Operators.Add(new TSPAlleleFrequencyAnalyzer());
     212      Operators.Add(new TSPPopulationDiversityAnalyzer());
     213      ParameterizeAnalyzers();
     214      Operators.AddRange(ApplicationManager.Manager.GetInstances<IPermutationOperator>().Cast<IOperator>());
    301215      ParameterizeOperators();
    302216      UpdateMoveEvaluators();
    303       InitializeMoveGenerators();
    304     }
    305     private void InitializeMoveGenerators() {
    306       foreach (IPermutationInversionMoveOperator op in Operators.OfType<IPermutationInversionMoveOperator>()) {
    307         if (op is IMoveGenerator) {
    308           op.InversionMoveParameter.ActualNameChanged += new EventHandler(MoveGenerator_InversionMoveParameter_ActualNameChanged);
    309         }
    310       }
    311       foreach (IPermutationTranslocationMoveOperator op in Operators.OfType<IPermutationTranslocationMoveOperator>()) {
    312         if (op is IMoveGenerator) {
    313           op.TranslocationMoveParameter.ActualNameChanged += new EventHandler(MoveGenerator_TranslocationMoveParameter_ActualNameChanged);
    314         }
    315       }
    316217    }
    317218    private void UpdateMoveEvaluators() {
    318       operators.RemoveAll(x => x is ISingleObjectiveMoveEvaluator);
     219      Operators.RemoveAll(x => x is ISingleObjectiveMoveEvaluator);
    319220      foreach (ITSPPathMoveEvaluator op in ApplicationManager.Manager.GetInstances<ITSPPathMoveEvaluator>())
    320221        if (op.EvaluatorType == Evaluator.GetType()) {
    321           operators.Add(op);
     222          Operators.Add(op);
    322223        }
    323224      ParameterizeOperators();
     
    400301        op.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
    401302        op.PermutationParameter.Hidden = true;
    402       }
    403       string inversionMove = Operators.OfType<IMoveGenerator>().OfType<IPermutationInversionMoveOperator>().First().InversionMoveParameter.ActualName;
    404       foreach (IPermutationInversionMoveOperator op in Operators.OfType<IPermutationInversionMoveOperator>()) {
    405         op.InversionMoveParameter.ActualName = inversionMove;
    406         op.InversionMoveParameter.Hidden = true;
    407       }
    408       string translocationMove = Operators.OfType<IMoveGenerator>().OfType<IPermutationTranslocationMoveOperator>().First().TranslocationMoveParameter.ActualName;
    409       foreach (IPermutationTranslocationMoveOperator op in Operators.OfType<IPermutationTranslocationMoveOperator>()) {
    410         op.TranslocationMoveParameter.ActualName = translocationMove;
    411         op.TranslocationMoveParameter.Hidden = true;
    412303      }
    413304      foreach (IPermutationMultiNeighborhoodShakingOperator op in Operators.OfType<IPermutationMultiNeighborhoodShakingOperator>()) {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/Plugin.cs.frame

    r6866 r6938  
    3434  [PluginDependency("HeuristicLab.MainForm", "3.3")]
    3535  [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
     36  [PluginDependency("HeuristicLab.Optimization", "3.3")]
    3637  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    3738  [PluginDependency("HeuristicLab.Problems.VehicleRouting", "3.3")]
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs

    r6441 r6938  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Drawing;
    2524using System.Linq;
    2625using HeuristicLab.Common;
    2726using HeuristicLab.Core;
    2827using HeuristicLab.Data;
    29 using HeuristicLab.Encodings.PermutationEncoding;
    3028using HeuristicLab.Optimization;
    3129using HeuristicLab.Parameters;
     
    4038  [Creatable("Problems")]
    4139  [StorableClass]
    42   public sealed class VehicleRoutingProblem : ParameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent {
     40  public sealed class VehicleRoutingProblem : SingleObjectiveHeuristicOptimizationProblem<IVRPEvaluator, IVRPCreator>, IStorableContent {
    4341    public string Filename { get; set; }
    4442
    45     public override Image ItemImage {
    46       get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
    47     }
    48 
    4943    #region Parameter Properties
    50     public ValueParameter<BoolValue> MaximizationParameter {
    51       get { return (ValueParameter<BoolValue>)Parameters["Maximization"]; }
    52     }
    53     IParameter ISingleObjectiveHeuristicOptimizationProblem.MaximizationParameter {
    54       get { return MaximizationParameter; }
    55     }
    5644    public ValueParameter<DoubleMatrix> CoordinatesParameter {
    5745      get { return (ValueParameter<DoubleMatrix>)Parameters["Coordinates"]; }
     
    8169      get { return (ValueParameter<DoubleArray>)Parameters["ServiceTime"]; }
    8270    }
    83     ValueParameter<IVRPCreator> SolutionCreatorParameter {
    84       get { return (ValueParameter<IVRPCreator>)Parameters["SolutionCreator"]; }
    85     }
    86     IParameter IHeuristicOptimizationProblem.SolutionCreatorParameter {
    87       get { return SolutionCreatorParameter; }
    88     }
    89     ValueParameter<IVRPEvaluator> EvaluatorParameter {
    90       get { return (ValueParameter<IVRPEvaluator>)Parameters["Evaluator"]; }
    91     }
    92     IParameter IHeuristicOptimizationProblem.EvaluatorParameter {
    93       get { return EvaluatorParameter; }
    94     }
    9571    public IValueParameter<DoubleValue> FleetUsageFactorParameter {
    9672      get { return (IValueParameter<DoubleValue>)Parameters["EvalFleetUsageFactor"]; }
     
    10783    public IValueParameter<DoubleValue> TardinessPenaltyParameter {
    10884      get { return (IValueParameter<DoubleValue>)Parameters["EvalTardinessPenalty"]; }
    109     }
    110     public OptionalValueParameter<DoubleValue> BestKnownQualityParameter {
    111       get { return (OptionalValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
    112     }
    113     IParameter ISingleObjectiveHeuristicOptimizationProblem.BestKnownQualityParameter {
    114       get { return BestKnownQualityParameter; }
    11585    }
    11686    public OptionalValueParameter<IVRPEncoding> BestKnownSolutionParameter {
     
    156126      set { ServiceTimeParameter.Value = value; }
    157127    }
    158     public DoubleValue BestKnownQuality {
    159       get { return BestKnownQualityParameter.Value; }
    160       set { BestKnownQualityParameter.Value = value; }
    161     }
    162128    public IVRPEncoding BestKnownSolution {
    163129      get { return BestKnownSolutionParameter.Value; }
    164130      set { BestKnownSolutionParameter.Value = value; }
    165131    }
    166     public IVRPCreator SolutionCreator {
    167       get { return SolutionCreatorParameter.Value; }
    168       set { SolutionCreatorParameter.Value = value; }
    169     }
    170     ISolutionCreator IHeuristicOptimizationProblem.SolutionCreator {
    171       get { return SolutionCreatorParameter.Value; }
    172     }
    173     public IVRPEvaluator Evaluator {
    174       get { return EvaluatorParameter.Value; }
    175       set { EvaluatorParameter.Value = value; }
    176     }
    177     ISingleObjectiveEvaluator ISingleObjectiveHeuristicOptimizationProblem.Evaluator {
    178       get { return EvaluatorParameter.Value; }
    179     }
    180     IEvaluator IHeuristicOptimizationProblem.Evaluator {
    181       get { return EvaluatorParameter.Value; }
    182     }
    183     public IEnumerable<IOperator> Operators {
    184       get { return operators; }
    185     }
    186132    private BestVRPSolutionAnalyzer BestVRPSolutionAnalyzer {
    187       get { return operators.OfType<BestVRPSolutionAnalyzer>().FirstOrDefault(); }
     133      get { return Operators.OfType<BestVRPSolutionAnalyzer>().FirstOrDefault(); }
    188134    }
    189135    private BestAverageWorstVRPToursAnalyzer BestAverageWorstVRPToursAnalyzer {
    190       get { return operators.OfType<BestAverageWorstVRPToursAnalyzer>().FirstOrDefault(); }
     136      get { return Operators.OfType<BestAverageWorstVRPToursAnalyzer>().FirstOrDefault(); }
    191137    }
    192138    #endregion
    193139
    194     [Storable]
    195     private List<IOperator> operators;
     140    // BackwardsCompatibility3.3
     141    #region Backwards compatible code, remove with 3.4
     142    [Obsolete]
     143    [Storable(Name = "operators")]
     144    private IEnumerable<IOperator> oldOperators {
     145      get { return null; }
     146      set {
     147        if (value != null && value.Any())
     148          Operators.AddRange(value);
     149      }
     150    }
     151    #endregion
    196152
    197153    [StorableConstructor]
     
    199155    private VehicleRoutingProblem(VehicleRoutingProblem original, Cloner cloner)
    200156      : base(original, cloner) {
    201       operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
    202157      AttachEventHandlers();
    203158    }
    204159    public VehicleRoutingProblem()
    205       : base() {
    206       IVRPCreator creator = new RandomCreator();
    207       IVRPEvaluator evaluator = new VRPEvaluator();
    208 
    209       Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to false as the Vehicle Routing Problem is a minimization problem.", new BoolValue(false)));
     160      : base(new VRPEvaluator(), new RandomCreator()) {
    210161      Parameters.Add(new ValueParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the cities.", new DoubleMatrix()));
    211162      Parameters.Add(new OptionalValueParameter<DoubleMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));
     
    217168      Parameters.Add(new ValueParameter<DoubleArray>("DueTime", "The due time of each customer.", new DoubleArray()));
    218169      Parameters.Add(new ValueParameter<DoubleArray>("ServiceTime", "The service time of each customer.", new DoubleArray()));
    219       Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance."));
    220170      Parameters.Add(new OptionalValueParameter<IVRPEncoding>("BestKnownSolution", "The best known solution of this VRP instance."));
    221171      Parameters.Add(new ValueParameter<DoubleValue>("EvalFleetUsageFactor", "The fleet usage factor considered in the evaluation.", new DoubleValue(100)));
     
    225175      Parameters.Add(new ValueParameter<DoubleValue>("EvalTardinessPenalty", "The tardiness penalty considered in the evaluation.", new DoubleValue(100)));
    226176
    227       Parameters.Add(new ValueParameter<IVRPCreator>("SolutionCreator", "The operator which should be used to create new VRP solutions.", creator));
    228       Parameters.Add(new ValueParameter<IVRPEvaluator>("Evaluator", "The operator which should be used to evaluate VRP solutions.", evaluator));
    229 
    230       creator.VRPToursParameter.ActualName = "VRPTours";
    231       evaluator.QualityParameter.ActualName = "VRPQuality";
     177      SolutionCreator.VRPToursParameter.ActualName = "VRPTours";
     178      Evaluator.QualityParameter.ActualName = "VRPQuality";
    232179
    233180      InitializeRandomVRPInstance();
     
    245192
    246193    #region Events
    247     public event EventHandler SolutionCreatorChanged;
    248     private void OnSolutionCreatorChanged() {
    249       EventHandler handler = SolutionCreatorChanged;
    250       if (handler != null) handler(this, EventArgs.Empty);
    251     }
    252     public event EventHandler EvaluatorChanged;
    253     private void OnEvaluatorChanged() {
    254       EventHandler handler = EvaluatorChanged;
    255       if (handler != null) handler(this, EventArgs.Empty);
    256     }
    257     public event EventHandler OperatorsChanged;
    258     private void OnOperatorsChanged() {
    259       EventHandler handler = OperatorsChanged;
    260       if (handler != null) handler(this, EventArgs.Empty);
    261     }
    262     public event EventHandler Reset;
    263     private void OnReset() {
    264       EventHandler handler = Reset;
    265       if (handler != null) handler(this, EventArgs.Empty);
    266     }
    267     void VehiclesValue_ValueChanged(object sender, EventArgs e) {
     194    protected override void OnSolutionCreatorChanged() {
     195      base.OnSolutionCreatorChanged();
     196      ParameterizeSolutionCreator();
     197      ParameterizeEvaluator();
     198      ParameterizeAnalyzer();
     199      ParameterizeOperators();
     200    }
     201    protected override void OnEvaluatorChanged() {
     202      base.OnEvaluatorChanged();
     203      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
     204      ParameterizeEvaluator();
     205      UpdateMoveEvaluators();
     206      ParameterizeAnalyzer();
     207    }
     208    private void VehiclesValue_ValueChanged(object sender, EventArgs e) {
    268209      ParameterizeSolutionCreator();
    269210    }
     
    287228      BestKnownSolution = null;
    288229    }
    289     private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
    290       ParameterizeSolutionCreator();
    291       ParameterizeEvaluator();
    292       ParameterizeAnalyzer();
    293       ParameterizeOperators();
    294       OnSolutionCreatorChanged();
    295     }
    296     private void SolutionCreator_PermutationParameter_ActualNameChanged(object sender, EventArgs e) {
    297       ParameterizeEvaluator();
    298       ParameterizeAnalyzer();
    299       ParameterizeOperators();
    300     }
    301     private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
    302       Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    303       ParameterizeEvaluator();
    304       UpdateMoveEvaluators();
    305       ParameterizeAnalyzer();
    306       OnEvaluatorChanged();
    307     }
    308230    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
    309231      ParameterizeAnalyzer();
    310     }
    311     private void TranslocationMoveParameter_ActualNameChanged(object sender, EventArgs e) {
    312       string name = ((ILookupParameter<TranslocationMove>)sender).ActualName;
    313       foreach (IPermutationTranslocationMoveOperator op in Operators.OfType<IPermutationTranslocationMoveOperator>()) {
    314         op.TranslocationMoveParameter.ActualName = name;
    315       }
    316232    }
    317233
     
    453369      Vehicles.ValueChanged += new EventHandler(VehiclesValue_ValueChanged);
    454370
    455       SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    456 
    457       EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
    458371      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    459372
     
    494407
    495408    private void InitializeOperators() {
    496       operators = new List<IOperator>();
    497       operators.Add(new BestVRPSolutionAnalyzer());
    498       operators.Add(new BestAverageWorstVRPToursAnalyzer());
     409      Operators.Add(new BestVRPSolutionAnalyzer());
     410      Operators.Add(new BestAverageWorstVRPToursAnalyzer());
    499411      ParameterizeAnalyzer();
    500       operators.AddRange(ApplicationManager.Manager.GetInstances<IVRPOperator>().Cast<IOperator>().OrderBy(op => op.Name));
     412      Operators.AddRange(ApplicationManager.Manager.GetInstances<IVRPOperator>().Cast<IOperator>().OrderBy(op => op.Name));
    501413      ParameterizeOperators();
    502414      UpdateMoveEvaluators();
    503       InitializeMoveGenerators();
    504     }
    505     private void InitializeMoveGenerators() {
    506       foreach (IAlbaTranslocationMoveOperator op in Operators.OfType<IAlbaTranslocationMoveOperator>()) {
    507         if (op is IMoveGenerator) {
    508           op.TranslocationMoveParameter.ActualNameChanged += new EventHandler(TranslocationMoveParameter_ActualNameChanged);
    509         }
    510       }
    511 
    512415    }
    513416    private void UpdateMoveEvaluators() {
  • trunk/sources/HeuristicLab.Tests/HeuristicLab-3.3/SamplesTest.cs

    r6930 r6938  
    8585      TravelingSalesmanProblem tspProblem = new TravelingSalesmanProblem();
    8686      tspProblem.ImportFromTSPLIB("ch130.tsp", "ch130.opt.tour", 6110);
    87       tspProblem.Evaluator = new TSPRoundedEuclideanPathEvaluator();
    88       tspProblem.SolutionCreator = new RandomPermutationCreator();
     87      tspProblem.EvaluatorParameter.Value = new TSPRoundedEuclideanPathEvaluator();
     88      tspProblem.SolutionCreatorParameter.Value = new RandomPermutationCreator();
    8989      tspProblem.UseDistanceMatrix.Value = true;
    9090      tspProblem.Name = "ch130 TSP (imported from TSPLIB)";
     
    140140      vrpProblem.TardinessPenaltyParameter.Value.Value = 100;
    141141      vrpProblem.TimeFactorParameter.Value.Value = 0;
    142       vrpProblem.Evaluator = new VRPEvaluator();
     142      vrpProblem.EvaluatorParameter.Value = new VRPEvaluator();
    143143      vrpProblem.MaximizationParameter.Value.Value = false;
    144       vrpProblem.SolutionCreator = new RandomCreator();
     144      vrpProblem.SolutionCreatorParameter.Value = new RandomCreator();
    145145      vrpProblem.UseDistanceMatrix.Value = true;
    146146      vrpProblem.Vehicles.Value = 25;
     
    480480
    481481      problem.ProblemSize.Value = 10;
    482       problem.Evaluator = new GriewankEvaluator();
    483       problem.SolutionCreator = new UniformRandomRealVectorCreator();
     482      problem.EvaluatorParameter.Value = new GriewankEvaluator();
     483      problem.SolutionCreatorParameter.Value = new UniformRandomRealVectorCreator();
    484484      problem.Maximization.Value = false;
    485485      problem.Bounds = new DoubleMatrix(new double[,] { { -600, 600 } });
     
    533533      TravelingSalesmanProblem tspProblem = new TravelingSalesmanProblem();
    534534      tspProblem.ImportFromTSPLIB("ch130.tsp", "ch130.opt.tour", 6110);
    535       tspProblem.Evaluator = new TSPRoundedEuclideanPathEvaluator();
    536       tspProblem.SolutionCreator = new RandomPermutationCreator();
     535      tspProblem.EvaluatorParameter.Value = new TSPRoundedEuclideanPathEvaluator();
     536      tspProblem.SolutionCreatorParameter.Value = new RandomPermutationCreator();
    537537      tspProblem.UseDistanceMatrix.Value = true;
    538538      tspProblem.Name = "ch130 TSP (imported from TSPLIB)";
     
    581581      #region Problem Configuration
    582582      KnapsackProblem problem = new KnapsackProblem();
    583       problem.BestKnownQuality = new DoubleValue(362);
     583      problem.BestKnownQuality.Value = 362;
    584584      problem.BestKnownSolution = new HeuristicLab.Encodings.BinaryVectorEncoding.BinaryVector(new bool[] {
    585585       true , false, false, true , true , true , true , true , false, true , true , true , true , true , true , false, true , false, true , true , false, true , true , false, true , false, true , true , true , false, true , true , false, true , true , false, true , false, true , true , true , true , true , true , true , true , true , true , true , true , true , false, true , false, false, true , true , false, true , true , true , true , true , true , true , true , false, true , false, true , true , true , true , false, true , true , true , true , true , true , true , true});
    586       problem.Evaluator = new KnapsackEvaluator();
    587       problem.SolutionCreator = new RandomBinaryVectorCreator();
     586      problem.EvaluatorParameter.Value = new KnapsackEvaluator();
     587      problem.SolutionCreatorParameter.Value = new RandomBinaryVectorCreator();
    588588      problem.KnapsackCapacity.Value = 297;
    589589      problem.Maximization.Value = true;
     
    651651      problem.BestKnownSolutionParameter.Value = new RealVector(new double[] { 420.968746, 420.968746 });
    652652      problem.Bounds = new DoubleMatrix(new double[,] { { -500, 500 } });
    653       problem.Evaluator = new SchwefelEvaluator();
     653      problem.EvaluatorParameter.Value = new SchwefelEvaluator();
    654654      problem.Maximization.Value = false;
    655655      problem.ProblemSize.Value = 2;
    656       problem.SolutionCreator = new UniformRandomRealVectorCreator();
     656      problem.SolutionCreatorParameter.Value = new UniformRandomRealVectorCreator();
    657657      #endregion
    658658      #region Algorithm Configuration
     
    721721      problem.BestKnownSolutionParameter.Value = new RealVector(new double[] { 0, 0 });
    722722      problem.Bounds = new DoubleMatrix(new double[,] { { -5.12, 5.12 } });
    723       problem.Evaluator = new RastriginEvaluator();
     723      problem.EvaluatorParameter.Value = new RastriginEvaluator();
    724724      problem.Maximization.Value = false;
    725725      problem.ProblemSize.Value = 2;
    726       problem.SolutionCreator = new UniformRandomRealVectorCreator();
     726      problem.SolutionCreatorParameter.Value = new UniformRandomRealVectorCreator();
    727727      #endregion
    728728      #region Algorithm Configuration
     
    788788      var tspProblem = new TravelingSalesmanProblem();
    789789      tspProblem.ImportFromTSPLIB("ch130.tsp", "ch130.opt.tour", 6110);
    790       tspProblem.Evaluator = new TSPRoundedEuclideanPathEvaluator();
    791       tspProblem.SolutionCreator = new RandomPermutationCreator();
     790      tspProblem.EvaluatorParameter.Value = new TSPRoundedEuclideanPathEvaluator();
     791      tspProblem.SolutionCreatorParameter.Value = new RandomPermutationCreator();
    792792      tspProblem.UseDistanceMatrix.Value = true;
    793793      tspProblem.Name = "ch130 TSP (imported from TSPLIB)";
     
    870870{48, 71}, {49, 71}, {50, 71}, {44, 70}, {45, 70}, {52, 70}, {53, 70}, {54, 70}, {41, 69}, {42, 69}, {55, 69}, {56, 69}, {40, 68}, {56, 68}, {57, 68}, {39, 67}, {57, 67}, {58, 67}, {59, 67}, {38, 66}, {59, 66}, {60, 66}, {37, 65}, {60, 65}, {36, 64}, {43, 64}, {35, 63}, {37, 63}, {41, 63}, {42, 63}, {43, 63}, {47, 63}, {61, 63}, {40, 62}, {41, 62}, {42, 62}, {43, 62}, {45, 62}, {46, 62}, {47, 62}, {62, 62}, {34, 61}, {38, 61}, {39, 61}, {42, 61}, {43, 61}, {44, 61}, {45, 61}, {46, 61}, {47, 61}, {52, 61}, {62, 61}, {63, 61}, {26, 60}, {38, 60}, {42, 60}, {43, 60}, {44, 60}, {46, 60}, {47, 60}, {63, 60}, {23, 59}, {24, 59}, {27, 59}, {29, 59}, {30, 59}, {31, 59}, {33, 59}, {42, 59}, {46, 59}, {47, 59}, {63, 59}, {21, 58}, {32, 58}, {33, 58}, {34, 58}, {35, 58}, {46, 58}, {47, 58}, {48, 58}, {53, 58}, {21, 57}, {35, 57}, {47, 57}, {48, 57}, {53, 57}, {36, 56}, {37, 56}, {46, 56}, {47, 56}, {48, 56}, {64, 56}, {65, 56}, {20, 55}, {38, 55}, {46, 55}, {47, 55}, {48, 55}, {52, 55}, {21, 54}, {40, 54}, {47, 54}, {48, 54}, {52, 54}, {65, 54}, {30, 53}, {41, 53}, {46, 53}, {47, 53}, {48, 53}, {52, 53}, {65, 53}, {21, 52}, {32, 52}, {33, 52}, {42, 52}, {51, 52}, {21, 51}, {33, 51}, {34, 51}, {43, 51}, {51, 51}, {21, 50}, {35, 50}, {44, 50}, {50, 50}, {66, 50}, {67, 50}, {21, 49}, {34, 49}, {36, 49}, {37, 49}, {46, 49}, {49, 49}, {67, 49}, {22, 48}, {36, 48}, {37, 48}, {46, 48}, {47, 48}, {22, 47}, {30, 47}, {34, 47}, {37, 47}, {38, 47}, {39, 47}, {47, 47}, {48, 47}, {67, 47}, {23, 46}, {28, 46}, {29, 46}, {30, 46}, {31, 46}, {32, 46}, {35, 46}, {37, 46}, {38, 46}, {39, 46}, {49, 46}, {67, 46}, {23, 45}, {28, 45}, {29, 45}, {31, 45}, {32, 45}, {40, 45}, {41, 45}, {49, 45}, {50, 45}, {68, 45}, {24, 44}, {29, 44}, {32, 44}, {41, 44}, {51, 44}, {68, 44}, {25, 43}, {30, 43}, {32, 43}, {42, 43}, {43, 43}, {51, 43}, {68, 43}, {69, 43}, {31, 42}, {32, 42}, {43, 42}, {52, 42}, {55, 42}, {26, 41}, {27, 41}, {31, 41}, {32, 41}, {33, 41}, {44, 41}, {45, 41}, {46, 41}, {47, 41}, {48, 41}, {49, 41}, {53, 41}, {25, 40}, {27, 40}, {32, 40}, {43, 40}, {44, 40}, {45, 40}, {46, 40}, {48, 40}, {49, 40}, {50, 40}, {51, 40}, {53, 40}, {56, 40}, {32, 39}, {33, 39}, {43, 39}, {50, 39}, {51, 39}, {54, 39}, {56, 39}, {69, 39}, {24, 38}, {32, 38}, {41, 38}, {42, 38}, {51, 38}, {52, 38}, {54, 38}, {57, 38}, {69, 38}, {31, 37}, {32, 37}, {40, 37}, {41, 37}, {42, 37}, {43, 37}, {44, 37}, {45, 37}, {46, 37}, {47, 37}, {48, 37}, {51, 37}, {52, 37}, {55, 37}, {57, 37}, {69, 37}, {24, 36}, {31, 36}, {32, 36}, {39, 36}, {40, 36}, {41, 36}, {42, 36}, {43, 36}, {45, 36}, {48, 36}, {49, 36}, {51, 36}, {53, 36}, {55, 36}, {58, 36}, {22, 35}, {23, 35}, {24, 35}, {25, 35}, {30, 35}, {31, 35}, {32, 35}, {39, 35}, {41, 35}, {49, 35}, {51, 35}, {55, 35}, {56, 35}, {58, 35}, {71, 35}, {20, 34}, {27, 34}, {30, 34}, {31, 34}, {51, 34}, {53, 34}, {57, 34}, {60, 34}, {18, 33}, {19, 33}, {29, 33}, {30, 33}, {31, 33}, {45, 33}, {46, 33}, {47, 33}, {52, 33}, {53, 33}, {55, 33}, {57, 33}, {58, 33}, {17, 32}, {30, 32}, {44, 32}, {47, 32}, {54, 32}, {57, 32}, {59, 32}, {61, 32}, {71, 32}, {72, 32}, {43, 31}, {47, 31}, {56, 31}, {58, 31}, {59, 31}, {61, 31}, {72, 31}, {74, 31}, {16, 30}, {43, 30}, {46, 30}, {47, 30}, {59, 30}, {63, 30}, {71, 30}, {75, 30}, {43, 29}, {46, 29}, {47, 29}, {59, 29}, {60, 29}, {75, 29}, {15, 28}, {43, 28}, {46, 28}, {61, 28}, {76, 28}, {15, 27}, {43, 27}, {44, 27}, {45, 27}, {46, 27}, {60, 27}, {62, 27}, {15, 26}, {43, 26}, {44, 26}, {46, 26}, {59, 26}, {60, 26}, {64, 26}, {77, 26}, {15, 25}, {58, 25}, {61, 25}, {77, 25}, {15, 24}, {53, 24}, {55, 24}, {61, 24}, {77, 24}, {62, 23}, {16, 22}, {61, 22}, {62, 22}, {15, 21}, {16, 21}, {52, 21}, {63, 21}, {77, 21}, {16, 20}, {17, 20}, {46, 20}, {47, 20}, {60, 20}, {62, 20}, {63, 20}, {65, 20}, {76, 20}, {15, 19}, {17, 19}, {18, 19}, {44, 19}, {45, 19}, {48, 19}, {53, 19}, {56, 19}, {60, 19}, {62, 19}, {67, 19}, {68, 19}, {76, 19}, {15, 18}, {18, 18}, {19, 18}, {20, 18}, {32, 18}, {33, 18}, {34, 18}, {41, 18}, {42, 18}, {43, 18}, {46, 18}, {48, 18}, {53, 18}, {59, 18}, {60, 18}, {69, 18}, {75, 18}, {16, 17}, {17, 17}, {20, 17}, {21, 17}, {22, 17}, {23, 17}, {24, 17}, {26, 17}, {28, 17}, {29, 17}, {30, 17}, {31, 17}, {32, 17}, {34, 17}, {35, 17}, {36, 17}, {37, 17}, {38, 17}, {39, 17}, {40, 17}, {44, 17}, {46, 17}, {48, 17}, {53, 17}, {56, 17}, {58, 17}, {75, 17}, {17, 16}, {18, 16}, {20, 16}, {24, 16}, {26, 16}, {27, 16}, {29, 16}, {33, 16}, {41, 16}, {42, 16}, {44, 16}, {47, 16}, {52, 16}, {57, 16}, {70, 16}, {73, 16}, {74, 16}, {17, 15}, {18, 15}, {20, 15}, {22, 15}, {24, 15}, {27, 15}, {29, 15}, {31, 15}, {33, 15}, {35, 15}, {36, 15}, {38, 15}, {39, 15}, {42, 15}, {45, 15}, {47, 15}, {52, 15}, {53, 15}, {55, 15}, {56, 15}, {70, 15}, {73, 15}, {17, 14}, {19, 14}, {21, 14}, {24, 14}, {26, 14}, {29, 14}, {31, 14}, {34, 14}, {37, 14}, {40, 14}, {42, 14}, {44, 14}, {46, 14}, {47, 14}, {53, 14}, {54, 14}, {55, 14}, {62, 14}, {70, 14}, {72, 14}, {17, 13}, {19, 13}, {21, 13}, {23, 13}, {25, 13}, {27, 13}, {30, 13}, {32, 13}, {34, 13}, {36, 13}, {38, 13}, {41, 13}, {43, 13}, {44, 13}, {45, 13}, {60, 13}, {70, 13}, {71, 13}, {18, 12}, {21, 12}, {23, 12}, {26, 12}, {28, 12}, {31, 12}, {34, 12}, {37, 12}, {39, 12}, {41, 12}, {42, 12}, {70, 12}, {18, 11}, {19, 11}, {20, 11}, {21, 11}, {24, 11}, {25, 11}, {27, 11}, {29, 11}, {31, 11}, {33, 11}, {35, 11}, {38, 11}, {41, 11}, {59, 11}, {26, 10}, {29, 10}, {32, 10}, {34, 10}, {36, 10}, {39, 10}, {40, 10}, {69, 10}, {21, 9}, {26, 9}, {28, 9}, {30, 9}, {32, 9}, {33, 9}, {35, 9}, {36, 9}, {37, 9}, {38, 9}, {39, 9}, {22, 8}, {27, 8}, {28, 8}, {29, 8}, {30, 8}, {31, 8}, {68, 8}, {23, 7}, {66, 7}, {24, 6}, {65, 6}, {25, 5}, {62, 5}, {63, 5}, {26, 4}, {55, 4}, {56, 4}, {57, 4}, {58, 4}, {59, 4}, {60, 4}, {61, 4}, {28, 3}, {53, 3}, {29, 2}, {50, 2}, {51, 2}, {52, 2}, {31, 1}, {32, 1}, {48, 1}
    871871      });
    872       tspProblem.BestKnownQuality = new DoubleValue(867);
    873 
    874       tspProblem.Evaluator = new TSPRoundedEuclideanPathEvaluator();
    875       tspProblem.SolutionCreator = new RandomPermutationCreator();
     872      tspProblem.BestKnownQuality.Value = 867;
     873
     874      tspProblem.EvaluatorParameter.Value = new TSPRoundedEuclideanPathEvaluator();
     875      tspProblem.SolutionCreatorParameter.Value = new RandomPermutationCreator();
    876876      tspProblem.UseDistanceMatrix.Value = true;
    877877      tspProblem.Name = "Funny TSP";
Note: See TracChangeset for help on using the changeset viewer.