Skip to content

Commit 343d8d3

Browse files
Merge pull request #987 from SciML/fix-formatter-line-splits
Initialize line split fixes following Catalyst.jl PR #1306
2 parents 19a6785 + 1aff553 commit 343d8d3

File tree

6 files changed

+7
-14
lines changed

6 files changed

+7
-14
lines changed

lib/OptimizationMOI/test/runtests.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@ end
232232
@parameters b = 4.0
233233
@parameters d = 2.0
234234
@named sys = OptimizationSystem(
235-
a * x[1]^2 + b * x[2]^2 + d * x[1] * x[2] + 5 * x[1] +
236-
x[2], [x...], [a, b, c, d];
235+
a * x[1]^2 + b * x[2]^2 + d * x[1] * x[2] + 5 * x[1] + x[2], [x...], [a, b, c, d];
237236
constraints = [
238237
x[1] + 2 * x[2] ~ 1.0
239238
])

lib/OptimizationMetaheuristics/src/OptimizationMetaheuristics.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ function initial_population!(opt, cache, bounds, f)
1515
Metaheuristics.optimize(f, bounds, opt_init)
1616

1717
pop_size = opt_init.parameters.N
18-
population_rand = [bounds[1, :] +
19-
rand(length(cache.u0)) .* (bounds[2, :] - bounds[1, :])
18+
population_rand = [bounds[1, :] + rand(length(cache.u0)) .* (bounds[2, :] - bounds[1, :])
2019
for i in 1:(pop_size - 1)]
2120
push!(population_rand, cache.u0)
2221
population_init = [Metaheuristics.create_child(x, f(x)) for x in population_rand]

lib/OptimizationMetaheuristics/test/runtests.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ Random.seed!(42)
7070
end
7171

7272
function rosenbrock(x)
73-
f1 = sum(100 .* (x[2:end] .- x[1:(end - 1)] .^ 2) .^ 2 .+
74-
(x[1:(end - 1)] .- 1) .^ 2)
75-
f2 = sum(100 .* ((x[2:end] .- 2.0) .- (x[1:(end - 1)] .^ 2)) .^ 2 .+
76-
((x[1:(end - 1)] .- 1.0) .^ 2))
73+
f1 = sum(100 .* (x[2:end] .- x[1:(end - 1)] .^ 2) .^ 2 .+ (x[1:(end - 1)] .- 1) .^ 2)
74+
f2 = sum(100 .* ((x[2:end] .- 2.0) .- (x[1:(end - 1)] .^ 2)) .^ 2 .+ ((x[1:(end - 1)] .- 1.0) .^ 2))
7775
gx = [0.0]
7876
hx = [0.0]
7977
return [f1, f2], gx, hx

lib/OptimizationNLPModels/test/runtests.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ using Test
2828
# https://jso.dev/NLPModelsTest.jl/dev/reference/#NLPModelsTest.BROWNDEN
2929
# Problem without bounds
3030
function brown_dennis(u, p)
31-
return sum([((u[1] + (i / 5) * u[2] - exp(i / 5))^2 +
32-
(u[3] + sin(i / 5) * u[4] - cos(i / 5))^2)^2 for i in 1:20])
31+
return sum([((u[1] + (i / 5) * u[2] - exp(i / 5))^2 + (u[3] + sin(i / 5) * u[4] - cos(i / 5))^2)^2 for i in 1:20])
3332
end
3433
f = Optimization.OptimizationFunction(brown_dennis, Optimization.AutoZygote())
3534
u0 = [25.0; 5.0; -5.0; -1.0]

src/auglag.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ function SciMLBase.__solve(cache::OptimizationCache{
109109
if cache.callback(opt_state, x...)
110110
error("Optimization halted by callback.")
111111
end
112-
return x[1] + sum(@. λ * cons_tmp[eq_inds] + ρ / 2 * (cons_tmp[eq_inds] .^ 2)) +
113-
1 / (2 * ρ) * sum((max.(Ref(0.0), μ .+.* cons_tmp[ineq_inds]))) .^ 2)
112+
return x[1] + sum(@. λ * cons_tmp[eq_inds] + ρ / 2 * (cons_tmp[eq_inds] .^ 2)) + 1 / (2 * ρ) * sum((max.(Ref(0.0), μ .+.* cons_tmp[ineq_inds]))) .^ 2)
114113
end
115114

116115
prev_eqcons = zero(λ)

src/lbfgsb.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ function SciMLBase.__solve(cache::OptimizationCache{
129129
if cache.callback(opt_state, x...)
130130
error("Optimization halted by callback.")
131131
end
132-
return x[1] + sum(@. λ * cons_tmp[eq_inds] + ρ / 2 * (cons_tmp[eq_inds] .^ 2)) +
133-
1 / (2 * ρ) * sum((max.(Ref(0.0), μ .+.* cons_tmp[ineq_inds]))) .^ 2)
132+
return x[1] + sum(@. λ * cons_tmp[eq_inds] + ρ / 2 * (cons_tmp[eq_inds] .^ 2)) + 1 / (2 * ρ) * sum((max.(Ref(0.0), μ .+.* cons_tmp[ineq_inds]))) .^ 2)
134133
end
135134

136135
prev_eqcons = zero(λ)

0 commit comments

Comments
 (0)