#ifndef CCONSTRAINT_H #define CCONSTRAINT_H /** @author Antoine Rozenknop */ #include "indices.h" #include "lecture.h" #include #include #include using std::vector ; using std::string ; /** * type intervalle pour les contraintes 21 */ struct CIntervalle { week_t start ; week_t end ; }; class CPlan ; /** * classe de base des contraintes 13 à 21 */ class CConstraint { public: CConstraint() {} virtual int getType() = 0 ; void lire ( int index ) ; virtual void lire_contrainte_typee() = 0 ; virtual double concerne( week_t, CPlan * ) = 0; virtual double borne( week_t ) { return 1; } constraint_t m ; // index lu std::vector m_C ; // clique /** * C() : set of powerplants submitted to this constraint * @return */ inline const std::vector & C() { return m_C; } }; class CConstraint13 : public CConstraint { public: CConstraint13() {} virtual int getType() { return 13; } virtual void lire_contrainte_typee(); virtual double concerne( week_t, CPlan * ) { return false ;} protected: week_t m_TO; week_t m_TA; public: powerplants2_t i; campaign_t k; /** * TO() : first possible week of the start of an outage (i.e. decoupling) * @return */ inline const week_t & TO() { return m_TO; } /** * TA() : last possible week of the start of an outage (i.e. decoupling) * @return */ inline const week_t & TA() { return m_TA; } static const week_t inconnu ; // contrainte inexistante dans les données static const week_t indefini ; // -1 dans les données. Voir CType2::corrigeTO. }; class CConstraint14 : public CConstraint { public: CConstraint14() {} virtual int getType() { return 14; } virtual void lire_contrainte_typee(); virtual double concerne( week_t, CPlan * ); protected: wlen_t m_Se; public: /** * Se() : duration in weeks of minimum authorized spacing. A negative value will be interpreted * as maximum authorized overlapping * @return */ inline const wlen_t & Se(){ return m_Se; } }; class CConstraint15 : public CConstraint14 { public: CConstraint15() {} virtual int getType() { return 15; } virtual void lire_contrainte_typee(); virtual double concerne( week_t, CPlan * ); private: week_t m_ID; week_t m_IF; public: /** * ID : week of the start of the specific period * @return */ inline const week_t & ID() { return m_ID; } /** * IF : week of the end of the specific period * @return */ inline const week_t & IF() { return m_IF; } }; class CConstraint16 : public CConstraint14 { public: CConstraint16() {} virtual double concerne( week_t, CPlan * ); virtual int getType() { return 16; } }; class CConstraint17 : public CConstraint14 { public: CConstraint17() {} virtual double concerne( week_t, CPlan * ); virtual int getType() { return 17; } }; class CConstraint18 : public CConstraint14 { public: CConstraint18() {} virtual double concerne( week_t, CPlan * ); virtual int getType() { return 18; } }; class CConstraint19 : public CConstraint { public: CConstraint19() {} virtual int getType() { return 19; } void lire_contrainte_typee(); virtual double concerne( week_t, CPlan * ); virtual double borne( week_t ) ; private: double m_Q ; std::map m_Cinv ; std::vector > m_L ; std::vector > m_TU ; public: /** * Q : available quantity of resource (the quantity of a resource used for every outage is equal * to one) * @return */ inline const double & Q() { return m_Q; } /** * C() : set of powerplants submitted to this constraint * @return */ inline const std::vector & C() { return m_C; } /** * L(i,k) : number of weeks after the start of the outage (i,k) that defines the start of the period * of use of a certain resource. L(i,k) is included in the interval [0 , DA(i,k)[. * @param i powerplant index * @param k cycle index * @return */ inline const int & L (powerplants2_t i, campaign_t k) { return m_L[ m_Cinv[i] ][k] ; } /** * TU(i,k) : time of use of resource (superior to 1), in weeks, that includes the length of possible * use of this resource as well as a period of possible unavailability between two successive * utilizations of this resource. * @param i i powerplant index * @param k cycle index * @return */ inline const int & TU(powerplants2_t i, campaign_t k) { return m_TU[ m_Cinv[i] ][k] ; } }; class CConstraint20 : public CConstraint { public: CConstraint20() {} virtual int getType() { return 20; } void lire_contrainte_typee(); virtual double concerne( week_t, CPlan * ); virtual double borne( week_t ); private: week_t m_h ; int m_N ; public: /** * week of the constraint * @return */ inline const week_t & h() { return m_h; } /** * C() : set of powerplants submitted to this constraint * @return */ inline const std::vector & C() { return m_C; } /** * N : a maximum number of outages in parallel during the week h() * @return */ inline const int & N() { return m_N; } }; class CConstraint21 : public CConstraint { public: CConstraint21() {} virtual int getType() { return 21; } void lire_contrainte_typee(); virtual double concerne( week_t, CPlan * ); virtual double borne( week_t ); private: CIntervalle m_IT ; double m_IMAX; public: /** * C() : set of powerplants submitted to this constraint * @return */ inline const std::vector & C() { return m_C; } /** * IT() : a time period in weeks * @return */ inline const CIntervalle & IT() { return m_IT; } /** * IMAX() : bound on maximum offline power capacity * @return */ inline const double & IMAX() { return m_IMAX; } }; #endif