Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2193


Ignore:
Timestamp:
07/28/09 15:26:29 (15 years ago)
Author:
gkronber
Message:

Added problem view for the cedma server. #712

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  
    8888  </ItemGroup>
    8989  <ItemGroup>
    90     <Compile Include="StoreProxy.cs" />
    9190    <Compile Include="IResultsViewFactory.cs" />
    9291    <Compile Include="ResultsEntry.cs" />
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Core/3.3/Results.cs

    r2190 r2193  
    3737namespace HeuristicLab.CEDMA.Core {
    3838  public class Results : ItemBase {
    39     private const int PAGE_SIZE = 1000;
    4039    private string[] categoricalVariables = null;
    4140    public string[] CategoricalVariables {
     
    6968
    7069    private IModelingDatabase database;
    71     //public IStore Store {
    72     //  get { return store; }
    73     //  set {
    74     //    store = value;
    75     //  }
    76     //}
    7770
    7871    private Dictionary<string, Dictionary<object, double>> categoricalValueIndices = new Dictionary<string, Dictionary<object, double>>();
     
    9992        modelEntry.Set("PersistedData", model.Data);
    10093        modelEntry.Set("TargetVariable", model.TargetVariable.Name);
     94        entries.Add(modelEntry);
    10195      }
    10296     
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherBase.cs

    r2185 r2193  
    3636using HeuristicLab.Core;
    3737using HeuristicLab.Modeling;
     38using HeuristicLab.Modeling.Database;
    3839
    3940namespace HeuristicLab.CEDMA.Server {
    4041  public abstract class DispatcherBase : IDispatcher {
    4142    private IModelingDatabase database;
    42     private DataSet dataset;
    4343    private List<int> allowedTargetVariables;
    4444    private Dictionary<int, List<int>> activeInputVariables;
    45 
     45    private Problem problem;
    4646    internal event EventHandler Changed;
    4747    private object locker = new object();
     
    4949    public IEnumerable<string> TargetVariables {
    5050      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));
    5353        } else return new string[0];
    5454      }
     
    5757    public IEnumerable<string> InputVariables {
    5858      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));
    6161        } else return new string[0];
    6262      }
    6363    }
    6464
    65     public DispatcherBase(IModelingDatabase database) {
     65    public DispatcherBase(IModelingDatabase database, Problem problem) {
     66      this.problem = problem;
    6667      this.database = database;
    6768      allowedTargetVariables = new List<int>();
     
    6970    }
    7071
    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) {
    7875          activeInputVariables.Add(targetVar, new List<int>());
    79           activeInputVariables[targetVar].AddRange(dataset.Problem.AllowedInputVariables);
     76          activeInputVariables[targetVar].AddRange(problem.AllowedInputVariables);
    8077        }
    8178        OnChanged();
     
    9390        }
    9491
    95         IAlgorithm selectedAlgorithm = SelectAndConfigureAlgorithm(targetVariable, inputVariables, dataset.Problem);
     92        HeuristicLab.Modeling.IAlgorithm selectedAlgorithm = SelectAndConfigureAlgorithm(targetVariable, inputVariables, problem);
    9693
    9794        return selectedAlgorithm;
     
    103100      return targetVariables[rand.Next(targetVariables.Length)];
    104101    }
    105     public abstract IAlgorithm SelectAndConfigureAlgorithm(int targetVariable, int[] inputVariables, Problem problem);
     102    public abstract HeuristicLab.Modeling.IAlgorithm SelectAndConfigureAlgorithm(int targetVariable, int[] inputVariables, Problem problem);
    106103
    107104    #region IViewable Members
    108105
    109106    public IView CreateView() {
    110       return new DispatcherView(this);
     107      return new ProblemView(this);
    111108    }
    112109
     
    115112    internal void EnableTargetVariable(string name) {
    116113      lock (locker)
    117         allowedTargetVariables.Add(dataset.Problem.Dataset.GetVariableIndex(name));
     114        allowedTargetVariables.Add(problem.Dataset.GetVariableIndex(name));
    118115    }
    119116
    120117    internal void DisableTargetVariable(string name) {
    121118      lock (locker)
    122         allowedTargetVariables.Remove(dataset.Problem.Dataset.GetVariableIndex(name));
     119        allowedTargetVariables.Remove(problem.Dataset.GetVariableIndex(name));
    123120    }
    124121
    125122    internal void EnableInputVariable(string target, string name) {
    126123      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);
    129126        if (!activeInputVariables[targetIndex].Contains(inputIndex)) {
    130127          activeInputVariables[targetIndex].Add(inputIndex);
     
    135132    internal void DisableInputVariable(string target, string name) {
    136133      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);
    139136        while (activeInputVariables[targetIndex].Remove(inputIndex)) { }
    140137      }
     
    146143
    147144    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));
    150147    }
    151148  }
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherView.cs

    r2153 r2193  
    1212  public partial class DispatcherView : ViewBase {
    1313    private DispatcherBase dispatcher;
    14     public DispatcherView(DispatcherBase dispatcher) : base() {
     14    public DispatcherView(DispatcherBase dispatcher)
     15      : base() {
    1516      this.dispatcher = dispatcher;
    1617      InitializeComponent();
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Server/3.3/HeuristicLab.CEDMA.Server-3.3.csproj

    r2185 r2193  
    9191  </ItemGroup>
    9292  <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>
    9399    <Compile Include="ExecuterView.cs">
    94100      <SubType>UserControl</SubType>
     
    175181  </ItemGroup>
    176182  <ItemGroup>
     183    <EmbeddedResource Include="ProblemView.resx">
     184      <DependentUpon>ProblemView.cs</DependentUpon>
     185    </EmbeddedResource>
    177186    <EmbeddedResource Include="DispatcherView.resx">
    178187      <DependentUpon>DispatcherView.cs</DependentUpon>
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Server/3.3/Server.cs

    r2190 r2193  
    4040    private static readonly string sqlServerCompactConnectionString = @"Data Source=" + sqlServerCompactFile;
    4141
     42    private DatabaseService database;
    4243    private IDispatcher dispatcher;
    4344    public IDispatcher Dispatcher { get { return dispatcher; } }
    4445    private IExecuter executer;
    4546    public IExecuter Executer { get { return executer; } }
     47    private Problem problem;
    4648
    4749    private string gridServiceUrl;
     
    5254
    5355    public Server() {
     56      database = new DatabaseService(sqlServerCompactConnectionString);
     57      problem = new Problem();
     58      try {
     59        problem.Dataset = database.GetDataset();
     60      }
     61      catch (InvalidOperationException ex) {
     62      }
    5463    }
    5564
    5665    internal void Connect(string serverUrl) {
    57       DatabaseService database = new DatabaseService(sqlServerCompactConnectionString);
    58       dispatcher = new SimpleDispatcher(database);
     66      dispatcher = new SimpleDispatcher(database, problem);
    5967      IGridServer gridServer = null;
    6068      if (serverUrl.Contains("ExecutionEngine")) {
     
    6472        gridServer = new GridServerProxy(serverUrl);
    6573      }
    66       executer = new GridExecuter(dispatcher, gridServer,database);
     74      executer = new GridExecuter(dispatcher, gridServer, database);
    6775      executer.Start();
    6876    }
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Server/3.3/ServerView.cs

    r2094 r2193  
    4747      this.server = server;
    4848      InitializeComponent();
    49       addressTextBox.Text = server.CedmaServiceUrl;
    5049    }
    5150
     
    5857      dispatcherControl.Dock = DockStyle.Fill;
    5958      dispatcherTabPage.Controls.Add(dispatcherControl);
     59      UserControl problemControl = (UserControl)server.Problem.CreateView();
     60      problemControl.Dock = DockStyle.Fill;
     61      problemPage.Controls.Add(problemControl);
    6062      connectButton.Enabled = false;     
    6163    }
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Server/3.3/ServerView.designer.cs

    r2094 r2193  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.addressTextBox = new System.Windows.Forms.TextBox();
    48       this.externalAddressLabel = new System.Windows.Forms.Label();
    4947      this.gridAddressLabel = new System.Windows.Forms.Label();
    5048      this.address = new System.Windows.Forms.TextBox();
     
    5351      this.executerTabPage = new System.Windows.Forms.TabPage();
    5452      this.dispatcherTabPage = new System.Windows.Forms.TabPage();
     53      this.problemPage = new System.Windows.Forms.TabPage();
    5554      this.tabControl.SuspendLayout();
    5655      this.SuspendLayout();
    57       //
    58       // addressTextBox
    59       //
    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       // externalAddressLabel
    67       //
    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:";
    7456      //
    7557      // gridAddressLabel
     
    10688      this.tabControl.Controls.Add(this.executerTabPage);
    10789      this.tabControl.Controls.Add(this.dispatcherTabPage);
     90      this.tabControl.Controls.Add(this.problemPage);
    10891      this.tabControl.Location = new System.Drawing.Point(3, 58);
    10992      this.tabControl.Name = "tabControl";
     
    132115      this.dispatcherTabPage.UseVisualStyleBackColor = true;
    133116      //
    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
    135128      //
    136129      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     
    140133      this.Controls.Add(this.gridAddressLabel);
    141134      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";
    145136      this.Size = new System.Drawing.Size(579, 604);
    146137      this.tabControl.ResumeLayout(false);
     
    152143    #endregion
    153144
    154     private System.Windows.Forms.TextBox addressTextBox;
    155     private System.Windows.Forms.Label externalAddressLabel;
    156145    private System.Windows.Forms.Label gridAddressLabel;
    157146    private System.Windows.Forms.TextBox address;
     
    160149    private System.Windows.Forms.TabPage executerTabPage;
    161150    private System.Windows.Forms.TabPage dispatcherTabPage;
     151    private System.Windows.Forms.TabPage problemPage;
    162152  }
    163153}
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Server/3.3/SimpleDispatcher.cs

    r2185 r2193  
    3636using HeuristicLab.Core;
    3737using HeuristicLab.Modeling;
     38using HeuristicLab.Modeling.Database;
    3839
    3940namespace HeuristicLab.CEDMA.Server {
     
    4849    private Dictionary<int, List<AlgorithmConfiguration>> finishedAndDispatchedRuns;
    4950
    50     public SimpleDispatcher(IModelingDatabase database)
    51       : base(database) {     
     51    public SimpleDispatcher(IModelingDatabase database, Problem problem)
     52      : base(database, problem) {     
    5253      random = new Random();
    5354      finishedAndDispatchedRuns = new Dictionary<int, List<AlgorithmConfiguration>>();
     
    5556    }
    5657
    57     public override IAlgorithm SelectAndConfigureAlgorithm(int targetVariable, int[] inputVariables, Problem problem) {
     58    public override HeuristicLab.Modeling.IAlgorithm SelectAndConfigureAlgorithm(int targetVariable, int[] inputVariables, Problem problem) {
    5859      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;
    6162      switch (problem.LearningTask) {
    6263        case LearningTask.Regression: {
     
    8586    }
    8687
    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) {
    8889      var deterministicAlgos = algos
    8990        .Where(a => (a as IStochasticAlgorithm) == null)
     
    9495    }
    9596
    96     private IAlgorithm ChooseStochastic(IEnumerable<IAlgorithm> regressionAlgos) {
     97    private HeuristicLab.Modeling.IAlgorithm ChooseStochastic(IEnumerable<HeuristicLab.Modeling.IAlgorithm> regressionAlgos) {
    9798      var stochasticAlgos = regressionAlgos.Where(a => (a as IStochasticAlgorithm) != null);
    9899      if (stochasticAlgos.Count() == 0) return null;
     
    149150    }
    150151
    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) {
    152153      algo.Dataset = problem.Dataset;
    153154      algo.TargetVariable = targetVariable;
Note: See TracChangeset for help on using the changeset viewer.