transport1.cpp 파일 참조
이것은 일련의 튜토리얼 예제 중 첫 번째 모델입니다.더 보기...
#include "메가 슬롯h"#include <iostream>#include <fstream>기능 | |
| int | 메인(int argc, char *argv[]) |
상세 설명
이것은 일련의 튜토리얼 예제 중 첫 번째 모델입니다.
이것은 일련의 튜토리얼 예제 중 첫 번째 모델입니다.
여기서 보여드리겠습니다:
- 파일에서 GAMSJob을 실행하는 방법
- 솔버 지정 방법
- 솔버 옵션 파일을 사용하여 작업을 실행하는 방법
이 예는 메가 슬롯 모델 라이브러리에서 [trnsport] 모델을 실행합니다.
파일의 정의transport1.cpp.
함수 문서
◆ 메인()
| int 메인 | ( | int | argc, |
| 문자 * | argv[] ) |
라인 정의43파일transport1.cpp.
44{
45cout <<"------------ 운송 1 ------------"<< endl;
46
47 시도해 보세요{
48 GAMSWorkspaceInfowsInfo;
49 if(인수 > 1)
50wsInfo.setSystemDirectory(argv[1]);
51 메가 슬롯작업공간ws(wsInfo);
52 // 메가 슬롯 모델 라이브러리에서 [trnsport] 모델을 검색합니다.
53ws.gamsLib("trnsport");
54
55 // 파일에서 GAMSJob을 생성하고 기본 설정으로 실행
57
58 // 기본 실행
59t1.실행();
60cout <<"기본값으로 실행:"<< endl;
62cout <<"x("<< Rec.key(0) <<","<< Rec.key(1) <<"):"<<" 레벨="<< Rec.level() <<" 한계="
63<< rec.marginal() << endl;
64
65 // 다른 솔버를 사용하여 작업을 다시 실행
66 메가 슬롯옵션opt = ws.addOptions();
68t1.실행(선택);
69cout <<"XPRESS로 실행:"<< endl;
71cout <<"x("<< Rec.key(0) <<","<< Rec.key(1) <<"):"<<" 레벨="<< Rec.level() <<" 한계="
72<< rec.marginal() << endl;
73
74 // 솔버 옵션 파일을 사용하여 작업 실행
75ofstream xpressopt(ws.workingDirectory() + cPathSep +"xpress.opt");
76xpressopt <<"알고리즘=장벽"<< endl;
77xpressopt.close();
78
79선택.setOptFile(1);
80t1.실행(선택);
81cout <<"기본값이 아닌 옵션으로 XPRESS를 실행했습니다:"<< endl;
83cout <<"x("<< Rec.key(0) <<","<< Rec.key(1) <<"):"<<" 레벨="<< Rec.level() <<" 한계="
84<< rec.marginal() << endl;
85
87cout <<"메가 슬롯예외 발생: "<< ex.what() << endl;
88}잡기(예외 &ex)
89cout << ex.what() << endl;
90}
91
92 반환0;
93}
GAMSVariable getVariable(const std::string &name)
메가 슬롯데이터베이스 outDB()
void run()
void setAllModelTypes(const std::string &solver)
void setOptFile(const int value)
void setSystemDirectory(const std::string &systemDir)