AmplTMINLP.hpp

Go to the documentation of this file.
00001 // (C) Copyright International Business Machines Corporation and Carnegie Mellon University 2004
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // Authors :
00006 // Carl D. Laird, Carnegie Mellon University,
00007 // Andreas Waechter, International Business Machines Corporation
00008 // Pierre Bonami, Carnegie Mellon University,
00009 //
00010 // Date : 12/01/2004
00011 
00012 #ifndef __IPAMPLTMINLP_HPP__
00013 #define __IPAMPLTMINLP_HPP__
00014 
00015 #include "TMINLP.hpp"
00016 #include "IpSmartPtr.hpp"
00017 #include "CoinPackedMatrix.hpp"
00018 #include "OsiCuts.hpp"
00019 
00020 namespace Ipopt
00021 {
00022 
00023 
00024   // Declarations, so that we don't have to include the Ipopt AMPL headers
00025   class AmplTNLP;
00026   class AmplSuffixHandler;
00027   class AmplOptionsList;
00028 
00034   class AmplTMINLP : public TMINLP
00035   {
00036   public:
00040     AmplTMINLP(const SmartPtr<const Journalist>& jnlst,
00041         const SmartPtr<OptionsList> options,
00042         char**& argv,
00043         AmplSuffixHandler* suffix_handler = NULL,
00044         const std::string& appName = "bonmin",
00045         std::string* nl_file_content = NULL);
00046 
00047     virtual void Initialize(const SmartPtr<const Journalist>& jnlst,
00048         const SmartPtr<OptionsList> options,
00049         char**& argv,
00050         AmplSuffixHandler* suffix_handler =NULL,
00051         const std::string& appName = "bonmin",
00052         std::string* nl_file_content = NULL);
00053 
00055     void read_priorities();
00056 
00058     void read_sos();
00059 
00060     AmplTMINLP();
00061 
00062     virtual AmplTMINLP * createEmpty()
00063     {
00064       AmplTMINLP * tminlp = new AmplTMINLP;
00065       return tminlp;
00066     }
00067 
00069     virtual ~AmplTMINLP();
00071 
00077     virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
00078         Index& nnz_h_lag,
00079         TNLP::IndexStyleEnum& index_style);
00080 
00082     virtual bool get_var_types(Index n, VariableType* var_types);
00084     virtual bool get_constraints_types(Index n, ConstraintType* const_types);
00086     virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
00087         Index m, Number* g_l, Number* g_u);
00088 
00091     virtual bool get_starting_point(Index n, bool init_x, Number* x,
00092                                     bool init_z, Number* z_L, Number* z_U,
00093         Index m, bool init_lambda, Number* lambda);
00094 
00096     virtual bool eval_f(Index n, const Number* x, bool new_x,
00097         Number& obj_value);
00098 
00101     virtual bool eval_grad_f(Index n, const Number* x, bool new_x,
00102         Number* grad_f);
00103 
00105     virtual bool eval_g(Index n, const Number* x, bool new_x,
00106         Index m, Number* g);
00107 
00111     virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
00112         Index m, Index nele_jac, Index* iRow,
00113         Index *jCol, Number* values);
00114 
00118     virtual bool eval_h(Index n, const Number* x, bool new_x,
00119         Number obj_factor, Index m, const Number* lambda,
00120         bool new_lambda, Index nele_hess, Index* iRow,
00121         Index* jCol, Number* values);
00123 
00126     virtual void finalize_solution(SolverReturn status,
00127         Index n, const Number* x, Number obj_value) const ;
00128 
00129     void write_solution(const std::string & message, const Number *x_sol) const;
00131 
00135     void write_solution_file(const std::string& message, const Number * x) const;
00137 
00138    
00139     virtual const BranchingInfo * branchingInfo() const
00140     {
00141       return &branch_;
00142     } 
00143 
00144     virtual const SosInfo * sosConstraints() const
00145     {
00146       return &sos_;
00147     }
00148 
00152     virtual void fillApplicationOptions(AmplOptionsList* amplOptList)
00153     {}
00155 
00156 
00158     virtual void getLinearPartOfObjective(double * obj);
00160     SmartPtr<const Journalist> jnlst_;
00161 
00163     double obj_sign_;
00164 
00167     Index nz_h_full_; // number of nonzeros in the full_x hessian
00168     /* the rest of the problem size data is available easily through the ampl variables */
00170 
00174     Number* non_const_x_;
00175 
00177     Number* x_sol_;
00178     Number* z_L_sol_;
00179     Number* z_U_sol_;
00180     Number* g_sol_;
00181     Number* lambda_sol_;
00182     Number obj_sol_;
00184 
00190     bool objval_called_with_current_x_;
00194     bool conval_called_with_current_x_;
00196 
00197 
00199     bool internal_objval(Number& obj_val);
00200 
00202     bool internal_conval(Index m, Number* g=NULL);
00203 
00206     void apply_new_x(bool new_x, Index n, const Number* x);
00207 
00209     void fillAmplOptionList(AmplOptionsList* amplOptList);
00210 
00219 
00221     AmplTMINLP(const AmplTMINLP&);
00222 
00224     void operator=(const AmplTMINLP&);
00226 
00228     AmplTNLP* ampl_tnlp_;
00229 
00231     BranchingInfo branch_;
00233     SosInfo sos_;
00235     SmartPtr<AmplSuffixHandler> suffix_handler_;
00236   };
00237 } // namespace Ipopt
00238 
00239 #endif

Generated on Fri May 16 21:05:57 2008 for Bonmin by  doxygen 1.4.7