Free cookie consent management tool by TermsFeed Policy Generator

source: branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/RoutePlanningProblem.cs @ 8508

Last change on this file since 8508 was 8429, checked in by spimming, 12 years ago

#1894

  • renamed Graph to OsmGraph
  • generic type in edge interface
File size: 3.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System.IO;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Optimization;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29using HeuristicLab.Problems.RoutePlanning.Graph;
30using HeuristicLab.Problems.RoutePlanning.Osm;
31using HeuristicLab.Problems.RoutePlanning.Osm.Data;
32
33namespace HeuristicLab.Problems.RoutePlanning {
34  [Item("Route Planning Problem", "Represents a Route Planning Problem.")]
35  [Creatable("Problems")]
36  [StorableClass]
37  public class RoutePlanningProblem : Problem {
38    private const string CoordinatesParameterName = "Coordinates";
39    private const string SourceParameterName = "Source";
40    private const string TargetParameterName = "Target";
41    public string Filename { get; set; }
42
43    IDataSource dataSource;
44    OsmGraph graph;
45
46    #region Parameter Properties
47
48    public OptionalValueParameter<DoubleMatrix> CoordinatesParameter {
49      get { return (OptionalValueParameter<DoubleMatrix>)Parameters[CoordinatesParameterName]; }
50    }
51    public ValueParameter<IntValue> SourceParameter {
52      get { return (ValueParameter<IntValue>)Parameters[SourceParameterName]; }
53    }
54    public ValueParameter<IntValue> TargetParameter {
55      get { return (ValueParameter<IntValue>)Parameters[TargetParameterName]; }
56    }
57
58    #endregion
59
60    #region Properties
61
62    public DoubleMatrix Coordinates {
63      get { return CoordinatesParameter.Value; }
64      set { CoordinatesParameter.Value = value; }
65    }
66
67    public IntValue Source {
68      get { return SourceParameter.Value; }
69      set { SourceParameter.Value = value; }
70    }
71
72    public IntValue Target {
73      get { return TargetParameter.Value; }
74      set { TargetParameter.Value = value; }
75    }
76
77    #endregion
78
79    #region Constructors
80
81    [StorableConstructor]
82    private RoutePlanningProblem(bool deserializing) : base(deserializing) { }
83
84    private RoutePlanningProblem(RoutePlanningProblem original, Cloner cloner)
85      : base(original, cloner) {
86      RegisterEventHandlers();
87    }
88
89    public override IDeepCloneable Clone(Cloner cloner) {
90      return new RoutePlanningProblem(this, cloner);
91    }
92
93    public RoutePlanningProblem() {
94      Parameters.Add(new OptionalValueParameter<DoubleMatrix>(CoordinatesParameterName, "The x- and y-Coordinates of the cities."));
95      Parameters.Add(new ValueParameter<IntValue>(SourceParameterName, "Source Node."));
96      Parameters.Add(new ValueParameter<IntValue>(TargetParameterName, "Target Node."));
97
98      RegisterEventHandlers();
99    }
100
101    #endregion
102
103    private void RegisterEventHandlers() { }
104
105    public void LoadData(string file) {
106      FileInfo f = new FileInfo(file);
107      dataSource = new XmlDataSource(file);
108      graph = new OsmGraph(dataSource);
109
110      Name = f.Name;
111
112      OnReset();
113    }
114
115  }
116}
Note: See TracBrowser for help on using the repository browser.