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
|
|
|
|
|
2010-10-06 00:15:55 +04:00
|
|
|
|
2010-09-20 08:52:30 +04:00
|
|
|
#include <ObjectList.h>
|
2010-09-20 08:34:38 +04:00
|
|
|
#include <String.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:
|
2010-09-20 08:34:38 +04:00
|
|
|
int32 Index() const;
|
2011-02-08 12:01:11 +03:00
|
|
|
int32 GlobalIndex() const;
|
2010-09-20 08:34:38 +04:00
|
|
|
LinearSpec* LS() const;
|
|
|
|
double Value() const;
|
|
|
|
void SetValue(double value);
|
|
|
|
double Min() const;
|
|
|
|
void SetMin(double min);
|
|
|
|
double Max() const;
|
|
|
|
void SetMax(double max);
|
|
|
|
void SetRange(double min, double max);
|
|
|
|
|
|
|
|
const char* Label();
|
|
|
|
void SetLabel(const char* label);
|
|
|
|
|
2011-03-14 03:24:12 +03:00
|
|
|
BString ToString() const;
|
2010-09-20 08:34:38 +04:00
|
|
|
|
|
|
|
Constraint* IsEqual(Variable* var);
|
|
|
|
Constraint* IsSmallerOrEqual(Variable* var);
|
|
|
|
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();
|
2010-10-06 00:15:55 +04:00
|
|
|
//! Dangerous the variable don't belong to the LinearSpec anymore,
|
|
|
|
//! delete it yourself!
|
2010-09-20 08:34:38 +04:00
|
|
|
void Invalidate();
|
|
|
|
|
2011-03-14 03:24:12 +03:00
|
|
|
virtual ~Variable();
|
2008-02-06 13:51:44 +03:00
|
|
|
|
|
|
|
protected:
|
2010-09-20 08:34:38 +04:00
|
|
|
Variable(LinearSpec* ls);
|
2008-02-06 13:51:44 +03:00
|
|
|
|
2011-01-27 01:06:02 +03:00
|
|
|
//! returns the ref count
|
|
|
|
int32 AddReference();
|
|
|
|
int32 RemoveReference();
|
2008-02-06 13:51:44 +03:00
|
|
|
private:
|
2010-09-20 08:34:38 +04:00
|
|
|
LinearSpec* fLS;
|
2010-10-06 00:15:55 +04:00
|
|
|
|
2010-09-20 08:34:38 +04:00
|
|
|
double fValue;
|
|
|
|
double fMin;
|
|
|
|
double fMax;
|
|
|
|
BString fLabel;
|
|
|
|
|
|
|
|
bool fIsValid;
|
2008-02-06 13:51:44 +03:00
|
|
|
|
2011-01-27 01:06:02 +03:00
|
|
|
int32 fReferenceCount;
|
2008-02-06 13:51:44 +03:00
|
|
|
public:
|
2009-10-16 16:13:07 +04:00
|
|
|
friend class LinearSpec;
|
2008-02-06 13:51:44 +03:00
|
|
|
};
|
|
|
|
|
2010-09-20 10:26:32 +04:00
|
|
|
|
|
|
|
typedef BObjectList<Variable> VariableList;
|
|
|
|
|
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
} // namespace LinearProgramming
|
|
|
|
|
|
|
|
using LinearProgramming::Variable;
|
2010-09-20 10:26:32 +04:00
|
|
|
using LinearProgramming::VariableList;
|
2008-02-06 13:51:44 +03:00
|
|
|
|
|
|
|
#endif // VARIABLE_H
|