0
Java OPL 인터페이스가 새로 도입되었으며 CPLEX가 해결 한 후에 결정 변수의 값을 얻는 방법에 대한 문제가 발생했습니다. 특히, 내가 OPL 모델 파일을 통합이 코드와 데이터 파일이 있습니다Java에서 Ilog OPL 요소를 인터페이스하지 못했습니다.
이String inDataFile = "F:\\UPS\\OPL\\data_mod_6.dat";
String modfileloc = "F:\\UPS\\OPL\\model2.mod";
IloOplFactory.setDebugMode(false);
IloOplFactory oplF = new IloOplFactory();
IloOplErrorHandler errHandler = oplF.createOplErrorHandler(System.out);
IloOplModelSource modelSource = oplF.createOplModelSource(modfileloc);
IloCplex cplex = null;
try {
cplex = oplF.createCplex();
} catch (IloException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
IloOplSettings settings = oplF.createOplSettings(errHandler);
IloOplModelDefinition def=oplF.createOplModelDefinition(modelSource,settings);
IloOplModel opl=oplF.createOplModel(def,cplex);
//IloOplDataElements DataElements = opl.makeDataElements();
IloOplDataSource dataSource=oplF.createOplDataSource(inDataFile);
opl.addDataSource(dataSource);
opl.generate();
if (cplex.solve()){
IloNumMap sw1 = opl.getElement("sw").asNumMap();
double [] sw = null;
int sw_length = sw1.getSize();
for (int i=0; i< sw_length; i++)
{
sw[i] = sw1.get(i+1);
}
}
지금 여기 SW cplex.solve() 단계에서 얻어진 "더블"벡터 결정 변수입니다. 는 말을 나에게 오류를 제공하지만 : 나는 CPLEX 설치 키트에만 oplall.jar 파일이 (
Exception in thread "main" ilog.concert.IloException: Type dvar float+ expected for element "sw"
at ilog.opl.lang.wrapJNI.IloOplElement_cpp_asNumMap(Native Method)
은이 선언의 오류 여부에 나를 도와주세요 아니면 내가 OPL에 대한 라이브러리의 일부를 잃었)
감사합니다,
프라 빈