39#include "non_dominated_sort.h"
45# include <sys/types.h>
58 SET_NON_DOMINATE_SORT,
63char *option[N_OPTIONS] = {
76 "Usage: sddssort [<SDDSinput>] [<SDDSoutput>] [options]\n\n"
78 " -pipe=[input][,output]\n"
79 " Enable piping for input and/or output.\n\n"
80 " -column=<name>[,{increasing|decreasing}|{minimize|maximize}][,absolute]...\n"
81 " Specify one or more columns to sort by.\n"
82 " - 'increasing' or 'decreasing' sets the sorting direction for regular sorting.\n"
83 " - 'minimize' or 'maximize' sets the sorting direction for non-dominated sorting.\n"
84 " - 'absolute' sorts based on absolute values.\n\n"
86 " Eliminate duplicate rows based on sort columns.\n"
87 " If 'count' is specified, an 'IdenticalCount' column is added to indicate the number of identical rows.\n\n"
89 " Suppress warning messages.\n\n"
90 " -parameter=<name>[,{increasing|decreasing}]...\n"
91 " Specify parameters to sort by.\n\n"
93 " Prioritize numeric characters over other characters in string comparisons.\n"
94 " Also ranks numeric character sets with fewer characters below those with more characters.\n\n"
96 " Perform non-dominated sorting when multiple sort columns are provided.\n"
97 " Note: Non-dominated sorting only works for numeric columns.\n\n"
98 " -majorOrder=row|column\n"
99 " Set the major order for data storage, either row-major or column-major.\n\n"
100 "Program by Michael Borland. (" __DATE__
" " __TIME__
", SVN revision: " SVN_VERSION
")\n";
106 short decreasing_order, maximize_order, absolute;
110static char *order_mode[5] = {
118long SDDS_SortRows(
SDDS_DATASET *SDDS_dataset,
SORT_REQUEST *xsort_request,
long xsort_requests,
long non_dominate_sort);
119long SDDS_UnsetDuplicateRows(
SDDS_DATASET *SDDS_dataset,
SORT_REQUEST *xsort_request,
long xsort_requests,
long provideIdenticalCount);
122 SORT_REQUEST *xsort_parameter,
long xsort_parameters,
long uniqueRows,
long provideIdenticalCount,
123 long pipeFlags,
long non_dominate_sort);
125double *read_constr_violation(
SDDS_DATASET *SDDS_dataset);
127long numericHigh = 0, constDefined = 0;
129int main(
int argc,
char **argv) {
131 char *input, *output;
132 long i_arg, non_dominate_sort = 0;
135 long tmpfile_used, sort_requests, noWarnings, uniqueRows, provideIdenticalCount, tmpfileForInternalPipe;
136 long sort_parameters;
138 unsigned long pipeFlags, majorOrderFlag;
139 short columnMajorOrder = -1;
142 argc =
scanargs(&s_arg, argc, argv);
147 input = output = NULL;
148 tmpfile_used = sort_requests = noWarnings = sort_parameters = tmpfileForInternalPipe = 0;
149 sort_request = sort_parameter = NULL;
151 uniqueRows = provideIdenticalCount = 0;
152 for (i_arg = 1; i_arg < argc; i_arg++) {
153 if (s_arg[i_arg].arg_type == OPTION) {
154 switch (
match_string(s_arg[i_arg].list[0], option, N_OPTIONS, 0)) {
155 case SET_MAJOR_ORDER:
157 s_arg[i_arg].n_items--;
158 if (s_arg[i_arg].n_items > 0 &&
159 (!
scanItemList(&majorOrderFlag, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
160 "row", -1, NULL, 0, SDDS_ROW_MAJOR_ORDER,
161 "column", -1, NULL, 0, SDDS_COLUMN_MAJOR_ORDER, NULL)))
162 SDDS_Bomb(
"invalid -majorOrder syntax/values");
163 if (majorOrderFlag & SDDS_COLUMN_MAJOR_ORDER)
164 columnMajorOrder = 1;
165 else if (majorOrderFlag & SDDS_ROW_MAJOR_ORDER)
166 columnMajorOrder = 0;
168 case SET_NON_DOMINATE_SORT:
169 non_dominate_sort = 1;
172 if (s_arg[i_arg].n_items < 2 || s_arg[i_arg].n_items > 4)
174 sort_request =
trealloc(sort_request,
sizeof(*sort_request) * (sort_requests + 1));
175 sort_request[sort_requests].name = s_arg[i_arg].list[1];
176 sort_request[sort_requests].maximize_order = 0;
177 sort_request[sort_requests].decreasing_order = 0;
178 sort_request[sort_requests].absolute = 0;
179 if (s_arg[i_arg].n_items >= 3) {
181 for (j = 2; j < s_arg[i_arg].n_items; j++) {
182 switch (
match_string(s_arg[i_arg].list[j], order_mode, 5, 0)) {
186 sort_request[sort_requests].decreasing_order = 1;
191 sort_request[sort_requests].maximize_order = 1;
194 sort_request[sort_requests].absolute = 1;
197 fprintf(stderr,
"unknown sort order specified--give 'increasing' or 'decreasing' for dominated sorting\n or'maximize' or 'minimize' for non-dominated-sorting.\n");
206 if (s_arg[i_arg].n_items < 2 || s_arg[i_arg].n_items > 3)
208 sort_parameter =
trealloc(sort_parameter,
sizeof(*sort_parameter) * (sort_parameters + 1));
209 sort_parameter[sort_parameters].name = s_arg[i_arg].list[1];
210 if (s_arg[i_arg].n_items == 3) {
211 if ((sort_parameter[sort_parameters].decreasing_order =
match_string(s_arg[i_arg].list[2], order_mode, 2, 0)) < 0)
212 SDDS_Bomb(
"unknown sort order specified--give 'increasing' or 'decreasing'");
214 sort_parameter[sort_parameters].decreasing_order = 0;
220 case SET_NUMERICHIGH:
224 if (!
processPipeOption(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1, &pipeFlags))
229 if (s_arg[i_arg].n_items > 1) {
231 if (s_arg[i_arg].n_items > 2 ||
232 strncmp(
"count", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) != 0)
234 provideIdenticalCount = 1;
238 fprintf(stderr,
"error: unknown switch: %s\n", s_arg[i_arg].list[0]);
244 input = s_arg[i_arg].list[0];
245 else if (output == NULL)
246 output = s_arg[i_arg].list[0];
252 if (!sort_requests && !sort_parameters)
254 processFilenames(
"sddssort", &input, &output, pipeFlags, noWarnings, &tmpfile_used);
259 if (sort_requests <= 1)
260 non_dominate_sort = 0;
262 if (SDDS_input.layout.popenUsed) {
267 char tmpfileName[1024];
269 sprintf(tmpfileName,
"/tmp/sddssort.%ld", (
long)pid);
270 tmpfileForInternalPipe = 1;
275 if (columnMajorOrder != -1)
276 SDDS_tmp.layout.data_mode.column_major = columnMajorOrder;
278 SDDS_tmp.layout.data_mode.column_major = SDDS_input.layout.data_mode.column_major;
279 if (non_dominate_sort) {
315 if (columnMajorOrder != -1)
316 SDDS_output.layout.data_mode.column_major = columnMajorOrder;
318 SDDS_output.layout.data_mode.column_major = SDDS_input.layout.data_mode.column_major;
319 if (provideIdenticalCount &&
324 if (non_dominate_sort) {
338 if (!SDDS_SortAll(&SDDS_input, &SDDS_output, sort_request, sort_requests, sort_parameter, sort_parameters,
339 uniqueRows, provideIdenticalCount, pipeFlags, non_dominate_sort)) {
357static long sort_requests;
358static int64_t *sort_row_index;
360int SDDS_CompareData(
SDDS_DATASET *SDDS_dataset,
short type,
short absolute,
void *data1,
void *data2) {
372 if ((ldouble_diff = *(
long double *)data1 - *(
long double *)data2) > 0)
374 else if (ldouble_diff < 0)
378 if ((double_diff = *(
double *)data1 - *(
double *)data2) > 0)
380 else if (double_diff < 0)
384 if ((float_diff = *(
float *)data1 - *(
float *)data2) > 0)
386 else if (float_diff < 0)
390 if ((long64_diff = *(int64_t *)data1 - *(int64_t *)data2) > 0)
392 else if (long64_diff < 0)
396 if ((long_diff = *(int32_t *)data1 - *(int32_t *)data2) > 0)
398 else if (long_diff < 0)
402 if ((short_diff = *(
short *)data1 - *(
short *)data2) > 0)
404 else if (short_diff < 0)
408 if (*(uint64_t *)data1 > *(uint64_t *)data2)
410 if (*(uint64_t *)data1 < *(uint64_t *)data2)
414 if (*(uint32_t *)data1 > *(uint32_t *)data2)
416 if (*(uint32_t *)data1 < *(uint32_t *)data2)
420 if (*(
unsigned short *)data1 > *(
unsigned short *)data2)
422 if (*(
unsigned short *)data1 < *(
unsigned short *)data2)
426 if ((char_diff = *(
char *)data1 - *(
char *)data2) > 0)
428 else if (char_diff < 0)
433 return (
strcmp_nh(*(
char **)data1, *(
char **)data2));
435 return (strcmp(*(
char **)data1, *(
char **)data2));
437 SDDS_SetError(
"Problem doing data comparison--invalid data type (SDDS_CompareData)");
444 if ((ldouble_diff = fabsl(*(
long double *)data1) - fabsl(*(
long double *)data2)) > 0)
446 else if (ldouble_diff < 0)
450 if ((double_diff = fabs(*(
double *)data1) - fabs(*(
double *)data2)) > 0)
452 else if (double_diff < 0)
456 if ((float_diff = fabsf(*(
float *)data1) - fabsf(*(
float *)data2)) > 0)
458 else if (float_diff < 0)
462 if ((long64_diff = llabs(*(int64_t *)data1) - llabs(*(int64_t *)data2)) > 0)
464 else if (long64_diff < 0)
468 if ((long_diff = labs(*(int32_t *)data1) - labs(*(int32_t *)data2)) > 0)
470 else if (long_diff < 0)
474 if ((short_diff = abs(*(
short *)data1) - abs(*(
short *)data2)) > 0)
476 else if (short_diff < 0)
480 if (*(uint64_t *)data1 > *(uint64_t *)data2)
482 if (*(uint64_t *)data1 < *(uint64_t *)data2)
486 if (*(uint32_t *)data1 > *(uint32_t *)data2)
488 if (*(uint32_t *)data1 < *(uint32_t *)data2)
492 if (*(
unsigned short *)data1 > *(
unsigned short *)data2)
494 if (*(
unsigned short *)data1 < *(
unsigned short *)data2)
498 if ((char_diff = *(
char *)data1 - *(
char *)data2) > 0)
500 else if (char_diff < 0)
505 return (
strcmp_nh(*(
char **)data1, *(
char **)data2));
507 return (strcmp(*(
char **)data1, *(
char **)data2));
509 SDDS_SetError(
"Problem doing data comparison--invalid data type (SDDS_CompareData)");
516int SDDS_CompareRows(
const void *vrow1,
const void *vrow2) {
520 static double data1, data2;
521 static int64_t row1, row2;
525 row1 = *(int64_t *)vrow1;
526 row2 = *(int64_t *)vrow2;
528 for (i = 0; i < sort_requests; i++) {
531 SDDS_SetError(
"Problem getting value for sort (SDDS_CompareRows)");
535 if ((comparison = SDDS_CompareData(SDDS_sort, sort_request[i].type, sort_request[i].absolute,
536 (
void *)&data1, (
void *)&data2))) {
540 free(*((
char **)p1));
541 free(*((
char **)p2));
545 return (sort_request[i].decreasing_order ? -comparison : comparison);
550 free(*((
char **)p1));
551 free(*((
char **)p2));
559long SDDS_SwapRows(
SDDS_DATASET *SDDS_dataset, int64_t row1, int64_t row2) {
560#define SWAP_BUFFER_SIZE 16
561 static char buffer[SWAP_BUFFER_SIZE];
564 data = SDDS_dataset->data;
566 fprintf(stderr,
"swapping row %" PRId64
" with row %" PRId64
"\n", row1, row2);
568 for (i = 0; i < SDDS_dataset->layout.n_columns; i++) {
569 if ((size =
SDDS_GetTypeSize(SDDS_dataset->layout.column_definition[i].type)) > SWAP_BUFFER_SIZE) {
570 SDDS_SetError(
"Unable to swap rows--swap buffer is too small (SDDS_SwapRows)");
574 if (SDDS_dataset->layout.column_definition[i].type ==
SDDS_STRING)
575 fprintf(stderr,
" %s <--> %s\n", *(
char **)((
char *)(data[i]) + row1 * size), *(
char **)((
char *)(data[i]) + row2 * size));
577 memcpy((
char *)buffer, (
char *)(data[i]) + row1 * size, size);
578 memcpy((
char *)(data[i]) + row1 * size, (
char *)(data[i]) + row2 * size, size);
579 memcpy((
char *)(data[i]) + row2 * size, (
char *)buffer, size);
584long SDDS_SortRows(
SDDS_DATASET *SDDS_dataset,
SORT_REQUEST *xsort_request,
long xsort_requests,
long non_dominate_sort) {
585 int64_t i, j, k, rows;
586 int64_t *row_location;
588 double **data = NULL, *dist = NULL, *const_violation = NULL;
589 int32_t *rank = NULL;
591 long *maximize = NULL;
593 SDDS_sort = SDDS_dataset;
594 sort_request = xsort_request;
595 sort_requests = xsort_requests;
599 for (i = 0; i < sort_requests; i++) {
601 sprintf(s,
"column name \"%s\" is not recognized(SDDS_GetColumnIndex)", sort_request[i].name);
608 if (non_dominate_sort) {
609 data = (
double **)malloc(
sizeof(*data) * sort_requests);
610 maximize = (
long *)malloc(
sizeof(*maximize) * sort_requests);
611 for (i = 0; i < sort_requests; i++) {
613 fprintf(stderr,
"Non-dominated sort is not available for string column.\n");
621 maximize[i] = sort_request[i].maximize_order;
623 const_violation = read_constr_violation(SDDS_sort);
624 fill_population(&pop, rows, sort_requests, data, maximize, const_violation);
626 rank = (int32_t *)malloc(
sizeof(*rank) * rows);
627 dist = (
double *)malloc(
sizeof(*dist) * rows);
628 if (!const_violation)
629 const_violation = calloc(rows,
sizeof(*const_violation));
630 for (i = 0; i < rows; i++) {
631 rank[i] = pop.ind[sort_row_index[i]].rank;
632 dist[i] = pop.ind[sort_row_index[i]].crowd_dist;
633 const_violation[i] = pop.ind[sort_row_index[i]].constr_violation;
636 for (i = 0; i < sort_requests; i++)
641 sort_row_index =
tmalloc(
sizeof(*sort_row_index) * rows);
642 for (i = 0; i < rows; i++)
643 sort_row_index[i] = i;
647 qsort((
void *)sort_row_index, rows,
sizeof(*sort_row_index), SDDS_CompareRows);
653 fprintf(stderr,
"new row order:\n");
654 for (i = 0; i < rows; i++)
655 fprintf(stderr,
"%" PRId64
" %" PRId64
"\n", i, sort_row_index[i]);
656 fprintf(stderr,
"\n");
659 row_location =
tmalloc(
sizeof(*sort_row_index) * rows);
660 for (i = 0; i < rows; i++)
661 row_location[sort_row_index[i]] = i;
662 for (i = 0; i < rows; i++) {
663 if ((j = sort_row_index[i]) != i) {
665 if (!SDDS_SwapRows(SDDS_sort, i, j)) {
666 SDDS_SetError(
"Problem swapping rows after index sort (SDDS_SortRows");
671 sort_row_index[i] = i;
674 sort_row_index[k] = j;
678 fprintf(stderr,
"new row order:\n");
679 for (j = 0; j < rows; j++)
680 fprintf(stderr,
"%" PRId64
" %" PRId64
"\n", j, sort_row_index[j]);
681 fprintf(stderr,
"\n");
684 if (non_dominate_sort) {
685 if (
SDDS_SetColumn(SDDS_sort, SDDS_SET_BY_NAME, rank, rows,
"Rank", NULL) != 1 ||
686 SDDS_SetColumn(SDDS_sort, SDDS_SET_BY_NAME, dist, rows,
"CrowdingDistance", NULL) != 1 ||
687 SDDS_SetColumn(SDDS_sort, SDDS_SET_BY_NAME, const_violation, rows,
"ConstraintsViolation", NULL) != 1) {
693 free(const_violation);
695 free(sort_row_index);
700long SDDS_UnsetDuplicateRows(
SDDS_DATASET *SDDS_dataset,
SORT_REQUEST *xsort_request,
long xsort_requests,
long provideIdenticalCount) {
702 int64_t *identicalCount;
706 SDDS_sort = SDDS_dataset;
707 sort_request = xsort_request;
708 sort_requests = xsort_requests;
710 for (i = 0; i < sort_requests; i++) {
712 sprintf(s,
"column name \"%s\" is not recognized(SDDS_GetColumnIndex)", sort_request[i].name);
723 rowFlag =
tmalloc(
sizeof(*rowFlag) * rows);
724 identicalCount =
tmalloc(
sizeof(*identicalCount) * rows);
725 for (i = 0; i < rows; i++)
726 rowFlag[i] = identicalCount[i] = 1;
728 for (i = 0; i < rows - 1; i++) {
731 for (j = i + 1; j < rows; j++) {
733 if (SDDS_CompareRows(&i, &j) == 0) {
734 identicalCount[i] += 1;
743 if (provideIdenticalCount && !
SDDS_SetColumn(SDDS_sort, SDDS_SET_BY_NAME, identicalCount, rows,
"IdenticalCount"))
750static long sort_parameters;
753int SDDS_ComparePages(
const void *vpage1,
const void *vpage2) {
757 static int32_t page1, page2;
761 page1 = *(int32_t *)vpage1;
762 page2 = *(int32_t *)vpage2;
764 for (i = 0; i < sort_parameters; i++) {
765 if ((comparison = SDDS_CompareData(SDDS_sortpage, sort_parameter[i].type, sort_parameter[i].absolute,
766 (
void *)&(sort_parameter[i].data[page1]), (
void *)&(sort_parameter[i].data[page2])))) {
771 return (sort_parameter[i].decreasing_order ? -comparison : comparison);
782 long xsort_requests,
SORT_REQUEST *xsort_parameter,
long xsort_parameters,
long uniqueRows,
783 long provideIdenticalCount,
long xpipeFlags,
long non_dominate_sort) {
785 int32_t *xsort_page_index;
790 SDDS_sortpage = SDDS_inputx;
791 sort_parameter = xsort_parameter;
792 sort_parameters = xsort_parameters;
793 sort_request = xsort_request;
794 sort_requests = xsort_requests;
795 xsort_page_index = NULL;
796 pages = i = j = k = 0;
797 for (i = 0; i < sort_parameters; i++) {
799 sprintf(s,
"Unable to get parameter value--parameter name \"%s\" is not recognized(SDDS_GetParameterIndex)", sort_parameter[i].name);
806 if (sort_parameters) {
807 if (xpipeFlags == 0 && !SDDS_sortpage->layout.gzipFile)
809 for (i = 0; i < sort_parameters; i++)
810 sort_parameter[i].data = NULL;
812 if (xpipeFlags || SDDS_sortpage->layout.gzipFile) {
815 tmp_datasets = realloc(tmp_datasets,
sizeof(*tmp_datasets) * (pages + 1));
825 for (i = 0; i < sort_parameters; i++) {
826 sort_parameter[i].data = realloc(sort_parameter[i].data,
sizeof(*sort_parameter[i].data) * (pages + 1));
829 SDDS_SetError(
"Problem getting parameter value for sort (SDDS_SortAll)");
837 xsort_page_index =
tmalloc(
sizeof(*xsort_page_index) * pages);
838 for (k = 0; k < pages; k++)
839 xsort_page_index[k] = k;
841 qsort((
void *)xsort_page_index, pages,
sizeof(*xsort_page_index), SDDS_ComparePages);
844 for (i = 0; i < pages; i++) {
845 j = xsort_page_index[i];
846 if (xpipeFlags || SDDS_sortpage->layout.gzipFile) {
876 if (!SDDS_SortRows(SDDS_outputx, sort_request, sort_requests, non_dominate_sort)) {
881 if (uniqueRows && !SDDS_UnsetDuplicateRows(SDDS_outputx, sort_request, sort_requests, provideIdenticalCount)) {
902 if (!SDDS_SortRows(SDDS_outputx, sort_request, sort_requests, non_dominate_sort)) {
907 if (uniqueRows && !SDDS_UnsetDuplicateRows(SDDS_outputx, sort_request, sort_requests, provideIdenticalCount)) {
922 if (xsort_page_index)
923 free(xsort_page_index);
927double *read_constr_violation(
SDDS_DATASET *SDDS_dataset) {
928 double *const_violation = NULL, **data = NULL;
929 int32_t columns, constraints, j;
931 char **columnName = NULL;
933 columns = constraints = 0;
935 if (!constDefined && !(const_violation = (
double *)
SDDS_GetColumnInDoubles(SDDS_dataset,
"ConstraintsViolation")))
940 for (i = 0; i < columns; i++) {
941 if (
wild_match(columnName[i],
"*Constraints*") && strcmp(columnName[i],
"ConstraintsViolation") != 0) {
942 data =
SDDS_Realloc(data,
sizeof(*data) * (constraints + 1));
943 data[constraints] = NULL;
950 const_violation = calloc(rows,
sizeof(*const_violation));
951 for (i = 0; i < rows; i++) {
952 for (j = 0; j < constraints; j++) {
954 const_violation[i] += data[j][i];
957 for (j = 0; j < constraints; j++)
962 return const_violation;
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
int32_t SDDS_SetDefaultIOBufferSize(int32_t newValue)
int32_t SDDS_InitializeCopy(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, char *filename, char *filemode)
int32_t SDDS_CopyPage(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
int32_t SDDS_SetColumn(SDDS_DATASET *SDDS_dataset, int32_t mode, void *data, int64_t rows,...)
Sets the values for one data column in the current data table of an SDDS dataset.
int32_t SDDS_DefineSimpleColumn(SDDS_DATASET *SDDS_dataset, const char *name, const char *unit, int32_t type)
Defines a simple data column within the SDDS dataset.
int32_t SDDS_WritePage(SDDS_DATASET *SDDS_dataset)
Writes the current data table to the output file.
int32_t SDDS_WriteLayout(SDDS_DATASET *SDDS_dataset)
Writes the SDDS layout header to the output file.
void SDDS_SetError(char *error_text)
Records an error message in the SDDS error stack.
int32_t SDDS_GetParameterType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of a parameter in the SDDS dataset by its index.
int32_t SDDS_GetParameterIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named parameter in the SDDS dataset.
int32_t SDDS_GetColumnIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named column in the SDDS dataset.
int32_t SDDS_CheckColumn(SDDS_DATASET *SDDS_dataset, char *name, char *units, int32_t type, FILE *fp_message)
Checks if a column exists in the SDDS dataset with the specified name, units, and type.
char ** SDDS_GetColumnNames(SDDS_DATASET *SDDS_dataset, int32_t *number)
Retrieves the names of all columns in the SDDS dataset.
void SDDS_PrintErrors(FILE *fp, int32_t mode)
Prints recorded error messages to a specified file stream.
void SDDS_RegisterProgramName(const char *name)
Registers the executable program name for use in error messages.
int32_t SDDS_GetTypeSize(int32_t type)
Retrieves the size in bytes of a specified SDDS data type.
int32_t SDDS_GetColumnType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of a column in the SDDS dataset by its index.
void SDDS_Bomb(char *message)
Terminates the program after printing an error message and recorded errors.
void * SDDS_Realloc(void *old_ptr, size_t new_size)
Reallocates memory to a new size.
#define SDDS_ULONG
Identifier for the unsigned 32-bit integer data type.
#define SDDS_FLOAT
Identifier for the float data type.
#define SDDS_STRING
Identifier for the string data type.
#define SDDS_ULONG64
Identifier for the unsigned 64-bit integer data type.
#define SDDS_LONG
Identifier for the signed 32-bit integer data type.
#define SDDS_SHORT
Identifier for the signed short integer data type.
#define SDDS_CHARACTER
Identifier for the character data type.
#define SDDS_USHORT
Identifier for the unsigned short integer data type.
#define SDDS_ANY_NUMERIC_TYPE
Special identifier used by SDDS_Check*() routines to accept any numeric type.
#define SDDS_DOUBLE
Identifier for the double data type.
#define SDDS_LONGDOUBLE
Identifier for the long double data type.
#define SDDS_LONG64
Identifier for the signed 64-bit integer data type.
void * trealloc(void *old_ptr, uint64_t size_of_block)
Reallocates a memory block to a new size.
void * tmalloc(uint64_t size_of_block)
Allocates a memory block of the specified size with zero initialization.
void bomb(char *error, char *usage)
Reports error messages to the terminal and aborts the program.
long match_string(char *string, char **option, long n_options, long mode)
Matches a given string against an array of option strings based on specified modes.
int64_t * non_dominated_sort(population *new_pop)
Performs non-dominated sorting on a population and assigns ranks and crowding distances.
void fill_population(population *pop, long rows, long columns, double **columnValue, long *maximize, double *const_violation)
Initializes and fills the population structure with individuals and their objective values.
void free_pop_mem(population *pop)
Frees all dynamically allocated memory associated with a population.
long replaceFileAndBackUp(char *file, char *replacement)
Replaces a file with a replacement file and creates a backup of the original.
int scanargs(SCANNED_ARG **scanned, int argc, char **argv)
long processPipeOption(char **item, long items, unsigned long *flags)
void processFilenames(char *programName, char **input, char **output, unsigned long pipeFlags, long noWarnings, long *tmpOutputUsed)
void free_scanargs(SCANNED_ARG **scanned, int argc)
long scanItemList(unsigned long *flags, char **item, long *items, unsigned long mode,...)
Scans a list of items and assigns values based on provided keywords and types.
char * str_tolower(char *s)
Convert a string to lower case.
int wild_match(char *string, char *template)
Determine whether one string is a wildcard match for another.
int strcmp_nh(const char *s1, const char *s2)
Compare two strings with a custom non-hierarchical ranking.