Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4365 for branches/VRP


Ignore:
Timestamp:
09/06/10 17:05:13 (14 years ago)
Author:
svonolfe
Message:

Worked on VRP operators (WIP) (#1177)

Location:
branches/VRP
Files:
23 added
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/HeuristicLabProblemsVehicleRoutingViewsPlugin.cs

    r4363 r4365  
    2626  /// Plugin class for HeuristicLab.Problems.VehicleRouting.Views plugin
    2727  /// </summary>
    28   [Plugin("HeuristicLab.Problems.VehicleRouting.Views", "3.4.0.4362")]
     28  [Plugin("HeuristicLab.Problems.VehicleRouting.Views", "3.4.0.4363")]
    2929  [PluginFile("HeuristicLab.Problems.VehicleRouting.Views-3.4.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Collections", "3.3")]
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/DefaultRepresentationCreator.cs

    r4363 r4365  
    4242    public override IOperation Apply() {
    4343      //choose default encoding here
    44       //VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(CreateSolution());
     44      VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(CreateSolution(), ProblemInstance);
    4545
    4646      return base.Apply();
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/VRPOperator.cs

    r4362 r4365  
    3434  [StorableClass]
    3535  public abstract class VRPOperator : SingleSuccessorOperator, IVRPOperator {
    36     protected LookupParameter<IVRPProblemInstance> ProblemInstanceParameter {
     36    public ILookupParameter<IVRPProblemInstance> ProblemInstanceParameter {
    3737      get { return (LookupParameter<IVRPProblemInstance>)Parameters["ProblemInstance"]; }
    3838    }
    3939
    40     protected IVRPProblemInstance ProblemInstance {
     40    public IVRPProblemInstance ProblemInstance {
    4141      get { return ProblemInstanceParameter.ActualValue; }
    4242    }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj

    r4363 r4365  
    106106  </ItemGroup>
    107107  <ItemGroup>
     108    <Compile Include="Encodings\Alba\AlbaEncoding.cs" />
    108109    <Compile Include="Encodings\Alba\Creators\DefaultRepresentationCreator.cs" />
     110    <Compile Include="Encodings\Alba\Creators\PushForwardInsertionCreator.cs" />
    109111    <Compile Include="Encodings\Alba\Creators\RandomCreator.cs" />
    110112    <Compile Include="Encodings\Alba\Creators\AlbaCreator.cs" />
    111113    <Compile Include="Encodings\Alba\AlbaOperator.cs" />
     114    <Compile Include="Encodings\Alba\Crossovers\AlbaCrossover.cs" />
     115    <Compile Include="Encodings\Alba\Crossovers\AlbaPermutationCrossover.cs" />
     116    <Compile Include="Encodings\Alba\Manipulators\AlbaCustomerInsertionManipulator.cs" />
     117    <Compile Include="Encodings\Alba\Manipulators\AlbaCustomerInversionManipulator.cs" />
     118    <Compile Include="Encodings\Alba\Manipulators\AlbaCustomerSwapManipulator.cs" />
     119    <Compile Include="Encodings\Alba\Manipulators\AlbaIntraRouteInversionManipulator.cs" />
     120    <Compile Include="Encodings\Alba\Manipulators\AlbaLambdaInterchangeManipulator.cs" />
     121    <Compile Include="Encodings\Alba\Manipulators\AlbaManipulator.cs" />
     122    <Compile Include="Encodings\Alba\Manipulators\AlbaPermutationManipulator.cs" />
     123    <Compile Include="Encodings\General\Creators\MultiVRPSolutionCreator.cs" />
     124    <Compile Include="Encodings\General\Crossovers\MultiVRPSolutionCrossover.cs" />
     125    <Compile Include="Encodings\General\Crossovers\RandomParentCloneCrossover.cs" />
     126    <Compile Include="Encodings\General\Manipulators\MultiVRPSolutionManipulator.cs" />
     127    <Compile Include="Encodings\General\PermutationEncoding.cs" />
     128    <Compile Include="Encodings\General\TourEncoding.cs" />
    112129    <Compile Include="Encodings\VRPOperator.cs" />
    113     <Compile Include="Encodings\VRPEncoding.cs" />
     130    <Compile Include="Interfaces\IMultiVRPOperator.cs" />
     131    <Compile Include="Interfaces\IVRPManipulator.cs" />
     132    <Compile Include="Interfaces\IVRPCrossover.cs" />
    114133    <Compile Include="Interfaces\IVRPEvaluator.cs" />
    115134    <Compile Include="Interfaces\IVRPCreator.cs" />
     
    123142    <Compile Include="Variants\Capacitated\Homogenous\ICapacitatedOperator.cs" />
    124143    <Compile Include="Variants\Capacitated\Homogenous\ICapacitatedProblemInstance.cs" />
     144    <Compile Include="Variants\General\IGeneralVRPOperator.cs" />
    125145    <Compile Include="Variants\SingleDepot\ISingleDepotOperator.cs" />
    126146    <Compile Include="Variants\SingleDepot\ISingleDepotEncoding.cs" />
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLabProblemsVehicleRoutingPlugin.cs

    r4363 r4365  
    2626  /// Plugin class for HeuristicLab.Problems.VehicleRouting plugin
    2727  /// </summary>
    28   [Plugin("HeuristicLab.Problems.VehicleRouting", "3.4.0.4362")]
     28  [Plugin("HeuristicLab.Problems.VehicleRouting", "3.4.0.4363")]
    2929  [PluginFile("HeuristicLab.Problems.VehicleRouting-3.4.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Analysis", "3.3")]
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPOperator.cs

    r4362 r4365  
    2828namespace HeuristicLab.Problems.VehicleRouting.Interfaces {
    2929  public interface IVRPOperator: IItem {
     30    ILookupParameter<IVRPProblemInstance> ProblemInstanceParameter { get; }
    3031  }
    3132}
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/SingleDepotVRPProblemInstance.cs

    r4363 r4365  
    4343    }
    4444
     45    public override IntValue Cities {
     46      get {
     47        return new IntValue(Demand.Length - 1);
     48      }
     49    }
     50
    4551    protected override IVRPEvaluator Evaluator {
    4652      get {
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPEvaluator.cs

    r4363 r4365  
    124124
    125125    public override IOperation Apply() {
     126      double quality = 0;
    126127      InitResultParameters();
    127128
    128129      foreach (Tour tour in VRPToursParameter.ActualValue.GetTours()) {
    129130        VRPEvaluation tourEvaluation = EvaluateTour(ProblemInstance, tour);
     131        quality += tourEvaluation.Quality;
    130132
    131133        UpdateResultParameters(tourEvaluation);
    132134      }
     135
     136      QualityParameter.ActualValue = new DoubleValue(quality);
    133137
    134138      return base.Apply();
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs

    r4363 r4365  
    8989      set { DemandParameter.Value = value; }
    9090    }
    91     public IntValue Cities {
     91    public virtual IntValue Cities {
    9292      get { return new IntValue(Demand.Length); }
    9393    }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs

    r4362 r4365  
    3535using HeuristicLab.Problems.VehicleRouting.Parsers;
    3636using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
     37using HeuristicLab.Problems.VehicleRouting.Variants;
    3738
    3839namespace HeuristicLab.Problems.VehicleRouting {
     
    6162      get { return BestKnownQualityParameter; }
    6263    }
    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       }
     64    public IValueParameter<IVRPCreator> SolutionCreatorParameter {
     65      get { return (IValueParameter<IVRPCreator>)Parameters["SolutionCreator"]; }
     66    }
     67    IParameter IProblem.SolutionCreatorParameter {
     68      get { return SolutionCreatorParameter; }
     69    }
     70    public IValueParameter<IVRPEvaluator> EvaluatorParameter {
     71      get { return (IValueParameter<IVRPEvaluator>)Parameters["Evaluator"]; }
     72    }
     73    IParameter IProblem.EvaluatorParameter {
     74      get { return EvaluatorParameter; }
    7875    }
    7976    #endregion
     
    8683
    8784    public ISingleObjectiveEvaluator Evaluator {
    88       get {
    89         if (ProblemInstance != null)
    90           return ProblemInstance.EvaluatorParameter.Value;
    91         else
    92           return null;
    93       }
     85      get { return ProblemInstance.EvaluatorParameter.Value; }
    9486    }
    9587
     
    9991
    10092    public ISolutionCreator SolutionCreator {
    101       get {
    102         if (ProblemInstance != null)
    103           return ProblemInstance.SolutionCreatorParameter.Value;
    104         else
    105           return null;
    106       }
    107     }
     93      get { return ProblemInstance.SolutionCreatorParameter.Value; }
     94    }
     95
     96    [Storable]
     97    private List<IOperator> operators;
    10898
    10999    public IEnumerable<IOperator> Operators {
    110       get {
    111         if (ProblemInstance != null)
    112           return ProblemInstance.Operators.OrderBy(op => op.Name);
    113         else
    114           return null;
    115       }
     100      get { return operators; }
    116101    }
    117102    #endregion
     
    124109      Parameters.Add(new ValueParameter<IVRPProblemInstance>("ProblemInstance", "The VRP problem instance"));
    125110      Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance."));
    126  
     111
     112      operators = new List<IOperator>();
     113
    127114      InitializeRandomVRPInstance();
     115      InitializeOperators();
    128116
    129117      AttachEventHandlers();
     
    133121    public override IDeepCloneable Clone(Cloner cloner) {
    134122      VehicleRoutingProblem clone = (VehicleRoutingProblem)base.Clone(cloner);
     123      clone.operators = operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
    135124      clone.AttachEventHandlers();
    136125      return clone;
     
    172161
    173162    private void AttachProblemInstanceEventHandlers() {
     163      if (Parameters.ContainsKey("Evaluator"))
     164        Parameters.Remove("Evaluator");
     165
     166      if (Parameters.ContainsKey("SolutionCreator"))
     167        Parameters.Remove("SolutionCreator");
     168
    174169      if (ProblemInstance != null) {
    175170        ProblemInstance.SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    176171        ProblemInstance.EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
     172        Parameters.Add(ProblemInstance.EvaluatorParameter);
     173        Parameters.Add(ProblemInstance.SolutionCreatorParameter);
    177174      }
    178175    }
     
    180177    void ProblemInstanceParameter_ValueChanged(object sender, EventArgs e) {
    181178      AttachProblemInstanceEventHandlers();
    182     }
    183 
     179      InitializeOperators();
     180
     181      OnSolutionCreatorChanged();
     182      OnEvaluatorChanged();
     183      OnOperatorsChanged();
     184    }
    184185    private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
     186      ParameterizeSolutionCreator();
     187     
    185188      OnSolutionCreatorChanged();
    186189    }
    187190    private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
    188191      OnEvaluatorChanged();
     192    }
     193
     194    private void InitializeOperators() {
     195      operators = new List<IOperator>();
     196
     197      if (ProblemInstance != null) {
     198        operators.AddRange(
     199        ProblemInstance.Operators.Concat(
     200          ApplicationManager.Manager.GetInstances<IGeneralVRPOperator>().Cast<IOperator>()).OrderBy(op => op.Name));
     201      }
     202
     203      ParameterizeOperators();
     204    }
     205
     206    private void ParameterizeSolutionCreator() {
     207      if (SolutionCreator is IMultiVRPOperator) {
     208        (SolutionCreator as IMultiVRPOperator).SetOperators(Operators);
     209      }
     210    }
     211
     212    private void ParameterizeOperators() {
     213      foreach (IOperator op in Operators) {
     214        if (op is IMultiVRPOperator) {
     215          (op as IMultiVRPOperator).SetOperators(Operators);
     216        }
     217      }
    189218    }
    190219    #endregion
Note: See TracChangeset for help on using the changeset viewer.