- Timestamp:
- 02/12/09 14:05:33 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/Dispatcher.cs
r1151 r1216 57 57 }; 58 58 59 var dataSetBindings = store.Query("?DataSet <" +Ontology.PredicateInstanceOf.Uri+"> <"+Ontology.TypeDataSet.Uri+"> .");59 var dataSetBindings = store.Query("?DataSet <" + Ontology.PredicateInstanceOf.Uri + "> <" + Ontology.TypeDataSet.Uri + "> ."); 60 60 61 61 // no datasets => do nothing … … 65 65 // find and select all results for this dataset 66 66 var dataSetEntity = (Entity)dataSetBindings.Last().Get("DataSet"); 67 var targetVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("TargetVariable");68 var modelVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("Model");69 var modelMAPE = new HeuristicLab.CEDMA.DB.Interfaces.Variable("ModelMAPE");70 71 var query = "<" + dataSetEntity.Uri + "> <" + Ontology.PredicateHasModel.Uri + "> ?Model ." + Environment.NewLine +72 "?Model <" + Ontology.TargetVariable.Uri + "> ?TargetVariable ." + Environment.NewLine +73 "?Model <" + Ontology.ValidationMeanAbsolutePercentageError.Uri + "> ?ModelMAPE .";74 75 76 77 var bindings = store.Query(query);78 67 DataSet dataSet = new DataSet(store, dataSetEntity); 79 double[] utilization = new double[dataSet.Problem.AllowedTargetVariables.Count]; 80 int i = 0; 81 int totalN = bindings.Count(); 82 foreach (int targetVariable in dataSet.Problem.AllowedTargetVariables) { 83 var targetVarBindings = bindings.Where(x => (int)((Literal)x.Get("TargetVariable")).Value == targetVariable); 84 if (targetVarBindings.Count() == 0) { 85 utilization[i++] = double.PositiveInfinity; 86 } else { 87 double averageMape = targetVarBindings.Average(x => (double)((Literal)x.Get("ModelMAPE")).Value); 88 double n = targetVarBindings.Count(); 89 utilization[i++] = -averageMape + Math.Sqrt(Math.Log(totalN) / n) * 0.1; 90 } 91 } 92 int[] idx = Enumerable.Range(0, utilization.Length).ToArray(); 93 Array.Sort(utilization, idx); 94 int nConfigurations = utilization.Length; 95 for (int j = nConfigurations - 1; j > nConfigurations * 0.8; j--) { 96 int targetVariable = dataSet.Problem.AllowedTargetVariables[idx[j]]; 97 IEngine engine = CreateEngine(dataSet.Problem, targetVariable); 98 if (engine != null) { 99 QueueJob(new Execution(dataSetEntity, engine, targetVariable)); 100 } 68 Random random = new Random(); 69 int targetVariable = dataSet.Problem.AllowedInputVariables[random.Next(0, dataSet.Problem.AllowedInputVariables.Count)]; 70 string targetVariableName = dataSet.Problem.GetVariableName(targetVariable); 71 Execution exec = CreateExecution(dataSet.Problem, targetVariable); 72 if (exec != null) { 73 exec.DataSetEntity = dataSetEntity; 74 exec.TargetVariable = targetVariableName; 75 QueueJob(exec); 101 76 } 102 77 } … … 122 97 } 123 98 124 private IEngine CreateEngine(Problem problem, int targetVariable) {99 private Execution CreateExecution(Problem problem, int targetVariable) { 125 100 switch (problem.LearningTask) { 126 101 case LearningTask.Classification: return null; 127 102 case LearningTask.Regression: { 128 return CreateStandardGp (problem, targetVariable).Engine;103 return CreateStandardGpExecution(problem, targetVariable, 100, 10); 129 104 } 130 105 case LearningTask.TimeSeries: return null; … … 134 109 } 135 110 136 private StandardGP CreateStandardGp(Problem problem, int targetVariable) {111 private Execution CreateStandardGpExecution(Problem problem, int targetVariable, int maxTreeSize, int maxTreeHeight) { 137 112 ProblemInjector probInjector = new ProblemInjector(problem); 138 113 probInjector.TargetVariable = targetVariable; 139 114 StandardGP sgp = new StandardGP(); 140 115 sgp.SetSeedRandomly = true; 141 sgp.MaxGenerations = 300;142 sgp.PopulationSize = 100 00;116 sgp.MaxGenerations = 2; 117 sgp.PopulationSize = 100; 143 118 sgp.Elites = 1; 144 119 sgp.ProblemInjector = probInjector; 145 return sgp; 120 sgp.MaxTreeHeight = maxTreeHeight; 121 sgp.MaxTreeSize = maxTreeSize; 122 Execution exec = new Execution(sgp.Engine); 123 exec.Description = "StandardGP - Medium Complexity"; 124 return exec; 146 125 } 147 126 }
Note: See TracChangeset
for help on using the changeset viewer.