Changeset 2126 for trunk/sources/HeuristicLab.SupportVectorMachines
- Timestamp:
- 07/01/09 21:32:22 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorRegression.cs
r2055 r2126 98 98 } 99 99 100 public DoubleArrayData GammaList { 101 get { return GetVariableInjector().GetVariable("GammaList").GetValue<DoubleArrayData>(); } 102 set { GetVariableInjector().GetVariable("GammaList").Value = value; } 103 } 104 105 public int MaxGammaIndex { 106 get { return GetVariableInjector().GetVariable("MaxGammaIndex").GetValue<IntData>().Data; } 107 set { GetVariableInjector().GetVariable("MaxGammaIndex").GetValue<IntData>().Data = value; } 108 } 109 100 110 public SupportVectorRegression() { 101 111 engine = new SequentialEngine.SequentialEngine(); … … 105 115 MaxCostIndex = CostList.Data.Length; 106 116 MaxNuIndex = NuList.Data.Length; 117 MaxGammaIndex = GammaList.Data.Length; 107 118 } 108 119 109 120 private CombinedOperator CreateAlgorithm() { 110 121 CombinedOperator algo = new CombinedOperator(); 122 SequentialProcessor seq = new SequentialProcessor(); 111 123 algo.Name = "SupportVectorRegression"; 124 seq.Name = "SupportVectorRegression"; 125 126 IOperator initialization = CreateInitialization(); 112 127 IOperator main = CreateMainLoop(); 113 algo.OperatorGraph.AddOperator(main); 114 algo.OperatorGraph.InitialOperator = main; 128 IOperator postProc = CreateModelAnalyser(); 129 130 seq.AddSubOperator(initialization); 131 seq.AddSubOperator(main); 132 seq.AddSubOperator(postProc); 133 134 algo.OperatorGraph.InitialOperator = seq; 135 algo.OperatorGraph.AddOperator(seq); 136 115 137 return algo; 138 } 139 140 private IOperator CreateInitialization() { 141 SequentialProcessor seq = new SequentialProcessor(); 142 seq.Name = "Initialization"; 143 seq.AddSubOperator(CreateGlobalInjector()); 144 seq.AddSubOperator(new ProblemInjector()); 145 seq.AddSubOperator(new RandomInjector()); 146 return seq; 116 147 } 117 148 118 149 private IOperator CreateMainLoop() { 119 150 SequentialProcessor main = new SequentialProcessor(); 120 main.AddSubOperator(CreateGlobalInjector()); 121 main.AddSubOperator(new ProblemInjector()); 122 main.AddSubOperator(new RandomInjector()); 123 151 main.Name = "Main"; 152 #region initial solution 124 153 SubScopesCreater modelScopeCreator = new SubScopesCreater(); 125 154 modelScopeCreator.GetVariableInfo("SubScopes").Local = true; 126 155 modelScopeCreator.AddVariable(new HeuristicLab.Core.Variable("SubScopes", new IntData(1))); 127 156 main.AddSubOperator(modelScopeCreator); 128 157 129 158 SequentialSubScopesProcessor seqSubScopesProc = new SequentialSubScopesProcessor(); 130 159 IOperator modelProcessor = CreateModelProcessor(); 160 131 161 seqSubScopesProc.AddSubOperator(modelProcessor); 132 162 main.AddSubOperator(seqSubScopesProc); 163 #endregion 133 164 134 165 SequentialProcessor nuLoop = new SequentialProcessor(); 135 166 nuLoop.Name = "NuLoop"; 136 167 168 SequentialProcessor gammaLoop = new SequentialProcessor(); 169 gammaLoop.Name = "GammaLoop"; 170 171 nuLoop.AddSubOperator(gammaLoop); 172 137 173 IOperator costCounter = CreateCounter("Cost"); 138 174 IOperator costComparator = CreateComparator("Cost"); 139 nuLoop.AddSubOperator(costCounter); 140 nuLoop.AddSubOperator(costComparator); 175 gammaLoop.AddSubOperator(costCounter); 176 gammaLoop.AddSubOperator(costComparator); 177 141 178 ConditionalBranch costBranch = new ConditionalBranch(); 142 179 costBranch.Name = "IfValidCostIndex"; … … 146 183 SequentialProcessor costLoop = new SequentialProcessor(); 147 184 costLoop.Name = "CostLoop"; 185 186 #region selection of better solution 148 187 costLoop.AddSubOperator(modelScopeCreator); 149 188 SequentialSubScopesProcessor subScopesProcessor = new SequentialSubScopesProcessor(); … … 165 204 RightReducer reducer = new RightReducer(); 166 205 costLoop.AddSubOperator(reducer); 206 #endregion 167 207 168 208 costLoop.AddSubOperator(costCounter); … … 172 212 costLoop.AddSubOperator(costBranch); 173 213 174 nuLoop.AddSubOperator(costBranch); 175 nuLoop.AddSubOperator(CreateResetOperator("CostIndex")); 214 gammaLoop.AddSubOperator(costBranch); // inner loop 215 gammaLoop.AddSubOperator(CreateResetOperator("CostIndex", -1)); 216 gammaLoop.AddSubOperator(CreateCounter("Gamma")); 217 gammaLoop.AddSubOperator(CreateComparator("Gamma")); 218 219 ConditionalBranch gammaBranch = new ConditionalBranch(); 220 gammaBranch.Name = "GammaLoop"; 221 gammaBranch.GetVariableInfo("Condition").ActualName = "RepeatGammaLoop"; 222 gammaBranch.AddSubOperator(gammaLoop); 223 gammaLoop.AddSubOperator(gammaBranch); 224 225 nuLoop.AddSubOperator(CreateResetOperator("GammaIndex", 0)); 176 226 177 227 nuLoop.AddSubOperator(CreateCounter("Nu")); … … 181 231 nuBranch.Name = "NuLoop"; 182 232 nuBranch.GetVariableInfo("Condition").ActualName = "RepeatNuLoop"; 233 183 234 nuBranch.AddSubOperator(nuLoop); 184 235 nuLoop.AddSubOperator(nuBranch); 185 236 186 237 main.AddSubOperator(nuLoop); 187 main.AddSubOperator(CreateModelAnalyser());188 238 return main; 189 239 } … … 193 243 modelProcessor.AddSubOperator(CreateSetNextParameterValueOperator("Nu")); 194 244 modelProcessor.AddSubOperator(CreateSetNextParameterValueOperator("Cost")); 245 modelProcessor.AddSubOperator(CreateSetNextParameterValueOperator("Gamma")); 195 246 196 247 SupportVectorCreator modelCreator = new SupportVectorCreator(); … … 215 266 ((ItemList<StringData>)collector.GetVariable("VariableNames").Value).Add(new StringData("Nu")); 216 267 ((ItemList<StringData>)collector.GetVariable("VariableNames").Value).Add(new StringData("Cost")); 268 ((ItemList<StringData>)collector.GetVariable("VariableNames").Value).Add(new StringData("Gamma")); 217 269 ((ItemList<StringData>)collector.GetVariable("VariableNames").Value).Add(new StringData("ValidationQuality")); 218 270 modelProcessor.AddSubOperator(collector); … … 298 350 } 299 351 300 private IOperator CreateResetOperator(string paramName ) {352 private IOperator CreateResetOperator(string paramName, int value) { 301 353 ProgrammableOperator progOp = new ProgrammableOperator(); 302 354 progOp.Name = "Reset" + paramName; 303 355 progOp.RemoveVariableInfo("Result"); 304 356 progOp.AddVariableInfo(new VariableInfo("Value", "Value", typeof(IntData), VariableKind.In | VariableKind.Out)); 305 progOp.Code = "Value.Data = -1;";357 progOp.Code = "Value.Data = "+value+";"; 306 358 progOp.GetVariableInfo("Value").ActualName = paramName; 307 359 return progOp; … … 311 363 VariableInjector injector = new VariableInjector(); 312 364 injector.AddVariable(new HeuristicLab.Core.Variable("CostIndex", new IntData(0))); 313 injector.AddVariable(new HeuristicLab.Core.Variable("CostList", new DoubleArrayData(new double[] { 0.1, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0 }))); 365 injector.AddVariable(new HeuristicLab.Core.Variable("CostList", new DoubleArrayData(new double[] { 366 Math.Pow(2,-5), 367 Math.Pow(2,-3), 368 Math.Pow(2,-1), 369 2, 370 Math.Pow(2,3), 371 Math.Pow(2,5), 372 Math.Pow(2,7), 373 Math.Pow(2,9), 374 Math.Pow(2,11), 375 Math.Pow(2,13), 376 Math.Pow(2,15)}))); 314 377 injector.AddVariable(new HeuristicLab.Core.Variable("MaxCostIndex", new IntData())); 315 378 injector.AddVariable(new HeuristicLab.Core.Variable("NuIndex", new IntData(0))); 316 injector.AddVariable(new HeuristicLab.Core.Variable("NuList", new DoubleArrayData(new double[] { 0. 01, 0.05, 0.1, 0.5})));379 injector.AddVariable(new HeuristicLab.Core.Variable("NuList", new DoubleArrayData(new double[] { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9, 0.8, 1 }))); 317 380 injector.AddVariable(new HeuristicLab.Core.Variable("MaxNuIndex", new IntData())); 318 381 injector.AddVariable(new HeuristicLab.Core.Variable("Log", new ItemList())); 319 injector.AddVariable(new HeuristicLab.Core.Variable("Gamma", new DoubleData(1))); 382 injector.AddVariable(new HeuristicLab.Core.Variable("GammaIndex", new IntData(0))); 383 injector.AddVariable(new HeuristicLab.Core.Variable("GammaList", new DoubleArrayData(new double[] { 384 3.0517578125E-05, 0.0001220703125,0.00048828125,0.001953125, 385 0.0078125,0.03125,0.125,0.5,2,4,8}))); 386 injector.AddVariable(new HeuristicLab.Core.Variable("MaxGammaIndex", new IntData())); 320 387 injector.AddVariable(new HeuristicLab.Core.Variable("KernelType", new StringData("RBF"))); 321 388 injector.AddVariable(new HeuristicLab.Core.Variable("Type", new StringData("NU_SVR"))); … … 383 450 384 451 private IOperator GetVariableInjector() { 385 return GetMainOperator().SubOperators[0] ;452 return GetMainOperator().SubOperators[0].SubOperators[0]; 386 453 } 387 454
Note: See TracChangeset
for help on using the changeset viewer.