- Timestamp:
- 05/26/09 13:37:27 (15 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Server/3.3/GridExecuter.cs
r1894 r1898 40 40 41 41 namespace HeuristicLab.CEDMA.Server { 42 public class Executer { 43 private IDispatcher dispatcher; 42 public class GridExecuter : ExecuterBase { 44 43 private JobManager jobManager; 45 private IStore store;46 44 private Dictionary<WaitHandle, Execution> activeExecutions; 47 45 … … 54 52 } 55 53 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) { 70 55 this.jobManager = new JobManager(gridUrl); 71 56 jobManager.Reset(); 72 57 } 73 58 74 internal void Start() { 75 new Thread(StartJobs).Start(); 76 } 77 78 private void StartJobs() { 59 protected override void StartJobs() { 79 60 List<WaitHandle> wh = new List<WaitHandle>(); 80 61 Dictionary<WaitHandle, AtomicOperation> activeOperations = new Dictionary<WaitHandle, AtomicOperation>(); … … 85 66 Thread.Sleep(StartJobInterval); 86 67 // get an execution from the dispatcher and execute in grid via job-manager 87 Execution execution = dispatcher.GetNextJob();68 Execution execution = Dispatcher.GetNextJob(); 88 69 if (execution != null) { 89 70 AtomicOperation op = new AtomicOperation(execution.Engine.OperatorGraph.InitialOperator, execution.Engine.GlobalScope); … … 109 90 } 110 91 activeOperations.Remove(readyHandle); 92 readyHandle.Close(); 111 93 ProcessingEngine finishedEngine = null; 112 94 try { … … 127 109 } 128 110 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() { 174 112 lock (activeExecutions) { 175 113 string[] retVal = new string[activeExecutions.Count];
Note: See TracChangeset
for help on using the changeset viewer.