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 {
|
2009-12-06 16:14:45 +03:00
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
class LinearSpec;
|
|
|
|
|
|
|
|
/**
|
2009-12-06 16:14:45 +03:00
|
|
|
* Hard linear constraint, i.e. one that must be satisfied.
|
2008-02-06 13:51:44 +03:00
|
|
|
* May render a specification infeasible.
|
|
|
|
*/
|
|
|
|
class Constraint {
|
2009-12-06 16:14:45 +03:00
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
public:
|
2009-12-06 16:14:45 +03:00
|
|
|
int32 Index() const;
|
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);
|
2009-12-06 16:14:45 +03:00
|
|
|
void SetLeftSide(double coeff1, Variable* var1,
|
2008-02-25 04:54:05 +03:00
|
|
|
double coeff2, Variable* var2);
|
2009-12-06 16:14:45 +03:00
|
|
|
void SetLeftSide(double coeff1, Variable* var1,
|
2008-02-25 04:54:05 +03:00
|
|
|
double coeff2, Variable* var2,
|
|
|
|
double coeff3, Variable* var3);
|
2009-12-06 16:14:45 +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();
|
|
|
|
|
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-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
|
|
|
|