Skip to content

Commit 0f7388e

Browse files
spelling
1 parent d1b827d commit 0f7388e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/systems/optimization/optimizationsystem.jl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,12 @@ function DiffEqBase.OptimizationProblem{iip}(sys::OptimizationSystem, u0map,
305305
lcons = lcons_
306306
ucons = ucons_
307307
else # use the user supplied constraints bounds
308+
xor(isnothing(lcons), isnothing(lcons)) &&
309+
throw(ArgumentError("Expected both `lcons` and `lcons` to be supplied"))
308310
!isnothing(lcons) && length(lcons) != length(cstr) &&
309-
throw(ArgumentError("Expected both `lcons` to be of the same length as the vector of constraints"))
311+
throw(ArgumentError("Expected `lcons` to be of the same length as the vector of constraints"))
310312
!isnothing(ucons) && length(ucons) != length(cstr) &&
311-
throw(ArgumentError("Expected both `ucons` to be of the same length as the vector of constraints"))
313+
throw(ArgumentError("Expected `ucons` to be of the same length as the vector of constraints"))
312314
end
313315

314316
if sparse
@@ -399,9 +401,9 @@ function OptimizationProblemExpr{iip}(sys::OptimizationSystem, u0,
399401
xor(isnothing(lb), isnothing(ub)) &&
400402
throw(ArgumentError("Expected both `lb` and `ub` to be supplied"))
401403
!isnothing(lb) && length(lb) != length(dvs) &&
402-
throw(ArgumentError("Expected both `lb` to be of the same length as the vector of optimization variables"))
404+
throw(ArgumentError("Expected `lb` to be of the same length as the vector of optimization variables"))
403405
!isnothing(ub) && length(ub) != length(dvs) &&
404-
throw(ArgumentError("Expected both `ub` to be of the same length as the vector of optimization variables"))
406+
throw(ArgumentError("Expected `ub` to be of the same length as the vector of optimization variables"))
405407
end
406408

407409
int = isintegervar.(dvs) .| isbinaryvar.(dvs)
@@ -469,11 +471,13 @@ function OptimizationProblemExpr{iip}(sys::OptimizationSystem, u0,
469471
if isnothing(lcons) && isnothing(ucons) # use the symbolically specified bounds
470472
lcons = lcons_
471473
ucons = ucons_
472-
else # use the user supplied variable bounds
474+
else # use the user supplied constraints bounds
475+
xor(isnothing(lcons), isnothing(lcons)) &&
476+
throw(ArgumentError("Expected both `lcons` and `lcons` to be supplied"))
473477
!isnothing(lcons) && length(lcons) != length(cstr) &&
474-
throw(ArgumentError("Expected both `lcons` to be of the same length as the vector of constraints"))
478+
throw(ArgumentError("Expected `lcons` to be of the same length as the vector of constraints"))
475479
!isnothing(ucons) && length(ucons) != length(cstr) &&
476-
throw(ArgumentError("Expected both `ucons` to be of the same length as the vector of constraints"))
480+
throw(ArgumentError("Expected `ucons` to be of the same length as the vector of constraints"))
477481
end
478482

479483
if sparse

0 commit comments

Comments
 (0)