Ejemplo n.º 1
0
        internal override void Propagate(ref bool fail)
        {
            if (NarrowedVariable != this.power)
            {
                this.power.NarrowTo(this.a.Value ^ this.exponent, ref fail);
                if (fail)
                {
                    return;
                }
            }

            // We want to repropagate in case this is an even power and we just split on a.
            //if (NarrowedVariable != this.a)
            {
                if ((exponent % 2 == 0) && this.a.Value.Lower < 0)
                {
                    if (this.a.Value.Upper <= 0)
                    {
                        // a is non-positive
                        this.a.NarrowTo(-Interval.InvPower(power.Value, exponent), ref fail);
                    }
                    else
                    {
                        // even inverse power of an interval that crosses zero
                        var bound = Interval.InvPower(power.Value, exponent).Upper;
                        this.a.NarrowTo(new Interval(-bound, bound)
#if SearchHints
                        {
                            SearchHint = SearchHint.NoGuess
                        }
#endif
                                        , ref fail);
                    }
                }
                else
                {
                    // a is already non-negative or exponent is odd (and so function is monotone)
                    this.a.NarrowTo(Interval.InvPower(this.power.Value, this.exponent), ref fail);
                }
            }
        }