Changeset 1857
- Timestamp:
- 05/20/09 10:50:18 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 added
- 1 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherBase.cs
r1529 r1857 35 35 using HeuristicLab.Data; 36 36 using HeuristicLab.Core; 37 using HeuristicLab.Modeling; 37 38 38 39 namespace HeuristicLab.CEDMA.Server { 39 40 public abstract class DispatcherBase : IDispatcher { 40 public enum ModelComplexity { Low, Medium, High };41 public enum Algorithm { StandardGpRegression, OffspringGpRegression, StandardGpClassification, OffspringGpClassification, StandardGpForecasting, OffspringGpForecasting };42 43 41 private IStore store; 44 private ModelComplexity[] possibleComplexities = new ModelComplexity[] { ModelComplexity.Low, ModelComplexity.Medium, ModelComplexity.High };45 private Dictionary<LearningTask, Algorithm[]> possibleAlgorithms = new Dictionary<LearningTask, Algorithm[]>() {46 {LearningTask.Classification, new Algorithm[] { Algorithm.StandardGpClassification, Algorithm.OffspringGpClassification }},47 {LearningTask.Regression, new Algorithm[] { Algorithm.StandardGpRegression, Algorithm.OffspringGpRegression }},48 {LearningTask.TimeSeries, new Algorithm[] { Algorithm.StandardGpForecasting, Algorithm.OffspringGpForecasting }}49 };50 42 51 43 private static int MaxGenerations { … … 79 71 80 72 int targetVariable = SelectTargetVariable(dataSet, dataSet.Problem.AllowedTargetVariables.ToArray()); 81 Algorithm selectedAlgorithm = SelectAlgorithm(dataSet, targetVariable, possibleAlgorithms[dataSet.Problem.LearningTask]);73 IAlgorithm selectedAlgorithm = SelectAlgorithm(dataSet, targetVariable, dataSet.Problem.LearningTask); 82 74 string targetVariableName = dataSet.Problem.GetVariableName(targetVariable); 83 ModelComplexity selectedComplexity = SelectComplexity(dataSet, targetVariable, selectedAlgorithm, possibleComplexities);84 75 85 Execution exec = CreateExecution(dataSet.Problem, targetVariable, selectedAlgorithm, selectedComplexity); 86 if (exec != null) { 76 77 if (selectedAlgorithm != null) { 78 Execution exec = CreateExecution(dataSet.Problem, targetVariable, selectedAlgorithm); 87 79 exec.DataSetEntity = dataSetEntity; 88 80 exec.TargetVariable = targetVariableName; 89 }90 return exec;81 return exec; 82 } else return null; 91 83 } 92 84 93 85 public abstract Entity SelectDataSet(Entity[] datasets); 94 86 public abstract int SelectTargetVariable(DataSet dataSet, int[] targetVariables); 95 public abstract Algorithm SelectAlgorithm(DataSet dataSet, int targetVariable, Algorithm[] possibleAlgorithms); 96 public abstract ModelComplexity SelectComplexity(DataSet dataSet, int targetVariable, Algorithm algorithm, ModelComplexity[] possibleComplexities); 87 public abstract IAlgorithm SelectAlgorithm(DataSet dataSet, int targetVariable, LearningTask learningTask); 97 88 98 private Execution CreateExecution(Problem problem, int targetVariable, Algorithm algorithm, ModelComplexity complexity) { 99 switch (algorithm) { 100 case Algorithm.StandardGpRegression: { 101 var algo = new HeuristicLab.GP.StructureIdentification.StandardGP(); 102 SetComplexityParameters(algo, complexity); 103 SetProblemParameters(algo, problem, targetVariable); 104 algo.PopulationSize = 10000; 105 algo.MaxGenerations = MaxGenerations; 106 Execution exec = new Execution(algo.Engine); 107 exec.Description = "StandardGP - Complexity: " + complexity; 108 return exec; 109 } 110 case Algorithm.OffspringGpRegression: { 111 var algo = new HeuristicLab.GP.StructureIdentification.OffspringSelectionGP(); 112 SetComplexityParameters(algo, complexity); 113 SetProblemParameters(algo, problem, targetVariable); 114 algo.MaxEvaluatedSolutions = MaxEvaluatedSolutions; 115 Execution exec = new Execution(algo.Engine); 116 exec.Description = "OffspringGP - Complexity: " + complexity; 117 return exec; 118 } 119 case Algorithm.StandardGpClassification: { 120 var algo = new HeuristicLab.GP.StructureIdentification.Classification.StandardGP(); 121 SetComplexityParameters(algo, complexity); 122 SetProblemParameters(algo, problem, targetVariable); 123 algo.PopulationSize = 10000; 124 algo.MaxGenerations = MaxGenerations; 125 Execution exec = new Execution(algo.Engine); 126 exec.Description = "StandardGP - Complexity: " + complexity; 127 return exec; 128 } 129 case Algorithm.OffspringGpClassification: { 130 var algo = new HeuristicLab.GP.StructureIdentification.Classification.OffspringSelectionGP(); 131 SetComplexityParameters(algo, complexity); 132 SetProblemParameters(algo, problem, targetVariable); 133 algo.MaxEvaluatedSolutions = MaxEvaluatedSolutions; 134 Execution exec = new Execution(algo.Engine); 135 exec.Description = "OffspringGP - Complexity: " + complexity; 136 return exec; 137 } 138 case Algorithm.StandardGpForecasting: { 139 var algo = new HeuristicLab.GP.StructureIdentification.TimeSeries.StandardGP(); 140 SetComplexityParameters(algo, complexity); 141 SetProblemParameters(algo, problem, targetVariable); 142 algo.PopulationSize = 10000; 143 algo.MaxGenerations = MaxGenerations; 144 Execution exec = new Execution(algo.Engine); 145 exec.Description = "StandardGP - Complexity: " + complexity; 146 return exec; 147 } 148 case Algorithm.OffspringGpForecasting: { 149 var algo = new HeuristicLab.GP.StructureIdentification.TimeSeries.OffspringSelectionGP(); 150 SetComplexityParameters(algo, complexity); 151 SetProblemParameters(algo, problem, targetVariable); 152 algo.MaxEvaluatedSolutions = MaxEvaluatedSolutions; 153 Execution exec = new Execution(algo.Engine); 154 exec.Description = "OffspringGP - Complexity: " + complexity; 155 return exec; 156 } 157 default: { 158 return null; 159 } 160 } 89 private Execution CreateExecution(Problem problem, int targetVariable, IAlgorithm algorithm) { 90 //switch (algorithm) { 91 // case Algorithm.StandardGpRegression: { 92 // var algo = new HeuristicLab.GP.StructureIdentification.StandardGP(); 93 // SetComplexityParameters(algo, complexity); 94 // SetProblemParameters(algo, problem, targetVariable); 95 // algo.PopulationSize = 10000; 96 // algo.MaxGenerations = MaxGenerations; 97 // Execution exec = new Execution(algo.Engine); 98 // exec.Description = "StandardGP - Complexity: " + complexity; 99 // return exec; 100 // } 101 SetProblemParameters(algorithm, problem, targetVariable); 102 Execution exec = new Execution(algorithm.Engine); 103 exec.Description = algorithm.Name; 104 return exec; 161 105 } 162 106 163 private void SetComplexityParameters(AlgorithmBase algo, ModelComplexity complexity) { 164 switch (complexity) { 165 case ModelComplexity.Low: { 166 algo.MaxTreeHeight = 5; 167 algo.MaxTreeSize = 20; 168 break; 169 } 170 case ModelComplexity.Medium: { 171 algo.MaxTreeHeight = 10; 172 algo.MaxTreeSize = 100; 173 break; 174 } 175 case ModelComplexity.High: { 176 algo.MaxTreeHeight = 12; 177 algo.MaxTreeSize = 200; 178 break; 179 } 180 } 181 } 182 183 private void SetProblemParameters(AlgorithmBase algo, Problem problem, int targetVariable) { 107 private void SetProblemParameters(IAlgorithm algo, Problem problem, int targetVariable) { 184 108 algo.ProblemInjector.GetVariable("Dataset").Value = problem.DataSet; 185 109 algo.ProblemInjector.GetVariable("TargetVariable").GetValue<IntData>().Data = targetVariable; -
trunk/sources/HeuristicLab.CEDMA.Server/3.3/HeuristicLab.CEDMA.Server-3.3.csproj
r1534 r1857 132 132 <Name>HeuristicLab.Data-3.2</Name> 133 133 </ProjectReference> 134 <ProjectReference Include="..\..\HeuristicLab.GP.StructureIdentification.Classification\3.3\HeuristicLab.GP.StructureIdentification.Classification-3.3.csproj">135 <Project>{7C20D100-8BEB-433A-9499-F075E2CB9297}</Project>136 <Name>HeuristicLab.GP.StructureIdentification.Classification-3.3</Name>137 </ProjectReference>138 <ProjectReference Include="..\..\HeuristicLab.GP.StructureIdentification.TimeSeries\3.3\HeuristicLab.GP.StructureIdentification.TimeSeries-3.3.csproj">139 <Project>{6084CFB5-733F-449D-9F92-2E40D13F0514}</Project>140 <Name>HeuristicLab.GP.StructureIdentification.TimeSeries-3.3</Name>141 </ProjectReference>142 <ProjectReference Include="..\..\HeuristicLab.GP.StructureIdentification\3.3\HeuristicLab.GP.StructureIdentification-3.3.csproj">143 <Project>{74223A32-C726-4978-BE78-37113A18373C}</Project>144 <Name>HeuristicLab.GP.StructureIdentification-3.3</Name>145 </ProjectReference>146 134 <ProjectReference Include="..\..\HeuristicLab.Grid\3.2\HeuristicLab.Grid-3.2.csproj"> 147 135 <Project>{545CE756-98D8-423B-AC2E-6E7D70926E5C}</Project> 148 136 <Name>HeuristicLab.Grid-3.2</Name> 137 </ProjectReference> 138 <ProjectReference Include="..\..\HeuristicLab.Modeling\3.2\HeuristicLab.Modeling-3.2.csproj"> 139 <Project>{80F7FADA-549D-4151-8856-79B620A50DBA}</Project> 140 <Name>HeuristicLab.Modeling-3.2</Name> 149 141 </ProjectReference> 150 142 <ProjectReference Include="..\..\HeuristicLab.Operators\3.2\HeuristicLab.Operators-3.2.csproj"> -
trunk/sources/HeuristicLab.CEDMA.Server/3.3/HeuristicLabCedmaServerPlugin.cs
r1529 r1857 34 34 [Dependency(Dependency = "HeuristicLab.Data-3.2")] 35 35 [Dependency(Dependency = "HeuristicLab.DataAnalysis-3.2")] 36 [Dependency(Dependency = "HeuristicLab.GP.StructureIdentification-3.3")] 37 [Dependency(Dependency = "HeuristicLab.GP.StructureIdentification.Classification-3.3")] 38 [Dependency(Dependency = "HeuristicLab.GP.StructureIdentification.TimeSeries-3.3")] 36 [Dependency(Dependency = "HeuristicLab.Modeling-3.2")] 39 37 public class HeuristicLabCedmaServerPlugin : PluginBase { 40 38 } -
trunk/sources/HeuristicLab.CEDMA.Server/3.3/RandomDispatcher.cs
r1529 r1857 35 35 using HeuristicLab.Data; 36 36 using HeuristicLab.Core; 37 using HeuristicLab.Modeling; 37 38 38 39 namespace HeuristicLab.CEDMA.Server { … … 44 45 } 45 46 46 public override Algorithm SelectAlgorithm(DataSet dataSet, int targetVariable, Algorithm[] possibleAlgorithms) { 47 return possibleAlgorithms[random.Next(possibleAlgorithms.Length)]; 48 } 49 50 public override ModelComplexity SelectComplexity(DataSet dataSet, int targetVariable, Algorithm algorithm, ModelComplexity[] possibleComplexities) { 51 return possibleComplexities[random.Next(possibleComplexities.Length)]; 47 public override IAlgorithm SelectAlgorithm(DataSet dataSet, int targetVariable, LearningTask learningTask) { 48 DiscoveryService ds = new DiscoveryService(); 49 IAlgorithm[] algos = ds.GetInstances<IAlgorithm>(); 50 switch (learningTask) { 51 case LearningTask.Regression: { 52 var regressionAlgos = algos.Where(a => (a as IClassificationAlgorithm) == null && (a as ITimeSeriesAlgorithm) == null); 53 if (regressionAlgos.Count() == 0) return null; 54 return regressionAlgos.ElementAt(random.Next(regressionAlgos.Count())); 55 } 56 case LearningTask.Classification: { 57 var classificationAlgos = algos.Where(a => (a as IClassificationAlgorithm) != null); 58 if (classificationAlgos.Count() == 0) return null; 59 return classificationAlgos.ElementAt(random.Next(classificationAlgos.Count())); 60 } 61 case LearningTask.TimeSeries: { 62 var timeSeriesAlgos = algos.Where(a => (a as ITimeSeriesAlgorithm) != null); 63 if (timeSeriesAlgos.Count() == 0) return null; 64 return timeSeriesAlgos.ElementAt(random.Next(timeSeriesAlgos.Count())); 65 } 66 } 67 return null; 52 68 } 53 69 -
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/OffspringSelectionGP.cs
r1856 r1857 33 33 34 34 namespace HeuristicLab.GP.StructureIdentification.Classification { 35 public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP {35 public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP, IClassificationAlgorithm { 36 36 protected override IOperator CreateProblemInjector() { 37 37 return new ProblemInjector(); -
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/StandardGP.cs
r1856 r1857 34 34 35 35 namespace HeuristicLab.GP.StructureIdentification.Classification { 36 public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP { 37 36 public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP, IClassificationAlgorithm { 38 37 protected override IOperator CreateProblemInjector() { 39 38 return new ProblemInjector(); -
trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/OffspringSelectionGP.cs
r1856 r1857 34 34 35 35 namespace HeuristicLab.GP.StructureIdentification.TimeSeries { 36 public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP {36 public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP, ITimeSeriesAlgorithm { 37 37 public virtual bool Autoregressive { 38 38 get { return ProblemInjector.GetVariable("Autoregressive").GetValue<BoolData>().Data; } -
trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/StandardGP.cs
r1856 r1857 34 34 35 35 namespace HeuristicLab.GP.StructureIdentification.TimeSeries { 36 public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP {36 public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP, ITimeSeriesAlgorithm { 37 37 public bool Autoregressive { 38 38 get { return ProblemInjector.GetVariable("Autoregressive").GetValue<BoolData>().Data; } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/AlgorithmBase.cs
r1529 r1857 35 35 using HeuristicLab.Operators.Programmable; 36 36 using HeuristicLab.Evolutionary; 37 using HeuristicLab.Modeling; 37 38 38 39 namespace HeuristicLab.GP.StructureIdentification { 39 public abstract class AlgorithmBase : ItemBase { 40 public abstract class AlgorithmBase : ItemBase, IAlgorithm, IStochasticAlgorithm { 41 public virtual string Name { get { return "GP"; } } 42 public virtual string Description { get { return "TODO"; } } 43 40 44 public virtual double MutationRate { 41 45 get { return GetVariableInjector().GetVariable("MutationRate").GetValue<DoubleData>().Data; } … … 52 56 } 53 57 54 public virtual int Seed {58 public virtual int RandomSeed { 55 59 get { return GetRandomInjector().GetVariable("Seed").GetValue<IntData>().Data; } 56 60 set { GetRandomInjector().GetVariable("Seed").GetValue<IntData>().Data = value; } … … 430 434 } 431 435 #endregion 436 432 437 } 433 438 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/OffspringSelectionGP.cs
r1529 r1857 39 39 namespace HeuristicLab.GP.StructureIdentification { 40 40 public class OffspringSelectionGP : StandardGP { 41 public override string Name { get { return "OffspringSelectionGP"; } } 41 42 42 43 public virtual int MaxEvaluatedSolutions { -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGP.cs
r1856 r1857 38 38 namespace HeuristicLab.GP.StructureIdentification { 39 39 public class StandardGP : AlgorithmBase, IEditable { 40 41 public override string Name { get { return "StandardGP"; } } 40 42 41 43 public virtual int MaxGenerations { -
trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj
r1856 r1857 83 83 <ItemGroup> 84 84 <Compile Include="ClassificationProblemInjector.cs" /> 85 <Compile Include="ITimeSeriesAlgorithm.cs" /> 86 <Compile Include="IClassificationAlgorithm.cs" /> 87 <Compile Include="IStochasticAlgorithm.cs" /> 85 88 <Compile Include="HeuristicLabModelingPlugin.cs" /> 89 <Compile Include="IAlgorithm.cs" /> 86 90 <Compile Include="ProblemInjector.cs" /> 87 91 <Compile Include="ProblemInjectorView.cs"> -
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/HeuristicLab.SupportVectorMachines-3.2.csproj
r1854 r1857 109 109 <Name>HeuristicLab.Data-3.2</Name> 110 110 </ProjectReference> 111 <ProjectReference Include="..\..\HeuristicLab.GP.StructureIdentification\3.3\HeuristicLab.GP.StructureIdentification-3.3.csproj">112 <Project>{74223A32-C726-4978-BE78-37113A18373C}</Project>113 <Name>HeuristicLab.GP.StructureIdentification-3.3</Name>114 </ProjectReference>115 111 <ProjectReference Include="..\..\HeuristicLab.Logging\3.2\HeuristicLab.Logging-3.2.csproj"> 116 112 <Project>{4095C92C-5A4C-44BC-9963-5F384CF5CC3F}</Project> 117 113 <Name>HeuristicLab.Logging-3.2</Name> 114 </ProjectReference> 115 <ProjectReference Include="..\..\HeuristicLab.Modeling\3.2\HeuristicLab.Modeling-3.2.csproj"> 116 <Project>{80F7FADA-549D-4151-8856-79B620A50DBA}</Project> 117 <Name>HeuristicLab.Modeling-3.2</Name> 118 118 </ProjectReference> 119 119 <ProjectReference Include="..\..\HeuristicLab.Operators.Programmable\3.2\HeuristicLab.Operators.Programmable-3.2.csproj"> -
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/HeuristicLabSupportVectorMachinesPlugin.cs
r1854 r1857 33 33 [Dependency(Dependency = "HeuristicLab.Data-3.2")] 34 34 [Dependency(Dependency = "HeuristicLab.DataAnalysis-3.2")] 35 [Dependency(Dependency = "HeuristicLab. GP.StructureIdentification-3.3")]35 [Dependency(Dependency = "HeuristicLab.Modeling-3.2")] 36 36 [Dependency(Dependency = "HeuristicLab.SequentialEngine-3.2")] 37 37 [Dependency(Dependency = "HeuristicLab.Logging-3.2")] -
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorRegression.cs
r1854 r1857 33 33 using HeuristicLab.Logging; 34 34 using HeuristicLab.Operators.Programmable; 35 using HeuristicLab.Modeling; 35 36 36 37 namespace HeuristicLab.SupportVectorMachines { 37 public class SupportVectorRegression : ItemBase, IEditable { 38 public class SupportVectorRegression : ItemBase, IEditable, IAlgorithm { 39 40 public string Name { get { return "SupportVectorRegression"; } } 41 public string Description { get { return "TODO"; } } 42 38 43 private SequentialEngine.SequentialEngine engine; 39 44 public IEngine Engine {
Note: See TracChangeset
for help on using the changeset viewer.