Skip to content

Commit 3b36d39

Browse files
Merge pull request #477 from SciML/opt
add OptimizationProblem
2 parents 608b806 + f78cd3d commit 3b36d39

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DiffEqBase"
22
uuid = "2b5f629d-d688-5b77-993f-72d75c75574e"
33
authors = ["Chris Rackauckas <[email protected]>"]
4-
version = "6.27.0"
4+
version = "6.28.0"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/DiffEqBase.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ abstract type AbstractQuadratureProblem{isinplace} <: DEProblem end
6565
"""
6666
$(TYPEDEF)
6767
68+
Base for types which define equations for optimization
69+
"""
70+
abstract type AbstractOptimizationProblem{isinplace} <: DEProblem end
71+
72+
"""
73+
$(TYPEDEF)
74+
6875
Base for types which define steady state problems for ODE systems.
6976
"""
7077
abstract type AbstractSteadyStateProblem{uType,isinplace} <: DEProblem end
@@ -569,7 +576,7 @@ export resize!,deleteat!,addat!,get_tmp_cache,
569576
set_u!, check_error, change_t_via_interpolation!, addsteps!,
570577
isdiscrete, reeval_internals_due_to_modification!
571578

572-
export LinearProblem, NonlinearProblem, QuadratureProblem
579+
export LinearProblem, NonlinearProblem, QuadratureProblem, OptimizationProblem
573580

574581
export DiscreteProblem
575582
export SteadyStateProblem, SteadyStateSolution

src/problems/basic_problems.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,26 @@ struct QuadratureProblem{isinplace,P,F,L,U,K} <: AbstractQuadratureProblem{isinp
5858
end
5959

6060
QuadratureProblem(f,lb,ub,args...;kwargs...) = QuadratureProblem{isinplace(f, 3)}(f,lb,ub,args...;kwargs...)
61+
62+
"""
63+
$(TYPEDEF)
64+
"""
65+
struct OptimizationProblem{isinplace,F,uType,BType,P,K} <: AbstractOptimizationProblem{isinplace}
66+
f::F
67+
u0::uType
68+
lb::BType
69+
ub::BType
70+
p::P
71+
kwargs::K
72+
73+
@add_kwonly function OptimizationProblem{iip}(f,p=NullParameters();
74+
u0 = nothing,
75+
lb = nothing,
76+
ub = nothing,
77+
kwargs...) where iip
78+
new{iip,typeof(f),typeof(u0),typeof(lb),typeof(p),
79+
typeof(kwargs)}(f,u0,lb,ub,p,kwargs)
80+
end
81+
end
82+
83+
OptimizationProblem(f,args...;kwargs...) = OptimizationProblem{false}(f,args...;kwargs...)

0 commit comments

Comments
 (0)