Skip to content

Commit

Permalink
Correct piecewise linear function test
Browse files Browse the repository at this point in the history
  • Loading branch information
trulsf committed Jan 14, 2025
1 parent 43f7dba commit b4c3862
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/pwlinear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function piecewiselinear(
return piecewiselinear(
model,
(input_var_x, input_var_y),
BivariatePWLFunction(x, y, f; pattern = UnstructuredTriangulation());
BivariatePWLFunction(x, y, f; pattern = pattern);
method = method,
direction = direction,
output_vars = isnothing(output_var) ? nothing : (output_var,),
Expand Down
6 changes: 2 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ end
d = 7
xs = collect(range(1; stop = 2π, length = (d + 1)))
zs = sin.(xs)
pwl = PLO.UnivariatePWLFunction(xs, zs)
y = piecewiselinear(model, x, pwl; method = method)
y = piecewiselinear(model, x, xs, zs; method = method)
@objective(model, Max, y)
optimize!(model)
@test termination_status(model) == MOI.OPTIMAL
Expand Down Expand Up @@ -197,8 +196,7 @@ append!(method_pattern, uj_methods)
@variable(model, x[1:2])
d = range(0; stop = 1, length = 8)
f = (x1, x2) -> 2 * (x1 - 1 / 3)^2 + 3 * (x2 - 4 / 7)^4
pwl = PLO.BivariatePWLFunction(d, d, f; pattern = pattern)
z = piecewiselinear(model, x[1], x[2], pwl; method = method)
z = piecewiselinear(model, x[1], x[2], d, d, f; method = method, pattern = pattern)
@objective(model, Min, z)
optimize!(model)
@test termination_status(model) == MOI.OPTIMAL
Expand Down

0 comments on commit b4c3862

Please sign in to comment.