Skip to main content

Nonlinear global optimization in pyomo (calling gurobi)




  • Riley Clement
    Gurobi Staff Gurobi Staff

    Hi Yingkai,

    It sounds like Pyomo wants to write the model to file, then invoke Gurobi via the command line.  It seems to be running into an error when writing the file.  If this is occurring with the latest version of Pyomo I would open up an issue at

    As a workaround, can you try and use the "persistent" interface, which builds the model in Gurobi directly:

    solver = pyo.SolverFactory('gurobi_persistent')

    Of course you could also use gurobipy to solve the issue.  I'm sure ChatGPT could do a quick conversion between your Pyomo code to gurobipy code.

    - Riley

  • Yingkai Song
    First Comment
    First Question

    Hi Riley,


    Thanks for your reply! 

    Even though I could not find the source again, several days ago, I found a post from Gurobi saying that to use nonlinear term such as sin in Gurobi, I have to use Model.addGenContrSin() in gurobipy. This function of Gurobi is just incompatible with Pyomo's modeling language. 




Please sign in to leave a comment.