* Applied patch by Hong Yul Yang to update linprog.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33609 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-10-16 12:13:07 +00:00
parent 98b4079944
commit 676ef01ba7
8 changed files with 511 additions and 90 deletions
+24 -6
View File
@@ -11,6 +11,7 @@
#include "Variable.h"
#include "Summand.h"
#include <File.h>
#include <List.h>
#include <String.h>
#include <SupportDefs.h>
@@ -29,7 +30,7 @@ class Constraint {
public:
int32 Index();
BList* LeftSide();
void SetLeftSide(BList* summands);
void UpdateLeftSide();
@@ -46,17 +47,30 @@ public:
OperatorType Op();
void SetOp(OperatorType value);
double RightSide();
double RightSide() const;
void SetRightSide(double value);
double PenaltyNeg();
double PenaltyNeg() const;
void SetPenaltyNeg(double value);
double PenaltyPos();
double PenaltyPos() const;
void SetPenaltyPos(double value);
const char* Label();
void SetLabel(const char* label);
void WriteXML(BFile* file);
Variable* DNeg() const;
Variable* DPos() const;
BString ToString();
void SetOwner(void* owner);
void* Owner() const;
bool IsValid();
void Invalidate();
BString* ToBString();
const char* ToString();
~Constraint();
protected:
@@ -71,6 +85,10 @@ private:
double fRightSide;
Summand* fDNegObjSummand;
Summand* fDPosObjSummand;
void* fOwner;
char* fLabel;
bool fIsValid;
public:
friend class LinearSpec;
+5 -1
View File
@@ -18,6 +18,7 @@
#include "lp_lib.h"
#include <List.h>
#include <String.h>
#include <OS.h>
#include <SupportDefs.h>
#include <math.h>
@@ -37,7 +38,7 @@ class LinearSpec {
public:
LinearSpec();
~LinearSpec();
virtual ~LinearSpec();
Variable* AddVariable();
@@ -100,6 +101,9 @@ public:
double ObjectiveValue() const;
double SolvingTime() const;
BString* ToBString();
const char* ToString();
protected:
int32 fCountColumns;
+1
View File
@@ -29,6 +29,7 @@ public:
private:
double fCoeff;
Variable* fVar;
bool fUsedInPenaltyFunction; //not set yet
};
+30 -6
View File
@@ -7,13 +7,16 @@
#ifndef VARIABLE_H
#define VARIABLE_H
#include <File.h>
#include <SupportDefs.h>
#include <List.h>
namespace LinearProgramming {
class Constraint;
class LinearSpec;
class Summand;
/**
* Contains minimum and maximum values.
@@ -23,7 +26,6 @@ class Variable {
public:
int32 Index();
LinearSpec* LS() const;
void SetLS(LinearSpec* value);
double Value() const;
void SetValue(double value);
double Min() const;
@@ -31,24 +33,46 @@ public:
double Max() const;
void SetMax(double max);
void SetRange(double min, double max);
//~ string ToString();
const char* Label();
void SetLabel(const char* label);
BString* ToBString();
const char* ToString();
Constraint* IsEqual(Variable* var);
Constraint* IsSmallerOrEqual(Variable* var);
Constraint* IsGreaterorEqual(Variable* var);
Constraint* IsGreaterOrEqual(Variable* var);
Constraint* IsEqual(Variable* var,
double penaltyNeg, double penaltyPos);
Constraint* IsSmallerOrEqual(Variable* var,
double penaltyNeg, double penaltyPos);
Constraint* IsGreaterOrEqual(Variable* var,
double penaltyNeg, double penaltyPos);
bool IsValid();
void Invalidate();
virtual ~Variable();
protected:
Variable(LinearSpec* ls);
~Variable();
private:
LinearSpec* fLS;
BList* fUsingSummands; // All Summands that link to this Variable
double fValue;
double fMin;
double fMax;
char* fLabel;
bool fIsValid;
public:
friend class LinearSpec;
friend class Constraint;
friend class LinearSpec;
friend class Constraint;
friend class Summand;
};