MeshKit  1.0
IASolverToolInt.hpp
Go to the documentation of this file.
00001 // IASolverToolInt.hpp
00002 // Interval Assignment for Meshkit
00003 // common integer problem tools
00004 
00005 #ifndef MESHKIT_IA_IASOLVERTOOLINT_HP
00006 #define MESHKIT_IA_IASOLVERTOOLINT_HP
00007 
00008 #include "meshkit/IASolverTool.hpp"
00009 
00010 namespace MeshKit {
00011   
00012 class IPData;
00013 class IAWeights;
00014 
00015 class IASolverToolInt : public IASolverTool 
00016 {
00017   // no data or inheritance, except debugging flags
00018 public:
00020   IASolverToolInt();
00021   IASolverToolInt(const bool debugging_set);
00022   IASolverToolInt(const IAData *ia_data, IASolution *ia_solution, bool debugging_set = false);
00023 
00025   virtual ~IASolverToolInt();
00026   
00027   // member get/set
00028   IPData *ip_data() {return ipData;}
00029   void ip_data(IPData *set_data) {ipData = set_data;}
00030   virtual void set_debug(const bool debugging_set) {debuggingToolInt = debugging_set; IASolverTool::set_debug(debugging_set);}
00031 
00032   // tools
00033   // round solution in place
00034   void round_solution();
00035   
00036   // standardize epsilon for determining if x is an integer solution
00037   bool solution_is_integer(const bool print_non_integer = false);
00038   
00039   // measures how far above or below floor( relaxed solution ) x is, in whole integers and fractional
00040   void get_frac( double x, int &integer, double &frac) const;
00041   double get_xl( int i ) const; // floor of relaxed solution
00042   double get_xh( int i ) const; // xl + 1
00043   
00044   double get_km( int i, double x ) const;  // how much bigger x is than xh, or zero if less
00045   double get_kp( int i, double x ) const;  // xl - x, or zero if negative
00046   void get_km( int i, double x, int &km_integer, double &km_frac ) const; // split into integer and fractional part
00047   void get_kp( int i, double x, int &kp_integer, double &kp_frac ) const;
00048   
00049   // randomize the value of weights for the non-integer values
00050   // return true if any weights were changed
00051   bool randomize_weights_of_non_int(IAWeights* weights, const double rand_factor);
00052   
00053 protected:  
00054   
00055   IPData *ipData;
00056 
00057   // debugging
00058   bool debuggingToolInt; 
00059   
00060 };
00061 
00062 } // namespace MeshKit 
00063 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines