def obj(self, x): """ Return the value of the objective function at `x`. This function is specialized since the original objective function only depends on a subvector of `x`. """ return AmplModel.obj(self, x[:self.original_n])
pi0 = nlp.pi0 n = nlp.n m = nlp.m print 'There are %d variables and %d constraints' % ( n, m ) max_n = min( n, 5 ) max_m = min( m, 5 ) print print ' Printing at most 5 first components of vectors' print print 'Initial point: ', x0[:max_n] print 'Lower bounds on x: ', nlp.Lvar[:max_n] print 'Upper bounds on x: ', nlp.Uvar[:max_n] print 'f( x0 ) = ', nlp.obj( x0 ) g0 = nlp.grad( x0 ) print 'grad f( x0 ) = ', g0[:max_n] if max_m > 0: print 'Initial multipliers: ', pi0[:max_m] print 'Lower constraint bounds: ', nlp.Lcon[:max_m] print 'Upper constraint bounds: ', nlp.Ucon[:max_m] c0 = nlp.cons( x0 ) print 'c( x0 ) = ', c0[:max_m] J = nlp.jac( x0 ) H = nlp.hess( x0, pi0 ) print print ' nnzJ = ', J.nnz print ' nnzH = ', H.nnz
pi0 = nlp.pi0 n = nlp.n m = nlp.m print 'There are %d variables and %d constraints' % (n, m) max_n = min(n, 5) max_m = min(m, 5) print print ' Printing at most 5 first components of vectors' print print 'Initial point: ', x0[:max_n] print 'Lower bounds on x: ', nlp.Lvar[:max_n] print 'Upper bounds on x: ', nlp.Uvar[:max_n] print 'f( x0 ) = ', nlp.obj(x0) g0 = nlp.grad(x0) print 'grad f( x0 ) = ', g0[:max_n] if max_m > 0: print 'Initial multipliers: ', pi0[:max_m] print 'Lower constraint bounds: ', nlp.Lcon[:max_m] print 'Upper constraint bounds: ', nlp.Ucon[:max_m] c0 = nlp.cons(x0) print 'c( x0 ) = ', c0[:max_m] J = nlp.jac(x0) H = nlp.hess(x0, pi0) print print ' nnzJ = ', J.nnz print ' nnzH = ', H.nnz