Skip to content

Commit

Permalink
Remove out-dated precompile.jl and simplify compile_workload
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Nov 6, 2024
1 parent b016cdd commit 9bc9c66
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 97 deletions.
40 changes: 3 additions & 37 deletions src/JuMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1367,13 +1367,7 @@ PrecompileTools.@compile_workload begin
# at lowering time, not much of this would get precompiled without `@eval`
@eval begin
let
model = Model(
() -> MOI.Utilities.MockOptimizer(
MOI.Utilities.UniversalFallback(
MOI.Utilities.Model{Float64}(),
),
),
)
model = Model()
@variables(model, begin
x1 >= 0
0 <= x2 <= 1
Expand All @@ -1387,6 +1381,7 @@ PrecompileTools.@compile_workload begin
@expressions(model, begin
a, -1 + x1 + x2
b, 1 + x1^2 + x2
nl_expr, sin(x)
end)
@constraints(model, begin
c1, a >= 0
Expand All @@ -1400,42 +1395,13 @@ PrecompileTools.@compile_workload begin
[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)
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.

0 comments on commit 9bc9c66

Please sign in to comment.