/home/coin/SVN-release/OS-2.0.0/Bonmin/src/Interfaces/Ampl/BonAmplTMINLP.hpp

Go to the documentation of this file.
00001 // (C) Copyright International Business Machines Corporation and
00002 // Carnegie Mellon University 2004, 2007
00003 //
00004 // All Rights Reserved.
00005 // This code is published under the Common Public License.
00006 //
00007 // Authors :
00008 // Carl D. Laird, Carnegie Mellon University,
00009 // Andreas Waechter, International Business Machines Corporation
00010 // Pierre Bonami, Carnegie Mellon University,
00011 //
00012 // Date : 12/01/2004
00013 
00014 #ifndef __IPAMPLTMINLP_HPP__
00015 #define __IPAMPLTMINLP_HPP__
00016 
00017 #include "BonTMINLP.hpp"
00018 #include "IpSmartPtr.hpp"
00019 #include "CoinPackedMatrix.hpp"
00020 #include "OsiCuts.hpp"
00021 #include "BonRegisteredOptions.hpp"
00022 
00023 /* non Ipopt forward declaration */
00024 struct ASL_pfgh;
00025 struct SufDecl;
00026 struct SufDesc;
00027 
00028 
00029 // Declarations, so that we don't have to include the Ipopt AMPL headers
00030 namespace Ipopt
00031 {
00032   class AmplSuffixHandler;
00033   class AmplOptionsList;
00034   class AmplTNLP;
00035 }
00036 
00037 namespace Bonmin
00038 {
00039 
00045   class AmplTMINLP : public TMINLP
00046   {
00047   public:
00051     AmplTMINLP(const SmartPtr<const Journalist>& jnlst,
00052         const SmartPtr<Bonmin::RegisteredOptions> roptions,
00053         const SmartPtr<OptionsList> options,
00054         char**& argv,
00055         AmplSuffixHandler* suffix_handler = NULL,
00056         const std::string& appName = "bonmin",
00057         std::string* nl_file_content = NULL);
00058 
00059     virtual void Initialize(const SmartPtr<const Journalist>& jnlst,
00060         const SmartPtr<Bonmin::RegisteredOptions> roptions,
00061         const SmartPtr<OptionsList> options,
00062         char**& argv,
00063         AmplSuffixHandler* suffix_handler =NULL,
00064         const std::string& appName = "bonmin",
00065         std::string* nl_file_content = NULL);
00066 
00068     void read_priorities();
00069 
00071     void read_sos();
00072 
00074     void read_convexities();
00075 
00077     void read_obj_suffixes();
00078 
00080     AmplTMINLP();
00081 
00082     virtual AmplTMINLP * createEmpty()
00083     {
00084       AmplTMINLP * tminlp = new AmplTMINLP;
00085       return tminlp;
00086     }
00087 
00089     virtual ~AmplTMINLP();
00091 
00093     const ASL_pfgh* AmplSolverObject() const;
00094 
00095 
00101     virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
00102         Index& nnz_h_lag,
00103         TNLP::IndexStyleEnum& index_style);
00104 
00106     virtual bool get_variables_types(Index n, VariableType* var_types);
00107 
00109     virtual bool get_variables_linearity(Index n, Ipopt::TNLP::LinearityType * var_types);
00110 
00113     virtual bool get_constraints_linearity(Index m,
00114         Ipopt::TNLP::LinearityType* const_types);
00115 
00117     virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
00118         Index m, Number* g_l, Number* g_u);
00119 
00122     virtual bool get_starting_point(Index n, bool init_x, Number* x,
00123         bool init_z, Number* z_L, Number* z_U,
00124         Index m, bool init_lambda, Number* lambda);
00125 
00127     virtual bool eval_f(Index n, const Number* x, bool new_x,
00128         Number& obj_value);
00129 
00132     virtual bool eval_grad_f(Index n, const Number* x, bool new_x,
00133         Number* grad_f);
00134 
00136     virtual bool eval_g(Index n, const Number* x, bool new_x,
00137         Index m, Number* g);
00138 
00142     virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
00143         Index m, Index nele_jac, Index* iRow,
00144         Index *jCol, Number* values);
00145 
00149     virtual bool eval_h(Index n, const Number* x, bool new_x,
00150         Number obj_factor, Index m, const Number* lambda,
00151         bool new_lambda, Index nele_hess, Index* iRow,
00152         Index* jCol, Number* values);
00153 
00155     virtual bool eval_gi(Index n, const Number* x, bool new_x,
00156         Index i, Number& gi);
00159     virtual bool eval_grad_gi(Index n, const Number* x, bool new_x,
00160         Index i, Index& nele_grad_gi, Index* jCol,
00161         Number* values);
00163 
00166     virtual void finalize_solution(TMINLP::SolverReturn status,
00167         Index n, const Number* x, Number obj_value);
00168 
00169     void write_solution(const std::string & message, const Number *x_sol);
00171 
00175     void write_solution_file(const std::string& message) const;
00177 
00178 
00179     virtual const BranchingInfo * branchingInfo() const
00180     {
00181       return &branch_;
00182     }
00183 
00184     virtual const SosInfo * sosConstraints() const
00185     {
00186       return &sos_;
00187     }
00188 
00189     virtual const PerturbInfo* perturbInfo() const
00190     {
00191       return &perturb_info_;
00192     }
00193 
00197     virtual void fillApplicationOptions(AmplOptionsList* amplOptList)
00198     {}
00200 
00201 
00203     virtual void getLinearPartOfObjective(double * obj);
00204 
00205 
00207     void fillAmplOptionList(AmplOptionsList* amplOptList);
00208 
00210     virtual bool hasUpperBoundingObjective()
00211     {
00212       return upperBoundingObj_ != -1;
00213     }
00214 
00217     virtual bool eval_upper_bound_f(Index n, const Number* x,
00218         Number& obj_value);
00219 
00221     virtual bool get_constraint_convexities(int m, TMINLP::Convexity * constraints_convexities)const
00222     {
00223       if (constraintsConvexities_ != NULL) {
00224         CoinCopyN(constraintsConvexities_, m, constraints_convexities);
00225       }
00226       else {
00227         CoinFillN(constraints_convexities, m, TMINLP::Convex);
00228       }
00229       return true;
00230     }
00232     virtual bool get_number_nonconvex(int & number_non_conv, int & number_concave) const
00233     {
00234       number_non_conv = numberNonConvex_;
00235       number_concave = numberSimpleConcave_;
00236       return true;
00237     }
00239     virtual bool get_constraint_convexities(int number_non_conv, MarkedNonConvex * non_convexes) const
00240     {
00241       assert(number_non_conv == numberNonConvex_);
00242       CoinCopyN( nonConvexConstraintsAndRelaxations_, number_non_conv, non_convexes);
00243       return true;
00244     }
00246     virtual bool get_simple_concave_constraints(int number_concave, SimpleConcaveConstraint * simple_concave) const
00247     {
00248       assert(number_concave == numberSimpleConcave_);
00249       CoinCopyN(simpleConcaves_, numberSimpleConcave_, simple_concave);
00250       return true;
00251     }
00252 
00254     virtual bool hasLinearObjective()
00255     {
00256       return hasLinearObjective_;
00257     }
00258   private:
00267 
00269     AmplTMINLP(const AmplTMINLP&);
00270 
00272     void operator=(const AmplTMINLP&);
00274 
00275     std::string appName_;
00276 
00278     int upperBoundingObj_;
00280     AmplTNLP* ampl_tnlp_;
00282     SmartPtr<const Journalist> jnlst_;
00283 
00285     BranchingInfo branch_;
00287     SosInfo sos_;
00289     PerturbInfo perturb_info_;
00291     SmartPtr<AmplSuffixHandler> suffix_handler_;
00292 
00294     TMINLP::Convexity * constraintsConvexities_;
00295 
00297     int numberNonConvex_;
00299     MarkedNonConvex * nonConvexConstraintsAndRelaxations_;
00301     int numberSimpleConcave_;
00303     SimpleConcaveConstraint * simpleConcaves_;
00304 
00306     bool hasLinearObjective_;
00307 
00309     int writeAmplSolFile_;
00310   };
00311 } // namespace Ipopt
00312 
00313 #endif
00314 

Generated on Mon Aug 3 03:02:18 2009 by  doxygen 1.4.7