Changeset 2193 for branches/HeuristicLab.Modeling Database Backend
- Timestamp:
- 07/28/09 15:26:29 (15 years ago)
- Location:
- branches/HeuristicLab.Modeling Database Backend/sources
- Files:
-
- 5 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Core/3.3/HeuristicLab.CEDMA.Core-3.3.csproj
r2190 r2193 88 88 </ItemGroup> 89 89 <ItemGroup> 90 <Compile Include="StoreProxy.cs" />91 90 <Compile Include="IResultsViewFactory.cs" /> 92 91 <Compile Include="ResultsEntry.cs" /> -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Core/3.3/Results.cs
r2190 r2193 37 37 namespace HeuristicLab.CEDMA.Core { 38 38 public class Results : ItemBase { 39 private const int PAGE_SIZE = 1000;40 39 private string[] categoricalVariables = null; 41 40 public string[] CategoricalVariables { … … 69 68 70 69 private IModelingDatabase database; 71 //public IStore Store {72 // get { return store; }73 // set {74 // store = value;75 // }76 //}77 70 78 71 private Dictionary<string, Dictionary<object, double>> categoricalValueIndices = new Dictionary<string, Dictionary<object, double>>(); … … 99 92 modelEntry.Set("PersistedData", model.Data); 100 93 modelEntry.Set("TargetVariable", model.TargetVariable.Name); 94 entries.Add(modelEntry); 101 95 } 102 96 -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherBase.cs
r2185 r2193 36 36 using HeuristicLab.Core; 37 37 using HeuristicLab.Modeling; 38 using HeuristicLab.Modeling.Database; 38 39 39 40 namespace HeuristicLab.CEDMA.Server { 40 41 public abstract class DispatcherBase : IDispatcher { 41 42 private IModelingDatabase database; 42 private DataSet dataset;43 43 private List<int> allowedTargetVariables; 44 44 private Dictionary<int, List<int>> activeInputVariables; 45 45 private Problem problem; 46 46 internal event EventHandler Changed; 47 47 private object locker = new object(); … … 49 49 public IEnumerable<string> TargetVariables { 50 50 get { 51 if ( dataset!= null) {52 return dataset.Problem.AllowedTargetVariables.Select(x => dataset.Problem.Dataset.GetVariableName(x));51 if (problem != null) { 52 return problem.AllowedTargetVariables.Select(x => problem.Dataset.GetVariableName(x)); 53 53 } else return new string[0]; 54 54 } … … 57 57 public IEnumerable<string> InputVariables { 58 58 get { 59 if ( dataset!= null) {60 return dataset.Problem.AllowedInputVariables.Select(x => dataset.Problem.Dataset.GetVariableName(x));59 if (problem != null) { 60 return problem.AllowedInputVariables.Select(x => problem.Dataset.GetVariableName(x)); 61 61 } else return new string[0]; 62 62 } 63 63 } 64 64 65 public DispatcherBase(IModelingDatabase database) { 65 public DispatcherBase(IModelingDatabase database, Problem problem) { 66 this.problem = problem; 66 67 this.database = database; 67 68 allowedTargetVariables = new List<int>(); … … 69 70 } 70 71 71 public IAlgorithm GetNextJob() { 72 if (dataset == null) { 73 var datasetEntities = store.Query("?DataSet <" + Ontology.InstanceOf.Uri + "> <" + Ontology.TypeDataSet.Uri + "> .", 0, 1) 74 .Select(x => (Entity)x.Get("DataSet")); 75 if (datasetEntities.Count() == 0) return null; 76 dataset = new DataSet(store, datasetEntities.ElementAt(0)); 77 foreach (int targetVar in dataset.Problem.AllowedTargetVariables) { 72 public HeuristicLab.Modeling.IAlgorithm GetNextJob() { 73 if (problem == null) { 74 foreach (int targetVar in problem.AllowedTargetVariables) { 78 75 activeInputVariables.Add(targetVar, new List<int>()); 79 activeInputVariables[targetVar].AddRange( dataset.Problem.AllowedInputVariables);76 activeInputVariables[targetVar].AddRange(problem.AllowedInputVariables); 80 77 } 81 78 OnChanged(); … … 93 90 } 94 91 95 IAlgorithm selectedAlgorithm = SelectAndConfigureAlgorithm(targetVariable, inputVariables, dataset.Problem);92 HeuristicLab.Modeling.IAlgorithm selectedAlgorithm = SelectAndConfigureAlgorithm(targetVariable, inputVariables, problem); 96 93 97 94 return selectedAlgorithm; … … 103 100 return targetVariables[rand.Next(targetVariables.Length)]; 104 101 } 105 public abstract IAlgorithm SelectAndConfigureAlgorithm(int targetVariable, int[] inputVariables, Problem problem);102 public abstract HeuristicLab.Modeling.IAlgorithm SelectAndConfigureAlgorithm(int targetVariable, int[] inputVariables, Problem problem); 106 103 107 104 #region IViewable Members 108 105 109 106 public IView CreateView() { 110 return new DispatcherView(this);107 return new ProblemView(this); 111 108 } 112 109 … … 115 112 internal void EnableTargetVariable(string name) { 116 113 lock (locker) 117 allowedTargetVariables.Add( dataset.Problem.Dataset.GetVariableIndex(name));114 allowedTargetVariables.Add(problem.Dataset.GetVariableIndex(name)); 118 115 } 119 116 120 117 internal void DisableTargetVariable(string name) { 121 118 lock (locker) 122 allowedTargetVariables.Remove( dataset.Problem.Dataset.GetVariableIndex(name));119 allowedTargetVariables.Remove(problem.Dataset.GetVariableIndex(name)); 123 120 } 124 121 125 122 internal void EnableInputVariable(string target, string name) { 126 123 lock (locker) { 127 int targetIndex = dataset.Problem.Dataset.GetVariableIndex(target);128 int inputIndex = dataset.Problem.Dataset.GetVariableIndex(name);124 int targetIndex = problem.Dataset.GetVariableIndex(target); 125 int inputIndex = problem.Dataset.GetVariableIndex(name); 129 126 if (!activeInputVariables[targetIndex].Contains(inputIndex)) { 130 127 activeInputVariables[targetIndex].Add(inputIndex); … … 135 132 internal void DisableInputVariable(string target, string name) { 136 133 lock (locker) { 137 int targetIndex = dataset.Problem.Dataset.GetVariableIndex(target);138 int inputIndex = dataset.Problem.Dataset.GetVariableIndex(name);134 int targetIndex = problem.Dataset.GetVariableIndex(target); 135 int inputIndex = problem.Dataset.GetVariableIndex(name); 139 136 while (activeInputVariables[targetIndex].Remove(inputIndex)) { } 140 137 } … … 146 143 147 144 internal IEnumerable<string> GetInputVariables(string target) { 148 return activeInputVariables[ dataset.Problem.Dataset.GetVariableIndex(target)]149 .Select(i => dataset.Problem.Dataset.GetVariableName(i));145 return activeInputVariables[problem.Dataset.GetVariableIndex(target)] 146 .Select(i => problem.Dataset.GetVariableName(i)); 150 147 } 151 148 } -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherView.cs
r2153 r2193 12 12 public partial class DispatcherView : ViewBase { 13 13 private DispatcherBase dispatcher; 14 public DispatcherView(DispatcherBase dispatcher) : base() { 14 public DispatcherView(DispatcherBase dispatcher) 15 : base() { 15 16 this.dispatcher = dispatcher; 16 17 InitializeComponent(); -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Server/3.3/HeuristicLab.CEDMA.Server-3.3.csproj
r2185 r2193 91 91 </ItemGroup> 92 92 <ItemGroup> 93 <Compile Include="ProblemView.cs"> 94 <SubType>UserControl</SubType> 95 </Compile> 96 <Compile Include="ProblemView.Designer.cs"> 97 <DependentUpon>ProblemView.cs</DependentUpon> 98 </Compile> 93 99 <Compile Include="ExecuterView.cs"> 94 100 <SubType>UserControl</SubType> … … 175 181 </ItemGroup> 176 182 <ItemGroup> 183 <EmbeddedResource Include="ProblemView.resx"> 184 <DependentUpon>ProblemView.cs</DependentUpon> 185 </EmbeddedResource> 177 186 <EmbeddedResource Include="DispatcherView.resx"> 178 187 <DependentUpon>DispatcherView.cs</DependentUpon> -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Server/3.3/Server.cs
r2190 r2193 40 40 private static readonly string sqlServerCompactConnectionString = @"Data Source=" + sqlServerCompactFile; 41 41 42 private DatabaseService database; 42 43 private IDispatcher dispatcher; 43 44 public IDispatcher Dispatcher { get { return dispatcher; } } 44 45 private IExecuter executer; 45 46 public IExecuter Executer { get { return executer; } } 47 private Problem problem; 46 48 47 49 private string gridServiceUrl; … … 52 54 53 55 public Server() { 56 database = new DatabaseService(sqlServerCompactConnectionString); 57 problem = new Problem(); 58 try { 59 problem.Dataset = database.GetDataset(); 60 } 61 catch (InvalidOperationException ex) { 62 } 54 63 } 55 64 56 65 internal void Connect(string serverUrl) { 57 DatabaseService database = new DatabaseService(sqlServerCompactConnectionString); 58 dispatcher = new SimpleDispatcher(database); 66 dispatcher = new SimpleDispatcher(database, problem); 59 67 IGridServer gridServer = null; 60 68 if (serverUrl.Contains("ExecutionEngine")) { … … 64 72 gridServer = new GridServerProxy(serverUrl); 65 73 } 66 executer = new GridExecuter(dispatcher, gridServer, database);74 executer = new GridExecuter(dispatcher, gridServer, database); 67 75 executer.Start(); 68 76 } -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Server/3.3/ServerView.cs
r2094 r2193 47 47 this.server = server; 48 48 InitializeComponent(); 49 addressTextBox.Text = server.CedmaServiceUrl;50 49 } 51 50 … … 58 57 dispatcherControl.Dock = DockStyle.Fill; 59 58 dispatcherTabPage.Controls.Add(dispatcherControl); 59 UserControl problemControl = (UserControl)server.Problem.CreateView(); 60 problemControl.Dock = DockStyle.Fill; 61 problemPage.Controls.Add(problemControl); 60 62 connectButton.Enabled = false; 61 63 } -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Server/3.3/ServerView.designer.cs
r2094 r2193 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.addressTextBox = new System.Windows.Forms.TextBox();48 this.externalAddressLabel = new System.Windows.Forms.Label();49 47 this.gridAddressLabel = new System.Windows.Forms.Label(); 50 48 this.address = new System.Windows.Forms.TextBox(); … … 53 51 this.executerTabPage = new System.Windows.Forms.TabPage(); 54 52 this.dispatcherTabPage = new System.Windows.Forms.TabPage(); 53 this.problemPage = new System.Windows.Forms.TabPage(); 55 54 this.tabControl.SuspendLayout(); 56 55 this.SuspendLayout(); 57 //58 // addressTextBox59 //60 this.addressTextBox.Location = new System.Drawing.Point(106, 6);61 this.addressTextBox.Name = "addressTextBox";62 this.addressTextBox.ReadOnly = true;63 this.addressTextBox.Size = new System.Drawing.Size(229, 20);64 this.addressTextBox.TabIndex = 0;65 //66 // externalAddressLabel67 //68 this.externalAddressLabel.AutoSize = true;69 this.externalAddressLabel.Location = new System.Drawing.Point(12, 9);70 this.externalAddressLabel.Name = "externalAddressLabel";71 this.externalAddressLabel.Size = new System.Drawing.Size(48, 13);72 this.externalAddressLabel.TabIndex = 3;73 this.externalAddressLabel.Text = "&Address:";74 56 // 75 57 // gridAddressLabel … … 106 88 this.tabControl.Controls.Add(this.executerTabPage); 107 89 this.tabControl.Controls.Add(this.dispatcherTabPage); 90 this.tabControl.Controls.Add(this.problemPage); 108 91 this.tabControl.Location = new System.Drawing.Point(3, 58); 109 92 this.tabControl.Name = "tabControl"; … … 132 115 this.dispatcherTabPage.UseVisualStyleBackColor = true; 133 116 // 134 // ServerForm 117 // problemPage 118 // 119 this.problemPage.Location = new System.Drawing.Point(4, 22); 120 this.problemPage.Name = "problemPage"; 121 this.problemPage.Padding = new System.Windows.Forms.Padding(3); 122 this.problemPage.Size = new System.Drawing.Size(565, 517); 123 this.problemPage.TabIndex = 2; 124 this.problemPage.Text = "Problem"; 125 this.problemPage.UseVisualStyleBackColor = true; 126 // 127 // ServerView 135 128 // 136 129 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); … … 140 133 this.Controls.Add(this.gridAddressLabel); 141 134 this.Controls.Add(this.address); 142 this.Controls.Add(this.externalAddressLabel); 143 this.Controls.Add(this.addressTextBox); 144 this.Name = "ServerForm"; 135 this.Name = "ServerView"; 145 136 this.Size = new System.Drawing.Size(579, 604); 146 137 this.tabControl.ResumeLayout(false); … … 152 143 #endregion 153 144 154 private System.Windows.Forms.TextBox addressTextBox;155 private System.Windows.Forms.Label externalAddressLabel;156 145 private System.Windows.Forms.Label gridAddressLabel; 157 146 private System.Windows.Forms.TextBox address; … … 160 149 private System.Windows.Forms.TabPage executerTabPage; 161 150 private System.Windows.Forms.TabPage dispatcherTabPage; 151 private System.Windows.Forms.TabPage problemPage; 162 152 } 163 153 } -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Server/3.3/SimpleDispatcher.cs
r2185 r2193 36 36 using HeuristicLab.Core; 37 37 using HeuristicLab.Modeling; 38 using HeuristicLab.Modeling.Database; 38 39 39 40 namespace HeuristicLab.CEDMA.Server { … … 48 49 private Dictionary<int, List<AlgorithmConfiguration>> finishedAndDispatchedRuns; 49 50 50 public SimpleDispatcher(IModelingDatabase database )51 : base(database ) {51 public SimpleDispatcher(IModelingDatabase database, Problem problem) 52 : base(database, problem) { 52 53 random = new Random(); 53 54 finishedAndDispatchedRuns = new Dictionary<int, List<AlgorithmConfiguration>>(); … … 55 56 } 56 57 57 public override IAlgorithm SelectAndConfigureAlgorithm(int targetVariable, int[] inputVariables, Problem problem) {58 public override HeuristicLab.Modeling.IAlgorithm SelectAndConfigureAlgorithm(int targetVariable, int[] inputVariables, Problem problem) { 58 59 DiscoveryService ds = new DiscoveryService(); 59 IAlgorithm[] algos = ds.GetInstances<IAlgorithm>();60 IAlgorithm selectedAlgorithm = null;60 HeuristicLab.Modeling.IAlgorithm[] algos = ds.GetInstances<HeuristicLab.Modeling.IAlgorithm>(); 61 HeuristicLab.Modeling.IAlgorithm selectedAlgorithm = null; 61 62 switch (problem.LearningTask) { 62 63 case LearningTask.Regression: { … … 85 86 } 86 87 87 private IAlgorithm ChooseDeterministic(int targetVariable, int[] inputVariables, IEnumerable<IAlgorithm> algos) {88 private HeuristicLab.Modeling.IAlgorithm ChooseDeterministic(int targetVariable, int[] inputVariables, IEnumerable<HeuristicLab.Modeling.IAlgorithm> algos) { 88 89 var deterministicAlgos = algos 89 90 .Where(a => (a as IStochasticAlgorithm) == null) … … 94 95 } 95 96 96 private IAlgorithm ChooseStochastic(IEnumerable<IAlgorithm> regressionAlgos) {97 private HeuristicLab.Modeling.IAlgorithm ChooseStochastic(IEnumerable<HeuristicLab.Modeling.IAlgorithm> regressionAlgos) { 97 98 var stochasticAlgos = regressionAlgos.Where(a => (a as IStochasticAlgorithm) != null); 98 99 if (stochasticAlgos.Count() == 0) return null; … … 149 150 } 150 151 151 private void SetProblemParameters( IAlgorithm algo, Problem problem, int targetVariable, int[] inputVariables) {152 private void SetProblemParameters(HeuristicLab.Modeling.IAlgorithm algo, Problem problem, int targetVariable, int[] inputVariables) { 152 153 algo.Dataset = problem.Dataset; 153 154 algo.TargetVariable = targetVariable;
Note: See TracChangeset
for help on using the changeset viewer.