Please try to format your code in a more readable/compact way next time.
You are using the wrong constructor to create your arrays. As you can see in the reference documentation (note that IloFloatVarArray is just another name for IloNumVarArray):
public
IloNumVarArray(const
IloEnv env,
IloInt n=
0)
This constructor creates an extensible array of
n numeric variables in
env. Initially, the
n elements are empty handles.
Since you are using that constructor you only create arrays with empty handles. They arrays are not populated with variable objects. Thus you get an invalid memory access as soon as you attempt to use any of those empty handles. You should instead use a constructor that actually creates variable objects in the array, for example this one:
public
IloNumVarArray(const
IloEnv env, const
IloNumArray lb, const
IloNumArray ub,
IloNumVar::Type type=
ILOFLOAT)
This constructor creates an extensible array of numeric variables in
env with lower and upper bounds and type as specified. The instances of
IloNumVar to fill this array are constructed at the same time. The length of the array
lb must be the same as the length of the array
ub. In other words,
lb.getSize == ub.getSize. This constructor will construct an array with the number of elements in the array
ub.
#CPLEXOptimizers#DecisionOptimization