Writing LP to an specific location
AnsweredHello,
I am trying to save a .lp file of the model I am working on. However, I would like to save it in a different directory. My plan is to have a folder where the scripts are and another folder where the lp files can be found. I tried something similar to this.
model.write('C:/Users/me/documents/model/LP files/mymodel.lp')
And of course, it didn't work. Any suggestions?
Thanks in advance
-
Hi Jose!
Gurobi staff will be better positioned to answer whether the target path can be changed inside of
model.write()
method, but - as a workaround - you can use Python's standard shutil package.
For a tutorial on how to copy a file to a different location using shutil, go here.
Best regards,
Jonasz0 -
Hello Jonasz,
Thanks for the tutorial, it is definitely a workaround I could work with.
Hopefully, Gurobi staff can provide insight as I am quite sure I am not the only one who would like to save the files in a different folder.
Best wishes
Jose
0 -
Hi Jose,
The write method writes the file to the specified folder (or current location on default). Do you have writing permissions in your folder? Did you execute your script as an administrator?
Best regards,
Jaromił0 -
Hello Jaromil,
No, I did not execute my script as administrator I ran it normally from the command terminal (windows). I will try to run it as an administrator. So, one can include a path in the method, similar to what I wrote in my first comment.
0
Please sign in to leave a comment.
Comments
4 comments