CPXENVptr env = NULL ;
CPXLPptr lp = NULL ;
...
/* Initialize the CPLEX environment */
env = CPXXopenCPLEX (&status);
lp = CPXXcreateprob(env, &status, "batch");
/* transform the original arrays that describe the problem to CPLEX 20.1 compatible ones */
CPXDIM xNCols = (CPXDIM) NCols ;
CPXDIM xNRows = (CPXDIM) NRows ;
CPXNNZ xNNZ = (CPXNNZ) NNZeros ;
CPXNNZ *xmatbeg = calloc(xNCols,sizeof(CPXNNZ *));
CPXDIM *xmatcnt = calloc(xNCols,sizeof(CPXDIM *));
CPXDIM *xmatind1 = calloc(xNNZ, sizeof(CPXDIM *));
double *xobjx = calloc(xNCols,sizeof(double *));
double *xrhsx = calloc(xNRows,sizeof(double *));
double *xmatval = calloc(xNNZ,sizeof(double *));
double *xbdl = calloc(xNCols,sizeof(double *));
double *xbdu = calloc(xNCols,sizeof(double *));
char *xsenx = calloc(xNRows,sizeof(char *)) ;
/* copy the data into the new defined arrays */
for (int i=0; i<xNCols;i++) xbdl[i] = (double const) bdl[i] ;
for (int i=0; i<xNCols;i++) xbdu[i] = (double const) bdu[i] ;
for (int i=0; i<xNCols;i++) xobjx[i] = (double const) objx[i] ;
for (int i=0; i<xNRows;i++) xrhsx[i] = (double const) rhsx[i] ;
for (int i=0; i<xNRows;i++) xsenx[i] = senx[i] ;
for (int i=0; i<xNCols;i++) xmatbeg[i] = (CPXNNZ const) matbeg[i] ;
for (int i=0; i<xNCols;i++) xmatcnt[i] = (CPXDIM const) matcnt[i] ;
for (int i=0; i<xNNZ;i++) xmatind1[i] = (CPXDIM const) matind1[i] ;
for (int i=0; i<xNNZ;i++) xmatval[i] = (double const) matval[i] ;
/*
for (i=0; i<NCols;i++) printf ("xobjx[%d] = %f objx[%d] = %f \n", i, xobjx[i], i, objx[i]) ;
for (i=0; i<NRows;i++) printf ("xrhsx[%d] = %f rhsx[%d] = %f \n", i, xrhsx[i], i, rhsx[i]) ;
for (int i=0; i<NRows;i++) printf ("xsenx[%d] = %c \n", i, xsenx[i]) ;
*/
/* populate cplex with the problem data as required by Cplex 20.1 */
status = CPXXcopylp (env, lp, xNCols, xNRows, MAXIMIZE, xobjx, xrhsx, xsenx, xmatbeg, xmatcnt, xmatind1, xmatval, xbdl,xbdu, NULL);
...
status = CPXXcloseCPLEX (&env);
I had a look in the 64bit examples provided by IBM and managed to get the application running. The code looks now as listed above.
CPXXcopylp() doesn't accept the "old" arrays. The application crashes in CPXXcopylp by the cause of segmentation fault.
------------------------------
K Braeu_
------------------------------
Original Message:
Sent: Wed April 07, 2021 06:02 AM
From: Vincent Beraudier
Subject: Cplex 20.1 crash
Why don't you directly declare the correct input structures? It should just work: when you move from CPX to CPXX, you move from 32 to 64 bits declarations, so get "the same structures but bigger": instead of int, you will get __int64, which will be able to store your previous running data that is 32 bits.
You cannot just cast your old declarations into the new expected ones: for example, CPXNNZ const* xmatbeg = (CPXNNZ const*) matbeg ; is wrong IMO.
CPXNNZ are __int64 or long long, depending on the platform, and your previous input one is an int.
------------------------------
Vincent Beraudier
------------------------------