Skip to content

Commit

Permalink
performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamed82008 committed Nov 10, 2023
1 parent 82c8f9d commit 3cf54e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/models/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ getmax(m::AbstractModel) = m.box_max
getmax(m::AbstractModel, i) = getmax(m)[i]

function getinit(model::AbstractModel)
_model, _, unflatten = tovecmodel(model, model.init)
return unflatten(getinit(_model))
return model.init
end

function setmin!(m::AbstractModel, min)
Expand Down
12 changes: 6 additions & 6 deletions src/models/vec_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,29 +140,29 @@ function tovecmodel(m::AbstractModel, _x0 = m.init)
# eq_constraints
length(m.eq_constraints.fs) != 0 ?
VectorOfFunctions(
map(m.eq_constraints.fs) do c
map(Tuple(m.eq_constraints.fs)) do c
EqConstraint(tovecfunc(c.f, x0)[1], maybeflatten(c.rhs)[1], c.dim, c.flags)
end,
) : VectorOfFunctions(EqConstraint[]),
) : VectorOfFunctions(()),
# ineq_constraints
length(m.ineq_constraints.fs) != 0 ?
VectorOfFunctions(
map(m.ineq_constraints.fs) do c
map(Tuple(m.ineq_constraints.fs)) do c
IneqConstraint(
tovecfunc(c.f, x0)[1],
maybeflatten(c.rhs)[1],
c.dim,
c.flags,
)
end,
) : VectorOfFunctions(IneqConstraint[]),
) : VectorOfFunctions(()),
# sd_constraints
length(m.sd_constraints.fs) != 0 ?
VectorOfFunctions(
map(m.sd_constraints.fs) do c
map(Tuple(m.sd_constraints.fs)) do c
SDConstraint(tovecfunc(c.f, x0; flatteny = false)[1], c.dim)
end,
) : VectorOfFunctions(SDConstraint[]),
) : VectorOfFunctions(()),
# box_min
float.(flatten(box_min)[1]),
# box_max
Expand Down

0 comments on commit 3cf54e2

Please sign in to comment.