Skip to content

Specifying variables in add_constraint not working #113

@margaeor

Description

@margaeor

When calling the add_non_linear_constraint method, specifying the argument vars as seen in the examples doesn't seem to do anything. In order to make it work, we have to specify expr_vars instead.
For instance, in the code snipped below, the first line with add_nonlinear_constraint doesn't
work. Whereas the second (commented) line works.

N = 5
M = 1

m = JuMP.Model(with_optimizer(CPLEX_SILENT))
@variable(m, x[1:N+1])
@objective(m, Min, x[N+1])

# Initialize GlobalModel
gm = OCTHaGOn.GlobalModel(model = m, name = "qp")

Q = randn(N, N)
c = randn(N)
expr = :((x) -> -x'*$(Q)*x - $(c)'*x)

lbs = push!(-5*ones(N), -800)
ubs = push!(5*ones(N), 0)
lbs_dict = Dict(x .=> lbs)
ubs_dict = Dict(x .=> ubs)

OCTHaGOn.bound!(gm, Dict(var => [lbs_dict[var], ubs_dict[var]] for var in gm.vars))
        

# Add constraints
OCTHaGOn.add_nonlinear_constraint(gm, expr, vars=x[1:N])
#OCTHaGOn.add_nonlinear_constraint(gm, expr, vars=x[1:N], expr_vars=[x[1:N]])

OCTHaGOn.globalsolve!(gm)

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions