Changeset 2865
- Timestamp:
- 02/25/10 06:35:43 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 added
- 4 deleted
- 23 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/EngineAlgorithmView.Designer.cs
r2864 r2865 68 68 // problemTabPage 69 69 // 70 this.problemTabPage.Size = new System.Drawing.Size( 482, 148);70 this.problemTabPage.Size = new System.Drawing.Size(648, 252); 71 71 // 72 72 // parameterCollectionView … … 96 96 // 97 97 this.executionTimeLabel.Location = new System.Drawing.Point(430, 440); 98 this.executionTimeLabel.TabIndex = 1 1;98 this.executionTimeLabel.TabIndex = 12; 99 99 // 100 100 // executionTimeTextBox 101 101 // 102 102 this.executionTimeTextBox.Location = new System.Drawing.Point(519, 437); 103 this.executionTimeTextBox.TabIndex = 1 2;103 this.executionTimeTextBox.TabIndex = 13; 104 104 // 105 105 // nameTextBox … … 150 150 this.createUserDefinedAlgorithmButton.Location = new System.Drawing.Point(90, 433); 151 151 this.createUserDefinedAlgorithmButton.Name = "createUserDefinedAlgorithmButton"; 152 this.createUserDefinedAlgorithmButton.Size = new System.Drawing.Size( 161, 24);153 this.createUserDefinedAlgorithmButton.TabIndex = 1 3;152 this.createUserDefinedAlgorithmButton.Size = new System.Drawing.Size(254, 24); 153 this.createUserDefinedAlgorithmButton.TabIndex = 11; 154 154 this.createUserDefinedAlgorithmButton.Text = "&Create User Defined Algorithm"; 155 155 this.toolTip.SetToolTip(this.createUserDefinedAlgorithmButton, "Create User Defined Algorithm from this Algorithm"); -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemView.cs
r2852 r2865 27 27 /// The base class for visual representations of items. 28 28 /// </summary> 29 [Content(typeof(Problem), true)] 30 [Content(typeof(IProblem), false)] 29 [Content(typeof(IProblem), true)] 31 30 public partial class ProblemView : ParameterizedNamedItemView { 32 31 public new IProblem Content { -
trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r2864 r2865 52 52 <None Include="HeuristicLabOptimizationPlugin.cs.frame" /> 53 53 <Compile Include="Algorithm.cs" /> 54 <Compile Include="Interfaces\IMultiObjectiveProblem.cs" /> 55 <Compile Include="Interfaces\IMultiObjectiveEvaluator.cs" /> 54 56 <Compile Include="Interfaces\IAlgorithm.cs" /> 55 <Compile Include="Interfaces\ICrossover Operator.cs" />57 <Compile Include="Interfaces\ICrossover.cs" /> 56 58 <Compile Include="Interfaces\IEvaluator.cs" /> 57 <Compile Include="Interfaces\IManipulat ionOperator.cs" />59 <Compile Include="Interfaces\IManipulator.cs" /> 58 60 <Compile Include="Interfaces\IProblem.cs" /> 59 61 <Compile Include="Interfaces\ISingleObjectiveEvaluator.cs" /> … … 61 63 <Compile Include="Interfaces\ISolutionCreator.cs" /> 62 64 <Compile Include="Interfaces\IStochasticOperator.cs" /> 63 <Compile Include="SingleObjectiveProblem.cs" />64 <Compile Include="SingleObjectiveEvaluator.cs" />65 65 <Compile Include="UserDefinedAlgorithm.cs" /> 66 66 <Compile Include="EngineAlgorithm.cs" /> 67 67 <Compile Include="HeuristicLabOptimizationPlugin.cs" /> 68 <Compile Include="Problem.cs" />69 68 <Compile Include="Properties\AssemblyInfo.cs" /> 70 69 </ItemGroup> -
trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/ICrossover.cs
r2864 r2865 21 21 22 22 using HeuristicLab.Core; 23 using HeuristicLab.Data;24 23 25 24 namespace HeuristicLab.Optimization { … … 27 26 /// An interface which represents an operator for crossing solutions. 28 27 /// </summary> 29 public interface ICrossover Operator: IOperator { }28 public interface ICrossover : IOperator { } 30 29 } -
trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IEvaluator.cs
r2864 r2865 21 21 22 22 using HeuristicLab.Core; 23 using HeuristicLab.Data;24 23 25 24 namespace HeuristicLab.Optimization { -
trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IManipulator.cs
r2864 r2865 21 21 22 22 using HeuristicLab.Core; 23 using HeuristicLab.Data;24 23 25 24 namespace HeuristicLab.Optimization { … … 27 26 /// An interface which represents an operator for manipulating solutions. 28 27 /// </summary> 29 public interface IManipulat ionOperator : IOperator { }28 public interface IManipulator : IOperator { } 30 29 } -
trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IProblem.cs
r2864 r2865 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Core; 23 using System;24 using HeuristicLab.Common;25 24 26 25 namespace HeuristicLab.Optimization { -
trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/ISingleObjectiveProblem.cs
r2864 r2865 20 20 #endregion 21 21 22 using HeuristicLab.Core;22 using System; 23 23 using HeuristicLab.Data; 24 using System;25 24 26 25 namespace HeuristicLab.Optimization { … … 29 28 /// </summary> 30 29 public interface ISingleObjectiveProblem : IProblem { 31 BoolData Maximization { get; set;}32 new ISingleObjectiveEvaluator Evaluator { get; set;}30 BoolData Maximization { get; } 31 new ISingleObjectiveEvaluator Evaluator { get; } 33 32 34 33 event EventHandler MaximizationChanged; -
trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/ISolutionCreator.cs
r2864 r2865 21 21 22 22 using HeuristicLab.Core; 23 using HeuristicLab.Data;24 23 25 24 namespace HeuristicLab.Optimization { -
trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IStochasticOperator.cs
r2864 r2865 21 21 22 22 using HeuristicLab.Core; 23 using HeuristicLab.Data;24 23 25 24 namespace HeuristicLab.Optimization { -
trunk/sources/HeuristicLab.Permutation/3.3/AbsolutePositionTopologicalCrossover.cs
r2854 r2865 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Text;25 23 using HeuristicLab.Core; 26 using HeuristicLab.Data;27 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 25 -
trunk/sources/HeuristicLab.Permutation/3.3/CosaCrossover.cs
r2856 r2865 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Text;25 23 using HeuristicLab.Core; 26 using HeuristicLab.Data;27 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 25 -
trunk/sources/HeuristicLab.Permutation/3.3/EdgeRecombinationCrossover.cs
r2854 r2865 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Text;25 23 using HeuristicLab.Core; 26 using HeuristicLab.Data;27 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 25 -
trunk/sources/HeuristicLab.Permutation/3.3/HeuristicLab.Permutation-3.3.csproj
r2857 r2865 83 83 <None Include="HeuristicLabPermutationPlugin.cs.frame" /> 84 84 <Compile Include="AbsolutePositionTopologicalCrossover.cs" /> 85 <Compile Include="IPermutationCreator.cs" /> 86 <Compile Include="IPermutationOperator.cs" /> 85 87 <Compile Include="CosaCrossover.cs" /> 86 88 <Compile Include="CyclicCrossover.cs" /> … … 90 92 <SubType>Code</SubType> 91 93 </Compile> 92 <Compile Include="IPermutationCrossover Operator.cs" />93 <Compile Include="IPermutationManipulat ionOperator.cs" />94 <Compile Include="IPermutationCrossover.cs" /> 95 <Compile Include="IPermutationManipulator.cs" /> 94 96 <Compile Include="MaximalPreservativeCrossover.cs" /> 95 97 <Compile Include="OrderBasedCrossover.cs" /> -
trunk/sources/HeuristicLab.Permutation/3.3/IPermutationCrossover.cs
r2862 r2865 21 21 22 22 using HeuristicLab.Core; 23 using HeuristicLab.Data;24 23 using HeuristicLab.Optimization; 25 24 … … 28 27 /// An interface which represents an operator for crossing permutations. 29 28 /// </summary> 30 public interface IPermutationCrossoverOperator : ICrossoverOperator { } 29 public interface IPermutationCrossover : IPermutationOperator, ICrossover { 30 ILookupParameter<ItemArray<Permutation>> ParentsParameter { get; } 31 ILookupParameter<Permutation> ChildParameter { get; } 32 } 31 33 } -
trunk/sources/HeuristicLab.Permutation/3.3/IPermutationManipulator.cs
r2862 r2865 21 21 22 22 using HeuristicLab.Core; 23 using HeuristicLab.Data;24 23 using HeuristicLab.Optimization; 25 24 … … 28 27 /// An interface which represents an operator for manipulating solutions. 29 28 /// </summary> 30 public interface IPermutationManipulationOperator : IManipulationOperator { } 29 public interface IPermutationManipulator : IPermutationOperator, IManipulator { 30 ILookupParameter<Permutation> PermutationParameter { get; } 31 } 31 32 } -
trunk/sources/HeuristicLab.Permutation/3.3/InsertionManipulator.cs
r2854 r2865 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Text;25 22 using HeuristicLab.Core; 26 23 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; -
trunk/sources/HeuristicLab.Permutation/3.3/OrderBasedCrossover.cs
r2854 r2865 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Text;25 23 using HeuristicLab.Core; 26 using HeuristicLab.Data;27 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 25 -
trunk/sources/HeuristicLab.Permutation/3.3/PermutationCrossover.cs
r2857 r2865 32 32 [Item("PermutationCrossover", "A base class for permutation crossover operators.")] 33 33 [EmptyStorableClass] 34 public abstract class PermutationCrossover : SingleSuccessorOperator, IPermutationCrossover Operator {34 public abstract class PermutationCrossover : SingleSuccessorOperator, IPermutationCrossover, IStochasticOperator { 35 35 public ILookupParameter<IRandom> RandomParameter { 36 36 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 37 37 } 38 public SubScopesLookupParameter<Permutation> ParentsParameter {38 public ILookupParameter<ItemArray<Permutation>> ParentsParameter { 39 39 get { return (SubScopesLookupParameter<Permutation>)Parameters["Parents"]; } 40 40 } 41 public LookupParameter<Permutation> ChildParameter {42 get { return ( LookupParameter<Permutation>)Parameters["Child"]; }41 public ILookupParameter<Permutation> ChildParameter { 42 get { return (ILookupParameter<Permutation>)Parameters["Child"]; } 43 43 } 44 44 -
trunk/sources/HeuristicLab.Permutation/3.3/PermutationManipulator.cs
r2857 r2865 32 32 [Item("PermutationManipulator", "A base class for permutation manipulation operators.")] 33 33 [EmptyStorableClass] 34 public abstract class PermutationManipulator : SingleSuccessorOperator, IPermutationManipulat ionOperator {34 public abstract class PermutationManipulator : SingleSuccessorOperator, IPermutationManipulator, IStochasticOperator { 35 35 public ILookupParameter<IRandom> RandomParameter { 36 36 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 37 37 } 38 public LookupParameter<Permutation> PermutationParameter {39 get { return ( LookupParameter<Permutation>)Parameters["Permutation"]; }38 public ILookupParameter<Permutation> PermutationParameter { 39 get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; } 40 40 } 41 41 -
trunk/sources/HeuristicLab.Permutation/3.3/RandomPermutationCreator.cs
r2852 r2865 34 34 [EmptyStorableClass] 35 35 [Creatable("Test")] 36 public sealed class RandomPermutationCreator : SingleSuccessorOperator, I SolutionCreator {36 public sealed class RandomPermutationCreator : SingleSuccessorOperator, IPermutationCreator, IStochasticOperator { 37 37 public ILookupParameter<IRandom> RandomParameter { 38 38 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 39 39 } 40 public ValueLookupParameter<IntData> LengthParameter {41 get { return ( ValueLookupParameter<IntData>)Parameters["Length"]; }40 public IValueLookupParameter<IntData> LengthParameter { 41 get { return (IValueLookupParameter<IntData>)Parameters["Length"]; } 42 42 } 43 public LookupParameter<Permutation> PermutationParameter {44 get { return ( LookupParameter<Permutation>)Parameters["Permutation"]; }43 public ILookupParameter<Permutation> PermutationParameter { 44 get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; } 45 45 } 46 46 -
trunk/sources/HeuristicLab.Routing.TSP/3.3/HeuristicLab.Routing.TSP-3.3.csproj
r2834 r2865 80 80 </Reference> 81 81 <Reference Include="System.Data" /> 82 <Reference Include="System.Drawing" /> 82 83 <Reference Include="System.Xml" /> 83 84 </ItemGroup> 84 85 <ItemGroup> 85 86 <None Include="HeuristicLabRoutingTSPPlugin.cs.frame" /> 87 <Compile Include="TSPEvaluator.cs" /> 88 <Compile Include="ITSPEvaluator.cs" /> 86 89 <Compile Include="TSPDistanceMatrixPathEvaluator.cs" /> 87 90 <Compile Include="TSPLIBParser.cs" /> … … 96 99 <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project> 97 100 <Name>HeuristicLab.Collections-3.3</Name> 101 </ProjectReference> 102 <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.2\HeuristicLab.Common.Resources-3.2.csproj"> 103 <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project> 104 <Name>HeuristicLab.Common.Resources-3.2</Name> 98 105 </ProjectReference> 99 106 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj"> -
trunk/sources/HeuristicLab.Routing.TSP/3.3/HeuristicLabRoutingTSPPlugin.cs.frame
r2834 r2865 29 29 [PluginFile("HeuristicLab.Routing.TSP-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Collections", "3.3")] 31 [PluginDependency("HeuristicLab.Common.Resources", "3.2")] 31 32 [PluginDependency("HeuristicLab.Core", "3.3")] 32 33 [PluginDependency("HeuristicLab.Data", "3.3")] -
trunk/sources/HeuristicLab.Routing.TSP/3.3/TSP.cs
r2857 r2865 20 20 #endregion 21 21 22 using System; 23 using System.Drawing; 24 using System.Linq; 22 25 using HeuristicLab.Core; 23 26 using HeuristicLab.Data; … … 26 29 using HeuristicLab.Permutation; 27 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using System;31 using HeuristicLab.PluginInfrastructure; 29 32 30 33 namespace HeuristicLab.Routing.TSP { … … 32 35 [Creatable("Problems")] 33 36 [EmptyStorableClass] 34 public sealed class TSP : SingleObjectiveProblem {35 p rivate ValueParameter<DoubleMatrixData> CoordinatesParameter{36 get { return (ValueParameter<DoubleMatrixData>)Parameters["Coordinates"]; }37 public sealed class TSP : ParameterizedNamedItem, ISingleObjectiveProblem { 38 public override Image ItemImage { 39 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Type; } 37 40 } 38 41 39 public DoubleMatrixData Coordinates { 40 get { return CoordinatesParameter.Value; } 41 set { CoordinatesParameter.Value = value; } 42 private IValueParameter<BoolData> MaximizationParameter { 43 get { return (IValueParameter<BoolData>)Parameters["Maximization"]; } 44 } 45 public IValueParameter<DoubleMatrixData> CoordinatesParameter { 46 get { return (IValueParameter<DoubleMatrixData>)Parameters["Coordinates"]; } 47 } 48 public IValueParameter<DoubleData> BestKnownQualityParameter { 49 get { return (IValueParameter<DoubleData>)Parameters["BestKnownQuality"]; } 50 } 51 public IValueParameter<IPermutationCreator> SolutionCreatorParameter { 52 get { return (IValueParameter<IPermutationCreator>)Parameters["SolutionCreator"]; } 53 } 54 public IValueParameter<ITSPEvaluator> EvaluatorParameter { 55 get { return (IValueParameter<ITSPEvaluator>)Parameters["Evaluator"]; } 56 } 57 58 public BoolData Maximization { 59 get { return MaximizationParameter.Value; } 60 } 61 public ISolutionCreator SolutionCreator { 62 get { return SolutionCreatorParameter.Value; } 63 } 64 public ISingleObjectiveEvaluator Evaluator { 65 get { return EvaluatorParameter.Value; } 66 } 67 IEvaluator IProblem.Evaluator { 68 get { return EvaluatorParameter.Value; } 69 } 70 private OperatorSet operators; 71 public OperatorSet Operators { 72 get { return operators; } 42 73 } 43 74 44 75 public TSP() 45 76 : base() { 46 Maximization = new BoolData(false); 77 ValueParameter<BoolData> maximizationParameter = new ValueParameter<BoolData>("Maximization", "Set to false as the Traveling Salesman Problem is a minimization problem.", new BoolData(false)); 78 maximizationParameter.ValueChanged += new EventHandler(MaximizationParameter_ValueChanged); 79 Parameters.Add(maximizationParameter); 80 47 81 Parameters.Add(new ValueParameter<DoubleMatrixData>("Coordinates", "The x- and y-Coordinates of the cities.", new DoubleMatrixData(0, 0))); 82 83 ValueParameter<IPermutationCreator> solutionCreatorParameter = new ValueParameter<IPermutationCreator>("SolutionCreator", "The operator which should be used to create new TSP solutions."); 84 solutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged); 85 Parameters.Add(solutionCreatorParameter); 86 87 ValueParameter<ITSPEvaluator> evaluatorParameter = new ValueParameter<ITSPEvaluator>("Evaluator", "The operator which should be used to evaluate TSP solutions."); 88 evaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged); 89 Parameters.Add(evaluatorParameter); 90 48 91 Parameters.Add(new ValueParameter<DoubleData>("BestKnownQuality", "The quality of the best known solution of this TSP instance.")); 92 49 93 RandomPermutationCreator creator = new RandomPermutationCreator(); 94 creator.PermutationParameter.ActualName = "TSPTour"; 50 95 creator.LengthParameter.Value = new IntData(0); 51 SolutionCreator = creator; 52 Evaluator = new TSPRoundedEuclideanPathEvaluator(); 96 SolutionCreatorParameter.Value = creator; 97 TSPRoundedEuclideanPathEvaluator evaluator = new TSPRoundedEuclideanPathEvaluator(); 98 evaluator.CoordinatesParameter.ActualName = CoordinatesParameter.Name; 99 evaluator.PermutationParameter.ActualName = creator.PermutationParameter.ActualName; 100 evaluator.QualityParameter.ActualName = "TSPTourLength"; 101 EvaluatorParameter.Value = evaluator; 102 103 operators = new OperatorSet(); 104 var crossovers = ApplicationManager.Manager.GetInstances<IPermutationCrossover>().ToList(); 105 crossovers.ForEach(x => { 106 x.ParentsParameter.ActualName = creator.PermutationParameter.ActualName; 107 x.ChildParameter.ActualName = creator.PermutationParameter.ActualName; 108 }); 109 var manipulators = ApplicationManager.Manager.GetInstances<IPermutationManipulator>().ToList(); 110 manipulators.ForEach(x => x.PermutationParameter.ActualName = creator.PermutationParameter.ActualName); 111 operators = new OperatorSet(crossovers.Cast<IOperator>().Concat(manipulators.Cast<IOperator>())); 53 112 } 54 113 … … 56 115 TSPLIBParser parser = new TSPLIBParser(filename); 57 116 parser.Parse(); 58 Coordinates = new DoubleMatrixData(parser.Vertices); 59 int cities = Coordinates.Rows; 60 RandomPermutationCreator creator = new RandomPermutationCreator(); 61 creator.LengthParameter.Value = new IntData(cities); 62 SolutionCreator = creator; 63 TSPRoundedEuclideanPathEvaluator evaluator = new TSPRoundedEuclideanPathEvaluator(); 64 Evaluator = evaluator; 117 CoordinatesParameter.Value = new DoubleMatrixData(parser.Vertices); 118 int cities = CoordinatesParameter.Value.Rows; 119 SolutionCreatorParameter.Value.LengthParameter.Value = new IntData(cities); 120 } 121 122 private void MaximizationParameter_ValueChanged(object sender, EventArgs e) { 123 OnMaximizationChanged(); 124 } 125 private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) { 126 OnSolutionCreatorChanged(); 127 } 128 private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) { 129 OnEvaluatorChanged(); 130 } 131 132 public event EventHandler MaximizationChanged; 133 private void OnMaximizationChanged() { 134 if (MaximizationChanged != null) 135 MaximizationChanged(this, EventArgs.Empty); 136 } 137 public event EventHandler SolutionCreatorChanged; 138 private void OnSolutionCreatorChanged() { 139 if (SolutionCreatorChanged != null) 140 SolutionCreatorChanged(this, EventArgs.Empty); 141 } 142 public event EventHandler EvaluatorChanged; 143 private void OnEvaluatorChanged() { 144 if (EvaluatorChanged != null) 145 EvaluatorChanged(this, EventArgs.Empty); 65 146 } 66 147 } -
trunk/sources/HeuristicLab.Routing.TSP/3.3/TSPDistanceMatrixPathEvaluator.cs
r2834 r2865 22 22 using HeuristicLab.Core; 23 23 using HeuristicLab.Data; 24 using HeuristicLab.Operators;25 24 using HeuristicLab.Parameters; 26 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 33 32 [Creatable("Test")] 34 33 [EmptyStorableClass] 35 public sealed class TSPDistanceMatrixPathEvaluator : SingleSuccessorOperator {34 public sealed class TSPDistanceMatrixPathEvaluator : TSPEvaluator { 36 35 public LookupParameter<DoubleMatrixData> DistanceMatrixParameter { 37 36 get { return (LookupParameter<DoubleMatrixData>)Parameters["DistanceMatrix"]; } … … 40 39 get { return (LookupParameter<Permutation.Permutation>)Parameters["Permutation"]; } 41 40 } 42 public LookupParameter<DoubleData> QualityParameter {43 get { return (LookupParameter<DoubleData>)Parameters["Quality"]; }44 }45 41 46 42 public TSPDistanceMatrixPathEvaluator() … … 48 44 Parameters.Add(new LookupParameter<DoubleMatrixData>("DistanceMatrix", "The distance matrix of the cities.")); 49 45 Parameters.Add(new LookupParameter<Permutation.Permutation>("Permutation", "The TSP solution given in path representation which should be evaluated.")); 50 Parameters.Add(new LookupParameter<DoubleData>("Quality", "The evaluated quality of the given TSP solution."));51 46 } 52 47 -
trunk/sources/HeuristicLab.Routing.TSP/3.3/TSPPathEvaluator.cs
r2852 r2865 22 22 using HeuristicLab.Core; 23 23 using HeuristicLab.Data; 24 using HeuristicLab.Optimization;25 24 using HeuristicLab.Parameters; 26 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 32 31 [Item("TSPPathEvaluator", "A base class for operators which evaluate TSP solutions given in path representation.")] 33 32 [EmptyStorableClass] 34 public abstract class TSPPathEvaluator : SingleObjectiveEvaluator {33 public abstract class TSPPathEvaluator : TSPEvaluator { 35 34 public LookupParameter<DoubleMatrixData> CoordinatesParameter { 36 35 get { return (LookupParameter<DoubleMatrixData>)Parameters["Coordinates"]; } -
trunk/sources/HeuristicLab.SGA/3.3/SGA.cs
r2864 r2865 20 20 #endregion 21 21 22 using System; 23 using System.Linq; 22 24 using HeuristicLab.Core; 23 25 using HeuristicLab.Data; … … 27 29 using HeuristicLab.Parameters; 28 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using System;30 31 31 32 namespace HeuristicLab.SGA { … … 40 41 [Storable] 41 42 private SGAOperator sgaOperator; 43 44 private ConstrainedValueParameter<ICrossover> CrossoverOperatorParameter { 45 get { return (ConstrainedValueParameter<ICrossover>)Parameters["CrossoverOperator"]; } 46 } 47 private ConstrainedValueParameter<IManipulator> MutationOperatorParameter { 48 get { return (ConstrainedValueParameter<IManipulator>)Parameters["MutationOperator"]; } 49 } 42 50 43 51 public override Type ProblemType { … … 54 62 Parameters.Add(new ValueParameter<BoolData>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolData(true))); 55 63 Parameters.Add(new ValueParameter<IntData>("PopulationSize", "The size of the population of solutions.", new IntData(100))); 56 Parameters.Add(new OperatorParameter("CrossoverOperator", "The operator used to cross solutions."));64 Parameters.Add(new ConstrainedValueParameter<ICrossover>("CrossoverOperator", "The operator used to cross solutions.")); 57 65 Parameters.Add(new ValueParameter<DoubleData>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new DoubleData(0.05))); 58 Parameters.Add(new OperatorParameter("MutationOperator", "The operator used to mutate solutions."));66 Parameters.Add(new ConstrainedValueParameter<IManipulator>("MutationOperator", "The operator used to mutate solutions.")); 59 67 Parameters.Add(new ValueParameter<IntData>("Elites", "The numer of elite solutions which are kept in each generation.", new IntData(1))); 60 68 Parameters.Add(new ValueParameter<IntData>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntData(1000))); … … 103 111 protected override void OnProblemChanged() { 104 112 if (Problem.SolutionCreator is IStochasticOperator) ((IStochasticOperator)Problem.SolutionCreator).RandomParameter.ActualName = "Random"; 113 if (Problem.Evaluator is IStochasticOperator) ((IStochasticOperator)Problem.Evaluator).RandomParameter.ActualName = "Random"; 114 Problem.Operators.Where(x => x is IStochasticOperator).Select(x => (x as IStochasticOperator).RandomParameter.ActualName = "Random"); 115 105 116 populationCreator.SolutionCreatorParameter.Value = Problem.SolutionCreator; 106 117 populationCreator.SolutionEvaluatorParameter.Value = Problem.Evaluator; 107 118 sgaOperator.MaximizationParameter.Value = Problem.Maximization; 108 sgaOperator.QualityParameter.ActualName = Problem.Evaluator.QualityParameter. Name;119 sgaOperator.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 109 120 sgaOperator.SolutionEvaluatorParameter.Value = Problem.Evaluator; 121 122 CrossoverOperatorParameter.ValidValues.Clear(); 123 var crossovers = from o in Problem.Operators 124 where o is ICrossover 125 select (ICrossover)o; 126 foreach (ICrossover crossover in crossovers) 127 CrossoverOperatorParameter.ValidValues.Add(crossover); 128 129 MutationOperatorParameter.ValidValues.Clear(); 130 var mutators = from o in Problem.Operators 131 where o is IManipulator 132 select (IManipulator)o; 133 foreach (IManipulator mutator in mutators) 134 MutationOperatorParameter.ValidValues.Add(mutator); 135 110 136 base.OnProblemChanged(); 111 137 } … … 116 142 } 117 143 protected override void Problem_EvaluatorChanged(object sender, EventArgs e) { 144 if (Problem.Evaluator is IStochasticOperator) ((IStochasticOperator)Problem.Evaluator).RandomParameter.ActualName = "Random"; 118 145 populationCreator.SolutionEvaluatorParameter.Value = Problem.Evaluator; 119 sgaOperator.QualityParameter.ActualName = Problem.Evaluator.QualityParameter. Name;146 sgaOperator.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 120 147 sgaOperator.SolutionEvaluatorParameter.Value = Problem.Evaluator; 121 148 base.Problem_EvaluatorChanged(sender, e);
Note: See TracChangeset
for help on using the changeset viewer.