Changeset 1266
- Timestamp:
- 03/05/09 20:08:00 (15 years ago)
- Location:
- branches/CEDMA-Refactoring-Ticket419
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/HeuristicLab.CEDMA.Core.csproj
r1109 r1266 107 107 </Compile> 108 108 <Compile Include="Properties\AssemblyInfo.cs" /> 109 <Compile Include="ProblemInjector.cs" />110 109 <Compile Include="Results.cs" /> 111 110 </ItemGroup> -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Problem.cs
r1215 r1266 104 104 get { return autoRegressive; } 105 105 set { autoRegressive = value; } 106 } 107 108 private int minTimeOffset; 109 public int MinTimeOffset { 110 get { return minTimeOffset; } 111 set { minTimeOffset = value; } 112 } 113 114 private int maxTimeOffset; 115 public int MaxTimeOffset { 116 get { return maxTimeOffset; } 117 set { maxTimeOffset = value; } 106 118 } 107 119 … … 147 159 XmlAttribute autoRegressiveAttr = document.CreateAttribute("AutoRegressive"); 148 160 autoRegressiveAttr.Value = AutoRegressive.ToString(); 161 XmlAttribute minTimeOffsetAttr = document.CreateAttribute("MinTimeOffset"); 162 minTimeOffsetAttr.Value = MinTimeOffset.ToString(); 163 XmlAttribute maxTimeOffsetAttr = document.CreateAttribute("MaxTimeOffset"); 164 maxTimeOffsetAttr.Value = MaxTimeOffset.ToString(); 149 165 150 166 node.Attributes.Append(trainingSamplesStartAttr); … … 156 172 node.Attributes.Append(learningTaskAttr); 157 173 node.Attributes.Append(autoRegressiveAttr); 174 node.Attributes.Append(minTimeOffsetAttr); 175 node.Attributes.Append(maxTimeOffsetAttr); 158 176 159 177 XmlElement targetVariablesElement = document.CreateElement("AllowedTargetVariables"); … … 177 195 LearningTask = (LearningTask)Enum.Parse(typeof(LearningTask), node.Attributes["LearningTask"].Value); 178 196 AutoRegressive = bool.Parse(node.Attributes["AutoRegressive"].Value); 197 if (node.Attributes["MinTimeOffset"] != null) 198 MinTimeOffset = XmlConvert.ToInt32(node.Attributes["MinTimeOffset"].Value); 199 else MinTimeOffset = 0; 200 if (node.Attributes["MaxTimeOffset"] != null) 201 MaxTimeOffset = XmlConvert.ToInt32(node.Attributes["MaxTimeOffset"].Value); 202 else MaxTimeOffset = 0; 203 179 204 allowedTargetVariables.Clear(); 180 205 foreach (string tok in node.SelectSingleNode("AllowedTargetVariables").InnerText.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries)) -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/DispatcherBase.cs
r1252 r1266 37 37 38 38 namespace HeuristicLab.CEDMA.Server { 39 public abstract class DispatcherBase : IDispatcher {39 public abstract class DispatcherBase : IDispatcher { 40 40 public enum ModelComplexity { Low, Medium, High }; 41 public enum Algorithm { StandardG P};41 public enum Algorithm { StandardGpRegression, OffspringGpRegression, StandardGpClassification, OffspringGpClassification, StandardGpForecasting, OffspringGpForecasting }; 42 42 43 43 private IStore store; 44 44 private ModelComplexity[] possibleComplexities = new ModelComplexity[] { ModelComplexity.Low, ModelComplexity.Medium, ModelComplexity.High }; 45 45 private Dictionary<LearningTask, Algorithm[]> possibleAlgorithms = new Dictionary<LearningTask, Algorithm[]>() { 46 {LearningTask.Classification, new Algorithm[] { }},47 {LearningTask.Regression, new Algorithm[] { Algorithm.StandardG P}},48 {LearningTask.TimeSeries, new 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 49 }; 50 50 … … 90 90 private Execution CreateExecution(Problem problem, int targetVariable, Algorithm algorithm, ModelComplexity complexity) { 91 91 switch (algorithm) { 92 case Algorithm.StandardGP: { 93 return CreateStandardGpExecution(problem, targetVariable, complexity); 92 case Algorithm.StandardGpRegression: { 93 var algo = new HeuristicLab.GP.StructureIdentification.StandardGP(); 94 SetGpParameters(algo, complexity); 95 SetProblemParameters(algo, problem, targetVariable); 96 algo.MaxGenerations = 2; 97 Execution exec = new Execution(algo.Engine); 98 exec.Description = "StandardGP - Complexity: " + complexity; 99 return exec; 100 } 101 case Algorithm.OffspringGpRegression: { 102 var algo = new HeuristicLab.GP.StructureIdentification.OffspringSelectionGP(); 103 SetGpParameters(algo, complexity); 104 SetProblemParameters(algo, problem, targetVariable); 105 algo.MaxEvaluatedSolutions = 10000; 106 Execution exec = new Execution(algo.Engine); 107 exec.Description = "OffspringGP - Complexity: " + complexity; 108 return exec; 109 } 110 case Algorithm.StandardGpClassification: { 111 var algo = new HeuristicLab.GP.StructureIdentification.Classification.StandardGP(); 112 SetGpParameters(algo, complexity); 113 SetProblemParameters(algo, problem, targetVariable); 114 algo.MaxGenerations = 2; 115 Execution exec = new Execution(algo.Engine); 116 exec.Description = "StandardGP - Complexity: " + complexity; 117 return exec; 118 } 119 case Algorithm.OffspringGpClassification: { 120 var algo = new HeuristicLab.GP.StructureIdentification.Classification.OffspringSelectionGP(); 121 SetGpParameters(algo, complexity); 122 SetProblemParameters(algo, problem, targetVariable); 123 algo.MaxEvaluatedSolutions = 10000; 124 Execution exec = new Execution(algo.Engine); 125 exec.Description = "OffspringGP - Complexity: " + complexity; 126 return exec; 127 } 128 case Algorithm.StandardGpForecasting: { 129 var algo = new HeuristicLab.GP.StructureIdentification.TimeSeries.StandardGP(); 130 SetGpParameters(algo, complexity); 131 SetProblemParameters(algo, problem, targetVariable); 132 algo.MaxGenerations = 2; 133 Execution exec = new Execution(algo.Engine); 134 exec.Description = "StandardGP - Complexity: " + complexity; 135 return exec; 136 } 137 case Algorithm.OffspringGpForecasting: { 138 var algo = new HeuristicLab.GP.StructureIdentification.TimeSeries.OffspringSelectionGP(); 139 SetGpParameters(algo, complexity); 140 SetProblemParameters(algo, problem, targetVariable); 141 algo.MaxEvaluatedSolutions = 10000; 142 Execution exec = new Execution(algo.Engine); 143 exec.Description = "OffspringGP - Complexity: " + complexity; 144 return exec; 94 145 } 95 146 default: { … … 99 150 } 100 151 101 private Execution CreateStandardGpExecution(Problem problem, int targetVariable, ModelComplexity complexity) { 102 HeuristicLab.CEDMA.Core.ProblemInjector probInjector = new HeuristicLab.CEDMA.Core.ProblemInjector(problem); 103 probInjector.TargetVariable = targetVariable; 104 StandardGP sgp = new StandardGP(); 105 sgp.SetSeedRandomly = true; 106 sgp.MaxGenerations = 2; 107 sgp.PopulationSize = 100; 108 sgp.Elites = 1; 109 sgp.ProblemInjector = probInjector; 110 111 int maxTreeHeight = 10; 112 int maxTreeSize = 100; 152 private void SetGpParameters(AlgorithmBase algo, ModelComplexity complexity) { 153 algo.SetSeedRandomly = true; 154 algo.PopulationSize = 1000; 155 algo.Elites = 1; 113 156 switch (complexity) { 114 157 case ModelComplexity.Low: { 115 maxTreeHeight = 5;116 maxTreeSize = 20;158 algo.MaxTreeHeight = 5; 159 algo.MaxTreeSize = 20; 117 160 break; 118 161 } 119 162 case ModelComplexity.Medium: { 120 maxTreeHeight = 10;121 maxTreeSize = 100;163 algo.MaxTreeHeight = 10; 164 algo.MaxTreeSize = 100; 122 165 break; 123 166 } 124 167 case ModelComplexity.High: { 125 maxTreeHeight = 12;126 maxTreeSize = 200;168 algo.MaxTreeHeight = 12; 169 algo.MaxTreeSize = 200; 127 170 break; 128 171 } 129 172 } 130 131 sgp.MaxTreeHeight = maxTreeHeight; 132 sgp.MaxTreeSize = maxTreeSize; 133 Execution exec = new Execution(sgp.Engine); 134 exec.Description = "StandardGP - Complexity: " + complexity; 135 return exec; 173 } 174 175 private void SetProblemParameters(AlgorithmBase algo, Problem problem, int targetVariable) { 176 algo.ProblemInjector.GetVariable("Dataset").Value = problem.DataSet; 177 algo.ProblemInjector.GetVariable("TargetVariable").GetValue<IntData>().Data = targetVariable; 178 algo.ProblemInjector.GetVariable("TrainingSamplesStart").GetValue<IntData>().Data = problem.TrainingSamplesStart; 179 algo.ProblemInjector.GetVariable("TrainingSamplesEnd").GetValue<IntData>().Data = problem.TrainingSamplesEnd; 180 algo.ProblemInjector.GetVariable("ValidationSamplesStart").GetValue<IntData>().Data = problem.ValidationSamplesStart; 181 algo.ProblemInjector.GetVariable("ValidationSamplesEnd").GetValue<IntData>().Data = problem.ValidationSamplesEnd; 182 algo.ProblemInjector.GetVariable("TestSamplesStart").GetValue<IntData>().Data = problem.TestSamplesStart; 183 algo.ProblemInjector.GetVariable("TestSamplesEnd").GetValue<IntData>().Data = problem.TestSamplesEnd; 184 ItemList<IntData> allowedFeatures = algo.ProblemInjector.GetVariable("AllowedFeatures").GetValue<ItemList<IntData>>(); 185 foreach (int allowedFeature in problem.AllowedInputVariables) allowedFeatures.Add(new IntData(allowedFeature)); 186 187 if (problem.LearningTask == LearningTask.TimeSeries) { 188 algo.ProblemInjector.GetVariable("Autoregressive").GetValue<BoolData>().Data = problem.AutoRegressive; 189 algo.ProblemInjector.GetVariable("MinTimeOffset").GetValue<IntData>().Data = problem.MinTimeOffset; 190 algo.ProblemInjector.GetVariable("MaxTimeOffset").GetValue<IntData>().Data = problem.MaxTimeOffset; 191 } else if (problem.LearningTask == LearningTask.Classification) { 192 ItemList<DoubleData> classValues = algo.ProblemInjector.GetVariable("TargetClassValues").GetValue<ItemList<DoubleData>>(); 193 foreach (double classValue in GetDifferentClassValues(problem.DataSet, targetVariable)) classValues.Add(new DoubleData(classValue)); 194 } 195 } 196 197 private IEnumerable<double> GetDifferentClassValues(HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable) { 198 throw new NotImplementedException(); 136 199 } 137 200 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/HeuristicLab.CEDMA.Server.csproj
r1217 r1266 108 108 <Name>HeuristicLab.Core</Name> 109 109 </ProjectReference> 110 <ProjectReference Include="..\HeuristicLab.DataAnalysis\HeuristicLab.DataAnalysis.csproj"> 111 <Project>{7DD3A97A-56E9-462F-90E2-A351FE7AF5C2}</Project> 112 <Name>HeuristicLab.DataAnalysis</Name> 113 </ProjectReference> 110 114 <ProjectReference Include="..\HeuristicLab.Data\HeuristicLab.Data.csproj"> 111 115 <Project>{F473D9AF-3F09-4296-9F28-3C65118DAFFA}</Project> 112 116 <Name>HeuristicLab.Data</Name> 117 </ProjectReference> 118 <ProjectReference Include="..\HeuristicLab.GP.StructureIdentification.Classification\HeuristicLab.GP.StructureIdentification.Classification.csproj"> 119 <Project>{7C20D100-8BEB-433A-9499-F075E2CB9297}</Project> 120 <Name>HeuristicLab.GP.StructureIdentification.Classification</Name> 121 </ProjectReference> 122 <ProjectReference Include="..\HeuristicLab.GP.StructureIdentification.TimeSeries\HeuristicLab.GP.StructureIdentification.TimeSeries.csproj"> 123 <Project>{6084CFB5-733F-449D-9F92-2E40D13F0514}</Project> 124 <Name>HeuristicLab.GP.StructureIdentification.TimeSeries</Name> 113 125 </ProjectReference> 114 126 <ProjectReference Include="..\HeuristicLab.GP.StructureIdentification\HeuristicLab.GP.StructureIdentification.csproj">
Note: See TracChangeset
for help on using the changeset viewer.