Skip to content

Printing models with parameters #2762

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

Open
joaquimg opened this issue May 22, 2025 · 4 comments
Open

Printing models with parameters #2762

joaquimg opened this issue May 22, 2025 · 4 comments

Comments

@joaquimg
Copy link
Member

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

@odow
Copy link
Member

odow commented May 22, 2025

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

@joaquimg
Copy link
Member Author

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?

@odow
Copy link
Member

odow commented May 22, 2025

@odow
Copy link
Member

odow commented May 23, 2025

So the issue is here:

function MOI.set(
b::AbstractBridgeOptimizer,
attr::MOI.VariableName,
vi::MOI.VariableIndex,
name::String,
)
if is_bridged(b, vi)
b.var_to_name[vi] = name
b.name_to_var = nothing # Invalidate the name map.
else
MOI.set(b.model, attr, vi, name)
end
return
end

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants