Skip to content

Commit

Permalink
Fixed unnecessary memory allocation in brute force search.
Browse files Browse the repository at this point in the history
  • Loading branch information
olof3 committed Jan 13, 2018
1 parent 06b2311 commit f966670
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/brute_force_search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@ index sets with m segemets. The costs are evaluated using least squares.
"""
function brute_force_search(ℓ::AbstractTransitionCost{T}, V_N::QuadraticPolynomial{T}, m::Integer) where {T}
cost_best = Inf

I_best = Vector{Int64}(m+1)
Y_best = Vector{T}(m+1)

N = size(ℓ, 2)

I = zeros(Int64, m+1)
I[1] = 1
I[end] = N

for I_inner=IterTools.subsets(2:N-1, m-1)
I = [1; I_inner; N]
# I = zeros(Int64, m+1)
# I[1] = 1
# I[end] = N
#
# for I_inner=IterTools.subsets(2:N-1, m-1)
#
# I[2:m] = I_inner

I[2:m] .= I_inner

P = zeros(m+1, m+1)
q = zeros(m+1)
Expand Down

0 comments on commit f966670

Please sign in to comment.