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 |
|
---|
22 | using System.IO;
|
---|
23 | using HeuristicLab.Common;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Data;
|
---|
26 | using HeuristicLab.Optimization;
|
---|
27 | using HeuristicLab.Parameters;
|
---|
28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
29 | using HeuristicLab.Problems.RoutePlanning.Graph;
|
---|
30 | using HeuristicLab.Problems.RoutePlanning.Osm;
|
---|
31 | using HeuristicLab.Problems.RoutePlanning.Osm.Data;
|
---|
32 |
|
---|
33 | namespace 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 | }
|
---|