Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/03/09 14:23:54 (15 years ago)
Author:
mkommend
Message:

reintegrated branch new heuristic.modeling database backend (ticket #712)

Location:
trunk/sources/HeuristicLab.CEDMA.Server/3.3
Files:
11 edited
5 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherBase.cs

    r2222 r2223  
    2727using System.Net;
    2828using System.ServiceModel;
    29 using HeuristicLab.CEDMA.DB.Interfaces;
    30 using HeuristicLab.CEDMA.DB;
    3129using System.ServiceModel.Description;
    3230using System.Linq;
     
    3533using HeuristicLab.Core;
    3634using HeuristicLab.Modeling;
     35using HeuristicLab.Modeling.Database;
    3736
    3837namespace HeuristicLab.CEDMA.Server {
    3938  public abstract class DispatcherBase : IDispatcher {
    40     private IStore store;
    41     private DataSet dataset;
     39    private IModelingDatabase database;
    4240    private List<int> allowedTargetVariables;
    4341    private Dictionary<int, List<int>> activeInputVariables;
    44 
     42    private Problem problem;
    4543    internal event EventHandler Changed;
    4644    private object locker = new object();
     
    4846    public IEnumerable<string> TargetVariables {
    4947      get {
    50         if (dataset != null) {
    51           return dataset.Problem.AllowedTargetVariables.Select(x => dataset.Problem.Dataset.GetVariableName(x));
     48        if (problem != null) {
     49          return Enumerable.Range(0, problem.Dataset.Columns).Select(x => problem.Dataset.GetVariableName(x));
    5250        } else return new string[0];
    5351      }
     
    5654    public IEnumerable<string> InputVariables {
    5755      get {
    58         if (dataset != null) {
    59           return dataset.Problem.AllowedInputVariables.Select(x => dataset.Problem.Dataset.GetVariableName(x));
     56        if (problem != null) {
     57          return TargetVariables;
    6058        } else return new string[0];
    6159      }
    6260    }
    6361
    64     public DispatcherBase(IStore store) {
    65       this.store = store;
     62    public DispatcherBase(IModelingDatabase database, Problem problem) {
     63      this.problem = problem;
    6664      allowedTargetVariables = new List<int>();
    6765      activeInputVariables = new Dictionary<int, List<int>>();
     66      problem.Changed += (sender, args) => {
     67        lock (locker) {
     68          allowedTargetVariables.Clear();
     69          activeInputVariables.Clear();
     70        }
     71        OnChanged();
     72      };
     73      this.database = database;
    6874    }
    6975
    70     public IAlgorithm GetNextJob() {
    71       if (dataset == null) {
    72         var datasetEntities = store.Query("?DataSet <" + Ontology.InstanceOf.Uri + "> <" + Ontology.TypeDataSet.Uri + "> .", 0, 1)
    73           .Select(x => (Entity)x.Get("DataSet"));
    74         if (datasetEntities.Count() == 0) return null;
    75         dataset = new DataSet(store, datasetEntities.ElementAt(0));
    76         foreach (int targetVar in dataset.Problem.AllowedTargetVariables) {
    77           activeInputVariables.Add(targetVar, new List<int>());
    78           activeInputVariables[targetVar].AddRange(dataset.Problem.AllowedInputVariables);
    79         }
    80         OnChanged();
    81       }
     76    public HeuristicLab.Modeling.IAlgorithm GetNextJob() {
    8277      if (allowedTargetVariables.Count > 0) {
    8378        int[] targetVariables, inputVariables;
     
    9287        }
    9388
    94         IAlgorithm selectedAlgorithm = SelectAndConfigureAlgorithm(targetVariable, inputVariables, dataset.Problem);
     89        HeuristicLab.Modeling.IAlgorithm selectedAlgorithm = SelectAndConfigureAlgorithm(targetVariable, inputVariables, problem);
    9590
    9691        return selectedAlgorithm;
     
    10297      return targetVariables[rand.Next(targetVariables.Length)];
    10398    }
    104     public abstract IAlgorithm SelectAndConfigureAlgorithm(int targetVariable, int[] inputVariables, Problem problem);
     99    public abstract HeuristicLab.Modeling.IAlgorithm SelectAndConfigureAlgorithm(int targetVariable, int[] inputVariables, Problem problem);
    105100
    106101    #region IViewable Members
     
    114109    internal void EnableTargetVariable(string name) {
    115110      lock (locker)
    116         allowedTargetVariables.Add(dataset.Problem.Dataset.GetVariableIndex(name));
     111        allowedTargetVariables.Add(problem.Dataset.GetVariableIndex(name));
    117112    }
    118113
    119114    internal void DisableTargetVariable(string name) {
    120115      lock (locker)
    121         allowedTargetVariables.Remove(dataset.Problem.Dataset.GetVariableIndex(name));
     116        allowedTargetVariables.Remove(problem.Dataset.GetVariableIndex(name));
    122117    }
    123118
    124119    internal void EnableInputVariable(string target, string name) {
    125120      lock (locker) {
    126         int targetIndex = dataset.Problem.Dataset.GetVariableIndex(target);
    127         int inputIndex = dataset.Problem.Dataset.GetVariableIndex(name);
     121        int targetIndex = problem.Dataset.GetVariableIndex(target);
     122        int inputIndex = problem.Dataset.GetVariableIndex(name);
     123        if (!activeInputVariables.ContainsKey(targetIndex)) activeInputVariables[targetIndex] = new List<int>();
    128124        if (!activeInputVariables[targetIndex].Contains(inputIndex)) {
    129125          activeInputVariables[targetIndex].Add(inputIndex);
     
    134130    internal void DisableInputVariable(string target, string name) {
    135131      lock (locker) {
    136         int targetIndex = dataset.Problem.Dataset.GetVariableIndex(target);
    137         int inputIndex = dataset.Problem.Dataset.GetVariableIndex(name);
     132        int targetIndex = problem.Dataset.GetVariableIndex(target);
     133        int inputIndex = problem.Dataset.GetVariableIndex(name);
     134        if (!activeInputVariables.ContainsKey(targetIndex)) activeInputVariables[targetIndex] = new List<int>();
    138135        while (activeInputVariables[targetIndex].Remove(inputIndex)) { }
    139136      }
     
    145142
    146143    internal IEnumerable<string> GetInputVariables(string target) {
    147       return activeInputVariables[dataset.Problem.Dataset.GetVariableIndex(target)]
    148         .Select(i => dataset.Problem.Dataset.GetVariableName(i));
     144      int targetIndex = problem.Dataset.GetVariableIndex(target);
     145      if (!activeInputVariables.ContainsKey(targetIndex)) activeInputVariables[targetIndex] = new List<int>();
     146      return activeInputVariables[targetIndex]
     147        .Select(i => problem.Dataset.GetVariableName(i));
    149148    }
    150149  }
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherView.cs

    r2153 r2223  
    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();
    1718      UpdateControls();
    1819      dispatcher.Changed += (sender, args) => UpdateControls();
     20      this.inputVariableList.CheckOnClick = true;
    1921    }
    2022
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/ExecuterBase.cs

    r2222 r2223  
    2727using System.Net;
    2828using System.ServiceModel;
    29 using HeuristicLab.CEDMA.DB.Interfaces;
    30 using HeuristicLab.CEDMA.DB;
    3129using System.ServiceModel.Description;
    3230using System.Linq;
     
    3836using System.Threading;
    3937using HeuristicLab.Modeling;
     38using HeuristicLab.Modeling.Database;
    4039
    4140namespace HeuristicLab.CEDMA.Server {
     
    4645    protected IDispatcher Dispatcher {
    4746      get { return dispatcher; }
    48     }
    49     private IStore store;
     47    }   
     48    private IModelingDatabase databaseService;
    5049
    5150    private int maxActiveJobs;
     
    5958    }
    6059
    61     public ExecuterBase(IDispatcher dispatcher, IStore store) {
     60    public ExecuterBase(IDispatcher dispatcher, IModelingDatabase databaseService) {
    6261      maxActiveJobs = 10;
    6362      this.dispatcher = dispatcher;
    64       this.store = store;
     63      this.databaseService = databaseService;
    6564    }
    6665
     
    7271
    7372    protected void SetResults(IScope src, IScope target) {
    74       foreach (IVariable v in src.Variables) {
     73      foreach (HeuristicLab.Core.IVariable v in src.Variables) {
    7574        target.AddVariable(v);
    7675      }
     
    8382    }
    8483
    85     protected void StoreResults(IAlgorithm finishedAlgorithm) {
    86       Entity modelEntity = new Entity(Ontology.CedmaNameSpace + Guid.NewGuid());
    87       IModel model = finishedAlgorithm.Model;
    88       List<Statement> statements = new List<Statement>();
    89       statements.Add(new Statement(modelEntity, Ontology.InstanceOf, Ontology.TypeModel));
    90       statements.Add(new Statement(modelEntity, Ontology.TargetVariable, new Literal(model.TargetVariable)));
    91       statements.Add(new Statement(modelEntity, Ontology.Name, new Literal(finishedAlgorithm.Name)));
     84    protected void StoreResults(HeuristicLab.Modeling.IAlgorithm finishedAlgorithm) {
     85      databaseService.Persist(finishedAlgorithm);
     86      //Entity modelEntity = new Entity(Ontology.CedmaNameSpace + Guid.NewGuid());
     87      //IModel model = finishedAlgorithm.Model;
     88      //List<Statement> statements = new List<Statement>();
     89      //statements.Add(new Statement(modelEntity, Ontology.InstanceOf, Ontology.TypeModel));
     90      //statements.Add(new Statement(modelEntity, Ontology.TargetVariable, new Literal(model.TargetVariable)));
     91      //statements.Add(new Statement(modelEntity, Ontology.Name, new Literal(finishedAlgorithm.Name)));
    9292     
    93       statements.Add(new Statement(modelEntity, Ontology.TrainingMeanSquaredError, new Literal(model.TrainingMeanSquaredError)));
    94       statements.Add(new Statement(modelEntity, Ontology.ValidationMeanSquaredError, new Literal(model.ValidationMeanSquaredError)));
    95       statements.Add(new Statement(modelEntity, Ontology.TestMeanSquaredError, new Literal(model.TestMeanSquaredError)));
    96       statements.Add(new Statement(modelEntity, Ontology.TrainingCoefficientOfDetermination, new Literal(model.TrainingCoefficientOfDetermination)));
    97       statements.Add(new Statement(modelEntity, Ontology.ValidationCoefficientOfDetermination, new Literal(model.ValidationCoefficientOfDetermination)));
    98       statements.Add(new Statement(modelEntity, Ontology.TestCoefficientOfDetermination, new Literal(model.TestCoefficientOfDetermination)));
    99       statements.Add(new Statement(modelEntity, Ontology.TrainingVarianceAccountedFor, new Literal(model.TrainingVarianceAccountedFor)));
    100       statements.Add(new Statement(modelEntity, Ontology.ValidationVarianceAccountedFor, new Literal(model.ValidationVarianceAccountedFor)));
    101       statements.Add(new Statement(modelEntity, Ontology.TestVarianceAccountedFor, new Literal(model.TestVarianceAccountedFor)));
    102       statements.Add(new Statement(modelEntity, Ontology.TrainingMeanAbsolutePercentageError, new Literal(model.TrainingMeanAbsolutePercentageError)));
    103       statements.Add(new Statement(modelEntity, Ontology.ValidationMeanAbsolutePercentageError, new Literal(model.ValidationMeanAbsolutePercentageError)));
    104       statements.Add(new Statement(modelEntity, Ontology.TestMeanAbsolutePercentageError, new Literal(model.TestMeanAbsolutePercentageError)));
    105       statements.Add(new Statement(modelEntity, Ontology.TrainingMeanAbsolutePercentageOfRangeError, new Literal(model.TrainingMeanAbsolutePercentageOfRangeError)));
    106       statements.Add(new Statement(modelEntity, Ontology.ValidationMeanAbsolutePercentageOfRangeError, new Literal(model.ValidationMeanAbsolutePercentageOfRangeError)));
    107       statements.Add(new Statement(modelEntity, Ontology.TestMeanAbsolutePercentageOfRangeError, new Literal(model.TestMeanAbsolutePercentageOfRangeError)));
     93      //statements.Add(new Statement(modelEntity, Ontology.TrainingMeanSquaredError, new Literal(model.TrainingMeanSquaredError)));
     94      //statements.Add(new Statement(modelEntity, Ontology.ValidationMeanSquaredError, new Literal(model.ValidationMeanSquaredError)));
     95      //statements.Add(new Statement(modelEntity, Ontology.TestMeanSquaredError, new Literal(model.TestMeanSquaredError)));
     96      //statements.Add(new Statement(modelEntity, Ontology.TrainingCoefficientOfDetermination, new Literal(model.TrainingCoefficientOfDetermination)));
     97      //statements.Add(new Statement(modelEntity, Ontology.ValidationCoefficientOfDetermination, new Literal(model.ValidationCoefficientOfDetermination)));
     98      //statements.Add(new Statement(modelEntity, Ontology.TestCoefficientOfDetermination, new Literal(model.TestCoefficientOfDetermination)));
     99      //statements.Add(new Statement(modelEntity, Ontology.TrainingVarianceAccountedFor, new Literal(model.TrainingVarianceAccountedFor)));
     100      //statements.Add(new Statement(modelEntity, Ontology.ValidationVarianceAccountedFor, new Literal(model.ValidationVarianceAccountedFor)));
     101      //statements.Add(new Statement(modelEntity, Ontology.TestVarianceAccountedFor, new Literal(model.TestVarianceAccountedFor)));
     102      //statements.Add(new Statement(modelEntity, Ontology.TrainingMeanAbsolutePercentageError, new Literal(model.TrainingMeanAbsolutePercentageError)));
     103      //statements.Add(new Statement(modelEntity, Ontology.ValidationMeanAbsolutePercentageError, new Literal(model.ValidationMeanAbsolutePercentageError)));
     104      //statements.Add(new Statement(modelEntity, Ontology.TestMeanAbsolutePercentageError, new Literal(model.TestMeanAbsolutePercentageError)));
     105      //statements.Add(new Statement(modelEntity, Ontology.TrainingMeanAbsolutePercentageOfRangeError, new Literal(model.TrainingMeanAbsolutePercentageOfRangeError)));
     106      //statements.Add(new Statement(modelEntity, Ontology.ValidationMeanAbsolutePercentageOfRangeError, new Literal(model.ValidationMeanAbsolutePercentageOfRangeError)));
     107      //statements.Add(new Statement(modelEntity, Ontology.TestMeanAbsolutePercentageOfRangeError, new Literal(model.TestMeanAbsolutePercentageOfRangeError)));
    108108
    109       for (int i = 0; i < finishedAlgorithm.Dataset.Columns; i++) {
    110         try {
    111           string variableName = finishedAlgorithm.Dataset.GetVariableName(i);
    112           double qualImpact = model.GetVariableQualityImpact(variableName);
    113           double evalImpact = model.GetVariableEvaluationImpact(variableName);
     109      //for (int i = 0; i < finishedAlgorithm.Dataset.Columns; i++) {
     110      //  try {
     111      //    string variableName = finishedAlgorithm.Dataset.GetVariableName(i);
     112      //    double qualImpact = model.GetVariableQualityImpact(variableName);
     113      //    double evalImpact = model.GetVariableEvaluationImpact(variableName);
    114114
    115           Entity inputVariableEntity = new Entity(Ontology.CedmaNameSpace + Guid.NewGuid());
    116           statements.Add(new Statement(inputVariableEntity, Ontology.InstanceOf, Ontology.TypeVariableImpact));
    117           statements.Add(new Statement(modelEntity, Ontology.HasInputVariable, inputVariableEntity));
    118           statements.Add(new Statement(inputVariableEntity, Ontology.EvaluationImpact, new Literal(evalImpact)));
    119           statements.Add(new Statement(inputVariableEntity, Ontology.QualityImpact, new Literal(qualImpact)));
    120           statements.Add(new Statement(inputVariableEntity, Ontology.Name, new Literal(variableName)));
    121         }
    122         catch (ArgumentException) {
    123           // ignore
    124         }
    125       }
     115      //    Entity inputVariableEntity = new Entity(Ontology.CedmaNameSpace + Guid.NewGuid());
     116      //    statements.Add(new Statement(inputVariableEntity, Ontology.InstanceOf, Ontology.TypeVariableImpact));
     117      //    statements.Add(new Statement(modelEntity, Ontology.HasInputVariable, inputVariableEntity));
     118      //    statements.Add(new Statement(inputVariableEntity, Ontology.EvaluationImpact, new Literal(evalImpact)));
     119      //    statements.Add(new Statement(inputVariableEntity, Ontology.QualityImpact, new Literal(qualImpact)));
     120      //    statements.Add(new Statement(inputVariableEntity, Ontology.Name, new Literal(variableName)));
     121      //  }
     122      //  catch (ArgumentException) {
     123      //    // ignore
     124      //  }
     125      //}
    126126
    127       byte[] serializedModel = PersistenceManager.SaveToGZip(model.Data);
    128       statements.Add(new Statement(modelEntity, Ontology.SerializedData, new Literal(Convert.ToBase64String(serializedModel))));
    129       store.AddRange(statements);
     127      //byte[] serializedModel = PersistenceManager.SaveToGZip(model.Data);
     128      //statements.Add(new Statement(modelEntity, Ontology.SerializedData, new Literal(Convert.ToBase64String(serializedModel))));
     129      //store.AddRange(statements);
    130130    }
    131131
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/GridExecuter.cs

    r2222 r2223  
    2727using System.Net;
    2828using System.ServiceModel;
    29 using HeuristicLab.CEDMA.DB.Interfaces;
    30 using HeuristicLab.CEDMA.DB;
    3129using System.ServiceModel.Description;
    3230using System.Linq;
     
    3836using System.Threading;
    3937using HeuristicLab.Modeling;
     38using HeuristicLab.Modeling.Database;
    4039
    4140namespace HeuristicLab.CEDMA.Server {
    4241  public class GridExecuter : ExecuterBase {
    4342    private JobManager jobManager;
    44     private Dictionary<AsyncGridResult, IAlgorithm> activeAlgorithms;
     43    private Dictionary<AsyncGridResult, HeuristicLab.Modeling.IAlgorithm> activeAlgorithms;
    4544
    4645    private TimeSpan StartJobInterval {
     
    5655    }
    5756
    58     public GridExecuter(IDispatcher dispatcher, IStore store, IGridServer server)
    59       : base(dispatcher, store) {
     57    public GridExecuter(IDispatcher dispatcher,  IGridServer server, IModelingDatabase databaseService)
     58      : base(dispatcher, databaseService) {
    6059      this.jobManager = new JobManager(server);
    61       activeAlgorithms = new Dictionary<AsyncGridResult, IAlgorithm>();
     60      activeAlgorithms = new Dictionary<AsyncGridResult, HeuristicLab.Modeling.IAlgorithm>();
    6261      jobManager.Reset();
    6362    }
     
    7170            Thread.Sleep(StartJobInterval);
    7271            // get an execution from the dispatcher and execute in grid via job-manager
    73             IAlgorithm algorithm = Dispatcher.GetNextJob();
     72            HeuristicLab.Modeling.IAlgorithm algorithm = Dispatcher.GetNextJob();
    7473            if (algorithm != null) {
    7574              AtomicOperation op = new AtomicOperation(algorithm.Engine.OperatorGraph.InitialOperator, algorithm.Engine.GlobalScope);
     
    9190            if (readyHandleIndex != WaitHandle.WaitTimeout) {
    9291              WaitHandle readyHandle = whArr[readyHandleIndex];
    93               IAlgorithm finishedAlgorithm = null;
     92              HeuristicLab.Modeling.IAlgorithm finishedAlgorithm = null;
    9493              AsyncGridResult finishedResult = null;
    9594              lock (activeAlgorithms) {
     
    138137        string[] retVal = new string[activeAlgorithms.Count];
    139138        int i = 0;
    140         foreach (IAlgorithm a in activeAlgorithms.Values) {
     139        foreach (HeuristicLab.Modeling.IAlgorithm a in activeAlgorithms.Values) {
    141140          retVal[i++] = a.Name + " " + a.Dataset.GetVariableName(a.TargetVariable);
    142141        }
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/HeuristicLab.CEDMA.Server-3.3.csproj

    r2094 r2223  
    9191  </ItemGroup>
    9292  <ItemGroup>
     93    <Compile Include="LearningTask.cs" />
     94    <Compile Include="Problem.cs" />
     95    <Compile Include="ProblemView.cs">
     96      <SubType>UserControl</SubType>
     97    </Compile>
     98    <Compile Include="ProblemView.Designer.cs">
     99      <DependentUpon>ProblemView.cs</DependentUpon>
     100    </Compile>
    93101    <Compile Include="ExecuterView.cs">
    94102      <SubType>UserControl</SubType>
     
    125133      <Name>HeuristicLab.CEDMA.Core-3.3</Name>
    126134    </ProjectReference>
    127     <ProjectReference Include="..\..\HeuristicLab.CEDMA.DB.Interfaces\3.3\HeuristicLab.CEDMA.DB.Interfaces-3.3.csproj">
    128       <Project>{4F9BB789-D561-436B-B226-2BF44B7D0804}</Project>
    129       <Name>HeuristicLab.CEDMA.DB.Interfaces-3.3</Name>
    130     </ProjectReference>
    131     <ProjectReference Include="..\..\HeuristicLab.CEDMA.DB\3.3\HeuristicLab.CEDMA.DB-3.3.csproj">
    132       <Project>{B3D6D8D9-2B1F-47EC-9C73-77FAECF87310}</Project>
    133       <Name>HeuristicLab.CEDMA.DB-3.3</Name>
    134     </ProjectReference>
    135135    <ProjectReference Include="..\..\HeuristicLab.Core\3.2\HeuristicLab.Core-3.2.csproj">
    136136      <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project>
     
    153153      <Name>HeuristicLab.Grid-3.2</Name>
    154154    </ProjectReference>
     155    <ProjectReference Include="..\..\HeuristicLab.Modeling.Database.SQLServerCompact\3.2\HeuristicLab.Modeling.Database.SQLServerCompact-3.2.csproj">
     156      <Project>{EC1AA756-D612-4FA6-AA52-25CF4F8E3836}</Project>
     157      <Name>HeuristicLab.Modeling.Database.SQLServerCompact-3.2</Name>
     158    </ProjectReference>
     159    <ProjectReference Include="..\..\HeuristicLab.Modeling.Database\3.2\HeuristicLab.Modeling.Database-3.2.csproj">
     160      <Project>{E84E5717-79F8-498F-A5E0-A055C4EC086B}</Project>
     161      <Name>HeuristicLab.Modeling.Database-3.2</Name>
     162    </ProjectReference>
    155163    <ProjectReference Include="..\..\HeuristicLab.Modeling\3.2\HeuristicLab.Modeling-3.2.csproj">
    156164      <Project>{80F7FADA-549D-4151-8856-79B620A50DBA}</Project>
     
    171179  </ItemGroup>
    172180  <ItemGroup>
     181    <EmbeddedResource Include="ProblemView.resx">
     182      <DependentUpon>ProblemView.cs</DependentUpon>
     183    </EmbeddedResource>
    173184    <EmbeddedResource Include="DispatcherView.resx">
    174185      <DependentUpon>DispatcherView.cs</DependentUpon>
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/HeuristicLabCedmaServerPlugin.cs

    r2058 r2223  
    2828  [ClassInfo(Name = "HeuristicLab.CEDMA.Server-3.3")]
    2929  [PluginFile(Filename = "HeuristicLab.CEDMA.Server-3.3.dll", Filetype = PluginFileType.Assembly)]
    30   [Dependency(Dependency = "HeuristicLab.CEDMA.DB.Interfaces-3.3")]
    31   [Dependency(Dependency = "HeuristicLab.CEDMA.DB-3.3")]
    3230  [Dependency(Dependency = "HeuristicLab.Grid-3.2")]
    3331  [Dependency(Dependency = "HeuristicLab.Grid.HiveBridge-3.2")]
     
    3634  [Dependency(Dependency = "HeuristicLab.DataAnalysis-3.2")]
    3735  [Dependency(Dependency = "HeuristicLab.Modeling-3.2")]
     36  [Dependency(Dependency = "HeuristicLab.Modeling.Database-3.2")]
     37  [Dependency(Dependency = "HeuristicLab.Modeling.Database.SQLServerCompact-3.2")]
    3838  [Dependency(Dependency = "HeuristicLab.Tracing-3.2")]
    3939  public class HeuristicLabCedmaServerPlugin : PluginBase {
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/Server.cs

    r2094 r2223  
    2727using System.Net;
    2828using System.ServiceModel;
    29 using HeuristicLab.CEDMA.DB.Interfaces;
    30 using HeuristicLab.CEDMA.DB;
    3129using System.ServiceModel.Description;
    3230using HeuristicLab.Grid;
    3331using HeuristicLab.Grid.HiveBridge;
    3432using HeuristicLab.Core;
     33using HeuristicLab.Modeling.Database;
     34using HeuristicLab.Modeling.Database.SQLServerCompact;
    3535
    3636namespace HeuristicLab.CEDMA.Server {
    3737  public class Server : IViewable {
    38     private static readonly string rdfFile = AppDomain.CurrentDomain.BaseDirectory + "rdf_store.db3";
    39     private static readonly string rdfConnectionString = "sqlite:rdf:Data Source=\"" + rdfFile + "\"";
     38    private static readonly string sqlServerCompactFile = AppDomain.CurrentDomain.BaseDirectory + "HeuristicLab.Modeling.database.sdf";
     39    private static readonly string sqlServerCompactConnectionString = @"Data Source=" + sqlServerCompactFile;
    4040
    41     private ServiceHost host;
    42     private Store store;
    43 
     41    private DatabaseService database;
    4442    private IDispatcher dispatcher;
    4543    public IDispatcher Dispatcher { get { return dispatcher; } }
    4644    private IExecuter executer;
    4745    public IExecuter Executer { get { return executer; } }
     46    private Problem problem;
     47    public Problem Problem { get { return problem; } }
    4848
    4949    private string gridServiceUrl;
     
    5353    }
    5454
    55     private string cedmaServiceUrl;
    56     public string CedmaServiceUrl {
    57       get { return cedmaServiceUrl; }
    58       set { cedmaServiceUrl = value; }
    59     }
    60 
    6155    public Server() {
    62       IPAddress[] addresses = Dns.GetHostAddresses(Dns.GetHostName());
    63       // windows XP returns the external ip on index 0 while windows vista returns the external ip as one of the last entries
    64       // also if IPv6 protocol is installed we want to find an entry that is IPv4
    65       int index = 0;
    66       if (System.Environment.OSVersion.Version.Major >= 6) {
    67         for (index = addresses.Length - 1; index >= 0; index--)
    68           if (addresses[index].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
    69             break;
     56      database = new DatabaseService(sqlServerCompactConnectionString);
     57      problem = new Problem();
     58      try {
     59        problem.Dataset = database.GetDataset();
    7060      }
    71       cedmaServiceUrl = "net.tcp://" + addresses[index] + ":8002/CEDMA";
    72       store = new Store(rdfConnectionString);
    73     }
    74 
    75     public void Start() {
    76       host = new ServiceHost(store, new Uri(cedmaServiceUrl));
    77       ServiceThrottlingBehavior throttlingBehavior = new ServiceThrottlingBehavior();
    78       throttlingBehavior.MaxConcurrentSessions = 20;
    79       host.Description.Behaviors.Add(throttlingBehavior);
    80       try {
    81         NetTcpBinding binding = new NetTcpBinding();
    82         binding.SendTimeout = new TimeSpan(10, 0, 0);
    83         binding.MaxReceivedMessageSize = int.MaxValue;
    84         binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
    85         binding.ReaderQuotas.MaxArrayLength = int.MaxValue;
    86         host.AddServiceEndpoint(typeof(IStore), binding, cedmaServiceUrl);
    87         host.Open();
    88       }
    89       catch (CommunicationException ex) {
    90         MessageBox.Show("An exception occurred: " + ex.Message);
    91         host.Abort();
     61      catch (InvalidOperationException ex) {
    9262      }
    9363    }
    9464
    9565    internal void Connect(string serverUrl) {
    96       dispatcher = new SimpleDispatcher(store);
     66      dispatcher = new SimpleDispatcher(database, problem);
    9767      IGridServer gridServer = null;
    9868      if (serverUrl.Contains("ExecutionEngine")) {
     
    10272        gridServer = new GridServerProxy(serverUrl);
    10373      }
    104       executer = new GridExecuter(dispatcher, store, gridServer);
     74      executer = new GridExecuter(dispatcher, gridServer, database);
    10575      executer.Start();
    10676    }
     
    11080      return new ServerView(this);
    11181    }
    112 
    11382    #endregion
    11483  }
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerApplication.cs

    r2119 r2223  
    2727
    2828namespace HeuristicLab.CEDMA.Server {
    29   [ClassInfo(Name = "CEDMA Server", Description = "Server to execute CEDMA agents.", AutoRestart=true)]
     29  [ClassInfo(Name = "CEDMA", Description = "Cooperative Evolutionary Data Mining.", AutoRestart=true)]
    3030  class ServerApplication : ApplicationBase {
    3131    public override void Run() {
    3232      Server server = new Server();
    33       server.Start();
    3433      Form mainForm = new Form();
    3534      UserControl serverControl = (UserControl)server.CreateView();
    3635      serverControl.Dock = DockStyle.Fill;
    3736      mainForm.Controls.Add(serverControl);
    38       mainForm.Name = "CEDMA Server";
     37      mainForm.Name = "CEDMA";
    3938      Application.Run(mainForm);
    4039    }
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerView.cs

    r2094 r2223  
    3232using HeuristicLab.PluginInfrastructure;
    3333using System.Net;
    34 using HeuristicLab.CEDMA.DB;
    35 using HeuristicLab.CEDMA.DB.Interfaces;
    3634using System.Data.Common;
    3735using System.Threading;
     
    4745      this.server = server;
    4846      InitializeComponent();
    49       addressTextBox.Text = server.CedmaServiceUrl;
    5047    }
    5148
     
    5855      dispatcherControl.Dock = DockStyle.Fill;
    5956      dispatcherTabPage.Controls.Add(dispatcherControl);
     57      UserControl problemControl = (UserControl)server.Problem.CreateView();
     58      problemControl.Dock = DockStyle.Fill;
     59      problemPage.Controls.Add(problemControl);
    6060      connectButton.Enabled = false;     
    6161    }
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerView.designer.cs

    r2094 r2223  
    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}
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/SimpleDispatcher.cs

    r2222 r2223  
    2727using System.Net;
    2828using System.ServiceModel;
    29 using HeuristicLab.CEDMA.DB.Interfaces;
    30 using HeuristicLab.CEDMA.DB;
    3129using System.ServiceModel.Description;
    3230using System.Linq;
     
    3533using HeuristicLab.Core;
    3634using HeuristicLab.Modeling;
     35using HeuristicLab.Modeling.Database;
    3736
    3837namespace HeuristicLab.CEDMA.Server {
     
    4443    }
    4544
    46     private Random random;
    47     private IStore store;
     45    private Random random;   
    4846    private Dictionary<int, List<AlgorithmConfiguration>> finishedAndDispatchedRuns;
    4947
    50     public SimpleDispatcher(IStore store)
    51       : base(store) {
    52       this.store = store;
     48    public SimpleDispatcher(IModelingDatabase database, Problem problem)
     49      : base(database, problem) {     
    5350      random = new Random();
    5451      finishedAndDispatchedRuns = new Dictionary<int, List<AlgorithmConfiguration>>();
     
    5653    }
    5754
    58     public override IAlgorithm SelectAndConfigureAlgorithm(int targetVariable, int[] inputVariables, Problem problem) {
     55    public override HeuristicLab.Modeling.IAlgorithm SelectAndConfigureAlgorithm(int targetVariable, int[] inputVariables, Problem problem) {
    5956      DiscoveryService ds = new DiscoveryService();
    60       IAlgorithm[] algos = ds.GetInstances<IAlgorithm>();
    61       IAlgorithm selectedAlgorithm = null;
     57      HeuristicLab.Modeling.IAlgorithm[] algos = ds.GetInstances<HeuristicLab.Modeling.IAlgorithm>();
     58      HeuristicLab.Modeling.IAlgorithm selectedAlgorithm = null;
    6259      switch (problem.LearningTask) {
    6360        case LearningTask.Regression: {
     
    8683    }
    8784
    88     private IAlgorithm ChooseDeterministic(int targetVariable, int[] inputVariables, IEnumerable<IAlgorithm> algos) {
     85    private HeuristicLab.Modeling.IAlgorithm ChooseDeterministic(int targetVariable, int[] inputVariables, IEnumerable<HeuristicLab.Modeling.IAlgorithm> algos) {
    8986      var deterministicAlgos = algos
    9087        .Where(a => (a as IStochasticAlgorithm) == null)
     
    9592    }
    9693
    97     private IAlgorithm ChooseStochastic(IEnumerable<IAlgorithm> regressionAlgos) {
     94    private HeuristicLab.Modeling.IAlgorithm ChooseStochastic(IEnumerable<HeuristicLab.Modeling.IAlgorithm> regressionAlgos) {
    9895      var stochasticAlgos = regressionAlgos.Where(a => (a as IStochasticAlgorithm) != null);
    9996      if (stochasticAlgos.Count() == 0) return null;
     
    10299
    103100    private void PopulateFinishedRuns() {
    104       Dictionary<Entity, Entity> processedModels = new Dictionary<Entity, Entity>();
    105       var datasetBindings = store
    106         .Query(
    107         "?Dataset <" + Ontology.InstanceOf + "> <" + Ontology.TypeDataSet + "> .", 0, 1)
    108         .Select(x => (Entity)x.Get("Dataset"));
    109 
    110       if (datasetBindings.Count() > 0) {
    111         var datasetEntity = datasetBindings.ElementAt(0);
    112 
    113         DataSet ds = new DataSet(store, datasetEntity);
    114         var result = store
    115           .Query(
    116           "?Model <" + Ontology.TargetVariable + "> ?TargetVariable ." + Environment.NewLine +
    117           "?Model <" + Ontology.Name + "> ?AlgoName .",
    118           0, 1000)
    119           .Select(x => new Resource[] { (Literal)x.Get("TargetVariable"), (Literal)x.Get("AlgoName"), (Entity)x.Get("Model") });
    120 
    121         foreach (Resource[] row in result) {
    122           Entity model = ((Entity)row[2]);
    123           if (!processedModels.ContainsKey(model)) {
    124             processedModels.Add(model, model);
    125 
    126             string targetVariable = (string)((Literal)row[0]).Value;
    127             string algoName = (string)((Literal)row[1]).Value;
    128             int targetVariableIndex = ds.Problem.Dataset.GetVariableIndex(targetVariable);
    129 
    130             var inputVariableLiterals = store
    131               .Query(
    132                 "<" + model.Uri + "> <" + Ontology.HasInputVariable + "> ?InputVariable ." + Environment.NewLine +
    133                 "?InputVariable <" + Ontology.Name + "> ?Name .",
    134                 0, 1000)
    135               .Select(x => (Literal)x.Get("Name"))
    136               .Select(l => (string)l.Value)
    137               .Distinct();
    138 
    139             List<int> inputVariables = new List<int>();
    140             foreach (string variableName in inputVariableLiterals) {
    141               int variableIndex = ds.Problem.Dataset.GetVariableIndex(variableName);
    142               inputVariables.Add(variableIndex);
    143             }
    144             if (!AlgorithmFinishedOrDispatched(targetVariableIndex, inputVariables.ToArray(), algoName)) {
    145               AddDispatchedRun(targetVariableIndex, inputVariables.ToArray(), algoName);
    146             }
    147           }
    148         }
    149       }
    150     }
    151 
    152     private void SetProblemParameters(IAlgorithm algo, Problem problem, int targetVariable, int[] inputVariables) {
     101      //Dictionary<Entity, Entity> processedModels = new Dictionary<Entity, Entity>();
     102      //var datasetBindings = store
     103      //  .Query(
     104      //  "?Dataset <" + Ontology.InstanceOf + "> <" + Ontology.TypeDataSet + "> .", 0, 1)
     105      //  .Select(x => (Entity)x.Get("Dataset"));
     106
     107      //if (datasetBindings.Count() > 0) {
     108      //  var datasetEntity = datasetBindings.ElementAt(0);
     109
     110      //  DataSet ds = new DataSet(store, datasetEntity);
     111      //  var result = store
     112      //    .Query(
     113      //    "?Model <" + Ontology.TargetVariable + "> ?TargetVariable ." + Environment.NewLine +
     114      //    "?Model <" + Ontology.Name + "> ?AlgoName .",
     115      //    0, 1000)
     116      //    .Select(x => new Resource[] { (Literal)x.Get("TargetVariable"), (Literal)x.Get("AlgoName"), (Entity)x.Get("Model") });
     117
     118      //  foreach (Resource[] row in result) {
     119      //    Entity model = ((Entity)row[2]);
     120      //    if (!processedModels.ContainsKey(model)) {
     121      //      processedModels.Add(model, model);
     122
     123      //      string targetVariable = (string)((Literal)row[0]).Value;
     124      //      string algoName = (string)((Literal)row[1]).Value;
     125      //      int targetVariableIndex = ds.Problem.Dataset.GetVariableIndex(targetVariable);
     126
     127      //      var inputVariableLiterals = store
     128      //        .Query(
     129      //          "<" + model.Uri + "> <" + Ontology.HasInputVariable + "> ?InputVariable ." + Environment.NewLine +
     130      //          "?InputVariable <" + Ontology.Name + "> ?Name .",
     131      //          0, 1000)
     132      //        .Select(x => (Literal)x.Get("Name"))
     133      //        .Select(l => (string)l.Value)
     134      //        .Distinct();
     135
     136      //      List<int> inputVariables = new List<int>();
     137      //      foreach (string variableName in inputVariableLiterals) {
     138      //        int variableIndex = ds.Problem.Dataset.GetVariableIndex(variableName);
     139      //        inputVariables.Add(variableIndex);
     140      //      }
     141      //      if (!AlgorithmFinishedOrDispatched(targetVariableIndex, inputVariables.ToArray(), algoName)) {
     142      //        AddDispatchedRun(targetVariableIndex, inputVariables.ToArray(), algoName);
     143      //      }
     144      //    }
     145      //  }
     146      //}
     147    }
     148
     149    private void SetProblemParameters(HeuristicLab.Modeling.IAlgorithm algo, Problem problem, int targetVariable, int[] inputVariables) {
    153150      algo.Dataset = problem.Dataset;
    154151      algo.TargetVariable = targetVariable;
Note: See TracChangeset for help on using the changeset viewer.