Changeset 14649


Ignore:
Timestamp:
02/07/17 10:43:13 (4 years ago)
Author:
jkarder
Message:

#2205: worked on optimization networks

  • added lrp network 3
  • fixed bug in distance calculation
  • renamed FLP.mod to FLP_1.mod
  • activated cma analyzer per default
Location:
branches/OptimizationNetworks
Files:
2 added
13 edited
1 moved

Legend:

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

    r14632 r14649  
    8383      <Private>False</Private>
    8484    </Reference>
     85    <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     86      <SpecificVersion>False</SpecificVersion>
     87      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
     88      <Private>False</Private>
     89    </Reference>
    8590    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    8691      <SpecificVersion>False</SpecificVersion>
     
    177182    <Compile Include="LrpNetwork.cs" />
    178183    <Compile Include="LrpNetwork2.cs" />
     184    <Compile Include="LrpNetwork3.cs" />
    179185    <Compile Include="LrpOrchestratorNode.cs" />
    180186    <Compile Include="LrpOrchestratorNode2.cs" />
     187    <Compile Include="LrpOrchestratorNode3.cs" />
    181188    <Compile Include="LrpUtils.cs" />
    182189    <Compile Include="LrpNetwork1.cs" />
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpNetwork1.cs

    r14628 r14649  
    5353      var vp = new MinimizationVariegationProblem<RealVectorEncoding>();
    5454      cmaes.Problem = vp;
     55      var cmaAnalyzer = cmaes.Analyzer.Operators.OfType<CMAAnalyzer>().Single();
     56      cmaes.Analyzer.Operators.SetItemCheckedState(cmaAnalyzer, true);
    5557      cmaes.MaximumGenerations = 80;
    5658      MetaSolver.Algorithm = cmaes;
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpNetwork2.cs

    r14628 r14649  
    5353      var vp = new MinimizationVariegationProblem<RealVectorEncoding>();
    5454      cmaes.Problem = vp;
     55      var cmaAnalyzer = cmaes.Analyzer.Operators.OfType<CMAAnalyzer>().Single();
     56      cmaes.Analyzer.Operators.SetItemCheckedState(cmaAnalyzer, true);
    5557      cmaes.MaximumGenerations = 80;
    5658      MetaSolver.Algorithm = cmaes;
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpOrchestratorNode.cs

    r14628 r14649  
    3131using HeuristicLab.Encodings.RealVectorEncoding;
    3232using HeuristicLab.Operators;
    33 using HeuristicLab.Optimization;
    3433using HeuristicLab.Parameters;
    3534using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    183182    }
    184183
    185     private void InstanceParameter_Value_ToStringChanged(object sender, EventArgs e) {
     184    protected virtual void InstanceParameter_Value_ToStringChanged(object sender, EventArgs e) {
    186185      string filePath = InstanceParameter.Value.Value;
    187186      LrpUtils.Import(filePath, out nrOfDepots, out nrOfCustomers,
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpOrchestratorNode1.cs

    r14628 r14649  
    9797        var vrp = (VehicleRoutingProblem)VrpParameter.Value.Clone();
    9898        var vrpInstance = (CVRPProblemInstance)vrp.ProblemInstance;
    99         var coordinates = LrpUtils.GetVrpCoordinates(depotCoordinates, customerCoordinates, depotIdx, customers);
     99        var coordinates = LrpUtils.GetVrpCoordinates(depotCoordinates, customerCoordinates, new[] { depotIdx }, customers);
    100100        var distances = LrpUtils.GetVrpDistances(coordinates, distanceType);
    101101        vrpInstance.Coordinates = new DoubleMatrix(coordinates);
     
    111111
    112112        var vrpResults = (ResultCollection)vrpMsg["Results"];
    113         var bestVrpSolution = (VRPSolution)vrpResults["Best valid VRP Solution"].Value.Clone();
     113        IResult bestVrpSolutionResult;
     114        if (!vrpResults.TryGetValue("Best valid VRP Solution", out bestVrpSolutionResult)
     115         && !vrpResults.TryGetValue("Best VRP Solution", out bestVrpSolutionResult)) {
     116          // no best solution found ... throw?
     117        }
     118        var bestVrpSolution = (VRPSolution)bestVrpSolutionResult.Value.Clone();
    114119        vrpSolutions.Add(new Result("Depot " + depot.Key, bestVrpSolution));
    115120      }
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpOrchestratorNode2.cs

    r14628 r14649  
    9797        var vrp = (VehicleRoutingProblem)VrpParameter.Value.Clone();
    9898        var vrpInstance = (CVRPProblemInstance)vrp.ProblemInstance;
    99         var coordinates = LrpUtils.GetVrpCoordinates(depotCoordinates, customerCoordinates, depotIdx, customers);
     99        var coordinates = LrpUtils.GetVrpCoordinates(depotCoordinates, customerCoordinates, new[] { depotIdx }, customers);
    100100        var distances = LrpUtils.GetVrpDistances(coordinates, distanceType);
    101101        vrpInstance.Coordinates = new DoubleMatrix(coordinates);
     
    111111
    112112        var vrpResults = (ResultCollection)vrpMsg["Results"];
    113         var bestVrpSolution = (VRPSolution)vrpResults["Best valid VRP Solution"].Value.Clone();
     113        IResult bestVrpSolutionResult;
     114        if (!vrpResults.TryGetValue("Best valid VRP Solution", out bestVrpSolutionResult)
     115         && !vrpResults.TryGetValue("Best VRP Solution", out bestVrpSolutionResult)) {
     116          // no best solution found ... throw?
     117        }
     118        var bestVrpSolution = (VRPSolution)bestVrpSolutionResult.Value.Clone();
    114119        vrpSolutions.Add(new Result("Depot " + depot.Key, bestVrpSolution));
    115120      }
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpUtils.cs

    r14604 r14649  
    1919      DistanceFuncs = new Dictionary<DistanceType, Func<double[,], int, double[,], int, double>>();
    2020      DistanceFuncs.Add(DistanceType.EUC_2D, (d, i, c, j) => Math.Sqrt(Math.Pow(d[i, 0] - c[j, 0], 2.0) + Math.Pow(d[i, 1] - c[j, 1], 2.0)));
    21       DistanceFuncs.Add(DistanceType.CEIL_2D, (d, i, c, j) => Math.Ceiling(DistanceFuncs[DistanceType.EUC_2D](d, i, c, j)) * 100);
     21      DistanceFuncs.Add(DistanceType.CEIL_2D, (d, i, c, j) => Math.Ceiling(DistanceFuncs[DistanceType.EUC_2D](d, i, c, j) * 100));
    2222    }
    2323
     
    135135    }
    136136
    137     public static double[,] GetVrpCoordinates(double[,] depotCoordinates, double[,] customerCoordinates, int depotIdx, int[] customers) {
    138       var coordinates = new double[customers.Length + 1, 2];
     137    public static double[,] GetVrpCoordinates(double[,] depotCoordinates, double[,] customerCoordinates, int[] depots, int[] customers) {
     138      var coordinates = new double[depots.Length + customers.Length, 2];
    139139
    140       coordinates[0, 0] = depotCoordinates[depotIdx, 0];
    141       coordinates[0, 1] = depotCoordinates[depotIdx, 1];
     140      for (int i = 0; i < depots.Length; i++) {
     141        coordinates[i, 0] = depotCoordinates[depots[i], 0];
     142        coordinates[i, 1] = depotCoordinates[depots[i], 1];
     143      }
    142144      for (int i = 0; i < customers.Length; i++) {
    143         coordinates[i + 1, 0] = customerCoordinates[customers[i], 0];
    144         coordinates[i + 1, 1] = customerCoordinates[customers[i], 1];
     145        coordinates[i + depots.Length, 0] = customerCoordinates[customers[i], 0];
     146        coordinates[i + depots.Length, 1] = customerCoordinates[customers[i], 1];
    145147      }
    146148
     
    148150    }
    149151
    150     public static double[,] GetVrpDistances(double[,] depotCoordinates, double[,] customerCoordinates, int depotIdx, int[] customers, DistanceType distanceType) {
    151       var coordinates = GetVrpCoordinates(depotCoordinates, customerCoordinates, depotIdx, customers);
     152    public static double[,] GetVrpDistances(double[,] depotCoordinates, double[,] customerCoordinates, int[] depots, int[] customers, DistanceType distanceType) {
     153      var coordinates = GetVrpCoordinates(depotCoordinates, customerCoordinates, depots, customers);
    152154      return GetVrpDistances(coordinates, distanceType);
    153155    }
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/HeuristicLab.Networks.IntegratedOptimization.TravelingThief-3.3.csproj

    r14632 r14649  
    8484    <Reference Include="HeuristicLab.Algorithms.ParameterlessPopulationPyramid-3.3">
    8585      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.ParameterlessPopulationPyramid-3.3.dll</HintPath>
     86      <Private>False</Private>
     87    </Reference>
     88    <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     89      <SpecificVersion>False</SpecificVersion>
     90      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
    8691      <Private>False</Private>
    8792    </Reference>
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork1.cs

    r14628 r14649  
    2020#endregion
    2121
     22using System.Linq;
    2223using HeuristicLab.Algorithms.CMAEvolutionStrategy;
    2324using HeuristicLab.Algorithms.LocalSearch;
     
    4546      var cmaes = new CMAEvolutionStrategy();
    4647      cmaes.Problem = new MaximizationVariegationProblem<RealVectorEncoding>();
     48      var cmaAnalyzer = cmaes.Analyzer.Operators.OfType<CMAAnalyzer>().Single();
     49      cmaes.Analyzer.Operators.SetItemCheckedState(cmaAnalyzer, true);
    4750      cmaes.MaximumGenerations = 80;
    4851      MetaSolver.Algorithm = cmaes;
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork2.cs

    r14628 r14649  
    2020#endregion
    2121
     22using System.Linq;
    2223using HeuristicLab.Algorithms.CMAEvolutionStrategy;
    2324using HeuristicLab.Algorithms.LocalSearch;
     
    4546      var cmaes = new CMAEvolutionStrategy();
    4647      cmaes.Problem = new MaximizationVariegationProblem<RealVectorEncoding>();
     48      var cmaAnalyzer = cmaes.Analyzer.Operators.OfType<CMAAnalyzer>().Single();
     49      cmaes.Analyzer.Operators.SetItemCheckedState(cmaAnalyzer, true);
    4750      cmaes.MaximumGenerations = 80;
    4851      MetaSolver.Algorithm = cmaes;
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork3.cs

    r14629 r14649  
    2020#endregion
    2121
     22using System.Linq;
    2223using HeuristicLab.Algorithms.CMAEvolutionStrategy;
    2324using HeuristicLab.Algorithms.LocalSearch;
     
    4546      var cmaes = new CMAEvolutionStrategy();
    4647      cmaes.Problem = new MaximizationVariegationProblem<RealVectorEncoding>();
     48      var cmaAnalyzer = cmaes.Analyzer.Operators.OfType<CMAAnalyzer>().Single();
     49      cmaes.Analyzer.Operators.SetItemCheckedState(cmaAnalyzer, true);
    4750      cmaes.MaximumGenerations = 80;
    4851      MetaSolver.Algorithm = cmaes;
  • branches/OptimizationNetworks/HeuristicLab.Problems.FacilityLocation.CplexSolver/3.3/FLPCplexSolver.cs

    r14646 r14649  
    3737
    3838namespace HeuristicLab.Problems.FacilityLocation.CplexSolver {
    39   public enum FlpVariant { FLP, FLP_2 }
     39  public enum FlpVariant { FLP_1, FLP_2 }
    4040
    4141  [Item("FLP CPLEX Solver", "Solves facility location problem (FLP) instances using CPLEX.")]
     
    8787    public FLPCplexSolver() {
    8888      Parameters.Add(maximumRuntimeParameter = new FixedValueParameter<TimeSpanValue>("Maximum Runtime", "Specifies how long CPLEX should be allowed to run.", new TimeSpanValue(TimeSpan.FromSeconds(60))));
    89       Parameters.Add(flpVariantParameter = new FixedValueParameter<EnumValue<FlpVariant>>("FLP Variant", "Which FLP variant should be run.", new EnumValue<FlpVariant>(FlpVariant.FLP)));
     89      Parameters.Add(flpVariantParameter = new FixedValueParameter<EnumValue<FlpVariant>>("FLP Variant", "Which FLP variant should be run.", new EnumValue<FlpVariant>(FlpVariant.FLP_1)));
    9090      Problem = new FacilityLocationProblem();
    9191    }
  • branches/OptimizationNetworks/HeuristicLab.Problems.FacilityLocation.CplexSolver/3.3/HeuristicLab.Problems.FacilityLocation.CplexSolver-3.3.csproj

    r14646 r14649  
    118118  </ItemGroup>
    119119  <ItemGroup>
    120     <EmbeddedResource Include="FLP.mod" />
     120    <EmbeddedResource Include="FLP_1.mod" />
    121121  </ItemGroup>
    122122  <ItemGroup>
Note: See TracChangeset for help on using the changeset viewer.