[8285] | 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 |
|
---|
[8301] | 22 | using System.IO;
|
---|
[8285] | 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;
|
---|
[8516] | 29 | using HeuristicLab.Problems.RoutePlanning.Data.Osm;
|
---|
| 30 | using HeuristicLab.Problems.RoutePlanning.Interfaces;
|
---|
[8285] | 31 |
|
---|
| 32 | namespace 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";
|
---|
[8301] | 38 | private const string SourceParameterName = "Source";
|
---|
| 39 | private const string TargetParameterName = "Target";
|
---|
[8285] | 40 | public string Filename { get; set; }
|
---|
| 41 |
|
---|
[8301] | 42 | IDataSource dataSource;
|
---|
[8516] | 43 | IGraph graph;
|
---|
[8301] | 44 |
|
---|
[8285] | 45 | #region Parameter Properties
|
---|
| 46 |
|
---|
| 47 | public OptionalValueParameter<DoubleMatrix> CoordinatesParameter {
|
---|
| 48 | get { return (OptionalValueParameter<DoubleMatrix>)Parameters[CoordinatesParameterName]; }
|
---|
| 49 | }
|
---|
[8301] | 50 | public ValueParameter<IntValue> SourceParameter {
|
---|
| 51 | get { return (ValueParameter<IntValue>)Parameters[SourceParameterName]; }
|
---|
[8285] | 52 | }
|
---|
[8301] | 53 | public ValueParameter<IntValue> TargetParameter {
|
---|
| 54 | get { return (ValueParameter<IntValue>)Parameters[TargetParameterName]; }
|
---|
[8285] | 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 |
|
---|
[8301] | 66 | public IntValue Source {
|
---|
| 67 | get { return SourceParameter.Value; }
|
---|
| 68 | set { SourceParameter.Value = value; }
|
---|
[8285] | 69 | }
|
---|
| 70 |
|
---|
[8301] | 71 | public IntValue Target {
|
---|
| 72 | get { return TargetParameter.Value; }
|
---|
| 73 | set { TargetParameter.Value = value; }
|
---|
[8285] | 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."));
|
---|
[8301] | 94 | Parameters.Add(new ValueParameter<IntValue>(SourceParameterName, "Source Node."));
|
---|
| 95 | Parameters.Add(new ValueParameter<IntValue>(TargetParameterName, "Target Node."));
|
---|
[8285] | 96 |
|
---|
| 97 | RegisterEventHandlers();
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | #endregion
|
---|
| 101 |
|
---|
| 102 | private void RegisterEventHandlers() { }
|
---|
| 103 |
|
---|
[8301] | 104 | public void LoadData(string file) {
|
---|
| 105 | FileInfo f = new FileInfo(file);
|
---|
[8516] | 106 | dataSource = new OsmDataSource(file);
|
---|
| 107 | graph = dataSource.GetRoutingGraph();
|
---|
[8301] | 108 |
|
---|
| 109 | Name = f.Name;
|
---|
| 110 |
|
---|
| 111 | OnReset();
|
---|
| 112 | }
|
---|
| 113 |
|
---|
[8285] | 114 | }
|
---|
| 115 | }
|
---|