python调用cplex求解_CPLEX的Python中Bender的分解示例
0 | 1參數(shù)是必需的。例如,需要按如下方式運(yùn)行腳本:python bendersatsp.py 0 "C:\Program Files (x86)\IBM\ILOG\CPLEX_Studio1261\cplex\examples/data/atsp.dat"
或者,假設(shè)您已經(jīng)更改了默認(rèn)的filename路徑:
^{pr2}$
我在解析以下命令行參數(shù)的代碼中添加了一些注釋,試圖使這一點(diǎn)更清楚:if __name__ == "__main__":
# If there are not 1 or 2 arguments then exit (recall that
# sys.argv[0] is the program name itself (i.e., "bendersatsp.py")
if len(sys.argv) != 2 and len(sys.argv) != 3:
usage()
sys.exit(-1)
# If the first argument is not "0" or "1" then exit.
if sys.argv[1] not in ["0", "1"]:
usage()
sys.exit(-1)
# Store the second argument in filename if there is one.
if len(sys.argv) == 3:
filename = sys.argv[2]
else:
# Otherwise, use the following default.
filename = "../../../examples/data/atsp.dat"
# Pass the arguments into the bendersATSP function.
bendersATSP(sys.argv[1][0], filename)
總結(jié)
以上是生活随笔為你收集整理的python调用cplex求解_CPLEX的Python中Bender的分解示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ad 卡尔曼_对Kalman(卡尔曼)滤
- 下一篇: shell 补齐路径_bash shel