Skip to content

Commit 4640969

Browse files
committed
c/ Add --no-check option to epsilon and igd executables.
1 parent faccfe9 commit 4640969

3 files changed

Lines changed: 43 additions & 16 deletions

File tree

c/NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
it to replace most `bool *` arguments.
1212
* `is_nondominated()` and `pareto_rank()` do not return pointers to newly
1313
allocated memory to help zero-copy communication with Python/R.
14+
* Add `--no-check` option to `epsilon` and `igd` executables.
1415

1516

1617
## 0.18

c/epsilon.c

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ OPTION_QUIET_STR
7777
" -r, --reference FILE file that contains the reference set \n"
7878
OPTION_OBJ_STR
7979
OPTION_MAXIMISE_STR
80+
" , --[no]-check The reference set must be nondominated. By default, \n"
81+
" dominated pointers are filtered out. Option --no-check\n"
82+
" skips the filtering, which may lead to wrong results."
8083
" -s, --suffix=STRING Create an output file for each input file by appending\n"
8184
" this suffix. This is ignored when reading from stdin. \n"
8285
" If missing, output is sent to stdout. \n"
@@ -141,18 +144,19 @@ int main(int argc, char *argv[])
141144
// See the man page for getopt_long for an explanation of these fields.
142145
static const char short_options[] = "hVvqamMr:s:o:";
143146
static const struct option long_options[] = {
144-
{"help", no_argument, NULL, 'h'},
145-
{"version", no_argument, NULL, 'V'},
146-
{"verbose", no_argument, NULL, 'v'},
147-
{"quiet", no_argument, NULL, 'q'},
148-
{"no-check", no_argument, NULL, 'c'},
149-
{"additive", no_argument, NULL, 'a'},
150-
{"multiplicative", no_argument, NULL, 'm'},
151-
{"maximise", no_argument, NULL, 'M'},
152-
{"maximize", no_argument, NULL, 'M'},
153-
{"reference", required_argument, NULL, 'r'},
154-
{"suffix", required_argument, NULL, 's'},
155-
{"obj", required_argument, NULL, 'o'},
147+
{"help", no_argument, NULL, 'h'},
148+
{"version", no_argument, NULL, 'V'},
149+
{"verbose", no_argument, NULL, 'v'},
150+
{"quiet", no_argument, NULL, 'q'},
151+
{"check", no_argument, NULL, 'c'},
152+
{"no-check", no_argument, NULL, 'C'},
153+
{"additive", no_argument, NULL, 'a'},
154+
{"multiplicative", no_argument, NULL, 'm'},
155+
{"maximise", no_argument, NULL, 'M'},
156+
{"maximize", no_argument, NULL, 'M'},
157+
{"reference", required_argument, NULL, 'r'},
158+
{"suffix", required_argument, NULL, 's'},
159+
{"obj", required_argument, NULL, 'o'},
156160
{NULL, 0, NULL, 0} /* marks end of list */
157161
};
158162

@@ -170,9 +174,11 @@ int main(int argc, char *argv[])
170174
while (0 < (opt = getopt_long(argc, argv, short_options,
171175
long_options, &longopt_index))) {
172176
switch (opt) {
173-
case 'c': // --no-check
174-
check_flag = false;
175-
break;
177+
178+
case 'c': // --check
179+
case 'C': // --no-check
180+
check_flag = (opt == 'c');
181+
break;
176182

177183
case 'a': // --additive
178184
additive_flag = true;

c/igd.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ OPTION_QUIET_STR
9494
" -r, --reference FILE file that contains the reference set \n"
9595
OPTION_OBJ_STR
9696
OPTION_MAXIMISE_STR
97+
" , --[no]-check The reference set must be nondominated. By default, \n"
98+
" dominated pointers are filtered out. Option --no-check\n"
99+
" skips the filtering, which may lead to wrong results."
97100
" -s, --suffix=STRING Create an output file for each input file by appending\n"
98101
" this suffix. This is ignored when reading from stdin. \n"
99102
" If missing, output is sent to stdout. \n"
@@ -196,6 +199,8 @@ int main(int argc, char *argv[])
196199
{"version", no_argument, NULL, 'V'},
197200
{"verbose", no_argument, NULL, 'v'},
198201
{"quiet", no_argument, NULL, 'q'},
202+
{"check", no_argument, NULL, 'c'},
203+
{"no-check", no_argument, NULL, 'C'},
199204
{"gd", no_argument, NULL, GD_opt},
200205
{"igd", no_argument, NULL, IGD_opt},
201206
{"gd-p", no_argument, NULL, GD_p_opt},
@@ -213,6 +218,7 @@ int main(int argc, char *argv[])
213218
};
214219
set_program_invocation_short_name(argv[0]);
215220

221+
bool check_flag = true;
216222
double * reference = NULL;
217223
size_t reference_size = 0;
218224
const int * minmax = NULL;
@@ -224,6 +230,12 @@ int main(int argc, char *argv[])
224230
while (0 < (opt = getopt_long(argc, argv, short_options,
225231
long_options, &longopt_index))) {
226232
switch (opt) {
233+
234+
case 'c': // --check
235+
case 'C': // --no-check
236+
check_flag = (opt == 'c');
237+
break;
238+
227239
case 'p':
228240
// FIXME: Use strtol
229241
exponent_p = atoi(optarg);
@@ -302,7 +314,15 @@ int main(int argc, char *argv[])
302314
if (minmax == NULL) {
303315
minmax = maximise_all_flag ? minmax_maximise((dimension_t) nobj) : minmax_minimise((dimension_t) nobj);
304316
}
305-
reference_size = filter_dominated_set(reference, reference_size, (dimension_t)nobj, minmax);
317+
318+
if (check_flag) {
319+
// Ensure the reference set is nondominated.
320+
size_t prev_reference_size = reference_size;
321+
reference_size = filter_dominated_set(reference, reference_size, (dimension_t)nobj, minmax);
322+
if (prev_reference_size > reference_size)
323+
warnprintf("removed %zd dominated points from the reference set",
324+
prev_reference_size - reference_size);
325+
}
306326

307327
int numfiles = argc - optind;
308328
if (numfiles < 1) {/* Read stdin. */

0 commit comments

Comments
 (0)