Changeset 1060
- Timestamp:
- 12/23/08 18:40:38 (16 years ago)
- Location:
- branches/CEDMA-Refactoring-Ticket419
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ProblemInjector.cs
r1053 r1060 35 35 } 36 36 37 private IntData targetVariable ;37 private IntData targetVariable = new IntData(); 38 38 public int TargetVariable { 39 39 get { return targetVariable.Data; } 40 40 set { targetVariable.Data = value; } 41 41 } 42 43 public ProblemInjector() : base() { } // for persistence 44 42 45 public ProblemInjector(Problem problem) 43 46 : base() { -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/Dispatcher.cs
r1053 r1060 34 34 using HeuristicLab.GP.StructureIdentification; 35 35 using HeuristicLab.Data; 36 using HeuristicLab.Core; 36 37 37 38 namespace HeuristicLab.CEDMA.Server { 38 39 public class Dispatcher { 39 private List< StandardGP> dispatchQueue;40 private List<Execution> dispatchQueue; 40 41 public IList<string> DispatchQueue { 41 42 get { return dispatchQueue.Select(t => "StandardGP").ToList(); } … … 46 47 public Dispatcher(IStore store) { 47 48 this.store = store; 48 this.dispatchQueue = new List< StandardGP>();49 this.dispatchQueue = new List<Execution>(); 49 50 } 50 51 … … 52 53 Dictionary<Entity, Dictionary<int, int>> numberOfModelsOfTargetVariableOfDataSet = new Dictionary<Entity, Dictionary<int, int>>(); 53 54 IList<Statement> datasetStatements = store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateInstanceOf, Ontology.TypeDataSet)); 54 foreach (Statement datasetStatement in datasetStatements) {55 foreach (Statement datasetStatement in datasetStatements) { 55 56 numberOfModelsOfTargetVariableOfDataSet.Add(datasetStatement.Subject, new Dictionary<int, int>()); 56 57 IList<Statement> modelStatements = store.Select(new Statement(datasetStatement.Subject, Ontology.PredicateHasModel, Ontology.AnyEntity)); 57 foreach (Statement modelStatement in modelStatements) {58 foreach (Statement modelStatement in modelStatements) { 58 59 IList<Statement> modelAttributeStatements = store.Select(new Statement((Entity)modelStatement.Property, Ontology.PredicateModelAttribute, Ontology.AnyEntity)); 59 foreach (Statement modelAttrStatement in modelAttributeStatements) {60 foreach (Statement modelAttrStatement in modelAttributeStatements) { 60 61 var targetVariableStatements = store.Select(new Statement((Entity)modelAttrStatement.Property, Ontology.PredicateModelAttributeName, Ontology.AnyEntity)) 61 62 .Where(t => (string)((Literal)t.Property).Value == "TargetVariable") 62 63 .SelectMany(t => store.Select(new Statement((Entity)modelAttrStatement.Property, Ontology.PredicateModelAttributeValue, Ontology.AnyEntity))) 63 64 .GroupBy(t => (int)((Literal)t.Property).Value); 64 foreach (var targetVariable in targetVariableStatements) {65 foreach (var targetVariable in targetVariableStatements) { 65 66 numberOfModelsOfTargetVariableOfDataSet[datasetStatement.Subject].Add(targetVariable.Key, targetVariable.Count()); 66 67 } … … 68 69 } 69 70 } 70 foreach (KeyValuePair<Entity, Dictionary<int, int>> dataSetEntry in numberOfModelsOfTargetVariableOfDataSet) {71 foreach (KeyValuePair<Entity, Dictionary<int, int>> dataSetEntry in numberOfModelsOfTargetVariableOfDataSet) { 71 72 DataSet dataSet = new DataSet(store, dataSetEntry.Key); 72 foreach(int targetVariable in dataSet.Problem.AllowedTargetVariables) 73 if(!dataSetEntry.Value.ContainsKey(targetVariable) || dataSetEntry.Value[targetVariable] < 10) { 74 QueueJob(CreateStandardGp(dataSet, targetVariable)); 73 foreach (int targetVariable in dataSet.Problem.AllowedTargetVariables) 74 if (!dataSetEntry.Value.ContainsKey(targetVariable) || dataSetEntry.Value[targetVariable] < 10) { 75 IEngine engine = CreateEngine(dataSet.Problem, targetVariable); 76 if (engine != null) { 77 QueueJob(new Execution(dataSetEntry.Key, engine, targetVariable)); 78 } 75 79 } 76 80 } 77 81 } 78 82 79 private StandardGP CreateStandardGp(DataSet dataSet, int targetVariable) { 80 ProblemInjector probInjector = new ProblemInjector(dataSet.Problem); 83 private void QueueJob(Execution execution) { 84 dispatchQueue.Add(execution); 85 } 86 87 public Execution GetNextJob() { 88 if (dispatchQueue.Count == 0) FillDispatchQueue(); 89 Execution next = dispatchQueue[0]; 90 dispatchQueue.RemoveAt(0); 91 return next; 92 } 93 94 internal void Start() { 95 FillDispatchQueue(); 96 } 97 98 private IEngine CreateEngine(Problem problem, int targetVariable) { 99 switch (problem.LearningTask) { 100 case LearningTask.Classification: return null; 101 case LearningTask.Regression: { 102 return CreateStandardGp(problem, targetVariable).Engine; 103 } 104 case LearningTask.TimeSeries: return null; 105 case LearningTask.Clustering: return null; 106 default: return null; 107 } 108 } 109 110 private StandardGP CreateStandardGp(Problem problem, int targetVariable) { 111 ProblemInjector probInjector = new ProblemInjector(problem); 81 112 probInjector.TargetVariable = targetVariable; 82 113 StandardGP sgp = new StandardGP(); … … 88 119 return sgp; 89 120 } 90 91 private void QueueJob(StandardGP job) {92 dispatchQueue.Add(job);93 }94 95 private StandardGP GetNextJob() {96 if(dispatchQueue.Count == 0) FillDispatchQueue();97 StandardGP next = dispatchQueue[0];98 dispatchQueue.RemoveAt(0);99 return next;100 }101 102 internal void Start() {103 FillDispatchQueue();104 }105 121 } 106 122 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/HeuristicLab.CEDMA.Server.csproj
r1053 r1060 75 75 </ItemGroup> 76 76 <ItemGroup> 77 <Compile Include="Execution.cs" /> 78 <Compile Include="Executer.cs" /> 77 79 <Compile Include="Dispatcher.cs" /> 78 80 <Compile Include="Server.cs" /> -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/Server.cs
r1044 r1060 51 51 52 52 public Server(IStore store) { 53 // windows XP returns the external ip on index 0 while windows vista returns the external ip on index 2 53 IPAddress[] addresses = Dns.GetHostAddresses(Dns.GetHostName()); 54 // windows XP returns the external ip on index 0 while windows vista returns the external ip as one of the last entries 55 // also if IPv6 protocol is installed we want to find an entry that is IPv4 56 int index = 0; 54 57 if (System.Environment.OSVersion.Version.Major >= 6) { 55 cedmaServiceUrl = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[2] + ":8002/CEDMA/World";56 } else {57 cedmaServiceUrl = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[0] + ":8002/CEDMA/World";58 for (index = addresses.Length - 1; index >= 0; index--) 59 if (addresses[index].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) 60 break; 58 61 } 62 cedmaServiceUrl = "net.tcp://" + addresses[index] + ":8002/CEDMA"; 59 63 this.store = store; 60 64 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/ServerForm.cs
r1044 r1060 45 45 private Store store; 46 46 private Dispatcher dispatcher; 47 private Executer executer; 47 48 48 49 private static readonly string rdfFile = AppDomain.CurrentDomain.BaseDirectory + "rdf_store.db3"; … … 64 65 65 66 private void connectButton_Click(object sender, EventArgs e) { 66 // new GridExecutor(dispatcher) 67 executer = new Executer(dispatcher, store, gridAddress.Text); 68 executer.Start(); 69 connectButton.Enabled = false; 67 70 } 68 71 }
Note: See TracChangeset
for help on using the changeset viewer.