Skip to content

Commit

Permalink
Handle empty parameters correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
lassepe committed Nov 22, 2023
1 parent 08c43c4 commit 555eead
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/parametric_problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ function ParametricMCP(
Symbolics.@variables(z_symbolic[1:problem_size], θ_symbolic[1:parameter_dimension]) .|>
Symbolics.scalarize

if isempty(θ_symbolic)
θ_symbolic = Symbolics.Num[]

Check warning on line 59 in src/parametric_problem.jl

View check run for this annotation

Codecov / codecov/patch

src/parametric_problem.jl#L59

Added line #L59 was not covered by tests
end

f_symbolic = f(z_symbolic, θ_symbolic)

ParametricMCP(
Expand Down
2 changes: 1 addition & 1 deletion src/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function solve(
length(initial_guess) == get_problem_size(problem) ||
throw(ArgumentError("initial guess must have length $(get_problem_size(problem))"))
length(θ) == get_parameter_dimension(problem) ||
throw(ArgumentError("θ must have length $(get_parameter_dimension(problem))"))
throw(ArgumentError("θ must have length $(get_parameter_dimension(problem)), got $(θ)"))

(; f!, jacobian_z!, lower_bounds, upper_bounds) = problem

Expand Down

0 comments on commit 555eead

Please sign in to comment.