Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11187


Ignore:
Timestamp:
07/14/14 13:21:16 (10 years ago)
Author:
pfleck
Message:

#2208

  • Added Operators in Problem.
  • Implemented simple OrienteeringEvaluator.
Location:
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3
Files:
1 added
3 edited

Legend:

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

    r11186 r11187  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Data;
     25using HeuristicLab.Encodings.IntegerVectorEncoding;
    2526using HeuristicLab.Operators;
    2627using HeuristicLab.Parameters;
     
    3132    public ILookupParameter<DoubleValue> QualityParameter {
    3233      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
     34    }
     35    public ILookupParameter<IntegerVector> SolutionParameter {
     36      get { return (ILookupParameter<IntegerVector>)Parameters["Solution"]; }
     37    }
     38    public ILookupParameter<DoubleArray> ScoresParameter {
     39      get { return (ILookupParameter<DoubleArray>)Parameters["Scores"]; }
    3340    }
    3441
     
    4653      : base() {
    4754      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The evaluated quality of the Orienteering solution."));
    48       // TODO
     55      Parameters.Add(new LookupParameter<IntegerVector>("Solution", "The Orienteering Solution given in path representation."));
     56      Parameters.Add(new LookupParameter<DoubleArray>("Scores", "The scores of the points."));
    4957    }
    5058
    51     public struct OrienteeringEvaluation {
     59    public class OrienteeringEvaluation {
    5260      public DoubleValue Quality;
    5361    }
    5462
    55     public static OrienteeringEvaluation Apply() {
    56       // TODO
    57       return default(OrienteeringEvaluation);
     63    public static OrienteeringEvaluation Apply(IntegerVector solution, DoubleArray scores) {
     64      // TODO distance penalty
     65      double score = 0.0;
     66
     67      for (int i = 0; i < solution.Length; i++) {
     68        score += scores[i];
     69      }
     70
     71      return new OrienteeringEvaluation {
     72        Quality = new DoubleValue(score)
     73      };
    5874    }
    5975
    6076    public override IOperation InstrumentedApply() {
    61       // TODO
    62       var evaluation = Apply();
     77      var evaluation = Apply(SolutionParameter.ActualValue, ScoresParameter.ActualValue);
     78
     79      QualityParameter.ActualValue = evaluation.Quality;
    6380
    6481      return base.InstrumentedApply();
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/HeuristicLab.Problems.Orienteering-3.3.csproj

    r11186 r11187  
    4646  </ItemGroup>
    4747  <ItemGroup>
     48    <Compile Include="DistanceMatrix.cs" />
    4849    <Compile Include="Interfaces\IOrienteeringEvaluator.cs" />
    4950    <Compile Include="Evaluators\OrienteeringEvaluator.cs" />
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/OrienteeringProblem.cs

    r11186 r11187  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Data;
    2526using HeuristicLab.Encodings.IntegerVectorEncoding;
    2627using HeuristicLab.Optimization;
     28using HeuristicLab.Parameters;
    2729using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2830
     
    3840    public string Filename { get; set; }
    3941
     42    #region Parameter Properties
     43    public OptionalValueParameter<DoubleMatrix> CoordinatesParameter {
     44      get { return (OptionalValueParameter<DoubleMatrix>)Parameters["Coordinates"]; }
     45    }
     46    public OptionalValueParameter<DistanceMatrix> DistanceMatrixParameter {
     47      get { return (OptionalValueParameter<DistanceMatrix>)Parameters["DistanceMatrix"]; }
     48    }
     49    public ValueParameter<BoolValue> UseDistanceMatrixParameter {
     50      get { return (ValueParameter<BoolValue>)Parameters["UseDistanceMatrix"]; }
     51    }
     52
     53    public ValueParameter<IntValue> StartingPointParameter {
     54      get { return (ValueParameter<IntValue>)Parameters["StartingPoint"]; }
     55    }
     56    public ValueParameter<IntValue> TerminusPointParameter {
     57      get { return (ValueParameter<IntValue>)Parameters["TerminusPoint"]; }
     58    }
     59    public ValueParameter<DoubleValue> MaximumDistanceParameter {
     60      get { return (ValueParameter<DoubleValue>)Parameters["MaximumDistance"]; }
     61    }
     62    public ValueParameter<DoubleArray> ScoresParameter {
     63      get { return (ValueParameter<DoubleArray>)Parameters["Scores"]; }
     64    }
     65    public ValueParameter<DoubleValue> FixedPenaltyParameter {
     66      get { return (ValueParameter<DoubleValue>)Parameters["FixedPenalty"]; }
     67    }
     68
     69    public OptionalValueParameter<IntegerVector> BestKnownSolutionParameter {
     70      get { return (OptionalValueParameter<IntegerVector>)Parameters["BestKnownSolution"]; }
     71    }
     72    #endregion
     73
     74    #region Properties
     75    public DoubleMatrix Coordinates {
     76      get { return CoordinatesParameter.Value; }
     77      set { CoordinatesParameter.Value = value; }
     78    }
     79    public DistanceMatrix DistanceMatrix {
     80      get { return DistanceMatrixParameter.Value; }
     81      set { DistanceMatrixParameter.Value = value; }
     82    }
     83    public BoolValue UseDistanceMatrix {
     84      get { return UseDistanceMatrixParameter.Value; }
     85      set { UseDistanceMatrixParameter.Value = value; }
     86    }
     87    public DoubleValue MaximumDistance {
     88      get { return MaximumDistanceParameter.Value; }
     89      set { MaximumDistanceParameter.Value = value; }
     90    }
     91    public DoubleArray Scores {
     92      get { return ScoresParameter.Value; }
     93      set { ScoresParameter.Value = value; }
     94    }
     95    public IntegerVector BestKnownSolution {
     96      get { return BestKnownSolutionParameter.Value; }
     97      set { BestKnownSolutionParameter.Value = value; }
     98    }
     99    #endregion
     100
    40101    [StorableConstructor]
    41102    private OrienteeringProblem(bool deserializing)
     
    55116    public OrienteeringProblem()
    56117      : base(new OrienteeringEvaluator(), new UniformRandomIntegerVectorCreator()) {
    57       // TODO: Parameters
     118      Parameters.Add(new OptionalValueParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the points."));
     119      Parameters.Add(new OptionalValueParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the points."));
     120      Parameters.Add(new ValueParameter<BoolValue>("UseDistanceMatrix", "True if the coordinates based evaluators should calculate the distance matrix from the coordinates and use it for evaluation similar to the distance matrix evaluator, otherwise false.", new BoolValue(true)));
     121      Parameters.Add(new ValueParameter<IntValue>("StartingPoint", "Index of the starting point.", new IntValue(0)));
     122      Parameters.Add(new ValueParameter<IntValue>("TerminusPoint", "Index of the ending point.", new IntValue(0)));
     123      Parameters.Add(new ValueParameter<DoubleValue>("MaximumDistance", "The maximum distance constraint for a Orienteering solution."));
     124      Parameters.Add(new ValueParameter<DoubleArray>("Scores", "The scores of the points.", new DoubleArray()));
     125      Parameters.Add(new ValueParameter<DoubleValue>("FixedPenalty", "The penalty for each visited vertex."));
     126      Parameters.Add(new OptionalValueParameter<IntegerVector>("BestKnownSolution", "The best known solution of this Orienteering instance."));
    58127
    59128      Maximization.Value = true;
     
    71140    }
    72141
    73     #region events
     142    #region Events
    74143    protected override void OnSolutionCreatorChanged() {
    75144      base.OnSolutionCreatorChanged();
     
    100169    private void RegisterEventHandlers() {
    101170      SolutionCreator.IntegerVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_IntegerVectorParameter_ActualNameChanged);
     171      // TODO
    102172    }
    103173    private void ParameterizeSolutionCreator() {
    104       // TODO
     174      if (SolutionCreator.LengthParameter.Value == null
     175          || SolutionCreator.LengthParameter.Value.Value != Scores.Length) {
     176        SolutionCreator.LengthParameter.Value = new IntValue(Scores.Length);
     177      }
    105178    }
    106179    private void ParameterizeEvaluator() {
     
    111184    }
    112185    private void ParameterizeAnalyzer() {
    113       // TODO 
     186      // TODO
    114187    }
    115188    private void InitializeOperators() {
Note: See TracChangeset for help on using the changeset viewer.