00001 #ifndef __CONSTRAINT_H 00002 #define __CONSTRAINT_H 00003 00004 #include "Constant.h" 00005 #include "LagrangianParam.h" 00006 #include <string> 00007 00008 class Model; 00009 class Expr; 00010 00012 00017 class Constraint 00018 { 00019 Model * model; 00020 VarId id; 00021 00022 public: 00024 Constraint():model(0),id(0) {}; 00025 00026 Constraint(Model & _m,VarId _id); 00027 Constraint( const Model & _m,VarId _id); 00028 00030 Constraint( const Constraint & _c) 00031 { 00032 model = _c.model; 00033 id = _c.id; 00034 } 00035 00036 Constraint operator= ( const Constraint & _c) 00037 { 00038 model = _c.model; 00039 id = _c.id; 00040 return *this; 00041 } 00042 00046 VarId GetId() const { return id;} 00047 00051 Model * GetModel() const { return model;} 00052 00053 bool Relax( float lagrangianValue = -Infinity); 00054 00055 LagrangianParam GetLagrangianParam() const; 00056 00057 void Rename( const std::string & name ); 00058 00059 void AddExpr(const Expr &); 00060 00061 Expr GetExpr(bool secondMember = false) const; 00062 00063 Expr GetRelaxedExpr(bool secondMember = false) const; 00064 00065 void SetSecondMember(float); 00066 00067 float GetSecondMember() const; 00068 00069 float GetValue() const; 00070 00071 ~Constraint() {} 00072 }; 00073 00074 inline bool operator==( const Constraint & c1, const Constraint & c2) 00075 { 00076 return c1.GetModel() == c2.GetModel() && c1.GetId() == c2.GetId(); 00077 } 00078 00079 #ifdef COMPILE_FOR_PYTHON 00080 void export_Constraint(); 00081 #endif 00082 00083 #endif