Originally posted by: SystemAdmin
I think this is what is happening, too. I think I just link what foo() actually is because the code is not long.
IloExpr twelveLHS(IloEnv & env, Sparse_Matrix<IloInt>& vox, vector<unsigned int> & A,
IloNum Tx, vector<unsigned int> & X, IloNumVarArray& w)
{
IloExpr expr(env);
for(unsigned int i=0;i<A.size();++i)
{
expr += D(A[i], vox, w, env) - Tx;
}
return expr;
}
And D(...) is the following function.
IloExpr D(unsigned int i, Sparse_Matrix<IloInt>& vox, IloNumVarArray& w, IloEnv & env)
{
IloExpr exp(env);
for(unsigned int j=vox.ia[i];j<vox.ia
i+1;++j)
{
exp += vox.a[j]*w[vox.ja
j];
}
return exp;
}
The only problem I could see with this is that you cannot return a IloExpr like this because it doesn't deallocate somehow. If the C++ bindings for cplex were programming to not allow this method of programming I think it would be rather foolish. If this is not acceptable then I could just pass in the IloExpr as an argument by reference. Do I always have to call the end of an IloExtractable? Shouldn't the destructor deallocate the memory when the scope of the variable is left?
#DecisionOptimization#MathematicalProgramming-General