MeshKit  1.0
IAIntCosNlp.hpp
Go to the documentation of this file.
00001 // IAIntCosNlp.hpp
00002 // Interval Assignment for Meshkit
00003 //
00004 // use a cosine-"wave" function as a constraint, so that the only feasible solutions are integer
00005 // use a cosine-"wave" with twice the period to enforce the evenality constraints
00006 
00007 #ifndef MESHKIT_IA_IAINTCOSNLP_HP
00008 #define MESHKIT_IA_IAINTCOSNLP_HP
00009 
00010 #include "meshkit/IAIntWaveNlp.hpp"
00011 
00012 #include <math.h>
00013 #include <limits.h>
00014 
00015 namespace MeshKit 
00016 {
00017 
00018 class IAIntCosNlp : public IAIntWaveNlp
00019 {
00020   // first set of functions required by TNLP
00021 public:
00023   IAIntCosNlp(const IAData *data_ptr, const IPData *ip_data_ptr, IASolution *solution_ptr,
00024                const bool set_silent = true) :
00025     IAIntWaveNlp(data_ptr, ip_data_ptr, solution_ptr, set_silent),
00026     PI( 3.1415926535897932384626433832795 )
00027   {}
00028 
00030   virtual ~IAIntCosNlp() {}
00031 
00032 protected:
00033   
00034   const double PI;
00035   // or PI( 2. * acos(0.0) )
00036   
00037   virtual double eval_g_int_x( const double x )
00038   {
00039     return cos( 2. * PI * x );
00040   }
00041   virtual double eval_g_int_s( const double s )
00042   {
00043     return cos( PI * s );
00044   }
00045   virtual double eval_jac_int_x( const double x )
00046   {
00047     return -2. * PI * sin( 2. * PI * x );    
00048   }
00049   virtual double eval_jac_int_s( const double s )
00050   {
00051     return -PI * sin( PI * s );
00052   }
00053   virtual double eval_hess_int_x( const double x )
00054   {
00055     return -4. * PI * PI * cos( 2. * PI * x );
00056   }
00057   virtual double eval_hess_int_s( const double s )
00058   {
00059     return -PI * PI * cos( PI * s );    
00060   }
00061   
00062 };
00063 
00064 
00065 } // namespace MeshKit
00066 
00067 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines