Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14621


Ignore:
Timestamp:
01/31/17 09:30:07 (8 years ago)
Author:
jkarder
Message:

#2205: worked on optimization networks

  • added lrp network 2
  • minor code changes
Location:
branches/OptimizationNetworks
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/HeuristicLab.Networks.IntegratedOptimization.LocationRouting-3.3.csproj

    r14604 r14621  
    180180    <None Include="Properties\AssemblyInfo.cs.frame" />
    181181    <None Include="Plugin.cs.frame" />
     182    <Compile Include="LrpNetwork.cs" />
     183    <Compile Include="LrpNetwork2.cs" />
     184    <Compile Include="LrpOrchestratorNode.cs" />
     185    <Compile Include="LrpOrchestratorNode2.cs" />
    182186    <Compile Include="LrpUtils.cs" />
    183187    <Compile Include="LrpNetwork1.cs" />
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpNetwork1.cs

    r14613 r14621  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.Linq;
    2524using HeuristicLab.Algorithms.CMAEvolutionStrategy;
     
    2726using HeuristicLab.Common;
    2827using HeuristicLab.Core;
    29 using HeuristicLab.Core.Networks;
    3028using HeuristicLab.Optimization;
    3129using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    4038  [Creatable("Optimization Networks")]
    4139  [StorableClass]
    42   public sealed class LrpNetwork1 : Network, IOptimizer {
    43     #region Nodes
    44     public LrpOrchestratorNode1 Orchestrator {
    45       get { return (LrpOrchestratorNode1)Nodes["Orchestrator"]; }
    46     }
    47 
    48     public OrchestratedAlgorithmNode MetaSolver {
    49       get { return (OrchestratedAlgorithmNode)Nodes["MetaSolver"]; }
    50     }
    51 
    52     public OrchestratedAlgorithmNode LrpSolver {
    53       get { return (OrchestratedAlgorithmNode)Nodes["LrpSolver"]; }
    54     }
    55 
    56     public OrchestratedAlgorithmNode VrpSolver {
    57       get { return (OrchestratedAlgorithmNode)Nodes["VrpSolver"]; }
    58     }
    59     #endregion
    60 
     40  public sealed class LrpNetwork1 : LrpNetwork, IOptimizer {
    6141    [StorableConstructor]
    6242    private LrpNetwork1(bool deserializing) : base(deserializing) { }
    63     private LrpNetwork1(LrpNetwork1 original, Cloner cloner) : base(original, cloner) {
    64       RegisterEvents();
    65     }
    66     public LrpNetwork1() : base("LrpNetwork1") {
    67       var orchestratorNode = new LrpOrchestratorNode1("Orchestrator");
    68       Nodes.Add(orchestratorNode);
     43    private LrpNetwork1(LrpNetwork1 original, Cloner cloner) : base(original, cloner) { }
     44    public LrpNetwork1() : this("LrpNetwork1") { }
     45    public LrpNetwork1(string name) : base(name) {
     46      Orchestrator = new LrpOrchestratorNode1(OrchestratorNodeName);
     47      MetaSolver = new OrchestratedAlgorithmNode(MetaSolverNodeName);
     48      FlpSolver = new OrchestratedAlgorithmNode(FlpSolverNodeName);
     49      VrpSolver = new OrchestratedAlgorithmNode(VrpSolverNodeName);
    6950
    70       var metaSolverNode = new OrchestratedAlgorithmNode("MetaSolver");
    7151      var cmaes = new CMAEvolutionStrategy();
    7252      var vp = new VariegationProblem();
     
    7454      cmaes.Problem = vp;
    7555      cmaes.MaximumGenerations = 80;
    76       metaSolverNode.Algorithm = cmaes;
    77       orchestratorNode.MetaSolverOrchestrationPort.ConnectedPort = metaSolverNode.OrchestrationPort;
    78       Nodes.Add(metaSolverNode);
     56      MetaSolver.Algorithm = cmaes;
     57      Orchestrator.MetaSolverOrchestrationPort.ConnectedPort = MetaSolver.OrchestrationPort;
    7958
    80       var flpSolverNode = new OrchestratedAlgorithmNode("FlpSolver");
    8159      var cplexSolver = new FLPCplexSolver();
    8260      cplexSolver.Problem = new FacilityLocationProblem();
    8361      cplexSolver.MaximumRuntimeParameter.Value.Value = TimeSpan.FromSeconds(3.0);
    84       flpSolverNode.Algorithm = cplexSolver;
    85       orchestratorNode.FlpSolverOrchestrationPort.ConnectedPort = flpSolverNode.OrchestrationPort;
    86       Nodes.Add(flpSolverNode);
     62      FlpSolver.Algorithm = cplexSolver;
     63      Orchestrator.FlpSolverOrchestrationPort.ConnectedPort = FlpSolver.OrchestrationPort;
    8764
    88       var vrpSolverNode = new OrchestratedAlgorithmNode("VrpSolver");
    8965      var ga = new GeneticAlgorithm();
    9066      ga.Problem = new VehicleRoutingProblem();
     
    9773      var selector = ga.SelectorParameter.ValidValues.OfType<TournamentSelector>().Single();
    9874      ga.SelectorParameter.Value = selector;
    99       vrpSolverNode.Algorithm = ga;
    100       orchestratorNode.VrpSolverOrchestrationPort.ConnectedPort = vrpSolverNode.OrchestrationPort;
    101       Nodes.Add(vrpSolverNode);
    102 
    103       RegisterEvents();
     75      VrpSolver.Algorithm = ga;
     76      Orchestrator.VrpSolverOrchestrationPort.ConnectedPort = VrpSolver.OrchestrationPort;
    10477    }
    10578
     
    10780      return new LrpNetwork1(this, cloner);
    10881    }
    109 
    110     [StorableHook(HookType.AfterDeserialization)]
    111     private void AfterDeserialization() {
    112       RegisterEvents();
    113     }
    114 
    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 
    137     #region IOptimizer Members
    138     public RunCollection Runs { get { return MetaSolver.Algorithm.Runs; } }
    139     public IEnumerable<IOptimizer> NestedOptimizers { get { yield break; } }
    140     public ExecutionState ExecutionState { get { return MetaSolver.Algorithm.ExecutionState; } }
    141     public TimeSpan ExecutionTime { get { return MetaSolver.Algorithm.ExecutionTime; } }
    142 
    143     public void Prepare() { Prepare(false); }
    144     public void Prepare(bool clearRuns) { Orchestrator.Prepare(clearRuns); }
    145     public void Start() { Orchestrator.StartAsync(); }
    146     public void Pause() { Orchestrator.Pause(); }
    147     public void Stop() { Orchestrator.Stop(); }
    148     #endregion
    149 
    150     private void OnExecutionStateChanged(object sender, EventArgs e) { OnExecutionStateChanged(); }
    151     private void OnExecutionTimeChanged(object sender, EventArgs e) { OnExecutionTimeChanged(); }
    152     private void OnPrepared(object sender, EventArgs e) { OnPrepared(); }
    153     private void OnStarted(object sender, EventArgs e) { OnStarted(); }
    154     private void OnPaused(object sender, EventArgs e) { OnPaused(); }
    155     private void OnStopped(object sender, EventArgs e) { OnStopped(); }
    156     private void OnExceptionOccurred(object sender, EventArgs<Exception> e) { OnExceptionOccurred(e.Value); }
    157 
    158     public event EventHandler ExecutionStateChanged;
    159     private void OnExecutionStateChanged() {
    160       var handler = ExecutionStateChanged;
    161       if (handler != null) handler(this, EventArgs.Empty);
    162     }
    163 
    164     public event EventHandler ExecutionTimeChanged;
    165     private void OnExecutionTimeChanged() {
    166       var handler = ExecutionTimeChanged;
    167       if (handler != null) handler(this, EventArgs.Empty);
    168     }
    169 
    170     public event EventHandler Prepared;
    171     private void OnPrepared() {
    172       var handler = Prepared;
    173       if (handler != null) handler(this, EventArgs.Empty);
    174     }
    175 
    176     public event EventHandler Started;
    177     private void OnStarted() {
    178       var handler = Started;
    179       if (handler != null) handler(this, EventArgs.Empty);
    180     }
    181 
    182     public event EventHandler Paused;
    183     private void OnPaused() {
    184       var handler = Paused;
    185       if (handler != null) handler(this, EventArgs.Empty);
    186     }
    187 
    188     public event EventHandler Stopped;
    189     private void OnStopped() {
    190       var handler = Stopped;
    191       if (handler != null) handler(this, EventArgs.Empty);
    192     }
    193 
    194     public event EventHandler<EventArgs<Exception>> ExceptionOccurred;
    195     private void OnExceptionOccurred(Exception exception) {
    196       var handler = ExceptionOccurred;
    197       if (handler != null) handler(this, new EventArgs<Exception>(exception));
    198     }
    19982  }
    20083}
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpOrchestratorNode1.cs

    r14616 r14621  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.Linq;
    25 using System.Text.RegularExpressions;
    26 using System.Threading;
    2724using HeuristicLab.Common;
    2825using HeuristicLab.Core;
    2926using HeuristicLab.Core.Networks;
    3027using HeuristicLab.Data;
    31 using HeuristicLab.Encodings.BinaryVectorEncoding;
    3228using HeuristicLab.Encodings.IntegerVectorEncoding;
    33 using HeuristicLab.Encodings.PermutationEncoding;
    3429using HeuristicLab.Encodings.RealVectorEncoding;
    35 using HeuristicLab.Operators;
    3630using HeuristicLab.Optimization;
    37 using HeuristicLab.Parameters;
    3831using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3932using HeuristicLab.Problems.FacilityLocation;
    4033using HeuristicLab.Problems.VehicleRouting;
    41 using HeuristicLab.Problems.VehicleRouting.Encodings.General;
    4234using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    4335
     
    4537  [Item("LrpOrchestratorNode1", "Orchestrator for LRP optimization network version 1.")]
    4638  [StorableClass]
    47   public sealed class LrpOrchestratorNode1 : OrchestratorNode {
    48     #region Constants
    49     private const string InstanceParameterName = "Instance";
    50     private const string FlpParameterName = "FLP";
    51     private const string VrpParameterName = "VRP";
    52     private const string MetaSolverName = "MetaSolver";
    53     private const string FlpSolverName = "FlpSolver";
    54     private const string VrpSolverName = "VrpSolver";
    55     #endregion
    56 
    57     private CancellationTokenSource cts;
    58     private ResultCollection vrpResults, flpResults;
    59 
    60     [Storable]
    61     int nrOfDepots, nrOfCustomers;
    62     [Storable]
    63     double[,] depotCoordinates = new double[0, 0], customerCoordinates = new double[0, 0];
    64     [Storable]
    65     LrpUtils.DistanceType distanceType;
    66     [Storable]
    67     double[] depotCapacities = new double[0], customerDemands = new double[0], depotCosts = new double[0];
    68     [Storable]
    69     double vehicleCapacity, vehicleCost;
    70 
    71     #region Parameters
    72     public IFixedValueParameter<TextFileValue> InstanceParameter {
    73       get { return (IFixedValueParameter<TextFileValue>)Parameters[InstanceParameterName]; }
    74     }
    75 
    76     public IValueParameter<FacilityLocationProblem> FlpParameter {
    77       get { return (IValueParameter<FacilityLocationProblem>)Parameters[FlpParameterName]; }
    78     }
    79 
    80     public IValueParameter<VehicleRoutingProblem> VrpParameter {
    81       get { return (IValueParameter<VehicleRoutingProblem>)Parameters[VrpParameterName]; }
    82     }
    83     #endregion
    84 
    85     #region Ports
    86     public IMessagePort MetaSolverOrchestrationPort {
    87       get { return (IMessagePort)Ports[MetaSolverName + OrchestrationPortNameSuffix]; }
    88     }
    89 
    90     public IMessagePort MetaSolverEvaluationPort {
    91       get { return (IMessagePort)Ports[MetaSolverName + EvaluationPortNameSuffix]; }
    92     }
    93 
    94     public IMessagePort FlpSolverOrchestrationPort {
    95       get { return (IMessagePort)Ports[FlpSolverName + OrchestrationPortNameSuffix]; }
    96     }
    97 
    98     public IMessagePort FlpSolverEvaluationPort {
    99       get { return (IMessagePort)Ports[FlpSolverName + EvaluationPortNameSuffix]; }
    100     }
    101 
    102     public IMessagePort VrpSolverOrchestrationPort {
    103       get { return (IMessagePort)Ports[VrpSolverName + OrchestrationPortNameSuffix]; }
    104     }
    105 
    106     public IMessagePort VrpSolverEvaluationPort {
    107       get { return (IMessagePort)Ports[VrpSolverName + EvaluationPortNameSuffix]; }
    108     }
    109     #endregion
    110 
     39  public sealed class LrpOrchestratorNode1 : LrpOrchestratorNode {
    11140    [StorableConstructor]
    11241    private LrpOrchestratorNode1(bool deserializing) : base(deserializing) { }
    113     private LrpOrchestratorNode1(LrpOrchestratorNode1 original, Cloner cloner) : base(original, cloner) {
    114       nrOfDepots = original.nrOfDepots;
    115       nrOfCustomers = original.nrOfCustomers;
    116       depotCoordinates = (double[,])original.depotCoordinates.Clone();
    117       customerCoordinates = (double[,])original.customerCoordinates.Clone();
    118       distanceType = original.distanceType;
    119       depotCapacities = (double[])original.depotCapacities.Clone();
    120       customerDemands = (double[])original.customerDemands.Clone();
    121       depotCosts = (double[])original.depotCosts.Clone();
    122       vehicleCapacity = original.vehicleCapacity;
    123       vehicleCost = original.vehicleCost;
    124 
    125       RegisterEvents();
    126     }
     42    private LrpOrchestratorNode1(LrpOrchestratorNode1 original, Cloner cloner) : base(original, cloner) { }
    12743    public LrpOrchestratorNode1() : this("LrpOrchestratorNode1") { }
    12844    public LrpOrchestratorNode1(string name) : base(name) {
    129       #region Configure Parameters
    130       Parameters.Add(new FixedValueParameter<TextFileValue>(InstanceParameterName));
    131       Parameters.Add(new ValueParameter<FacilityLocationProblem>(FlpParameterName, new FacilityLocationProblem()));
    132       Parameters.Add(new ValueParameter<VehicleRoutingProblem>(VrpParameterName, new VehicleRoutingProblem() { ProblemInstance = new CVRPProblemInstance() }));
    133       #endregion
    134 
    135       #region Configure Ports
    136       Ports.Add(CreateOrchestrationPort<VariegationProblem>(MetaSolverName));
    137       Ports.Add(CreateEvaluationPort<RealVector>(MetaSolverName, "RealVector", "Quality"));
    138       Ports.Add(CreateOrchestrationPort<VehicleRoutingProblem>(VrpSolverName));
    139       Ports.Add(CreateEvaluationPort<Permutation>(VrpSolverName, "TSPTour", "TSPTourLength"));
    140       Ports.Add(CreateOrchestrationPort<FacilityLocationProblem>(FlpSolverName));
    141       Ports.Add(CreateEvaluationPort<BinaryVector>(FlpSolverName, "KnapsackSolution", "Quality"));
    142 
    143       RegisterEvents();
    144       #endregion
     45      MetaSolverOrchestrationPort = CreateOrchestrationPort<VariegationProblem>(MetaSolverName);
     46      MetaSolverEvaluationPort = CreateEvaluationPort<RealVector>(MetaSolverName, "RealVector", "Quality");
     47      FlpSolverOrchestrationPort = CreateOrchestrationPort<FacilityLocationProblem>(FlpSolverName);
     48      VrpSolverOrchestrationPort = CreateOrchestrationPort<VehicleRoutingProblem>(VrpSolverName);
    14549    }
    14650
     
    14953    }
    15054
    151     [StorableHook(HookType.AfterDeserialization)]
    152     private void AfterDeserialization() {
    153       RegisterEvents();
    154     }
    155 
    156     private void RegisterEvents() {
    157       InstanceParameter.Value.ToStringChanged += InstanceParameter_Value_ToStringChanged;
    158       MetaSolverOrchestrationPort.ConnectedPortChanged += MetaSolverOrchestrationPort_ConnectedPortChanged;
    159       VrpSolverOrchestrationPort.ConnectedPortChanged += VrpSolverOrchestrationPort_ConnectedPortChanged;
    160       FlpSolverOrchestrationPort.ConnectedPortChanged += FlpSolverOrchestrationPort_ConnectedPortChanged;
    161     }
    162 
    163     private void InstanceParameter_Value_ToStringChanged(object sender, EventArgs e) {
    164       string filePath = InstanceParameter.Value.Value;
    165       LrpUtils.Import(filePath, out nrOfDepots, out nrOfCustomers,
    166                                 out depotCoordinates, out customerCoordinates,
    167                                 out distanceType,
    168                                 out depotCapacities, out customerDemands, out depotCosts,
    169                                 out vehicleCapacity, out vehicleCost);
    170 
    171       var flp = FlpParameter.Value;
    172       flp.CustomerDemandsParameter.Value = new DoubleArray(customerDemands);
    173       flp.DeliveryCostsParameter.Value = new DoubleMatrix(LrpUtils.GetFlpDeliveryCosts(depotCoordinates, customerCoordinates, distanceType));
    174       flp.DepotCapacitiesParameter.Value = new DoubleArray(depotCapacities);
    175       flp.Encoding.Length = nrOfCustomers;
    176       flp.OpeningCostsParameter.Value = new DoubleArray(depotCosts);
    177 
    178       var vrpInstance = (CVRPProblemInstance)VrpParameter.Value.ProblemInstance;
    179       vrpInstance.Capacity.Value = vehicleCapacity;
    180       vrpInstance.FleetUsageFactor.Value = vehicleCost;
    181       vrpInstance.OverloadPenalty.Value = vehicleCost * 1000.0;
    182 
    183       var crossover = VrpParameter.Value.OperatorsParameter.Value.OfType<MultiVRPSolutionCrossover>().Single(x => x.Name == "MultiVRPSolutionCrossover");
    184       foreach (var c in crossover.Operators)
    185         crossover.Operators.SetItemCheckedState(c, c.Name.StartsWith("Potvin"));
    186       var mutator = VrpParameter.Value.OperatorsParameter.Value.OfType<MultiVRPSolutionManipulator>().Single(x => x.Name == "MultiVRPSolutionManipulator");
    187       foreach (var m in mutator.Operators)
    188         mutator.Operators.SetItemCheckedState(m, Regex.IsMatch(m.Name, @"Potvin(One|Two).*"));
    189 
    190       Prepare();
    191     }
    192 
    19355    public override void Prepare(bool clearRuns = false) {
    194       Results.Clear();
     56      base.Prepare(clearRuns);
    19557
    19658      var metaMsg = MetaSolverOrchestrationPort.PrepareMessage();
     
    19961      metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(msgFlags);
    20062      var problem = new VariegationProblem();
    201       problem.Encoding.Length = FlpParameter.Value.Encoding.Length * 2;
    202       problem.Encoding.Bounds = new DoubleMatrix(new[,] { { 0.0, 2.0 } });
     63      problem.Encoding.Length = nrOfCustomers * 2;
     64      problem.Encoding.Bounds = new DoubleMatrix(new[,] { { -1.0, 1.0 } });
    20365      metaMsg["Problem"] = problem;
    20466      MetaSolverOrchestrationPort.SendMessage(metaMsg);
    20567    }
    20668
    207     public override void Start() {
    208       cts = new CancellationTokenSource();
    209 
    210       var metaMsg = MetaSolverOrchestrationPort.PrepareMessage();
    211       metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Start);
    212       MetaSolverOrchestrationPort.SendMessage(metaMsg);
    213     }
    214 
    215     public override void Pause() {
    216       cts.Cancel();
    217 
    218       var metaMsg = MetaSolverOrchestrationPort.PrepareMessage();
    219       metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Pause);
    220       MetaSolverOrchestrationPort.SendMessage(metaMsg);
    221 
    222       var vrpMsg = VrpSolverOrchestrationPort.PrepareMessage();
    223       vrpMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Stop);
    224       VrpSolverOrchestrationPort.SendMessage(vrpMsg);
    225 
    226       var kspMsg = FlpSolverOrchestrationPort.PrepareMessage();
    227       kspMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Stop);
    228       FlpSolverOrchestrationPort.SendMessage(kspMsg);
    229     }
    230 
    231     public override void Stop() {
    232       cts.Cancel();
    233 
    234       var metaMsg = MetaSolverOrchestrationPort.PrepareMessage();
    235       metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Stop);
    236       MetaSolverOrchestrationPort.SendMessage(metaMsg);
    237 
    238       var vrpMsg = VrpSolverOrchestrationPort.PrepareMessage();
    239       vrpMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Stop);
    240       VrpSolverOrchestrationPort.SendMessage(vrpMsg);
    241 
    242       var kspMsg = FlpSolverOrchestrationPort.PrepareMessage();
    243       kspMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Stop);
    244       FlpSolverOrchestrationPort.SendMessage(kspMsg);
    245     }
    246 
    247     protected override void ProcessMessage(IMessage message, IMessagePort port, CancellationToken token) {
    248       var messageActions = new Dictionary<IMessagePort, Action<IMessage>>();
    249       messageActions.Add(MetaSolverOrchestrationPort, MetaSolverOrchestrationPortMessage);
    250       messageActions.Add(MetaSolverEvaluationPort, MetaSolverEvaluationPortMessage);
    251       messageActions.Add(VrpSolverOrchestrationPort, VrpSolverOrchestrationPortMessage);
    252       messageActions.Add(VrpSolverEvaluationPort, VrpSolverEvaluationPortMessage);
    253       messageActions.Add(FlpSolverOrchestrationPort, FlpSolverOrchestrationPortMessage);
    254       messageActions.Add(FlpSolverEvaluationPort, FlpSolverEvaluationPortMessage);
    255 
    256       messageActions[port](message);
    257 
    258       base.ProcessMessage(message, port, token);
    259     }
    260 
    26169    #region MetaSolver Message Handling
    262     private void MetaSolverOrchestrationPortMessage(IMessage message) { }
    263 
    264     private void MetaSolverEvaluationPortMessage(IMessage message) {
     70    protected override void MetaSolverEvaluationPortMessage(IMessage message) {
    26571      var factors = (RealVector)message["RealVector"];
    26672
     
    324130    }
    325131    #endregion
    326 
    327     #region VrpSolver Message Handling
    328     private void VrpSolverOrchestrationPortMessage(IMessage message) {
    329       var results = (ResultCollection)message["Results"];
    330       if (results.ContainsKey("Best valid VRP Solution")) {
    331         vrpResults = results;
    332       }
    333     }
    334 
    335     private void VrpSolverEvaluationPortMessage(IMessage message) { }
    336     #endregion
    337 
    338     #region KspSolver Message Handling
    339     private void FlpSolverOrchestrationPortMessage(IMessage message) {
    340       var results = (ResultCollection)message["Results"];
    341       if (results.ContainsKey("Best Solution")) {
    342         flpResults = results;
    343       }
    344     }
    345 
    346     private void FlpSolverEvaluationPortMessage(IMessage message) { }
    347     #endregion
    348 
    349     #region Event Handlers
    350     private void MetaSolverOrchestrationPort_ConnectedPortChanged(object sender, EventArgs e) {
    351       if (MetaSolverOrchestrationPort.ConnectedPort == null) return;
    352 
    353       var node = MetaSolverOrchestrationPort.ConnectedPort.Parent as OrchestratedAlgorithmNode;
    354       if (node == null) return;
    355 
    356       var hook = new HookOperator { Name = "Meta Eval Hook" };
    357       hook.Parameters.Add(new LookupParameter<RealVector>("RealVector") { Hidden = true });
    358       hook.Parameters.Add(new LookupParameter<DoubleValue>("Quality") { Hidden = true });
    359       node.EvalHook = hook;
    360 
    361       node.OrchestrationPort.CloneParametersFromPort(MetaSolverOrchestrationPort);
    362       node.EvaluationPort.CloneParametersFromPort(MetaSolverEvaluationPort);
    363       node.EvaluationPort.ConnectedPort = MetaSolverEvaluationPort;
    364     }
    365 
    366     private void VrpSolverOrchestrationPort_ConnectedPortChanged(object sender, EventArgs e) {
    367       if (VrpSolverOrchestrationPort.ConnectedPort == null) return;
    368 
    369       var node = VrpSolverOrchestrationPort.ConnectedPort.Parent as OrchestratedAlgorithmNode;
    370       if (node == null) return;
    371 
    372       var hook = new HookOperator { Name = "VRP Eval Hook" };
    373       hook.Parameters.Add(new LookupParameter<Permutation>("VRPTours") { Hidden = true });
    374       hook.Parameters.Add(new LookupParameter<DoubleValue>("Quality") { Hidden = true });
    375       node.EvalHook = hook;
    376 
    377       node.OrchestrationPort.CloneParametersFromPort(VrpSolverOrchestrationPort);
    378       node.EvaluationPort.CloneParametersFromPort(VrpSolverEvaluationPort);
    379       node.EvaluationPort.ConnectedPort = VrpSolverEvaluationPort;
    380     }
    381 
    382     private void FlpSolverOrchestrationPort_ConnectedPortChanged(object sender, EventArgs e) {
    383       if (FlpSolverOrchestrationPort.ConnectedPort == null) return;
    384 
    385       var node = FlpSolverOrchestrationPort.ConnectedPort.Parent as OrchestratedAlgorithmNode;
    386       if (node == null) return;
    387 
    388       var hook = new HookOperator { Name = "FLP Eval Hook" };
    389       hook.Parameters.Add(new LookupParameter<BinaryVector>("IntegerVector") { Hidden = true });
    390       hook.Parameters.Add(new LookupParameter<DoubleValue>("Quality") { Hidden = true });
    391       node.EvalHook = hook;
    392 
    393       node.OrchestrationPort.CloneParametersFromPort(FlpSolverOrchestrationPort);
    394       node.EvaluationPort.CloneParametersFromPort(FlpSolverEvaluationPort);
    395       node.EvaluationPort.ConnectedPort = FlpSolverEvaluationPort;
    396     }
    397     #endregion
    398132  }
    399133}
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork.cs

    r14616 r14621  
    3131  [Item("TtpNetwork", "An abstract base class for TTP optimization networks.")]
    3232  [StorableClass]
    33   public abstract class TtpNetwork : Network {
     33  public abstract class TtpNetwork : Network, IOptimizer {
    3434    #region Constants
    3535    protected const string OrchestratorNodeName = "Orchestrator";
     
    104104      if (algorithm == null) return;
    105105
    106       algorithm.ExecutionStateChanged += OnExecutionStateChanged;
    107       algorithm.ExecutionTimeChanged += OnExecutionTimeChanged;
    108       algorithm.Prepared += OnPrepared;
    109       algorithm.Started += OnStarted;
    110       algorithm.Paused += OnPaused;
    111       algorithm.Stopped += OnStopped;
    112       algorithm.ExceptionOccurred += OnExceptionOccurred;
     106      algorithm.ExecutionStateChanged += (s, e) => OnExecutionStateChanged();
     107      algorithm.ExecutionTimeChanged += (s, e) => OnExecutionTimeChanged();
     108      algorithm.Prepared += (s, e) => OnPrepared();
     109      algorithm.Started += (s, e) => OnStarted();
     110      algorithm.Paused += (s, e) => OnPaused();
     111      algorithm.Stopped += (s, e) => OnStopped();
     112      algorithm.ExceptionOccurred += (s, e) => OnExceptionOccurred(e.Value);
    113113    }
    114114
     
    167167    }
    168168    #endregion
    169 
    170     protected void OnExecutionStateChanged(object sender, EventArgs e) { OnExecutionStateChanged(); }
    171     protected void OnExecutionTimeChanged(object sender, EventArgs e) { OnExecutionTimeChanged(); }
    172     protected void OnPrepared(object sender, EventArgs e) { OnPrepared(); }
    173     protected void OnStarted(object sender, EventArgs e) { OnStarted(); }
    174     protected void OnPaused(object sender, EventArgs e) { OnPaused(); }
    175     protected void OnStopped(object sender, EventArgs e) { OnStopped(); }
    176     protected void OnExceptionOccurred(object sender, EventArgs<Exception> e) { OnExceptionOccurred(e.Value); }
    177169  }
    178170}
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork1.cs

    r14616 r14621  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
    27 using HeuristicLab.Optimization;
    2827using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2928
     
    3231  [Creatable("Optimization Networks")]
    3332  [StorableClass]
    34   public sealed class TtpNetwork1 : TtpNetwork, IOptimizer {
     33  public sealed class TtpNetwork1 : TtpNetwork {
    3534    [StorableConstructor]
    3635    private TtpNetwork1(bool deserializing) : base(deserializing) { }
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork2.cs

    r14616 r14621  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
    27 using HeuristicLab.Optimization;
    2827using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2928
     
    3231  [Creatable("Optimization Networks")]
    3332  [StorableClass]
    34   public sealed class TtpNetwork2 : TtpNetwork, IOptimizer {
     33  public sealed class TtpNetwork2 : TtpNetwork {
    3534    [StorableConstructor]
    3635    private TtpNetwork2(bool deserializing) : base(deserializing) { }
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork3.cs

    r14616 r14621  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
    27 using HeuristicLab.Optimization;
    2827using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2928
     
    3231  [Creatable("Optimization Networks")]
    3332  [StorableClass]
    34   public sealed class TtpNetwork3 : TtpNetwork, IOptimizer {
     33  public sealed class TtpNetwork3 : TtpNetwork {
    3534    [StorableConstructor]
    3635    private TtpNetwork3(bool deserializing) : base(deserializing) { }
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpOrchestratorNode.cs

    r14616 r14621  
    199199    }
    200200
    201     protected void InstanceParameter_Value_ToStringChanged(object sender, EventArgs e) {
     201    private void InstanceParameter_Value_ToStringChanged(object sender, EventArgs e) {
    202202      string filePath = InstanceParameter.Value.Value;
    203203      TtpUtils.Import(filePath, out tspCoordinates, out distanceType,
Note: See TracChangeset for help on using the changeset viewer.