使用pyomo为2stage SLP执行模型文件时出现问题

2024-09-30 18:29:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在阅读pyomo手册,学习如何使用Python和cplex/gurobi这样的解算器来解两阶段随机线性规划。但是我很难执行这个github(https://github.com/Pyomo/pyomo/tree/master/examples/pysp/farmer)中提供的具体模型

对于农民的问题,使用命令行:runph --model-directory=models --instance-directory=nodedata --default-rho=1pyomo solve --solver=cplex ReferenceModel.py AverageScenario.dat。我的Python版本是3.5,我在Annaconda中安装的cplex版本是3.5。你知道吗

错误消息是

ERROR: Unexpected exception while running model:
        No executable found for solver 'cplex'

我的问题:如何通过命令行更改目录路径,以便它可以查找cplex解算器?我正在使用Annaconda运行命令行!pyomo solve --solver=cplex ReferenceModel.py AverageScenario.dat。包含我的ReferenceModel.pynodedata的路径是:Users/[myname]/pyomo-master/models/ReferenceModel.py。我已经把所有的数据文件放在了ReferenceModel.py的同一个文件夹中,但是没有任何效果。你知道吗


Tags: 命令行pygithubmastermodelmodelsdirectorypyomo
1条回答
网友
1楼 · 发布于 2024-09-30 18:29:04

从错误消息来看,pyomo似乎无法找到cplex.exe可执行文件。根据pyomo documentation

the directory containing the cplex executable must be in the list of paths defined by the PATH environment variable

例如,要在控制台窗口中执行此操作(临时),您可以执行以下操作:

set PATH=%PATH%;"C:\Program Files\IBM\ILOG\CPLEX_Studio128\cplex\bin\x64_win64"

要永久设置路径环境变量,请参见here。你知道吗

相关问题 更多 >