Cream.Solver.WaitNext C# (CSharp) Method

WaitNext() public method

Waits for the next solution, or the end of the solver execution. It returns true if the next solution is available, false if the solver ends the execution.
public WaitNext ( ) : bool
return bool
        public virtual bool WaitNext()
        {
            lock (this)
            {
                return WaitNext(0);
            }
        }

Same methods

Solver::WaitNext ( long timeout ) : bool

Usage Example

Example #1
0
 private void doItOnce()
 {
     Session.Clear();
     net = new Network();
     John = new AllenVariable(net, 0, 40, 30, "John");
     Mary = new AllenVariable(net, 35, 60, 20, "Mary");
     Wendy = new AllenVariable(net, 0, 60, 50, "Wendy");
     Soccer = new AllenVariable(net, 30, 135, 105, "Soccer");
     John.Equals(Mary);
     John.Starts(Mary);
     John.StartedBy(Mary);
     John.Meets(Mary);
     John.Equals(Wendy);
     John.Starts(Wendy);
     John.StartedBy(Wendy);
     John.Meets(Wendy);
     John.Overlaps(Soccer);
     Mary.Finishes(Wendy);
     Mary.FinishedBy(Wendy);
     Mary.During(Soccer);
     Mary.Contains(Soccer);
     AllenDomain ad0 = (AllenDomain)(John.Domain);
     AllenDomain ad1 = (AllenDomain)(Mary.Domain);
     AllenDomain ad2 = (AllenDomain)(Wendy.Domain);
     AllenDomain ad3 = (AllenDomain)(Soccer.Domain);
     solver = new AllenSolver(net);
     for (solver.Start(); solver.WaitNext(); solver.Resume())
     {
         solution = solver.Solution;
         Session["jd"] = ad0.Duration;
         Session["md"] = ad1.Duration;
         Session["wd"] = ad2.Duration;
         Session["sd"] = ad3.Duration;
         Session["js" + Convert.ToInt16(counter)] = solution.GetIntValue(John);
         Session["ms" + Convert.ToInt16(counter)] = solution.GetIntValue(Mary);
         Session["ws" + Convert.ToInt16(counter)] = solution.GetIntValue(Wendy);
         Session["ss" + Convert.ToInt16(counter)] = solution.GetIntValue(Soccer);
         Session["jp" + Convert.ToInt16(counter)] = ad0.Duration;
         Session["mp" + Convert.ToInt16(counter)] = ad1.Duration;
         Session["wp" + Convert.ToInt16(counter)] = ad2.Duration;
         Session["sp" + Convert.ToInt16(counter)] = ad3.Duration;
         Session["jn" + Convert.ToInt16(counter)] = solution.GetIntValue(John).ToString();
         Session["mn" + Convert.ToInt16(counter)] = solution.GetIntValue(Mary).ToString();
         Session["wn" + Convert.ToInt16(counter)] = solution.GetIntValue(Wendy).ToString();
         Session["sn" + Convert.ToInt16(counter)] = solution.GetIntValue(Soccer).ToString();
         counter += 1;
     }
     Session["done"] = true;
     Session["total"] = counter;
     Session["counter"] = 0;
     total.Text = "There are " + counter + " solutions";
     counter = 0;
     Display();
     Button1.Enabled = true;
     Button2.Enabled = true;
     Button3.Enabled = true;
     Button4.Enabled = true;
     if (Convert.ToInt16(Session["counter"]) == 0)
     {
         Button1.Enabled = false;
         Button2.Enabled = false;
     }
     if (Convert.ToInt16(Session["counter"]) == Convert.ToInt16(Session["total"]) - 1)
     {
         Button3.Enabled = false;
         Button4.Enabled = false;
     }
 }