Pack groups of similar constraints of sum of similar terms into lightweight generators. This representation can then be used by ExaModels to accelerate the Automatic Differentiation on GPU. See the presentation at JuMP-dev 2025.
GenOpt.jl is licensed under the MIT license.
The package is not registered yet so to install GenOpt using Pkg.add, do:
import Pkg
Pkg.add("https://github.com/blegat/GenOpt.jl")To create a group of constraints, give ParametrizedArray as container keyword:
using GenOpt
@constraint(
model,
[i in 1:n],
x[1, i] == x0[i],
container = ParametrizedArray,
)To a grouped sum, use lazy_sum as follows:
@objective(
model,
Min,
lazy_sum(0.5 * R[j] * (u[i, j]^2) for i in 1:N, j in 1:p),
)To solve it on GPU with ExaModels, use
set_optimizer(model, () -> GenOpt.ExaOptimizer(madnlp, CUDABackend()))
optimize!(model)