주메뉴 바로가기 본문 바로가기 하단 바로가기

고객지원

기술문의

Error

  • 위주영
  • 2011.12.06
  • 조회수 2,113
안녕하세요,
전화로 문의드렸던 위주영입니다.
"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;
}

댓글 2

  • 이성균2011-12-07
    안녕하세요.
    KSTEC의 이성균입니다.

    함수만 주셔서 전체 소스 구성과 데이터 형태를 파악하기 힘듭니다만, 한가지 오류가 날 만한 부분이 있어서 여쭈어 볼께요.
    소스상에서 보시면
    c[i][j] == od[i][j];
    Matrix형태로 들어온 od의 값을 IloArray형태의 c에 대입하는 부분이 좀 이상한데요.

    혹시 Matrix를 IloArray< IloNumArray >형태로 define 하셨다면,
    IloArray형태로 c를 선언하면 compile 에러가 나지 않나요?

    보통 2차원 상수배열을 사용하시려면
    IloArray< IloNumArray > c(env,row);
    형태로 구현하거든요.

    현재 버전에서는 IloArray는 templete이라 뒤에 IloArray< typename > 형식으로만 쓰여야 합니다.

    그런데 문의 주셨던 소스는 IloArray만 쓰여있어서 현재 버전으로 컴파일이 되지 않습니다.

    혹시 컴파일이 되신다면 Cplex 버전이 예전것일 수 있으니 버젼정보를 알려주시면 감사하겠습니다.
    아이콘삭제
  • 위주영2011-12-07
    소스코드 올려드립니다.
    아이콘삭제

댓글 입력