public List <Tuple <int, double> > GetDualVariables(string folderPath, RouteSet solution) { /*Solo permite obtener soluciones extremales del dual que son muy malas para la generacion de columnas*/ ColumnSelectionGAMS gamsProcedure = new ColumnSelectionGAMS(ProblemData); return(gamsProcedure.DualSolve(folderPath, GetExtRouteInfo(solution))); }
protected List <Tuple <Route, double> > SolveRestrictedMasterProblem(string folderPath, string coveringPath, List <ExtRouteInfo> currentPool) { ColumnSelectionGAMS gamsProcedure = new ColumnSelectionGAMS(ProblemData); DirectoryInfo coveringDir = Directory.CreateDirectory(folderPath).CreateSubdirectory(coveringPath); List <Tuple <Route, double> > coveringSelection = gamsProcedure.Solve(coveringDir.FullName, currentPool); for (int i = 0; i < coveringSelection.Count; i++) { coveringSelection[i].Item1.ToXMLFormat().Save(Path.Combine(coveringDir.FullName, string.Format("r={0} s={1}.xml", i, coveringSelection[i].Item2))); } return(coveringSelection); }
//public double[] GetDualVariables(List<Tuple<Route, double>> coveringSelection) //{ // //no gatantiza que sea solucion optima del dual // double[] vars = new double[ProblemData.Clients.Count + 1]; // foreach (var item in coveringSelection) // { // double routePartialCost = GetCost(item.Item1) * item.Item2; // foreach (var c in item.Item1) // { // vars[c] += routePartialCost / item.Item1.Count; // } // } // return vars; //} public double[] GetExtremeDualVariables(string folderPath, List <ExtRouteInfo> pool, int dualVectorSize) { double[] dual = new double[dualVectorSize]; if (pool.Count > 0) { ColumnSelectionGAMS gamsProcedure = new ColumnSelectionGAMS(ProblemData); var dualvalues = gamsProcedure.DualSolve(folderPath, pool); foreach (var item in dualvalues) { dual[item.Item1] = item.Item2; } } return(dual); }
private RouteSet Solve <TProcedure, TParameters>(double overloadFactor, int shakings, Exploration expCondition, Random rdObj, List <Func <RouteSet, Exploration, Random, RouteSet> > neighborhoods, List <Func <RouteSet, Random, RouteSet> > shakingProcedures, string gamsFolderPath, TProcedure procedure, TParameters parameters, List <RouteSet> initialPool) where TProcedure : LocalSearchProcedure <RouteSet, TParameters> { List <RouteSet> solutionPool = BuildSolutionPool(overloadFactor, shakings, expCondition, rdObj, neighborhoods, shakingProcedures, procedure, parameters, initialPool); Console.WriteLine("solution pool {0}", solutionPool.Count); List <ExtRouteInfo> routesPool = BuildRoutePool(solutionPool, overloadFactor, gamsFolderPath); Console.WriteLine("routes pool {0}", routesPool.Count); ColumnSelectionGAMS gamsProcedure = new ColumnSelectionGAMS(ProblemData); List <Route> selected = gamsProcedure.Solve(gamsFolderPath, routesPool); for (int i = 0; i < selected.Count; i++) { selected[i].ToXMLFormat().Save(Path.Combine(gamsFolderPath, string.Format("overlapping{0}.xml", i))); } return(BuildSolution(selected)); }