Index: /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/DispatcherBase.cs
===================================================================
--- /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/DispatcherBase.cs (revision 1311)
+++ /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/DispatcherBase.cs (revision 1311)
@@ -0,0 +1,138 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using HeuristicLab.PluginInfrastructure;
+using System.Net;
+using System.ServiceModel;
+using HeuristicLab.CEDMA.DB.Interfaces;
+using HeuristicLab.CEDMA.DB;
+using System.ServiceModel.Description;
+using System.Linq;
+using HeuristicLab.CEDMA.Core;
+using HeuristicLab.GP.StructureIdentification;
+using HeuristicLab.Data;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.CEDMA.Server {
+ public abstract class DispatcherBase :IDispatcher {
+ public enum ModelComplexity { Low, Medium, High };
+ public enum Algorithm { StandardGP };
+
+ private IStore store;
+ private ModelComplexity[] possibleComplexities = new ModelComplexity[] { ModelComplexity.Low, ModelComplexity.Medium, ModelComplexity.High };
+ private Dictionary possibleAlgorithms = new Dictionary() {
+ {LearningTask.Classification, new Algorithm[] {}},
+ {LearningTask.Regression, new Algorithm[] { Algorithm.StandardGP }},
+ {LearningTask.TimeSeries, new Algorithm[] { }}
+ };
+
+ public DispatcherBase(IStore store) {
+ this.store = store;
+ }
+
+ public Execution GetNextJob() {
+ // find and select a dataset
+ var dataSetVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("DataSet");
+ var dataSetQuery = new Statement[] {
+ new Statement(dataSetVar, Ontology.PredicateInstanceOf, Ontology.TypeDataSet)
+ };
+
+ Entity[] datasets = store.Query("?DataSet <" + Ontology.PredicateInstanceOf.Uri + "> <" + Ontology.TypeDataSet.Uri + "> .")
+ .Select(x => (Entity)x.Get("DataSet"))
+ .ToArray();
+
+ // no datasets => do nothing
+ if (datasets.Length == 0) return null;
+
+ Entity dataSetEntity = SelectDataSet(datasets);
+ DataSet dataSet = new DataSet(store, dataSetEntity);
+
+ int targetVariable = SelectTargetVariable(dataSet, dataSet.Problem.AllowedInputVariables.ToArray());
+ Algorithm selectedAlgorithm = SelectAlgorithm(dataSet, targetVariable, possibleAlgorithms[dataSet.Problem.LearningTask]);
+ string targetVariableName = dataSet.Problem.GetVariableName(targetVariable);
+ ModelComplexity selectedComplexity = SelectComplexity(dataSet, targetVariable, selectedAlgorithm, possibleComplexities);
+
+ Execution exec = CreateExecution(dataSet.Problem, targetVariable, selectedAlgorithm, selectedComplexity);
+ if (exec != null) {
+ exec.DataSetEntity = dataSetEntity;
+ exec.TargetVariable = targetVariableName;
+ }
+ return exec;
+ }
+
+ public abstract Entity SelectDataSet(Entity[] datasets);
+ public abstract int SelectTargetVariable(DataSet dataSet, int[] targetVariables);
+ public abstract Algorithm SelectAlgorithm(DataSet dataSet, int targetVariable, Algorithm[] possibleAlgorithms);
+ public abstract ModelComplexity SelectComplexity(DataSet dataSet, int targetVariable, Algorithm algorithm, ModelComplexity[] possibleComplexities);
+
+ private Execution CreateExecution(Problem problem, int targetVariable, Algorithm algorithm, ModelComplexity complexity) {
+ switch (algorithm) {
+ case Algorithm.StandardGP: {
+ return CreateStandardGpExecution(problem, targetVariable, complexity);
+ }
+ default: {
+ return null;
+ }
+ }
+ }
+
+ private Execution CreateStandardGpExecution(Problem problem, int targetVariable, ModelComplexity complexity) {
+ ProblemInjector probInjector = new ProblemInjector(problem);
+ probInjector.TargetVariable = targetVariable;
+ StandardGP sgp = new StandardGP();
+ sgp.SetSeedRandomly = true;
+ sgp.MaxGenerations = 2;
+ sgp.PopulationSize = 100;
+ sgp.Elites = 1;
+ sgp.ProblemInjector = probInjector;
+
+ int maxTreeHeight = 10;
+ int maxTreeSize = 100;
+ switch (complexity) {
+ case ModelComplexity.Low: {
+ maxTreeHeight = 5;
+ maxTreeSize = 20;
+ break;
+ }
+ case ModelComplexity.Medium: {
+ maxTreeHeight = 10;
+ maxTreeSize = 100;
+ break;
+ }
+ case ModelComplexity.High: {
+ maxTreeHeight = 12;
+ maxTreeSize = 200;
+ break;
+ }
+ }
+
+ sgp.MaxTreeHeight = maxTreeHeight;
+ sgp.MaxTreeSize = maxTreeSize;
+ Execution exec = new Execution(sgp.Engine);
+ exec.Description = "StandardGP - Complexity: " + complexity;
+ return exec;
+ }
+ }
+}
Index: /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/Executer.cs
===================================================================
--- /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/Executer.cs (revision 1311)
+++ /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/Executer.cs (revision 1311)
@@ -0,0 +1,162 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using HeuristicLab.PluginInfrastructure;
+using System.Net;
+using System.ServiceModel;
+using HeuristicLab.CEDMA.DB.Interfaces;
+using HeuristicLab.CEDMA.DB;
+using System.ServiceModel.Description;
+using System.Linq;
+using HeuristicLab.CEDMA.Core;
+using HeuristicLab.GP.StructureIdentification;
+using HeuristicLab.Data;
+using HeuristicLab.Grid;
+using System.Diagnostics;
+using HeuristicLab.Core;
+using System.Threading;
+
+namespace HeuristicLab.CEDMA.Server {
+ public class Executer {
+ private IDispatcher dispatcher;
+ private JobManager jobManager;
+ private IStore store;
+ private Dictionary activeExecutions;
+
+ private TimeSpan StartJobInterval {
+ get { return TimeSpan.FromMilliseconds(500); }
+ }
+
+ private TimeSpan WaitForFinishedJobsTimeout {
+ get { return TimeSpan.FromMilliseconds(100); }
+ }
+
+ private int maxActiveJobs;
+ public int MaxActiveJobs {
+ get { return maxActiveJobs; }
+ set {
+ if (value < 0) throw new ArgumentException("Only positive values are allowed for MaxActiveJobs");
+ maxActiveJobs = value;
+ }
+ }
+
+ public Executer(IDispatcher dispatcher, IStore store, string gridUrl) {
+ activeExecutions = new Dictionary();
+ maxActiveJobs = 10;
+ this.dispatcher = dispatcher;
+ this.store = store;
+ this.jobManager = new JobManager(gridUrl);
+ jobManager.Reset();
+ }
+
+ internal void Start() {
+ new Thread(StartJobs).Start();
+ }
+
+ private void StartJobs() {
+ List wh = new List();
+ Dictionary activeOperations = new Dictionary();
+ while (true) {
+ try {
+ // start new jobs as long as there are less than MaxActiveJobs
+ while (wh.Count < MaxActiveJobs) {
+ Thread.Sleep(StartJobInterval);
+ // get an execution from the dispatcher and execute in grid via job-manager
+ Execution execution = dispatcher.GetNextJob();
+ if (execution != null) {
+ AtomicOperation op = new AtomicOperation(execution.Engine.OperatorGraph.InitialOperator, execution.Engine.GlobalScope);
+ WaitHandle opWh = jobManager.BeginExecuteOperation(execution.Engine.GlobalScope, op);
+ wh.Add(opWh);
+ activeOperations.Add(opWh, op);
+ lock (activeExecutions) {
+ activeExecutions.Add(opWh, execution);
+ }
+ }
+ }
+ // wait until any job is finished
+ WaitHandle[] whArr = wh.ToArray();
+ int readyHandleIndex = WaitHandle.WaitAny(whArr, WaitForFinishedJobsTimeout);
+ if (readyHandleIndex != WaitHandle.WaitTimeout) {
+ WaitHandle readyHandle = whArr[readyHandleIndex];
+ AtomicOperation finishedOp = activeOperations[readyHandle];
+ wh.Remove(readyHandle);
+ Execution finishedExecution = null;
+ lock (activeExecutions) {
+ finishedExecution = activeExecutions[readyHandle];
+ activeExecutions.Remove(readyHandle);
+ }
+ activeOperations.Remove(readyHandle);
+ ProcessingEngine finishedEngine = null;
+ try {
+ finishedEngine = jobManager.EndExecuteOperation(finishedOp);
+ }
+ catch (Exception badEx) {
+ Trace.WriteLine("CEDMA Executer: Exception in job execution thread. " + badEx.Message);
+ }
+ if (finishedEngine != null) {
+ StoreResults(finishedExecution, finishedEngine);
+ }
+ }
+ }
+ catch (Exception ex) {
+ Trace.WriteLine("CEDMA Executer: Exception in job-management thread. " + ex.Message);
+ }
+ }
+ }
+
+ private void StoreResults(Execution finishedExecution, ProcessingEngine finishedEngine) {
+ Entity model = new Entity(Ontology.CedmaNameSpace + Guid.NewGuid());
+ store.Add(new Statement(model, Ontology.PredicateInstanceOf, Ontology.TypeGeneticProgrammingFunctionTree));
+ store.Add(new Statement(finishedExecution.DataSetEntity, Ontology.PredicateHasModel, model));
+ StoreModelAttribute(model, Ontology.TargetVariable, finishedExecution.TargetVariable);
+ Scope bestModelScope = finishedEngine.GlobalScope.GetVariableValue("BestValidationSolution", false);
+ StoreModelAttribute(model, Ontology.TrainingMeanSquaredError, bestModelScope.GetVariableValue("Quality", false).Data);
+ StoreModelAttribute(model, Ontology.ValidationMeanSquaredError, bestModelScope.GetVariableValue("ValidationQuality", false).Data);
+ StoreModelAttribute(model, Ontology.TrainingMeanAbsolutePercentageError, bestModelScope.GetVariableValue("TrainingMAPE", false).Data);
+ StoreModelAttribute(model, Ontology.ValidationMeanAbsolutePercentageError, bestModelScope.GetVariableValue("ValidationMAPE", false).Data);
+ StoreModelAttribute(model, Ontology.TreeSize, bestModelScope.GetVariableValue("TreeSize", false).Data);
+ StoreModelAttribute(model, Ontology.TreeHeight, bestModelScope.GetVariableValue("TreeHeight", false).Data);
+ StoreModelAttribute(model, Ontology.EvaluatedSolutions, bestModelScope.GetVariableValue("EvaluatedSolutions", false).Data);
+
+ byte[] serializedModel = PersistenceManager.SaveToGZip(bestModelScope.GetVariableValue("FunctionTree", false));
+ store.Add(new Statement(model, Ontology.PredicateSerializedData, new Literal(Convert.ToBase64String(serializedModel))));
+ }
+
+ private void StoreModelAttribute(Entity model, Entity predicate, object value) {
+ store.Add(new Statement(model, predicate, new Literal(value)));
+ }
+
+ internal string[] GetJobs() {
+ lock (activeExecutions) {
+ string[] retVal = new string[activeExecutions.Count];
+ int i = 0;
+ foreach (Execution e in activeExecutions.Values) {
+ retVal[i++] = "Target-Variable: "+e.TargetVariable+" "+e.Description;
+ }
+ return retVal;
+ }
+ }
+ }
+}
Index: /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/Execution.cs
===================================================================
--- /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/Execution.cs (revision 1311)
+++ /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/Execution.cs (revision 1311)
@@ -0,0 +1,71 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using HeuristicLab.PluginInfrastructure;
+using System.Net;
+using System.ServiceModel;
+using HeuristicLab.CEDMA.DB.Interfaces;
+using HeuristicLab.CEDMA.DB;
+using System.ServiceModel.Description;
+using System.Linq;
+using HeuristicLab.CEDMA.Core;
+using HeuristicLab.GP.StructureIdentification;
+using HeuristicLab.Data;
+using HeuristicLab.Grid;
+using System.Diagnostics;
+using HeuristicLab.Core;
+using System.Threading;
+
+namespace HeuristicLab.CEDMA.Server {
+ public class Execution {
+ private Entity dataSetEntity;
+ public Entity DataSetEntity {
+ get { return dataSetEntity; }
+ set { dataSetEntity = value; }
+ }
+
+ private IEngine engine;
+ public IEngine Engine {
+ get { return engine; }
+ set { engine = value; }
+ }
+
+ private string targetVariable;
+ public string TargetVariable {
+ get { return targetVariable; }
+ set { targetVariable = value; }
+ }
+
+ private string description;
+ public string Description {
+ get { return description; }
+ set { description = value; }
+ }
+
+ public Execution(IEngine engine) {
+ this.engine = engine;
+ }
+ }
+}
Index: /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/HeuristicLab.CEDMA.Server.csproj
===================================================================
--- /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/HeuristicLab.CEDMA.Server.csproj (revision 1311)
+++ /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/HeuristicLab.CEDMA.Server.csproj (revision 1311)
@@ -0,0 +1,156 @@
+
+
+
+ Debug
+ AnyCPU
+ 9.0.30729
+ 2.0
+ {F05D261A-4F7D-46C9-AB9C-21FD4566D719}
+ Library
+ Properties
+ HeuristicLab.CEDMA.Server
+ HeuristicLab.CEDMA.Server-3.2
+ v3.5
+ 512
+ false
+ HeuristicLab.snk
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE
+ full
+ x86
+ prompt
+
+
+ bin\x86\Release\
+ TRACE
+ true
+ pdbonly
+ x86
+ prompt
+
+
+
+
+ 3.5
+
+
+ 3.5
+
+
+
+ 3.0
+
+
+ 3.0
+
+
+
+ 3.5
+
+
+ 3.5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ ServerForm.cs
+
+
+
+
+ {C27DDF6C-84DF-45EF-B82F-57A28DD51166}
+ HeuristicLab.CEDMA.Core
+
+
+ {4F9BB789-D561-436B-B226-2BF44B7D0804}
+ HeuristicLab.CEDMA.DB.Interfaces
+
+
+ {B3D6D8D9-2B1F-47EC-9C73-77FAECF87310}
+ HeuristicLab.CEDMA.DB
+
+
+ {F43B59AB-2B8C-4570-BC1E-15592086517C}
+ HeuristicLab.Core
+
+
+ {F473D9AF-3F09-4296-9F28-3C65118DAFFA}
+ HeuristicLab.Data
+
+
+ {74223A32-C726-4978-BE78-37113A18373C}
+ HeuristicLab.GP.StructureIdentification
+
+
+ {545CE756-98D8-423B-AC2E-6E7D70926E5C}
+ HeuristicLab.Grid
+
+
+ {A9983BA2-B3B2-475E-8E2C-62050B71D1C5}
+ HeuristicLab.Operators
+
+
+ {94186A6A-5176-4402-AE83-886557B53CCA}
+ HeuristicLab.PluginInfrastructure
+
+
+
+
+ ServerForm.cs
+ Designer
+
+
+
+
+
+
+
+
+ set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
+set ProjectDir=$(ProjectDir)
+set SolutionDir=$(SolutionDir)
+set Outdir=$(Outdir)
+
+call PreBuildEvent.cmd
+
+
Index: /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/HeuristicLabCedmaServerPlugin.cs
===================================================================
--- /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/HeuristicLabCedmaServerPlugin.cs (revision 1311)
+++ /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/HeuristicLabCedmaServerPlugin.cs (revision 1311)
@@ -0,0 +1,37 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.CEDMA.Server {
+ [ClassInfo(Name = "HeuristicLab.CEDMA.Server-3.2")]
+ [PluginFile(Filename = "HeuristicLab.CEDMA.Server-3.2.dll", Filetype = PluginFileType.Assembly)]
+ [Dependency(Dependency = "HeuristicLab.CEDMA.DB.Interfaces-3.2")]
+ [Dependency(Dependency = "HeuristicLab.CEDMA.DB-3.2")]
+ [Dependency(Dependency = "HeuristicLab.Grid-3.2")]
+ [Dependency(Dependency = "HeuristicLab.Core-3.2")]
+ [Dependency(Dependency = "HeuristicLab.Data-3.2")]
+ public class HeuristicLabCedmaServerPlugin : PluginBase {
+ }
+}
Index: /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/IDispatcher.cs
===================================================================
--- /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/IDispatcher.cs (revision 1311)
+++ /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/IDispatcher.cs (revision 1311)
@@ -0,0 +1,42 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using HeuristicLab.PluginInfrastructure;
+using System.Net;
+using System.ServiceModel;
+using HeuristicLab.CEDMA.DB.Interfaces;
+using HeuristicLab.CEDMA.DB;
+using System.ServiceModel.Description;
+using System.Linq;
+using HeuristicLab.CEDMA.Core;
+using HeuristicLab.GP.StructureIdentification;
+using HeuristicLab.Data;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.CEDMA.Server {
+ public interface IDispatcher {
+ Execution GetNextJob();
+ }
+}
Index: /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/Properties/AssemblyInfo.frame
===================================================================
--- /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/Properties/AssemblyInfo.frame (revision 1311)
+++ /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/Properties/AssemblyInfo.frame (revision 1311)
@@ -0,0 +1,38 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using HeuristicLab.PluginInfrastructure;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("HeuristicLab.CEDMA.Server")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HeuristicLab")]
+[assembly: AssemblyCopyright("(c) 2002-2008 HEAL")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("209a38c6-cbb8-407e-9158-6f4f60bdadb7")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("3.2.0.$WCREV$")]
+[assembly: AssemblyFileVersion("3.2.0.$WCREV$")]
+[assembly: AssemblyBuildDate("$WCNOW$")]
Index: /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/RandomDispatcher.cs
===================================================================
--- /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/RandomDispatcher.cs (revision 1311)
+++ /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/RandomDispatcher.cs (revision 1311)
@@ -0,0 +1,62 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using HeuristicLab.PluginInfrastructure;
+using System.Net;
+using System.ServiceModel;
+using HeuristicLab.CEDMA.DB.Interfaces;
+using HeuristicLab.CEDMA.DB;
+using System.ServiceModel.Description;
+using System.Linq;
+using HeuristicLab.CEDMA.Core;
+using HeuristicLab.GP.StructureIdentification;
+using HeuristicLab.Data;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.CEDMA.Server {
+ public class RandomDispatcher : DispatcherBase {
+ private Random random;
+ public RandomDispatcher(IStore store)
+ : base(store) {
+ random = new Random();
+ }
+
+ public override Algorithm SelectAlgorithm(DataSet dataSet, int targetVariable, Algorithm[] possibleAlgorithms) {
+ return possibleAlgorithms[random.Next(possibleAlgorithms.Length)];
+ }
+
+ public override ModelComplexity SelectComplexity(DataSet dataSet, int targetVariable, Algorithm algorithm, ModelComplexity[] possibleComplexities) {
+ return possibleComplexities[random.Next(possibleComplexities.Length)];
+ }
+
+ public override Entity SelectDataSet(Entity[] datasets) {
+ return datasets[random.Next(datasets.Length)];
+ }
+
+ public override int SelectTargetVariable(DataSet dataSet, int[] targetVariables) {
+ return targetVariables[random.Next(targetVariables.Length)];
+ }
+ }
+}
Index: /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/Server.cs
===================================================================
--- /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/Server.cs (revision 1311)
+++ /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/Server.cs (revision 1311)
@@ -0,0 +1,86 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using HeuristicLab.PluginInfrastructure;
+using System.Net;
+using System.ServiceModel;
+using HeuristicLab.CEDMA.DB.Interfaces;
+using HeuristicLab.CEDMA.DB;
+using System.ServiceModel.Description;
+
+namespace HeuristicLab.CEDMA.Server {
+ public class Server {
+ private ServiceHost host;
+ private IStore store;
+
+ private string gridServiceUrl;
+
+ public string GridServiceUrl {
+ get { return gridServiceUrl; }
+ set { gridServiceUrl = value; }
+ }
+
+ private string cedmaServiceUrl;
+
+ public string CedmaServiceUrl {
+ get { return cedmaServiceUrl; }
+ set { cedmaServiceUrl = value; }
+ }
+
+ public Server(IStore store) {
+ IPAddress[] addresses = Dns.GetHostAddresses(Dns.GetHostName());
+ // windows XP returns the external ip on index 0 while windows vista returns the external ip as one of the last entries
+ // also if IPv6 protocol is installed we want to find an entry that is IPv4
+ int index = 0;
+ if (System.Environment.OSVersion.Version.Major >= 6) {
+ for (index = addresses.Length - 1; index >= 0; index--)
+ if (addresses[index].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
+ break;
+ }
+ cedmaServiceUrl = "net.tcp://" + addresses[index] + ":8002/CEDMA";
+ this.store = store;
+ }
+
+ public void Start() {
+ host = new ServiceHost(store, new Uri(cedmaServiceUrl));
+ ServiceThrottlingBehavior throttlingBehavior = new ServiceThrottlingBehavior();
+ throttlingBehavior.MaxConcurrentSessions = 20;
+ host.Description.Behaviors.Add(throttlingBehavior);
+ try {
+ NetTcpBinding binding = new NetTcpBinding();
+ binding.SendTimeout = new TimeSpan(1, 0, 0);
+ binding.MaxReceivedMessageSize = 1000000000; // 100Mbytes
+ binding.ReaderQuotas.MaxStringContentLength = 1000000000; // also 100M chars
+ binding.ReaderQuotas.MaxArrayLength = 1000000000; // also 100M elements;
+ host.AddServiceEndpoint(typeof(IStore), binding, cedmaServiceUrl);
+ host.Open();
+ }
+ catch (CommunicationException ex) {
+ MessageBox.Show("An exception occurred: " + ex.Message);
+ host.Abort();
+ }
+ }
+ }
+}
Index: /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/ServerApplication.cs
===================================================================
--- /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/ServerApplication.cs (revision 1311)
+++ /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/ServerApplication.cs (revision 1311)
@@ -0,0 +1,36 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.CEDMA.Server {
+ [ClassInfo(Name = "CEDMA Server", Description = "Server to execute CEDMA agents.", AutoRestart=true)]
+ class ServerApplication : ApplicationBase {
+ public override void Run() {
+ Form mainForm = new ServerForm();
+ Application.Run(mainForm);
+ }
+ }
+}
Index: /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/ServerForm.cs
===================================================================
--- /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/ServerForm.cs (revision 1311)
+++ /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/ServerForm.cs (revision 1311)
@@ -0,0 +1,78 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using HeuristicLab.PluginInfrastructure;
+using System.Net;
+using HeuristicLab.CEDMA.DB;
+using HeuristicLab.CEDMA.DB.Interfaces;
+using System.Data.Common;
+using System.Threading;
+using HeuristicLab.Grid;
+using HeuristicLab.Data;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.CEDMA.Server {
+ public partial class ServerForm : Form {
+ private Server server;
+ private Store store;
+ private IDispatcher dispatcher;
+ private Executer executer;
+
+ private static readonly string rdfFile = AppDomain.CurrentDomain.BaseDirectory + "rdf_store.db3";
+ private static readonly string rdfConnectionString = "sqlite:rdf:Data Source=\"" + rdfFile + "\"";
+
+ public ServerForm() {
+ InitializeComponent();
+ store = new Store(rdfConnectionString);
+ server = new Server(store);
+ server.Start();
+ addressTextBox.Text = server.CedmaServiceUrl;
+ }
+
+ private void refreshTimer_Tick(object sender, EventArgs e) {
+ listBox.DataSource = executer.GetJobs();
+ }
+
+ private void connectButton_Click(object sender, EventArgs e) {
+ dispatcher = new RandomDispatcher(store);
+ executer = new Executer(dispatcher, store, gridAddress.Text);
+ executer.Start();
+ maxActiveJobsUpDown.Enabled = true;
+ maxActiveJobsUpDown.Value = executer.MaxActiveJobs;
+ connectButton.Enabled = false;
+ refreshTimer.Start();
+ }
+
+ private void maxActiveJobsUpDown_ValueChanged(object sender, EventArgs e) {
+ executer.MaxActiveJobs = Convert.ToInt32(maxActiveJobsUpDown.Value);
+ }
+ }
+}
Index: /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/ServerForm.designer.cs
===================================================================
--- /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/ServerForm.designer.cs (revision 1311)
+++ /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/ServerForm.designer.cs (revision 1311)
@@ -0,0 +1,176 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.CEDMA.Server {
+ partial class ServerForm {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent() {
+ this.components = new System.ComponentModel.Container();
+ this.addressTextBox = new System.Windows.Forms.TextBox();
+ this.externalAddressLabel = new System.Windows.Forms.Label();
+ this.gridAddressLabel = new System.Windows.Forms.Label();
+ this.gridAddress = new System.Windows.Forms.TextBox();
+ this.connectButton = new System.Windows.Forms.Button();
+ this.listBox = new System.Windows.Forms.ListBox();
+ this.refreshTimer = new System.Windows.Forms.Timer(this.components);
+ this.maxActiveJobsUpDown = new System.Windows.Forms.NumericUpDown();
+ this.label1 = new System.Windows.Forms.Label();
+ ((System.ComponentModel.ISupportInitialize)(this.maxActiveJobsUpDown)).BeginInit();
+ this.SuspendLayout();
+ //
+ // addressTextBox
+ //
+ this.addressTextBox.Location = new System.Drawing.Point(106, 6);
+ this.addressTextBox.Name = "addressTextBox";
+ this.addressTextBox.ReadOnly = true;
+ this.addressTextBox.Size = new System.Drawing.Size(229, 20);
+ this.addressTextBox.TabIndex = 0;
+ //
+ // externalAddressLabel
+ //
+ this.externalAddressLabel.AutoSize = true;
+ this.externalAddressLabel.Location = new System.Drawing.Point(12, 9);
+ this.externalAddressLabel.Name = "externalAddressLabel";
+ this.externalAddressLabel.Size = new System.Drawing.Size(48, 13);
+ this.externalAddressLabel.TabIndex = 3;
+ this.externalAddressLabel.Text = "&Address:";
+ //
+ // gridAddressLabel
+ //
+ this.gridAddressLabel.AutoSize = true;
+ this.gridAddressLabel.Location = new System.Drawing.Point(12, 35);
+ this.gridAddressLabel.Name = "gridAddressLabel";
+ this.gridAddressLabel.Size = new System.Drawing.Size(69, 13);
+ this.gridAddressLabel.TabIndex = 9;
+ this.gridAddressLabel.Text = "&Grid address:";
+ //
+ // gridAddress
+ //
+ this.gridAddress.Location = new System.Drawing.Point(106, 32);
+ this.gridAddress.Name = "gridAddress";
+ this.gridAddress.Size = new System.Drawing.Size(160, 20);
+ this.gridAddress.TabIndex = 8;
+ //
+ // connectButton
+ //
+ this.connectButton.Location = new System.Drawing.Point(272, 30);
+ this.connectButton.Name = "connectButton";
+ this.connectButton.Size = new System.Drawing.Size(75, 23);
+ this.connectButton.TabIndex = 10;
+ this.connectButton.Text = "Connect";
+ this.connectButton.UseVisualStyleBackColor = true;
+ this.connectButton.Click += new System.EventHandler(this.connectButton_Click);
+ //
+ // listBox
+ //
+ this.listBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.listBox.FormattingEnabled = true;
+ this.listBox.Location = new System.Drawing.Point(12, 84);
+ this.listBox.Name = "listBox";
+ this.listBox.Size = new System.Drawing.Size(350, 251);
+ this.listBox.TabIndex = 11;
+ //
+ // refreshTimer
+ //
+ this.refreshTimer.Interval = 1000;
+ this.refreshTimer.Tick += new System.EventHandler(this.refreshTimer_Tick);
+ //
+ // maxActiveJobsUpDown
+ //
+ this.maxActiveJobsUpDown.Enabled = false;
+ this.maxActiveJobsUpDown.Location = new System.Drawing.Point(106, 59);
+ this.maxActiveJobsUpDown.Maximum = new decimal(new int[] {
+ 64,
+ 0,
+ 0,
+ 0});
+ this.maxActiveJobsUpDown.Name = "maxActiveJobsUpDown";
+ this.maxActiveJobsUpDown.Size = new System.Drawing.Size(120, 20);
+ this.maxActiveJobsUpDown.TabIndex = 12;
+ this.maxActiveJobsUpDown.ValueChanged += new System.EventHandler(this.maxActiveJobsUpDown_ValueChanged);
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Enabled = false;
+ this.label1.Location = new System.Drawing.Point(12, 61);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(84, 13);
+ this.label1.TabIndex = 13;
+ this.label1.Text = "&Max active jobs:";
+ //
+ // ServerForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(374, 342);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.maxActiveJobsUpDown);
+ this.Controls.Add(this.listBox);
+ this.Controls.Add(this.connectButton);
+ this.Controls.Add(this.gridAddressLabel);
+ this.Controls.Add(this.gridAddress);
+ this.Controls.Add(this.externalAddressLabel);
+ this.Controls.Add(this.addressTextBox);
+ this.Name = "ServerForm";
+ this.Text = "CEDMA Server";
+ ((System.ComponentModel.ISupportInitialize)(this.maxActiveJobsUpDown)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TextBox addressTextBox;
+ private System.Windows.Forms.Label externalAddressLabel;
+ private System.Windows.Forms.Label gridAddressLabel;
+ private System.Windows.Forms.TextBox gridAddress;
+ private System.Windows.Forms.Button connectButton;
+ private System.Windows.Forms.ListBox listBox;
+ private System.Windows.Forms.Timer refreshTimer;
+ private System.Windows.Forms.NumericUpDown maxActiveJobsUpDown;
+ private System.Windows.Forms.Label label1;
+ }
+}
Index: /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/ServerForm.resx
===================================================================
--- /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/ServerForm.resx (revision 1311)
+++ /branches/plugins/HeuristicLab.CEDMA.DB.Server/3.2/ServerForm.resx (revision 1311)
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+