Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some additions to handle unconstrained case directly in aug. Lagrangian.

  • Loading branch information...
commit 7acf6af725d29cd40e189d512a6e0d8367354cd0 1 parent cc6129e
@lambe authored
Showing with 17 additions and 10 deletions.
  1. +17 −10 nlpy/optimize/solvers/auglag.py
View
27 nlpy/optimize/solvers/auglag.py
@@ -85,8 +85,8 @@ def __init__(self, nlp, **kwargs):
self.approxHess = kwargs.get('approxHess',True)
if self.approxHess:
# LBFGS is currently the only option
- self.Hessapp = LBFGS(self.n)
- #self.Hessapp = LSR1(self.n)
+ self.Hessapp = LBFGS(self.n,**kwargs)
+ #self.Hessapp = LSR1(self.n,**kwargs)
# Extend bound arrays to include slack variables
self.Lvar = numpy.zeros(self.n,'d')
@@ -116,11 +116,16 @@ def get_infeas(self, x, **kwargs):
nsLR_ind = nsUU_ind + self.nsLR
nsUR_ind = nsLR_ind + self.nsUR
- convals = self.nlp.cons(x[:nx])
- #convals[self.nlp.m:] = convals[self.nlp.rangeC]
- convals[self.lowerC] -= x[nx:nsLL_ind] + self.Lcon[self.lowerC]
- convals[self.upperC] += x[nsLL_ind:nsUU_ind] - self.Ucon[self.upperC]
- convals[self.equalC] -= self.Lcon[self.equalC]
+ if self.m == 0:
+ convals = numpy.zeros(self.m)
+ else:
+ convals = self.nlp.cons(x[:nx])
+ #convals[self.nlp.m:] = convals[self.nlp.rangeC]
+ convals[self.lowerC] -= x[nx:nsLL_ind] + self.Lcon[self.lowerC]
+ convals[self.upperC] += x[nsLL_ind:nsUU_ind] - self.Ucon[self.upperC]
+ convals[self.equalC] -= self.Lcon[self.equalC]
+ # end if
+
return convals
# end def
@@ -167,7 +172,8 @@ def grad(self, x, **kwargs):
JE = PysparseLinearOperator(_JE, symmetric=False)
algrad[:nx] += JE.T * vec
else:
- algrad[:nx] += numpy.dot(nlp.jac(x[:nx]).transpose(),vec)
+ if self.m != 0:
+ algrad[:nx] += numpy.dot(nlp.jac(x[:nx]).transpose(),vec)
# end if
algrad[nx:nsLL_ind] = -self.pi[nlp.lowerC] \
@@ -470,8 +476,9 @@ def solve(self, **kwargs):
if self.printlevel>=1:
print 'f = ',self.f
- print 'pi_max = ',max(self.pi)
- print 'max infeas. = ',max_cons_new
+ if self.alprob.m != 0:
+ print 'pi_max = ',numpy.max(self.pi)
+ print 'max infeas. = ',max_cons_new
# end def
Please sign in to comment.
Something went wrong with that request. Please try again.