-
-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathprecompilation.jl
More file actions
22 lines (17 loc) · 705 Bytes
/
precompilation.jl
File metadata and controls
22 lines (17 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using PrecompileTools
@setup_workload begin
@compile_workload begin
# Precompile basic OptimizationFunction and OptimizationProblem creation
# These are the most common operations users perform
# Simple objective function
f_simple(x, p) = sum(abs2, x .- p)
# Create OptimizationFunction with NoAD (most basic case)
optf = OptimizationFunction(f_simple)
# Create OptimizationProblem with common type combinations
x0 = zeros(2)
p = [1.0, 2.0]
prob = OptimizationProblem(optf, x0, p)
# Also precompile with bounds
prob_bounded = OptimizationProblem(optf, x0, p; lb = zeros(2), ub = ones(2))
end
end