public override IEnumerable TryNarrowing() { bool fail = false; #if SearchHints if (SafeToGuess) #endif { double randomElement = Value.RandomElement(); CSP.PushChoice("Guess {0}={1}", this.Name, randomElement); this.NarrowTo(new Interval(randomElement), ref fail); Debug.Assert(!fail, "trial narrowing failed"); yield return(false); } if ((CSP.Random.Next() & 1) == 0) { CSP.PushChoice("Lower half {0} to {1}", this.Name, this.Value.LowerHalf); this.NarrowTo(Value.LowerHalf, ref fail); Debug.Assert(!fail, "trial narrowing failed"); yield return(false); CSP.PushChoice("Upper half {0} to {1}", this.Name, this.Value.UpperHalf); this.NarrowTo(Value.UpperHalf, ref fail); Debug.Assert(!fail, "trial narrowing failed"); yield return(false); } else { CSP.PushChoice("Upper half {0} to {1}", this.Name, this.Value.UpperHalf); this.NarrowTo(Value.UpperHalf, ref fail); Debug.Assert(!fail, "trial narrowing failed"); yield return(false); CSP.PushChoice("Lower half {0} to {1}", this.Name, this.Value.LowerHalf); this.NarrowTo(Value.LowerHalf, ref fail); Debug.Assert(!fail, "trial narrowing failed"); yield return(false); } }
protected Variable(string name, CSP p) { Name = name; p.Variables.Add(this); CSP = p; }
public Vector3Variable(string name, CSP p, double x, double y, double z) : this(name, p, new Interval(x), new Interval(y), new Interval(z)) { }
public Vector3Variable(string name, CSP p, BoundingBox b) : this(name, p, b.X, b.Y, b.Z) { }
public static FloatVariable Constant(CSP p, double c) { // ReSharper disable SpecifyACultureInStringConversionExplicitly return(p.Memoize("constant", () => new FloatVariable(c.ToString(), p, c, c), c)); // ReSharper restore SpecifyACultureInStringConversionExplicitly }
public FloatVariable(string name, CSP csp) : this(name, csp, Interval.AllValues) { }
public FloatVariable(string name, CSP p, Interval initialValue) : base(name, p, p.IntervalUndoStack, initialValue) { }
public FloatVariable(string name, CSP p, double lower, double upper) : this(name, p, new Interval(lower, upper)) { }