private List <Tuple <RouteSet, double> > ParallelExeDualParallelShaking <TProcedure, TParameters>(Exploration expCondition, Random rdObj, List <Func <RouteSet, Exploration, Random, RouteSet> > neighborhoods, List <Func <RouteSet, Random, RouteSet> > shaking, TProcedure procedure, TParameters parameters, RouteSet bestSolution, RouteSet current, int iteration, Stopwatch timer, double[,] dualCost) where TProcedure : LocalSearchProcedure <RouteSet, TParameters> { Tuple <RouteSet, double>[] parallelSolutions = new Tuple <RouteSet, double> [shaking.Count]; VRPSimultaneousPickupDelivery dualProblem = ProblemData.GetDualReduceCostProblem(dualCost); PenalizationLocalSearch dualProcedure = new PenalizationLocalSearch(dualProblem); dualProcedure.OverloadFactor = OverloadFactor; Parallel.For(0, shaking.Count, i => { Random pRdObj = new Random((i + 1) * (i + 2) * Environment.TickCount); var shk = shaking[i](current, pRdObj); var imp = procedure.Solve(parameters, shk, neighborhoods, expCondition, dualProcedure.GetCost, pRdObj); /*para la construccion de las nuevas rutas se usan los costos reducidos*/ parallelSolutions[i] = new Tuple <RouteSet, double>(imp, GetCost(imp)); OnIteration(new IterationEventArgs <RouteSet>(bestSolution, imp, (iteration + 1) * i, timer.Elapsed.TotalSeconds)); /*iteration+1 pq las iteraciones comienzan en cero*/ }); return(parallelSolutions.ToList()); }
private List <Tuple <RouteSet, double> > DualParallelShaking <TProcedure, TParameters>(Exploration expCondition, Random rdObj, List <Func <RouteSet, Exploration, Random, RouteSet> > neighborhoods, List <Func <RouteSet, Random, RouteSet> > shaking, TProcedure procedure, TParameters parameters, RouteSet bestSolution, RouteSet current, int iteration, Stopwatch timer, double[,] dualCost) where TProcedure : LocalSearchProcedure <RouteSet, TParameters> { List <Tuple <RouteSet, double> > parallelSolutions = new List <Tuple <RouteSet, double> >(); VRPSimultaneousPickupDelivery dualProblem = ProblemData.GetDualReduceCostProblem(dualCost); PenalizationLocalSearch dualProcedure = new PenalizationLocalSearch(dualProblem); dualProcedure.OverloadFactor = OverloadFactor; for (int k = 0; k < shaking.Count; k++) { var shk = shaking[k](current, rdObj); var imp = procedure.Solve(parameters, shk, neighborhoods, expCondition, dualProcedure.GetCost, rdObj); /*para la construccion de las nuevas rutas se usan los costos reducidos*/ parallelSolutions.Add(new Tuple <RouteSet, double>(imp, GetCost(imp))); OnIteration(new IterationEventArgs <RouteSet>(bestSolution, imp, (iteration + 1) * k, timer.Elapsed.TotalSeconds)); /*iteration+1 pq las iteraciones comienzan en cero*/ } return(parallelSolutions); }