Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/26/09 13:37:27 (15 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)

File:
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];
Note: See TracChangeset for help on using the changeset viewer.