public List <ExtRouteInfo> BuildRoutePool(List <RouteSet> solutionPool, double overloadFactor, string gamsFolderPath)
        {
            OverloadFactor = 0;
            List <ExtRouteInfo> routePool     = new List <ExtRouteInfo>();
            SingleRouteSPDGAMS  gamsProcedure = new SingleRouteSPDGAMS(ProblemData);
            DirectoryInfo       gamsDir       = Directory.CreateDirectory(gamsFolderPath);
            int i = 0;

            foreach (var solution in solutionPool)
            {
                foreach (var route in solution)
                {
                    if (route.IsEmpty)
                    {
                        continue;
                    }
                    if (ProblemData.IsFeasible(route) && !ExtRouteInfo.IsInPool(routePool, route))
                    {
                        DirectoryInfo gamsIteration = gamsDir.CreateSubdirectory(i.ToString());
                        Route         current       = gamsProcedure.Solve(gamsIteration.FullName, route);
                        routePool.Add(new ExtRouteInfo(current, GetTravelCost(route)));
                    }
                }
            }
            return(routePool);
        }
Esempio n. 2
0
        protected Route ParseGamsSolution(string routePath, int[] mapping, Route currentRoute)
        {
            //TODO!!!!! Verificar q exista el fichero, si no existe es q gams no pudo encontrar solucion para alguna ruta
            Route        newRoute = new Route(currentRoute.Vehicle);
            Regex        routeExp = new Regex(@"(?<ci>C\d+)\S+(?<cj>C\d+)\S+(?<v>\d\.d+)");
            StreamReader reader   = new StreamReader(Path.Combine(routePath, "tspspdsolution.dat"));
            double       cost     = double.Parse(reader.ReadLine().Trim());

            if (cost == 0)
            {
                Console.WriteLine("weak feasible {0} strong feasible {1}", ProblemData.IsFeasible(currentRoute), ((VRPSimultaneousPickupDelivery)ProblemData).IsStrongFeasible(currentRoute));
                return(currentRoute);
            }
            Dictionary <int, int> routeInfo = GetRouteInfo(reader);
            int lastCLient = 0;
            int newClient  = routeInfo[lastCLient];

            while (newClient != 0)
            {
                newRoute.Add(mapping[newClient]);
                lastCLient = newClient;
                newClient  = routeInfo[lastCLient];
            }
            return(newRoute);
        }
 public override bool IsAllowedMovement(TwoOpt m)
 {
     return(ProblemData.IsFeasible(m.current));
 }
 public override bool IsAllowedMovement(IntraSwap m)
 {
     return(ProblemData.IsFeasible(m.current));
 }