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 CONSTRAINT_H
|
|
|
|
#define CONSTRAINT_H
|
|
|
|
|
|
|
|
#include "OperatorType.h"
|
2008-02-25 04:54:05 +03:00
|
|
|
#include "Variable.h"
|
2008-03-11 00:43:32 +03:00
|
|
|
#include "Summand.h"
|
2008-02-06 13:51:44 +03:00
|
|
|
|
2009-10-16 16:13:07 +04:00
|
|
|
#include <File.h>
|
2008-02-06 13:51:44 +03:00
|
|
|
#include <List.h>
|
|
|
|
#include <String.h>
|
|
|
|
#include <SupportDefs.h>
|
2008-02-25 04:54:05 +03:00
|
|
|
#include <math.h>
|
2008-02-06 13:51:44 +03: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();
|
2009-10-16 16:13:07 +04:00
|
|
|
|
2008-03-11 00:43:32 +03:00
|
|
|
BList* LeftSide();
|
|
|
|
void SetLeftSide(BList* summands);
|
|
|
|
void UpdateLeftSide();
|
|
|
|
void SetLeftSide(double coeff1, Variable* var1);
|
|
|
|
void SetLeftSide(double coeff1, Variable* var1,
|
2008-02-25 04:54:05 +03:00
|
|
|
double coeff2, Variable* var2);
|
2008-03-11 00:43:32 +03:00
|
|
|
void SetLeftSide(double coeff1, Variable* var1,
|
2008-02-25 04:54:05 +03:00
|
|
|
double coeff2, Variable* var2,
|
|
|
|
double coeff3, Variable* var3);
|
2008-03-11 00:43:32 +03:00
|
|
|
void SetLeftSide(double coeff1, Variable* var1,
|
2008-02-25 04:54:05 +03:00
|
|
|
double coeff2, Variable* var2,
|
|
|
|
double coeff3, Variable* var3,
|
|
|
|
double coeff4, Variable* var4);
|
2008-03-11 00:43:32 +03:00
|
|
|
|
2008-02-25 04:54:05 +03:00
|
|
|
OperatorType Op();
|
|
|
|
void SetOp(OperatorType value);
|
2009-10-16 16:13:07 +04:00
|
|
|
double RightSide() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetRightSide(double value);
|
2009-10-16 16:13:07 +04:00
|
|
|
double PenaltyNeg() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetPenaltyNeg(double value);
|
2009-10-16 16:13:07 +04:00
|
|
|
double PenaltyPos() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetPenaltyPos(double value);
|
2008-03-11 00:43:32 +03:00
|
|
|
|
2009-10-16 16:13:07 +04:00
|
|
|
const char* Label();
|
|
|
|
void SetLabel(const char* label);
|
|
|
|
|
|
|
|
void WriteXML(BFile* file);
|
|
|
|
|
2008-02-25 04:54:05 +03:00
|
|
|
Variable* DNeg() const;
|
|
|
|
Variable* DPos() const;
|
2009-10-16 16:13:07 +04:00
|
|
|
|
|
|
|
void SetOwner(void* owner);
|
|
|
|
void* Owner() const;
|
|
|
|
|
|
|
|
bool IsValid();
|
|
|
|
void Invalidate();
|
|
|
|
|
|
|
|
BString* ToBString();
|
|
|
|
const char* ToString();
|
|
|
|
|
2008-02-25 04:54:05 +03:00
|
|
|
~Constraint();
|
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
protected:
|
2008-03-11 00:43:32 +03:00
|
|
|
Constraint(LinearSpec* ls, BList* summands,
|
2008-02-25 04:54:05 +03:00
|
|
|
OperatorType op, double rightSide,
|
|
|
|
double penaltyNeg, double penaltyPos);
|
2008-02-06 13:51:44 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
LinearSpec* fLS;
|
2008-03-11 00:43:32 +03:00
|
|
|
BList* fLeftSide;
|
2008-02-25 04:54:05 +03:00
|
|
|
OperatorType fOp;
|
2008-02-06 13:51:44 +03:00
|
|
|
double fRightSide;
|
2008-03-11 00:43:32 +03:00
|
|
|
Summand* fDNegObjSummand;
|
|
|
|
Summand* fDPosObjSummand;
|
2009-10-16 16:13:07 +04:00
|
|
|
void* fOwner;
|
|
|
|
char* fLabel;
|
|
|
|
|
|
|
|
bool fIsValid;
|
2008-02-06 13:51:44 +03:00
|
|
|
|
|
|
|
public:
|
2008-02-25 04:54:05 +03:00
|
|
|
friend class LinearSpec;
|
2008-02-06 13:51:44 +03:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace LinearProgramming
|
|
|
|
|
|
|
|
using LinearProgramming::Constraint;
|
|
|
|
|
|
|
|
#endif // CONSTRAINT_H
|
2008-03-11 00:43:32 +03:00
|
|
|
|