Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7566 for branches/MPI


Ignore:
Timestamp:
03/06/12 16:11:36 (13 years ago)
Author:
svonolfe
Message:

Adapted MPI operators (#1542)

Location:
branches/MPI
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/MPI/HeuristicLab.MPIAlgorithmRunner/3.3/HeuristicLab.MPIAlgorithmRunner-3.3.csproj

    r7205 r7566  
    115115      <Private>False</Private>
    116116    </Reference>
     117    <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    117118    <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    118119      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
  • branches/MPI/HeuristicLab.MPIAlgorithmRunner/3.3/Program.cs

    r7544 r7566  
    3333using HeuristicLab.Core;
    3434using System.Diagnostics;
     35using HeuristicLab.Common;
     36using System.IO;
    3537
    3638namespace HeuristicLab.MPIAlgorithmRunner {
     
    4143      if (args.Length == 2) {
    4244        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            }
    4961          }
    50         }
     62        }       
    5163      } else {
    5264        using (new MPI.Environment(ref args)) {
     
    192204      sw.Start();
    193205
    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);
    213229          }
    214 
    215           Thread.Sleep(300000);
    216         }
    217       });
    218       t.IsBackground = true;
    219       t.Start();*/
     230        });
     231        t.IsBackground = true;
     232        t.Start();
     233      }
    220234
    221235      waitHandle.WaitOne();
     
    225239      Console.WriteLine("TIME: " + sw.ElapsedMilliseconds + "ms");
    226240
    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());
    230244      }
    231245
     
    236250      waitHandle.Set();
    237251    }
     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    }
    238284  }
    239285}
  • branches/MPI/HeuristicLab.MPIEngine/3.3/Plugin.cs.frame

    r7205 r7566  
    3838  [PluginDependency("HeuristicLab.MainForm", "3.3")]
    3939  [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
    40   [PluginDependency("HeuristicLab.MPInet", "1.0.0")]
    41   [PluginDependency("HeuristicLab.MPIAlgorithmRunner", "3.3")]
    4240  [PluginDependency("HeuristicLab.Operators.MPISupport", "3.3")]
    4341  [PluginDependency("HeuristicLab.Optimization", "3.3")]
  • branches/MPI/HeuristicLab.Operators.MPISupport/3.3/MPIHelper.cs

    r7544 r7566  
    2727    }
    2828
    29     public static void Execute(IAtomicOperation op, CancellationToken cancellationToken) {
     29    public static void Execute(IAtomicOperation op) {
    3030      IOperation next;
    3131      OperationCollection coll;
     
    3636
    3737      while (executionStack.Count > 0) {
    38         cancellationToken.ThrowIfCancellationRequested();
    39 
    4038        next = executionStack.Pop();
    4139        if (next is OperationCollection) {
     
    4644          operation = (IAtomicOperation)next;
    4745          try {
    48             next = operation.Operator.Execute((IExecutionContext)operation, cancellationToken);
     46            next = operation.Operator.Execute((IExecutionContext)operation, new CancellationToken());
    4947          }
    5048          catch (Exception ex) {
  • branches/MPI/HeuristicLab.Operators.MPISupport/3.3/MPISolutionsCreator.cs

    r7544 r7566  
    2929using System.Collections.Generic;
    3030using MPI;
     31using System;
    3132
    3233namespace HeuristicLab.Operators.MPISupport {
     
    103104          if (creator != null) {
    104105            IAtomicOperation op = ExecutionContext.CreateOperation(creator, scopes[i]);
    105             MPIHelper.Execute(op, CancellationToken);
     106            MPIHelper.Execute(op);
    106107          }
    107108
    108109          if (evaluator != null) {
    109110            IAtomicOperation op = ExecutionContext.CreateOperation(evaluator, scopes[i]);
    110             MPIHelper.Execute(op, CancellationToken);
     111            MPIHelper.Execute(op);
    111112          }
    112113
  • branches/MPI/HeuristicLab.Operators.MPISupport/3.3/MPIUniformSubscopesProcessor.cs

    r7544 r7566  
    6464          for (int i = start; i < end; i++) {
    6565            IAtomicOperation op = ExecutionContext.CreateOperation(Operator, scopes[i]);
    66             MPIHelper.Execute(op, CancellationToken);
     66            MPIHelper.Execute(op);
    6767           
    6868            //SEND results to other clients
  • branches/MPI/HeuristicLab.Operators.MPISupport/3.3/Plugin.cs.frame

    r7544 r7566  
    2828  [Plugin("HeuristicLab.Operators.MPISupport", "3.3.4.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Operators.MPISupport-3.3.dll", PluginFileType.Assembly)]
    30   [PluginDependency("HeuristicLab.MPInet", "1.0.0")]
    3130  [PluginDependency("HeuristicLab.Core", "3.3")]
    3231  [PluginDependency("HeuristicLab.Common", "3.3")]
Note: See TracChangeset for help on using the changeset viewer.