Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update format for JuliaFormatter v1.0.15 #3130

Merged
merged 4 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CSV = "0.10"
DataFrames = "1"
Documenter = "0.27.9"
GLPK = "=1.1.0"
HTTP = "1"
HTTP = "=1.5.2"
HiGHS = "=1.2.0"
Interpolations = "0.14"
Ipopt = "=1.1.0"
Expand Down
6 changes: 3 additions & 3 deletions docs/src/tutorials/linear/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ function example_user_cut_constraint()
function my_callback_function(cb_data)
callback_called = true
x_vals = callback_value.(Ref(cb_data), x)
accumulated = sum(item_weights[i] for i = 1:N if x_vals[i] > 1e-4)
accumulated = sum(item_weights[i] for i in 1:N if x_vals[i] > 1e-4)
println("Called with accumulated = $(accumulated)")
n_terms = sum(1 for i = 1:N if x_vals[i] > 1e-4)
n_terms = sum(1 for i in 1:N if x_vals[i] > 1e-4)
if accumulated > 10
con = @build_constraint(
sum(x[i] for i = 1:N if x_vals[i] > 0.5) <= n_terms - 1
sum(x[i] for i in 1:N if x_vals[i] > 0.5) <= n_terms - 1
)
println("Adding $(con)")
MOI.submit(model, MOI.UserCut(cb_data), con)
Expand Down
2 changes: 1 addition & 1 deletion src/lp_sensitivity2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function lp_sensitivity_report(model::Model; atol::Float64 = 1e-8)
# We call `collect` here because some Julia versions are missing sparse
# matrix \ sparse vector fallbacks.
j => B_fact \ collect(std_form.A[:, j]) for
j = 1:length(basis.basic_cols) if basis.basic_cols[j] == false
j in 1:length(basis.basic_cols) if basis.basic_cols[j] == false
)

report = SensitivityReport(
Expand Down
6 changes: 3 additions & 3 deletions test/constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -649,15 +649,15 @@ function test_sum_constraint(ModelType, ::Any)
C = [1 2 3; 4 5 6; 7 8 9]

@test_expression sum(C[i, j] * x[i, j] for i in 1:2, j in 2:3)
@test_expression sum(C[i, j] * x[i, j] for i = 1:3, j in 1:3 if i != j) - y
@test_expression sum(C[i, j] * x[i, j] for i in 1:3, j in 1:3 if i != j) - y
@test JuMP.isequal_canonical(
@expression(model, sum(C[i, j] * x[i, j] for i in 1:3, j in 1:i)),
sum(C[i, j] * x[i, j] for i in 1:3 for j in 1:i),
)
@test_expression sum(C[i, j] * x[i, j] for i in 1:3 for j in 1:i)
@test_expression sum(C[i, j] * x[i, j] for i = 1:3 if true for j in 1:i)
@test_expression sum(C[i, j] * x[i, j] for i in 1:3 if true for j in 1:i)
@test_expression sum(
C[i, j] * x[i, j] for i = 1:3 if true for j = 1:i if true
C[i, j] * x[i, j] for i in 1:3 if true for j in 1:i if true
)
@test_expression sum(0 * x[i, 1] for i in 1:3)
@test_expression sum(0 * x[i, 1] + y for i in 1:3)
Expand Down
12 changes: 6 additions & 6 deletions test/hygiene.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,30 @@ JuMP.@variable(model, z[i = 1:2, j = 1:2], Symmetric)
@test z isa LinearAlgebra.Symmetric

JuMP.@constraint(model, x + sum(j * y[j] for j in r) <= 1)
JuMP.@constraint(model, sum(y[j] for j = r if j == 4) <= 1)
JuMP.@constraint(model, sum(y[j] for j in r if j == 4) <= 1)
JuMP.@constraint(model, -1 <= x + y[3] <= 1)
JuMP.@constraints(model, begin
x + sum(j * y[j] for j in r) <= 1
sum(y[j] for j = r if j == 4) <= 1
sum(y[j] for j in r if j == 4) <= 1
end)

JuMP.@constraint(model, [x x; -x x] >= 0, JuMP.PSDCone())

JuMP.@objective(model, sense, y[4])
JuMP.@objective(model, Min, x + sum(j * y[j] for j in r))
JuMP.@objective(model, Max, sum(y[j] for j = r if j == 4))
JuMP.@objective(model, Max, sum(y[j] for j in r if j == 4))

JuMP.@NLconstraint(model, y[3] == 1)
JuMP.@NLconstraint(model, x + sum(j * y[j] for j in r) <= 1)
JuMP.@NLconstraint(model, sum(y[j] for j = r if j == 4) <= 1)
JuMP.@NLconstraint(model, sum(y[j] for j in r if j == 4) <= 1)
JuMP.@NLconstraints(model, begin
x + sum(j * y[j] for j in r) <= 1
sum(y[j] for j = r if j == 4) <= 1
sum(y[j] for j in r if j == 4) <= 1
end)

JuMP.@NLobjective(model, sense, y[4])
JuMP.@NLobjective(model, Min, x + sum(j * y[j] for j in r))
JuMP.@NLobjective(model, Max, sum(y[j] for j = r if j == 4))
JuMP.@NLobjective(model, Max, sum(y[j] for j in r if j == 4))

# TODO: Add tests for the content of the model.

Expand Down
2 changes: 1 addition & 1 deletion test/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ let id = 0
end

function test_Check_Julia_generator_expression_parsing()
sumexpr = :(sum(x[i, j] * y[i, j] for i = 1:N, j in 1:M if i != j))
sumexpr = :(sum(x[i, j] * y[i, j] for i in 1:N, j in 1:M if i != j))
@test sumexpr.head == :call
@test sumexpr.args[1] == :sum
@test sumexpr.args[2].head == :generator
Expand Down
12 changes: 6 additions & 6 deletions test/perf/JuMPBenchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ function _macro_linear(N::Int)
sum(
sum(
N * i * j * k * y[i, j, k] + x[i, j] for
k = 1:N if i != j && j != k
k in 1:N if i != j && j != k
) for j in 1:N
) for i in 1:N
) + sum(
sum(x[i, j] for j = 1:5N if j % i == 3) for
i = 1:10N if i <= N * z
sum(x[i, j] for j in 1:5N if j % i == 3) for
i in 1:10N if i <= N * z
)
)
end
Expand All @@ -252,12 +252,12 @@ function _macro_quad(N::Int)
sum(
sum(
N * i * j * k * y[i, j, k] * x[i, j] for
k = 1:N if i != j && j != k
k in 1:N if i != j && j != k
) for j in 1:N
) for i in 1:N
) + sum(
sum(x[i, j] for j = 1:5N if j % i == 3) for
i = 1:10N if i <= N * z
sum(x[i, j] for j in 1:5N if j % i == 3) for
i in 1:10N if i <= N * z
)
)
end
Expand Down