Skip to content

Commit ada6b8c

Browse files
committed
cleanup isappox
1 parent 85e65a7 commit ada6b8c

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/coefficients.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ function _get_constraint_data(
8383
func::JuMP.GenericAffExpr,
8484
)
8585
if length(func.terms) == 1
86-
if first(values(func.terms)) 1.0
86+
if isapprox(first(values(func.terms)), 1.0, rtol = sqrt(eps(Float64)))
8787
push!(data.bound_rows, ref)
8888
data.matrix_nnz += 1
8989
return
9090
end
9191
end
9292
nnz = 0
9393
for (variable, coefficient) in func.terms
94-
if coefficient 0.0
94+
if iszero(coefficient)
9595
continue
9696
end
9797
nnz += _update_range(data.matrix_range, coefficient)
@@ -122,7 +122,7 @@ function _get_constraint_data(
122122
_get_constraint_data(data, ref, func.aff)
123123
nnz = 0
124124
for ((v1, v2), coefficient) in func.terms
125-
if coefficient 0.0
125+
if iszero(coefficient)
126126
continue
127127
end
128128
nnz += _update_range(data.matrix_quadratic_range, coefficient)
@@ -139,7 +139,7 @@ function _get_constraint_data(
139139
end
140140

141141
function _get_variable_data(data, variable, coefficient::Number)
142-
if !(coefficient 0.0)
142+
if !(iszero(coefficient))
143143
_update_range(data.bounds_range, coefficient)
144144
if abs(coefficient) < data.threshold_small
145145
push!(data.bounds_small, (variable, coefficient))
@@ -153,7 +153,7 @@ end
153153
function _get_objective_data(data, func::JuMP.GenericAffExpr)
154154
nnz = 0
155155
for (variable, coefficient) in func.terms
156-
if coefficient 0.0
156+
if iszero(coefficient)
157157
continue
158158
end
159159
nnz += _update_range(data.objective_range, coefficient)
@@ -170,7 +170,7 @@ function _get_objective_data(data, func::JuMP.GenericQuadExpr)
170170
_get_objective_data(data, func.aff)
171171
nnz = 0
172172
for ((v1, v2), coefficient) in func.terms
173-
if coefficient 0.0
173+
if iszero(coefficient)
174174
continue
175175
end
176176
nnz += _update_range(data.objective_quadratic_range, coefficient)
@@ -229,7 +229,7 @@ end
229229

230230
function _get_constraint_data(data, ref, func::JuMP.GenericAffExpr, set)
231231
coefficient = func.constant
232-
if coefficient 0.0
232+
if iszero(coefficient)
233233
return
234234
end
235235
_update_range(data.rhs_range, coefficient)
@@ -267,7 +267,7 @@ function _get_constraint_data(
267267
set::MOI.LessThan,
268268
)
269269
coefficient = set.upper - func.constant
270-
if coefficient 0.0
270+
if iszero(coefficient)
271271
return
272272
end
273273
_update_range(data.rhs_range, coefficient)
@@ -299,7 +299,7 @@ function _get_constraint_data(
299299
set::MOI.GreaterThan,
300300
)
301301
coefficient = set.lower - func.constant
302-
if coefficient 0.0
302+
if iszero(coefficient)
303303
return
304304
end
305305
_update_range(data.rhs_range, coefficient)
@@ -329,7 +329,7 @@ function _get_constraint_data(
329329
set::MOI.EqualTo,
330330
)
331331
coefficient = set.value - func.constant
332-
if coefficient 0.0
332+
if iszero(coefficient)
333333
return
334334
end
335335
_update_range(data.rhs_range, coefficient)
@@ -348,7 +348,7 @@ function _get_constraint_data(
348348
set::MOI.Interval,
349349
)
350350
coefficient = set.upper - func.constant
351-
if !(coefficient 0.0)
351+
if !(iszero(coefficient))
352352
_update_range(data.rhs_range, coefficient)
353353
if abs(coefficient) < data.threshold_small
354354
push!(data.rhs_small, (ref, coefficient))
@@ -357,7 +357,7 @@ function _get_constraint_data(
357357
end
358358
end
359359
coefficient = set.lower - func.constant
360-
if coefficient 0.0
360+
if iszero(coefficient)
361361
return
362362
end
363363
_update_range(data.rhs_range, coefficient)

0 commit comments

Comments
 (0)