MeshKit  1.0
IASolverBend.hpp
Go to the documentation of this file.
00001 // IASolverBend.hpp
00002 // Interval Assignment for Meshkit
00003 // Meshkit calls this class function to find the intervals
00004 // this class calls underlying solvers
00005 //
00006 #ifndef MESHKIT_IA_IASOLVERBEND_HP
00007 #define MESHKIT_IA_IASOLVERBEND_HP
00008 
00009 #include <map>
00010 
00011 #include "IASolverToolInt.hpp"
00012 #include "IPBend.hpp"
00013 #include "IAWeights.hpp"
00014 // #include "IPData.hpp"
00015 // #include "IABendNlp.hpp"
00016 
00017 namespace MeshKit {
00018   
00019 class IAData;
00020 class IASolution;
00021 class IABendNlp;
00022 class IPData;
00023 
00024 class IASolverBend : public IASolverToolInt
00025 {
00026 public:
00028   IASolverBend(const IAData * ia_data_ptr, IASolution *relaxed_solution_ptr, const bool set_silent = true);
00029 
00031   virtual ~IASolverBend();
00032   
00033   bool solve();
00034   // return true if solved; false if not solved (e.g. infeasible)
00035 
00036 private:  
00037   // hide untrusted default methods
00039   IASolverBend(const IASolverBend&);
00040   IASolverBend& operator=(const IASolverBend&);
00042   
00043   // if true, then sum-even constraints are enforced, otherwise ignored.
00044   // must remain the same during a call to solve() = ipopt as it changes the 
00045   // problem size and structure.
00046   bool evenConstraintsActive;
00047   
00048   // debug
00049   const bool silent;
00050   const bool debugging;    
00051   
00052   // top level
00053 
00054   // set initial ip bends from relaxed solution
00055   void initialize_ip_bends();
00056 
00057   // update them based on fractional solutions, large deltas
00058   bool update_ip_bends();
00059   
00060   // return the weight (slope) between xbig and xlit given g
00061   double raw_weight( const double g, double xlit, double xbig);
00062   
00063   // combine tilts for the same exact interval into a much larger tilt, to try to address the problem more quickly. Basically doubling the tilt rather than adding to it.
00064   void merge_tilts(IPBend::TiltVec &tilts);
00065   
00066   // actually change the weight of the delta based on the tilt
00067   void tilt_weight(const IPBend::TiltVec &tilts, const int tilt_direction, const double g, const double xlit, const double xbig, const int delta_direction, double &w);
00068   
00069   // call the nlp solver
00070   bool solve_nlp();
00071 
00072   void cleanup();
00073 
00074   // round solution to nearest integer
00075   // if its feasible, then replace current solution and return true
00076   bool round_solution();
00077   
00078   IABendNlp *myianlp;
00079 
00080   IPBendData bendData;
00081 
00082   // weight index for deltas start at delta_i_start - num_variables   
00083   IAWeights weights;
00084 
00085   // convert IPBends to IAWeights
00086   void add_bend_weights(unsigned int i);
00087   // void add_bend_sum_weights(unsigned int i, const double factor);
00088 
00089   // utility
00090   double f_x_value( double I_i, double x_i ) const;
00091   double fpow(double f) const;
00092   double get_f_xl(int i) const; // obj function value at xl
00093   double get_f_xh(int i) const; // obj function value at xh
00094 
00095   
00096 };
00097 
00098 } // namespace MeshKit 
00099 
00100 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines