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

How to use feasRelax in Gurobi ? #407

Closed
4ree opened this issue May 10, 2021 · 4 comments
Closed

How to use feasRelax in Gurobi ? #407

4ree opened this issue May 10, 2021 · 4 comments

Comments

@4ree
Copy link

4ree commented May 10, 2021

I have some constraints that should be allowed to be violated for creating a feasibility relaxation. How can i use C API GRBModel::feasRelax() to do that?

@odow
Copy link
Member

odow commented May 10, 2021

Use the C API: https://www.gurobi.com/documentation/9.1/refman/c_feasrelax.html

using JuMP, Gurobi
jump_model = direct_model(Gurobi.Optimizer())
model = backend(jump_model)

Then pass model to GRBfeasrelax:

function GRBfeasrelax(model, relaxobjtype, minrelax, lbpen, ubpen, rhspen, feasobjP)
ccall((:GRBfeasrelax, libgurobi), Cint, (Ptr{GRBmodel}, Cint, Cint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}), model, relaxobjtype, minrelax, lbpen, ubpen, rhspen, feasobjP)
end

You should be aware that this operation is advanced, and that Gurobi.jl is not officially supported by Gurobi.

@4ree
Copy link
Author

4ree commented May 11, 2021

Thanks for your help. But in Gurobi documents, it have 2 signatures for this method, as i can see in the function above is the simpler one. Can i call out the more complex one to specify extractly which contraints should be violated?

@odow
Copy link
Member

odow commented May 11, 2021

There is only one signature in the Gurobi documentation, which is identical to this one.

using JuMP, Gurobi
jump_model = direct_model(Gurobi.Optimizer())
model = backend(jump_model)
penalties = Cdouble[] 
error = GRBfeasrelax(model, 0, 0, C_NULL, C_NULL, penalties, C_NULL)

@4ree
Copy link
Author

4ree commented May 11, 2021

Sorry, i read that method in C++API. Thank you so much for your help.

@4ree 4ree closed this as completed May 11, 2021
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