private void getOptSolnContent(CreateNetWork net) { foreach (var pairing in OptSoln) { string str = ""; double T = 0, dis = 0; LR.TranslationCSP(pairing.Route, net, ref str, ref T, ref dis, 0, 0); LR.YUB.Add(str); } }
public void InitCG(CreateNetWork net) { num_task = net.LineList.Count; RMP = new Cplex(); DvarSet = new List <INumVar>(net.CrewList.Count); CoverMatrix = new List <int[]>(); DualSet = new double[num_task]; constraints = new IRange[num_task]; ColumnPool = new List <Pairing>(); }
public Summery(Lagrange lag, CreateNetWork net, double netConstructTime, double solveTime) { for (int i = 0; i < lag.YUB.Count; i++) { crew_schedule_content += "乘务交路" + (i + 1).ToString() + "为:" + lag.YUB[i] + "\n"; } //opt_lb_with = lag.BestLB; //opt_ub_with = lag.BestUB; opt_lb_with = lag.BestLB_with_penalty; opt_ub_with = lag.BestUB_with_penalty; opt_lb_without = lag.BestLB_without_penalty; opt_ub_without = lag.BestUB_without_penalty; gap_with = (opt_ub_with - opt_lb_with) / opt_ub_with; gap_without = (opt_ub_without - opt_lb_without) / opt_ub_without; iteration_num = lag.k; state_node_num = net.T_S_S_NodeList.Count; state_arc_num = net.T_S_S_ArcList.Count; dvar_num = state_arc_num * lag.CrewCount; net_construct_time = netConstructTime; solve_time = solveTime; }
public void InitLR(CreateNetWork net, int stepSize) { LR = new Lagrange(net, stepSize); }
public void LR_and_CG(ref CreateNetWork net, int lr_iter_num) { //1.initial solution LR.GenerateLRSoln(ref net, lr_iter_num); double lr_lb = LR.BestLB; double ub = 0; //2.RMP //BuildRMP(LR.SortedPathSet); //AddColumnsToRMP(LR.LB_PathSet); BuildRMP(LR.g_LB_PathSet); //double real_LB = 0; //double real_UB = 0; #region //CG progress changed 20191026 //for (; ; ) //{ // try // { // RMP.Solve(); // //Console.WriteLine(GetRMPObjValue(LR.SortedPathSet)); // RMPObjValue = RMP.GetObjValue(); // Console.WriteLine("RMPOBJ:" + RMPObjValue); // //3.get dual:v // GetDuals(); // } // catch (ILOG.Concert.Exception iloex) // { // Console.WriteLine(iloex.Message); // } // //4.renew LR multipliers u //2 way:1) u = a*v + u_best of last LR solve process // double weight = 0.05;// 0.05; // List<Line> lineList = net.LineList; // List<T_S_S_Arc> taskArcSet = LR.type_arcPair[1]; // RenewLRMultipliers(ref lineList, ref taskArcSet, weight); // real_LB = LR.BestLB; // real_UB = LR.BestUB; // foreach (var path in LR.LB_PathSet) // { // if (path.Route.Count <= 2) // { // real_LB -= path.Price; // } // } // foreach (var path in LR.SortedPathSet) // { // if (path.Route.Count <= 2) // { // real_UB -= path.Price; // } // } // Console.WriteLine("real_LB: {0} \t real_UB: {1}\n", real_LB, real_UB); // //5.gap // if (CheckTwoGAP(real_LB, real_UB, RMPObjValue) || num_iter >= 100) // { // //got best solution // break; // } // //6.LR loop,either for some short path,not all Np numbers, or all Np short path // //7.found no path with negetive reduced cost,then // //renew LR multipliers by renew weight // num_iter += 20; // LR.GenerateLRSoln(ref net, num_iter); // while (LR.SortedPathSet[0].Price >= 0 && weight < 1) // { // Console.WriteLine("!!!!"); // weight += 0.1; // RenewLRMultipliers(ref lineList, ref taskArcSet, weight); // num_iter += 20; // LR.GenerateLRSoln(ref net, num_iter); // } // if (weight >= 1) // { // //got best solution // break; // } // //8.if found path with negetive reduced cost,then // //add to RMP // AddColumnsToRMP(LR.SortedPathSet); // AddColumnsToRMP(LR.LB_PathSet); //} #endregion //求整数解 IConversion mip = RMP.Conversion(DvarSet.ToArray(), NumVarType.Int); RMP.Add(mip); RMP.Solve(); Console.WriteLine("MIP_OBJ:" + RMP.GetObjValue()); int real_crew_num = 0; //ub = calLRUB_with_and_without_penalry(net.virtualRoutingCost, ref real_crew_num); Console.WriteLine("ub:" + ub); Console.WriteLine("real crew num:" + real_crew_num); //******stop when met stop-condition LR.BestUB = ub; setOptSoln(net.LineList); sortOptSolnByASC(); getOptSolnContent(net); }