Skip to content

Pass constraint names to CPLEX #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DillonJ opened this issue Mar 14, 2019 · 10 comments · Fixed by #261
Closed

Pass constraint names to CPLEX #225

DillonJ opened this issue Mar 14, 2019 · 10 comments · Fixed by #261
Labels
Wrapper: MathOptInterface Relates to the MathOptInterface API

Comments

@DillonJ
Copy link

DillonJ commented Mar 14, 2019

Hi,

All CPLEX solver messages are reported with generic constraint names e.g. c23474

It makes it very difficult to diagnose infeasibilities and such.

Is there a plan to pass the JuMP constraint names on to CPLEX? It seems possible as in GAMS for example I get more helpful names.

@mlubin
Copy link
Member

mlubin commented Mar 15, 2019

Yes, these names should be passed to CPLEX.

@chengg04
Copy link
Contributor

This should be possible as CPLEX API has a function called SetName() for such a purpose. We can have a wrapper for this.

@DillonJ
Copy link
Author

DillonJ commented Apr 29, 2020

Hi folks,

Thanks @odow and @mlubin for looking at this.

I'm wondering this is working properly or if I'm not using it correctly?

I have named all the constraints and variables in my model and I can see the names when I write an MPS file using write_to_file(). However, CPLEX still reports diagnostic information using generic names as follows:
Integer infeasible column 'x6467'.

Is there something specific I need to do ? Is it possible to relate the CPLEX name above to the MPS names in any way?

@odow
Copy link
Member

odow commented Apr 29, 2020

We pass variables names to CPLEX if they are ASCII: https://github.com/JuliaOpt/CPLEX.jl/blob/5ae4628446470fa0a46438cdfe577155dbcfd54c/src/MOI/MOI_wrapper.jl#L599-L603

So either your variable name is non-ascii, or it has an empty name (i.e., "").

If you can provide a minimal working example (using 2 or 3 variables, not 6000), open a new issue.

@DillonJ
Copy link
Author

DillonJ commented Apr 29, 2020

Ahhh...

julia> isascii("unit_flow_capacity(CLN,_ELEC_1911_CUI_110,_to_node,_2000-01-01T00:00:00_�_2000-01-01T01:00:00)")
false

Maybe some sanitisation to be done...

@DillonJ
Copy link
Author

DillonJ commented Apr 29, 2020

So that didn't solve it.

Here is a minimum example :

using JuMP
using CPLEX
m = Model(CPLEX.Optimizer)
@variable(m, bin_var1, Bin)
@variable(m, bin_var2, Bin)
con1=@constraint(m, constraint1, bin_var1 + bin_var2 >= 2)
con2=@constraint(m, constraint2, bin_var1            == 0)
@objective(m, Max, 5bin_var1 + 3bin_var2)
optimize!(m)
write_to_file(m, "cplex_min_example.mps")

Which outputs

Warning:  Non-integral bounds for integer variables rounded.
Warning:  No solution found from 1 MIP starts.
Retaining values of one MIP start for possible repair.
Warning:  Non-integral bounds for integer variables rounded.
Row 'c2' implies binary variable 'x2' is greater than 1.
Presolve time = 0.00 sec. (0.00 ticks)

And in the MPS file:

NAME          
ROWS
 N  OBJ
 G  constraint1
 E  constraint2
COLUMNS
    MARKER    'MARKER'                 'INTORG'
     bin_var2 constraint1 1
     bin_var2 OBJ      -3
    MARKER    'MARKER'                 'INTEND'
    MARKER    'MARKER'                 'INTORG'
     bin_var1 constraint1 1
     bin_var1 constraint2 1
     bin_var1 OBJ      -5
    MARKER    'MARKER'                 'INTEND'
RHS
    rhs       constraint1  2
    rhs       constraint2  0
RANGES
BOUNDS
 BV bounds    bin_var1
 BV bounds    bin_var2
ENDATA

Even if I explicitly use the set_name() function, CPLEX still reports anonymous constraint and variable names.

@odow
Copy link
Member

odow commented Apr 29, 2020

What happens if you use m = direct_model(CPLEX.Optimizer())

@DillonJ
Copy link
Author

DillonJ commented Apr 29, 2020

Ah, interesting :

Warning:  Non-integral bounds for integer variables rounded.
Warning:  No solution found from 1 MIP starts.
Retaining values of one MIP start for possible repair.
Warning:  Non-integral bounds for integer variables rounded.
Infeasibility row 'constraint1':  0 >= 1.
Presolve time = 0.00 sec. (0.00 ticks)

@odow
Copy link
Member

odow commented Apr 29, 2020

@blegat
Copy link
Member

blegat commented Apr 29, 2020

The names are not passed to the optimizer, they are only stored in the cache. It's not related to CPLEX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Wrapper: MathOptInterface Relates to the MathOptInterface API
Development

Successfully merging a pull request may close this issue.

5 participants