How to identify a constraint in JuMp?


I’m writing all constrained with a given name, as follows:

@constraint(m, constraint[j in 1:20], sum(A[j,i]*x[i] for i in 1:30) <= b[j])

after runing the model, it returns Infeasibility row 'c11': 0 = 1.

how can I find that row c11 is correnspond to which constraint? None of the name that I used for my constraint are in the format of c followd by number like c11

What solver are you using?

I call CPLEX

You need to set the CPLEX.PassNames attribute:

julia> using JuMP, CPLEX

julia> model = Model(CPLEX.Optimizer);

julia> set_optimizer_attribute(model, CPLEX.PassNames(), true)

julia> @constraint(model, my_constraint, 0 == 1)
my_constraint : 0 = 1.0

julia> optimize!(model)
CPLEX Error  3003: Not a mixed-integer problem.
Version identifier: | 2019-11-26 | 843d4de
Infeasibility row 'my_constraint':  0  = 1.
Presolve time = 0.00 sec. (0.00 ticks)

See the documentation in the CPLEX.Optimizer object:

help?> CPLEX.Optimizer
  Optimizer(env::Union{Nothing, Env} = nothing)

  Create a new Optimizer object.

  You can share CPLEX Envs between models by passing an instance of Env as the first argument.

  Set optimizer attributes using MOI.RawOptimizerAttribute or JuMP.set_optimizer_atttribute.


  using JuMP, CPLEX
  const env = CPLEX.Env()
  model = JuMP.Model(() -> CPLEX.Optimizer(env)
  set_optimizer_attribute(model, "CPXPARAM_ScreenOutput", 0)


  By default, variable and constraint names are stored in the MOI wrapper, but are not passed to
  the inner CPLEX model object because doing so can lead to a large performance degradation. The
  downside of not passing names is that various log messages from CPLEX will report names like
  constraint "R1" and variable "C2" instead of their actual names. You can change this behavior
  using CPLEX.PassNames to force CPLEX.jl to pass variable and constraint names to the inner CPLEX
  model object:

  using JuMP, CPLEX
  model = JuMP.Model(CPLEX.Optimizer)
  set_optimizer_attribute(model, CPLEX.PassNames(), true)
1 Like

Thanks odow

1 Like