1 /* 2 * Copyright 2007-2008, Christof Lutteroth, lutteroth@cs.auckland.ac.nz 3 * Copyright 2007-2008, James Kim, jkim202@ec.auckland.ac.nz 4 * Distributed under the terms of the MIT License. 5 */ 6 7 #ifndef VARIABLE_H 8 #define VARIABLE_H 9 10 #include <File.h> 11 #include <SupportDefs.h> 12 #include <List.h> 13 14 15 namespace LinearProgramming { 16 17 class Constraint; 18 class LinearSpec; 19 class Summand; 20 21 /** 22 * Contains minimum and maximum values. 23 */ 24 class Variable { 25 26 public: 27 int32 Index(); 28 LinearSpec* LS() const; 29 double Value() const; 30 void SetValue(double value); 31 double Min() const; 32 void SetMin(double min); 33 double Max() const; 34 void SetMax(double max); 35 void SetRange(double min, double max); 36 37 const char* Label(); 38 void SetLabel(const char* label); 39 40 BString* ToBString(); 41 const char* ToString(); 42 43 Constraint* IsEqual(Variable* var); 44 Constraint* IsSmallerOrEqual(Variable* var); 45 Constraint* IsGreaterOrEqual(Variable* var); 46 47 Constraint* IsEqual(Variable* var, 48 double penaltyNeg, double penaltyPos); 49 Constraint* IsSmallerOrEqual(Variable* var, 50 double penaltyNeg, double penaltyPos); 51 Constraint* IsGreaterOrEqual(Variable* var, 52 double penaltyNeg, double penaltyPos); 53 54 bool IsValid(); 55 void Invalidate(); 56 57 virtual ~Variable(); 58 59 protected: 60 Variable(LinearSpec* ls); 61 62 private: 63 LinearSpec* fLS; 64 BList* fUsingSummands; // All Summands that link to this Variable 65 double fValue; 66 double fMin; 67 double fMax; 68 char* fLabel; 69 70 bool fIsValid; 71 72 public: 73 friend class LinearSpec; 74 friend class Constraint; 75 friend class Summand; 76 77 }; 78 79 } // namespace LinearProgramming 80 81 using LinearProgramming::Variable; 82 83 #endif // VARIABLE_H 84