MOOCHO and TSFCore object-oriented software and interfaces for the development of optimization and other advanced abstract numerical algorithms Roscoe A. Bartlett Optimization and Uncertainty Estimation Sandia National Laboratories Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company, for the United States Department of Energy under contract DE-AC04-94AL85000. Nonlinear Programming for Large-Scale Optimization NLP formulation for Simulation-Driven Optimization min f(y,u) f(y,u) : Y U R s.t. c(y,u) = 0 c(y,u) : Y U C (yL, uL) (y, u) (yU, uU) Y R m, U R n-m, C R m y Y : state variables f(y,u) : objective function u U : design/control variables c(y,u) : state (simulation) constriants • Classes of problems considered: • • • • Large-scale (up to 106 variables and more) Special problem structure (e.g. PDEs, DAEs) Application specific methods (e.g. linear solvers, nonlinear globalization) Specialized computing environments (e.g. MPP, client/server, out-of-core) • What we can not do: • Use the current generation of optimization software to exploit problem structure and take advantage of advanced computing environments • What we do not want to do: • Write a new optimization implementation for each piece of application software • What we do want to do: • Use gradient-based methods for simultaneous analysis and design (SAND) NAND vs. SAND : Choosing the right approach Nested Analysis and Design NAND • Better scalability to large design spaces • More accurate solutions • Algorithmic flexibility • Less computer time • Decreased impact to existing code • Ease of interfacing • Nonsmooth behavior Simultaneous Analysis and Design SAND Introducing MOOCHO! MOOCHO : Multifunctional Object-Oriented arCHitecture for Optimization • Built using object-oriented principles => OO! • Initially developed at CMU (rSQP++) => Good times! • Active-set and interior-point SQP-related methods => Fast! or Fast? • Open source (available soon?) => You can get it! • Flexible algorithm configuration => You can alter it! • Exchangeable numerical components => You can tailor it! • Abstract linear-algebra interfaces (AbstractLinAlgPack) => You can parallelize it! Nonlinear Equations : Foundation for many Problems! Applications • Discretized PDEs (e.g. finite element, finite volume, finite difference etc.) • Network problems (e.g. electrical circuits) Nonlinear Equations : Sensitivities Related Algorithms • Gradient-based optimization • SAND • NAND • Nonlinear equations (NLS) • Multidisciplinary analysis • Linear (matrix) analysis • Block iterative solvers • Eigenvalue problems • Uncertainty quantification • SFE • Stability analysis / continuation • Transients (ODEs, DAEs) B. van Bloemen Waanders, R. A. Bartlett, K. R. Long and P. T. Boggs. Large Scale Non-Linear Programming: PDE Applications and Dynamical Systems, Sandia National Laboratories, SAND2002-3198, 2002 Applications, Algorithms, Linear-Algebra Software Computes functions APP Interface ANA 1 1 1 APP 1 1 1..* 1..* Key points 1 LAL 1..* 1 Mat Vec Preconditioner • • • • • Complex algorithms Complex software Complex interfaces Complex computers Duplication of effort? APP : Application: Defines data for the problem (e.g. PDE or DAE model and discretization) LAL : Linear-Algebra Library : Implements basic matrices, vector and algebraic precondtioners (e.g. Epetra/Ifpack (Trilinos), PETSc etc.) ANA : Abstract Numerical Algorithm : Solves the numerical problem (e.g. optimization, nonlinear solvers, stability analysis, SFE, transient solvers etc.) MOOCHO and TSFCore TSFCore::Nonlin Computes functions APP Interface ANA MOOCHO NLPInterfacePack 1 1 1 TSFCore APP 1..* Key points 1..* 1 LAL Mat Vec Preconditioner • Maximizing development AbstractLinAlgPack impact • Software can be run on more sophisticated computers • Fosters improved algorithm development TSFCore : Basic Linear Algebra Interfaces OpBase domain range space VectorSpace A Vector knows its VectorSpaceMultiVector <<create>> 1..* columns LinearOp A linear operator is a kind of operator An operator knows its domain and range spaces 1 VectorSpaces RTOpT create Vectors! Vector Unified Modeling Langage (UML) Notation! LinearOps apply to Vectors TSFCore : Basic Linear Algebra Interfaces OpBase domain range space VectorSpace MultiVector <<create>> 1 LinearOp Compatible with: HCL (Hilbert Class Library) SVL (Standard Vector Library) Near optimal for many but not all abstract numerical algorithms (ANAs) RTOpT 1..* columns Vector TSFCore : Basic Linear Algebra Interfaces OpBase domain range space VectorSpace LinearOps apply to MultiVectors LinearOp <<create>> A MulitVector is a linear operator! MultiVector 1 VectorSpaces create MultiVectors! RTOpT 1..* columns Vector A MulitVector is a tall thin dense matrix A MulitVector has a collection of column vectors! TSFCore : Basic Linear Algebra Interfaces OpBase domain range space VectorSpace LinearOp <<create>> MultiVector 1 1..* columns Vector What about standard vector ops? Reductions (norm, dot etc.)? Transformations (axpy, scaling etc.)? RTOpT What about specialized vector ops? e.g. Interior point methods for opt TSFCore : Basic Linear Algebra Interfaces OpBase domain range space VectorSpace LinearOp MultiVector The Key to success! 1 RTOpT 1..* columns Vector Reduction/Transformation Operators • Supports all needed vector operations • Data/parallel independence • Optimal performance Challenge to interoperability? R. A. Bartlett, B. G. van Bloemen Waanders and M. A. Heroux. Vector Reduction/Transformation Operators, Accepted to ACM TOMS, 2003 TSFCore : Basic Linear Algebra Interfaces smallVecSpcFcty TSFCore::VectorSpaceFactory createVecSpc(in dim : int) : VectorSpace «create» TSFCore::VectorSpace TSFCore::OpBase dim : int space createMember() : Vector createMembers(in numMembers : int) : MultiVector isCompatible(in vecSpc : VectorSpace) : bool scalarProd(in x : Vector, in y : Vector) : Scalar opSupported(in M_trans) : bool domain Adjoints supported but are optional! range «create» TSFCore::LinearOp apply(in M_trans, in x : Vector, out y : Vector, in ...) apply(in M_trans, in X : MultiVector, out Y : MultiVector, in ...) TSFCore::MultiVector «create» VectorSpaces create Vectors and MultiVectors! applyOp(in op : RTOpT, inout ...) subView(in col_rng : Range1D) : MultiVector subView(in numCols : int, in cols[1..numCols] : int) : MultiVector Vector and MultiVector versions of apply(…)! 1 MultiVector subviews can be created! RTOpPack::RTOpT 1..* columns apply_op(inout ...) reduce_reduct_objs(inout ...) TSFCore::Vector applyOp(in op : RTOpT, inout ...) Only one vector method! TSFCore Details All interfaces are templated on Scalar type (support real and complex) Smart reference counted pointer class Teuchos::RefCountPtr<> used for all dynamic memory management Many operations have default implementations based on very few pure virtual methods RTOp operators (and wrapper functions) are provided for many common level1 vector and multi-vector operations Default implementation provided for MultiVector (MultiVectorCols) Default implementations provided for serial computation: VectorSpace (SerialVectorSpace), VectorSpaceFactory (SerialVectorSpaceFactory), Vector (SerialVector) AbstractLinAlgPack : MOOCHO Linear Algebra space_cols MatrixOp VectorSpace Mp_StM() Vp_StMtV() Mp_StMtM() dim create_member() : VectorMutable create_members(in num : int) : MultiVectorMutable is_compatible(in : VectorSpace) : bool space_rows Gc D MatrixOpNonsing space MultiVector MatrixSymOp apply_reduction(in op, in ..., inout reduct_obj) sub_view(in rows : Range1D, in cols : Range1D) : MultiVector Mp_StMtMtM() V_InvMtV() M_StInvMtM() M_StMtInvM() 1 C MatrixSymOpNonsing 0..1 is_pos_def : bool Vector «creates» apply_reduction(in op, in ..., inout reduct_obj) sub_view(in : Range1D) : Vector M_StMtInvMtM() MultiVectorMutable apply_transformation(in op, in ..., inout reduct_obj) sub_view(in rows : Range1D, in cols : Range1D) : MultiVectorMutable VectorMutable apply_transformation(in op, in ..., inout reduct_obj) sub_view(in : Range1D) : VectorMutable BasisSystem update_basis(in Gc, out C, out D, out ...) P_var «create» Permutation BasisSystemPerm set_basis(in Gc, in Px, in Pc, out C, out D) select_basis(inout Gc, out Qx, out Qc, out C, out D) P_equ Example ANA : Linear Conjugate Gradient Solver Multi-vector Conjugate-Gradient Solver : Single Iteration template<class Scalar> void CGSolver<Scalar>::doIteration( const LinearOp<Scalar> &M, ETransp opM_notrans ,ETransp opM_trans, MultiVector<Scalar> *X, Scalar a ,const LinearOp<Scalar> *M_tilde_inv ,ETransp opM_tilde_inv_notrans, ETransp opM_tilde_inv_trans ) const { const Index m = currNumSystems_; int j; if( M_tilde_inv ) M_tilde_inv->apply( opM_tilde_inv_notrans, *R_, &*Z_ ); else assign( &*Z_, *R_ ); dot( *Z_, *R_, &rho_[0] ); if( currIteration_ == 1 ) { assign( &*P_, *Z_ ); } else { for(j=0;j<m;++j) beta_[j] = rho_[j]/rho_old_[j]; update( *Z_, &beta_[0], 1.0, &*P_ ); } M.apply( opM_notrans, *P_, &*Q_ ); dot( *P_, *Q_, &gamma_[0] ); for(j=0;j<m;++j) alpha_[j] = rho_[j]/gamma_[j]; update( &alpha_[0], +1.0, *P_, X ) update( &alpha_[0], -1.0, *Q_, &*R_ ); } TSFCore::Nonlin : Interfaces to Nonlinear Problems State equations NonlinearProblem Function evaluations: Auxiliary variables State variables Response functions NonlinearProblemFirstOrder (nonsingular) State Jacobian evaluations : Auxiliary Jacobian evaluations : • • • • • • Supported Areas NAND optimization SAND optimization Nonlinear equations Multidisciplinary analysis Stability analysis / continuation SFE TSFCore SAND Reports Get most recent copy at: Trilinos/doc/TSFCore Summary & Conclusions MOOCHO • MOOCHO is framework/library for large-scale NLP • MOOCHO currently supports several active-set and interior-point SQPrelated methods • MOOCHO can be adapted to the application • MOOCHO is fully scalable TSFCore • Minimal but efficient interface to linear algebra implementations • Trilinos (LGPL) standard for abstract interfaces for linear algebra – Block linear solvers (Belos) – Block eigenvalue solvers (Anasazi) • Used in SPMD, client/server, master/slave etc. • Example numerical algorithms: – NLP optimization (through MOOCHO) – Nonlinear equation solvers (through NOX) – Time domain decomposition (Heinkenshloss)