Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1060


Ignore:
Timestamp:
12/23/08 18:40:38 (15 years ago)
Author:
gkronber
Message:

worked on executer which retrieves the next job from the dispatcher and sends it to the grid for execution. #419 (Refactor CEDMA plugins)

Location:
branches/CEDMA-Refactoring-Ticket419
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ProblemInjector.cs

    r1053 r1060  
    3535    }
    3636
    37     private IntData targetVariable;
     37    private IntData targetVariable = new IntData();
    3838    public int TargetVariable {
    3939      get { return targetVariable.Data; }
    4040      set { targetVariable.Data = value; }
    4141    }
     42
     43    public ProblemInjector() : base() { } // for persistence
     44
    4245    public ProblemInjector(Problem problem)
    4346      : base() {
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/Dispatcher.cs

    r1053 r1060  
    3434using HeuristicLab.GP.StructureIdentification;
    3535using HeuristicLab.Data;
     36using HeuristicLab.Core;
    3637
    3738namespace HeuristicLab.CEDMA.Server {
    3839  public class Dispatcher {
    39     private List<StandardGP> dispatchQueue;
     40    private List<Execution> dispatchQueue;
    4041    public IList<string> DispatchQueue {
    4142      get { return dispatchQueue.Select(t => "StandardGP").ToList(); }
     
    4647    public Dispatcher(IStore store) {
    4748      this.store = store;
    48       this.dispatchQueue = new List<StandardGP>();
     49      this.dispatchQueue = new List<Execution>();
    4950    }
    5051
     
    5253      Dictionary<Entity, Dictionary<int, int>> numberOfModelsOfTargetVariableOfDataSet = new Dictionary<Entity, Dictionary<int, int>>();
    5354      IList<Statement> datasetStatements = store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateInstanceOf, Ontology.TypeDataSet));
    54       foreach(Statement datasetStatement in datasetStatements) {
     55      foreach (Statement datasetStatement in datasetStatements) {
    5556        numberOfModelsOfTargetVariableOfDataSet.Add(datasetStatement.Subject, new Dictionary<int, int>());
    5657        IList<Statement> modelStatements = store.Select(new Statement(datasetStatement.Subject, Ontology.PredicateHasModel, Ontology.AnyEntity));
    57         foreach(Statement modelStatement in modelStatements) {
     58        foreach (Statement modelStatement in modelStatements) {
    5859          IList<Statement> modelAttributeStatements = store.Select(new Statement((Entity)modelStatement.Property, Ontology.PredicateModelAttribute, Ontology.AnyEntity));
    59           foreach(Statement modelAttrStatement in modelAttributeStatements) {
     60          foreach (Statement modelAttrStatement in modelAttributeStatements) {
    6061            var targetVariableStatements = store.Select(new Statement((Entity)modelAttrStatement.Property, Ontology.PredicateModelAttributeName, Ontology.AnyEntity))
    6162               .Where(t => (string)((Literal)t.Property).Value == "TargetVariable")
    6263               .SelectMany(t => store.Select(new Statement((Entity)modelAttrStatement.Property, Ontology.PredicateModelAttributeValue, Ontology.AnyEntity)))
    6364               .GroupBy(t => (int)((Literal)t.Property).Value);
    64             foreach(var targetVariable in targetVariableStatements) {
     65            foreach (var targetVariable in targetVariableStatements) {
    6566              numberOfModelsOfTargetVariableOfDataSet[datasetStatement.Subject].Add(targetVariable.Key, targetVariable.Count());
    6667            }
     
    6869        }
    6970      }
    70       foreach(KeyValuePair<Entity, Dictionary<int, int>> dataSetEntry in numberOfModelsOfTargetVariableOfDataSet) {
     71      foreach (KeyValuePair<Entity, Dictionary<int, int>> dataSetEntry in numberOfModelsOfTargetVariableOfDataSet) {
    7172        DataSet dataSet = new DataSet(store, dataSetEntry.Key);
    72         foreach(int targetVariable in dataSet.Problem.AllowedTargetVariables)
    73           if(!dataSetEntry.Value.ContainsKey(targetVariable) || dataSetEntry.Value[targetVariable] < 10) {
    74             QueueJob(CreateStandardGp(dataSet, targetVariable));
     73        foreach (int targetVariable in dataSet.Problem.AllowedTargetVariables)
     74          if (!dataSetEntry.Value.ContainsKey(targetVariable) || dataSetEntry.Value[targetVariable] < 10) {
     75            IEngine engine = CreateEngine(dataSet.Problem, targetVariable);
     76            if (engine != null) {
     77              QueueJob(new Execution(dataSetEntry.Key, engine, targetVariable));
     78            }
    7579          }
    7680      }
    7781    }
    7882
    79     private StandardGP CreateStandardGp(DataSet dataSet, int targetVariable) {
    80       ProblemInjector probInjector = new ProblemInjector(dataSet.Problem);
     83    private void QueueJob(Execution execution) {
     84      dispatchQueue.Add(execution);
     85    }
     86
     87    public Execution GetNextJob() {
     88      if (dispatchQueue.Count == 0) FillDispatchQueue();
     89      Execution next = dispatchQueue[0];
     90      dispatchQueue.RemoveAt(0);
     91      return next;
     92    }
     93
     94    internal void Start() {
     95      FillDispatchQueue();
     96    }
     97
     98    private IEngine CreateEngine(Problem problem, int targetVariable) {
     99      switch (problem.LearningTask) {
     100        case LearningTask.Classification: return null;
     101        case LearningTask.Regression: {
     102            return CreateStandardGp(problem, targetVariable).Engine;
     103          }
     104        case LearningTask.TimeSeries: return null;
     105        case LearningTask.Clustering: return null;
     106        default: return null;
     107      }
     108    }
     109
     110    private StandardGP CreateStandardGp(Problem problem, int targetVariable) {
     111      ProblemInjector probInjector = new ProblemInjector(problem);
    81112      probInjector.TargetVariable = targetVariable;
    82113      StandardGP sgp = new StandardGP();
     
    88119      return sgp;
    89120    }
    90 
    91     private void QueueJob(StandardGP job) {
    92       dispatchQueue.Add(job);
    93     }
    94 
    95     private StandardGP GetNextJob() {
    96       if(dispatchQueue.Count == 0) FillDispatchQueue();
    97       StandardGP next = dispatchQueue[0];
    98       dispatchQueue.RemoveAt(0);
    99       return next;
    100     }
    101 
    102     internal void Start() {
    103       FillDispatchQueue();
    104     }
    105121  }
    106122}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/HeuristicLab.CEDMA.Server.csproj

    r1053 r1060  
    7575  </ItemGroup>
    7676  <ItemGroup>
     77    <Compile Include="Execution.cs" />
     78    <Compile Include="Executer.cs" />
    7779    <Compile Include="Dispatcher.cs" />
    7880    <Compile Include="Server.cs" />
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/Server.cs

    r1044 r1060  
    5151
    5252    public Server(IStore store) {
    53       // windows XP returns the external ip on index 0 while windows vista returns the external ip on index 2
     53      IPAddress[] addresses = Dns.GetHostAddresses(Dns.GetHostName());
     54      // windows XP returns the external ip on index 0 while windows vista returns the external ip as one of the last entries
     55      // also if IPv6 protocol is installed we want to find an entry that is IPv4
     56      int index = 0;
    5457      if (System.Environment.OSVersion.Version.Major >= 6) {
    55         cedmaServiceUrl = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[2] + ":8002/CEDMA/World";
    56       } else {
    57         cedmaServiceUrl = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[0] + ":8002/CEDMA/World";
     58        for (index = addresses.Length - 1; index >= 0; index--)
     59          if (addresses[index].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
     60            break;
    5861      }
     62      cedmaServiceUrl = "net.tcp://" + addresses[index] + ":8002/CEDMA";
    5963      this.store = store;
    6064    }
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/ServerForm.cs

    r1044 r1060  
    4545    private Store store;
    4646    private Dispatcher dispatcher;
     47    private Executer executer;
    4748
    4849    private static readonly string rdfFile = AppDomain.CurrentDomain.BaseDirectory + "rdf_store.db3";
     
    6465
    6566    private void connectButton_Click(object sender, EventArgs e) {
    66       // new GridExecutor(dispatcher)
     67      executer = new Executer(dispatcher, store, gridAddress.Text);
     68      executer.Start();
     69      connectButton.Enabled = false;
    6770    }
    6871  }
Note: See TracChangeset for help on using the changeset viewer.