MOOCHO Version of the Day
NLPInterfacePack_ExampleNLPBanded.hpp
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00005 //                  Copyright (2003) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #ifndef EXAMPLE_NLP_BANDED_H
00043 #define EXAMPLE_NLP_BANDED_H
00044 
00045 
00046 #include "NLPInterfacePack_NLPSerialPreprocessExplJac.hpp"
00047 
00048 
00049 namespace NLPInterfacePack {
00050 
00051 
00159 class ExampleNLPBanded
00160   : public NLPSerialPreprocessExplJac
00161 {
00162 public:
00163 
00166 
00171   ExampleNLPBanded(
00172     size_type     nD
00173     ,size_type    nI
00174     ,size_type    bw                = 1
00175     ,size_type    mU                = 0
00176     ,size_type    mI                = 0
00177     ,value_type   xo                = 0.1
00178     ,value_type   xDl               = -NLP::infinite_bound()
00179     ,value_type   xDu               = +NLP::infinite_bound()
00180     ,value_type   xIl               = -NLP::infinite_bound()
00181     ,value_type   xIu               = +NLP::infinite_bound()
00182     ,value_type   hl                = -NLP::infinite_bound()
00183     ,value_type   hu                = +NLP::infinite_bound()
00184     ,bool         nlp_selects_basis = false
00185     ,value_type   diag_scal         = 10.0
00186     ,value_type   diag_vary         = 1.0
00187     ,bool         sym_basis         = false
00188     ,value_type   f_offset          = 0.0
00189     ,value_type   co                = 0.0
00190     ,bool         ignore_constraints = false
00191     );
00192 
00194 
00195   // Todo: Add methods to manipulate bounds and co ...
00196 
00199   
00200   // ToDo: Add these ...
00201 
00203 
00206 
00208   void initialize(bool test_setup);
00210   bool is_initialized() const;
00212   value_type max_var_bounds_viol() const;
00213 
00215 
00218   
00220   bool nlp_selects_basis() const;
00221 
00223 
00224 protected:
00225 
00228 
00230   bool imp_nlp_has_changed() const;
00232   size_type imp_n_orig() const;
00234   size_type imp_m_orig() const;
00236   size_type imp_mI_orig() const;
00238   const DVectorSlice imp_xinit_orig() const;
00240   bool imp_has_var_bounds() const;
00242   const DVectorSlice imp_xl_orig() const;
00244   const DVectorSlice imp_xu_orig() const;
00246   const DVectorSlice imp_hl_orig() const;
00248   const DVectorSlice imp_hu_orig() const;
00250   void imp_calc_f_orig(
00251     const DVectorSlice            &x_full
00252     ,bool                        newx
00253     ,const ZeroOrderInfoSerial   &zero_order_info
00254     ) const;
00256   void imp_calc_c_orig(
00257     const DVectorSlice            &x_full
00258     ,bool                        newx
00259     ,const ZeroOrderInfoSerial   &zero_order_info
00260     ) const;
00262   void imp_calc_h_orig(
00263     const DVectorSlice            &x_full
00264     ,bool                        newx
00265     ,const ZeroOrderInfoSerial   &zero_order_info
00266     ) const;
00268   void imp_calc_Gf_orig(
00269     const DVectorSlice            &x_full
00270     ,bool                        newx
00271     ,const ObjGradInfoSerial     &obj_grad_info
00272     ) const;
00274   bool imp_get_next_basis(
00275     IVector      *var_perm_full
00276     ,IVector     *equ_perm_full
00277     ,size_type   *rank_full
00278     ,size_type   *rank
00279     );
00281   void imp_report_orig_final_solution(
00282     const DVectorSlice      &x_orig
00283     ,const DVectorSlice     *lambda_orig
00284     ,const DVectorSlice     *lambdaI_orig
00285     ,const DVectorSlice     *nu_orig
00286     ,bool                  is_optimal
00287     ) const;
00288 
00290   
00293 
00295   size_type imp_Gc_nz_orig() const;
00297   size_type imp_Gh_nz_orig() const;
00299   void imp_calc_Gc_orig(
00300     const DVectorSlice& x_full, bool newx
00301     , const FirstOrderExplInfo& first_order_expl_info
00302     ) const;
00304   void imp_calc_Gh_orig(
00305     const DVectorSlice& x_full, bool newx
00306     , const FirstOrderExplInfo& first_order_expl_info
00307     ) const;
00308 
00310 
00311 private:
00312 
00313   // /////////////////////////////////////////
00314   // Private types
00315 
00316   // /////////////////////////////////////////
00317   // Private data members
00318 
00319   bool         is_initialized_;
00320 
00321   bool         nlp_selects_basis_;
00322   bool         basis_selection_was_given_;
00323 
00324   bool         has_var_bounds_;
00325 
00326   value_type   f_offset_;
00327 
00328   size_type    nD_;
00329   size_type    nI_;
00330   size_type    bw_;
00331   size_type    mU_;
00332   size_type    mI_;
00333 
00334   bool         ignore_constraints_;
00335 
00336   size_type    Gc_orig_nz_;
00337   size_type    Gh_orig_nz_;
00338 
00339   DVector      xinit_orig_;
00340   DVector      xl_orig_;
00341   DVector      xu_orig_;
00342   DVector      hl_orig_;
00343   DVector      hu_orig_;
00344 
00345   DVector      co_orig_;
00346 
00347   mutable bool c_orig_updated_;
00348 
00349   value_type   diag_scal_;
00350   value_type   diag_vary_;
00351   value_type   fu_;
00352 
00353   // /////////////////////////////////////////
00354   // Private member functions
00355 
00357   void assert_is_initialized() const;
00358 
00360   void inform_new_point(bool newx) const;
00361 
00362   // Not defined and not to be called
00363   ExampleNLPBanded();
00364   ExampleNLPBanded(const ExampleNLPBanded&);
00365   ExampleNLPBanded& operator=(const ExampleNLPBanded&);
00366 
00367 
00368 };  // end class ExampleNLPBanded
00369 
00370 
00371 } // end namespace NLPInterfacePack
00372 
00373 
00374 #endif  // EXAMPLE_NLP_BANDED_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends