Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/14/14 15:27:11 (10 years ago)
Author:
pfleck
Message:

#2208

  • Implemented OrienteeringProblem as CVRPData ProblemInstanceInterpreter.
  • Added OrienteeringProblemView.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/OrienteeringProblem.cs

    r11187 r11189  
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Problems.Instances;
    3031
    3132namespace HeuristicLab.Problems.Orienteering {
     
    3637  public class OrienteeringProblem
    3738    : SingleObjectiveHeuristicOptimizationProblem<IOrienteeringEvaluator, IIntegerVectorCreator>,
    38     IStorableContent {
     39    IStorableContent, IProblemInstanceConsumer<CVRPData> {
    3940
    4041    public string Filename { get; set; }
     
    8586      set { UseDistanceMatrixParameter.Value = value; }
    8687    }
     88    public IntValue StartingPoint {
     89      get { return StartingPointParameter.Value; }
     90      set { StartingPointParameter.Value = value; }
     91    }
     92    public IntValue TerminusPoint {
     93      get { return TerminusPointParameter.Value; }
     94      set { TerminusPointParameter.Value = value; }
     95    }
    8796    public DoubleValue MaximumDistance {
    8897      get { return MaximumDistanceParameter.Value; }
     
    93102      set { ScoresParameter.Value = value; }
    94103    }
     104    public DoubleValue FixedPenalty {
     105      get { return FixedPenaltyParameter.Value; }
     106      set { FixedPenaltyParameter.Value = value; }
     107    }
    95108    public IntegerVector BestKnownSolution {
    96109      get { return BestKnownSolutionParameter.Value; }
     
    115128
    116129    public OrienteeringProblem()
    117       : base(new OrienteeringEvaluator(), new UniformRandomIntegerVectorCreator()) {
     130      : base(new OrienteeringEvaluator(), new UniformRandomIntegerVectorCreator()) { // TODO: Greedy route creator for solution creator
    118131      Parameters.Add(new OptionalValueParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the points."));
    119132      Parameters.Add(new OptionalValueParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the points."));
     
    197210      // TODO
    198211    }
     212
     213    public void Load(CVRPData data) {
     214      if (data.Coordinates == null && data.Distances == null)
     215        throw new System.IO.InvalidDataException("The given instance specifies neither coordinates nor distances!");
     216      if (data.Coordinates != null && data.Coordinates.GetLength(1) != 2)
     217        throw new System.IO.InvalidDataException("The coordinates of the given instance are not in the right format, there need to be one row for each customer and two columns for the x and y coordinates.");
     218
     219      Name = data.Name;
     220      Description = data.Description;
     221
     222      Coordinates = data.Coordinates != null ? new DoubleMatrix(data.Coordinates) : null;
     223      UseDistanceMatrix.Value = data.Distances != null;
     224      DistanceMatrix = data.Distances != null ? new DistanceMatrix(data.Distances) : null;
     225      StartingPoint = new IntValue(0);// Depot is interpreted as start and endpoint (default)
     226      TerminusPoint = new IntValue(0);
     227
     228      MaximumDistance = new DoubleValue(data.Capacity); // capacity is interpreted as max distance
     229      Scores = new DoubleArray(data.Demands); // demands are interpreted as scores
     230
     231      BestKnownQuality = null;
     232      BestKnownSolution = null;
     233    }
    199234  }
    200235}
Note: See TracChangeset for help on using the changeset viewer.