안녕하세요,
전화로 문의드렸던 위주영입니다.
"This application has requested the Runtime to terminate it in an unusual way."
로 시작하는 에러 메시지가 떴습니다.
소스코드는 아래와 같습니다.
double solve(std::vector<Stop>& stopList, std::vector<Facility>& facilityList, Matrix<double>& od, Matrix<int>& indexMatrix, vector<Point<int>>& indexList, char* filename){
IloEnv env;
IloModel model(env);
IloExpr tmp(env);
int row = od.row();
int col = od.col();
int i,j;
// 상수
IloArray<IloFloatArray> c(env, row);
for(i = 0; i < row; i++){
c[i] = IloFloatArray(env, col);
for(int j = 0; j < col; j++){
c[i][j] = od[i][j];
}
}
IloFloatArray d(env, row);
for(i = 0; i < row; i++) d[i] = stopList[i].demand;
IloFloatArray F(env, col);
for(j = 0; j < col; j++) F[j] = facilityList[j].capacity;
// 변수
IloBoolVarArray x(env, (int)indexList.size());
for(i = 0; i < (int)indexList.size(); i++){
stringstream name;
name << "x[" << indexList[i].x << "][" << indexList[i].y << "]";
x[i].setName(name.str().c_str());
}
// 목적식
for(i = 0; i < row; i++){
for(j = 0; j < col; j++){
if (indexMatrix[i][j] != -1) tmp += x[indexMatrix[i][j]] * c[i][j];
}
}
model.add(IloMinimize(env,tmp));
// 조건식
for(i = 0; i < row; i++){
tmp.clear();
for(j = 0; j < col; j++){
if (indexMatrix[i][j] != -1) tmp += x[indexMatrix[i][j]];
}
model.add(tmp == 1);
}
for(j = 0; j < col; j++){
tmp.clear();
for(i = 0; i < row; i++){
if (indexMatrix[i][j] != -1) tmp += x[indexMatrix[i][j]] * d[i];
}
model.add(tmp <= F[j]);
}
IloCplex cplex(model);
cplex.exportModel(filename);
cplex.setParam(IloCplex::WorkMem, 16384);
double startTime = env.getTime();
cplex.solve();
double endTime = env.getTime();
if (cplex.getStatus() != IloAlgorithm::Optimal) return startTime - endTime;
cout << "Solution status : " << cplex.getStatus() << endl;
cout << "Solution Value : " << cplex.getObjValue() << endl;
return endTime - startTime;
}