Originally posted by: zhixin
I tried a general 100*1000 linear program, and still have a similar problem. The code and output is as follows:
 void example()
 {
 CPXENVptr env = NULL;
 CPXLPptr lp = NULL;
 int status = 0;
 int numcols=100;//number of variables
 int numrows=100;//number of constraints
 int objsen = CPX_MIN; /* The problem is minimization */
 double* obj = new double
numcols;//coefficients of the objective function
 double* rhs = new double
numrows;//right handside values
 char* sense = new char
numrows;// sign for constraints
 int* matbeg=new int
numcols;//The nonzero elements of every column must be stored in sequential locations with matbeg[j] containing the index of the beginning of column j starting from 0
 int* matcnt=new int
numcols;//matcnt[j] containing the number of entries in column j
 int* matind;//For each k, matind[k] specifies the row number of the corresponding coefficient, matval[k]
 double* matval;//coefficient
 double* lb=new double
numcols;//lower bound
 double* ub=new double
numcols;//upper bound
 long i,j;
 //the linear objecitive coefficient
 for(i=0;i<numcols;i++)
 obj[i]=(double)rand()/(RAND_MAX);
 //right hand side values of the constraints
 for(i=0;i<numrows;i++)
 rhs[i]=(double)rand()/(RAND_MAX);
 //the sign of constraints
 for(i=0;i<numrows;i++)
 sense[i]='G';//all >=
 //lower and upper bounds, and type of variables
 for(i=0;i<numcols;i++)
 lb[i]=0;
 for(i=0;i<numcols;i++)
 ub[i]=RAND_MAX;
 int NUMNZ=numcols*numrows;//number of nonzero entries in the constraint matrix
 //beg and cnt
 for(i=0;i<numcols;i++)
 {
 matbeg[i]=i*numrows;
 matcnt[i]=numrows;
 }
 //the index of nonzero constraint coefficients
 matind=new int
NUMNZ;
 for(i=0;i<NUMNZ;i++)
 matind[i]=i%numrows;
 //constraint coefficients
 matval=new double
NUMNZ;
 for(i=0;i<NUMNZ;i++)
 matval[i]=(double)rand()/(RAND_MAX);
 /* Initialize the CPLEX environment */
 env = CPXopenCPLEX (&status);
 /* Create the problem. */
 lp = CPXcreateprob (env, &status, "linear");
 /* Now copy the problem data into the lp */
 status = CPXcopylp (env, lp, numcols, numrows, objsen, obj, rhs,sense, matbeg, matcnt, matind, matval,lb, ub, NULL);
 /* Optimize the problem and obtain solution. */
 long tt=clock();
 for(long ii=0;ii<10000000;ii++)
 {
 CPXlpopt (env, lp);
 if(ii%100==99)
 {
 printf("%f\n",((double)clock()-tt) / CLOCKS_PER_SEC);
 tt=clock();
 }
 }
 status = CPXlpopt (env, lp);
 /* Free up the problem as allocated by CPXcreateprob, if necessary */
 status = CPXfreeprob (env, &lp);
 /* Free up the CPLEX environment, if necessary */
 status = CPXcloseCPLEX (&env);
 delete []obj;
 delete []rhs;
 delete []sense;
 delete []matbeg;
 delete []matcnt;
 delete []matind;
 delete []matval;
 delete []lb;
 delete []ub;
 }
 partial output:
 0.136000
 0.136000
 0.172000
 0.152000
 0.192000
 0.174000
 0.196000
 0.219000
 0.236000
 0.218000
 0.221000
 0.225000
 0.270000
 0.284000
 0.253000
 0.269000
 0.273000
 0.302000
 0.308000
 0.326000
 0.338000
 0.372000
 0.349000
 0.372000
 0.403000
 0.386000
 0.400000
 0.432000
 0.429000
 0.469000
 .
 .
 .
 I appreciate your help.
#CPLEXOptimizers#DecisionOptimization