2008-02-25 01:54:05 +00: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 10:51:44 +00:00
|
|
|
#ifndef CONSTRAINT_H
|
|
|
|
#define CONSTRAINT_H
|
|
|
|
|
|
|
|
#include "OperatorType.h"
|
2008-02-25 01:54:05 +00:00
|
|
|
#include "Variable.h"
|
|
|
|
#include "ObjFunctionSummand.h"
|
2008-02-06 10:51:44 +00:00
|
|
|
|
|
|
|
#include <List.h>
|
|
|
|
#include <String.h>
|
|
|
|
#include <SupportDefs.h>
|
2008-02-25 01:54:05 +00:00
|
|
|
#include <math.h>
|
2008-02-06 10:51:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace LinearProgramming {
|
|
|
|
|
|
|
|
class LinearSpec;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hard linear constraint, i.e. one that must be satisfied.
|
|
|
|
* May render a specification infeasible.
|
|
|
|
*/
|
|
|
|
class Constraint {
|
|
|
|
|
|
|
|
public:
|
|
|
|
int32 Index();
|
2008-02-25 01:54:05 +00:00
|
|
|
BList* Summands();
|
|
|
|
void ChangeLeftSide(BList* summands);
|
|
|
|
void ChangeLeftSide(double coeff1, Variable* var1);
|
|
|
|
void ChangeLeftSide(double coeff1, Variable* var1,
|
|
|
|
double coeff2, Variable* var2);
|
|
|
|
void ChangeLeftSide(double coeff1, Variable* var1,
|
|
|
|
double coeff2, Variable* var2,
|
|
|
|
double coeff3, Variable* var3);
|
|
|
|
void ChangeLeftSide(double coeff1, Variable* var1,
|
|
|
|
double coeff2, Variable* var2,
|
|
|
|
double coeff3, Variable* var3,
|
|
|
|
double coeff4, Variable* var4);
|
|
|
|
OperatorType Op();
|
|
|
|
void SetOp(OperatorType value);
|
2008-02-06 10:51:44 +00:00
|
|
|
double RightSide();
|
2008-02-25 01:54:05 +00:00
|
|
|
void SetRightSide(double value);
|
|
|
|
double PenaltyNeg();
|
|
|
|
void SetPenaltyNeg(double value);
|
|
|
|
double PenaltyPos();
|
|
|
|
void SetPenaltyPos(double value);
|
|
|
|
Variable* DNeg() const;
|
|
|
|
Variable* DPos() const;
|
2008-02-06 10:51:44 +00:00
|
|
|
|
2008-02-25 01:54:05 +00:00
|
|
|
BString ToString();
|
|
|
|
~Constraint();
|
|
|
|
|
2008-02-06 10:51:44 +00:00
|
|
|
protected:
|
2008-02-25 01:54:05 +00:00
|
|
|
Constraint(LinearSpec* ls, BList* summands,
|
|
|
|
OperatorType op, double rightSide,
|
|
|
|
double penaltyNeg, double penaltyPos);
|
2008-02-06 10:51:44 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
LinearSpec* fLS;
|
2008-02-25 01:54:05 +00:00
|
|
|
BList* fSummands;
|
|
|
|
OperatorType fOp;
|
2008-02-06 10:51:44 +00:00
|
|
|
double fRightSide;
|
2008-02-25 01:54:05 +00:00
|
|
|
Variable* fDNeg;
|
|
|
|
Variable* fDPos;
|
|
|
|
ObjFunctionSummand* fDNegSummand;
|
|
|
|
ObjFunctionSummand* fDPosSummand;
|
|
|
|
|
|
|
|
void _UpdateLeftSide();
|
2008-02-06 10:51:44 +00:00
|
|
|
|
|
|
|
public:
|
2008-02-25 01:54:05 +00:00
|
|
|
friend class LinearSpec;
|
2008-02-06 10:51:44 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace LinearProgramming
|
|
|
|
|
|
|
|
using LinearProgramming::Constraint;
|
|
|
|
|
|
|
|
#endif // CONSTRAINT_H
|