Changeset 6938
- Timestamp:
- 10/26/11 23:36:10 (13 years ago)
- Location:
- trunk/sources
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab 3.3.vsmdi
r4066 r6938 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <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> 3 45 <TestList name="Lists of Tests" id="8c43106b-9dc1-4907-a29f-aa66a61bf5b6"> 4 46 <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 26 26 using HeuristicLab.Common; 27 27 using HeuristicLab.Core; 28 using HeuristicLab.Parameters; 28 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 30 … … 32 33 [StorableClass] 33 34 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 34 41 public override Image ItemImage { 35 42 get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; } … … 37 44 38 45 [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 } 40 50 protected Problem(Problem original, Cloner cloner) 41 51 : base(original, cloner) { … … 47 57 : base() { 48 58 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; 49 61 RegisterEventHandlers(); 50 62 } … … 52 64 [StorableHook(HookType.AfterDeserialization)] 53 65 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 54 73 RegisterEventHandlers(); 55 74 } -
trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs
r6476 r6938 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing;25 24 using System.Linq; 26 25 using HeuristicLab.Common; … … 37 36 [Creatable("Problems")] 38 37 [StorableClass] 39 public sealed class KnapsackProblem : ParameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent {38 public sealed class KnapsackProblem : SingleObjectiveHeuristicOptimizationProblem<IKnapsackEvaluator, IBinaryVectorCreator>, IStorableContent { 40 39 public string Filename { get; set; } 41 40 42 public override Image ItemImage {43 get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }44 }45 46 41 #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 }53 42 public ValueParameter<IntValue> KnapsackCapacityParameter { 54 43 get { return (ValueParameter<IntValue>)Parameters["KnapsackCapacity"]; } … … 63 52 get { return (ValueParameter<DoubleValue>)Parameters["Penalty"]; } 64 53 } 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 }83 54 public OptionalValueParameter<BinaryVector> BestKnownSolutionParameter { 84 55 get { return (OptionalValueParameter<BinaryVector>)Parameters["BestKnownSolution"]; } … … 87 58 88 59 #region Properties 89 public BoolValue Maximization {90 get { return MaximizationParameter.Value; }91 set { MaximizationParameter.Value = value; }92 }93 60 public IntValue KnapsackCapacity { 94 61 get { return KnapsackCapacityParameter.Value; } … … 107 74 set { PenaltyParameter.Value = value; } 108 75 } 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 }130 76 public BinaryVector BestKnownSolution { 131 77 get { return BestKnownSolutionParameter.Value; } 132 78 set { BestKnownSolutionParameter.Value = value; } 133 79 } 134 public IEnumerable<IOperator> Operators {135 get { return operators.Cast<IOperator>(); }136 }137 80 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 144 97 145 98 [StorableConstructor] … … 147 100 private KnapsackProblem(KnapsackProblem original, Cloner cloner) 148 101 : base(original, cloner) { 149 this.operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList();150 102 AttachEventHandlers(); 151 103 } … … 154 106 } 155 107 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()) { 161 109 Parameters.Add(new ValueParameter<IntValue>("KnapsackCapacity", "Capacity of the Knapsack.", new IntValue(0))); 162 110 Parameters.Add(new ValueParameter<IntArray>("Weights", "The weights of the items.", new IntArray(5))); 163 111 Parameters.Add(new ValueParameter<IntArray>("Values", "The values of the items.", new IntArray(5))); 164 112 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."));168 113 Parameters.Add(new OptionalValueParameter<BinaryVector>("BestKnownSolution", "The best known solution of this Knapsack instance.")); 169 114 170 creator.BinaryVectorParameter.ActualName = "KnapsackSolution"; 115 Maximization.Value = true; 116 117 SolutionCreator.BinaryVectorParameter.ActualName = "KnapsackSolution"; 171 118 172 119 InitializeRandomKnapsackInstance(); … … 180 127 181 128 #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(); 204 131 SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_BinaryVectorParameter_ActualNameChanged); 205 132 ParameterizeSolutionCreator(); … … 207 134 ParameterizeAnalyzer(); 208 135 ParameterizeOperators(); 209 OnSolutionCreatorChanged(); 136 } 137 protected override void OnEvaluatorChanged() { 138 base.OnEvaluatorChanged(); 139 ParameterizeEvaluator(); 140 ParameterizeAnalyzer(); 210 141 } 211 142 private void SolutionCreator_BinaryVectorParameter_ActualNameChanged(object sender, EventArgs e) { … … 214 145 ParameterizeOperators(); 215 146 } 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) { 226 152 ParameterizeEvaluator(); 227 153 ParameterizeAnalyzer(); … … 230 156 WeightsParameter.Value.Reset += new EventHandler(WeightsValue_Reset); 231 157 } 232 void WeightsValue_Reset(object sender, EventArgs e) {158 private void WeightsValue_Reset(object sender, EventArgs e) { 233 159 ParameterizeSolutionCreator(); 234 160 … … 236 162 ((IStringConvertibleArray)ValuesParameter.Value).Length = WeightsParameter.Value.Length; 237 163 } 238 void ValuesParameter_ValueChanged(object sender, EventArgs e) {164 private void ValuesParameter_ValueChanged(object sender, EventArgs e) { 239 165 ParameterizeEvaluator(); 240 166 ParameterizeAnalyzer(); … … 243 169 ValuesParameter.Value.Reset += new EventHandler(ValuesValue_Reset); 244 170 } 245 void ValuesValue_Reset(object sender, EventArgs e) {171 private void ValuesValue_Reset(object sender, EventArgs e) { 246 172 ParameterizeSolutionCreator(); 247 173 … … 249 175 ((IStringConvertibleArray)WeightsParameter.Value).Length = ValuesParameter.Value.Length; 250 176 } 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) { 255 181 string name = ((ILookupParameter<OneBitflipMove>)sender).ActualName; 256 182 foreach (IOneBitflipMoveOperator op in Operators.OfType<IOneBitflipMoveOperator>()) { … … 265 191 // BackwardsCompatibility3.3 266 192 #region Backwards compatible code (remove with 3.4) 267 if ( operators == null) InitializeOperators();193 if (Operators.Count > 0) InitializeOperators(); 268 194 #endregion 269 195 AttachEventHandlers(); … … 271 197 272 198 private void AttachEventHandlers() { 273 SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);274 199 SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_BinaryVectorParameter_ActualNameChanged); 275 EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);276 200 KnapsackCapacityParameter.ValueChanged += new EventHandler(KnapsackCapacityParameter_ValueChanged); 277 201 WeightsParameter.ValueChanged += new EventHandler(WeightsParameter_ValueChanged); … … 319 243 } 320 244 private void InitializeOperators() { 321 operators = new List<IOperator>(); 322 operators.Add(new BestKnapsackSolutionAnalyzer()); 245 Operators.Add(new BestKnapsackSolutionAnalyzer()); 323 246 ParameterizeAnalyzer(); 324 247 foreach (IBinaryVectorOperator op in ApplicationManager.Manager.GetInstances<IBinaryVectorOperator>()) { 325 248 if (!(op is ISingleObjectiveMoveEvaluator) || (op is IKnapsackMoveEvaluator)) { 326 operators.Add(op);249 Operators.Add(op); 327 250 } 328 251 } -
trunk/sources/HeuristicLab.Problems.OneMax/3.3/OnemaxProblem.cs
r6042 r6938 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing;25 24 using System.Linq; 26 25 using HeuristicLab.Common; … … 37 36 [Creatable("Problems")] 38 37 [StorableClass] 39 public sealed class OneMaxProblem : ParameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent {38 public sealed class OneMaxProblem : SingleObjectiveHeuristicOptimizationProblem<IOneMaxEvaluator, IBinaryVectorCreator>, IStorableContent { 40 39 public string Filename { get; set; } 41 40 42 public override Image ItemImage {43 get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }44 }45 46 41 #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 }53 42 public ValueParameter<IntValue> LengthParameter { 54 43 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; }73 44 } 74 45 #endregion … … 79 50 set { LengthParameter.Value = value; } 80 51 } 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 }104 52 private BestOneMaxSolutionAnalyzer BestOneMaxSolutionAnalyzer { 105 get { return operators.OfType<BestOneMaxSolutionAnalyzer>().FirstOrDefault(); }53 get { return Operators.OfType<BestOneMaxSolutionAnalyzer>().FirstOrDefault(); } 106 54 } 107 55 #endregion 108 56 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 111 69 112 70 [StorableConstructor] … … 114 72 private OneMaxProblem(OneMaxProblem original, Cloner cloner) 115 73 : base(original, cloner) { 116 operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList();117 74 AttachEventHandlers(); 118 75 } 119 76 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; 123 80 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"; 132 83 ParameterizeSolutionCreator(); 133 84 ParameterizeEvaluator(); … … 142 93 143 94 #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(); 166 97 SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_BinaryVectorParameter_ActualNameChanged); 167 98 ParameterizeSolutionCreator(); … … 169 100 ParameterizeAnalyzer(); 170 101 ParameterizeOperators(); 171 OnSolutionCreatorChanged(); 102 } 103 protected override void OnEvaluatorChanged() { 104 base.OnEvaluatorChanged(); 105 ParameterizeEvaluator(); 106 ParameterizeAnalyzer(); 172 107 } 173 108 private void SolutionCreator_BinaryVectorParameter_ActualNameChanged(object sender, EventArgs e) { … … 176 111 ParameterizeOperators(); 177 112 } 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) { 184 114 ParameterizeSolutionCreator(); 185 115 LengthParameter.Value.ValueChanged += new EventHandler(Length_ValueChanged); 186 116 BestKnownQualityParameter.Value.Value = Length.Value; 187 117 } 188 void Length_ValueChanged(object sender, EventArgs e) {118 private void Length_ValueChanged(object sender, EventArgs e) { 189 119 BestKnownQualityParameter.Value.Value = Length.Value; 190 120 } 191 void BestKnownQualityParameter_ValueChanged(object sender, EventArgs e) {121 private void BestKnownQualityParameter_ValueChanged(object sender, EventArgs e) { 192 122 BestKnownQualityParameter.Value.Value = Length.Value; 193 123 } 194 void OneBitflipMoveParameter_ActualNameChanged(object sender, EventArgs e) {124 private void OneBitflipMoveParameter_ActualNameChanged(object sender, EventArgs e) { 195 125 string name = ((ILookupParameter<OneBitflipMove>)sender).ActualName; 196 126 foreach (IOneBitflipMoveOperator op in Operators.OfType<IOneBitflipMoveOperator>()) { … … 205 135 // BackwardsCompatibility3.3 206 136 #region Backwards compatible code (remove with 3.4) 207 if ( operators == null) InitializeOperators();137 if (Operators.Count == 0) InitializeOperators(); 208 138 #endregion 209 139 AttachEventHandlers(); … … 211 141 212 142 private void AttachEventHandlers() { 213 SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);214 143 SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_BinaryVectorParameter_ActualNameChanged); 215 EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);216 144 LengthParameter.ValueChanged += new EventHandler(LengthParameter_ValueChanged); 217 145 LengthParameter.Value.ValueChanged += new EventHandler(Length_ValueChanged); … … 233 161 } 234 162 private void InitializeOperators() { 235 operators = new List<IOperator>(); 236 operators.Add(new BestOneMaxSolutionAnalyzer()); 163 Operators.Add(new BestOneMaxSolutionAnalyzer()); 237 164 ParameterizeAnalyzer(); 238 165 foreach (IBinaryVectorOperator op in ApplicationManager.Manager.GetInstances<IBinaryVectorOperator>()) { 239 166 if (!(op is ISingleObjectiveMoveEvaluator) || (op is IOneMaxMoveEvaluator)) { 240 operators.Add(op);167 Operators.Add(op); 241 168 } 242 169 } -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs
r6051 r6938 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing;25 24 using System.Linq; 26 25 using HeuristicLab.Common; … … 37 36 [StorableClass] 38 37 [Creatable("Problems")] 39 public sealed class SingleObjectiveTestFunctionProblem : ParameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent {38 public sealed class SingleObjectiveTestFunctionProblem : SingleObjectiveHeuristicOptimizationProblem<ISingleObjectiveTestFunctionProblemEvaluator, IRealVectorCreator>, IStorableContent { 40 39 public string Filename { get; set; } 41 40 … … 47 46 private StdDevStrategyVectorManipulator strategyVectorManipulator; 48 47 49 public override Image ItemImage {50 get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }51 }52 53 48 #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 }60 49 public ValueParameter<DoubleMatrix> BoundsParameter { 61 50 get { return (ValueParameter<DoubleMatrix>)Parameters["Bounds"]; } … … 64 53 get { return (ValueParameter<IntValue>)Parameters["ProblemSize"]; } 65 54 } 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 }84 55 public OptionalValueParameter<RealVector> BestKnownSolutionParameter { 85 56 get { return (OptionalValueParameter<RealVector>)Parameters["BestKnownSolution"]; } … … 88 59 89 60 #region Properties 90 public BoolValue Maximization {91 get { return MaximizationParameter.Value; }92 set { MaximizationParameter.Value = value; }93 }94 61 public DoubleMatrix Bounds { 95 62 get { return BoundsParameter.Value; } … … 100 67 set { ProblemSizeParameter.Value = value; } 101 68 } 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 }126 69 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 133 86 134 87 [StorableConstructor] … … 136 89 private SingleObjectiveTestFunctionProblem(SingleObjectiveTestFunctionProblem original, Cloner cloner) 137 90 : base(original, cloner) { 138 operators = original.operators.Where(x => original.IsNotFieldReferenced(x)).Select(x => cloner.Clone(x)).ToList();139 91 strategyVectorCreator = cloner.Clone(original.strategyVectorCreator); 140 operators.Add(strategyVectorCreator);141 92 strategyVectorCrossover = cloner.Clone(original.strategyVectorCrossover); 142 operators.Add(strategyVectorCrossover);143 93 strategyVectorManipulator = cloner.Clone(original.strategyVectorManipulator); 144 operators.Add(strategyVectorManipulator);145 94 AttachEventHandlers(); 146 95 } 147 96 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)); 154 99 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)));158 100 Parameters.Add(new OptionalValueParameter<RealVector>("BestKnownSolution", "The best known solution for this test function instance.")); 159 101 … … 165 107 strategyVectorManipulator.GeneralLearningRateParameter.Value = new DoubleValue(0.5); 166 108 167 creator.RealVectorParameter.ActualName = "Point";109 SolutionCreator.RealVectorParameter.ActualName = "Point"; 168 110 ParameterizeSolutionCreator(); 169 111 ParameterizeEvaluator(); … … 185 127 186 128 #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(); 221 131 ParameterizeSolutionCreator(); 222 132 ParameterizeAnalyzers(); 133 SolutionCreator.RealVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_RealVectorParameter_ActualNameChanged); 223 134 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(); 232 138 ParameterizeEvaluator(); 233 139 UpdateMoveEvaluators(); … … 242 148 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 243 149 Evaluator_QualityParameter_ActualNameChanged(null, EventArgs.Empty); 244 OnEvaluatorChanged();245 150 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(); 246 168 } 247 169 private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) { … … 305 227 // BackwardsCompatibility3.3 306 228 #region Backwards compatible code (remove with 3.4) 307 if ( operators == null) InitializeOperators();229 if (Operators.Count == 0) InitializeOperators(); 308 230 #endregion 309 231 AttachEventHandlers(); … … 316 238 Bounds.ToStringChanged += new EventHandler(Bounds_ToStringChanged); 317 239 Bounds.ItemChanged += new EventHandler<EventArgs<int, int>>(Bounds_ItemChanged); 318 SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);319 240 SolutionCreator.RealVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_RealVectorParameter_ActualNameChanged); 320 EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);321 241 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 322 242 strategyVectorCreator.BoundsParameter.ValueChanged += new EventHandler(strategyVectorCreator_BoundsParameter_ValueChanged); … … 334 254 } 335 255 private void InitializeOperators() { 336 operators = new List<IOperator>(); 337 operators.Add(new BestSingleObjectiveTestFunctionSolutionAnalyzer()); 256 Operators.Add(new BestSingleObjectiveTestFunctionSolutionAnalyzer()); 338 257 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); 343 262 UpdateMoveEvaluators(); 344 263 ParameterizeOperators(); … … 354 273 private void UpdateMoveEvaluators() { 355 274 foreach (ISingleObjectiveTestFunctionMoveEvaluator op in Operators.OfType<ISingleObjectiveTestFunctionMoveEvaluator>().ToList()) 356 operators.Remove(op);275 Operators.Remove(op); 357 276 foreach (ISingleObjectiveTestFunctionMoveEvaluator op in ApplicationManager.Manager.GetInstances<ISingleObjectiveTestFunctionMoveEvaluator>()) 358 277 if (op.EvaluatorType == Evaluator.GetType()) { 359 operators.Add(op);278 Operators.Add(op); 360 279 #region Synchronize evaluator specific parameters with the parameters of the corresponding move evaluators 361 280 if (op is ISphereMoveEvaluator) { -
trunk/sources/HeuristicLab.Problems.TravelingSalesman.Views/3.3/Plugin.cs.frame
r6866 r6938 36 36 [PluginDependency("HeuristicLab.MainForm", "3.3")] 37 37 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")] 38 [PluginDependency("HeuristicLab.Optimization", "3.3")] 38 39 [PluginDependency("HeuristicLab.Parameters", "3.3")] 39 40 [PluginDependency("HeuristicLab.Problems.TravelingSalesman", "3.3")] -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
r6051 r6938 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing;25 24 using System.IO; 26 25 using System.Linq; … … 38 37 [Creatable("Problems")] 39 38 [StorableClass] 40 public sealed class TravelingSalesmanProblem : ParameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent {39 public sealed class TravelingSalesmanProblem : SingleObjectiveHeuristicOptimizationProblem<ITSPEvaluator, IPermutationCreator>, IStorableContent { 41 40 public string Filename { get; set; } 42 41 43 public override Image ItemImage {44 get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }45 }46 47 42 #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 }54 43 public ValueParameter<DoubleMatrix> CoordinatesParameter { 55 44 get { return (ValueParameter<DoubleMatrix>)Parameters["Coordinates"]; } … … 60 49 public ValueParameter<BoolValue> UseDistanceMatrixParameter { 61 50 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; }80 51 } 81 52 public OptionalValueParameter<Permutation> BestKnownSolutionParameter { … … 97 68 set { UseDistanceMatrixParameter.Value = value; } 98 69 } 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 }120 70 public Permutation BestKnownSolution { 121 71 get { return BestKnownSolutionParameter.Value; } 122 72 set { BestKnownSolutionParameter.Value = value; } 123 73 } 124 public IEnumerable<IOperator> Operators {125 get { return operators; }126 }127 74 private BestTSPSolutionAnalyzer BestTSPSolutionAnalyzer { 128 get { return operators.OfType<BestTSPSolutionAnalyzer>().FirstOrDefault(); }75 get { return Operators.OfType<BestTSPSolutionAnalyzer>().FirstOrDefault(); } 129 76 } 130 77 private TSPAlleleFrequencyAnalyzer TSPAlleleFrequencyAnalyzer { 131 get { return operators.OfType<TSPAlleleFrequencyAnalyzer>().FirstOrDefault(); }78 get { return Operators.OfType<TSPAlleleFrequencyAnalyzer>().FirstOrDefault(); } 132 79 } 133 80 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 140 97 141 98 [StorableConstructor] … … 143 100 private TravelingSalesmanProblem(TravelingSalesmanProblem original, Cloner cloner) 144 101 : base(original, cloner) { 145 this.operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList();146 102 AttachEventHandlers(); 147 103 } … … 150 106 } 151 107 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 157 110 Parameters.Add(new ValueParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the cities.")); 158 111 Parameters.Add(new OptionalValueParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities.")); 159 112 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."));163 113 Parameters.Add(new OptionalValueParameter<Permutation>("BestKnownSolution", "The best known solution of this TSP instance.")); 164 114 … … 173 123 }); 174 124 175 creator.PermutationParameter.ActualName = "TSPTour";176 evaluator.QualityParameter.ActualName = "TSPTourLength";125 SolutionCreator.PermutationParameter.ActualName = "TSPTour"; 126 Evaluator.QualityParameter.ActualName = "TSPTourLength"; 177 127 ParameterizeSolutionCreator(); 178 128 ParameterizeEvaluator(); … … 183 133 184 134 #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 } 206 151 private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) { 207 152 Coordinates.ItemChanged += new EventHandler<EventArgs<int, int>>(Coordinates_ItemChanged); … … 217 162 ClearDistanceMatrix(); 218 163 } 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 }227 164 private void SolutionCreator_PermutationParameter_ActualNameChanged(object sender, EventArgs e) { 228 165 ParameterizeEvaluator(); … … 230 167 ParameterizeOperators(); 231 168 } 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 }240 169 private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) { 241 170 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 }254 171 } 255 172 #endregion … … 277 194 } 278 195 279 if ( operators == null) InitializeOperators();196 if (Operators.Count == 0) InitializeOperators(); 280 197 #endregion 281 198 AttachEventHandlers(); … … 286 203 Coordinates.ItemChanged += new EventHandler<EventArgs<int, int>>(Coordinates_ItemChanged); 287 204 Coordinates.Reset += new EventHandler(Coordinates_Reset); 288 SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);289 205 SolutionCreator.PermutationParameter.ActualNameChanged += new EventHandler(SolutionCreator_PermutationParameter_ActualNameChanged); 290 EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);291 206 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 292 207 } 293 208 294 209 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>()); 301 215 ParameterizeOperators(); 302 216 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 }316 217 } 317 218 private void UpdateMoveEvaluators() { 318 operators.RemoveAll(x => x is ISingleObjectiveMoveEvaluator);219 Operators.RemoveAll(x => x is ISingleObjectiveMoveEvaluator); 319 220 foreach (ITSPPathMoveEvaluator op in ApplicationManager.Manager.GetInstances<ITSPPathMoveEvaluator>()) 320 221 if (op.EvaluatorType == Evaluator.GetType()) { 321 operators.Add(op);222 Operators.Add(op); 322 223 } 323 224 ParameterizeOperators(); … … 400 301 op.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName; 401 302 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;412 303 } 413 304 foreach (IPermutationMultiNeighborhoodShakingOperator op in Operators.OfType<IPermutationMultiNeighborhoodShakingOperator>()) { -
trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/Plugin.cs.frame
r6866 r6938 34 34 [PluginDependency("HeuristicLab.MainForm", "3.3")] 35 35 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")] 36 [PluginDependency("HeuristicLab.Optimization", "3.3")] 36 37 [PluginDependency("HeuristicLab.Parameters", "3.3")] 37 38 [PluginDependency("HeuristicLab.Problems.VehicleRouting", "3.3")] -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs
r6441 r6938 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing;25 24 using System.Linq; 26 25 using HeuristicLab.Common; 27 26 using HeuristicLab.Core; 28 27 using HeuristicLab.Data; 29 using HeuristicLab.Encodings.PermutationEncoding;30 28 using HeuristicLab.Optimization; 31 29 using HeuristicLab.Parameters; … … 40 38 [Creatable("Problems")] 41 39 [StorableClass] 42 public sealed class VehicleRoutingProblem : ParameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent {40 public sealed class VehicleRoutingProblem : SingleObjectiveHeuristicOptimizationProblem<IVRPEvaluator, IVRPCreator>, IStorableContent { 43 41 public string Filename { get; set; } 44 42 45 public override Image ItemImage {46 get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }47 }48 49 43 #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 }56 44 public ValueParameter<DoubleMatrix> CoordinatesParameter { 57 45 get { return (ValueParameter<DoubleMatrix>)Parameters["Coordinates"]; } … … 81 69 get { return (ValueParameter<DoubleArray>)Parameters["ServiceTime"]; } 82 70 } 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 }95 71 public IValueParameter<DoubleValue> FleetUsageFactorParameter { 96 72 get { return (IValueParameter<DoubleValue>)Parameters["EvalFleetUsageFactor"]; } … … 107 83 public IValueParameter<DoubleValue> TardinessPenaltyParameter { 108 84 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; }115 85 } 116 86 public OptionalValueParameter<IVRPEncoding> BestKnownSolutionParameter { … … 156 126 set { ServiceTimeParameter.Value = value; } 157 127 } 158 public DoubleValue BestKnownQuality {159 get { return BestKnownQualityParameter.Value; }160 set { BestKnownQualityParameter.Value = value; }161 }162 128 public IVRPEncoding BestKnownSolution { 163 129 get { return BestKnownSolutionParameter.Value; } 164 130 set { BestKnownSolutionParameter.Value = value; } 165 131 } 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 }186 132 private BestVRPSolutionAnalyzer BestVRPSolutionAnalyzer { 187 get { return operators.OfType<BestVRPSolutionAnalyzer>().FirstOrDefault(); }133 get { return Operators.OfType<BestVRPSolutionAnalyzer>().FirstOrDefault(); } 188 134 } 189 135 private BestAverageWorstVRPToursAnalyzer BestAverageWorstVRPToursAnalyzer { 190 get { return operators.OfType<BestAverageWorstVRPToursAnalyzer>().FirstOrDefault(); }136 get { return Operators.OfType<BestAverageWorstVRPToursAnalyzer>().FirstOrDefault(); } 191 137 } 192 138 #endregion 193 139 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 196 152 197 153 [StorableConstructor] … … 199 155 private VehicleRoutingProblem(VehicleRoutingProblem original, Cloner cloner) 200 156 : base(original, cloner) { 201 operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList();202 157 AttachEventHandlers(); 203 158 } 204 159 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()) { 210 161 Parameters.Add(new ValueParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the cities.", new DoubleMatrix())); 211 162 Parameters.Add(new OptionalValueParameter<DoubleMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities.")); … … 217 168 Parameters.Add(new ValueParameter<DoubleArray>("DueTime", "The due time of each customer.", new DoubleArray())); 218 169 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."));220 170 Parameters.Add(new OptionalValueParameter<IVRPEncoding>("BestKnownSolution", "The best known solution of this VRP instance.")); 221 171 Parameters.Add(new ValueParameter<DoubleValue>("EvalFleetUsageFactor", "The fleet usage factor considered in the evaluation.", new DoubleValue(100))); … … 225 175 Parameters.Add(new ValueParameter<DoubleValue>("EvalTardinessPenalty", "The tardiness penalty considered in the evaluation.", new DoubleValue(100))); 226 176 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"; 232 179 233 180 InitializeRandomVRPInstance(); … … 245 192 246 193 #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) { 268 209 ParameterizeSolutionCreator(); 269 210 } … … 287 228 BestKnownSolution = null; 288 229 } 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 }308 230 private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) { 309 231 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 }316 232 } 317 233 … … 453 369 Vehicles.ValueChanged += new EventHandler(VehiclesValue_ValueChanged); 454 370 455 SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);456 457 EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);458 371 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 459 372 … … 494 407 495 408 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()); 499 411 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)); 501 413 ParameterizeOperators(); 502 414 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 512 415 } 513 416 private void UpdateMoveEvaluators() { -
trunk/sources/HeuristicLab.Tests/HeuristicLab-3.3/SamplesTest.cs
r6930 r6938 85 85 TravelingSalesmanProblem tspProblem = new TravelingSalesmanProblem(); 86 86 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(); 89 89 tspProblem.UseDistanceMatrix.Value = true; 90 90 tspProblem.Name = "ch130 TSP (imported from TSPLIB)"; … … 140 140 vrpProblem.TardinessPenaltyParameter.Value.Value = 100; 141 141 vrpProblem.TimeFactorParameter.Value.Value = 0; 142 vrpProblem.Evaluator = new VRPEvaluator();142 vrpProblem.EvaluatorParameter.Value = new VRPEvaluator(); 143 143 vrpProblem.MaximizationParameter.Value.Value = false; 144 vrpProblem.SolutionCreator = new RandomCreator();144 vrpProblem.SolutionCreatorParameter.Value = new RandomCreator(); 145 145 vrpProblem.UseDistanceMatrix.Value = true; 146 146 vrpProblem.Vehicles.Value = 25; … … 480 480 481 481 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(); 484 484 problem.Maximization.Value = false; 485 485 problem.Bounds = new DoubleMatrix(new double[,] { { -600, 600 } }); … … 533 533 TravelingSalesmanProblem tspProblem = new TravelingSalesmanProblem(); 534 534 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(); 537 537 tspProblem.UseDistanceMatrix.Value = true; 538 538 tspProblem.Name = "ch130 TSP (imported from TSPLIB)"; … … 581 581 #region Problem Configuration 582 582 KnapsackProblem problem = new KnapsackProblem(); 583 problem.BestKnownQuality = new DoubleValue(362);583 problem.BestKnownQuality.Value = 362; 584 584 problem.BestKnownSolution = new HeuristicLab.Encodings.BinaryVectorEncoding.BinaryVector(new bool[] { 585 585 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(); 588 588 problem.KnapsackCapacity.Value = 297; 589 589 problem.Maximization.Value = true; … … 651 651 problem.BestKnownSolutionParameter.Value = new RealVector(new double[] { 420.968746, 420.968746 }); 652 652 problem.Bounds = new DoubleMatrix(new double[,] { { -500, 500 } }); 653 problem.Evaluator = new SchwefelEvaluator();653 problem.EvaluatorParameter.Value = new SchwefelEvaluator(); 654 654 problem.Maximization.Value = false; 655 655 problem.ProblemSize.Value = 2; 656 problem.SolutionCreator = new UniformRandomRealVectorCreator();656 problem.SolutionCreatorParameter.Value = new UniformRandomRealVectorCreator(); 657 657 #endregion 658 658 #region Algorithm Configuration … … 721 721 problem.BestKnownSolutionParameter.Value = new RealVector(new double[] { 0, 0 }); 722 722 problem.Bounds = new DoubleMatrix(new double[,] { { -5.12, 5.12 } }); 723 problem.Evaluator = new RastriginEvaluator();723 problem.EvaluatorParameter.Value = new RastriginEvaluator(); 724 724 problem.Maximization.Value = false; 725 725 problem.ProblemSize.Value = 2; 726 problem.SolutionCreator = new UniformRandomRealVectorCreator();726 problem.SolutionCreatorParameter.Value = new UniformRandomRealVectorCreator(); 727 727 #endregion 728 728 #region Algorithm Configuration … … 788 788 var tspProblem = new TravelingSalesmanProblem(); 789 789 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(); 792 792 tspProblem.UseDistanceMatrix.Value = true; 793 793 tspProblem.Name = "ch130 TSP (imported from TSPLIB)"; … … 870 870 {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} 871 871 }); 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(); 876 876 tspProblem.UseDistanceMatrix.Value = true; 877 877 tspProblem.Name = "Funny TSP";
Note: See TracChangeset
for help on using the changeset viewer.