I noticed some people specify the solver as "cplex_direct" whereas others as "cplex" when passing the option to
SolverFactory in Pyomo. Is there any difference between the two options? If so, what it is the difference between the two?
Pyomo has a number of interfaces to the CPLEX solver:
cplexis a wrapper around a number of (primarily file-based) interfaces to the cplex solver executable. By default, that interface writes "LP" files, but can be configured to use MPS or NL files (through the
solver_ioargument to the
cplex_directis an interface that communicates the model to CPLEX through the CPLEX Python bindings. In theory this can be more efficient as it avoids writing/reading text files and spawning an external subprocess. This interface can also be obtained with
cplex_persistentis an extension of the
cplex_directinterface that supports a "persistent" interface to the CPLEX environment and supports more efficient "resolves" (i.e., solving a slightly modified model)
appsi_cplexis a complete rewrite of the direct/persistent interface to CPLEX as part of APPSI (the "auto-persistent Pyomo solver interface" project). This interface is significantly more performant, and can "automatically" detect the changed parts of the model with relatively low overhead. That said, APPSI is still very much "under development" (as of 2022), so interfaces and APIs are still subject to change.