Add system_time to the Jamfile, missed in hrev49598.
[haiku.git] / headers / libs / linprog / Constraint.h
blob0a4d5b27fbaba3fe1f9c6b1f0c682d32410c3e16
1 /*
2 * Copyright 2007-2008, Christof Lutteroth, lutteroth@cs.auckland.ac.nz
3 * Copyright 2007-2008, James Kim, jkim202@ec.auckland.ac.nz
4 * Distributed under the terms of the MIT License.
5 */
6 #ifndef CONSTRAINT_H
7 #define CONSTRAINT_H
9 #include <ObjectList.h>
10 #include <String.h>
11 #include <SupportDefs.h>
13 #include "LinearProgrammingTypes.h"
14 #include "Summand.h"
15 #include "Variable.h"
18 namespace LinearProgramming {
20 class LinearSpec;
22 /**
23 * Hard linear constraint, i.e.&nbsp;one that must be satisfied.
24 * May render a specification infeasible.
26 class Constraint {
27 public:
28 Constraint();
29 /*! Creates a soft copy of the constraint which is not connected
30 to the solver. Variables are not copied or cloned but the soft copy
31 has its own summand list with summands. */
32 Constraint(Constraint* constraint);
34 int32 Index() const;
36 SummandList* LeftSide();
38 bool SetLeftSide(SummandList* summands,
39 bool deleteOldSummands);
41 bool SetLeftSide(double coeff1, Variable* var1);
42 bool SetLeftSide(double coeff1, Variable* var1,
43 double coeff2, Variable* var2);
44 bool SetLeftSide(double coeff1, Variable* var1,
45 double coeff2, Variable* var2,
46 double coeff3, Variable* var3);
47 bool SetLeftSide(double coeff1, Variable* var1,
48 double coeff2, Variable* var2,
49 double coeff3, Variable* var3,
50 double coeff4, Variable* var4);
52 OperatorType Op();
53 void SetOp(OperatorType value);
54 double RightSide() const;
55 void SetRightSide(double value);
56 double PenaltyNeg() const;
57 void SetPenaltyNeg(double value);
58 double PenaltyPos() const;
59 void SetPenaltyPos(double value);
61 const char* Label();
62 void SetLabel(const char* label);
64 bool IsValid();
65 void Invalidate();
67 BString ToString() const;
68 void PrintToStream();
70 ~Constraint();
72 protected:
73 Constraint(LinearSpec* ls,
74 SummandList* summands, OperatorType op,
75 double rightSide,
76 double penaltyNeg = -1,
77 double penaltyPos = -1);
79 private:
80 LinearSpec* fLS;
81 SummandList* fLeftSide;
82 OperatorType fOp;
83 double fRightSide;
85 double fPenaltyNeg;
86 double fPenaltyPos;
87 BString fLabel;
89 public:
90 friend class LinearSpec;
94 typedef BObjectList<Constraint> ConstraintList;
97 } // namespace LinearProgramming
99 using LinearProgramming::Constraint;
100 using LinearProgramming::ConstraintList;
102 #endif // CONSTRAINT_H