Skip to content

Commit

Permalink
internalize a potentially useful variables_for
Browse files Browse the repository at this point in the history
  • Loading branch information
exaexa committed Jan 4, 2024
1 parent 0eca87f commit 328010b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/constraint_tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ function variables(; keys::AbstractVector{Symbol}, bounds = nothing)
)
end

"""
$(TYPEDSIGNATURES)
Allocate a variable for each item in a constraint tree (or any other kind of
tree) and return a [`ConstraintTree`](@ref) with variables bounded by the
`makebound` function, which converts a given tree element's value into a bound
for the corresponding variable.
"""
function variables_for(makebound, ts::Tree)
var_idx = 0
map(ts, Constraint) do x
var_idx += 1
variable(idx = var_idx, bound = makebound(x))

Check warning on line 231 in src/constraint_tree.jl

View check run for this annotation

Codecov / codecov/patch

src/constraint_tree.jl#L227-L231

Added lines #L227 - L231 were not covered by tests
end
end

#
# Transforming the constraint trees
#
Expand Down

0 comments on commit 328010b

Please sign in to comment.