Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/04/09 19:14:48 (15 years ago)
Author:
gkronber
Message:

Fixed a few bugs introduced with r2000. #656 (CEDMA server should handle only one data set (problem) at a time)

File:
1 edited

Legend:

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

    r2000 r2012  
    4040  public abstract class DispatcherBase : IDispatcher {
    4141    private IStore store;
     42    private DataSet dataset;
     43   
    4244    public DispatcherBase(IStore store) {
    4345      this.store = store;
     
    4547
    4648    public IAlgorithm GetNextJob() {
    47       // find and select a dataset
    48       var dataSetVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("DataSet");
    49       var dataSetQuery = new Statement[] {
    50         new Statement(dataSetVar, Ontology.PredicateInstanceOf, Ontology.TypeDataSet)
    51       };
    52 
    53       Entity[] datasets = store.Query("?DataSet <" + Ontology.PredicateInstanceOf.Uri + "> <" + Ontology.TypeDataSet.Uri + "> .", 0, 100)
    54         .Select(x => (Entity)x.Get("DataSet"))
    55         .ToArray();
    56 
    57       // no datasets => do nothing
    58       if (datasets.Length == 0) return null;
    59 
    60       Entity dataSetEntity = SelectDataSet(datasets);
    61       DataSet dataSet = new DataSet(store, dataSetEntity);
    62 
    63       int targetVariable = SelectTargetVariable(dataSetEntity, dataSet.Problem.AllowedTargetVariables.ToArray());
    64       IAlgorithm selectedAlgorithm = SelectAlgorithm(dataSetEntity, targetVariable, dataSet.Problem.LearningTask);
    65       string targetVariableName = dataSet.Problem.GetVariableName(targetVariable);
     49      if (dataset == null) {
     50        var datasetEntities = store.Query("?DataSet <" + Ontology.PredicateInstanceOf.Uri + "> <" + Ontology.TypeDataSet.Uri + "> .", 0, 1)
     51          .Select(x => (Entity)x.Get("DataSet"));
     52        if (datasetEntities.Count() == 0) return null;
     53        dataset = new DataSet(store, datasetEntities.ElementAt(0));
     54      }
     55      int targetVariable = SelectTargetVariable(dataset.Problem.AllowedTargetVariables.ToArray());
     56      IAlgorithm selectedAlgorithm = SelectAlgorithm(targetVariable, dataset.Problem.LearningTask);
     57      string targetVariableName = dataset.Problem.GetVariableName(targetVariable);
    6658
    6759      if (selectedAlgorithm != null) {
    68         SetProblemParameters(selectedAlgorithm, dataSet.Problem, targetVariable);
     60        SetProblemParameters(selectedAlgorithm, dataset.Problem, targetVariable);
    6961      }
    7062      return selectedAlgorithm;
    7163    }
    7264
    73     public abstract Entity SelectDataSet(Entity[] datasets);
    74     public abstract int SelectTargetVariable(Entity dataSet, int[] targetVariables);
    75     public abstract IAlgorithm SelectAlgorithm(Entity dataSet, int targetVariable, LearningTask learningTask);
     65    public abstract int SelectTargetVariable(int[] targetVariables);
     66    public abstract IAlgorithm SelectAlgorithm(int targetVariable, LearningTask learningTask);
    7667
    7768    private void SetProblemParameters(IAlgorithm algo, Problem problem, int targetVariable) {
Note: See TracChangeset for help on using the changeset viewer.