Changeset 16948
- Timestamp:
- 05/13/19 15:21:54 (6 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 4 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorMultiObjectiveProblem.cs
r16876 r16948 28 28 using HeuristicLab.Common; 29 29 using HeuristicLab.Core; 30 using HeuristicLab.Data;31 30 using HeuristicLab.Optimization; 32 using HeuristicLab.Parameters;33 31 34 32 namespace HeuristicLab.Encodings.BinaryVectorEncoding { … … 38 36 get { return Encoding.Length; } 39 37 set { Encoding.Length = value; } 40 }41 42 private IFixedValueParameter<IntValue> LengthParameter {43 get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }44 38 } 45 39 … … 56 50 } 57 51 58 protected BinaryVectorMultiObjectiveProblem() : base(new BinaryVectorEncoding()) { 59 var lengthParameter = new FixedValueParameter<IntValue>("Length", "The length of the BinaryVector.", new IntValue(10)); 60 Parameters.Add(lengthParameter); 61 Encoding.LengthParameter = lengthParameter; 52 protected BinaryVectorMultiObjectiveProblem() : this(new BinaryVectorEncoding() { Length = 10 }) { } 53 protected BinaryVectorMultiObjectiveProblem(BinaryVectorEncoding encoding) : base(encoding) { 54 EncodingParameter.ReadOnly = true; 62 55 63 56 Operators.Add(new HammingSimilarityCalculator()); … … 75 68 protected override void OnEncodingChanged() { 76 69 base.OnEncodingChanged(); 77 Encoding.LengthParameter = LengthParameter;78 70 Parameterize(); 79 71 } … … 87 79 88 80 private void RegisterEventHandlers() { 89 LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged;81 Encoding.LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged; 90 82 } 91 83 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorProblem.cs
r16814 r16948 28 28 using HeuristicLab.Common; 29 29 using HeuristicLab.Core; 30 using HeuristicLab.Data;31 30 using HeuristicLab.Optimization; 32 31 using HeuristicLab.Optimization.Operators; 33 using HeuristicLab.Parameters;34 32 35 33 namespace HeuristicLab.Encodings.BinaryVectorEncoding { … … 39 37 get { return Encoding.Length; } 40 38 set { Encoding.Length = value; } 41 }42 43 private IFixedValueParameter<IntValue> LengthParameter {44 get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }45 39 } 46 40 … … 57 51 } 58 52 59 protected BinaryVectorProblem() : base(new BinaryVectorEncoding()) { 60 var lengthParameter = new FixedValueParameter<IntValue>("Length", "The length of the BinaryVector.", new IntValue(10)); 61 Parameters.Add(lengthParameter); 62 Encoding.LengthParameter = lengthParameter; 53 protected BinaryVectorProblem() : this(new BinaryVectorEncoding() { Length = 10 }) { } 54 protected BinaryVectorProblem(BinaryVectorEncoding encoding) : base(encoding) { 55 EncodingParameter.ReadOnly = true; 63 56 64 57 Operators.Add(new HammingSimilarityCalculator()); … … 75 68 var best = Maximization ? orderedIndividuals.Last().Individual : orderedIndividuals.First().Individual; 76 69 77 if (!results.ContainsKey("Best Solution")) { 78 results.Add(new Result("Best Solution", typeof(BinaryVector))); 79 } 80 results["Best Solution"].Value = (IItem)best.Clone(); 70 results.AddOrUpdateResult("Best Solution", (IItem)best.Clone()); 81 71 } 82 72 83 73 protected override void OnEncodingChanged() { 84 74 base.OnEncodingChanged(); 85 Encoding.LengthParameter = LengthParameter;86 75 Parameterize(); 87 76 } … … 95 84 96 85 private void RegisterEventHandlers() { 97 LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged;86 Encoding.LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged; 98 87 } 99 88 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorMultiObjectiveProblem.cs
r16876 r16948 28 28 using HeuristicLab.Common; 29 29 using HeuristicLab.Core; 30 using HeuristicLab.Data;31 30 using HeuristicLab.Optimization; 32 using HeuristicLab.Parameters;33 31 34 32 namespace HeuristicLab.Encodings.IntegerVectorEncoding { … … 38 36 get { return Encoding.Length; } 39 37 set { Encoding.Length = value; } 40 }41 42 private IFixedValueParameter<IntValue> LengthParameter {43 get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }44 38 } 45 39 … … 56 50 } 57 51 58 protected IntegerVectorMultiObjectiveProblem() : base(new IntegerVectorEncoding()) { 59 var lengthParameter = new FixedValueParameter<IntValue>("Length", "The length of the IntegerVector.", new IntValue(10)); 60 Parameters.Add(lengthParameter); 61 Encoding.LengthParameter = lengthParameter; 52 protected IntegerVectorMultiObjectiveProblem() : this(new IntegerVectorEncoding() { Length = 10 }) { } 53 protected IntegerVectorMultiObjectiveProblem(IntegerVectorEncoding encoding) : base(encoding) { 54 EncodingParameter.ReadOnly = true; 62 55 63 56 Operators.Add(new HammingSimilarityCalculator()); … … 75 68 protected override void OnEncodingChanged() { 76 69 base.OnEncodingChanged(); 77 Encoding.LengthParameter = LengthParameter;78 70 Parameterize(); 79 71 } … … 87 79 88 80 private void RegisterEventHandlers() { 89 LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged;81 Encoding.LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged; 90 82 } 91 83 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorProblem.cs
r16876 r16948 28 28 using HeuristicLab.Common; 29 29 using HeuristicLab.Core; 30 using HeuristicLab.Data;31 30 using HeuristicLab.Optimization; 32 31 using HeuristicLab.Optimization.Operators; 33 using HeuristicLab.Parameters;34 32 35 33 namespace HeuristicLab.Encodings.IntegerVectorEncoding { … … 39 37 get { return Encoding.Length; } 40 38 set { Encoding.Length = value; } 41 }42 43 private IFixedValueParameter<IntValue> LengthParameter {44 get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }45 39 } 46 40 … … 57 51 } 58 52 59 protected IntegerVectorProblem() : base(new IntegerVectorEncoding()) { 60 var lengthParameter = new FixedValueParameter<IntValue>("Length", "The length of the IntegerVector.", new IntValue(10)); 61 Parameters.Add(lengthParameter); 62 Encoding.LengthParameter = lengthParameter; 53 protected IntegerVectorProblem() : this(new IntegerVectorEncoding() { Length = 10 }) { } 54 protected IntegerVectorProblem(IntegerVectorEncoding encoding) : base(encoding) { 55 EncodingParameter.ReadOnly = true; 63 56 64 57 Operators.Add(new HammingSimilarityCalculator()); … … 75 68 var best = Maximization ? orderedIndividuals.Last().Individual : orderedIndividuals.First().Individual; 76 69 77 if (!results.ContainsKey("Best Solution")) { 78 results.Add(new Result("Best Solution", typeof(IntegerVector))); 79 } 80 results["Best Solution"].Value = (IItem)best.Clone(); 70 results.AddOrUpdateResult("Best Solution", (IItem)best.Clone()); 81 71 } 82 72 83 73 protected override void OnEncodingChanged() { 84 74 base.OnEncodingChanged(); 85 Encoding.LengthParameter = LengthParameter;86 75 Parameterize(); 87 76 } … … 95 84 96 85 private void RegisterEventHandlers() { 97 LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged;86 Encoding.LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged; 98 87 } 99 88 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/HeuristicLab.Encodings.LinearLinkageEncoding-3.4.csproj
r16723 r16948 88 88 </PropertyGroup> 89 89 <ItemGroup> 90 <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj"> 91 <Project>{887425b4-4348-49ed-a457-b7d2c26ddbf9}</Project> 92 <Name>HeuristicLab.Analysis-3.3</Name> 93 <Private>False</Private> 94 </ProjectReference> 90 95 <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj"> 91 96 <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project> … … 164 169 <Compile Include="Crossovers\MultiLLECrossover.cs" /> 165 170 <Compile Include="Crossovers\SinglePointCrossover.cs" /> 171 <Compile Include="LinearLinkageMultiObjectiveProblem.cs" /> 172 <Compile Include="LinearLinkageProblem.cs" /> 166 173 <Compile Include="Interfaces\ILinearLinkageMoveOperator.cs" /> 167 174 <Compile Include="Interfaces\ILinearLinkageEMSSMoveOperator.cs" /> -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/HeuristicLab.Encodings.PermutationEncoding-3.3.csproj
r16723 r16948 115 115 </ItemGroup> 116 116 <ItemGroup> 117 <Compile Include="PermutationMultiObjectiveProblem.cs" /> 118 <Compile Include="PermutationProblem.cs" /> 117 119 <Compile Include="Creators\RandomPermutationCreator.cs" /> 118 120 <Compile Include="Crossovers\CosaCrossover.cs" /> … … 218 220 </ItemGroup> 219 221 <ItemGroup> 222 <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj"> 223 <Project>{887425b4-4348-49ed-a457-b7d2c26ddbf9}</Project> 224 <Name>HeuristicLab.Analysis-3.3</Name> 225 <Private>False</Private> 226 </ProjectReference> 220 227 <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj"> 221 228 <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project> -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Problem.cs
r16946 r16948 96 96 protected Problem() 97 97 : base() { 98 Parameters.Add(new ValueParameter<TEncoding>("Encoding", "Describes the configuration of the encoding, what the variables are called, what type they are and their bounds if any.") );99 Parameters.Add(new ValueParameter<TEvaluator>("Evaluator", "The operator used to evaluate a solution.") );100 98 Parameters.Add(new ValueParameter<TEncoding>("Encoding", "Describes the configuration of the encoding, what the variables are called, what type they are and their bounds if any.") { Hidden = true }); 99 Parameters.Add(new ValueParameter<TEvaluator>("Evaluator", "The operator used to evaluate a solution.") { Hidden = true }); 100 101 101 if (Encoding != null) { 102 102 oldEncoding = Encoding; … … 107 107 protected Problem(TEncoding encoding) { 108 108 if (encoding == null) throw new ArgumentNullException("encoding"); 109 Parameters.Add(new ValueParameter<TEncoding>("Encoding", "Describes the configuration of the encoding, what the variables are called, what type they are and their bounds if any.", encoding) );110 Parameters.Add(new ValueParameter<TEvaluator>("Evaluator", "The operator used to evaluate a solution.") );109 Parameters.Add(new ValueParameter<TEncoding>("Encoding", "Describes the configuration of the encoding, what the variables are called, what type they are and their bounds if any.", encoding) { Hidden = true }); 110 Parameters.Add(new ValueParameter<TEvaluator>("Evaluator", "The operator used to evaluate a solution.") { Hidden = true }); 111 111 112 112 oldEncoding = Encoding; -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GraphColoring/3.3/GraphColoringProblem.cs
r16808 r16948 39 39 [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 135)] 40 40 [StorableType("007BD5F0-196C-4045-AC5D-BF287927C3DC")] 41 public sealed class GraphColoringProblem : SingleObjectiveProblem<LinearLinkageEncoding, LinearLinkage>,41 public sealed class GraphColoringProblem : LinearLinkageProblem, 42 42 IProblemInstanceConsumer<GCPData>, IProblemInstanceExporter<GCPData> { 43 43 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs
r16723 r16948 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Analysis; 26 27 using HeuristicLab.Common; … … 31 32 using HeuristicLab.Optimization.Operators; 32 33 using HeuristicLab.Parameters; 33 using HEAL.Attic;34 34 35 35 namespace HeuristicLab.Problems.Knapsack { … … 37 37 [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 200)] 38 38 [StorableType("8CEDAFA2-6E0A-4D4B-B6C6-F85CC58B824E")] 39 public sealed class KnapsackProblem : SingleObjectiveProblem<BinaryVectorEncoding, BinaryVector>{39 public sealed class KnapsackProblem : BinaryVectorProblem { 40 40 public override bool Maximization { get { return true; } } 41 41 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs
r16723 r16948 24 24 using System.Drawing; 25 25 using System.Linq; 26 using HEAL.Attic; 26 27 using HeuristicLab.Analysis; 27 28 using HeuristicLab.Common; … … 32 33 using HeuristicLab.Optimization.Operators; 33 34 using HeuristicLab.Parameters; 34 using HEAL.Attic;35 35 using HeuristicLab.PluginInfrastructure; 36 36 using HeuristicLab.Problems.Instances; … … 40 40 [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 140)] 41 41 [StorableType("A86B1F49-D8E6-45E4-8EFB-8F5CCA2F9DC7")] 42 public sealed class QuadraticAssignmentProblem : SingleObjectiveProblem<PermutationEncoding, Permutation>,42 public sealed class QuadraticAssignmentProblem : PermutationProblem, 43 43 IProblemInstanceConsumer<QAPData>, 44 44 IProblemInstanceConsumer<TSPData> {
Note: See TracChangeset
for help on using the changeset viewer.