- Timestamp:
- 06/04/09 19:14:48 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherBase.cs
r2000 r2012 40 40 public abstract class DispatcherBase : IDispatcher { 41 41 private IStore store; 42 private DataSet dataset; 43 42 44 public DispatcherBase(IStore store) { 43 45 this.store = store; … … 45 47 46 48 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); 66 58 67 59 if (selectedAlgorithm != null) { 68 SetProblemParameters(selectedAlgorithm, data Set.Problem, targetVariable);60 SetProblemParameters(selectedAlgorithm, dataset.Problem, targetVariable); 69 61 } 70 62 return selectedAlgorithm; 71 63 } 72 64 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); 76 67 77 68 private void SetProblemParameters(IAlgorithm algo, Problem problem, int targetVariable) {
Note: See TracChangeset
for help on using the changeset viewer.