-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
I am investigating the solution of optimization problems with parameters in ExaModels. Currently, the following syntax is breaking:
N = 10
params = rand(N)
core = ExaModels.ExaCore(Float64)
x = ExaModels.variable(core, N)
expr = ExaModels.constraint(core, x[i] + params[i] for i in 1:N; lcon=0.0, ucon=Inf)
The current solution is to pass the parameters directly in the iterator, like
N = 10
params = rand(N)
core = ExaModels.ExaCore(Float64)
x = ExaModels.variable(core, N)
expr = ExaModels.constraint(core, x[i]+p for (i, p) in zip(1:N, params); lcon=0.0, ucon=Inf)
However, that means that if we change the parameters, they are not easy to update in the model, as that means modifying the iterator inplace.
I am wondering if we should add a new object in the expression tree to make parameters first-class citizen in ExaModels. A potential syntax would be
N = 10
params = rand(N)
core = ExaModels.ExaCore(Float64)
x = ExaModels.variable(core, N)
p = ExaModels.parameters(params)
expr = ExaModels.constraint(core, x[i] + p[i] for i in 1:N; lcon=0.0, ucon=Inf)
An idea would be to implement a new node as:
struct Parameter{I} <: AbstractNode
i::I
end
and implements the same functions as for Var.
The values of the parameters would be stored in a vector inside ExaCore. If we do that, it would be very easy to update the parameters.
cc @klamike
klamike and KSepetanc
Metadata
Metadata
Assignees
Labels
No labels