/// <summary> /// Creates and returns a real variable which represents the minimum of <paramref name="a"/> and <paramref name="b"/> /// </summary> public static RealVariable Minimize(RealVariable a, RealVariable b) { RealVariable min = new RealVariable(a.ConstraintThingySolver, null, RealVariable.DefaultRange); // calculate the possible range for the sum so we improve the speed of the search Constraint.InRange(min, MultiInterval.Min(a.AllowableValues.First, b.AllowableValues.First)); Min(min, a, b); return(min); }
protected internal override void UpdateVariable(RealVariable variable, out bool success) { MultiInterval result; if (variable == Min) { result = Variables[1].AllowableValues.First; for (int i = 2; i < Variables.Length; i++) { result = MultiInterval.Min(result, Variables[i].AllowableValues.First); } } else { // we can't be less than the 'min', so we bound ourselves to the range (min, +infinity] result = Min.AllowableValues.First.Extend(double.PositiveInfinity); } variable.NarrowTo(result, out success); return; }