mirror of
https://review.haiku-os.org/haiku
synced 2025-01-22 22:34:48 +01:00
0306945545
* copyright headers for the files of the libraries linprog and alm * new class Summand for representing summands in a linear constraint * merged class SoftConstraint into class Constraint; Constraint now supports both soft and hard constraint functionality * new AddConstraint methods in class LinearSpec for directly setting constraints with 1 to 4 summands * code cleanups by using aforementioned AddConstraint methods * a new very simple test application for alm * some style corrections git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24108 a95241bf-73f2-0310-859d-f6bbb57e9c96
85 lines
2.0 KiB
C++
85 lines
2.0 KiB
C++
/*
|
|
* 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.
|
|
*/
|
|
|
|
#ifndef CONSTRAINT_H
|
|
#define CONSTRAINT_H
|
|
|
|
#include "OperatorType.h"
|
|
#include "Variable.h"
|
|
#include "ObjFunctionSummand.h"
|
|
|
|
#include <List.h>
|
|
#include <String.h>
|
|
#include <SupportDefs.h>
|
|
#include <math.h>
|
|
|
|
|
|
namespace LinearProgramming {
|
|
|
|
class LinearSpec;
|
|
|
|
/**
|
|
* Hard linear constraint, i.e. one that must be satisfied.
|
|
* May render a specification infeasible.
|
|
*/
|
|
class Constraint {
|
|
|
|
public:
|
|
int32 Index();
|
|
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);
|
|
double RightSide();
|
|
void SetRightSide(double value);
|
|
double PenaltyNeg();
|
|
void SetPenaltyNeg(double value);
|
|
double PenaltyPos();
|
|
void SetPenaltyPos(double value);
|
|
Variable* DNeg() const;
|
|
Variable* DPos() const;
|
|
|
|
BString ToString();
|
|
~Constraint();
|
|
|
|
protected:
|
|
Constraint(LinearSpec* ls, BList* summands,
|
|
OperatorType op, double rightSide,
|
|
double penaltyNeg, double penaltyPos);
|
|
|
|
private:
|
|
LinearSpec* fLS;
|
|
BList* fSummands;
|
|
OperatorType fOp;
|
|
double fRightSide;
|
|
Variable* fDNeg;
|
|
Variable* fDPos;
|
|
ObjFunctionSummand* fDNegSummand;
|
|
ObjFunctionSummand* fDPosSummand;
|
|
|
|
void _UpdateLeftSide();
|
|
|
|
public:
|
|
friend class LinearSpec;
|
|
|
|
};
|
|
|
|
} // namespace LinearProgramming
|
|
|
|
using LinearProgramming::Constraint;
|
|
|
|
#endif // CONSTRAINT_H
|