Author: czeidler Date: 2010-09-20 06:23:27 +0200 (Mon, 20 Sep 2010) New Revision: 38736 Changeset: http://dev.haiku-os.org/changeset/38736 Modified: haiku/trunk/headers/libs/linprog/LinearSpec.h haiku/trunk/headers/libs/linprog/ResultType.h Log: Some clean up (not complete). Modified: haiku/trunk/headers/libs/linprog/LinearSpec.h =================================================================== --- haiku/trunk/headers/libs/linprog/LinearSpec.h 2010-09-20 03:45:04 UTC (rev 38735) +++ haiku/trunk/headers/libs/linprog/LinearSpec.h 2010-09-20 04:23:27 UTC (rev 38736) @@ -1,29 +1,30 @@ /* * Copyright 2007-2008, Christof Lutteroth, lutteroth@xxxxxxxxxxxxxxxxx * Copyright 2007-2008, James Kim, jkim202@xxxxxxxxxxxxxxxxx + * Copyright 2010, Clemens Zeidler, haiku@xxxxxxxxxxxxxxxxxx * Distributed under the terms of the MIT License. */ - #ifndef LINEAR_SPEC_H #define LINEAR_SPEC_H -#include "Variable.h" +#include <math.h> + +#include <List.h> +#include <OS.h> +#include <String.h> +#include <SupportDefs.h> + #include "Constraint.h" -#include "Summand.h" + +#include "OperatorType.h" +#include "OptimizationType.h" #include "PenaltyFunction.h" -#include "OperatorType.h" #include "ResultType.h" -#include "OptimizationType.h" +#include "Summand.h" +#include "Variable.h" #include "lp_lib.h" -#include <List.h> -#include <String.h> -#include <OS.h> -#include <SupportDefs.h> -#include <math.h> - - namespace LinearProgramming { class Constraint; @@ -31,92 +32,95 @@ class PenaltyFunction; class Variable; -/** + +/*! * Specification of a linear programming problem. */ class LinearSpec { - public: - LinearSpec(); - virtual ~LinearSpec(); + LinearSpec(); + virtual ~LinearSpec(); - Variable* AddVariable(); + Variable* AddVariable(); - Constraint* AddConstraint(BList* summands, - OperatorType op, double rightSide); - Constraint* AddConstraint(double coeff1, Variable* var1, - OperatorType op, double rightSide); - Constraint* AddConstraint(double coeff1, Variable* var1, - double coeff2, Variable* var2, - OperatorType op, double rightSide); - Constraint* AddConstraint(double coeff1, Variable* var1, - double coeff2, Variable* var2, - double coeff3, Variable* var3, - OperatorType op, double rightSide); - Constraint* AddConstraint(double coeff1, Variable* var1, - double coeff2, Variable* var2, - double coeff3, Variable* var3, - double coeff4, Variable* var4, - OperatorType op, double rightSide); + Constraint* AddConstraint(BList* summands, + OperatorType op, double rightSide); + Constraint* AddConstraint(double coeff1, Variable* var1, + OperatorType op, double rightSide); + Constraint* AddConstraint(double coeff1, Variable* var1, + double coeff2, Variable* var2, + OperatorType op, double rightSide); + Constraint* AddConstraint(double coeff1, Variable* var1, + double coeff2, Variable* var2, + double coeff3, Variable* var3, + OperatorType op, double rightSide); + Constraint* AddConstraint(double coeff1, Variable* var1, + double coeff2, Variable* var2, + double coeff3, Variable* var3, + double coeff4, Variable* var4, + OperatorType op, double rightSide); - Constraint* AddConstraint(BList* summands, - OperatorType op, double rightSide, - double penaltyNeg, double penaltyPos); - Constraint* AddConstraint(double coeff1, Variable* var1, - OperatorType op, double rightSide, - double penaltyNeg, double penaltyPos); - Constraint* AddConstraint(double coeff1, Variable* var1, - double coeff2, Variable* var2, - OperatorType op, double rightSide, - double penaltyNeg, double penaltyPos); - Constraint* AddConstraint(double coeff1, Variable* var1, - double coeff2, Variable* var2, - double coeff3, Variable* var3, - OperatorType op, double rightSide, - double penaltyNeg, double penaltyPos); - Constraint* AddConstraint(double coeff1, Variable* var1, - double coeff2, Variable* var2, - double coeff3, Variable* var3, - double coeff4, Variable* var4, - OperatorType op, double rightSide, - double penaltyNeg, double penaltyPos); + Constraint* AddConstraint(BList* summands, + OperatorType op, double rightSide, + double penaltyNeg, double penaltyPos); + Constraint* AddConstraint(double coeff1, Variable* var1, + OperatorType op, double rightSide, + double penaltyNeg, double penaltyPos); + Constraint* AddConstraint(double coeff1, Variable* var1, + double coeff2, Variable* var2, + OperatorType op, double rightSide, + double penaltyNeg, double penaltyPos); + Constraint* AddConstraint(double coeff1, Variable* var1, + double coeff2, Variable* var2, + double coeff3, Variable* var3, + OperatorType op, double rightSide, + double penaltyNeg, double penaltyPos); + Constraint* AddConstraint(double coeff1, Variable* var1, + double coeff2, Variable* var2, + double coeff3, Variable* var3, + double coeff4, Variable* var4, + OperatorType op, double rightSide, + double penaltyNeg, double penaltyPos); - PenaltyFunction* AddPenaltyFunction(Variable* var, BList* xs, BList* gs); + PenaltyFunction* AddPenaltyFunction(Variable* var, BList* xs, + BList* gs); - BList* ObjFunction(); - void SetObjFunction(BList* summands); - void UpdateObjFunction(); + BList* ObjFunction(); + void SetObjFunction(BList* summands); + void UpdateObjFunction(); - ResultType Presolve(); - void RemovePresolved(); - ResultType Solve(); - void Save(const char* fileName); + ResultType Presolve(); + void RemovePresolved(); + ResultType Solve(); + void Save(const char* fileName); - int32 CountColumns() const; - OptimizationType Optimization() const; - void SetOptimization(OptimizationType value); - BList* Variables() const; - BList* Constraints() const; - ResultType Result() const; - double ObjectiveValue() const; - double SolvingTime() const; + int32 CountColumns() const; + OptimizationType Optimization() const; + void SetOptimization(OptimizationType value); - operator BString() const; - void GetString(BString& string) const; + ResultType Result() const; + double ObjectiveValue() const; + double SolvingTime() const; + operator BString() const; + void GetString(BString& string) const; + protected: - int32 fCountColumns; + BList* Variables() const; + BList* Constraints() const; + int32 fCountColumns; + private: - lprec* fLpPresolved; - OptimizationType fOptimization; - lprec* fLP; - BList* fObjFunction; - BList fVariables; - BList fConstraints; - ResultType fResult; - double fObjectiveValue; - double fSolvingTime; + lprec* fLpPresolved; + OptimizationType fOptimization; + lprec* fLP; + BList* fObjFunction; + BList fVariables; + BList fConstraints; + ResultType fResult; + double fObjectiveValue; + double fSolvingTime; public: friend class Constraint; Modified: haiku/trunk/headers/libs/linprog/ResultType.h =================================================================== --- haiku/trunk/headers/libs/linprog/ResultType.h 2010-09-20 03:45:04 UTC (rev 38735) +++ haiku/trunk/headers/libs/linprog/ResultType.h 2010-09-20 04:23:27 UTC (rev 38736) @@ -14,9 +14,21 @@ * The possible results of a solving attempt. */ enum ResultType { - NOMEMORY = -2, ERROR = -1, OPTIMAL = 0, SUBOPTIMAL = 1, INFEASIBLE = 2, UNBOUNDED = 3, - DEGENERATE = 4, NUMFAILURE = 5, USERABORT = 6, TIMEOUT = 7, PRESOLVED = 9, PROCFAIL = 10, - PROCBREAK = 11, FEASFOUND = 12, NOFEASFOUND = 13 + NOMEMORY = -2, + ERROR = -1, + OPTIMAL = 0, + SUBOPTIMAL = 1, + INFEASIBLE = 2, + UNBOUNDED = 3, + DEGENERATE = 4, + NUMFAILURE = 5, + USERABORT = 6, + TIMEOUT = 7, + PRESOLVED = 9, + PROCFAIL = 10, + PROCBREAK = 11, + FEASFOUND = 12, + NOFEASFOUND = 13 }; } // namespace LinearProgramming