MathOptInterface.jl icon indicating copy to clipboard operation
MathOptInterface.jl copied to clipboard

Printing models with parameters

Open joaquimg opened this issue 7 months ago • 4 comments

Consider:

model = Model()
@variable(model, y == 18)
@variable(model, p in Parameter(1.3))
@constraint(model, c1, 2y + 3p >= 0)
@objective(model, Min, 5y + 6p)

write_to_file(model, "test_param.mps")

print(read("test_param.mps", String))

The resulting file is:

NAME
ROWS
 N  OBJ
 G  c1
COLUMNS
    y         c1        2
    y         OBJ       5
    x2        c1        3
    x2        OBJ       6
RHS
    rhs       c1        0
RANGES
BOUNDS
 FX bounds    y         18
 FX bounds    x2        1.3
ENDATA

It seems that, once the parameter goes to the ParameterToEqualToBridge the name information is lost

joaquimg avatar May 22 '25 20:05 joaquimg

I don't think we have a convention for what to do with bridged names.

odow avatar May 22 '25 22:05 odow

Do we bridge the variables themselves? or just the constraints? The bridge does not seem to create variables, so why would the name be lost?

joaquimg avatar May 22 '25 22:05 joaquimg

It's implemented as a variable bridge: https://github.com/jump-dev/MathOptInterface.jl/blob/master/src/Bridges/Variable/bridges/ParameterToEqualToBridge.jl

odow avatar May 22 '25 22:05 odow

So the issue is here:

https://github.com/jump-dev/MathOptInterface.jl/blob/bc869ec1d53bf2d35ddc94cc24b0d35a43e808c5/src/Bridges/bridge_optimizer.jl#L1687-L1700

If the variable is bridged we don't attempt to set the variable name of the inner.

I don't know that I'm strongly motivated to fix this.

odow avatar May 23 '25 02:05 odow

Closed by #2822

odow avatar Aug 26 '25 23:08 odow