transport13.cpp 파일 참조
이것은 일련의 튜토리얼 예제 중 13번째 모델입니다.더 보기...
#include "크레이지 슬롯h"#include "수송.h"#include <iostream>#include <지도>#include <문자열>#include <튜플>#include <벡터>기능 | |
| int | 메인(int argc, char *argv[]) |
상세 설명
이것은 일련의 튜토리얼 예제 중 13번째 모델입니다.
여기서 보여드리겠습니다:
- 특정 크레이지 슬롯 모델을 패키징하기 위해 래퍼 클래스를 사용하여 GAMSJob을 실행하는 방법
파일의 정의transport13.cpp.
함수 문서
◆ 메인()
| int 메인 | ( | int | argc, |
| 문자 * | argv[] ) |
라인 정의42파일transport13.cpp.
43{
44cout <<"---------- 수송 13 ------------"<< endl;
45
46 시도{
47벡터<string> 식물"시애틀", "샌디에고"};
48벡터<string> 시장"뉴욕", "시카고", "토피카"};
49map<string, double> 용량
50{"시애틀", 350.0 }, { "샌디에이고", 600.0 }
51};
52map<string, double> 수요
53{"뉴욕", 325.0 }, { "시카고", 300.0 }, { "토피카", 275.0 }
54};
55맵<튜플<문자열, 문자열>,더블> 거리
56make_tuple("시애틀", "뉴욕"), 2.5 },
57make_tuple("시애틀", "시카고"), 1.7 },
58make_tuple("시애틀", "토피카"), 1.8 },
59make_tuple("샌디에고", "뉴욕"), 2.5 },
60make_tuple("샌디에고", "시카고"), 1.8 },
61make_tuple("샌디에고", "토피카"), 1.4 }
62};
63
64 GAMSWorkspaceInfowsInfo;
65 if(인수 > 1)
66wsInfo.setSystemDirectory(argv[1]);
67 크레이지 슬롯작업공간ws(wsInfo);
68
69 운송t(ws);
70
71 for (문자열p : 식물)
72t.i().addRecord(p);
73
74 for (문자열m : 시장)
75t.j().addRecord(m);
76
77 for (문자열p : 식물)
78t.a().addRecord(p).setValue(용량[p]);
79
80 for (문자열m : 시장)
81t.b().addRecord(m).setValue(수요[m]);
82
83 for (자동dis : 거리)
84t.d().addRecord(get<0>(dis.first), get<1>(dis.first)).setValue(distance[dis.first]);
85
86t.f().addRecord().setValue(90);
87
88t.opt().setAllModelTypes("복합체");
89
90t.run(크레이지 슬롯체크포인트(), cout);
91
92cout <<"목표: "<< t.z().firstRecord().level() << endl;
94cout <<"x("<< Rec.key(0) <<","<< Rec.key(1) <<"): 레벨="<< Rec.level() <<
95 " 한계="<< rec.marginal() << endl;
96
98cout <<"크레이지 슬롯예외 발생: "<< ex.what() << endl;
99}잡기(예외 &ex)
100cout << ex.what() << endl;
101}
102
103 반환0;
104}
void setSystemDirectory(const std::string &systemDir)