로드 중...
검색 중...
일치하는 항목 없음
transport7.cpp
이 파일의 문서로 이동하세요.
1
25#include "슬롯 사이트 추천h"
26#include <벡터>
27#include <iostream>
28
29네임스페이스 사용게임;
30네임스페이스 사용표준;
31
33문자열 getModelText()
34{
35 반환 " 세트 \n"
36 " 나는 식물 통조림 / 시애틀, 샌디에고 / \n"
37 " j 마켓 / 뉴욕, 시카고, 토피카 / ; \n"
38 " \n"
39 "매개변수 \n"
40 " a(i) 경우에 따라 공장 i의 용량 \n"
41 " / 시애틀 350 \n"
42 " 샌디에고 600 / \n"
43 " \n"
44 " b(j) 경우의 시장 j 수요 \n"
45 " / 뉴욕 325 \n"
46 " 시카고 300 \n"
47 " 토피카 275 / ; \n"
48 " \n"
49 "테이블 d(i,j) 거리(천 마일 단위) \n"
50 " 뉴욕 시카고 토피카 \n"
51 " 시애틀 2.5 1.7 1.8 \n"
52 " 샌디에고 2.5 1.8 1.4 ; \n"
53 " \n"
54 "천 마일당 케이스당 달러 단위의 스칼라 f 운임 /90/ ;\n"
55 "스칼라 bmult 수요 승수 /1/; \n"
56 " \n"
57 "매개변수 c(i,j) 운송 비용(케이스당 수천 달러); \n"
58 " \n"
59 " c(i,j) = f * d(i,j) / 1000 ; \n"
60 " \n"
61 "변수 \n"
62 " x(i,j) 배송 수량 \n"
63 " z 총 운송 비용(수천 달러) ; \n"
64 " \n"
65 "양수 변수 x ; \n"
66 " \n"
67 "방정식 \n"
68 " 비용 정의 목적 함수 \n"
69 " 공급(i) i 공장의 공급 제한 준수 \n"
70 " 수요(j)는 시장 j의 수요를 충족시킵니다. \n"
71 " \n"
72 "비용 .. z =e= sum((i,j), c(i,j)*x(i,j)) ; \n"
73 " \n"
74 "공급(i) .. 합계(j, x(i,j)) =l= a(i) ; \n"
75 " \n"
76 "수요(j) .. sum(i, x(i,j)) =g= bmult*b(j) ; \n"
77 " \n"
78 "모델 전송 /all/ ; \n";
79}
80
88int 메인(intargc,문자* argv[])
89{
90cout <<"---------- 수송 7 ------------"<< endl;
91
92 시도해 보세요{
94 if(인수 > 1)
95wsInfo.setSystemDirectory(argv[1]);
98
99 // GAMSJob을 실행하여 GAMSCheckpoint 초기화
101t7.실행(cp);
102
103 // GAMSModelInstance를 생성하고 다른 스칼라 bmult를 사용하여 여러 번 해결
105 슬롯 사이트 추천매개변수bmult = mi.syncDb().addParameter("bmult", 0,"수요 승수");
107선택.setAllModelTypes("복합체");
108
109 // GAMSModelInstance를 인스턴스화하고 모델 정의 및 GAMSModifier를 전달하여 bmult 변경 가능 선언
110mi.인스턴스화("운송은 lp min z를 사용합니다", 선택,GAMSModifier(bmult));
111
112b다중.추가기록().세트값(1.0);
113벡터<더블> bmultlist = 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3 ;
114
115 for (더블b : bmultilist)
117mi.해결();
118cout <<"시나리오 bmult="<< b <<":"<< endl;
119cout <<" 모델 상태: "<< 마일.modelStatusAsString() << endl;
120cout <<" 해결 상태: "<< 마일.solveStatusAsString() << endl;
121cout <<" 개체: "<< 마일.syncDb().get변수("z").findRecord().레벨() << endl;
122}
123
124 // GAMSModelInstance를 생성하고 차단된 네트워크의 단일 링크로 해결
125mi = cp.addModelInstance();
126
127 슬롯 사이트 추천변수x = 마일.syncDb().추가변수("x", 2, GAMSEnum::VarType::Positive,"");
128 슬롯 사이트 추천매개변수xup = mi.syncDb().addParameter("xup", 2,"x의 상한");
129
130 // GAMSModelInstance를 인스턴스화하고 모델 정의 및 GAMSModifier를 전달하여 X의 상한을 변경 가능으로 선언
131mi.인스턴스화("운송은 lp min z를 사용합니다", GAMSModifier(x, GAMSEnum::SymbolUpdateAction::Upper, xup));
132
133 for (GAMSSetRecordi : t7.outDB().getSet("나")) {
134 for (GAMSSetRecordj : t7.outDB().getSet("j")) {
135xup.지우기();
136xup.추가기록(i.key(0), j.key(0)).세트값(0);
137mi.해결();
138cout <<"시나리오 링크가 차단되었습니다="<< i.key(0) <<"-"<< j.key(0) << endl;
139cout <<" 모델 상태: "<< 마일.modelStatusAsString() << endl;
140cout <<" 해결 상태: "<< 마일.solveStatusAsString() << endl;
141cout <<" 개체: "<< 마일.syncDb().get변수("z").findRecord().레벨() << endl;
142}
143}
144
146cout <<"슬롯 사이트 추천예외 발생: "<< ex.what() << endl;
147}잡기(예외 &ex)
148cout << ex.what() << endl;
149}
150
151 반환0;
152}
GAMSModelInstance addModelInstance(const std::string &modelInstanceName="")
GAMSVariable addVariable(const std::string &name, const int 차원, const GAMSEnum::VarType varType, const std::string &explanatoryText="")
GAMSParameter addParameter(const std::string &name, const int 차원, const std::string &explanatoryText="")
GAMSSet getSet(const std::string &name)
GAMSVariable getVariable(const std::string &name)
슬롯 사이트 추천데이터베이스 outDB()
void 인스턴스화(const std::string &modelDefinition, const 슬롯 사이트 추천::GAMSOptions &options, const std::Vector< 슬롯 사이트 추천::GAMSModifier > &modifiers= )
voidsolv(GAMSEnum::SymbolUpdateType updateType, std::ostream &output, const GAMSModelInstanceOpt &miOpt)
슬롯 사이트 추천데이터베이스 syncDb()
void setAllModelTypes(const std::string &solver)
GAMSParameterRecord firstRecord(const std::벡터< std::string > &slice)
GAMSParameterRecord addRecord(const std::벡터< std::string > &keys)
GAMSVariableRecord findRecord(const std::벡터< std::string > &keys)
void setSystemDirectory(const std::string &systemDir)
GAMSJob addJobFromString(const std::string &gamsSource, const std::string &jobName="")
GAMSCheckpoint addCheckpoint(const std::string &checkpointName="")
int main(int argc, char *argv[])
string getModelText()
모델을 문자열로 가져옵니다.