Skip to main content

<ipython-input-2-56eb22f5bc96>

Answered

Comments

3 comments

  • Sonja Mars
    Gurobi Staff Gurobi Staff

    Hi,

    The easiest way to read a file is to give the complete path of this file. We provide a copy of afiro.mps in your Gurobi installation directory in examples/data. If you don't want to provide the complete path you should copy the file to your current working directory.

    Best regards,

      Sonja

    0
  • Golnar Karimifar
    Gurobi-versary
    First Comment

    Hi, I get this error, what should I do?

    Unable to open file 'C:\gurobi902\win64\examples\datafiro.mps' for input
    
     
    ---------------------------------------------------------------------------
    GurobiError                               Traceback (most recent call last)
    <ipython-input-8-61beb9e089e5> in <module>
    ----> 1 model = read("C:\gurobi902\win64\examples\data\afiro.mps")
    
    gurobi.pxi in gurobipy.read()
    
    gurobi.pxi in gurobipy.gurobi.read()
    
    GurobiError: Unable to read model
    
    0
  • Eli Towle
    Gurobi Staff Gurobi Staff

    You are trying to read a model with

    model = read("C:\gurobi902\win64\examples\data\afiro.mps")

    In Python, \( \texttt{\a} \) is an escape sequence for a special ASCII character. To ensure your path is parsed correctly, try escaping the backslashes in the string with two backslashes:

    model = read("C:\\gurobi902\\win64\\examples\\data\\afiro.mps")

    You could alternatively use \( \texttt{os.path.join()} \) to avoid issues like this.

    0

Please sign in to leave a comment.