Changeset 7566 for branches/MPI
- Timestamp:
- 03/06/12 16:11:36 (13 years ago)
- Location:
- branches/MPI
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MPI/HeuristicLab.MPIAlgorithmRunner/3.3/HeuristicLab.MPIAlgorithmRunner-3.3.csproj
r7205 r7566 115 115 <Private>False</Private> 116 116 </Reference> 117 <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 117 118 <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 118 119 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath> -
branches/MPI/HeuristicLab.MPIAlgorithmRunner/3.3/Program.cs
r7544 r7566 33 33 using HeuristicLab.Core; 34 34 using System.Diagnostics; 35 using HeuristicLab.Common; 36 using System.IO; 35 37 36 38 namespace HeuristicLab.MPIAlgorithmRunner { … … 41 43 if (args.Length == 2) { 42 44 string fileName = args[0]; 43 string resultName = args[1]; 44 45 using (new MPI.Environment(ref args)) { 46 if (MPI.Communicator.world.Rank != 0) { 47 Program p = new Program(); 48 p.StartAlgorithm(fileName, resultName + MPI.Communicator.world.Rank + ".hl"); 45 int calcTime; 46 if (int.TryParse(args[1], out calcTime)) { 47 using (new MPI.Environment(ref args)) { 48 if (MPI.Communicator.world.Rank != 0) { 49 Program p = new Program(); 50 p.StartAlgorithm(fileName,calcTime); 51 } 52 } 53 } else { 54 string resultName = args[1]; 55 56 using (new MPI.Environment(ref args)) { 57 if (MPI.Communicator.world.Rank != 0) { 58 Program p = new Program(); 59 p.StartAlgorithm(fileName, resultName + MPI.Communicator.world.Rank + ".hl"); 60 } 49 61 } 50 } 62 } 51 63 } else { 52 64 using (new MPI.Environment(ref args)) { … … 192 204 sw.Start(); 193 205 194 /* Thread.Sleep(10000); 195 Thread t = new Thread(delegate() { 196 while (true) { 197 if (alg.ExecutionState == Core.ExecutionState.Started) { 198 alg.Pause(); 199 200 while (alg.ExecutionState == Core.ExecutionState.Started) 201 Thread.Sleep(100); 202 203 if (alg.Results.ContainsKey("Best valid Solution Distance")) { 204 Console.WriteLine("BestDistance: " + alg.Results["Best valid Solution Distance"].Value.ToString()); 205 } 206 207 if (alg.Results.ContainsKey("Best valid Solution Vehicles")) { 208 Console.WriteLine("BestVehicles: " + alg.Results["Best valid Solution Vehicles"].Value.ToString()); 209 } 210 211 XmlGenerator.Serialize(alg, resultName); 212 alg.Start(); 206 if (MPI.Communicator.world.Rank == 1) { 207 Thread.Sleep(10000); 208 Thread t = new Thread(delegate() { 209 while (true) { 210 if (alg.ExecutionState == Core.ExecutionState.Started) { 211 alg.Pause(); 212 213 while (alg.ExecutionState == Core.ExecutionState.Started) 214 Thread.Sleep(100); 215 216 if (alg.Results.ContainsKey("Best valid VRP Solution Distance")) { 217 Console.WriteLine("BestDistance: " + alg.Results["Best valid VRP Solution Distance"].Value.ToString()); 218 } 219 220 if (alg.Results.ContainsKey("Best valid VRP Solution VehicleUtilization")) { 221 Console.WriteLine("BestVehicles: " + alg.Results["Best valid VRP Solution VehicleUtilization"].Value.ToString()); 222 } 223 224 XmlGenerator.Serialize(alg, resultName); 225 alg.Start(); 226 } 227 228 Thread.Sleep(300000); 213 229 } 214 215 Thread.Sleep(300000); 216 } 217 }); 218 t.IsBackground = true; 219 t.Start();*/ 230 }); 231 t.IsBackground = true; 232 t.Start(); 233 } 220 234 221 235 waitHandle.WaitOne(); … … 225 239 Console.WriteLine("TIME: " + sw.ElapsedMilliseconds + "ms"); 226 240 227 if (alg.Results.ContainsKey("Best valid Solution Distance") && alg.Results.ContainsKey("Best valid Solution Vehicles")) {228 Console.WriteLine("BestDistance: " + alg.Results["Best valid Solution Distance"].Value.ToString() + ", " +229 "BestVehicles: " + alg.Results["Best valid Solution Vehicles"].Value.ToString());241 if (alg.Results.ContainsKey("Best valid VRP Solution Distance") && alg.Results.ContainsKey("Best valid VRP Solution VehicleUtilization")) { 242 Console.WriteLine("BestDistance: " + alg.Results["Best valid VRP Solution Distance"].Value.ToString() + ", " + 243 "BestVehicles: " + alg.Results["Best valid VRP Solution VehicleUtilization"].Value.ToString()); 230 244 } 231 245 … … 236 250 waitHandle.Set(); 237 251 } 252 253 public void StartAlgorithm(string fileName, int calculationTime) { 254 IAlgorithm alg = XmlParser.Deserialize<HeuristicLab.Optimization.IAlgorithm>(fileName); 255 IOperator breakpoint = ((alg.Parameters["Analyzer"] as IValueParameter).Value as IOperator); 256 257 waitHandle.Reset(); 258 259 alg.Start(); 260 261 Thread.Sleep(calculationTime); 262 263 if (alg.ExecutionState == ExecutionState.Started) { 264 waitHandle.Reset(); 265 alg.Paused += new EventHandler(alg_Paused); 266 breakpoint.Breakpoint = true; 267 268 waitHandle.WaitOne(); 269 270 breakpoint.Breakpoint = false; 271 alg.Paused -= new EventHandler(alg_Paused); 272 } 273 274 Mutex mutex = new Mutex(false, "ResultFile"); 275 mutex.WaitOne(); 276 Console.WriteLine("SERIALIZING"); 277 XmlGenerator.Serialize(alg, fileName); 278 MPI.Communicator.world.Abort(0); 279 } 280 281 void alg_Paused(object sender, EventArgs e) { 282 waitHandle.Set(); 283 } 238 284 } 239 285 } -
branches/MPI/HeuristicLab.MPIEngine/3.3/Plugin.cs.frame
r7205 r7566 38 38 [PluginDependency("HeuristicLab.MainForm", "3.3")] 39 39 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")] 40 [PluginDependency("HeuristicLab.MPInet", "1.0.0")]41 [PluginDependency("HeuristicLab.MPIAlgorithmRunner", "3.3")]42 40 [PluginDependency("HeuristicLab.Operators.MPISupport", "3.3")] 43 41 [PluginDependency("HeuristicLab.Optimization", "3.3")] -
branches/MPI/HeuristicLab.Operators.MPISupport/3.3/MPIHelper.cs
r7544 r7566 27 27 } 28 28 29 public static void Execute(IAtomicOperation op , CancellationToken cancellationToken) {29 public static void Execute(IAtomicOperation op) { 30 30 IOperation next; 31 31 OperationCollection coll; … … 36 36 37 37 while (executionStack.Count > 0) { 38 cancellationToken.ThrowIfCancellationRequested();39 40 38 next = executionStack.Pop(); 41 39 if (next is OperationCollection) { … … 46 44 operation = (IAtomicOperation)next; 47 45 try { 48 next = operation.Operator.Execute((IExecutionContext)operation, cancellationToken);46 next = operation.Operator.Execute((IExecutionContext)operation, new CancellationToken()); 49 47 } 50 48 catch (Exception ex) { -
branches/MPI/HeuristicLab.Operators.MPISupport/3.3/MPISolutionsCreator.cs
r7544 r7566 29 29 using System.Collections.Generic; 30 30 using MPI; 31 using System; 31 32 32 33 namespace HeuristicLab.Operators.MPISupport { … … 103 104 if (creator != null) { 104 105 IAtomicOperation op = ExecutionContext.CreateOperation(creator, scopes[i]); 105 MPIHelper.Execute(op , CancellationToken);106 MPIHelper.Execute(op); 106 107 } 107 108 108 109 if (evaluator != null) { 109 110 IAtomicOperation op = ExecutionContext.CreateOperation(evaluator, scopes[i]); 110 MPIHelper.Execute(op , CancellationToken);111 MPIHelper.Execute(op); 111 112 } 112 113 -
branches/MPI/HeuristicLab.Operators.MPISupport/3.3/MPIUniformSubscopesProcessor.cs
r7544 r7566 64 64 for (int i = start; i < end; i++) { 65 65 IAtomicOperation op = ExecutionContext.CreateOperation(Operator, scopes[i]); 66 MPIHelper.Execute(op , CancellationToken);66 MPIHelper.Execute(op); 67 67 68 68 //SEND results to other clients -
branches/MPI/HeuristicLab.Operators.MPISupport/3.3/Plugin.cs.frame
r7544 r7566 28 28 [Plugin("HeuristicLab.Operators.MPISupport", "3.3.4.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Operators.MPISupport-3.3.dll", PluginFileType.Assembly)] 30 [PluginDependency("HeuristicLab.MPInet", "1.0.0")]31 30 [PluginDependency("HeuristicLab.Core", "3.3")] 32 31 [PluginDependency("HeuristicLab.Common", "3.3")]
Note: See TracChangeset
for help on using the changeset viewer.