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

Remove out-dated precompile.jl and simplify compile_workload #3871

Merged
merged 4 commits into from
Nov 6, 2024
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
50 changes: 19 additions & 31 deletions src/JuMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1367,13 +1367,20 @@
# at lowering time, not much of this would get precompiled without `@eval`
@eval begin
let
model = Model(
# We don't care about this particular optimizer, but it still
# exercises generic code paths that calls like
# Model(HiGHS.Optimizer) also need.
Model(
() -> MOI.Utilities.MockOptimizer(
MOI.Utilities.UniversalFallback(
MOI.Utilities.Model{Float64}(),
),
),
)
# Use an empty model to build, which is a common use-case, and
# doesn't bake in Utilities.MockOptimizer.
model = Model()
set_silent(model)
@variables(model, begin
x1 >= 0
0 <= x2 <= 1
Expand All @@ -1385,8 +1392,9 @@
x8[i = 1:3; isodd(i)], (start = i)
end)
@expressions(model, begin
a, -1 + x1 + x2
a, 2 * x1 + 3 * x2
b, 1 + x1^2 + x2
nl_expr, sin(x1)
end)
@constraints(model, begin
c1, a >= 0
Expand All @@ -1400,42 +1408,22 @@
[x1, x2, x1] in SecondOrderCone()
[1.0*x1 x2; x2 x1] >= 0, PSDCone()
1.0 * x1 ⟂ x2
nl_expr <= 1
end)
@objective(model, Min, x1)
@objective(model, Max, a)
@objective(model, Min, b)
@NLconstraint(model, c9, 1 * sin(x1) + 2.0 * sin(a) + sin(b) <= 1)
@NLparameter(model, p == 2)
@NLexpression(model, expr, x1^p)
@NLobjective(model, Min, 1 + expr)
set_optimizer(
model,
() -> MOI.Utilities.MockOptimizer(

Check warning on line 1418 in src/JuMP.jl

View check run for this annotation

Codecov / codecov/patch

src/JuMP.jl#L1418

Added line #L1418 was not covered by tests
MOI.Utilities.UniversalFallback(
MOI.Utilities.Model{Float64}(),
),
),
)
optimize!(model)
# This block could sit in MOI, but it's a public API at the JuMP
# level, so it can go here.
#
# We evaluate with a `view` because it's a common type for solvers
# like Ipopt to use.
d = NLPEvaluator(model)
MOI.features_available(d)
MOI.initialize(d, [:Grad, :Jac, :Hess])
g = zeros(num_nonlinear_constraints(model))
v_g = view(g, 1:length(g))
x = zeros(num_variables(model))
MOI.eval_objective(d, x)
MOI.eval_constraint(d, g, x)
MOI.eval_constraint(d, v_g, x)
MOI.eval_objective_gradient(d, g, x)
J = zeros(length(MOI.jacobian_structure(d)))
MOI.eval_constraint_jacobian(d, J, x)
v_J = view(J, 1:length(J))
MOI.eval_constraint_jacobian(d, v_J, x)
H = zeros(length(MOI.hessian_lagrangian_structure(d)))
v_H = view(H, 1:length(H))
MOI.eval_hessian_lagrangian(d, v_H, x, 1.0, v_g)
end
end
end

include("precompile.jl")
_precompile_()

end
60 changes: 0 additions & 60 deletions src/precompile.jl

This file was deleted.

Loading