如何连接 cplex 和 pyomo?

How to connect cplex and pyomo?

opt = SolverFactory('cplex', executable="/Applications/CPLEX_Studio_Community129/cplex/bin/x86-64_osx/cplex")

如果使用可执行选项(如上),它会起作用。如果不是,我们会收到以下错误:

ApplicationError: No executable found for solver 'cplex'

如果您不想使用executable选项指定路径,您需要将以下目录添加到您的PATH环境变量中:

/Applications/CPLEX_Studio_Community129/cplex/bin/x86-64_osx

例如,您可以从命令行执行此操作,如下所示:

export PATH=$PATH:/Applications/CPLEX_Studio_Community129/cplex/bin/x86-64_osx

如果可行,那么您可以使用 here

中描述的技术将其添加到您的 ~/.bash_profile 中,使其永久化

试试这个

SolverFactory('cplex_direct')