Changeset 11554


Ignore:
Timestamp:
11/17/14 03:22:32 (5 years ago)
Author:
swagner
Message:

#2205: Implemented review comments:

  • added cloning of Port in HookOperator and prevented cloning of hook operator ports in AlgorithmNode instead
  • added additional checks that port parameters of a hook operator port match with parameters of hook operator
Location:
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Operators/HookOperator.cs

    r11530 r11554  
    5151    protected HookOperator(HookOperator original, Cloner cloner)
    5252      : base(original, cloner) {
    53       // ATTENTION: port is intentionally NOT cloned
    54       port = original.port;
     53      port = cloner.Clone(original.port);
    5554    }
    5655    public HookOperator() : base() { }
     
    7372          if (Parameters.TryGetValue(output.Name, out param)) {
    7473            msg[output.Name] = param.ActualValue;
     74          } else if (output.DefaultValue == null) {
     75            throw new InvalidOperationException(string.Format("Cannot determine value for output parameter \"{0}\".", output.Name));
    7576          }
    7677        }
     
    8283          if (Parameters.TryGetValue(input.Name, out param)) {
    8384            param.ActualValue = msg[input.Name];
     85          } else {
     86            throw new InvalidOperationException(string.Format("Cannot find operator parameter for input parameter \"{0}\".", input.Name));
    8487          }
    8588        }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Optimization.Networks/AlgorithmNode.cs

    r11529 r11554  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Core.Networks;
     25using HeuristicLab.Operators;
    2526using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2627using System;
     
    107108      IAlgorithm algorithm;
    108109      lock (locker) {
    109         algorithm = (IAlgorithm)Algorithm.Clone();
     110        // prevent cloning of ports in hook operators
     111        var cloner = new Cloner();
     112        foreach (var hook in Algorithm.GetObjectGraphObjects(new HashSet<object>() { Algorithm.Results, Algorithm.Runs }).OfType<IHookOperator>()) {
     113          cloner.RegisterClonedObject(hook.Port, hook.Port);
     114        }
     115        algorithm = (IAlgorithm)Algorithm.Clone(cloner);
    110116        waitHandles.Add(algorithm, new AutoResetEvent(false));
    111117      }
Note: See TracChangeset for help on using the changeset viewer.