Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 15802 was 8516, checked in by spimming, 12 years ago

#1894:

  • solution restructured
  • removed obsolete and outdated parts
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.Data.Osm;
30using HeuristicLab.Problems.RoutePlanning.Interfaces;
31
32namespace HeuristicLab.Problems.RoutePlanning {
33  [Item("Route Planning Problem", "Represents a Route Planning Problem.")]
34  [Creatable("Problems")]
35  [StorableClass]
36  public class RoutePlanningProblem : Problem {
37    private const string CoordinatesParameterName = "Coordinates";
38    private const string SourceParameterName = "Source";
39    private const string TargetParameterName = "Target";
40    public string Filename { get; set; }
41
42    IDataSource dataSource;
43    IGraph graph;
44
45    #region Parameter Properties
46
47    public OptionalValueParameter<DoubleMatrix> CoordinatesParameter {
48      get { return (OptionalValueParameter<DoubleMatrix>)Parameters[CoordinatesParameterName]; }
49    }
50    public ValueParameter<IntValue> SourceParameter {
51      get { return (ValueParameter<IntValue>)Parameters[SourceParameterName]; }
52    }
53    public ValueParameter<IntValue> TargetParameter {
54      get { return (ValueParameter<IntValue>)Parameters[TargetParameterName]; }
55    }
56
57    #endregion
58
59    #region Properties
60
61    public DoubleMatrix Coordinates {
62      get { return CoordinatesParameter.Value; }
63      set { CoordinatesParameter.Value = value; }
64    }
65
66    public IntValue Source {
67      get { return SourceParameter.Value; }
68      set { SourceParameter.Value = value; }
69    }
70
71    public IntValue Target {
72      get { return TargetParameter.Value; }
73      set { TargetParameter.Value = value; }
74    }
75
76    #endregion
77
78    #region Constructors
79
80    [StorableConstructor]
81    private RoutePlanningProblem(bool deserializing) : base(deserializing) { }
82
83    private RoutePlanningProblem(RoutePlanningProblem original, Cloner cloner)
84      : base(original, cloner) {
85      RegisterEventHandlers();
86    }
87
88    public override IDeepCloneable Clone(Cloner cloner) {
89      return new RoutePlanningProblem(this, cloner);
90    }
91
92    public RoutePlanningProblem() {
93      Parameters.Add(new OptionalValueParameter<DoubleMatrix>(CoordinatesParameterName, "The x- and y-Coordinates of the cities."));
94      Parameters.Add(new ValueParameter<IntValue>(SourceParameterName, "Source Node."));
95      Parameters.Add(new ValueParameter<IntValue>(TargetParameterName, "Target Node."));
96
97      RegisterEventHandlers();
98    }
99
100    #endregion
101
102    private void RegisterEventHandlers() { }
103
104    public void LoadData(string file) {
105      FileInfo f = new FileInfo(file);
106      dataSource = new OsmDataSource(file);
107      graph = dataSource.GetRoutingGraph();
108
109      Name = f.Name;
110
111      OnReset();
112    }
113
114  }
115}
Note: See TracBrowser for help on using the repository browser.