Skip to content

Commit 11bd665

Browse files
Update runtests.jl
Correcting function definition.
1 parent 17204c4 commit 11bd665

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/OptimizationODE/test/runtests.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,21 @@ end
102102
# Minimize f(x) = x₁² + x₂²
103103
# Subject to x₁ - x₂ = 1
104104

105-
function constrained_objective(x, p,args...)
105+
function constrained_objective(x, p)
106106
return x[1]^2 + x[2]^2
107107
end
108108

109-
function constrained_objective_grad!(g, x, p, args...)
109+
function constrained_objective_grad!(g, x, p)
110110
g .= 2 .* x .* p[1]
111111
return nothing
112112
end
113113

114114
# Constraint: x₁ - x₂ - p[1] = 0 (p[1] = 1 → x₁ - x₂ = 1)
115-
function constraint_func(x, p, args...)
115+
function constraint_func(x, p)
116116
return x[1] - x[2] - p[1]
117117
end
118118

119-
function constraint_jac!(J, x,args...)
119+
function constraint_jac!(J, x)
120120
J[1, 1] = 1.0
121121
J[1, 2] = -1.0
122122
return nothing
@@ -159,8 +159,8 @@ end
159159
x0 = [0.0, 0.0]
160160
p=Float64[] # No parameters provided
161161
# Create a problem with NullParameters
162-
optf = OptimizationFunction((x, p, args...) -> sum(x.^2),
163-
grad=(grad, x, p, args...) -> (grad .= 2.0 .* x))
162+
optf = OptimizationFunction((x, p) -> sum(x.^2),
163+
grad=(grad, x, p) -> (grad .= 2.0 .* x))
164164
prob = OptimizationProblem(optf, x0,p) # No parameters provided
165165

166166
opt = ODEGradientDescent()
@@ -262,8 +262,8 @@ end
262262
x0 = [0.5]
263263
p = [1.0]
264264

265-
single_var_func(x, p,args...) = (x[1] - p[1])^2
266-
single_var_grad!(grad, x, p,args...) = (grad[1] = 2.0 * (x[1] - p[1]))
265+
single_var_func(x, p) = (x[1] - p[1])^2
266+
single_var_grad!(grad, x, p) = (grad[1] = 2.0 * (x[1] - p[1]))
267267

268268
optf = OptimizationFunction(single_var_func; grad=single_var_grad!)
269269
prob = OptimizationProblem(optf, x0, p)

0 commit comments

Comments
 (0)