public StateActiveSpace Clone() { StateActiveSpace sas = new StateActiveSpace(); sas.UnionWith(this); return(sas); }
private void SolveSubProblem() { for (int t = CurrentTime; t < Data.TimeHorizon; t++) { IALPState temp_s = null; IMDPDecision deci_a = null; bool IsSubOpt = RCG(t, out temp_s, out deci_a); if (!IsSubOpt) { int iteration = t; IALPState tempstate = temp_s; IMDPDecision tempdeci = deci_a; Task ta = factory.StartNew(() => { StateActive temp = new StateActive() { T = iteration, S = tempstate, D = tempdeci }; if (curSAS.FirstOrDefault(i => i.Equals(temp)) == null) { tempSA.Push(temp); lock (RMPModel) { temp.Var = AddCol(temp.T, temp.S, temp.D); } } }, cts.Token); tasks.Add(ta); //StateActive tempSA = new StateActive() { T = t, S = temp_s, D = deci_a }; //if (curSAS.Add(tempSA)) //{ // tempSA.Var = AddCol(t, temp_s, deci_a); //} } IsOptimal = IsSubOpt && IsOptimal; //System.Console.WriteLine("#{0}第{1}个子问题已经解决!", System.DateTime.Now.ToLongTimeString(), t); } Task.WaitAll(tasks.ToArray()); tasks.Clear(); curSAS.UnionWith(tempSA); tempSA.Clear(); }