chiark
/
gitweb
/
~ianmdlvl
/
nlopt.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
35686c1
)
print out which bound was violated for bounds violation
author
stevenj
<stevenj@alum.mit.edu>
Mon, 12 Jul 2010 22:30:58 +0000
(18:30 -0400)
committer
stevenj
<stevenj@alum.mit.edu>
Mon, 12 Jul 2010 22:30:58 +0000
(18:30 -0400)
darcs-hash:
20100712223058
-c8de0-
28424889fa63e686e5377c0625b0891bc2446b84
.gz
test/testopt.cpp
patch
|
blob
|
history
diff --git
a/test/testopt.cpp
b/test/testopt.cpp
index 2319ea1bca110a77100bc2eb58c65fd87fd51b93..b1fed82dfd779bc670c187be102e231ab9d2ae66 100644
(file)
--- a/
test/testopt.cpp
+++ b/
test/testopt.cpp
@@
-78,11
+78,20
@@
static double bounds_wrap_func(int n, const double *x, double *grad, void *d_)
{
bounds_wrap_data *d = (bounds_wrap_data *) d_;
int i;
- for (i = 0; i < n; ++i)
- if (x[i] < d->lb[i] || x[i] > d->ub[i])
+ double b = 0;
+ for (i = 0; i < n; ++i) {
+ if (x[i] < d->lb[i]) {
+ b = d->lb[i];
+ break;
+ }
+ else if (x[i] > d->ub[i]) {
+ b = d->ub[i];
break;
+ }
+ }
if (i < n)
- fprintf(stderr, "WARNING: bounds violated by x[%d] = %g\n", i, x[i]);
+ fprintf(stderr, "WARNING: bounds violated by x[%d] = %g = %g + %g\n",
+ i, x[i], b, x[i] - b);
return d->f(n, x, grad, d->f_data);
}