solution file and rew as input
AnsweredI want to share my solution file (warm-start) and MPS file with support. However, I want to remove col/row names. I have a .sol and .mps file that work together fine, but when I try to input .sol and .rew, it obviously can't match up the input solution.
To generate the files I used:
grbModel.write("test.rew");
grbModel.write("test.mps");
grbModel.set(GRB.StringParam.SolFiles, "test");
What is the best way to share with support an MPS file (obfuscated) and a starting solution (since by default, the solver struggles to find a first solution)?
-
To share an obfuscated MPS file and a compatible warm-start solution file with Gurobi support:
-
Obfuscate MPS File: Replace column and row names in the MPS file with generic identifiers (e.g.,
COL001
,ROW001
). -
Update Solution File: Modify the .sol file to match the new names in the obfuscated MPS file.
-
Check Consistency: Ensure the obfuscated MPS and updated solution file are consistent by loading them in Gurobi.
-
Share with Support: Send the consistent obfuscated MPS and solution files to Gurobi support, explaining the obfuscation for context.
0 -
-
Hi Matthew,
The following Python code can also do what you are looking for.
import gurobipy as gp
m1 = gp.read("test.mps")
m1.read("test.sol")
m1.params.SolutionLimit=1
m1.optimize()
m1.write("test.rew")
m2= gp.read("test.rew")
A = m2.getAttr("VarName", m2.getVars()) #Get variables names from rew file
m1.setAttr("VarName", m1.getVars(), A) #Replace variable names in m1 with names from rew
m1.write("test1.sol")The variables names in test1.sol should match the names in the rew file
I hope this can help
Thanks
- Ahmed
0
Please sign in to leave a comment.
Comments
2 comments