@@ -150,28 +150,36 @@ For specifying Jacobians and mass matrices, see the
150150* `f`: The function in the problem.
151151* `u0`: The initial guess for the root.
152152* `p`: The parameters for the problem. Defaults to `NullParameters`.
153+ * `lb`: Lower bounds for the solution. Defaults to `nothing`.
154+ * `ub`: Upper bounds for the solution. Defaults to `nothing`.
153155* `kwargs`: The keyword arguments passed on to the solvers.
154156"""
155- mutable struct NonlinearProblem{uType, isinplace, P, F, K, PT} < :
157+ mutable struct NonlinearProblem{uType, isinplace, P, F, K, PT, LB, UB } < :
156158 AbstractNonlinearProblem{uType, isinplace}
157159 f:: F
158160 u0:: uType
159161 p:: P
160162 problem_type:: PT
163+ lb:: LB
164+ ub:: UB
161165 kwargs:: K
162166 @add_kwonly function NonlinearProblem {iip} (f:: AbstractNonlinearFunction{iip} , u0,
163167 p = NullParameters (),
164168 problem_type = StandardNonlinearProblem ();
169+ lb = nothing ,
170+ ub = nothing ,
165171 kwargs... ) where {iip}
166172 if haskey (kwargs, :p )
167173 error (" `p` specified as a keyword argument `p = $(kwargs[:p ]) ` to `NonlinearProblem`. This is not supported." )
168174 end
169175 warn_paramtype (p)
170176 new{typeof (u0), iip, typeof (p), typeof (f),
171- typeof (kwargs), typeof (problem_type)}(f,
177+ typeof (kwargs), typeof (problem_type), typeof (lb), typeof (ub) }(f,
172178 u0,
173179 p,
174180 problem_type,
181+ lb,
182+ ub,
175183 kwargs)
176184 end
177185
@@ -223,13 +231,13 @@ function NonlinearProblem(f::AbstractODEFunction, u0, p = NullParameters(); kwar
223231end
224232
225233function ConstructionBase. constructorof (:: Type{P} ) where {P <: NonlinearProblem }
226- function ctor (f, u0, p, pt, kw)
234+ function ctor (f, u0, p, pt, lb, ub, kw)
227235 if f isa AbstractNonlinearFunction
228236 iip = isinplace (f)
229237 else
230238 iip = isinplace (f, 4 )
231239 end
232- return NonlinearProblem {iip} (f, u0, p, pt; kw... )
240+ return NonlinearProblem {iip} (f, u0, p, pt; lb, ub, kw... )
233241 end
234242end
235243
@@ -296,21 +304,29 @@ For specifying Jacobians and mass matrices, see the
296304* `f`: The function in the problem.
297305* `u0`: The initial guess for the solution.
298306* `p`: The parameters for the problem. Defaults to `NullParameters`.
307+ * `lb`: Lower bounds for the solution. Defaults to `nothing`.
308+ * `ub`: Upper bounds for the solution. Defaults to `nothing`.
299309* `kwargs`: The keyword arguments passed on to the solvers.
300310"""
301- struct NonlinearLeastSquaresProblem{uType, isinplace, P, F, K} < :
311+ struct NonlinearLeastSquaresProblem{uType, isinplace, P, F, K, LB, UB } < :
302312 AbstractNonlinearProblem{uType, isinplace}
303313 f:: F
304314 u0:: uType
305315 p:: P
316+ lb:: LB
317+ ub:: UB
306318 kwargs:: K
307319
308320 @add_kwonly function NonlinearLeastSquaresProblem {iip} (
309321 f:: AbstractNonlinearFunction {
310322 iip}, u0,
311- p = NullParameters (); kwargs... ) where {iip}
323+ p = NullParameters ();
324+ lb = nothing ,
325+ ub = nothing ,
326+ kwargs... ) where {iip}
312327 warn_paramtype (p)
313- return new {typeof(u0), iip, typeof(p), typeof(f), typeof(kwargs)} (f, u0, p, kwargs)
328+ return new{typeof (u0), iip, typeof (p), typeof (f), typeof (kwargs),
329+ typeof (lb), typeof (ub)}(f, u0, p, lb, ub, kwargs)
314330 end
315331
316332 function NonlinearLeastSquaresProblem {iip} (f, u0, p = NullParameters ()) where {iip}
@@ -334,13 +350,13 @@ function NonlinearLeastSquaresProblem(f, u0, p = NullParameters(); kwargs...)
334350end
335351
336352function ConstructionBase. constructorof (:: Type{P} ) where {P <: NonlinearLeastSquaresProblem }
337- function ctor (f, u0, p, kw)
353+ function ctor (f, u0, p, lb, ub, kw)
338354 if f isa AbstractNonlinearFunction
339355 iip = isinplace (f)
340356 else
341357 iip = isinplace (f, 4 )
342358 end
343- return NonlinearLeastSquaresProblem {iip} (f, u0, p; kw... )
359+ return NonlinearLeastSquaresProblem {iip} (f, u0, p; lb, ub, kw... )
344360 end
345361end
346362
0 commit comments