- Timestamp:
- 02/16/10 06:50:14 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 8 added
- 11 deleted
- 19 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab 3.3.sln
r2803 r2805 76 76 {958B43BC-CC5C-4FA2-8628-2B3B01D890B6} = {958B43BC-CC5C-4FA2-8628-2B3B01D890B6} 77 77 {AB687BBE-1BFE-476B-906D-44237135431D} = {AB687BBE-1BFE-476B-906D-44237135431D} 78 {DF2E61C4-A76D-4315-9D0B-53A077B1AC2C} = {DF2E61C4-A76D-4315-9D0B-53A077B1AC2C} 78 79 {102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B} = {102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B} 79 80 {EE2034D9-6E27-48A1-B855-42D45F69A4FC} = {EE2034D9-6E27-48A1-B855-42D45F69A4FC} … … 145 146 EndProject 146 147 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.SharpDevelop-3.1.1.5327", "HeuristicLab.ExtLibs\HeuristicLab.SharpDevelop\3.1.1.5327\HeuristicLab.SharpDevelop-3.1.1.5327.csproj", "{4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}" 148 EndProject 149 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Routing.TSP.Views-3.3", "HeuristicLab.Routing.TSP.Views\3.3\HeuristicLab.Routing.TSP.Views-3.3.csproj", "{DF2E61C4-A76D-4315-9D0B-53A077B1AC2C}" 147 150 EndProject 148 151 Global … … 638 641 {4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}.Release|x86.ActiveCfg = Release|x86 639 642 {4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}.Release|x86.Build.0 = Release|x86 643 {DF2E61C4-A76D-4315-9D0B-53A077B1AC2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 644 {DF2E61C4-A76D-4315-9D0B-53A077B1AC2C}.Debug|Any CPU.Build.0 = Debug|Any CPU 645 {DF2E61C4-A76D-4315-9D0B-53A077B1AC2C}.Debug|x64.ActiveCfg = Debug|Any CPU 646 {DF2E61C4-A76D-4315-9D0B-53A077B1AC2C}.Debug|x86.ActiveCfg = Debug|Any CPU 647 {DF2E61C4-A76D-4315-9D0B-53A077B1AC2C}.Release|Any CPU.ActiveCfg = Release|Any CPU 648 {DF2E61C4-A76D-4315-9D0B-53A077B1AC2C}.Release|Any CPU.Build.0 = Release|Any CPU 649 {DF2E61C4-A76D-4315-9D0B-53A077B1AC2C}.Release|x64.ActiveCfg = Release|Any CPU 650 {DF2E61C4-A76D-4315-9D0B-53A077B1AC2C}.Release|x86.ActiveCfg = Release|Any CPU 640 651 EndGlobalSection 641 652 GlobalSection(SolutionProperties) = preSolution -
trunk/sources/HeuristicLab 3.3/Files.txt
r2801 r2805 50 50 HeuristicLab.ExtLibs\HeuristicLab.Netron\3.0.2672.12446\HeuristicLab.Netron-3.0.2672.12446:Netron.Diagramming.Core License.txt 51 51 52 HeuristicLab.ExtLibs\HeuristicLab.WinFormsUI\2.3.1\WinFormsUI-2.3.1:WeifenLuo.WinFormsUI.Docking-2.3.1.dll53 HeuristicLab.ExtLibs\HeuristicLab.WinFormsUI\2.3.1\HeuristicLab.WinFormsUI-2.3.1:HeuristicLab.WinFormsUI-2.3.1.dll54 HeuristicLab.ExtLibs\HeuristicLab.WinFormsUI\2.3.1\HeuristicLab.WinFormsUI-2.3.1:WeifenLuo.WinFormsUI.Docking License.txt55 56 52 HeuristicLab.ExtLibs\HeuristicLab.SharpDevelop\3.1.1.5327:HeuristicLab.SharpDevelop-3.1.1.5327.dll 57 53 HeuristicLab.ExtLibs\HeuristicLab.SharpDevelop\3.1.1.5327:ICSharpCode.NRefactory.dll … … 61 57 HeuristicLab.ExtLibs\HeuristicLab.SharpDevelop\3.1.1.5327:Mono License.txt 62 58 HeuristicLab.ExtLibs\HeuristicLab.SharpDevelop\3.1.1.5327:SharpDevelop License.txt 59 60 HeuristicLab.ExtLibs\HeuristicLab.WinFormsUI\2.3.1\WinFormsUI-2.3.1:WeifenLuo.WinFormsUI.Docking-2.3.1.dll 61 HeuristicLab.ExtLibs\HeuristicLab.WinFormsUI\2.3.1\HeuristicLab.WinFormsUI-2.3.1:HeuristicLab.WinFormsUI-2.3.1.dll 62 HeuristicLab.ExtLibs\HeuristicLab.WinFormsUI\2.3.1\HeuristicLab.WinFormsUI-2.3.1:WeifenLuo.WinFormsUI.Docking License.txt -
trunk/sources/HeuristicLab.Core.Views/3.3/HeuristicLab.Core.Views-3.3.csproj
r2803 r2805 131 131 <DependentUpon>OperatorTreeView.cs</DependentUpon> 132 132 </Compile> 133 <Compile Include="OperatorView.cs">134 <SubType>UserControl</SubType>135 </Compile>136 <Compile Include="OperatorView.Designer.cs">137 <DependentUpon>OperatorView.cs</DependentUpon>138 </Compile>139 133 <Compile Include="ProblemView.cs"> 140 134 <SubType>UserControl</SubType> -
trunk/sources/HeuristicLab.Core.Views/3.3/ProblemView.Designer.cs
r2796 r2805 93 93 #endregion 94 94 95 private ValueParameterCollectionView valueParameterCollectionView; 96 95 protected ValueParameterCollectionView valueParameterCollectionView; 97 96 98 97 } -
trunk/sources/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj
r2796 r2805 117 117 <Compile Include="Item.cs" /> 118 118 <Compile Include="NamedItem.cs" /> 119 <Compile Include="Operator.cs" />120 119 <Compile Include="Problem.cs" /> 121 120 <Compile Include="OperatorGraph.cs" /> -
trunk/sources/HeuristicLab.Operators.Views/3.3/HeuristicLab.Operators.Views-3.3.csproj
r2803 r2805 81 81 <DependentUpon>MultipleCallsOperatorView.cs</DependentUpon> 82 82 </Compile> 83 <Compile Include="OperatorView.cs"> 84 <SubType>UserControl</SubType> 85 </Compile> 86 <Compile Include="OperatorView.Designer.cs"> 87 <DependentUpon>OperatorView.cs</DependentUpon> 88 </Compile> 83 89 <Compile Include="ValuesCollectorView.cs"> 84 90 <SubType>UserControl</SubType> -
trunk/sources/HeuristicLab.Operators.Views/3.3/OperatorView.Designer.cs
r2804 r2805 20 20 #endregion 21 21 22 namespace HeuristicLab. Core.Views {22 namespace HeuristicLab.Operators.Views { 23 23 partial class OperatorView { 24 24 /// <summary> -
trunk/sources/HeuristicLab.Operators.Views/3.3/OperatorView.cs
r2804 r2805 20 20 #endregion 21 21 22 using HeuristicLab.Core; 23 using HeuristicLab.Core.Views; 22 24 using HeuristicLab.MainForm; 23 25 24 namespace HeuristicLab. Core.Views {26 namespace HeuristicLab.Operators.Views { 25 27 /// <summary> 26 28 /// The base class for visual representations of items. -
trunk/sources/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj
r2796 r2805 91 91 <Compile Include="Assigner.cs" /> 92 92 <Compile Include="MultipleCallsOperator.cs" /> 93 <Compile Include="Operator.cs" /> 93 94 <Compile Include="ParallelSubScopesProcessor.cs" /> 94 95 <Compile Include="Placeholder.cs" /> -
trunk/sources/HeuristicLab.Operators/3.3/Operator.cs
r2804 r2805 23 23 using System.Drawing; 24 24 using HeuristicLab.Collections; 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 27 27 namespace HeuristicLab. Core{28 namespace HeuristicLab.Operators { 28 29 /// <summary> 29 30 /// The base class for all operators. -
trunk/sources/HeuristicLab.Parameters/3.3/LookupParameter.cs
r2793 r2805 111 111 return scope != null ? scope.Variables[actualName] : null; 112 112 } 113 private IValueParameter<T> GetProblemParameter(string name) { 114 IValueParameter<T> param = null; 115 if (ExecutionContext.Problem.Parameters.ContainsKey(name)) { 116 param = ExecutionContext.Problem.Parameters[name] as IValueParameter<T>; 117 if (param == null) 118 throw new InvalidOperationException( 119 string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\".", 120 name, 121 typeof(IValueParameter<T>).GetPrettyName()) 122 ); 123 } 124 return param; 125 } 113 126 protected override IItem GetActualValue() { 114 127 string name; 115 // try to get localvalue from context stack128 // try to get value from context stack 116 129 IValueParameter<T> param = GetParameter(out name); 117 130 if (param != null) return param.Value; 118 else { // try to get variable from scope 119 IVariable var = LookupVariable(name); 120 if (var != null) { 121 T value = var.Value as T; 122 if (value == null) 123 throw new InvalidOperationException( 124 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".", 125 name, 126 typeof(T).GetPrettyName()) 127 ); 128 return value; 129 } 130 } 131 132 // try to get variable from scope 133 IVariable var = LookupVariable(name); 134 if (var != null) { 135 T value = var.Value as T; 136 if (value == null) 137 throw new InvalidOperationException( 138 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".", 139 name, 140 typeof(T).GetPrettyName()) 141 ); 142 return value; 143 } 144 145 // try to get value from problem 146 IValueParameter<T> problemParam = GetProblemParameter(name); 147 if (problemParam != null) return problemParam.Value; 148 131 149 return null; 132 150 } … … 138 156 typeof(T).GetPrettyName()) 139 157 ); 140 // try to get local value fromcontext stack158 // try to set value in context stack 141 159 string name; 142 160 IValueParameter<T> param = GetParameter(out name); 143 if (param != null) param.Value = val; 144 else { // try to get variable from scope 145 IVariable var = LookupVariable(name); 146 if (var != null) var.Value = val; 147 else ExecutionContext.Scope.Variables.Add(new Variable(name, value)); 148 } 161 if (param != null) { 162 param.Value = val; 163 return; 164 } 165 166 // try to set value in scope 167 IVariable var = LookupVariable(name); 168 if (var != null) { 169 var.Value = val; 170 return; 171 } 172 173 // try to set value in problem 174 IValueParameter<T> problemParam = GetProblemParameter(name); 175 if (problemParam != null) { 176 problemParam.Value = val; 177 return; 178 } 179 180 // create new variable 181 ExecutionContext.Scope.Variables.Add(new Variable(name, value)); 149 182 } 150 183 -
trunk/sources/HeuristicLab.Routing.TSP.Views/3.3/HeuristicLab.Routing.TSP.Views-3.3.csproj
r2796 r2805 39 39 <RequiredTargetFramework>3.5</RequiredTargetFramework> 40 40 </Reference> 41 <Reference Include="System.Drawing" /> 42 <Reference Include="System.Windows.Forms" /> 41 43 <Reference Include="System.Xml.Linq"> 42 44 <RequiredTargetFramework>3.5</RequiredTargetFramework> … … 50 52 <ItemGroup> 51 53 <Compile Include="HeuristicLabRoutingTSPViewsPlugin.cs" /> 54 <Compile Include="TSPView.cs"> 55 <SubType>UserControl</SubType> 56 </Compile> 57 <Compile Include="TSPView.Designer.cs"> 58 <DependentUpon>TSPView.cs</DependentUpon> 59 </Compile> 52 60 <Compile Include="Properties\AssemblyInfo.cs" /> 53 61 </ItemGroup> … … 58 66 </ItemGroup> 59 67 <ItemGroup> 68 <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj"> 69 <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project> 70 <Name>HeuristicLab.Collections-3.3</Name> 71 </ProjectReference> 72 <ProjectReference Include="..\..\HeuristicLab.Core.Views\3.3\HeuristicLab.Core.Views-3.3.csproj"> 73 <Project>{E226881D-315F-423D-B419-A766FE0D8685}</Project> 74 <Name>HeuristicLab.Core.Views-3.3</Name> 75 </ProjectReference> 76 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj"> 77 <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project> 78 <Name>HeuristicLab.Core-3.3</Name> 79 </ProjectReference> 80 <ProjectReference Include="..\..\HeuristicLab.MainForm.WindowsForms\3.2\HeuristicLab.MainForm.WindowsForms-3.2.csproj"> 81 <Project>{AB687BBE-1BFE-476B-906D-44237135431D}</Project> 82 <Name>HeuristicLab.MainForm.WindowsForms-3.2</Name> 83 </ProjectReference> 84 <ProjectReference Include="..\..\HeuristicLab.MainForm\3.2\HeuristicLab.MainForm-3.2.csproj"> 85 <Project>{3BD61258-31DA-4B09-89C0-4F71FEF5F05A}</Project> 86 <Name>HeuristicLab.MainForm-3.2</Name> 87 </ProjectReference> 60 88 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> 61 89 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> 62 90 <Name>HeuristicLab.PluginInfrastructure</Name> 91 </ProjectReference> 92 <ProjectReference Include="..\..\HeuristicLab.Routing.TSP\3.3\HeuristicLab.Routing.TSP-3.3.csproj"> 93 <Project>{600287A3-8714-453E-B875-A05F3EB72315}</Project> 94 <Name>HeuristicLab.Routing.TSP-3.3</Name> 63 95 </ProjectReference> 64 96 </ItemGroup> -
trunk/sources/HeuristicLab.Routing.TSP.Views/3.3/HeuristicLabRoutingTSPViewsPlugin.cs.frame
r2796 r2805 28 28 [Plugin("HeuristicLab.Routing.TSP.Views", "3.3.0.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Routing.TSP.Views-3.3.dll", PluginFileType.Assembly)] 30 [PluginDependency("HeuristicLab.Collections", "3.3")] 30 31 [PluginDependency("HeuristicLab.Core", "3.3")] 31 32 [PluginDependency("HeuristicLab.Core.Views", "3.3")] 32 [PluginDependency("HeuristicLab.Data", "3.3")]33 33 [PluginDependency("HeuristicLab.MainForm", "3.2")] 34 34 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.2")] 35 [PluginDependency("HeuristicLab.Operators", "3.3")] 36 [PluginDependency("HeuristicLab.Permutation", "3.3")] 37 [PluginDependency("HeuristicLab.Persistence", "3.3")] 35 [PluginDependency("HeuristicLab.Routing.TSP", "3.3")] 38 36 public class HeuristicLabRoutingTSPViewsPlugin : PluginBase { 39 37 } -
trunk/sources/HeuristicLab.Routing.TSP/3.3/HeuristicLab.Routing.TSP-3.3.csproj
r2796 r2805 86 86 <ItemGroup> 87 87 <None Include="HeuristicLabRoutingTSPPlugin.cs.frame" /> 88 <Compile Include="TSPDistanceMatrixPathEvaluator.cs" /> 89 <Compile Include="TSPLIBParser.cs" /> 90 <Compile Include="TSPRoundedEuclideanPathEvaluator.cs" /> 91 <Compile Include="TSPPathEvaluator.cs" /> 88 92 <Compile Include="TSP.cs" /> 89 93 <Compile Include="HeuristicLabRoutingTSPPlugin.cs" /> 90 94 <Compile Include="Properties\AssemblyInfo.cs" /> 91 <Compile Include="TSPParser.cs" />92 95 </ItemGroup> 93 96 <ItemGroup> … … 108 111 <Name>HeuristicLab.Operators-3.3</Name> 109 112 </ProjectReference> 113 <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj"> 114 <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project> 115 <Name>HeuristicLab.Parameters-3.3</Name> 116 </ProjectReference> 110 117 <ProjectReference Include="..\..\HeuristicLab.Permutation\3.3\HeuristicLab.Permutation-3.3.csproj"> 111 118 <Project>{00282156-589D-424F-9CE4-A8038636C926}</Project> … … 122 129 </ItemGroup> 123 130 <ItemGroup> 131 <None Include="ch130.tsp" /> 132 <None Include="fl1400.tsp" /> 124 133 <None Include="HeuristicLab.snk" /> 125 134 <None Include="Properties\AssemblyInfo.frame" /> -
trunk/sources/HeuristicLab.Routing.TSP/3.3/HeuristicLabRoutingTSPPlugin.cs.frame
r2796 r2805 32 32 [PluginDependency("HeuristicLab.Data", "3.3")] 33 33 [PluginDependency("HeuristicLab.Operators", "3.3")] 34 [PluginDependency("HeuristicLab.Parameters", "3.3")] 34 35 [PluginDependency("HeuristicLab.Permutation", "3.3")] 35 36 [PluginDependency("HeuristicLab.Persistence", "3.3")] -
trunk/sources/HeuristicLab.Routing.TSP/3.3/TSP.cs
r2796 r2805 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Text;25 using System.Xml;26 22 using HeuristicLab.Core; 27 23 using HeuristicLab.Data; 24 using HeuristicLab.Parameters; 25 using HeuristicLab.Permutation; 28 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 27 30 namespace HeuristicLab. Data{28 namespace HeuristicLab.Routing.TSP { 31 29 [Item("TSP", "Represents a symmetric Traveling Salesman Problem.")] 32 30 [Creatable("Problems")] 31 [EmptyStorableClass] 33 32 public sealed class TSP : Problem { 33 private ValueParameter<DoubleMatrixData> CoordinatesParameter { 34 get { return (ValueParameter<DoubleMatrixData>)Parameters["Coordinates"]; } 35 } 36 private OperatorParameter SolutionGeneratorParameter { 37 get { return (OperatorParameter)Parameters["SolutionGenerator"]; } 38 } 39 private OperatorParameter EvaluatorParameter { 40 get { return (OperatorParameter)Parameters["Evaluator"]; } 41 } 42 43 public DoubleMatrixData Coordinates { 44 get { return CoordinatesParameter.Value; } 45 set { CoordinatesParameter.Value = value; } 46 } 47 public IOperator SolutionGenerator { 48 get { return SolutionGeneratorParameter.Value; } 49 set { SolutionGeneratorParameter.Value = value; } 50 } 51 public IOperator Evaluator { 52 get { return EvaluatorParameter.Value; } 53 set { EvaluatorParameter.Value = value; } 54 } 55 34 56 public TSP() 35 57 : base() { 58 Parameters.Add(new ValueParameter<BoolData>("Maximization", "Set to false as the TSP is a minimization problem.", new BoolData(false))); 59 Parameters.Add(new ValueParameter<DoubleMatrixData>("Coordinates", "The x- and y-Coordinates of the cities.", new DoubleMatrixData(0, 0))); 60 Parameters.Add(new ValueParameter<DoubleData>("BestKnownQuality", "The quality of the best known solution of this TSP instance.")); 61 Parameters.Add(new OperatorParameter("SolutionGenerator", "The operator which should be used to generate new solutions.")); 62 Parameters.Add(new OperatorParameter("Evaluator", "The operator which should be used to evaluate solutions.")); 63 } 36 64 65 public void ImportFromTSPLIB(string filename) { 66 TSPLIBParser parser = new TSPLIBParser(filename); 67 parser.Parse(); 68 Coordinates = new DoubleMatrixData(parser.Vertices); 69 int cities = Coordinates.Rows; 70 RandomPermutationCreator creator = new RandomPermutationCreator(); 71 creator.LengthParameter.Value = new IntData(cities); 72 SolutionGenerator = creator; 73 TSPRoundedEuclideanPathEvaluator evaluator = new TSPRoundedEuclideanPathEvaluator(); 74 Evaluator = evaluator; 37 75 } 38 76 } -
trunk/sources/HeuristicLab.Routing.TSP/3.3/TSPLIBParser.cs
r2804 r2805 28 28 /// Parses a *.tsp file in the TSPLIB format and extracts its information about a TSP. 29 29 /// </summary> 30 public class TSP Parser {30 public class TSPLIBParser { 31 31 private const int EOF = 0; 32 32 private const int NAME = 1; … … 67 67 /// </exception> 68 68 /// <param name="path">The path where the TSP is stored.</param> 69 public TSP Parser(String path) {69 public TSPLIBParser(String path) { 70 70 if (!path.EndsWith(".tsp")) 71 71 throw new ArgumentException("Input file name has to be in TSP format (*.tsp)"); -
trunk/sources/HeuristicLab.Selection/3.3/HeuristicLab.Selection-3.3.csproj
r2790 r2805 82 82 <ItemGroup> 83 83 <None Include="HeuristicLabSelectionPlugin.cs.frame" /> 84 <Compile Include="RightSelector.cs" /> 85 <Compile Include="StochasticSelector.cs" /> 86 <Compile Include="LeftSelector.cs" /> 87 <Compile Include="RandomSelector.cs" /> 88 <Compile Include="StochasticSingleObjectiveSelector.cs" /> 84 89 <Compile Include="HeuristicLabSelectionPlugin.cs" /> 85 90 <Compile Include="Properties\AssemblyInfo.cs" /> 91 <Compile Include="Selector.cs" /> 92 <Compile Include="TournamentSelector.cs" /> 86 93 </ItemGroup> 87 94 <ItemGroup> … … 90 97 </ItemGroup> 91 98 <ItemGroup> 99 <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj"> 100 <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project> 101 <Name>HeuristicLab.Collections-3.3</Name> 102 </ProjectReference> 92 103 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj"> 93 104 <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project> … … 101 112 <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project> 102 113 <Name>HeuristicLab.Operators-3.3</Name> 114 </ProjectReference> 115 <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj"> 116 <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project> 117 <Name>HeuristicLab.Parameters-3.3</Name> 118 </ProjectReference> 119 <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj"> 120 <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project> 121 <Name>HeuristicLab.Persistence-3.3</Name> 103 122 </ProjectReference> 104 123 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> -
trunk/sources/HeuristicLab.Selection/3.3/HeuristicLabSelectionPlugin.cs.frame
r2790 r2805 31 31 [Plugin("HeuristicLab.Selection", "3.3.0.$WCREV$")] 32 32 [PluginFile("HeuristicLab.Selection-3.3.dll", PluginFileType.Assembly)] 33 [PluginDependency("HeuristicLab.Collections", "3.3")] 33 34 [PluginDependency("HeuristicLab.Core", "3.3")] 34 35 [PluginDependency("HeuristicLab.Data", "3.3")] 35 36 [PluginDependency("HeuristicLab.Operators", "3.3")] 37 [PluginDependency("HeuristicLab.Parameters", "3.3")] 38 [PluginDependency("HeuristicLab.Persistence", "3.3")] 36 39 public class HeuristicLabSelectionPlugin : PluginBase { 37 40 } -
trunk/sources/HeuristicLab.Selection/3.3/LeftSelector.cs
r1530 r2805 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-20 08Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 using System.Text;25 23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 25 using HeuristicLab.Parameters; 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 27 27 28 namespace HeuristicLab.Selection { 28 29 /// <summary> 29 /// Copies or moves a defined number of sub scopes from a source scope to a target scope, starting at 30 /// the left side of the tree. 30 /// An operator which selects sub-scopes from left to right. 31 31 /// </summary> 32 public class LeftSelector : StochasticSelectorBase {33 /// <inheritdoc select="summary"/>34 public override string Description {35 get { return @"TODO\r\nOperator description still missing ..."; }36 }32 [Item("LeftSelector", "An operator which selects sub-scopes from left to right.")] 33 [EmptyStorableClass] 34 [Creatable("Test")] 35 public sealed class LeftSelector : Selector { 36 public LeftSelector() : base() { } 37 37 38 /// <summary> 39 /// Copies or moves a number of sub scopes (<paramref name="selected"/>) from <paramref name="source"/> 40 /// starting at the left end to the <paramref name="target"/>. 41 /// </summary> 42 /// <param name="random">A random number generator.</param> 43 /// <param name="source">The source scope from which to copy/move the sub scopes.</param> 44 /// <param name="selected">The number of sub scopes to move. Can be also bigger than the total 45 /// number of sub scopes in <paramref name="source"/>, then the copying process starts again from the 46 /// beginning.</param> 47 /// <param name="target">The target where to copy/move the sub scopes.</param> 48 /// <param name="copySelected">Boolean flag whether the sub scopes shall be copied or moved.</param> 49 protected override void Select(IRandom random, IScope source, int selected, IScope target, bool copySelected) { 50 int index = 0; 51 for (int i = 0; i < selected; i++) { 52 if (copySelected) { 53 target.AddSubScope((IScope)source.SubScopes[index].Clone()); 54 index++; 55 if (index >= source.SubScopes.Count) index = 0; 38 protected override void Select(ScopeList source, ScopeList target) { 39 int count = NumberOfSelectedSubScopesParameter.ActualValue.Value; 40 bool copy = CopySelectedParameter.Value.Value; 41 42 int j = 0; 43 for (int i = 0; i < count; i++) { 44 if (copy) { 45 target.Add((IScope)source[j].Clone()); 46 j++; 47 if (j >= source.Count) j = 0; 56 48 } else { 57 IScope s = source.SubScopes[0]; 58 source.RemoveSubScope(s); 59 target.AddSubScope(s); 49 target.Add(source[0]); 50 source.RemoveAt(0); 60 51 } 61 52 } -
trunk/sources/HeuristicLab.Selection/3.3/RandomSelector.cs
r1530 r2805 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-20 08Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 using System.Text;25 23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 25 using HeuristicLab.Parameters; 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 27 27 28 namespace HeuristicLab.Selection { 28 29 /// <summary> 29 /// Copies or moves a defined number of sub scopes from a source scope to a target scope, being selected 30 /// randomly. 30 /// A random selection operator. 31 31 /// </summary> 32 public class RandomSelector : StochasticSelectorBase {33 /// <inheritdoc select="summary"/>34 public override string Description {35 get { return @"TODO\r\nOperator description still missing ..."; }36 }32 [Item("RandomSelector", "A random selection operator.")] 33 [EmptyStorableClass] 34 [Creatable("Test")] 35 public sealed class RandomSelector : StochasticSelector { 36 public RandomSelector() : base() { } 37 37 38 /// <summary> 39 /// Copies or moves a number of sub scopes (<paramref name="selected"/>) from <paramref name="source"/> 40 /// to the <paramref name="target"/>, chosen randomly. 41 /// </summary> 42 /// <param name="random">The random number generator.</param> 43 /// <param name="source">The source scope from which to copy/move the sub scopes.</param> 44 /// <param name="selected">The number of sub scopes to move.</param> 45 /// <param name="target">The target where to copy/move the sub scopes.</param> 46 /// <param name="copySelected">Boolean flag whether the sub scopes shall be copied or moved.</param> 47 protected override void Select(IRandom random, IScope source, int selected, IScope target, bool copySelected) { 48 for (int i = 0; i < selected; i++) { 49 if (copySelected) { 50 target.AddSubScope((IScope)source.SubScopes[random.Next(source.SubScopes.Count)].Clone()); 51 } else { 52 IScope s = source.SubScopes[random.Next(source.SubScopes.Count)]; 53 source.RemoveSubScope(s); 54 target.AddSubScope(s); 38 protected override void Select(ScopeList source, ScopeList target) { 39 int count = NumberOfSelectedSubScopesParameter.ActualValue.Value; 40 bool copy = CopySelectedParameter.Value.Value; 41 IRandom random = RandomParameter.ActualValue; 42 43 for (int i = 0; i < count; i++) { 44 if (copy) 45 target.Add((IScope)source[random.Next(source.Count)].Clone()); 46 else { 47 int index = random.Next(source.Count); 48 target.Add(source[index]); 49 source.RemoveAt(index); 55 50 } 56 51 } -
trunk/sources/HeuristicLab.Selection/3.3/RightSelector.cs
r1530 r2805 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-20 08Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 using System.Text;25 23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 25 using HeuristicLab.Parameters; 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 27 27 28 namespace HeuristicLab.Selection { 28 29 /// <summary> 29 /// Copies or moves a defined number of sub scopes from a source scope to a target scope, starting at 30 /// the right side of the tree. 30 /// An operator which selects sub-scopes from right to left. 31 31 /// </summary> 32 public class RightSelector : StochasticSelectorBase {33 /// <inheritdoc select="summary"/>34 public override string Description {35 get { return @"TODO\r\nOperator description still missing ..."; }36 }32 [Item("RightSelector", "An operator which selects sub-scopes from right to left.")] 33 [EmptyStorableClass] 34 [Creatable("Test")] 35 public sealed class RightSelector : Selector { 36 public RightSelector() : base() { } 37 37 38 /// <summary> 39 /// Copies or moves a number of sub scopes (<paramref name="selected"/>) from <paramref name="source"/> 40 /// starting at the right end to the <paramref name="target"/>. 41 /// </summary> 42 /// <param name="random">A random number generator.</param> 43 /// <param name="source">The source scope from which to copy/move the sub scopes.</param> 44 /// <param name="selected">The number of sub scopes to move. Can be also bigger than the total 45 /// number of sub scopes in <paramref name="source"/>, then the copying process starts again from the 46 /// beginning.</param> 47 /// <param name="target">The target where to copy/move the sub scopes.</param> 48 /// <param name="copySelected">Boolean flag whether the sub scopes shall be copied or moved.</param> 49 protected override void Select(IRandom random, IScope source, int selected, IScope target, bool copySelected) { 50 int index = source.SubScopes.Count - 1; 51 for (int i = 0; i < selected; i++) { 52 if (copySelected) { 53 target.AddSubScope((IScope)source.SubScopes[index].Clone()); 54 index--; 55 if (index < 0) index = source.SubScopes.Count - 1; 38 protected override void Select(ScopeList source, ScopeList target) { 39 int count = NumberOfSelectedSubScopesParameter.ActualValue.Value; 40 bool copy = CopySelectedParameter.Value.Value; 41 42 int j = source.Count - 1; 43 for (int i = 0; i < count; i++) { 44 if (copy) { 45 target.Add((IScope)source[j].Clone()); 46 j--; 47 if (j < 0) j = source.Count - 1; 56 48 } else { 57 IScope s = source.SubScopes[source.SubScopes.Count - 1]; 58 source.RemoveSubScope(s); 59 target.AddSubScope(s); 49 target.Add(source[source.Count - 1]); 50 source.RemoveAt(source.Count - 1); 60 51 } 61 52 } -
trunk/sources/HeuristicLab.Selection/3.3/TournamentSelector.cs
r1530 r2805 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-20 08Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 using System.Text;25 23 using HeuristicLab.Core; 26 24 using HeuristicLab.Data; 25 using HeuristicLab.Parameters; 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 27 28 28 namespace HeuristicLab.Selection { 29 29 /// <summary> 30 /// Moves or copies a defined number of the best sub scopes from a source scope to a target scope.30 /// A tournament selection operator which considers a single double quality value for selection. 31 31 /// </summary> 32 public class TournamentSelector : StochasticSelectorBase { 33 /// <inheritdoc select="summary"/> 34 public override string Description { 35 get { return @"TODO\r\nOperator description still missing ..."; } 32 [Item("TournamentSelector", "A tournament selection operator which considers a single double quality value for selection.")] 33 [EmptyStorableClass] 34 [Creatable("Test")] 35 public sealed class TournamentSelector : StochasticSingleObjectiveSelector { 36 public ValueLookupParameter<IntData> GroupSizeParameter { 37 get { return (ValueLookupParameter<IntData>)Parameters["GroupSize"]; } 36 38 } 37 39 38 /// <summary> 39 /// Initializes a new instance of <see cref="TournamentSelector"/> with three variable infos 40 /// (<c>Maximization</c>, <c>Quality</c> and <c>GroupSize</c>, being a local variable and set to 41 /// <c>2</c>) with <c>CopySelected</c> set to <c>true</c>. 42 /// </summary> 43 public TournamentSelector() { 44 AddVariableInfo(new VariableInfo("Maximization", "Maximization problem", typeof(BoolData), VariableKind.In)); 45 AddVariableInfo(new VariableInfo("Quality", "Quality value", typeof(DoubleData), VariableKind.In)); 46 AddVariableInfo(new VariableInfo("GroupSize", "Size of the tournament group", typeof(IntData), VariableKind.In)); 47 GetVariableInfo("GroupSize").Local = true; 48 AddVariable(new Variable("GroupSize", new IntData(2))); 49 GetVariable("CopySelected").GetValue<BoolData>().Data = true; 40 public TournamentSelector() : base() { 41 Parameters.Add(new ValueLookupParameter<IntData>("GroupSize", "The size of the tournament group.", new IntData(2))); 50 42 } 51 43 52 /// <summary> 53 /// Copies or moves the best sub scopes from the given <paramref name="source"/> to the specified 54 /// <paramref name="target"/>. 55 /// </summary> 56 /// <exception cref="InvalidOperationException">Thrown when no source sub scopes are available.</exception> 57 /// <param name="random">The random number generator.</param> 58 /// <param name="source">The source scope from where to copy/move the sub scopes.</param> 59 /// <param name="selected">The number of sub scopes to copy/move.</param> 60 /// <param name="target">The target scope where to add the sub scopes.</param> 61 /// <param name="copySelected">Boolean flag whether the sub scopes shall be moved or copied.</param> 62 protected override void Select(IRandom random, IScope source, int selected, IScope target, bool copySelected) { 63 IVariableInfo qualityInfo = GetVariableInfo("Quality"); 64 bool maximization = GetVariableValue<BoolData>("Maximization", source, true).Data; 65 int groupSize = GetVariableValue<IntData>("GroupSize", source, true).Data; 66 for (int i = 0; i < selected; i++) { 67 if (source.SubScopes.Count < 1) throw new InvalidOperationException("No source scopes available to select."); 44 protected override void Select(ScopeList source, ScopeList target) { 45 int count = NumberOfSelectedSubScopesParameter.ActualValue.Value; 46 bool copy = CopySelectedParameter.Value.Value; 47 IRandom random = RandomParameter.ActualValue; 48 bool maximization = MaximizationParameter.ActualValue.Value; 49 List<DoubleData> qualities = new List<DoubleData>(QualityParameter.ActualValue); 50 int groupSize = GroupSizeParameter.ActualValue.Value; 68 51 69 IScope selectedScope = source.SubScopes[random.Next(source.SubScopes.Count)]; 70 double best = selectedScope.GetVariableValue<DoubleData>(qualityInfo.FormalName, false).Data; 52 for (int i = 0; i < count; i++) { 53 int best = random.Next(source.Count); 54 int index; 71 55 for (int j = 1; j < groupSize; j++) { 72 IScope scope = source.SubScopes[random.Next(source.SubScopes.Count)]; 73 double quality = scope.GetVariableValue<DoubleData>(qualityInfo.FormalName, false).Data; 74 if (((maximization) && (quality > best)) || 75 ((!maximization) && (quality < best))) { 76 best = quality; 77 selectedScope = scope; 56 index = random.Next(source.Count); 57 if (((maximization) && (qualities[index].Value > qualities[best].Value)) || 58 ((!maximization) && (qualities[index].Value < qualities[best].Value))) { 59 best = index; 78 60 } 79 61 } 80 62 81 if (copy Selected)82 target.Add SubScope((IScope)selectedScope.Clone());63 if (copy) 64 target.Add((IScope)source[best].Clone()); 83 65 else { 84 source.RemoveSubScope(selectedScope); 85 target.AddSubScope(selectedScope); 66 target.Add(source[best]); 67 source.RemoveAt(best); 68 qualities.RemoveAt(best); 86 69 } 87 70 }
Note: See TracChangeset
for help on using the changeset viewer.