Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11190


Ignore:
Timestamp:
07/15/14 09:16:57 (10 years ago)
Author:
pfleck
Message:

#2208

  • Added BestOrienteeringSolutionAnalyser
  • Added OrienteeringSolution
  • Implemented InitializeInitialOrienteeringInstance
Location:
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/HeuristicLab.Problems.Orienteering-3.3.csproj

    r11189 r11190  
    4646  </ItemGroup>
    4747  <ItemGroup>
     48    <Compile Include="Analyzers\BestOrienteeringSolutionAnalyser.cs" />
    4849    <Compile Include="DistanceMatrix.cs" />
    4950    <Compile Include="Interfaces\IOrienteeringEvaluator.cs" />
     
    5152    <Compile Include="OrienteeringProblem.cs" />
    5253    <Compile Include="OrienteeringScript.cs" />
     54    <Compile Include="OrienteeringSolution.cs" />
    5355    <Compile Include="Plugin.cs" />
    5456    <Compile Include="Properties\AssemblyInfo.cs" />
     
    6769      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
    6870      <Name>HeuristicLab.Collections-3.3</Name>
     71    </ProjectReference>
     72    <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">
     73      <Project>{0e27a536-1c4a-4624-a65e-dc4f4f23e3e1}</Project>
     74      <Name>HeuristicLab.Common.Resources-3.3</Name>
    6975    </ProjectReference>
    7076    <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
     
    120126    </ProjectReference>
    121127  </ItemGroup>
     128  <ItemGroup />
    122129  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    123130  <PropertyGroup>
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/OrienteeringProblem.cs

    r11189 r11190  
    2121
    2222using System;
     23using System.Linq;
     24using HeuristicLab.Analysis;
    2325using HeuristicLab.Common;
    2426using HeuristicLab.Core;
     
    110112      set { BestKnownSolutionParameter.Value = value; }
    111113    }
     114    private BestOrienteeringSolutionAnalyser BestOrienteeringSolutionAnalyser {
     115      get { return Operators.OfType<BestOrienteeringSolutionAnalyser>().SingleOrDefault(); }
     116    }
     117    private SingleObjectivePopulationDiversityAnalyzer SingleObjectivePopulationDiversityAnalyzer {
     118      get { return Operators.OfType<SingleObjectivePopulationDiversityAnalyzer>().SingleOrDefault(); }
     119    }
    112120    #endregion
    113121
     
    116124      : base(deserializing) {
    117125    }
    118 
    119126    private OrienteeringProblem(OrienteeringProblem original, Cloner cloner)
    120127      : base(original, cloner) {
    121128      RegisterEventHandlers();
    122129    }
    123 
    124130    public override IDeepCloneable Clone(Cloner cloner) {
    125131      return new OrienteeringProblem(this, cloner);
    126132    }
    127 
    128 
    129133    public OrienteeringProblem()
    130134      : base(new OrienteeringEvaluator(), new UniformRandomIntegerVectorCreator()) { // TODO: Greedy route creator for solution creator
     
    144148      SolutionCreator.IntegerVectorParameter.ActualName = "OrienteeringSolution";
    145149
    146       InitializeRandomOrienteeringInstance();
     150      InitializeInitialOrienteeringInstance();
    147151
    148152      ParameterizeSolutionCreator();
     
    156160    protected override void OnSolutionCreatorChanged() {
    157161      base.OnSolutionCreatorChanged();
    158       SolutionCreator.IntegerVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_IntegerVectorParameter_ActualNameChanged);
     162      SolutionCreator.IntegerVectorParameter.ActualNameChanged += SolutionCreator_IntegerVectorParameter_ActualNameChanged;
    159163      ParameterizeSolutionCreator();
    160164      ParameterizeEvaluator();
     
    171175      ParameterizeAnalyzer();
    172176      ParameterizeOperators();
     177    }
     178    private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
     179      if (Coordinates != null) {
     180        Coordinates.ItemChanged += new EventHandler<EventArgs<int, int>>(CoordinatesValue_ItemChanged);
     181        Coordinates.Reset += new EventHandler(CoordinatesValue_Reset);
     182      }
     183      ParameterizeSolutionCreator();
     184      DistanceMatrix = null;
     185    }
     186    private void CoordinatesValue_ItemChanged(object sender, EventArgs<int, int> e) {
     187      DistanceMatrix = null;
     188    }
     189    private void CoordinatesValue_Reset(object sender, EventArgs e) {
     190      ParameterizeSolutionCreator();
     191      DistanceMatrix = null;
     192    }
     193    private void StartingPointParameter_ValueChanged(object sender, EventArgs e) {
     194      ParameterizeEvaluator();
     195      ParameterizeAnalyzer();
     196    }
     197
     198    private void TerminusPointParameter_ValueChanged(object sender, EventArgs e) {
     199      ParameterizeEvaluator();
     200      ParameterizeAnalyzer();
     201    }
     202    private void MaximumDistanceParameter_ValueChanged(object sender, EventArgs e) {
     203      ParameterizeEvaluator();
     204      ParameterizeAnalyzer();
     205    }
     206    private void ScoresParameter_ValueChanged(object sender, EventArgs e) {
     207      ParameterizeEvaluator();
     208      ParameterizeAnalyzer();
     209      ParameterizeSolutionCreator();
     210
     211      ScoresParameter.Value.Reset += new EventHandler(ScoresValue_Reset);
     212    }
     213    private void ScoresValue_Reset(object sender, EventArgs e) {
     214      ParameterizeSolutionCreator();
     215    }
     216    private void FixedPenaltyParameter_ValueChanged(object sender, EventArgs e) {
     217      ParameterizeEvaluator();
     218      ParameterizeAnalyzer();
    173219    }
    174220    #endregion
     
    181227
    182228    private void RegisterEventHandlers() {
    183       SolutionCreator.IntegerVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_IntegerVectorParameter_ActualNameChanged);
    184       // TODO
    185     }
     229      SolutionCreator.IntegerVectorParameter.ActualNameChanged += SolutionCreator_IntegerVectorParameter_ActualNameChanged;
     230
     231      CoordinatesParameter.ValueChanged += CoordinatesParameter_ValueChanged;
     232      if (CoordinatesParameter.Value != null) {
     233        CoordinatesParameter.Value.ItemChanged += CoordinatesValue_ItemChanged;
     234        CoordinatesParameter.Value.Reset += CoordinatesValue_Reset;
     235      }
     236
     237      StartingPointParameter.ValueChanged += StartingPointParameter_ValueChanged;
     238      TerminusPointParameter.ValueChanged += TerminusPointParameter_ValueChanged;
     239      MaximumDistanceParameter.ValueChanged += MaximumDistanceParameter_ValueChanged;
     240
     241      ScoresParameter.ValueChanged += ScoresParameter_ValueChanged;
     242      ScoresParameter.Value.Reset += ScoresValue_Reset;
     243      FixedPenaltyParameter.ValueChanged += FixedPenaltyParameter_ValueChanged;
     244    }
     245
    186246    private void ParameterizeSolutionCreator() {
    187       if (SolutionCreator.LengthParameter.Value == null
    188           || SolutionCreator.LengthParameter.Value.Value != Scores.Length) {
    189         SolutionCreator.LengthParameter.Value = new IntValue(Scores.Length);
     247      if (SolutionCreator is UniformRandomIntegerVectorCreator) {
     248        if (SolutionCreator.LengthParameter.Value == null || SolutionCreator.LengthParameter.Value.Value != Scores.Length) {
     249          SolutionCreator.LengthParameter.Value = new IntValue(Scores.Length);
     250        }
    190251      }
    191252    }
     
    193254      if (Evaluator is OrienteeringEvaluator) {
    194255        var orienteeringEvaluator = (OrienteeringEvaluator)Evaluator;
    195         // TODO
     256        orienteeringEvaluator.SolutionParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName;
     257        orienteeringEvaluator.ScoresParameter.ActualName = ScoresParameter.Name;
    196258      }
    197259    }
     
    200262    }
    201263    private void InitializeOperators() {
    202       // TODO 
     264      // TODO
    203265    }
    204266    private void ParameterizeOperators() {
     
    207269    #endregion
    208270
    209     private void InitializeRandomOrienteeringInstance() {
    210       // TODO
     271    private void InitializeInitialOrienteeringInstance() {
     272      Coordinates = new DoubleMatrix(new double[21, 2] {
     273        {  4.60,  7.10 }, {  5.70, 11.40 }, {  4.40, 12.30 }, {  2.80, 14.30 }, {  3.20, 10.30 },
     274        {  3.50,  9.80 }, {  4.40,  8.40 }, {  7.80, 11.00 }, {  8.80,  9.80 }, {  7.70,  8.20 },
     275        {  6.30,  7.90 }, {  5.40,  8.20 }, {  5.80,  6.80 }, {  6.70,  5.80 }, { 13.80, 13.10 },
     276        { 14.10, 14.20 }, { 11.20, 13.60 }, {  9.70, 16.40 }, {  9.50, 18.80 }, {  4.70, 16.80 },
     277        {  5.00,  5.60 }
     278      });
     279      UseDistanceMatrix.Value = false;
     280
     281      StartingPoint.Value = 0;
     282      TerminusPoint.Value = 20;
     283      MaximumDistance.Value = 30;
     284
     285      Scores = new DoubleArray(new double[21] { 0, 20, 20, 30, 15, 15, 10, 20, 20, 20, 15, 10, 10, 25, 40, 40, 30, 30, 50, 30, 0 });
    211286    }
    212287
Note: See TracChangeset for help on using the changeset viewer.