@@ -245,10 +245,8 @@ function DiffEqBase.OptimizationProblem{iip}(sys::OptimizationSystem, u0map,
245
245
lb = varmap_to_vars (dvs .=> lb, dvs; defaults = defs, tofloat = false , use_union)
246
246
ub = varmap_to_vars (dvs .=> ub, dvs; defaults = defs, tofloat = false , use_union)
247
247
248
- if ! isnothing (lb) && all (lb .== - Inf )
248
+ if ! isnothing (lb) && all (lb .== - Inf ) && ! isnothing (ub) && all (ub .== Inf )
249
249
lb = nothing
250
- end
251
- if ! isnothing (ub) && all (ub .== Inf )
252
250
ub = nothing
253
251
end
254
252
@@ -301,16 +299,18 @@ function DiffEqBase.OptimizationProblem{iip}(sys::OptimizationSystem, u0map,
301
299
cons_expr = toexpr .(subs_constants (constraints (cons_sys)))
302
300
rep_pars_vals! .(cons_expr, Ref (pairs_arr))
303
301
304
- if isnothing ( lcons) && isnothing ( ucons) # use the symbolically specified bounds
302
+ if ! haskey (kwargs, : lcons ) && ! haskey (kwargs, : ucons ) # use the symbolically specified bounds
305
303
lcons = lcons_
306
304
ucons = ucons_
307
305
else # use the user supplied constraints bounds
308
- xor ( isnothing (lcons), isnothing ( lcons)) &&
309
- throw (ArgumentError (" Expected both `lcons ` and `lcons` to be supplied" ))
310
- ! isnothing ( lcons) && length (lcons) != length (cstr) &&
306
+ haskey (kwargs, : lcons ) && haskey (kwargs, :ucons ) &&
307
+ throw (ArgumentError (" Expected both `ucons ` and `lcons` to be supplied" ))
308
+ haskey (kwargs, : lcons ) && length (kwargs[ : lcons] ) != length (cstr) &&
311
309
throw (ArgumentError (" Expected `lcons` to be of the same length as the vector of constraints" ))
312
- ! isnothing ( ucons) && length (ucons) != length (cstr) &&
310
+ haskey (kwargs, : ucons ) && length (kwargs[ : ucons] ) != length (cstr) &&
313
311
throw (ArgumentError (" Expected `ucons` to be of the same length as the vector of constraints" ))
312
+ lcons = haskey (kwargs, :lcons )
313
+ ucons = haskey (kwargs, :ucons )
314
314
end
315
315
316
316
if sparse
@@ -417,10 +417,8 @@ function OptimizationProblemExpr{iip}(sys::OptimizationSystem, u0,
417
417
lb = varmap_to_vars (dvs .=> lb, dvs; defaults = defs, tofloat = false , use_union)
418
418
ub = varmap_to_vars (dvs .=> ub, dvs; defaults = defs, tofloat = false , use_union)
419
419
420
- if ! isnothing (lb) && all (lb .== - Inf )
420
+ if ! isnothing (lb) && all (lb .== - Inf ) && ! isnothing (ub) && all (ub .== Inf )
421
421
lb = nothing
422
- end
423
- if ! isnothing (ub) && all (ub .== Inf )
424
422
ub = nothing
425
423
end
426
424
@@ -468,16 +466,18 @@ function OptimizationProblemExpr{iip}(sys::OptimizationSystem, u0,
468
466
cons_expr = toexpr .(subs_constants (constraints (cons_sys)))
469
467
rep_pars_vals! .(cons_expr, Ref (pairs_arr))
470
468
471
- if isnothing ( lcons) && isnothing ( ucons) # use the symbolically specified bounds
469
+ if ! haskey (kwargs, : lcons ) && ! haskey (kwargs, : ucons ) # use the symbolically specified bounds
472
470
lcons = lcons_
473
471
ucons = ucons_
474
472
else # use the user supplied constraints bounds
475
- xor ( isnothing (lcons), isnothing ( lcons)) &&
476
- throw (ArgumentError (" Expected both `lcons ` and `lcons` to be supplied" ))
477
- ! isnothing ( lcons) && length (lcons) != length (cstr) &&
473
+ haskey (kwargs, : lcons ) && haskey (kwargs, :ucons ) &&
474
+ throw (ArgumentError (" Expected both `ucons ` and `lcons` to be supplied" ))
475
+ haskey (kwargs, : lcons ) && length (kwargs[ : lcons] ) != length (cstr) &&
478
476
throw (ArgumentError (" Expected `lcons` to be of the same length as the vector of constraints" ))
479
- ! isnothing ( ucons) && length (ucons) != length (cstr) &&
477
+ haskey (kwargs, : ucons ) && length (kwargs[ : ucons] ) != length (cstr) &&
480
478
throw (ArgumentError (" Expected `ucons` to be of the same length as the vector of constraints" ))
479
+ lcons = haskey (kwargs, :lcons )
480
+ ucons = haskey (kwargs, :ucons )
481
481
end
482
482
483
483
if sparse
0 commit comments