Changeset 1898
- Timestamp:
- 05/26/09 13:37:27 (16 years ago)
- 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 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]; -
trunk/sources/HeuristicLab.CEDMA.Server/3.3/HeuristicLab.CEDMA.Server-3.3.csproj
r1873 r1898 91 91 </ItemGroup> 92 92 <ItemGroup> 93 <Compile Include="ExecuterBase.cs" /> 94 <Compile Include="HiveExecuter.cs"> 95 <SubType>Code</SubType> 96 </Compile> 97 <Compile Include="IExecuter.cs" /> 93 98 <Compile Include="DispatcherBase.cs" /> 99 <Compile Include="GridExecuter.cs" /> 94 100 <Compile Include="IDispatcher.cs" /> 95 101 <Compile Include="Execution.cs" /> 96 <Compile Include="Executer.cs" />97 102 <Compile Include="Server.cs" /> 98 103 <Compile Include="ServerApplication.cs" /> … … 136 141 <Name>HeuristicLab.Grid-3.2</Name> 137 142 </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> 138 147 <ProjectReference Include="..\..\HeuristicLab.Modeling\3.2\HeuristicLab.Modeling-3.2.csproj"> 139 148 <Project>{80F7FADA-549D-4151-8856-79B620A50DBA}</Project> -
trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerForm.cs
r1873 r1898 45 45 private Store store; 46 46 private IDispatcher dispatcher; 47 private Executer executer;47 private IExecuter executer; 48 48 49 49 private static readonly string rdfFile = AppDomain.CurrentDomain.BaseDirectory + "rdf_store.db3"; … … 64 64 private void connectButton_Click(object sender, EventArgs e) { 65 65 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 } 67 72 executer.Start(); 68 73 maxActiveJobsUpDown.Enabled = true; -
trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerForm.designer.cs
r1529 r1898 49 49 this.externalAddressLabel = new System.Windows.Forms.Label(); 50 50 this.gridAddressLabel = new System.Windows.Forms.Label(); 51 this. gridAddress = new System.Windows.Forms.TextBox();51 this.address = new System.Windows.Forms.TextBox(); 52 52 this.connectButton = new System.Windows.Forms.Button(); 53 53 this.listBox = new System.Windows.Forms.ListBox(); … … 86 86 // gridAddress 87 87 // 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; 92 92 // 93 93 // connectButton … … 151 151 this.Controls.Add(this.connectButton); 152 152 this.Controls.Add(this.gridAddressLabel); 153 this.Controls.Add(this. gridAddress);153 this.Controls.Add(this.address); 154 154 this.Controls.Add(this.externalAddressLabel); 155 155 this.Controls.Add(this.addressTextBox); … … 167 167 private System.Windows.Forms.Label externalAddressLabel; 168 168 private System.Windows.Forms.Label gridAddressLabel; 169 private System.Windows.Forms.TextBox gridAddress;169 private System.Windows.Forms.TextBox address; 170 170 private System.Windows.Forms.Button connectButton; 171 171 private System.Windows.Forms.ListBox listBox;
Note: See TracChangeset
for help on using the changeset viewer.