Skip to content

Commit 60ff5ec

Browse files
committed
added $e1/3[1] for constraints with length one lower / upper bounds
1 parent ffa126e commit 60ff5ec

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

src/onepass.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ function p_constraint_exa!(p, p_ocp, e1, e2, e3, c_type, label)
731731
e2 = replace_call(e2, p.x, p.tf, xf)
732732
e2 = subs2(e2, x0, p.x, 0)
733733
e2 = subs2(e2, xf, p.x, :grid_size)
734-
concat(code, :($pref.constraint($p_ocp, $e2; lcon=($e1), ucon=($e3))))
734+
concat(code, :($pref.constraint($p_ocp, $e2; lcon=($e1[1]), ucon=($e3[1])))) # todo: e1/3[1] will be e1/3[k] when vectorised over dim
735735
end
736736
(:initial, rg) => begin
737737
if isnothing(rg)
@@ -837,7 +837,7 @@ function p_constraint_exa!(p, p_ocp, e1, e2, e3, c_type, label)
837837
concat(
838838
code,
839839
:($pref.constraint(
840-
$p_ocp, $e2 for $j in 0:grid_size; lcon=($e1), ucon=($e3)
840+
$p_ocp, $e2 for $j in 0:grid_size; lcon=($e1[1]), ucon=($e3[1])
841841
)),
842842
)
843843
end

test/test_onepass_exa.jl

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ function __test_onepass_exa(
5454
)
5555
backend_name = isnothing(backend) ? "CPU" : "GPU"
5656

57-
@ignore begin # debug
5857
test_name = "min ($backend_name, $scheme)"
5958
@testset "$test_name" begin
6059
println(test_name)
@@ -1020,9 +1019,8 @@ function __test_onepass_exa(
10201019
sol = madnlp(m; tol=tolerance, kwargs...)
10211020
@test sol.status == MadNLP.SOLVE_SUCCEEDED
10221021
end
1023-
end # debug
10241022

1025-
test_name = "use case no. 8: stability of solve for unilateral constraints ($backend_name, $scheme)"
1023+
test_name = "use case no. 8: example of solve with unilateral nonlinear constraints ($backend_name, $scheme)"
10261024
@testset "$test_name" begin
10271025
println(test_name)
10281026

@@ -1044,16 +1042,10 @@ function __test_onepass_exa(
10441042
(x₁(0)^2 + x₂(0)^2 + x₃(0)^2 + (x₁(1) + x₂(1) + x₃(1))^2) + 0.5( u₁(t)^2 + u₂(t)^2 ) min
10451043
end
10461044

1047-
N = 250
1048-
max_iter = 2
1045+
N = 100
10491046
m, _ = discretise_exa_full(o; grid_size=N, backend=backend, scheme=scheme)
10501047
@test m isa ExaModels.ExaModel
1051-
sol = madnlp(m; tol=tolerance, max_iter=max_iter, kwargs...)
1052-
obj1 = sol.objective
1053-
sol = madnlp(m; tol=tolerance, max_iter=max_iter, kwargs...)
1054-
obj2 = sol.objective
1055-
1056-
__atol = 1e-9
1057-
@test obj1 obj2 atol = __atol
1048+
sol = madnlp(m; tol=tolerance, kwargs...)
1049+
@test sol.status == MadNLP.SOLVE_SUCCEEDED
10581050
end
10591051
end

0 commit comments

Comments
 (0)