Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4362


Ignore:
Timestamp:
09/02/10 16:45:33 (14 years ago)
Author:
svonolfe
Message:

Added initial version - WIP (#1177)

Location:
branches/VRP
Files:
48 added
1 deleted
5 edited
3 moved

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/HeuristicLab.Problems.VehicleRouting.Views-3.4.csproj

    r4361 r4362  
    113113    <Compile Include="HeuristicLabProblemsVehicleRoutingViewsPlugin.cs" />
    114114    <Compile Include="Properties\AssemblyInfo.cs" />
     115    <Compile Include="VehicleRoutingProblemView.cs">
     116      <SubType>UserControl</SubType>
     117    </Compile>
     118    <Compile Include="VehicleRoutingProblemView.Designer.cs">
     119      <DependentUpon>VehicleRoutingProblemView.cs</DependentUpon>
     120    </Compile>
    115121  </ItemGroup>
    116122  <ItemGroup>
     
    180186      <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
    181187    </ProjectReference>
    182     <ProjectReference Include="..\..\HeuristicLab.Problems.VehicleRouting\3.3\HeuristicLab.Problems.VehicleRouting-3.3.csproj">
    183       <Project>{6410BDA6-3641-42B2-BABA-AA626E2F6F71}</Project>
    184       <Name>HeuristicLab.Problems.VehicleRouting-3.3</Name>
     188    <ProjectReference Include="..\..\HeuristicLab.Problems.VehicleRouting\3.4\HeuristicLab.Problems.VehicleRouting-3.4.csproj">
     189      <Project>{B94FFB82-43D4-40AB-9980-B03470ADF221}</Project>
     190      <Name>HeuristicLab.Problems.VehicleRouting-3.4</Name>
    185191    </ProjectReference>
    186192  </ItemGroup>
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/HeuristicLabProblemsVehicleRoutingViewsPlugin.cs

    r4361 r4362  
    2626  /// Plugin class for HeuristicLab.Problems.VehicleRouting.Views plugin
    2727  /// </summary>
    28   [Plugin("HeuristicLab.Problems.VehicleRouting.Views", "3.4.0.4359")]
     28  [Plugin("HeuristicLab.Problems.VehicleRouting.Views", "3.4.0.4361")]
    2929  [PluginFile("HeuristicLab.Problems.VehicleRouting.Views-3.4.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Collections", "3.3")]
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj

    r4361 r4362  
    106106  </ItemGroup>
    107107  <ItemGroup>
    108     <Compile Include="ORLIBParser.cs" />
    109     <Compile Include="TSPLIBParser.cs" />
    110     <Compile Include="VRPUtilities.cs" />
     108    <Compile Include="Encodings\Alba\Creators\DefaultRepresentationCreator.cs" />
     109    <Compile Include="Encodings\Alba\Creators\RandomCreator.cs" />
     110    <Compile Include="Encodings\Alba\Creators\AlbaCreator.cs" />
     111    <Compile Include="Encodings\Alba\AlbaOperator.cs" />
     112    <Compile Include="Encodings\VRPOperator.cs" />
     113    <Compile Include="Encodings\VRPEncoding.cs" />
     114    <Compile Include="Interfaces\IVRPEvaluator.cs" />
     115    <Compile Include="Interfaces\IVRPCreator.cs" />
     116    <Compile Include="Interfaces\IVRPOperator.cs" />
     117    <Compile Include="Interfaces\IVRPEncoding.cs" />
     118    <Compile Include="Interfaces\IVRPProblemInstance.cs" />
     119    <Compile Include="Interfaces\Variants\Capacitated\Heterogenous\IHeterogenousCapacitatedProblemInstance.cs" />
     120    <Compile Include="Interfaces\Variants\Capacitated\Heterogenous\IHeterogenousCapacitatedOperator.cs" />
     121    <Compile Include="Interfaces\Variants\Capacitated\Heterogenous\IHeterogenousCapacitatedEncoding.cs" />
     122    <Compile Include="Interfaces\Variants\Capacitated\Homogenous\ICapacitatedEncoding.cs" />
     123    <Compile Include="Interfaces\Variants\Capacitated\Homogenous\ICapacitatedOperator.cs" />
     124    <Compile Include="Interfaces\Variants\Capacitated\Homogenous\ICapacitatedProblemInstance.cs" />
     125    <Compile Include="Interfaces\Variants\SingleDepot\ISingleDepotOperator.cs" />
     126    <Compile Include="Interfaces\Variants\SingleDepot\ISingleDepotEncoding.cs" />
     127    <Compile Include="Interfaces\Variants\SingleDepot\ISingleDepotProblemInstance.cs" />
     128    <Compile Include="Interfaces\Variants\TimeWindowed\ITimeWindowedProblemInstance.cs" />
     129    <Compile Include="Interfaces\Variants\TimeWindowed\ITimeWindowedOperator.cs" />
     130    <Compile Include="Interfaces\Variants\TimeWindowed\ITimeWindowedEncoding.cs" />
     131    <Compile Include="Parsers\ORLIBParser.cs" />
     132    <Compile Include="ProblemInstances\CVRPTWProblemInstance.cs" />
     133    <Compile Include="ProblemInstances\CVRPProblemInstance.cs" />
     134    <Compile Include="ProblemInstances\Evaluation\CVRPTWEvaluation.cs" />
     135    <Compile Include="ProblemInstances\Evaluation\CVRPEvaluation.cs" />
     136    <Compile Include="ProblemInstances\Evaluation\Evaluators\SingleDepotVRPEvaluator.cs" />
     137    <Compile Include="ProblemInstances\Evaluation\Evaluators\VRPEvaluator.cs" />
     138    <Compile Include="ProblemInstances\Evaluation\VRPEvaluation.cs" />
     139    <Compile Include="ProblemInstances\SingleDepotVRPProblemInstance.cs" />
     140    <Compile Include="ProblemInstances\VRPProblemInstance.cs" />
     141    <Compile Include="DomainModel\Tour.cs" />
     142    <Compile Include="Parsers\TSPLIBParser.cs" />
    111143    <Compile Include="HeuristicLabProblemsVehicleRoutingPlugin.cs" />
    112144    <Compile Include="Properties\AssemblyInfo.cs" />
    113     <Compile Include="SolomonParser.cs" />
     145    <Compile Include="Parsers\SolomonParser.cs" />
    114146    <Compile Include="VehicleRoutingProblem.cs" />
    115147  </ItemGroup>
     
    191223  </ItemGroup>
    192224  <ItemGroup>
    193     <Folder Include="Encodings\" />
    194     <Folder Include="Interfaces\" />
    195     <Folder Include="ProblemInstances\" />
     225    <Folder Include="ProblemInstances\Evaluation\MoveEvaluators\" />
    196226  </ItemGroup>
    197227  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLabProblemsVehicleRoutingPlugin.cs

    r4361 r4362  
    2626  /// Plugin class for HeuristicLab.Problems.VehicleRouting plugin
    2727  /// </summary>
    28   [Plugin("HeuristicLab.Problems.VehicleRouting", "3.4.0.4360")]
     28  [Plugin("HeuristicLab.Problems.VehicleRouting", "3.4.0.4361")]
    2929  [PluginFile("HeuristicLab.Problems.VehicleRouting-3.4.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Analysis", "3.3")]
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Parsers/ORLIBParser.cs

    r4361 r4362  
    2727using System.Globalization;
    2828
    29 namespace HeuristicLab.Problems.VehicleRouting {
     29namespace HeuristicLab.Problems.VehicleRouting.Parsers {
    3030  class ORLIBParser {
    3131    private StreamReader source;
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Parsers/SolomonParser.cs

    r4361 r4362  
    2525using System.Text.RegularExpressions;
    2626
    27 namespace HeuristicLab.Problems.VehicleRouting {
     27namespace HeuristicLab.Problems.VehicleRouting.Parsers {
    2828  class SolomonParser {
    2929    private string file;
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Parsers/TSPLIBParser.cs

    r4361 r4362  
    2424using System.IO;
    2525
    26 namespace HeuristicLab.Problems.VehicleRouting {
     26namespace HeuristicLab.Problems.VehicleRouting.Parsers {
    2727  /// <summary>
    2828  /// Parses a *.vrp file in TSPLIB format and extracts its information about a VRP.
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs

    r4360 r4362  
    3232using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3333using HeuristicLab.PluginInfrastructure;
     34using HeuristicLab.Problems.VehicleRouting.Interfaces;
     35using HeuristicLab.Problems.VehicleRouting.Parsers;
     36using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    3437
    3538namespace HeuristicLab.Problems.VehicleRouting {
     
    4245    }
    4346
    44     #region ISingleObjectiveProblem Members
    45     public IParameter BestKnownQualityParameter {
    46       get { throw new NotImplementedException(); }
    47     }
    48 
    49     public ISingleObjectiveEvaluator Evaluator {
    50       get { throw new NotImplementedException(); }
    51     }
    52 
    53     #endregion
    54 
    55     #region IProblem Members
    56     public IParameter SolutionCreatorParameter {
    57       get { throw new NotImplementedException(); }
    58     }
    59 
    60     public ISolutionCreator SolutionCreator {
    61       get { throw new NotImplementedException(); }
    62     }
    63 
    64     public IParameter EvaluatorParameter {
    65       get { throw new NotImplementedException(); }
    66     }
    67 
    68     IEvaluator IProblem.Evaluator {
    69       get { throw new NotImplementedException(); }
    70     }
    71 
    72     public IEnumerable<IOperator> Operators {
    73       get { throw new NotImplementedException(); }
    74     }
    75     #endregion
    76 
    7747    #region Parameter Properties
    7848    public ValueParameter<BoolValue> MaximizationParameter {
     
    8252      get { return MaximizationParameter; }
    8353    }
     54    public ValueParameter<IVRPProblemInstance> ProblemInstanceParameter {
     55      get { return (ValueParameter<IVRPProblemInstance>)Parameters["ProblemInstance"]; }
     56    }
     57    public OptionalValueParameter<DoubleValue> BestKnownQualityParameter {
     58      get { return (OptionalValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
     59    }
     60    IParameter ISingleObjectiveProblem.BestKnownQualityParameter {
     61      get { return BestKnownQualityParameter; }
     62    }
     63    public IParameter SolutionCreatorParameter {
     64      get {
     65        if (ProblemInstance != null)
     66          return ProblemInstance.SolutionCreatorParameter;
     67        else
     68          return null;
     69      }
     70    }
     71    public IParameter EvaluatorParameter {
     72      get {
     73        if (ProblemInstance != null)
     74          return ProblemInstance.EvaluatorParameter;
     75        else
     76          return null;
     77      }
     78    }
    8479    #endregion
    8580
    8681    #region Properties
    87    
     82    public IVRPProblemInstance ProblemInstance {
     83      get { return ProblemInstanceParameter.Value; }
     84      set { ProblemInstanceParameter.Value = value; }
     85    }
     86
     87    public ISingleObjectiveEvaluator Evaluator {
     88      get {
     89        if (ProblemInstance != null)
     90          return ProblemInstance.EvaluatorParameter.Value;
     91        else
     92          return null;
     93      }
     94    }
     95
     96    IEvaluator IProblem.Evaluator {
     97      get { return this.Evaluator; }
     98    }
     99
     100    public ISolutionCreator SolutionCreator {
     101      get {
     102        if (ProblemInstance != null)
     103          return ProblemInstance.SolutionCreatorParameter.Value;
     104        else
     105          return null;
     106      }
     107    }
     108
     109    public IEnumerable<IOperator> Operators {
     110      get {
     111        if (ProblemInstance != null)
     112          return ProblemInstance.Operators.OrderBy(op => op.Name);
     113        else
     114          return null;
     115      }
     116    }
    88117    #endregion
    89 
    90     [Storable]
    91     private List<IOperator> operators;
    92118
    93119    [StorableConstructor]
     
    96122      : base() {
    97123      Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to false as the Vehicle Routing Problem is a minimization problem.", new BoolValue(false)));
    98    
     124      Parameters.Add(new ValueParameter<IVRPProblemInstance>("ProblemInstance", "The VRP problem instance"));
     125      Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance."));
     126 
    99127      InitializeRandomVRPInstance();
    100128
    101       ParameterizeSolutionCreator();
    102       ParameterizeEvaluator();
    103 
    104       InitializeOperators();
    105129      AttachEventHandlers();
     130      AttachProblemInstanceEventHandlers();
    106131    }
    107132
    108133    public override IDeepCloneable Clone(Cloner cloner) {
    109134      VehicleRoutingProblem clone = (VehicleRoutingProblem)base.Clone(cloner);
    110       clone.operators = operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
    111135      clone.AttachEventHandlers();
    112136      return clone;
     
    140164    private void AfterDeserializationHook() {
    141165      AttachEventHandlers();
     166      AttachProblemInstanceEventHandlers();
    142167    }
    143168
    144169    private void AttachEventHandlers() {
    145      
    146     }
    147     private void InitializeOperators() {
    148       operators = new List<IOperator>();
    149       ParameterizeAnalyzer();
    150       //operators.AddRange(ApplicationManager.Manager.GetInstances<IVRPOperator>().Cast<IOperator>().OrderBy(op => op.Name));
    151       ParameterizeOperators();
    152       UpdateMoveEvaluators();
    153       InitializeMoveGenerators();
    154     }
    155     private void InitializeMoveGenerators() {
    156      
    157     }
    158     private void UpdateMoveEvaluators() {
    159       ParameterizeOperators();
    160       OnOperatorsChanged();
    161     }
    162     private void ParameterizeSolutionCreator() {
    163      
    164     }
    165     private void ParameterizeEvaluator() {
    166      
    167     }
    168     private void ParameterizeAnalyzer() {
    169      
    170     }
    171     private void ParameterizeOperators() {
    172      
    173     }
    174     private void ClearDistanceMatrix() {
    175      
     170      ProblemInstanceParameter.ValueChanged += new EventHandler(ProblemInstanceParameter_ValueChanged);
     171    }
     172
     173    private void AttachProblemInstanceEventHandlers() {
     174      if (ProblemInstance != null) {
     175        ProblemInstance.SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
     176        ProblemInstance.EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
     177      }
     178    }
     179
     180    void ProblemInstanceParameter_ValueChanged(object sender, EventArgs e) {
     181      AttachProblemInstanceEventHandlers();
     182    }
     183
     184    private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
     185      OnSolutionCreatorChanged();
     186    }
     187    private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
     188      OnEvaluatorChanged();
    176189    }
    177190    #endregion
     
    182195
    183196      this.Name = parser.ProblemName;
     197      CVRPTWProblemInstance problem = new CVRPTWProblemInstance();
     198     
     199      problem.Coordinates = new DoubleMatrix(parser.Coordinates);
     200      problem.Vehicles.Value = parser.Vehicles;
     201      problem.Capacity.Value = parser.Capacity;
     202      problem.Demand = new DoubleArray(parser.Demands);
     203      problem.ReadyTime = new DoubleArray(parser.Readytimes);
     204      problem.DueTime = new DoubleArray(parser.Duetimes);
     205      problem.ServiceTime = new DoubleArray(parser.Servicetimes);
     206
     207      this.ProblemInstance = problem;
    184208
    185209      OnReset();
     
    199223        throw new Exception("Invalid weight type");
    200224
     225      CVRPTWProblemInstance problem = new CVRPTWProblemInstance();
     226      problem.Coordinates = new DoubleMatrix(parser.Vertices);
     227      if (parser.Vehicles != -1)
     228        problem.Vehicles.Value = parser.Vehicles;
     229      else
     230        problem.Vehicles.Value = problemSize - 1;
     231      problem.Capacity.Value = parser.Capacity;
     232      problem.Demand = new DoubleArray(parser.Demands);
     233      problem.ReadyTime = new DoubleArray(problemSize);
     234      problem.DueTime = new DoubleArray(problemSize);
     235      problem.ServiceTime = new DoubleArray(problemSize);
     236
     237      for (int i = 0; i < problemSize; i++) {
     238        problem.ReadyTime[i] = 0;
     239        problem.DueTime[i] = int.MaxValue;
     240        problem.ServiceTime[i] = 0;
     241      }
     242
     243      if (parser.Distance != -1) {
     244        problem.DueTime[0] = parser.Distance;
     245      }
     246
     247      this.ProblemInstance = problem;
     248
    201249      OnReset();
    202250    }
     
    209257      int problemSize = parser.Demands.Length;
    210258
     259      CVRPProblemInstance problem = new CVRPProblemInstance();
     260
     261      problem.Coordinates = new DoubleMatrix(parser.Vertices);
     262      problem.Vehicles.Value = problemSize - 1;
     263      problem.Capacity.Value = parser.Capacity;
     264      problem.Demand = new DoubleArray(parser.Demands);
     265
     266      this.ProblemInstance = problem;
     267
    211268      OnReset();
    212269    }
     
    215272      System.Random rand = new System.Random();
    216273
     274      CVRPTWProblemInstance problem = new CVRPTWProblemInstance();
    217275      int cities = 100;
     276
     277      problem.Coordinates = new DoubleMatrix(cities + 1, 2);
     278      problem.Demand = new DoubleArray(cities + 1);
     279      problem.DueTime = new DoubleArray(cities + 1);
     280      problem.ReadyTime = new DoubleArray(cities + 1);
     281      problem.ServiceTime = new DoubleArray(cities + 1);
     282
     283      problem.Vehicles.Value = 100;
     284      problem.Capacity.Value = 200;
     285
     286      for (int i = 0; i <= cities; i++) {
     287        problem.Coordinates[i, 0] = rand.Next(0, 100);
     288        problem.Coordinates[i, 1] = rand.Next(0, 100);
     289
     290        if (i == 0) {
     291          problem.Demand[i] = 0;
     292          problem.DueTime[i] = Int16.MaxValue;
     293          problem.ReadyTime[i] = 0;
     294          problem.ServiceTime[i] = 0;
     295        } else {
     296          problem.Demand[i] = rand.Next(10, 50);
     297          problem.DueTime[i] = rand.Next((int)Math.Ceiling(problem.GetDistance(0, i)), 1200);
     298          problem.ReadyTime[i] = problem.DueTime[i] - rand.Next(0, 100);
     299          problem.ServiceTime[i] = 90;
     300        }
     301      }
     302
     303      this.ProblemInstance = problem;
    218304    }
    219305  }
Note: See TracChangeset for help on using the changeset viewer.