From 60f3acd25c36f4957fc766630744bce8ffa6cc70 Mon Sep 17 00:00:00 2001 From: Vaibhav Dixit Date: Thu, 19 Oct 2023 23:38:40 -0400 Subject: [PATCH] minor fixes --- src/systems/optimization/modelingtoolkitize.jl | 2 +- src/systems/optimization/optimizationsystem.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/systems/optimization/modelingtoolkitize.jl b/src/systems/optimization/modelingtoolkitize.jl index 710f3f392b..254f2d1a3a 100644 --- a/src/systems/optimization/modelingtoolkitize.jl +++ b/src/systems/optimization/modelingtoolkitize.jl @@ -26,7 +26,7 @@ function modelingtoolkitize(prob::DiffEqBase.OptimizationProblem; kwargs...) if !isnothing(prob.lcons) for i in 1:num_cons if !isinf(prob.lcons[i]) - if prob.lcons[i] != prob.ucons[i] && + if prob.lcons[i] != prob.ucons[i] push!(cons, prob.lcons[i] ≲ lhs[i]) else push!(cons, lhs[i] ~ prob.ucons[i]) diff --git a/src/systems/optimization/optimizationsystem.jl b/src/systems/optimization/optimizationsystem.jl index e1ab36c9ae..2bd0cefe9a 100644 --- a/src/systems/optimization/optimizationsystem.jl +++ b/src/systems/optimization/optimizationsystem.jl @@ -349,7 +349,7 @@ function DiffEqBase.OptimizationProblem{iip}(sys::OptimizationSystem, u0map, lcons = lcons_ ucons = ucons_ else # use the user supplied constraints bounds - haskey(kwargs, :lcons) && haskey(kwargs, :ucons) && + (haskey(kwargs, :lcons) ⊻ haskey(kwargs, :ucons)) && throw(ArgumentError("Expected both `ucons` and `lcons` to be supplied")) haskey(kwargs, :lcons) && length(kwargs[:lcons]) != length(cstr) && throw(ArgumentError("Expected `lcons` to be of the same length as the vector of constraints")) @@ -527,7 +527,7 @@ function OptimizationProblemExpr{iip}(sys::OptimizationSystem, u0map, lcons = lcons_ ucons = ucons_ else # use the user supplied constraints bounds - !haskey(kwargs, :lcons) && !haskey(kwargs, :ucons) && + (haskey(kwargs, :lcons) ⊻ haskey(kwargs, :ucons)) && throw(ArgumentError("Expected both `ucons` and `lcons` to be supplied")) haskey(kwargs, :lcons) && length(kwargs[:lcons]) != length(cstr) && throw(ArgumentError("Expected `lcons` to be of the same length as the vector of constraints"))