Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1898


Ignore:
Timestamp:
05/26/09 13:37:27 (16 years ago)
Author:
gkronber
Message:

Implemented and integrated first version of backend for execution of CEDMA runs on HL.Hive. #642 (Hive backend for CEDMA)

Location:
trunk/sources/HeuristicLab.CEDMA.Server/3.3
Files:
3 added
3 edited
1 moved

Legend:

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

    r1894 r1898  
    4040
    4141namespace HeuristicLab.CEDMA.Server {
    42   public class Executer {
    43     private IDispatcher dispatcher;
     42  public class GridExecuter : ExecuterBase {
    4443    private JobManager jobManager;
    45     private IStore store;
    4644    private Dictionary<WaitHandle, Execution> activeExecutions;
    4745
     
    5452    }
    5553
    56     private int maxActiveJobs;
    57     public int MaxActiveJobs {
    58       get { return maxActiveJobs; }
    59       set {
    60         if (value < 0) throw new ArgumentException("Only positive values are allowed for MaxActiveJobs");
    61         maxActiveJobs = value;
    62       }
    63     }
    64 
    65     public Executer(IDispatcher dispatcher, IStore store, string gridUrl) {
    66       activeExecutions = new Dictionary<WaitHandle, Execution>();
    67       maxActiveJobs = 10;
    68       this.dispatcher = dispatcher;
    69       this.store = store;
     54    public GridExecuter(IDispatcher dispatcher, IStore store, string gridUrl) : base(dispatcher, store) {
    7055      this.jobManager = new JobManager(gridUrl);
    7156      jobManager.Reset();
    7257    }
    7358
    74     internal void Start() {
    75       new Thread(StartJobs).Start();
    76     }
    77 
    78     private void StartJobs() {
     59    protected override void StartJobs() {
    7960      List<WaitHandle> wh = new List<WaitHandle>();
    8061      Dictionary<WaitHandle, AtomicOperation> activeOperations = new Dictionary<WaitHandle, AtomicOperation>();
     
    8566            Thread.Sleep(StartJobInterval);
    8667            // get an execution from the dispatcher and execute in grid via job-manager
    87             Execution execution = dispatcher.GetNextJob();
     68            Execution execution = Dispatcher.GetNextJob();
    8869            if (execution != null) {
    8970              AtomicOperation op = new AtomicOperation(execution.Engine.OperatorGraph.InitialOperator, execution.Engine.GlobalScope);
     
    10990            }
    11091            activeOperations.Remove(readyHandle);
     92            readyHandle.Close();
    11193            ProcessingEngine finishedEngine = null;
    11294            try {
     
    127109    }
    128110
    129     private void StoreResults(Execution finishedExecution, ProcessingEngine finishedEngine) {
    130       Entity model = new Entity(Ontology.CedmaNameSpace + Guid.NewGuid());
    131       store.Add(new Statement(finishedExecution.DataSetEntity, Ontology.PredicateHasModel, model));
    132       StoreModelAttribute(model, Ontology.TargetVariable, finishedExecution.TargetVariable);
    133       StoreModelAttribute(model, Ontology.AlgorithmName, finishedExecution.Description);
    134       Scope bestModelScope = finishedEngine.GlobalScope.GetVariableValue<Scope>("BestValidationSolution", false);
    135       StoreModelVariable(model, Ontology.TrainingMeanSquaredError, bestModelScope, "Quality");
    136       StoreModelVariable(model, Ontology.ValidationMeanSquaredError, bestModelScope, "ValidationQuality");
    137       StoreModelVariable(model, Ontology.TestMeanSquaredError, bestModelScope, "TestQuality");
    138       StoreModelVariable(model, Ontology.TrainingMeanAbsolutePercentageError, bestModelScope, "TrainingMAPE");
    139       StoreModelVariable(model, Ontology.ValidationMeanAbsolutePercentageError, bestModelScope, "ValidationMAPE");
    140       StoreModelVariable(model, Ontology.TestMeanAbsolutePercentageError, bestModelScope, "TestMAPE");
    141       StoreModelVariable(model, Ontology.TrainingMeanAbsolutePercentageOfRangeError, bestModelScope, "TrainingMAPRE");
    142       StoreModelVariable(model, Ontology.ValidationMeanAbsolutePercentageOfRangeError, bestModelScope, "ValidationMAPRE");
    143       StoreModelVariable(model, Ontology.TestMeanAbsolutePercentageOfRangeError, bestModelScope, "TestMAPRE");
    144       StoreModelVariable(model, Ontology.TrainingCoefficientOfDetermination, bestModelScope, "TrainingR2");
    145       StoreModelVariable(model, Ontology.ValidationCoefficientOfDetermination, bestModelScope, "ValidationR2");
    146       StoreModelVariable(model, Ontology.TestCoefficientOfDetermination, bestModelScope, "TestR2");
    147       StoreModelVariable(model, Ontology.TrainingCoefficientOfDetermination, bestModelScope, "TrainingVAF");
    148       StoreModelVariable(model, Ontology.ValidationCoefficientOfDetermination, bestModelScope, "ValidationVAF");
    149       StoreModelVariable(model, Ontology.TestCoefficientOfDetermination, bestModelScope, "TestVAF");
    150       StoreModelVariable(model, Ontology.TrainingTheilsInequalityCoefficient, bestModelScope, "TrainingTheilInequalityCoefficient");
    151       StoreModelVariable(model, Ontology.ValidationTheilsInequalityCoefficient, bestModelScope, "ValidationTheilInequalityCoefficient");
    152       StoreModelVariable(model, Ontology.TestTheilsInequalityCoefficient, bestModelScope, "TestTheilInequalityCoefficient");
    153       StoreModelVariable(model, Ontology.TrainingAccuracy, bestModelScope, "TrainingAccuracy");
    154       StoreModelVariable(model, Ontology.ValidationAccuracy, bestModelScope, "ValidationAccuracy");
    155       StoreModelVariable(model, Ontology.TestAccuracy, bestModelScope, "TestAccuracy");
    156       StoreModelVariable(model, Ontology.TreeSize, bestModelScope, "TreeSize");
    157       StoreModelVariable(model, Ontology.TreeHeight, bestModelScope, "TreeHeight");
    158       StoreModelVariable(model, Ontology.EvaluatedSolutions, bestModelScope, "EvaluatedSolutions");
    159 
    160       byte[] serializedModel = PersistenceManager.SaveToGZip(bestModelScope.GetVariableValue("FunctionTree", false));
    161       store.Add(new Statement(model, Ontology.PredicateSerializedData, new Literal(Convert.ToBase64String(serializedModel))));
    162     }
    163 
    164     private void StoreModelVariable(Entity model, Entity entity, Scope scope, string variableName) {
    165       if (scope.GetVariable(variableName) != null)
    166         StoreModelAttribute(model, entity, scope.GetVariableValue<ObjectData>(variableName, false).Data);
    167     }
    168 
    169     private void StoreModelAttribute(Entity model, Entity predicate, object value) {
    170       store.Add(new Statement(model, predicate, new Literal(value)));
    171     }
    172 
    173     internal string[] GetJobs() {
     111    public override string[] GetJobs() {
    174112      lock (activeExecutions) {
    175113        string[] retVal = new string[activeExecutions.Count];
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/HeuristicLab.CEDMA.Server-3.3.csproj

    r1873 r1898  
    9191  </ItemGroup>
    9292  <ItemGroup>
     93    <Compile Include="ExecuterBase.cs" />
     94    <Compile Include="HiveExecuter.cs">
     95      <SubType>Code</SubType>
     96    </Compile>
     97    <Compile Include="IExecuter.cs" />
    9398    <Compile Include="DispatcherBase.cs" />
     99    <Compile Include="GridExecuter.cs" />
    94100    <Compile Include="IDispatcher.cs" />
    95101    <Compile Include="Execution.cs" />
    96     <Compile Include="Executer.cs" />
    97102    <Compile Include="Server.cs" />
    98103    <Compile Include="ServerApplication.cs" />
     
    136141      <Name>HeuristicLab.Grid-3.2</Name>
    137142    </ProjectReference>
     143    <ProjectReference Include="..\..\HeuristicLab.Hive.Engine\3.2\HeuristicLab.Hive.Engine-3.2.csproj">
     144      <Project>{C8FEDAC1-0326-4293-B585-F0FEDDEDFC11}</Project>
     145      <Name>HeuristicLab.Hive.Engine-3.2</Name>
     146    </ProjectReference>
    138147    <ProjectReference Include="..\..\HeuristicLab.Modeling\3.2\HeuristicLab.Modeling-3.2.csproj">
    139148      <Project>{80F7FADA-549D-4151-8856-79B620A50DBA}</Project>
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerForm.cs

    r1873 r1898  
    4545    private Store store;
    4646    private IDispatcher dispatcher;
    47     private Executer executer;
     47    private IExecuter executer;
    4848
    4949    private static readonly string rdfFile = AppDomain.CurrentDomain.BaseDirectory + "rdf_store.db3";
     
    6464    private void connectButton_Click(object sender, EventArgs e) {
    6565      dispatcher = new SimpleDispatcher(store);
    66       executer = new Executer(dispatcher, store, gridAddress.Text);
     66      if (address.Text.Contains("ExecutionEngine")) {
     67        executer = new HiveExecuter(dispatcher, store, address.Text);
     68      } else {
     69        // default is grid backend
     70        executer = new GridExecuter(dispatcher, store, address.Text);
     71      }
    6772      executer.Start();
    6873      maxActiveJobsUpDown.Enabled = true;
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerForm.designer.cs

    r1529 r1898  
    4949      this.externalAddressLabel = new System.Windows.Forms.Label();
    5050      this.gridAddressLabel = new System.Windows.Forms.Label();
    51       this.gridAddress = new System.Windows.Forms.TextBox();
     51      this.address = new System.Windows.Forms.TextBox();
    5252      this.connectButton = new System.Windows.Forms.Button();
    5353      this.listBox = new System.Windows.Forms.ListBox();
     
    8686      // gridAddress
    8787      //
    88       this.gridAddress.Location = new System.Drawing.Point(106, 32);
    89       this.gridAddress.Name = "gridAddress";
    90       this.gridAddress.Size = new System.Drawing.Size(160, 20);
    91       this.gridAddress.TabIndex = 8;
     88      this.address.Location = new System.Drawing.Point(106, 32);
     89      this.address.Name = "gridAddress";
     90      this.address.Size = new System.Drawing.Size(160, 20);
     91      this.address.TabIndex = 8;
    9292      //
    9393      // connectButton
     
    151151      this.Controls.Add(this.connectButton);
    152152      this.Controls.Add(this.gridAddressLabel);
    153       this.Controls.Add(this.gridAddress);
     153      this.Controls.Add(this.address);
    154154      this.Controls.Add(this.externalAddressLabel);
    155155      this.Controls.Add(this.addressTextBox);
     
    167167    private System.Windows.Forms.Label externalAddressLabel;
    168168    private System.Windows.Forms.Label gridAddressLabel;
    169     private System.Windows.Forms.TextBox gridAddress;
     169    private System.Windows.Forms.TextBox address;
    170170    private System.Windows.Forms.Button connectButton;
    171171    private System.Windows.Forms.ListBox listBox;
Note: See TracChangeset for help on using the changeset viewer.