[8670] | 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;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.IO;
|
---|
| 25 | using System.Text.RegularExpressions;
|
---|
| 26 |
|
---|
| 27 | namespace HeuristicLab.PDPSimulation {
|
---|
| 28 | class DefaultDynPDPParser: DynPDPParser {
|
---|
| 29 | public DefaultDynPDPParser(string file): base(file) {
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | public override void Parse() {
|
---|
| 33 | string line;
|
---|
| 34 | Regex reg = new Regex(@"-?\d+");
|
---|
| 35 | MatchCollection m;
|
---|
| 36 |
|
---|
| 37 | StreamReader reader = new StreamReader(file);
|
---|
| 38 |
|
---|
| 39 | line = reader.ReadLine();
|
---|
| 40 | problemName = line;
|
---|
| 41 |
|
---|
| 42 | line = reader.ReadLine();
|
---|
| 43 | int vehicleCount = int.Parse(line);
|
---|
| 44 |
|
---|
| 45 | for (int i = 0; i < vehicleCount; i++) {
|
---|
| 46 | line = reader.ReadLine();
|
---|
| 47 | m = reg.Matches(line);
|
---|
| 48 | Vehicle v = new Vehicle();
|
---|
| 49 |
|
---|
| 50 | v.xCoord = double.Parse(m[0].Value);
|
---|
| 51 | v.yCoord = double.Parse(m[1].Value);
|
---|
| 52 | v.capacity = double.Parse(m[2].Value);
|
---|
| 53 | v.readyTime = double.Parse(m[3].Value);
|
---|
| 54 | v.dueTime = double.Parse(m[4].Value);
|
---|
| 55 |
|
---|
| 56 | vehicles.Add(v);
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | line = reader.ReadLine();
|
---|
| 60 | int orderCount = int.Parse(line);
|
---|
| 61 | m = reg.Matches(line);
|
---|
| 62 | for (int i = 0; i < orderCount; i++) {
|
---|
| 63 | line = reader.ReadLine();
|
---|
| 64 | m = reg.Matches(line);
|
---|
| 65 | Order o = new Order();
|
---|
| 66 |
|
---|
| 67 | o.revealedTime = double.Parse(m[0].Value);
|
---|
| 68 | o.pickupXCoord = double.Parse(m[1].Value);
|
---|
| 69 | o.pickupYCoord = double.Parse(m[2].Value);
|
---|
| 70 | o.deliveryXCoord = double.Parse(m[3].Value);
|
---|
| 71 | o.deliveryYCoord = double.Parse(m[4].Value);
|
---|
| 72 | o.demand = double.Parse(m[5].Value);
|
---|
| 73 | o.pickupServiceTime = double.Parse(m[6].Value);
|
---|
| 74 | o.pickupReadyTime = double.Parse(m[7].Value);
|
---|
| 75 | o.pickupDueTime = double.Parse(m[8].Value);
|
---|
| 76 | o.deliveryServiceTime = double.Parse(m[9].Value);
|
---|
| 77 | o.deliveryReadyTime = double.Parse(m[10].Value);
|
---|
| 78 | o.deliveryDueTime = double.Parse(m[11].Value);
|
---|
| 79 |
|
---|
| 80 | orders.Add(o);
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
| 83 | }
|
---|
| 84 | }
|
---|