Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auglag divide by zero #235

Closed
galbramc opened this issue Nov 26, 2018 · 4 comments
Closed

auglag divide by zero #235

galbramc opened this issue Nov 26, 2018 · 4 comments

Comments

@galbramc
Copy link

On line 177 of auglag.c there is:

d.rho = MAX(1e-6, MIN(10, 2 * fabs(*minf) / con2));

However, if there are only inequality constraints and they are all satisfied then con2 == 0. Something like

if (con2 == 0) d.rho = 10;
else d.rho = MAX(1e-6, MIN(10, 2 * fabs(*minf) / con2));

would be a simple fix, but I'm just guessing.

@jschueller
Copy link
Collaborator

please provide a simple test-case

@galbramc
Copy link
Author

galbramc commented Dec 7, 2018

I've attached a modified version of the tutorial that reproduces the divide by zero.
tutorial.txt

@jschueller
Copy link
Collaborator

you start from 0, with sqrt ... closing
Please provide a valid test case

@galbramc
Copy link
Author

My apologize I put together the example in haste and didn't notice I had the 1/0 in there. I've updated the the example tutorial.txt.

I modified the objective function to remove the 1/0 and provide two initial guesses. One initial guess where the constraint is satisfied and one initial guess where the constraint is violated. I also enabled floating point trapping. Running the example with gdb to catch the floating point exeption I get:

gdb ./a.out
GNU gdb (Ubuntu 8.2-0ubuntu1~14.04.1) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./a.out...done.
(gdb) run
Starting program: /home/galbramc/util/NLOPT/nlopt-2.5.0/test/a.out

Program received signal SIGFPE, Arithmetic exception.
0x0000000000443992 in auglag_minimize (n=2, f=0x4028f6 <myfunc>, f_data=0x0, m=0, fc=0x6b0d90, p=0, h=0x0, lb=0x6b0d10, ub=0x6b0d30, x=0x7fffffffd130,
    minf=0x7fffffffd120, stop=0x7fffffffd000, sub_opt=0x6b0e20, sub_has_fc=0) at /home/galbramc/util/NLOPT/nlopt-2.5.0/src/algs/auglag/auglag.c:177
177               d.rho = MAX(1e-6, MIN(10, 2 * fabs(*minf) / con2));
(gdb) print con2
$1 = 0
(gdb)

Using the initial guess that violates the constraint works just fine because con2 >
0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants