I am using OPL/Cplex libraries in my c++ code,
In my file.mod I decalred this decision variable: dvar int+ x[nodes][nodes][1..nb_max][lambdas];
Now I that Cplex solved the model I successfully recuperate the objective value as follows:
try {
IloCplex cplex(env);
cplex.setOut(env.getNullStream());
IloOplErrorHandler handler(env,cout);
IloOplModelSource modelSource(env, "file.mod");
IloOplSettings settings(env,handler);
IloOplModelDefinition def(modelSource,settings);
IloOplModel opl(def,cplex);
IloOplDataSource dataSource(env, "file2.dat");
opl.addDataSource(dataSource);
opl.generate();
if ( cplex.solve() ) {
cout<< opl.getCplex().getObjValue()<< endl;
}
}
My question is how can I recuperate the multidimentional array "x"? I tried with
IloIntVar x = opl.getElement("x").asIntVar; IloIntVar xvar =x.get(0);//first item
but the following errors occur!
error: conversion from '' to non-scalar type 'IloIntVar' requested error: 'class IloIntVar' has no member named 'get'
I am really a beginner in OPL, Thanks in advance!