@@ -32,24 +32,16 @@ import NNlib: relu, selu, leakyrelu, sigmoid, swish, gelu, elu, softsign, logcos
3232
3333using IntervalArithmetic
3434using IntervalArithmetic: @round
35- if isdefined (IntervalArithmetic, :big53 )
36- big_val (x) = IntervalArithmetic. big53 (x)
37- else
38- big_val (x) = IntervalArithmetic. bigequiv (x)
39- end
4035
4136using IntervalRootFinding
42- import IntervalArithmetic: dist, mid, pow, + , - , * , / , convert, in, isempty,
37+ import IntervalArithmetic: dist, mid, pow, + , - , * , / , convert,
4338 one, zero, real, eps, max, min, abs, exp,
44- expm1, log, log2, log10, log1p, sqrt, ^ ,
45- sin, cos, tan, min, max, sec, csc, cot, step, sech,
46- csch, coth, acsch, acoth, asech,
47- sign, dist, mid, pow, Interval, interval, sinh, cosh,
48- ∩ , IntervalBox, bisect, isdisjoint, length,
49- atan, asin, acos, AbstractInterval, atomic,
50- sind, cosd, tand, asind, acosd, atand,
51- secd, cscd, cotd, asecd, acscd, acotd, half_pi,
52- setrounding, diam, isthin, abs2
39+ expm1, log, log2, log10, log1p, sqrt, ^ , sin,
40+ cos, tan, min, max, sec, csc, cot, step, sech,
41+ csch, coth, acsch, acoth, asech, sign, dist, mid,
42+ pow, interval, sinh, cosh, length, atan, asin, acos,
43+ atomic, sind, cosd, tand, asind, acosd, atand, secd, cscd,
44+ cotd, asecd, acscd, acotd, setrounding, diam, isthin, abs2
5345
5446import SpecialFunctions: erf, erfc, erfinv, erfcinv
5547export erf, erfinv, erfc, erfcinv, erf_kernel, erfinv_kernel, erfc_kernel, erfcinv_kernel
@@ -134,18 +126,6 @@ const MC_MV_TOL = 1E-8
134126const MC_DEGEN_TOL = 1E-14
135127const MC_DOMAIN_TOL = 1E-10
136128
137- const IntervalConstr = interval
138- const Half64 = Float64 (0.5 )
139- const Two64 = Float64 (2.0 )
140- const Three64 = Float64 (3.0 )
141- const EqualityTolerance = Float64 (1E-12 )
142- const DegToRadIntv = atomic (Interval{Float64}, pi )/ Interval (180.0 )
143- const one_intv = one (Interval{Float64})
144- const half_intv = Interval {Float64} (0.5 )
145- const two_intv = Interval {Float64} (2.0 )
146- const log2_intv = log (Interval {Float64} (2.0 ))
147- const log10_intv = log (Interval {Float64} (10.0 ))
148-
149129const NumberNotRelax = Union{Bool, Float16, Float32, Signed, Unsigned, BigFloat,
150130 Int8, Int64, Int32, Int16, Int128}
151131
@@ -289,14 +269,14 @@ function cut(xL::Float64, xU::Float64, cv::Float64, cc::Float64,
289269 return cvo, cco, cv_grado, cc_grado
290270end
291271
292- lo (x:: Interval{Float64} ) = x. lo
293- hi (x:: Interval{Float64} ) = x. hi
272+ lo (x:: Interval{Float64} ) = x. bareinterval . lo
273+ hi (x:: Interval{Float64} ) = x. bareinterval . hi
294274
295275function step (x:: Interval{Float64} )
296- isempty (x) && return emptyinterval (x)
297- xmin:: Float64 = ((x. lo) < 0.0 ) ? 0.0 : 1.0
298- xmax:: Float64 = ((x. hi) >= 0.0 ) ? 1.0 : 0.0
299- return Interval {Float64} (xmin,xmax)
276+ isempty_interval (x) && return x
277+ xmin:: Float64 = ((x. bareinterval . lo) < 0.0 ) ? 0.0 : 1.0
278+ xmax:: Float64 = ((x. bareinterval . hi) >= 0.0 ) ? 1.0 : 0.0
279+ return interval (xmin, xmax)
300280end
301281
302282
@@ -333,11 +313,11 @@ end
333313"""
334314MC{N,T}(y::Interval{Float64})
335315
336- Constructs a McCormick relaxation with the convex relaxation equal to `y.lo` and
337- concave relaxation equal to `y.hi`.
316+ Constructs a McCormick relaxation with the convex relaxation equal to `y.bareinterval. lo` and
317+ concave relaxation equal to `y.bareinterval. hi`.
338318"""
339319function MC {N,T} (y:: Interval{Float64} ) where {N, T <: RelaxTag }
340- MC {N,T} (y. lo, y. hi, y, zero (SVector{N,Float64}),
320+ MC {N,T} (y. bareinterval . lo, y. bareinterval . hi, y, zero (SVector{N,Float64}),
341321 zero (SVector{N,Float64}), true )
342322end
343323
@@ -347,11 +327,11 @@ MC{N,T}(y::Float64)
347327Constructs a McCormick relaxation with the convex relaxation equal to `y` and
348328concave relaxation equal to `y`.
349329"""
350- MC {N,T} (y:: Float64 ) where {N, T <: RelaxTag } = MC {N,T} (Interval {Float64} (y))
330+ MC {N,T} (y:: Float64 ) where {N, T <: RelaxTag } = MC {N,T} (interval (y))
351331function MC {N,T} (y:: Y ) where {N, T <: RelaxTag , Y <: AbstractIrrational }
352- MC {N,T} (Interval {Float64} (y))
332+ MC {N,T} (interval (y))
353333end
354- MC {N,T} (y:: Q ) where {N, T <: RelaxTag , Q <: NumberNotRelax } = MC {N,T} (Interval {Float64} (y))
334+ MC {N,T} (y:: Q ) where {N, T <: RelaxTag , Q <: NumberNotRelax } = MC {N,T} (interval (y))
355335
356336"""
357337MC{N,T}(cv::Float64, cc::Float64)
@@ -360,7 +340,7 @@ Constructs a McCormick relaxation with the convex relaxation equal to `cv` and
360340concave relaxation equal to `cc`.
361341"""
362342function MC {N,T} (cv:: Float64 , cc:: Float64 ) where {N, T <: RelaxTag }
363- MC {N,T} (cv, cc, Interval {Float64} (cv, cc), zero (SVector{N,Float64}),
343+ MC {N,T} (cv, cc, interval (cv, cc), zero (SVector{N,Float64}),
364344 zero (SVector{N,Float64}), true )
365345end
366346MC {N,T} (cv:: Q , cc:: R ) where {N, T <: RelaxTag , Q <: NumberNotRelax , R <: NumberNotRelax } = MC {N,T} (Float64 (cv), Float64 (cc))
@@ -393,8 +373,8 @@ function MC{N,T}(x::MC{N,T}) where {N, T <: RelaxTag}
393373end
394374
395375Intv (x:: MC ) = x. Intv
396- lo (x:: MC ) = x. Intv. lo
397- hi (x:: MC ) = x. Intv. hi
376+ lo (x:: MC ) = x. Intv. bareinterval . lo
377+ hi (x:: MC ) = x. Intv. bareinterval . hi
398378cc (x:: MC ) = x. cc
399379cv (x:: MC ) = x. cv
400380cc_grad (x:: MC ) = x. cc_grad
@@ -407,8 +387,8 @@ isthin(x::MC) = isthin(x.Intv)
407387
408388function isone (x:: MC )
409389 flag = true
410- flag &= (x. Intv. lo == 1.0 )
411- flag &= (x. Intv. hi == 1.0 )
390+ flag &= (x. Intv. bareinterval . lo == 1.0 )
391+ flag &= (x. Intv. bareinterval . hi == 1.0 )
412392 flag &= x. cnst
413393 return flag
414394end
@@ -453,11 +433,11 @@ end
453433"""
454434MCNoGrad(y::Interval{Float64})
455435
456- Constructs McCormick relaxation with convex relaxation equal to `y.lo` and
457- concave relaxation equal to `y.hi`.
436+ Constructs McCormick relaxation with convex relaxation equal to `y.bareinterval. lo` and
437+ concave relaxation equal to `y.bareinterval. hi`.
458438"""
459439function MCNoGrad (y:: Interval{Float64} )
460- MCNoGrad (y. lo, y. hi, y, true )
440+ MCNoGrad (y. bareinterval . lo, y. bareinterval . hi, y, true )
461441end
462442
463443"""
@@ -466,11 +446,11 @@ MCNoGrad(y::Float64)
466446Constructs McCormick relaxation with convex relaxation equal to `y` and
467447concave relaxation equal to `y`.
468448"""
469- MCNoGrad (y:: Float64 ) = MCNoGrad (Interval {Float64} (y))
449+ MCNoGrad (y:: Float64 ) = MCNoGrad (interval (y))
470450function MCNoGrad (y:: Y ) where Y <: AbstractIrrational
471- MCNoGrad (Interval {Float64} (y))
451+ MCNoGrad (interval (y))
472452end
473- MCNoGrad (y:: Q ) where Q <: NumberNotRelax = MCNoGrad (Interval {Float64} (y))
453+ MCNoGrad (y:: Q ) where Q <: NumberNotRelax = MCNoGrad (interval (y))
474454
475455"""
476456MCNoGrad(cv::Float64, cc::Float64)
@@ -479,12 +459,12 @@ Constructs McCormick relaxation with convex relaxation equal to `cv` and
479459concave relaxation equal to `cc`.
480460"""
481461function MCNoGrad (cv:: Float64 , cc:: Float64 )
482- MC {N,T} (cv, cc, Interval {Float64} (cv, cc), true )
462+ MC {N,T} (cv, cc, interval (cv, cc), true )
483463end
484464
485465Intv (x:: MCNoGrad ) = x. Intv
486- lo (x:: MCNoGrad ) = x. Intv. lo
487- hi (x:: MCNoGrad ) = x. Intv. hi
466+ lo (x:: MCNoGrad ) = x. Intv. bareinterval . lo
467+ hi (x:: MCNoGrad ) = x. Intv. bareinterval . hi
488468cc (x:: MCNoGrad ) = x. cc
489469cv (x:: MCNoGrad ) = x. cv
490470cnst (x:: MCNoGrad ) = x. cnst
@@ -494,8 +474,8 @@ isthin(x::MCNoGrad) = isthin(x.Intv)
494474
495475function isone (x:: MCNoGrad )
496476 flag = true
497- flag &= (x. Intv. lo == 1.0 )
498- flag &= (x. Intv. hi == 1.0 )
477+ flag &= (x. Intv. bareinterval . lo == 1.0 )
478+ flag &= (x. Intv. bareinterval . hi == 1.0 )
499479 flag &= x. cnst
500480 return flag
501481end
0 commit comments