MeshKit  1.0
IARoundingFar3StepNlp.hpp
Go to the documentation of this file.
00001 // IARoundingFarNnl.hpp
00002 // Interval Assignment for Meshkit
00003 //
00004 // ipopt mixed-integer solution
00005 // The idea is the optimal solution will be an integer one, if one exists
00006 // Define some region around the relaxed solution and search for an integer solution
00007 //
00008 
00009 #ifndef MESHKIT_IA_IAROUNDINGFARP3STEPNLP_HP
00010 #define MESHKIT_IA_IAROUNDINGFARP3STEPNLP_HP
00011 
00012 class IAData;
00013 class IPData;
00014 class IASolution;
00015 #include "meshkit/IANlp.hpp"
00016 #include "meshkit/IAWeights.hpp"
00017 
00018 #include "IpTNLP.hpp"
00019 
00020 class IARoundingFar3StepNlp : public TNLP
00021 {
00022 public:
00024   IARoundingFar3StepNlp(const IAData *data_ptr, const IPData *ip_data_ptr, IASolution *solution_ptr); 
00025 
00027   virtual ~IARoundingFar3StepNlp();
00028   
00032   virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
00033                             Index& nnz_h_lag, IndexStyleEnum& index_style);
00034 
00036   virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
00037                                Index m, Number* g_l, Number* g_u);
00038 
00040   virtual bool get_starting_point(Index n, bool init_x, Number* x_init,
00041                                   bool init_z, Number* z_L, Number* z_U,
00042                                   Index m, bool init_lambda,
00043                                   Number* lambda);
00044 
00046   virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
00047 
00049   virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
00050 
00052   virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
00053 
00058   virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
00059                           Index m, Index nele_jac, Index* iRow, Index *jCol,
00060                           Number* values);
00061 
00066   virtual bool eval_h(Index n, const Number* x, bool new_x,
00067                       Number obj_factor, Index m, const Number* lambda,
00068                       bool new_lambda, Index nele_hess, Index* iRow,
00069                       Index* jCol, Number* values);
00070 
00072 
00076   virtual void finalize_solution(SolverReturn status,
00077                                  Index n, const Number* x, const Number* z_L, const Number* z_U,
00078                                  Index m, const Number* g, const Number* lambda,
00079                                  Number obj_value,
00080                                  const IpoptData* ip_data,
00081                                  IpoptCalculatedQuantities* ip_cq);
00083 
00084 
00085 private:  
00086   // hide untrusted default methods
00088   //  IA_NLP();
00089   IARoundingFar3StepNlp();
00090   IARoundingFar3StepNlp(const IARoundingFar3StepNlp&);
00091   IARoundingFar3StepNlp& operator=(const IARoundingFar3StepNlp&);
00093   
00094   // input data
00095   const IAData *data;
00096   const IPData *ipData;
00097   IAWeights h0; // h0, as weights in IARoundingNLP
00098   IAWeights hp; // h+
00099   IAWeights hm; // h-
00100   // model variables indices
00101   const int x01_start;
00102   const int xp_start;
00103   const int xm_start;
00104   const int sum_even_start;
00105   const int x_constraint_start;
00106   const int problem_n, problem_m, base_n, base_m; // Index?
00107 
00108   // f' is discontinuous at integer values
00109   // Two choices: 
00110   // ZERO. give f'' as constant, zero, which is correct but hides the discontinuities
00111   // ROUNDED. give f'' as an average value, which might help the solver ..
00112   enum HessOptions {ZERO, ROUNDED};
00113   const HessOptions hess_option;
00114 
00115   // solution data
00116   IASolution *solution;
00117   
00118   
00119   // implemented using an overlay over an IANlp
00120   IANlp baseNlp;  
00121   
00122   const bool debugging;
00123   const bool verbose; // verbose debugging
00124 
00125   // utility
00126   double f_x_value( double I_i, double x_i ) const;
00127   double get_f_xl(int i) const; // obj function value at xl
00128   double get_f_xh(int i) const; // obj function value at xh
00129 };
00130 
00131 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines