MeshKit  1.0
IPBend.hpp
Go to the documentation of this file.
00001 // IPBend.hpp
00002 // Interval Assignment Data for Meshkit
00003 //
00004 // Data for defining an objective function that is piecewise linear and bends at integer points
00005 //
00006 
00007 #ifndef MESHKIT_IA_IPBEND_HP
00008 #define MESHKIT_IA_IPBEND_HP
00009 
00010 #include <vector>
00011 #include <limits>
00012 
00013 namespace MeshKit 
00014 {
00015 
00016 class IPBend
00017 {
00018 public:
00019   // index of delta, magnitude of tilt = weight multiplier
00020   // note tilt is applied to that delta and all subsequent ones
00021   typedef std::pair<unsigned int, double> IPTilt;
00022   typedef std::vector< IPTilt > TiltVec;
00023   
00025   IPBend() :
00026     deltaIStart(0), numDeltaPlus(1), numDeltaMinus(1), 
00027     plusTilts(), minusTilts()  // usually these vecs are empty
00028   {}
00029   
00031   virtual ~IPBend() {}
00032   
00033   // index i of x[i] or sum-even constraint i is implicitly defined by position in IPBendVec
00034 
00035   int xl; // x value if all deltas are zero
00036   
00037   int deltaIStart; // index of the first delta variables in the Nlp
00038 
00039   // delta0 is always defined, one of them
00040   int numDeltaPlus; // number of plus deltas defined
00041   int numDeltaMinus; // number of minus deltas defined
00042   int num_deltas() const 
00043     {return numDeltaPlus + numDeltaMinus; } 
00044   
00045   // x = xl + sum ( deltas_plus ) - sum (deltas_minus );
00046   // delta_plus[k] for k < numDeltaPlus + 1 is in [0,1], last is [0,infinity]
00047   
00048   static int num_deltas_max() 
00049   { return std::numeric_limits<int>::max()/2 - 2; }
00050   
00051   // sorted tilts, for x > g and x < g
00052   TiltVec plusTilts, minusTilts; 
00053   
00054 };
00055 
00056 typedef std::vector< IPBend > IPBendVec;
00057   
00058 class IPBendData
00059 {
00060 public:
00061   IPBendVec bendVec;
00062   int numSumVars;
00063   int sumVarStart;
00064   double maxActiveVarWeight;
00065 };
00066   
00067 // default constructors for object and its members OK
00068 // inline IPData::IPData() {} 
00069 
00070 // default destructor OK
00071 
00072 } // namespace MeshKit 
00073 
00074 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines