Skip to content

Commit

Permalink
Support setting parallel form in Symbolics dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
lassepe committed Oct 11, 2023
1 parent b76df14 commit 0a02e1b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/parametric_problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function ParametricMCP(
lower_bounds,
upper_bounds;
compute_sensitivities = true,
parallel = nothing,
)
length(lower_bounds) == length(upper_bounds) ||
throw(ArgumentError("lower_bounds and upper_bounds have inconsistent lenghts."))
Expand All @@ -91,7 +92,12 @@ function ParametricMCP(

# compile all the symbolic expressions into callable julia code
f! = let
_f! = Symbolics.build_function(f_symbolic, [z_symbolic; θ_symbolic]; expression = Val{false})[2]
_f! = Symbolics.build_function(
f_symbolic,
[z_symbolic; θ_symbolic];
expression = Val{false},
parallel,
)[2]
(result, z, θ) -> _f!(result, [z; θ])
end

Expand All @@ -100,6 +106,7 @@ function ParametricMCP(
jacobian_z_symbolic,
[z_symbolic; θ_symbolic];
expression = Val{false},
parallel,
)[2]
rows, cols, _ = SparseArrays.findnz(jacobian_z_symbolic)

Expand All @@ -115,6 +122,7 @@ function ParametricMCP(
jacobian_θ_symbolic,
[z_symbolic; θ_symbolic];
expression = Val{false},
parallel,
)[2]
rows, cols, _ = SparseArrays.findnz(jacobian_θ_symbolic)
SparseFunction(rows, cols, size(jacobian_θ_symbolic)) do result, z, θ
Expand Down

0 comments on commit 0a02e1b

Please sign in to comment.