Simplify code and clean up.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38738 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b329767e2f
commit
43b24b87de
@ -3,7 +3,6 @@
|
||||
* Copyright 2007-2008, James Kim, jkim202@ec.auckland.ac.nz
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef SUMMAND_H
|
||||
#define SUMMAND_H
|
||||
|
||||
@ -17,20 +16,19 @@ class Variable;
|
||||
* A summand of a linear term.
|
||||
*/
|
||||
class Summand {
|
||||
|
||||
public:
|
||||
double Coeff();
|
||||
void SetCoeff(double coeff);
|
||||
Variable* Var();
|
||||
void SetVar(Variable* var);
|
||||
Summand(double coeff, Variable* var);
|
||||
~Summand();
|
||||
Summand(double coeff, Variable* var);
|
||||
~Summand();
|
||||
|
||||
double Coeff();
|
||||
void SetCoeff(double coeff);
|
||||
Variable* Var();
|
||||
void SetVar(Variable* var);
|
||||
|
||||
private:
|
||||
double fCoeff;
|
||||
Variable* fVar;
|
||||
bool fUsedInPenaltyFunction; //not set yet
|
||||
|
||||
double fCoeff;
|
||||
Variable* fVar;
|
||||
bool fUsedInPenaltyFunction; //not set yet
|
||||
};
|
||||
|
||||
} // namespace LinearProgramming
|
||||
|
@ -7,7 +7,7 @@
|
||||
#define VARIABLE_H
|
||||
|
||||
#include <File.h>
|
||||
#include <List.h>
|
||||
#include <ObjectList.h>
|
||||
#include <String.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
@ -60,7 +60,7 @@ protected:
|
||||
|
||||
private:
|
||||
LinearSpec* fLS;
|
||||
BList* fUsingSummands;
|
||||
BObjectList<Summand> fUsingSummands;
|
||||
// All Summands that link to this Variable
|
||||
double fValue;
|
||||
double fMin;
|
||||
|
@ -3,6 +3,7 @@ SubDir HAIKU_TOP src libs linprog ;
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
UseLibraryHeaders lp_solve linprog ;
|
||||
UsePrivateHeaders shared ;
|
||||
|
||||
SharedLibrary liblinprog.so :
|
||||
Constraint.cpp
|
||||
|
@ -62,7 +62,7 @@ Summand::SetVar(Variable* var)
|
||||
*/
|
||||
Summand::~Summand()
|
||||
{
|
||||
fVar->fUsingSummands->RemoveItem(this);
|
||||
fVar->fUsingSummands.RemoveItem(this);
|
||||
}
|
||||
|
||||
|
||||
@ -74,7 +74,6 @@ Summand::Summand(double coeff, Variable* var)
|
||||
fCoeff = coeff;
|
||||
fVar = var;
|
||||
fUsedInPenaltyFunction = false;
|
||||
fVar->fUsingSummands->AddItem(this);
|
||||
|
||||
fVar->fUsingSummands.AddItem(this);
|
||||
}
|
||||
|
||||
|
@ -97,11 +97,7 @@ Variable::Min() const
|
||||
void
|
||||
Variable::SetMin(double min)
|
||||
{
|
||||
if (!fIsValid)
|
||||
return;
|
||||
|
||||
fMin = min;
|
||||
set_bounds(fLS->fLP, this->Index(), fMin, fMax);
|
||||
SetRange(min, fMax);
|
||||
}
|
||||
|
||||
|
||||
@ -125,11 +121,7 @@ Variable::Max() const
|
||||
void
|
||||
Variable::SetMax(double max)
|
||||
{
|
||||
if (!fIsValid)
|
||||
return;
|
||||
|
||||
fMax = max;
|
||||
set_bounds(fLS->fLP, this->Index(), fMin, fMax);
|
||||
SetRange(fMin, max);
|
||||
}
|
||||
|
||||
|
||||
@ -325,8 +317,9 @@ Variable::Invalidate()
|
||||
* Constructor.
|
||||
*/
|
||||
Variable::Variable(LinearSpec* ls)
|
||||
: fLS(ls),
|
||||
fUsingSummands(new BList()),
|
||||
:
|
||||
fLS(ls),
|
||||
|
||||
fValue(NAN),
|
||||
fMin(0),
|
||||
fMax(DBL_MAX),
|
||||
@ -353,6 +346,5 @@ Variable::Variable(LinearSpec* ls)
|
||||
Variable::~Variable()
|
||||
{
|
||||
Invalidate();
|
||||
delete fUsingSummands;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user