2017-11-17 20 views
0

[! [여기에 이미지 설명을 입력하십시오.] [1]] [1] CPLEX에서 eclips를 통해 제안한 예제에서 "bendersatsp.py"를 실행하고 있습니다. "filename ="이 정의 된 main 절에 atsp.dat의 경로 만 추가했습니다. 그것을 실행 한 후 len (sys.argv) = 1에 대해서만 실행되는 것으로 보이며 다음 결과를 제공합니다. 문제가 무엇이고 왜 완전하게 실행되지 않는지 아십니까?CPLEX의 Python에서 Bender의 분해 예제

Usage:  bendersatsp.py {0|1} [filename] 
    0:  Benders' cuts only used as lazy constraints, 
      to separate integer infeasible solutions. 
    1:  Benders' cuts also used as user cuts, 
      to separate fractional infeasible solutions. 
    filename: ATSP instance file name. 
     File C:\Program Files (x86)\IBM\ILOG\CPLEX_Studio1261\cplex\examples/data/atsp.dat used if no name is provided. 
+0

bendersatsp.py에 대한 수정 사항을 표시하십시오. – rkersh

+0

@rkersh, 방금 파일 이름의 경로를 추가했습니다. 기본 데이터는 mycom의 C : ₩ Program Files (x86) ₩ IBM ₩ ILOG ₩ CPLEX_Studio1261 ₩ cplex ₩ examples/data/atsp.dat에 정의되어 있으므로 원래 bendersatsp.py에 파일 이름으로 저장합니다. 아직 bendersatsp.py를 변경하지 않았습니다. – rezzz

답변

1

0 인수가 필요합니다.

python bendersatsp.py 0 

내가 구문 분석하는 코드에 대한 몇 가지 의견을 추가했습니다 : 기본 filename 경로를 변경 한 가정

python bendersatsp.py 0 "C:\Program Files (x86)\IBM\ILOG\CPLEX_Studio1261\cplex\examples/data/atsp.dat" 

또는 예를 들어, 다음과 같이 스크립트를 실행해야합니다 아래의 커맨드 라인 인자를 사용해보십시오.

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) 
+0

답장을 보내 주셔서 감사합니다! 커맨드 라인에서도 여전히 프로그램을 실행할 수 없습니다. 내가 추가 한 그림을 보아라. – rezzz

+0

스크린 샷에서 올바른 명령을 사용하고 있지 않습니다. 예를 들어, bendersatsp.py가 존재하는 디렉토리로'cd' 할 필요가 있습니다. 그런 다음'c : \ Python34 \ python.exe bendersatsp.py 0'을 실행하십시오. 이 명령을 실행하기 전에 대화 형 Python을 시작하지 마십시오. – rkersh

+0

@ rkersh 감사합니다, 당신 말이 맞아요! 이클립스는? 어떻게 할 수 있습니까? – rezzz