MeshKit  1.0
IASolverEven.hpp
Go to the documentation of this file.
00001 // IASolver.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_IASOLVEREVEN_HP
00007 #define MESHKIT_IA_IASOLVEREVEN_HP
00008 
00009 #include "meshkit/IAData.hpp"
00010 #include "meshkit/IPData.hpp"
00011 #include "meshkit/IASolution.hpp"
00012 
00013 #include <map> //todo move this data to an auxillary class
00014 
00015 namespace MeshKit 
00016 {
00017 
00018 class IANlp;
00019 class IAMINlp;
00020 class IPData;
00021 
00022 class IASolverEven: public IASolution 
00023 {
00024 public:
00026   IASolverEven(const IAData *ia_data, const IASolution *int_solution);
00027 
00029   virtual ~IASolverEven();
00030   
00031   bool solve();
00032   // return true if solved; false if not solved (e.g. infeasible)
00033 
00034 private:  
00035   // hide untrusted default methods
00037   //  IA_NLP();
00038   IASolverEven(const IASolverEven&);
00039   IASolverEven& operator=(const IASolverEven&);
00041   
00042  
00043   // print x that is currently non-integer
00044   void report_one_constraint(const int i, const int b); 
00045   // print x that was non-integer, but was constrained to be integer and resolved
00046   void report_one_non_integer(const int i, const int b); 
00047   
00048   bool calculate_rounding_value(const int i, double &obj_increase, int &y_int );
00049   // y_int = what x[i] should be rounded to
00050   // obj_increase is the increase in the objective function value if x[i] changes to y_int
00051   
00052   bool calculate_sumeven_value(const int i, double &obj_increase, int &y_int );
00053   // assumes x[i] is already an integer
00054   // y_int = what x[i] should be rounded to, in order to help satisfy a sum-even constraint
00055   // obj_increase is the increase in the objective function value if x[i] changes to y_int
00056 
00057 
00058   void constrain_integer(const int i_nonint, const int x_bound);
00059   bool find_one_non_integer(int &i_nonint, int &x_bound);
00060   bool constrain_one_non_integer(int &i, int &b);
00061   
00062   // value of objective function increase if x is rounded to the next farther integer, and index of x
00063   typedef std::pair<int,int> RoundingX;  // x index, x bound
00064   typedef std::multimap<double, RoundingX> RoundingMap; // obj value increase, roundingX
00065   bool find_many_non_integer(RoundingMap &rounding_map);
00066   bool constrain_many_non_integer(RoundingMap &rounding_map);
00067   void back_off(RoundingMap &rounding_map);
00068   void report_many_non_integer(RoundingMap &rounding_map);
00069 
00070   double distance_to_even(int i);
00071   
00072   // data
00073   const IAData *iaData;
00074   IPData ipData; // holds integer solution
00075   IAMINlp *myianlp;
00076 
00077   void cleanup(); // clean up memory management of the above pointers.
00078   
00079   // debug
00080   const bool debugging;
00081   void print_solution(IPData &ip_data);
00082   
00083 };
00084 
00085 } // namespace MeshKit
00086 
00087 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines