JuliaSmoothOptimizers / JuliaSmoothOptimizers/ADNLPModels.jl
Document use of conditionals for sparsity detection
Open
documentation
- Dominant language
- Julia
- Stars
- 44
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
With the new `TracerSparsityDetector` from SparseConnectivityTracer, `if` blocks are not supported if they involve an input variable. They must be replaced with `ifelse` statements, which are compatible with operator overloading.
In your objective functions or constraints, do not write
```julia
y = if x[1] > 0
x[2]
else
x[3]
end
```
but instead write
```julia
y = ifelse(x[1] > 0, x[2], x[3])
```
Related:
- https://github.com/JuliaSmoothOptimizers/ADNLPModels.jl/issues/247#issuecomment-2207029473
Contributor guide
Assessment
This issue has not been assessed yet.