QSprob QSload_prob (const char *probname, int ncols, int nrows, int *cmatcnt, int *cmatbeg, int *cmatind, double *cmatval, int objsense, double *obj, double *rhs, char *sense, double *lower, double *upper, const char **colnames, const char **rownames)
/* */ /* Using QSload_prob to load the following LP problem */ /* Maximize 3.0x + 2.0y + 4.0z */ /* Subject to */ /* 3.1x + 2.3y + 1.4z <= 12.2 */ /* 5.0x + 1.1y = 10.0 */ /* x >= 2.0 */ /* y free */ /* 1.0 <= z <= 10.0 */ /* */ int rval; QSprob p; int cmatcnt[3] = { 2, 2, 1 }; int cmatbeg[3] = { 0, 2, 4 }; int cmatind[5] = { 0, 1, 0, 1, 0 }; double cmatval[5] = { 3.1, 5.0, 2.3, 1.1, 1.4 }; double obj[3] = { 3.0, 2.0, 4.0 }; double rhs[2] = { 12.2, 10.0 }; char sense[2] = { 'L', 'E' }; double lower[3] = { 2.0, -QS_MAXDOUBLE, 1.0 }; double upper[3] = { QS_MAXDOUBLE, QS_MAXDOUBLE, 10.0 }; const char *colnames[3] = { "x", "y", "z" }; p = QSload_prob ("small", 3, 2, cmatcnt, cmatbeg, cmatind, cmatval, QS_MAX, obj, rhs, sense, lower, upper, colnames, (char **) NULL); if (p == (QSprob) NULL) { fprintf (stderr, "Unable to load the LP problem\n"); } else { /* As a check, write the LP to a file */ rval = QSwrite_prob (p, "small.lp", "LP"); if (rval) { fprintf (stderr, "Could not write LP, error code %d\n", rval); } }