Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14613


Ignore:
Timestamp:
01/26/17 15:44:04 (8 years ago)
Author:
jkarder
Message:

#2205: worked on optimization networks

  • fixed event handler registration
Location:
branches/OptimizationNetworks
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpNetwork1.cs

    r14610 r14613  
    6464      RegisterEvents();
    6565    }
    66 
    67     private void RegisterEvents() {
    68       MetaSolver.Algorithm.ExecutionStateChanged += OnExecutionStateChanged;
    69       MetaSolver.Algorithm.ExecutionTimeChanged += OnExecutionTimeChanged;
    70       MetaSolver.Algorithm.Prepared += OnPrepared;
    71       MetaSolver.Algorithm.Started += OnStarted;
    72       MetaSolver.Algorithm.Paused += OnPaused;
    73       MetaSolver.Algorithm.Stopped += OnStopped;
    74       MetaSolver.Algorithm.ExceptionOccurred += OnExceptionOccurred;
    75     }
    76 
    7766    public LrpNetwork1() : base("LrpNetwork1") {
    7867      var orchestratorNode = new LrpOrchestratorNode1("Orchestrator");
     
    124113    }
    125114
     115    private void RegisterEvents() {
     116      MetaSolver.AlgorithmChanged += MetaSolver_AlgorithmChanged;
     117      RegisterAlgorithmEvents();
     118    }
     119
     120    private void RegisterAlgorithmEvents() {
     121      var algorithm = MetaSolver.Algorithm;
     122      if (algorithm == null) return;
     123
     124      algorithm.ExecutionStateChanged += OnExecutionStateChanged;
     125      algorithm.ExecutionTimeChanged += OnExecutionTimeChanged;
     126      algorithm.Prepared += OnPrepared;
     127      algorithm.Started += OnStarted;
     128      algorithm.Paused += OnPaused;
     129      algorithm.Stopped += OnStopped;
     130      algorithm.ExceptionOccurred += OnExceptionOccurred;
     131    }
     132
     133    private void MetaSolver_AlgorithmChanged(object sender, EventArgs e) {
     134      RegisterAlgorithmEvents();
     135    }
     136
    126137    #region IOptimizer Members
    127138    public RunCollection Runs { get { return MetaSolver.Algorithm.Runs; } }
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork.cs

    r14610 r14613  
    5555      RegisterEvents();
    5656    }
    57     protected TtpNetwork() : base("TtpNetwork") { }
     57    protected TtpNetwork() : this("TtpNetwork") { }
    5858    protected TtpNetwork(string name) : base(name) {
    5959      Nodes.Add(new TtpOrchestratorNode1("Orchestrator"));
     
    7272    protected virtual void RegisterEvents() {
    7373      MetaSolver.AlgorithmChanged += MetaSolver_AlgorithmChanged;
     74      RegisterAlgorithmEvents();
    7475    }
    7576
    76     protected virtual void MetaSolver_AlgorithmChanged(object sender, EventArgs e) {
     77    protected virtual void RegisterAlgorithmEvents() {
    7778      var algorithm = MetaSolver.Algorithm;
    7879      if (algorithm == null) return;
     
    8586      algorithm.Stopped += OnStopped;
    8687      algorithm.ExceptionOccurred += OnExceptionOccurred;
     88    }
     89
     90    protected virtual void MetaSolver_AlgorithmChanged(object sender, EventArgs e) {
     91      RegisterAlgorithmEvents();
    8792    }
    8893
Note: See TracChangeset for help on using the changeset viewer.