Note that we also support the direct Python interfaces to Gurobi and Cplex, which can be significantly faster than the file based interfaces (LP and NL). This is especially true in cases where you construct the model once, and then perform many solves on incrementally changed versions of the model. However, if it is in fact the solve time that is dominating (and not the process of creating the solver input file from a Pyomo model), then this won’t help much.
If you’re interested in using the Python interfaces, just install the Gurobi/Cplex python bindings into the same Python installation as Pyomo (you should be able to “import gurobipy” / “import cplex”). The “--solver-io=python” pyomo command-line option will activate the appropriate interface (if available) based on the solver name. If you are scripting, then the keyword "solver_io=‘python’” should be passed into SolverFactory. E.g.,
# Python interface
solver = SolverFactory(“gurobi”, solver_io=‘python’)
# LP-file interface (default)
solver = SolverFactory(“gurobi”) #, solver_io=‘lp’)
# NL-file interface (executable name)
solver = SolverFactory(“gurobi_ampl”) #, solver_io=‘nl’)
Regards,
Gabe