2008-02-25 04:54:05 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2007-2008, Christof Lutteroth, lutteroth@cs.auckland.ac.nz
|
|
|
|
* Copyright 2007-2008, James Kim, jkim202@ec.auckland.ac.nz
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
#ifndef VARIABLE_H
|
|
|
|
#define VARIABLE_H
|
|
|
|
|
2009-10-16 16:13:07 +04:00
|
|
|
#include <File.h>
|
2008-02-06 13:51:44 +03:00
|
|
|
#include <SupportDefs.h>
|
2009-10-16 16:13:07 +04:00
|
|
|
#include <List.h>
|
2008-02-06 13:51:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
namespace LinearProgramming {
|
|
|
|
|
|
|
|
class Constraint;
|
|
|
|
class LinearSpec;
|
2009-10-16 16:13:07 +04:00
|
|
|
class Summand;
|
2008-02-06 13:51:44 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Contains minimum and maximum values.
|
|
|
|
*/
|
|
|
|
class Variable {
|
|
|
|
|
|
|
|
public:
|
2009-12-06 16:14:45 +03:00
|
|
|
int32 Index() const;
|
2008-02-06 13:51:44 +03:00
|
|
|
LinearSpec* LS() const;
|
|
|
|
double Value() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetValue(double value);
|
2008-02-06 13:51:44 +03:00
|
|
|
double Min() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetMin(double min);
|
2008-02-06 13:51:44 +03:00
|
|
|
double Max() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetMax(double max);
|
|
|
|
void SetRange(double min, double max);
|
2009-10-16 16:13:07 +04:00
|
|
|
|
|
|
|
const char* Label();
|
|
|
|
void SetLabel(const char* label);
|
2009-12-06 16:14:45 +03:00
|
|
|
|
|
|
|
operator BString() const;
|
|
|
|
void GetString(BString& string) const;
|
2009-10-16 16:13:07 +04:00
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
Constraint* IsEqual(Variable* var);
|
|
|
|
Constraint* IsSmallerOrEqual(Variable* var);
|
2009-10-16 16:13:07 +04:00
|
|
|
Constraint* IsGreaterOrEqual(Variable* var);
|
|
|
|
|
|
|
|
Constraint* IsEqual(Variable* var,
|
|
|
|
double penaltyNeg, double penaltyPos);
|
|
|
|
Constraint* IsSmallerOrEqual(Variable* var,
|
|
|
|
double penaltyNeg, double penaltyPos);
|
|
|
|
Constraint* IsGreaterOrEqual(Variable* var,
|
|
|
|
double penaltyNeg, double penaltyPos);
|
|
|
|
|
|
|
|
bool IsValid();
|
|
|
|
void Invalidate();
|
|
|
|
|
|
|
|
virtual ~Variable();
|
2008-02-06 13:51:44 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Variable(LinearSpec* ls);
|
|
|
|
|
|
|
|
private:
|
|
|
|
LinearSpec* fLS;
|
2009-10-16 16:13:07 +04:00
|
|
|
BList* fUsingSummands; // All Summands that link to this Variable
|
2008-02-06 13:51:44 +03:00
|
|
|
double fValue;
|
|
|
|
double fMin;
|
|
|
|
double fMax;
|
2009-10-16 16:13:07 +04:00
|
|
|
char* fLabel;
|
|
|
|
|
|
|
|
bool fIsValid;
|
2008-02-06 13:51:44 +03:00
|
|
|
|
|
|
|
public:
|
2009-10-16 16:13:07 +04:00
|
|
|
friend class LinearSpec;
|
|
|
|
friend class Constraint;
|
|
|
|
friend class Summand;
|
2008-02-06 13:51:44 +03:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace LinearProgramming
|
|
|
|
|
|
|
|
using LinearProgramming::Variable;
|
|
|
|
|
|
|
|
#endif // VARIABLE_H
|