[Scipy-tickets] [SciPy] #1231: use of uninitialized variable in SLSQP when n equality constraints
SciPy Trac
scipy-tickets@scipy....
Mon Jul 12 17:51:07 CDT 2010
#1231: use of uninitialized variable in SLSQP when n equality constraints
----------------------------+-----------------------------------------------
Reporter: stevenj | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 0.9.0
Component: scipy.optimize | Version: 0.7.0
Keywords: |
----------------------------+-----------------------------------------------
I was adapting the SLSQP code for use in another library (NLopt, ab-
initio.mit.edu/nlopt), and I noticed a bug that you might want to fix. In
the case where the number of equality constraints equals the dimension of
the problem, valgrind reported the use of an uninitialized variable in a
conditional statement. I tracked the source of the uninitialized value
down to line 813 of slsqp_optmz.f in SUBROUTINE lsei:
CALL dcopy_ (mg-mc,w(mc1),0,w(mc1),1)
I believe that this should be:
CALL dcopy_ (mg,w(mc1),0,w(mc1),1)
This initializes part of the work array w to 0. If the number of
inequality constraints differs from the number of dimensions (mc.NE.n in
lsei), then this statement doesn't matter because w(mc1...mc1+mg-1) get
overwritten anyway by the Lagrange multipliers when lsi is called a little
later. But if mc.EQ.n, then the GOTO statment on line 815 jumps to the
end, where w(mc1...mc1+mg-1) is used in a dot product.
I've verified that, with the above fix, it correctly solves a test problem
with various numbers of equality and/or inequality constraints, and
valgrind no longer complains.
PS. I should also mention that, because of rounding errors, SLSQP will
occasionally evaluate the objective/constraints slightly outside of the
bounding box. I'm not sure if you care about this; my NLopt library
guarantees that the bound constraints are strictly honored (unlike
nonlinear constraints), so I had to tweak SLSQP in a couple of places to
check that rounding errors don't push the solution out of bounds.
--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1231>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
More information about the Scipy-tickets
mailing list