Changeset 1287 for trunk/sources/HeuristicLab.CEDMA.Server
- Timestamp:
- 03/08/09 12:48:18 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.CEDMA.Server
- Files:
-
- 1 deleted
- 4 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Server/DispatcherBase.cs
r1217 r1287 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 51 private static int MaxGenerations { 52 get { return 3; } 53 } 54 55 private static int MaxEvaluatedSolutions { 56 get { return 3000; } 57 } 50 58 51 59 public DispatcherBase(IStore store) { … … 70 78 DataSet dataSet = new DataSet(store, dataSetEntity); 71 79 72 int targetVariable = SelectTargetVariable(dataSet, dataSet.Problem.Allowed InputVariables.ToArray());80 int targetVariable = SelectTargetVariable(dataSet, dataSet.Problem.AllowedTargetVariables.ToArray()); 73 81 Algorithm selectedAlgorithm = SelectAlgorithm(dataSet, targetVariable, possibleAlgorithms[dataSet.Problem.LearningTask]); 74 82 string targetVariableName = dataSet.Problem.GetVariableName(targetVariable); … … 90 98 private Execution CreateExecution(Problem problem, int targetVariable, Algorithm algorithm, ModelComplexity complexity) { 91 99 switch (algorithm) { 92 case Algorithm.StandardGP: { 93 return CreateStandardGpExecution(problem, targetVariable, complexity); 100 case Algorithm.StandardGpRegression: { 101 var algo = new HeuristicLab.GP.StructureIdentification.StandardGP(); 102 SetComplexityParameters(algo, complexity); 103 SetProblemParameters(algo, problem, targetVariable); 104 algo.PopulationSize = 10000; 105 algo.MaxGenerations = MaxGenerations; 106 Execution exec = new Execution(algo.Engine); 107 exec.Description = "StandardGP - Complexity: " + complexity; 108 return exec; 109 } 110 case Algorithm.OffspringGpRegression: { 111 var algo = new HeuristicLab.GP.StructureIdentification.OffspringSelectionGP(); 112 SetComplexityParameters(algo, complexity); 113 SetProblemParameters(algo, problem, targetVariable); 114 algo.MaxEvaluatedSolutions = MaxEvaluatedSolutions; 115 Execution exec = new Execution(algo.Engine); 116 exec.Description = "OffspringGP - Complexity: " + complexity; 117 return exec; 118 } 119 case Algorithm.StandardGpClassification: { 120 var algo = new HeuristicLab.GP.StructureIdentification.Classification.StandardGP(); 121 SetComplexityParameters(algo, complexity); 122 SetProblemParameters(algo, problem, targetVariable); 123 algo.PopulationSize = 10000; 124 algo.MaxGenerations = MaxGenerations; 125 Execution exec = new Execution(algo.Engine); 126 exec.Description = "StandardGP - Complexity: " + complexity; 127 return exec; 128 } 129 case Algorithm.OffspringGpClassification: { 130 var algo = new HeuristicLab.GP.StructureIdentification.Classification.OffspringSelectionGP(); 131 SetComplexityParameters(algo, complexity); 132 SetProblemParameters(algo, problem, targetVariable); 133 algo.MaxEvaluatedSolutions = MaxEvaluatedSolutions; 134 Execution exec = new Execution(algo.Engine); 135 exec.Description = "OffspringGP - Complexity: " + complexity; 136 return exec; 137 } 138 case Algorithm.StandardGpForecasting: { 139 var algo = new HeuristicLab.GP.StructureIdentification.TimeSeries.StandardGP(); 140 SetComplexityParameters(algo, complexity); 141 SetProblemParameters(algo, problem, targetVariable); 142 algo.PopulationSize = 10000; 143 algo.MaxGenerations = MaxGenerations; 144 Execution exec = new Execution(algo.Engine); 145 exec.Description = "StandardGP - Complexity: " + complexity; 146 return exec; 147 } 148 case Algorithm.OffspringGpForecasting: { 149 var algo = new HeuristicLab.GP.StructureIdentification.TimeSeries.OffspringSelectionGP(); 150 SetComplexityParameters(algo, complexity); 151 SetProblemParameters(algo, problem, targetVariable); 152 algo.MaxEvaluatedSolutions = MaxEvaluatedSolutions; 153 Execution exec = new Execution(algo.Engine); 154 exec.Description = "OffspringGP - Complexity: " + complexity; 155 return exec; 94 156 } 95 157 default: { … … 99 161 } 100 162 101 private Execution CreateStandardGpExecution(Problem problem, int targetVariable, ModelComplexity complexity) { 102 ProblemInjector probInjector = new 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; 163 private void SetComplexityParameters(AlgorithmBase algo, ModelComplexity complexity) { 113 164 switch (complexity) { 114 165 case ModelComplexity.Low: { 115 maxTreeHeight = 5;116 maxTreeSize = 20;166 algo.MaxTreeHeight = 5; 167 algo.MaxTreeSize = 20; 117 168 break; 118 169 } 119 170 case ModelComplexity.Medium: { 120 maxTreeHeight = 10;121 maxTreeSize = 100;171 algo.MaxTreeHeight = 10; 172 algo.MaxTreeSize = 100; 122 173 break; 123 174 } 124 175 case ModelComplexity.High: { 125 maxTreeHeight = 12;126 maxTreeSize = 200;176 algo.MaxTreeHeight = 12; 177 algo.MaxTreeSize = 200; 127 178 break; 128 179 } 129 180 } 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; 181 } 182 183 private void SetProblemParameters(AlgorithmBase algo, Problem problem, int targetVariable) { 184 algo.ProblemInjector.GetVariable("Dataset").Value = problem.DataSet; 185 algo.ProblemInjector.GetVariable("TargetVariable").GetValue<IntData>().Data = targetVariable; 186 algo.ProblemInjector.GetVariable("TrainingSamplesStart").GetValue<IntData>().Data = problem.TrainingSamplesStart; 187 algo.ProblemInjector.GetVariable("TrainingSamplesEnd").GetValue<IntData>().Data = problem.TrainingSamplesEnd; 188 algo.ProblemInjector.GetVariable("ValidationSamplesStart").GetValue<IntData>().Data = problem.ValidationSamplesStart; 189 algo.ProblemInjector.GetVariable("ValidationSamplesEnd").GetValue<IntData>().Data = problem.ValidationSamplesEnd; 190 algo.ProblemInjector.GetVariable("TestSamplesStart").GetValue<IntData>().Data = problem.TestSamplesStart; 191 algo.ProblemInjector.GetVariable("TestSamplesEnd").GetValue<IntData>().Data = problem.TestSamplesEnd; 192 ItemList<IntData> allowedFeatures = algo.ProblemInjector.GetVariable("AllowedFeatures").GetValue<ItemList<IntData>>(); 193 foreach (int allowedFeature in problem.AllowedInputVariables) allowedFeatures.Add(new IntData(allowedFeature)); 194 195 if (problem.LearningTask == LearningTask.TimeSeries) { 196 algo.ProblemInjector.GetVariable("Autoregressive").GetValue<BoolData>().Data = problem.AutoRegressive; 197 algo.ProblemInjector.GetVariable("MinTimeOffset").GetValue<IntData>().Data = problem.MinTimeOffset; 198 algo.ProblemInjector.GetVariable("MaxTimeOffset").GetValue<IntData>().Data = problem.MaxTimeOffset; 199 } else if (problem.LearningTask == LearningTask.Classification) { 200 ItemList<DoubleData> classValues = algo.ProblemInjector.GetVariable("TargetClassValues").GetValue<ItemList<DoubleData>>(); 201 foreach (double classValue in GetDifferentClassValues(problem.DataSet, targetVariable)) classValues.Add(new DoubleData(classValue)); 202 } 203 } 204 205 private IEnumerable<double> GetDifferentClassValues(HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable) { 206 return Enumerable.Range(0, dataset.Rows).Select(x => dataset.GetValue(x, targetVariable)).Distinct(); 136 207 } 137 208 } -
trunk/sources/HeuristicLab.CEDMA.Server/Executer.cs
r1060 r1287 41 41 namespace HeuristicLab.CEDMA.Server { 42 42 public class Executer { 43 private static int MaxActiveJobs { 44 get { return 20; } 45 } 46 private Dispatcher dispatcher; 43 private IDispatcher dispatcher; 47 44 private JobManager jobManager; 48 45 private IStore store; 46 private Dictionary<WaitHandle, Execution> activeExecutions; 49 47 50 public Executer(Dispatcher dispatcher, IStore store, string gridUrl) { 48 private TimeSpan StartJobInterval { 49 get { return TimeSpan.FromMilliseconds(500); } 50 } 51 52 private TimeSpan WaitForFinishedJobsTimeout { 53 get { return TimeSpan.FromMilliseconds(100); } 54 } 55 56 private int maxActiveJobs; 57 public int MaxActiveJobs { 58 get { return maxActiveJobs; } 59 set { 60 if (value < 0) throw new ArgumentException("Only positive values are allowed for MaxActiveJobs"); 61 maxActiveJobs = value; 62 } 63 } 64 65 public Executer(IDispatcher dispatcher, IStore store, string gridUrl) { 66 activeExecutions = new Dictionary<WaitHandle, Execution>(); 67 maxActiveJobs = 10; 51 68 this.dispatcher = dispatcher; 52 69 this.store = store; … … 61 78 private void StartJobs() { 62 79 List<WaitHandle> wh = new List<WaitHandle>(); 63 Dictionary<WaitHandle, AtomicOperation> activeOperations = new Dictionary<WaitHandle,AtomicOperation>(); 64 Dictionary<WaitHandle, Execution> activeExecutions = new Dictionary<WaitHandle,Execution>(); 80 Dictionary<WaitHandle, AtomicOperation> activeOperations = new Dictionary<WaitHandle, AtomicOperation>(); 65 81 while (true) { 66 82 try { 67 83 // start new jobs as long as there are less than MaxActiveJobs 68 84 while (wh.Count < MaxActiveJobs) { 85 Thread.Sleep(StartJobInterval); 69 86 // get an execution from the dispatcher and execute in grid via job-manager 70 87 Execution execution = dispatcher.GetNextJob(); 71 AtomicOperation op = new AtomicOperation(execution.Engine.OperatorGraph.InitialOperator, execution.Engine.GlobalScope); 72 WaitHandle opWh = jobManager.BeginExecuteOperation(execution.Engine.GlobalScope, op); 73 wh.Add(opWh); 74 activeOperations.Add(opWh, op); 88 if (execution != null) { 89 AtomicOperation op = new AtomicOperation(execution.Engine.OperatorGraph.InitialOperator, execution.Engine.GlobalScope); 90 WaitHandle opWh = jobManager.BeginExecuteOperation(execution.Engine.GlobalScope, op); 91 wh.Add(opWh); 92 activeOperations.Add(opWh, op); 93 lock (activeExecutions) { 94 activeExecutions.Add(opWh, execution); 95 } 96 } 75 97 } 76 98 // wait until any job is finished 77 99 WaitHandle[] whArr = wh.ToArray(); 78 int readyHandleIndex = WaitHandle.WaitAny(whArr); 79 WaitHandle readyHandle = whArr[readyHandleIndex]; 80 AtomicOperation finishedOp = activeOperations[readyHandle]; 81 Execution finishedExecution = activeExecutions[readyHandle]; 82 wh.Remove(readyHandle); 83 activeExecutions.Remove(readyHandle); 84 activeOperations.Remove(readyHandle); 85 ProcessingEngine finishedEngine = null; 86 try { 87 finishedEngine = jobManager.EndExecuteOperation(finishedOp); 88 } catch (Exception badEx) { 89 Trace.WriteLine("CEDMA Executer: Exception in job execution thread. " + badEx.Message); 90 } 91 if (finishedEngine != null) { 92 Entity modelEntity = new Entity(Ontology.CedmaNameSpace+Guid.NewGuid()); 93 store.Add(new Statement(modelEntity, Ontology.PredicateInstanceOf, Ontology.TypeGeneticProgrammingFunctionTree)); 94 Entity targetVariableAttr = new Entity(Ontology.CedmaNameSpace+Guid.NewGuid()); 95 store.Add(new Statement(modelEntity, Ontology.PredicateModelAttribute, targetVariableAttr)); 96 store.Add(new Statement(targetVariableAttr, Ontology.PredicateModelAttributeName, new Literal("TargetVariable"))); 97 store.Add(new Statement(targetVariableAttr, Ontology.PredicateModelAttributeValue, new Literal(finishedExecution.TargetVariable))); 98 store.Add(new Statement(targetVariableAttr, Ontology.PredicateModelAttributeType, Ontology.TypeCategoricalAttribute)); 99 store.Add(new Statement(finishedExecution.DataSetEntity, Ontology.PredicateHasModel, modelEntity)); 100 int readyHandleIndex = WaitHandle.WaitAny(whArr, WaitForFinishedJobsTimeout); 101 if (readyHandleIndex != WaitHandle.WaitTimeout) { 102 WaitHandle readyHandle = whArr[readyHandleIndex]; 103 AtomicOperation finishedOp = activeOperations[readyHandle]; 104 wh.Remove(readyHandle); 105 Execution finishedExecution = null; 106 lock (activeExecutions) { 107 finishedExecution = activeExecutions[readyHandle]; 108 activeExecutions.Remove(readyHandle); 109 } 110 activeOperations.Remove(readyHandle); 111 ProcessingEngine finishedEngine = null; 112 try { 113 finishedEngine = jobManager.EndExecuteOperation(finishedOp); 114 } 115 catch (Exception badEx) { 116 Trace.WriteLine("CEDMA Executer: Exception in job execution thread. " + badEx.Message); 117 } 118 if (finishedEngine != null) { 119 StoreResults(finishedExecution, finishedEngine); 120 } 100 121 } 101 122 } … … 105 126 } 106 127 } 128 129 private void StoreResults(Execution finishedExecution, ProcessingEngine finishedEngine) { 130 Entity model = new Entity(Ontology.CedmaNameSpace + Guid.NewGuid()); 131 store.Add(new Statement(model, Ontology.PredicateInstanceOf, Ontology.TypeGeneticProgrammingFunctionTree)); 132 store.Add(new Statement(finishedExecution.DataSetEntity, Ontology.PredicateHasModel, model)); 133 StoreModelAttribute(model, Ontology.TargetVariable, finishedExecution.TargetVariable); 134 Scope bestModelScope = finishedEngine.GlobalScope.GetVariableValue<Scope>("BestValidationSolution", false); 135 StoreModelVariable(model, Ontology.TrainingMeanSquaredError, bestModelScope, "Quality"); 136 StoreModelVariable(model, Ontology.ValidationMeanSquaredError, bestModelScope, "ValidationQuality"); 137 StoreModelVariable(model, Ontology.TestMeanSquaredError, bestModelScope, "TestQuality"); 138 StoreModelVariable(model, Ontology.TrainingMeanAbsolutePercentageError, bestModelScope, "TrainingMAPE"); 139 StoreModelVariable(model, Ontology.ValidationMeanAbsolutePercentageError, bestModelScope, "ValidationMAPE"); 140 StoreModelVariable(model, Ontology.TestMeanAbsolutePercentageError, bestModelScope, "TestMAPE"); 141 StoreModelVariable(model, Ontology.TrainingMeanAbsolutePercentageOfRangeError, bestModelScope, "TrainingMAPRE"); 142 StoreModelVariable(model, Ontology.ValidationMeanAbsolutePercentageOfRangeError, bestModelScope, "ValidationMAPRE"); 143 StoreModelVariable(model, Ontology.TestMeanAbsolutePercentageOfRangeError, bestModelScope, "TestMAPRE"); 144 StoreModelVariable(model, Ontology.TrainingCoefficientOfDetermination, bestModelScope, "TrainingR2"); 145 StoreModelVariable(model, Ontology.ValidationCoefficientOfDetermination, bestModelScope, "ValidationR2"); 146 StoreModelVariable(model, Ontology.TestCoefficientOfDetermination, bestModelScope, "TestR2"); 147 StoreModelVariable(model, Ontology.TrainingTheilsInequalityCoefficient, bestModelScope, "TrainingTheilInequalityCoefficient"); 148 StoreModelVariable(model, Ontology.ValidationTheilsInequalityCoefficient, bestModelScope, "ValidationTheilInequalityCoefficient"); 149 StoreModelVariable(model, Ontology.TestTheilsInequalityCoefficient, bestModelScope, "TestTheilInequalityCoefficient"); 150 StoreModelVariable(model, Ontology.TrainingAccuracy, bestModelScope, "TrainingAccuracy"); 151 StoreModelVariable(model, Ontology.ValidationAccuracy, bestModelScope, "ValidationAccuracy"); 152 StoreModelVariable(model, Ontology.TestAccuracy, bestModelScope, "TestAccuracy"); 153 StoreModelVariable(model, Ontology.TreeSize, bestModelScope, "TreeSize"); 154 StoreModelVariable(model, Ontology.TreeHeight, bestModelScope, "TreeHeight"); 155 StoreModelVariable(model, Ontology.EvaluatedSolutions, bestModelScope, "EvaluatedSolutions"); 156 157 byte[] serializedModel = PersistenceManager.SaveToGZip(bestModelScope.GetVariableValue("FunctionTree", false)); 158 store.Add(new Statement(model, Ontology.PredicateSerializedData, new Literal(Convert.ToBase64String(serializedModel)))); 159 } 160 161 private void StoreModelVariable(Entity model, Entity entity, Scope scope, string variableName) { 162 if (scope.GetVariable(variableName) != null) 163 StoreModelAttribute(model, entity, scope.GetVariableValue<ObjectData>(variableName, false).Data); 164 } 165 166 private void StoreModelAttribute(Entity model, Entity predicate, object value) { 167 store.Add(new Statement(model, predicate, new Literal(value))); 168 } 169 170 internal string[] GetJobs() { 171 lock (activeExecutions) { 172 string[] retVal = new string[activeExecutions.Count]; 173 int i = 0; 174 foreach (Execution e in activeExecutions.Values) { 175 retVal[i++] = "Target-Variable: " + e.TargetVariable + " " + e.Description; 176 } 177 return retVal; 178 } 179 } 107 180 } 108 181 } -
trunk/sources/HeuristicLab.CEDMA.Server/Execution.cs
r1060 r1287 53 53 } 54 54 55 //private Problem problem; 56 //public Problem Problem { 57 // get { return problem; } 58 // set { problem = value; } 59 //} 60 61 private int targetVariable; 62 public int TargetVariable { 55 private string targetVariable; 56 public string TargetVariable { 63 57 get { return targetVariable; } 64 58 set { targetVariable = value; } 65 59 } 66 60 67 public Execution(Entity dataSetEntity, IEngine engine, int targetVariable) { 68 this.dataSetEntity = dataSetEntity; 61 private string description; 62 public string Description { 63 get { return description; } 64 set { description = value; } 65 } 66 67 public Execution(IEngine engine) { 69 68 this.engine = engine; 70 this.targetVariable = targetVariable;71 69 } 72 70 } -
trunk/sources/HeuristicLab.CEDMA.Server/HeuristicLab.CEDMA.Server.csproj
r852 r1287 75 75 </ItemGroup> 76 76 <ItemGroup> 77 <Compile Include="RunScheduler.cs" /> 77 <Compile Include="DispatcherBase.cs" /> 78 <Compile Include="IDispatcher.cs" /> 79 <Compile Include="Execution.cs" /> 80 <Compile Include="Executer.cs" /> 81 <Compile Include="RandomDispatcher.cs" /> 82 <Compile Include="Server.cs" /> 78 83 <Compile Include="ServerApplication.cs" /> 79 84 <Compile Include="HeuristicLabCedmaServerPlugin.cs" /> … … 103 108 <Name>HeuristicLab.Core</Name> 104 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> 105 114 <ProjectReference Include="..\HeuristicLab.Data\HeuristicLab.Data.csproj"> 106 115 <Project>{F473D9AF-3F09-4296-9F28-3C65118DAFFA}</Project> 107 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> 125 </ProjectReference> 126 <ProjectReference Include="..\HeuristicLab.GP.StructureIdentification\HeuristicLab.GP.StructureIdentification.csproj"> 127 <Project>{74223A32-C726-4978-BE78-37113A18373C}</Project> 128 <Name>HeuristicLab.GP.StructureIdentification</Name> 108 129 </ProjectReference> 109 130 <ProjectReference Include="..\HeuristicLab.Grid\HeuristicLab.Grid.csproj"> -
trunk/sources/HeuristicLab.CEDMA.Server/Server.cs
r1044 r1287 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 } … … 67 71 try { 68 72 NetTcpBinding binding = new NetTcpBinding(); 69 binding.MaxReceivedMessageSize = 100000000; // 100Mbytes 70 binding.ReaderQuotas.MaxStringContentLength = 100000000; // also 100M chars 71 binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements; 72 binding.Security.Mode = SecurityMode.None; 73 73 binding.SendTimeout = new TimeSpan(1, 0, 0); 74 binding.MaxReceivedMessageSize = 1000000000; // 100Mbytes 75 binding.ReaderQuotas.MaxStringContentLength = 1000000000; // also 100M chars 76 binding.ReaderQuotas.MaxArrayLength = 1000000000; // also 100M elements; 74 77 host.AddServiceEndpoint(typeof(IStore), binding, cedmaServiceUrl); 75 78 host.Open(); -
trunk/sources/HeuristicLab.CEDMA.Server/ServerForm.cs
r556 r1287 42 42 namespace HeuristicLab.CEDMA.Server { 43 43 public partial class ServerForm : Form { 44 private ServiceHost host; 45 private ServiceHost rdfHost; 46 private Database database; 44 private Server server; 47 45 private Store store; 48 private static readonly string dbFile = AppDomain.CurrentDomain.BaseDirectory + "/test.db3"; 49 private static readonly string connectionString = "Data Source=\"" + dbFile + "\";Pooling=False"; 46 private IDispatcher dispatcher; 47 private Executer executer; 48 50 49 private static readonly string rdfFile = AppDomain.CurrentDomain.BaseDirectory + "rdf_store.db3"; 51 50 private static readonly string rdfConnectionString = "sqlite:rdf:Data Source=\"" + rdfFile + "\""; 51 52 52 public ServerForm() { 53 53 InitializeComponent(); 54 // windows XP returns the external ip on index 0 while windows vista returns the external ip on index 2 55 if(System.Environment.OSVersion.Version.Major >= 6) { 56 addressTextBox.Text = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[2] + ":8002/CEDMA/World"; 57 } else { 58 addressTextBox.Text = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[0] + ":8002/CEDMA/World"; 59 } 54 store = new Store(rdfConnectionString); 55 server = new Server(store); 56 server.Start(); 57 addressTextBox.Text = server.CedmaServiceUrl; 60 58 } 61 59 62 private void InitRunScheduler() { 63 JobManager jobManager = new JobManager(gridAddress.Text); 64 jobManager.Reset(); 65 RunScheduler scheduler = new RunScheduler(database, jobManager, addressTextBox.Text); 66 Thread runSchedulerThread = new Thread(scheduler.Run); 67 runSchedulerThread.Start(); 60 private void refreshTimer_Tick(object sender, EventArgs e) { 61 listBox.DataSource = executer.GetJobs(); 68 62 } 69 63 70 private void InitDatabase() { 71 DbProviderFactory fact; 72 fact = DbProviderFactories.GetFactory("System.Data.SQLite"); 73 if(!System.IO.File.Exists(dbFile)) { 74 database = new Database(connectionString); 75 database.CreateNew(); 76 } else { 77 database = new Database(connectionString); 78 } 64 private void connectButton_Click(object sender, EventArgs e) { 65 dispatcher = new RandomDispatcher(store); 66 executer = new Executer(dispatcher, store, gridAddress.Text); 67 executer.Start(); 68 maxActiveJobsUpDown.Enabled = true; 69 maxActiveJobsUpDown.Value = executer.MaxActiveJobs; 70 connectButton.Enabled = false; 71 refreshTimer.Start(); 79 72 } 80 73 81 private void InitRdfStore() { 82 store = new Store(rdfConnectionString); 83 } 84 85 private void Start() { 86 InitDatabase(); 87 InitRdfStore(); 88 InitRunScheduler(); 89 90 host = new ServiceHost(database, new Uri(addressTextBox.Text)); 91 rdfHost = new ServiceHost(store, new Uri(addressTextBox.Text+"/RdfStore")); 92 ServiceThrottlingBehavior throttlingBehavior = new ServiceThrottlingBehavior(); 93 throttlingBehavior.MaxConcurrentSessions = 20; 94 host.Description.Behaviors.Add(throttlingBehavior); 95 rdfHost.Description.Behaviors.Add(throttlingBehavior); 96 try { 97 NetTcpBinding binding = new NetTcpBinding(); 98 binding.MaxReceivedMessageSize = 100000000; // 100Mbytes 99 binding.ReaderQuotas.MaxStringContentLength = 100000000; // also 100M chars 100 binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements; 101 binding.Security.Mode = SecurityMode.None; 102 103 host.AddServiceEndpoint(typeof(IDatabase), binding, addressTextBox.Text); 104 host.Open(); 105 rdfHost.AddServiceEndpoint(typeof(IStore), binding, addressTextBox.Text+"/RdfStore"); 106 rdfHost.Open(); 107 } catch(CommunicationException ex) { 108 MessageBox.Show("An exception occurred: " + ex.Message); 109 host.Abort(); 110 rdfHost.Abort(); 111 } 112 } 113 114 private void startButton_Click(object sender, EventArgs e) { 115 Start(); 116 startButton.Enabled = false; 74 private void maxActiveJobsUpDown_ValueChanged(object sender, EventArgs e) { 75 executer.MaxActiveJobs = Convert.ToInt32(maxActiveJobsUpDown.Value); 117 76 } 118 77 } -
trunk/sources/HeuristicLab.CEDMA.Server/ServerForm.designer.cs
r378 r1287 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.components = new System.ComponentModel.Container(); 47 48 this.addressTextBox = new System.Windows.Forms.TextBox(); 48 49 this.externalAddressLabel = new System.Windows.Forms.Label(); 49 this.activeAgentsLabel = new System.Windows.Forms.Label();50 this.activeAgentsTextBox = new System.Windows.Forms.TextBox();51 50 this.gridAddressLabel = new System.Windows.Forms.Label(); 52 51 this.gridAddress = new System.Windows.Forms.TextBox(); 53 this.startButton = new System.Windows.Forms.Button(); 52 this.connectButton = new System.Windows.Forms.Button(); 53 this.listBox = new System.Windows.Forms.ListBox(); 54 this.refreshTimer = new System.Windows.Forms.Timer(this.components); 55 this.maxActiveJobsUpDown = new System.Windows.Forms.NumericUpDown(); 56 this.label1 = new System.Windows.Forms.Label(); 57 ((System.ComponentModel.ISupportInitialize)(this.maxActiveJobsUpDown)).BeginInit(); 54 58 this.SuspendLayout(); 55 59 // … … 71 75 this.externalAddressLabel.Text = "&Address:"; 72 76 // 73 // activeAgentsLabel74 //75 this.activeAgentsLabel.AutoSize = true;76 this.activeAgentsLabel.Location = new System.Drawing.Point(12, 61);77 this.activeAgentsLabel.Name = "activeAgentsLabel";78 this.activeAgentsLabel.Size = new System.Drawing.Size(75, 13);79 this.activeAgentsLabel.TabIndex = 7;80 this.activeAgentsLabel.Text = "A&ctive agents:";81 //82 // activeAgentsTextBox83 //84 this.activeAgentsTextBox.Location = new System.Drawing.Point(106, 58);85 this.activeAgentsTextBox.Name = "activeAgentsTextBox";86 this.activeAgentsTextBox.ReadOnly = true;87 this.activeAgentsTextBox.Size = new System.Drawing.Size(90, 20);88 this.activeAgentsTextBox.TabIndex = 6;89 this.activeAgentsTextBox.Text = "0";90 this.activeAgentsTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;91 //92 77 // gridAddressLabel 93 78 // … … 103 88 this.gridAddress.Location = new System.Drawing.Point(106, 32); 104 89 this.gridAddress.Name = "gridAddress"; 105 this.gridAddress.Size = new System.Drawing.Size( 229, 20);90 this.gridAddress.Size = new System.Drawing.Size(160, 20); 106 91 this.gridAddress.TabIndex = 8; 107 92 // 108 // startButton93 // connectButton 109 94 // 110 this.startButton.Location = new System.Drawing.Point(15, 84); 111 this.startButton.Name = "startButton"; 112 this.startButton.Size = new System.Drawing.Size(75, 23); 113 this.startButton.TabIndex = 10; 114 this.startButton.Text = "Start"; 115 this.startButton.UseVisualStyleBackColor = true; 116 this.startButton.Click += new System.EventHandler(this.startButton_Click); 95 this.connectButton.Location = new System.Drawing.Point(272, 30); 96 this.connectButton.Name = "connectButton"; 97 this.connectButton.Size = new System.Drawing.Size(75, 23); 98 this.connectButton.TabIndex = 10; 99 this.connectButton.Text = "Connect"; 100 this.connectButton.UseVisualStyleBackColor = true; 101 this.connectButton.Click += new System.EventHandler(this.connectButton_Click); 102 // 103 // listBox 104 // 105 this.listBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 106 | System.Windows.Forms.AnchorStyles.Left) 107 | System.Windows.Forms.AnchorStyles.Right))); 108 this.listBox.FormattingEnabled = true; 109 this.listBox.Location = new System.Drawing.Point(12, 84); 110 this.listBox.Name = "listBox"; 111 this.listBox.Size = new System.Drawing.Size(350, 251); 112 this.listBox.TabIndex = 11; 113 // 114 // refreshTimer 115 // 116 this.refreshTimer.Interval = 1000; 117 this.refreshTimer.Tick += new System.EventHandler(this.refreshTimer_Tick); 118 // 119 // maxActiveJobsUpDown 120 // 121 this.maxActiveJobsUpDown.Enabled = false; 122 this.maxActiveJobsUpDown.Location = new System.Drawing.Point(106, 59); 123 this.maxActiveJobsUpDown.Maximum = new decimal(new int[] { 124 64, 125 0, 126 0, 127 0}); 128 this.maxActiveJobsUpDown.Name = "maxActiveJobsUpDown"; 129 this.maxActiveJobsUpDown.Size = new System.Drawing.Size(120, 20); 130 this.maxActiveJobsUpDown.TabIndex = 12; 131 this.maxActiveJobsUpDown.ValueChanged += new System.EventHandler(this.maxActiveJobsUpDown_ValueChanged); 132 // 133 // label1 134 // 135 this.label1.AutoSize = true; 136 this.label1.Enabled = false; 137 this.label1.Location = new System.Drawing.Point(12, 61); 138 this.label1.Name = "label1"; 139 this.label1.Size = new System.Drawing.Size(84, 13); 140 this.label1.TabIndex = 13; 141 this.label1.Text = "&Max active jobs:"; 117 142 // 118 143 // ServerForm … … 120 145 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 121 146 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 122 this.ClientSize = new System.Drawing.Size(347, 119); 123 this.Controls.Add(this.startButton); 147 this.ClientSize = new System.Drawing.Size(374, 342); 148 this.Controls.Add(this.label1); 149 this.Controls.Add(this.maxActiveJobsUpDown); 150 this.Controls.Add(this.listBox); 151 this.Controls.Add(this.connectButton); 124 152 this.Controls.Add(this.gridAddressLabel); 125 153 this.Controls.Add(this.gridAddress); 126 this.Controls.Add(this.activeAgentsLabel);127 this.Controls.Add(this.activeAgentsTextBox);128 154 this.Controls.Add(this.externalAddressLabel); 129 155 this.Controls.Add(this.addressTextBox); 130 156 this.Name = "ServerForm"; 131 this.Text = "Agent Server"; 157 this.Text = "CEDMA Server"; 158 ((System.ComponentModel.ISupportInitialize)(this.maxActiveJobsUpDown)).EndInit(); 132 159 this.ResumeLayout(false); 133 160 this.PerformLayout(); … … 139 166 private System.Windows.Forms.TextBox addressTextBox; 140 167 private System.Windows.Forms.Label externalAddressLabel; 141 private System.Windows.Forms.Label activeAgentsLabel;142 private System.Windows.Forms.TextBox activeAgentsTextBox;143 168 private System.Windows.Forms.Label gridAddressLabel; 144 169 private System.Windows.Forms.TextBox gridAddress; 145 private System.Windows.Forms.Button startButton; 170 private System.Windows.Forms.Button connectButton; 171 private System.Windows.Forms.ListBox listBox; 172 private System.Windows.Forms.Timer refreshTimer; 173 private System.Windows.Forms.NumericUpDown maxActiveJobsUpDown; 174 private System.Windows.Forms.Label label1; 146 175 } 147 176 } -
trunk/sources/HeuristicLab.CEDMA.Server/ServerForm.resx
r378 r1287 118 118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 119 119 </resheader> 120 <metadata name="refreshTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 121 <value>17, 17</value> 122 </metadata> 120 123 </root>
Note: See TracChangeset
for help on using the changeset viewer.