Skip to content

Commit

Permalink
Don't convert to julia expression here
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaibhavdixit02 committed Nov 23, 2023
1 parent 6dd8d79 commit 0f3113f
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/systems/optimization/optimizationsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,6 @@ end

hessian_sparsity(sys::OptimizationSystem) = hessian_sparsity(get_op(sys), states(sys))

function rep_pars_vals!(e::Expr, p)
rep_pars_vals!.(e.args, Ref(p))
replace!(e.args, p...)
end

function rep_pars_vals!(e, p) end

"""
```julia
DiffEqBase.OptimizationProblem{iip}(sys::OptimizationSystem, u0map,
Expand Down Expand Up @@ -276,13 +269,7 @@ function DiffEqBase.OptimizationProblem{iip}(sys::OptimizationSystem, u0map,
expression = Val{false})

obj_expr = toexpr(subs_constants(objective(sys)))
pairs_arr = if p isa SciMLBase.NullParameters
[Symbol(_s) => Expr(:ref, :x, i) for (i, _s) in enumerate(dvs)]
else
vcat([Symbol(_s) => Expr(:ref, :x, i) for (i, _s) in enumerate(dvs)],
[Symbol(_p) => p[i] for (i, _p) in enumerate(ps)])
end
rep_pars_vals!(obj_expr, pairs_arr)

if grad
grad_oop, grad_iip = generate_gradient(sys, checkbounds = checkbounds,
linenumbers = linenumbers,
Expand Down Expand Up @@ -342,8 +329,7 @@ function DiffEqBase.OptimizationProblem{iip}(sys::OptimizationSystem, u0map,
else
_cons_h = nothing
end
cons_expr = toexpr.(subs_constants(constraints(cons_sys)))
rep_pars_vals!.(cons_expr, Ref(pairs_arr))
cons_expr = subs_constants(constraints(cons_sys))

if !haskey(kwargs, :lcons) && !haskey(kwargs, :ucons) # use the symbolically specified bounds
lcons = lcons_
Expand Down

0 comments on commit 0f3113f

Please sign in to comment.