#region License Information /* HeuristicLab * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Collections.Generic; using System.IO; using System.Text.RegularExpressions; namespace HeuristicLab.PDPSimulation { class DefaultDynPDPParser: DynPDPParser { public DefaultDynPDPParser(string file): base(file) { } public override void Parse() { string line; Regex reg = new Regex(@"-?\d+"); MatchCollection m; StreamReader reader = new StreamReader(file); line = reader.ReadLine(); problemName = line; line = reader.ReadLine(); int vehicleCount = int.Parse(line); for (int i = 0; i < vehicleCount; i++) { line = reader.ReadLine(); m = reg.Matches(line); Vehicle v = new Vehicle(); v.xCoord = double.Parse(m[0].Value); v.yCoord = double.Parse(m[1].Value); v.capacity = double.Parse(m[2].Value); v.readyTime = double.Parse(m[3].Value); v.dueTime = double.Parse(m[4].Value); vehicles.Add(v); } line = reader.ReadLine(); int orderCount = int.Parse(line); m = reg.Matches(line); for (int i = 0; i < orderCount; i++) { line = reader.ReadLine(); m = reg.Matches(line); Order o = new Order(); o.revealedTime = double.Parse(m[0].Value); o.pickupXCoord = double.Parse(m[1].Value); o.pickupYCoord = double.Parse(m[2].Value); o.deliveryXCoord = double.Parse(m[3].Value); o.deliveryYCoord = double.Parse(m[4].Value); o.demand = double.Parse(m[5].Value); o.pickupServiceTime = double.Parse(m[6].Value); o.pickupReadyTime = double.Parse(m[7].Value); o.pickupDueTime = double.Parse(m[8].Value); o.deliveryServiceTime = double.Parse(m[9].Value); o.deliveryReadyTime = double.Parse(m[10].Value); o.deliveryDueTime = double.Parse(m[11].Value); orders.Add(o); } } } }