Changeset 1130
- Timestamp:
- 01/14/09 20:48:04 (16 years ago)
- Location:
- branches/CEDMA-Refactoring-Ticket419
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Console.cs
r1129 r1130 79 79 binding.ReaderQuotas.MaxStringContentLength = 1000000000; // also 100M chars 80 80 binding.ReaderQuotas.MaxArrayLength = 1000000000; // also 100M elements; 81 binding.Security.Mode = SecurityMode.None;82 81 factory = new ChannelFactory<IStore>(binding); 83 82 store = factory.CreateChannel(new EndpointAddress(serverUri)); -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSet.cs
r1129 r1130 49 49 // lazy loading of problem from DB 50 50 if (problem == null) { 51 var serializedDataVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("SerializedData"); 51 //var serializedDataVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("SerializedData"); 52 //var persistedData = Store.Query( 53 // new Statement[] { new Statement(new Entity(Ontology.CedmaNameSpace + Guid), Ontology.PredicateSerializedData, serializedDataVar)}); 52 54 var persistedData = Store.Query( 53 new Statement[] { new Statement(new Entity(Ontology.CedmaNameSpace + Guid), Ontology.PredicateSerializedData, serializedDataVar)});55 "<" + Ontology.CedmaNameSpace + Guid + "> <" + Ontology.PredicateSerializedData.Uri + "> ?SerializedData ."); 54 56 if (persistedData.Count() == 1) { 55 57 Literal persistedLiteral = (Literal)persistedData.First().Get("SerializedData"); -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/Ontology.cs
r988 r1130 33 33 } 34 34 35 #region model attributes 36 public static Entity PredicateModelAttribute { 37 get { return new Entity(CedmaNameSpace + "ModelAttribute"); } 38 } 39 public static Entity PredicateModelAttributeName { 40 get { return new Entity(CedmaNameSpace + "ModelAttributeName"); } 41 } 42 public static Entity PredicateModelAttributeValue { 43 get { return new Entity(CedmaNameSpace + "ModelAttributeValue"); } 44 } 45 public static Entity PredicateModelAttributeType { 46 get { return new Entity(CedmaNameSpace + "ModelAttributeType"); } 47 } 35 #region model attribute types 48 36 /// <summary> 49 37 /// Attribute value is ordinal, values can be sorted. … … 118 106 #endregion 119 107 108 #region default attributes 109 public static Entity TargetVariable { 110 get { return new Entity(CedmaNameSpace + "TargetVariable"); } 111 } 112 public static Entity TrainingMeanSquaredError { 113 get { return new Entity(CedmaNameSpace + "TrainingMeanSquaredError"); } 114 } 115 public static Entity ValidationMeanSquaredError { 116 get { return new Entity(CedmaNameSpace + "ValidationMeanSquaredError"); } 117 } 118 public static Entity TrainingMeanAbsolutePercentageError { 119 get { return new Entity(CedmaNameSpace + "TrainingMeanAbsolutePercentageError"); } 120 } 121 public static Entity ValidationMeanAbsolutePercentageError { 122 get { return new Entity(CedmaNameSpace + "ValidationMeanAbsolutePercentageError"); } 123 } 124 public static Entity TreeSize { 125 get { return new Entity(CedmaNameSpace + "TreeSize"); } 126 } 127 public static Entity TreeHeight { 128 get { return new Entity(CedmaNameSpace + "TreeHeight"); } 129 } 130 public static Entity EvaluatedSolutions { 131 get { return new Entity(CedmaNameSpace + "EvaluatedSolutions"); } 132 } 133 #endregion 134 135 public static ICollection<Statement> InitialStatements { 136 get { 137 return new List<Statement> { 138 new Statement(TargetVariable, PredicateInstanceOf, TypeCategoricalAttribute), 139 new Statement(TrainingMeanSquaredError, PredicateInstanceOf, TypeOrdinalAttribute), 140 new Statement(TrainingMeanSquaredError, PredicateInstanceOf, TypeQualityAttribute), 141 new Statement(ValidationMeanSquaredError, PredicateInstanceOf, TypeOrdinalAttribute), 142 new Statement(ValidationMeanSquaredError, PredicateInstanceOf, TypeQualityAttribute), 143 new Statement(TrainingMeanAbsolutePercentageError, PredicateInstanceOf, TypeOrdinalAttribute), 144 new Statement(TrainingMeanAbsolutePercentageError, PredicateInstanceOf, TypeQualityAttribute), 145 new Statement(ValidationMeanAbsolutePercentageError, PredicateInstanceOf, TypeOrdinalAttribute), 146 new Statement(ValidationMeanAbsolutePercentageError, PredicateInstanceOf, TypeQualityAttribute), 147 new Statement(TreeSize, PredicateInstanceOf, TypeOrdinalAttribute), 148 new Statement(TreeSize, PredicateInstanceOf, TypeComplexityAttribute), 149 new Statement(TreeHeight, PredicateInstanceOf, TypeOrdinalAttribute), 150 new Statement(TreeHeight, PredicateInstanceOf, TypeComplexityAttribute), 151 new Statement(EvaluatedSolutions, PredicateInstanceOf, TypeOrdinalAttribute) 152 }; 153 } 154 } 155 156 120 157 /// <summary> 121 158 /// Wildcard entity for filtering. -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB/Store.cs
r1129 r1130 45 45 this.connectionString = connectionString; 46 46 store = SemWeb.Store.Create(connectionString); 47 InitStore(); 48 } 49 } 50 51 private void InitStore() { 52 foreach (Statement s in Ontology.InitialStatements) { 53 Add(s); 47 54 } 48 55 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/Dispatcher.cs
r1129 r1130 51 51 52 52 private void FillDispatchQueue() { 53 //Dictionary<Entity, Dictionary<int, int>> numberOfModelsOfTargetVariableOfDataSet = new Dictionary<Entity, Dictionary<int, int>>(); 54 //var datasetStatements = store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateInstanceOf, Ontology.TypeDataSet)); 55 //foreach (Statement datasetStatement in datasetStatements) { 56 // numberOfModelsOfTargetVariableOfDataSet.Add(datasetStatement.Subject, new Dictionary<int, int>()); 57 // var modelStatements = store.Select(new Statement(datasetStatement.Subject, Ontology.PredicateHasModel, Ontology.AnyEntity)); 58 // foreach (Statement modelStatement in modelStatements) { 59 // var modelAttributeStatements = store.Select(new Statement((Entity)modelStatement.Property, Ontology.PredicateModelAttribute, Ontology.AnyEntity)); 60 // foreach (Statement modelAttrStatement in modelAttributeStatements) { 61 // var targetVariableStatements = store.Select(new Statement((Entity)modelAttrStatement.Property, Ontology.PredicateModelAttributeName, Ontology.AnyEntity)) 62 // .Where(t => (string)((Literal)t.Property).Value == "TargetVariable") 63 // .SelectMany(t => store.Select(new Statement((Entity)modelAttrStatement.Property, Ontology.PredicateModelAttributeValue, Ontology.AnyEntity))) 64 // .GroupBy(t => (int)((Literal)t.Property).Value); 65 // foreach (var targetVariable in targetVariableStatements) { 66 // if (numberOfModelsOfTargetVariableOfDataSet[datasetStatement.Subject].ContainsKey(targetVariable.Key)) { 67 // numberOfModelsOfTargetVariableOfDataSet[datasetStatement.Subject][targetVariable.Key] = targetVariable.Count(); 68 // } else { 69 // numberOfModelsOfTargetVariableOfDataSet[datasetStatement.Subject].Add(targetVariable.Key, targetVariable.Count()); 70 // } 71 // } 72 // } 73 // } 74 //} 75 //foreach (KeyValuePair<Entity, Dictionary<int, int>> dataSetEntry in numberOfModelsOfTargetVariableOfDataSet) { 76 // DataSet dataSet = new DataSet(store, dataSetEntry.Key); 77 // foreach (int targetVariable in dataSet.Problem.AllowedTargetVariables) 78 // if (!dataSetEntry.Value.ContainsKey(targetVariable) || dataSetEntry.Value[targetVariable] < 10) { 79 // IEngine engine = CreateEngine(dataSet.Problem, targetVariable); 80 // if (engine != null) { 81 // QueueJob(new Execution(dataSetEntry.Key, engine, targetVariable)); 82 // } 83 // } 84 //} 53 // find and select a dataset 54 var dataSetVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("DataSet"); 55 var dataSetQuery = new Statement[] { 56 new Statement(dataSetVar, Ontology.PredicateInstanceOf, Ontology.TypeDataSet) 57 }; 58 59 var dataSetBindings = store.Query("?DataSet <"+Ontology.PredicateInstanceOf.Uri+"> <"+Ontology.TypeDataSet.Uri+"> ."); 60 61 // no datasets => do nothing 62 if (dataSetBindings.Count() == 0) return; 63 64 // assume last dataset is the most interesting one 65 // find and select all results for this dataset 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 = new Statement[] { 72 // new Statement(dataSetEntity, Ontology.PredicateHasModel, modelVar), 73 // new Statement(modelVar, Ontology.TargetVariable, targetVar), 74 // new Statement(modelVar, Ontology.ValidationMeanAbsolutePercentageError, modelMAPE) 75 //}; 76 77 var query = "<" + dataSetEntity.Uri + "> <" + Ontology.PredicateHasModel.Uri + "> ?Model ." + Environment.NewLine + 78 "?Model <" + Ontology.TargetVariable.Uri + "> ?TargetVariable ." + Environment.NewLine + 79 "?Model <" + Ontology.ValidationMeanAbsolutePercentageError.Uri + "> ?ModelMAPE ."; 80 81 82 83 var bindings = store.Query(query); 84 DataSet dataSet = new DataSet(store, dataSetEntity); 85 double[] utilization = new double[dataSet.Problem.AllowedTargetVariables.Count]; 86 int i = 0; 87 int totalN = bindings.Count(); 88 foreach (int targetVariable in dataSet.Problem.AllowedTargetVariables) { 89 var targetVarBindings = bindings.Where(x => (int)((Literal)x.Get("TargetVariable")).Value == targetVariable); 90 if (targetVarBindings.Count() == 0) { 91 utilization[i++] = double.PositiveInfinity; 92 } else { 93 double averageMape = targetVarBindings.Average(x => (double)((Literal)x.Get("ModelMAPE")).Value); 94 double n = targetVarBindings.Count(); 95 utilization[i++] = -averageMape + Math.Sqrt(Math.Log(totalN) / n) * 0.1; 96 } 97 } 98 int[] idx = Enumerable.Range(0, utilization.Length).ToArray(); 99 Array.Sort(utilization, idx); 100 int nConfigurations = utilization.Length; 101 for (int j = nConfigurations - 1; j > nConfigurations * 0.8; j--) { 102 int targetVariable = dataSet.Problem.AllowedTargetVariables[j]; 103 IEngine engine = CreateEngine(dataSet.Problem, targetVariable); 104 if (engine != null) { 105 QueueJob(new Execution(dataSetEntity, engine, targetVariable)); 106 } 107 } 85 108 } 86 109 … … 90 113 91 114 public Execution GetNextJob() { 92 if (dispatchQueue.Count == 0) FillDispatchQueue(); 115 if (dispatchQueue.Count == 0) { 116 FillDispatchQueue(); 117 } 93 118 if (dispatchQueue.Count > 0) { 94 119 Execution next = dispatchQueue[0]; … … 120 145 StandardGP sgp = new StandardGP(); 121 146 sgp.SetSeedRandomly = true; 122 sgp.MaxGenerations = 100;123 sgp.PopulationSize = 1000 ;147 sgp.MaxGenerations = 300; 148 sgp.PopulationSize = 10000; 124 149 sgp.Elites = 1; 125 150 sgp.ProblemInjector = probInjector; -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/Executer.cs
r1116 r1130 103 103 104 104 private void StoreResults(Execution finishedExecution, ProcessingEngine finishedEngine) { 105 Entity model Entity= new Entity(Ontology.CedmaNameSpace + Guid.NewGuid());106 store.Add(new Statement(model Entity, Ontology.PredicateInstanceOf, Ontology.TypeGeneticProgrammingFunctionTree));107 store.Add(new Statement(finishedExecution.DataSetEntity, Ontology.PredicateHasModel, model Entity));108 StoreModelAttribute(model Entity, "TargetVariable", finishedExecution.TargetVariable);105 Entity model = new Entity(Ontology.CedmaNameSpace + Guid.NewGuid()); 106 store.Add(new Statement(model, Ontology.PredicateInstanceOf, Ontology.TypeGeneticProgrammingFunctionTree)); 107 store.Add(new Statement(finishedExecution.DataSetEntity, Ontology.PredicateHasModel, model)); 108 StoreModelAttribute(model, Ontology.TargetVariable, finishedExecution.TargetVariable); 109 109 Scope bestModelScope = finishedEngine.GlobalScope.GetVariableValue<Scope>("BestValidationSolution", false); 110 StoreModelAttribute(model Entity, "TrainingMeanSquaredError", bestModelScope.GetVariableValue<DoubleData>("Quality", false).Data);111 StoreModelAttribute(model Entity, "ValidationMeanSquaredError", bestModelScope.GetVariableValue<DoubleData>("ValidationQuality", false).Data);112 StoreModelAttribute(model Entity, "TrainingMeanAbsolutePercentageError", bestModelScope.GetVariableValue<DoubleData>("TrainingMAPE", false).Data);113 StoreModelAttribute(model Entity, "ValidationMeanAbsolutePercentageError", bestModelScope.GetVariableValue<DoubleData>("ValidationMAPE", false).Data);114 StoreModelAttribute(model Entity, "TreeSize", bestModelScope.GetVariableValue<IntData>("TreeSize", false).Data);115 StoreModelAttribute(model Entity, "TreeHeight", bestModelScope.GetVariableValue<IntData>("TreeHeight", false).Data);116 StoreModelAttribute(model Entity, "EvaluatedSolutions", bestModelScope.GetVariableValue<IntData>("EvaluatedSolutions", false).Data);110 StoreModelAttribute(model, Ontology.TrainingMeanSquaredError, bestModelScope.GetVariableValue<DoubleData>("Quality", false).Data); 111 StoreModelAttribute(model, Ontology.ValidationMeanSquaredError, bestModelScope.GetVariableValue<DoubleData>("ValidationQuality", false).Data); 112 StoreModelAttribute(model, Ontology.TrainingMeanAbsolutePercentageError, bestModelScope.GetVariableValue<DoubleData>("TrainingMAPE", false).Data); 113 StoreModelAttribute(model, Ontology.ValidationMeanAbsolutePercentageError, bestModelScope.GetVariableValue<DoubleData>("ValidationMAPE", false).Data); 114 StoreModelAttribute(model, Ontology.TreeSize, bestModelScope.GetVariableValue<IntData>("TreeSize", false).Data); 115 StoreModelAttribute(model, Ontology.TreeHeight, bestModelScope.GetVariableValue<IntData>("TreeHeight", false).Data); 116 StoreModelAttribute(model, Ontology.EvaluatedSolutions, bestModelScope.GetVariableValue<IntData>("EvaluatedSolutions", false).Data); 117 117 118 118 byte[] serializedModel = PersistenceManager.SaveToGZip(bestModelScope.GetVariableValue("FunctionTree", false)); 119 store.Add(new Statement(modelEntity, Ontology.PredicateSerializedData, new Literal(Convert.ToBase64String(serializedModel)))); 119 store.Add(new Statement(model, Ontology.PredicateSerializedData, new Literal(Convert.ToBase64String(serializedModel)))); 120 } 120 121 121 } 122 123 private void StoreModelAttribute(Entity model, string name, object value) { 124 Entity attr = new Entity(Ontology.CedmaNameSpace + Guid.NewGuid()); 125 store.Add(new Statement(model, Ontology.PredicateModelAttribute, attr)); 126 store.Add(new Statement(attr, Ontology.PredicateModelAttributeName, new Literal(name))); 127 store.Add(new Statement(attr, Ontology.PredicateModelAttributeValue, new Literal(value))); 128 store.Add(new Statement(attr, Ontology.PredicateModelAttributeType, Ontology.TypeOrdinalAttribute)); 122 private void StoreModelAttribute(Entity model, Entity predicate, object value) { 123 store.Add(new Statement(model, predicate, new Literal(value))); 129 124 } 130 125 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/Server.cs
r1129 r1130 75 75 binding.ReaderQuotas.MaxStringContentLength = 1000000000; // also 100M chars 76 76 binding.ReaderQuotas.MaxArrayLength = 1000000000; // also 100M elements; 77 binding.Security.Mode = SecurityMode.None;78 79 77 host.AddServiceEndpoint(typeof(IStore), binding, cedmaServiceUrl); 80 78 host.Open(); -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.Grid/GridClient.cs
r766 r1130 101 101 binding.ReaderQuotas.MaxStringContentLength = 100000000; // also 100M chars 102 102 binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements; 103 binding.Security.Mode = SecurityMode.None;104 103 factory = new ChannelFactory<IEngineStore>(binding); 105 104 engineStore = factory.CreateChannel(new EndpointAddress(uri)); -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.Grid/JobManager.cs
r1113 r1130 99 99 binding.ReaderQuotas.MaxStringContentLength = 100000000; // also 100M chars 100 100 binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements; 101 binding.Security.Mode = SecurityMode.None;102 101 103 102 factory = new ChannelFactory<IGridServer>(binding); -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.Grid/ServerForm.cs
r1113 r1130 73 73 binding.ReaderQuotas.MaxStringContentLength = 100000000; // also 100M chars 74 74 binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements; 75 binding.Security.Mode = SecurityMode.None;76 77 78 75 externalHost.AddServiceEndpoint(typeof(IGridServer), binding, externalAddressTextBox.Text); 79 76 externalHost.Open();
Note: See TracChangeset
for help on using the changeset viewer.