00001
00035 #ifndef ABA_VARIABLE_H
00036 #define ABA_VARIABLE_H
00037 #include <iostream>
00038 using namespace std;
00039
00040 #include "abacus/convar.h"
00041 #include "abacus/fsvarstat.h"
00042 #include "abacus/vartype.h"
00043
00044 class ABA_MASTER;
00045 class ABA_SUB;
00046 class ABA_VARTYPE;
00047 class ABA_COLUMN;
00048 template<class BaseType, class CoType> class ABA_ACTIVE;
00049
00050 #ifdef ABACUS_PARALLEL
00051 #include "abacus/message.h"
00052 #endif
00053
00054
00055 class ABA_VARIABLE : public ABA_CONVAR {
00056 public:
00057
00083 ABA_VARIABLE(ABA_MASTER *master, const ABA_SUB *sub,
00084 bool dynamic, bool local,
00085 double obj, double lBound, double uBound,
00086 ABA_VARTYPE::TYPE type);
00087
00089 virtual ~ABA_VARIABLE();
00090 #ifdef ABACUS_PARALLEL
00091
00097 ABA_VARIABLE(ABA_MASTER *master, ABA_MESSAGE &msg);
00098
00108 virtual void pack(ABA_MESSAGE &msg) const;
00109 #endif
00110
00111
00114 ABA_VARTYPE::TYPE varType() const;
00115
00119 bool discrete();
00120
00124 bool binary();
00125
00129 bool integer();
00130
00133 virtual double obj();
00134
00137 double uBound() const;
00138
00143 void uBound(double newValue);
00144
00147 double lBound() const;
00148
00154 void lBound(double newValue);
00155
00161 ABA_FSVARSTAT *fsVarStat();
00162
00172 virtual bool valid(ABA_SUB *sub);
00173
00187 virtual int genColumn(ABA_ACTIVE<ABA_CONSTRAINT, ABA_VARIABLE> *actCon,
00188 ABA_COLUMN &col);
00189
00200 virtual double coeff(ABA_CONSTRAINT *con);
00201
00212 virtual bool violated(double rc) const;
00213
00231 virtual bool violated(ABA_ACTIVE<ABA_CONSTRAINT, ABA_VARIABLE> *constraints,
00232 double *y, double *slack = 0);
00233
00247 virtual double redCost(ABA_ACTIVE<ABA_CONSTRAINT, ABA_VARIABLE> *actCon,
00248 double *y);
00249
00264 virtual bool useful(ABA_ACTIVE<ABA_CONSTRAINT, ABA_VARIABLE> *actCon,
00265 double *y,
00266 double lpVal);
00267
00275 void printCol(ostream &out,
00276 ABA_ACTIVE<ABA_CONSTRAINT, ABA_VARIABLE> *constraints);
00277
00278 protected:
00279
00282 ABA_FSVARSTAT fsVarStat_;
00283
00286 double obj_;
00287
00290 double lBound_;
00291
00294 double uBound_;
00295
00298 ABA_VARTYPE type_;
00299 };
00300
00301
00302 inline ABA_VARTYPE::TYPE ABA_VARIABLE::varType() const
00303 {
00304 return type_.type();
00305 }
00306
00307 inline bool ABA_VARIABLE::discrete()
00308 {
00309 return type_.discrete();
00310 }
00311
00312 inline bool ABA_VARIABLE::binary()
00313 {
00314 return type_.binary();
00315 }
00316
00317 inline bool ABA_VARIABLE::integer()
00318 {
00319 return type_.integer();
00320 }
00321
00322 inline double ABA_VARIABLE::lBound() const
00323 {
00324 return lBound_;
00325 }
00326
00327 inline void ABA_VARIABLE::lBound(double newBound)
00328 {
00329 lBound_ = newBound;
00330 }
00331
00332 inline double ABA_VARIABLE::uBound() const
00333 {
00334 return uBound_;
00335 }
00336
00337 inline void ABA_VARIABLE::uBound(double newBound)
00338 {
00339 uBound_ = newBound;
00340 }
00341
00342 inline ABA_FSVARSTAT *ABA_VARIABLE::fsVarStat()
00343 {
00344 return &fsVarStat_;
00345 }
00346
00347
00348 #endif // ABA_VARIABLE_H
00349