scipopt / SCIP.jl

Julia interface to SCIP solver
MIT License
95 stars 24 forks source link

Can I develop models in Julia and solve them in Python? #224

Closed rezabayani closed 2 years ago

rezabayani commented 2 years ago

I want to export my julia optimization models as files supported by scip solver so I can use them in other frameworks such as pyscipopt in python. Is this possible?

rschwarz commented 2 years ago

I guess you could export them in standard file formats such as lp, mps or cip (which is specific to SCIP). These can be loaded by solvers, including via PySCIPOpt. Note that you'll have to identify variables by name.

matbesancon commented 2 years ago

By Julia optimization model, I'll assume this is a JuMP model, you may want to look into the following function: https://jump.dev/JuMP.jl/stable/reference/models/#JuMP.write_to_file

rezabayani commented 2 years ago

@rschwarz @matbesancon Thank you, it works! and yes I am using JuMP, and saving with *.mps format. However, the pyscipopt objective value was the exact negative of what was in my original model! Could it be because mps format treats all models as minimization problems? (my original problem was Max and it is fixed with Min) I also wonder if I could do the same with nonlinear models because I was not able to use JuMP.write_to_file for a model with non-linear constraints?

matbesancon commented 2 years ago

thanks @rezabayani that's unexpected. Can you re-read the MPS in JuMP to see if the MPS itself was transformed or if pyscipopt is inverting it upon reading? From the JuMP MPS writer, it seems writing out both min and max are supported

rezabayani commented 2 years ago

@matbesancon I found an issue where if the mps file contains the objective sense, pyscipop returns error. It was fixed when I manually deleted that line from the mps file.

rezabayani commented 2 years ago

@rschwarz @matbesancon I am still facing an issue where pyscipopt can not load 'mps' files unless I manually delete the ObjSesne line in the saved file. Do you think there is a remedy to this besides manually editing these files?