로드 중...
검색 중...
일치하는 항목 없음
transport1.cpp
이 파일의 문서로 이동하세요.
1
25#include "슬롯 머신h"
26#include <iostream>
27#include <fstream>
28
29네임스페이스 사용게임;
30네임스페이스 사용표준;
31
43int 메인(intargc,문자* argv[])
44{
45cout <<"---------- 수송 1 ------------"<< endl;
46
47 시도{
49 if(인수 > 1)
50wsInfo.setSystemDirectory(argv[1]);
52 // 슬롯 머신 모델 라이브러리에서 [trnsport] 모델을 검색합니다.
53ws.gamsLib("trnsport");
54
55 // 파일에서 GAMSJob을 생성하고 기본 설정으로 실행
56 GAMSJobt1 = ws.addJobFromFile("trnsport.gms");
57
58 // 기본 실행
59t1.실행();
60cout <<"기본값으로 실행:"<< endl;
61 for (GAMSVariableRecordrec : t1.outDB().get변수("x"))
62cout <<"x("<< Rec.key(0) <<","<< Rec.key(1) <<"):"<<" 레벨="<< Rec.level() <<" 한계="
63<< rec.marginal() << endl;
64
65 // 다른 솔버를 사용하여 작업을 다시 실행
67선택.setAllModelTypes("익스프레스");
68t1.실행(선택);
69cout <<"XPRESS로 실행:"<< endl;
70 for (GAMSVariableRecordrec : t1.outDB().get변수("x"))
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;
82 (GAMSVariableRecordrec : t1.outDB().get변수("x"))
83cout <<"x("<< Rec.key(0) <<","<< Rec.key(1) <<"):"<<" 레벨="<< Rec.level() <<" 한계="
84<< rec.marginal() << endl;
85
86}잡기 (슬롯 머신예외&ex)
87cout <<"슬롯 머신예외 발생: "<< ex.what() << endl;
88}잡기(예외 &ex)
89cout << ex.what() << endl;
90}
91
92 반환0;
93}
GAMSVariable getVariable(const std::string &name)
슬롯 머신데이터베이스 outDB()
void setAllModelTypes(const std::string &solver)
void setOptFile(const int value)
void setSystemDirectory(const std::string &systemDir)
std::string WorkingDirectory() const
void gamsLib(const std::string &model)
GAMSJob addJobFromFile(const std::string &fileName, const std::string &jobName="")
int main(int argc, char *argv[])