Initializing help system before first use

XPRSgetnamelist

Purpose
Returns the names for the rows, columns, sets, piecewise linear constraints, general constraints or objectives in a given range. The names will be returned in a character buffer, with no trailing whitespace and with each name being separated by a NULL character.
Topic area
Synopsis
int XPRS_CC XPRSgetnamelist(XPRSprob prob, int type, char names[], int maxbytes, int * p_nbytes, int first, int last);
Arguments
prob 
The current problem.
type 
XPRS_NAMES_ROW 
(=1) if row names are required;
XPRS_NAMES_COLUMN 
(=2) if column names are required;
XPRS_NAMES_SET 
(=3) if set names are required;
XPRS_NAMES_PWLCONS 
(=4) if piecewise linear constraint names are required;
XPRS_NAMES_GENCONS 
(=5) if general constraint names are required;
XPRS_NAMES_OBJECTIVE 
(=6) if objective function names are required.
names 
A buffer into which the names will be returned as a sequence of null-terminated strings. The buffer should be of length maxbytes bytes. May be NULL if maxbytes is 0.
maxbytes 
The maximum number of bytes that may be written to the buffer names.
p_nbytes 
A pointer to a variable into which will be written the number of bytes required to contain the names in the specified range. May be NULL if not required.
first 
First row, column, set, piecewise linear or general constraint in the range.
last 
Last row, column, set, piecewise linear or general constraint in the range.
Example
The following example retrieves and outputs the row and column names for the current problem.
int i, o, cols, rows, cnames_len, rnames_len;
char *cnames, *rnames;
...
/* Get problem size */
XPRSgetintattrib(prob,XPRS_COLS,&cols);
XPRSgetintattrib(prob,XPRS_ROWS,&rows);
/* Request number of bytes required to retrieve the names */
XPRSgetnamelist(prob,XPRS_NAMES_ROW,NULL,0,&rnames_len,0,rows-1);
XPRSgetnamelist(prob,XPRS_NAMES_COLUMN,NULL,0,&cnames_len,0,cols-1);

/* Now allocate buffers big enough then fetch the names */
cnames = (char *) malloc(sizeof(char)*cnames_len);
rnames = (char *) malloc(sizeof(char)*rnames_len);
XPRSgetnamelist(prob,XPRS_NAMES_ROW,rnames,rnames_len,NULL,0,rows-1);
XPRSgetnamelist(prob,XPRS_NAMES_COLUMN,cnames,cnames_len,NULL,0,cols-1);

/* Output row names */
o=0;
for (i=0;i<rows;i++) {
  printf("Row #%d: %s\n", i, rnames+o);
  o += strlen(rnames+o)+1;
}
/* Output column names */
o=0;
for (i=0;i<cols;i++) {
  printf("Column #%d: %s\n", i, cnames+o);
  o += strlen(cnames+o)+1;
} 
See also examples repair.c, tableau.c.
Related topics

© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.