Skip to content

add_expr is broken #293

Description

@odow

See this example. The expression y looks correct, but when used in the objective it substitutes y[i] -> x[i] instead of y[i] -> x[p[I]]:

julia> using ExaModels, NLPModelsIpopt

julia> begin
           core = ExaModels.ExaCore(; concrete = Val(true))
           p = [3, 1, 2]
           x0 = [1, 2, 3]
           core, x = ExaModels.add_var(core, 3; lvar = x0, uvar = x0)
           core, y = ExaModels.add_expr(core, x[p_i] for p_i in p)
           core, _ = ExaModels.add_obj(core, i * y[i] for i in 1:3)
           m = ExaModels.ExaModel(core)
           result = NLPModelsIpopt.ipopt(m; print_level = 0)
           result.objective, sum(i * x0[p[i]] for i in 1:3)
       end
(14.0, 11)

julia> y
Subexpression (reduced)

  s  R^{3}
  s(x,i) = x[i]

julia> y[1], y[2], y[3]
(x[3], x[1], x[2])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions