Skip to content
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

Priority in variable bridge #165

Closed
blegat opened this issue Jan 21, 2025 · 3 comments
Closed

Priority in variable bridge #165

blegat opened this issue Jan 21, 2025 · 3 comments

Comments

@blegat
Copy link
Member

blegat commented Jan 21, 2025

In the following model, Q is added as a constrained variable in the copy and it is then set as a parameter after. Because of this, it goes through the slack bridge which create a new variable that is a parameter and that is equal to Q[]. Then it fails saying that Mosek does not support quadratic constraints because it does not see Q[] as a parameter anymore.
During a copy, Parameter should have higher priority to be added as variable-wise constraint.

model = Model(() -> POI.Optimizer(Mosek.Optimizer()))
@variable(model, x)
@variable(model, Q[1:1, 1:1] in PSDCone())
@constraint(model, Q[] in Parameter(1.0))
@constraint(model, Q[] * x == 0)
optimize!(model)
@odow
Copy link
Member

odow commented Jan 21, 2025

That's a messed up way to write the model! I don't know that I condone this approach. I would have done:

model = Model(() -> POI.Optimizer(Mosek.Optimizer()))
@variable(model, x)
@variable(model, Q[1:1, 1:1] in PSDCone())
@variable(model, p in Parameter(1.0))
@constraint(model, Q[1, 1] == p)
@constraint(model, p * x == 0)
optimize!(model)

@joaquimg
Copy link
Member

I would write as @odow did. For me it is not surprising that Q[] * x is quadratic.

Maybe the user-proof solution is that the Parameter set should only be used in add_constrained_variable and never in add_constraint?

I still think that a @parameter macro would be very helpful to users, at least in POI.

@blegat
Copy link
Member Author

blegat commented Jan 21, 2025

@odow The way you write it is exactly the model after bridging Thinking more about it, I think the behavior makes sense. There could also be only part of the matrices that are set to parameters in which case what is done currently is definitely right.

@blegat blegat closed this as completed Jan 21, 2025
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

3 participants