Merge all linear programming types in one file an rename them.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39832 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler
2010-12-13 19:23:33 +00:00
parent cbe1fb0f0c
commit f108cdbfab
14 changed files with 99 additions and 125 deletions
+1 -1
View File
@@ -13,7 +13,7 @@
#include <String.h>
#include <SupportDefs.h>
#include "OperatorType.h"
#include "LinearProgrammingTypes.h"
#include "Summand.h"
#include "Variable.h"
@@ -0,0 +1,57 @@
/*
* Copyright 2007-2008, Christof Lutteroth, [email protected]
* Copyright 2007-2008, James Kim, [email protected]
* Copyright 2010, Clemens Zeidler <[email protected]>
* Distributed under the terms of the MIT License.
*/
#ifndef LINEAR_PROGRAMMING_TYPES_H
#define LINEAR_PROGRAMMING_TYPES_H
namespace LinearProgramming {
/**
* The possible results of a solving attempt.
*/
enum ResultType {
kNoMemory = -2,
kError = -1,
kOptimal = 0,
kSuboptimal = 1,
kInfeasible = 2,
kUnbounded = 3,
kDegenerate = 4,
kNumFailure = 5
};
/**
* Possible operators for linear constraints.
*/
enum OperatorType {
kEQ,
kLE,
kGE
};
/**
* The two possibilities for optimizing the objective function.
*/
enum OptimizationType {
kMinimize,
kMaximize
};
} // namespace LinearProgramming
using LinearProgramming::ResultType;
using LinearProgramming::OperatorType;
using LinearProgramming::OptimizationType;
#endif // LINEAR_PROGRAMMING_TYPES_H
+1 -3
View File
@@ -15,10 +15,8 @@
#include <SupportDefs.h>
#include "Constraint.h"
#include "OperatorType.h"
#include "OptimizationType.h"
#include "LinearProgrammingTypes.h"
#include "PenaltyFunction.h"
#include "ResultType.h"
#include "Summand.h"
#include "Variable.h"
-26
View File
@@ -1,26 +0,0 @@
/*
* Copyright 2007-2008, Christof Lutteroth, [email protected]
* Copyright 2007-2008, James Kim, [email protected]
* Distributed under the terms of the MIT License.
*/
#ifndef OPERATOR_TYPE_H
#define OPERATOR_TYPE_H
namespace LinearProgramming {
/**
* Possible operators for linear constraints.
*/
enum OperatorType {
kEQ,
kLE,
kGE
};
} // namespace LinearProgramming
using LinearProgramming::OperatorType;
#endif
-24
View File
@@ -1,24 +0,0 @@
/*
* Copyright 2007-2008, Christof Lutteroth, [email protected]
* Copyright 2007-2008, James Kim, [email protected]
* Distributed under the terms of the MIT License.
*/
#ifndef OPTIMIZATION_TYPE_H
#define OPTIMIZATION_TYPE_H
namespace LinearProgramming {
/**
* The two possibilities for optimizing the objective function.
*/
enum OptimizationType {
MINIMIZE, MAXIMIZE
};
} // namespace LinearProgramming
using LinearProgramming::OptimizationType;
#endif
-38
View File
@@ -1,38 +0,0 @@
/*
* Copyright 2007-2008, Christof Lutteroth, [email protected]
* Copyright 2007-2008, James Kim, [email protected]
* Distributed under the terms of the MIT License.
*/
#ifndef RESULT_TYPE_H
#define RESULT_TYPE_H
namespace LinearProgramming {
/**
* 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
};
} // namespace LinearProgramming
using LinearProgramming::ResultType;
#endif
@@ -88,11 +88,11 @@ GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
ResultType result;
for (int32 tries = 0; tries < 15; tries++) {
result = fSATGroup->GetLinearSpec()->Solve();
if (result == INFEASIBLE) {
if (result == kInfeasible) {
debug_printf("can't solve constraints!\n");
break;
}
if (result == OPTIMAL) {
if (result == kOptimal) {
fSATGroup->AdjustWindows(triggerWindow);
_UpdateWindowSize(frame);
break;
+9 -11
View File
@@ -14,8 +14,6 @@
#include "ViewLayoutItem.h"
#include "ResultType.h"
using namespace LinearProgramming;
@@ -706,10 +704,10 @@ BALMLayout::DerivedLayoutItems()
_SolveLayout();
// if new layout is infeasible, use previous layout
if (fSolver->Result() == INFEASIBLE)
if (fSolver->Result() == kInfeasible)
return;
if (fSolver->Result() != OPTIMAL) {
if (fSolver->Result() != kOptimal) {
fSolver->Save("failed-layout.txt");
printf("Could not solve the layout specification (%d). ",
fSolver->Result());
@@ -791,7 +789,7 @@ BALMLayout::_CreateLayoutItem(BView* view)
void
BALMLayout::_SolveLayout()
{
// Try to solve the layout until the result is OPTIMAL or INFEASIBLE,
// Try to solve the layout until the result is kOptimal or kInfeasible,
// maximally 15 tries sometimes the solving algorithm encounters numerical
// problems (NUMFAILURE), and repeating the solving often helps to overcome
// them.
@@ -811,7 +809,7 @@ BALMLayout::_SolveLayout()
fSolver->Variables()->CountItems(),
fSolver->Constraints()->CountItems()));*/
}
if (result == OPTIMAL || result == INFEASIBLE)
if (result == kOptimal || result == kInfeasible)
break;
}
delete file;
@@ -834,9 +832,9 @@ BALMLayout::_CalculateMinSize()
_SolveLayout();
fSolver->SetObjectiveFunction(oldObjFunction);
if (fSolver->Result() == UNBOUNDED)
if (fSolver->Result() == kUnbounded)
return kMinSize;
if (fSolver->Result() != OPTIMAL) {
if (fSolver->Result() != kOptimal) {
fSolver->Save("failed-layout.txt");
printf("Could not solve the layout specification (%d). "
"Saved specification in file failed-layout.txt", fSolver->Result());
@@ -863,9 +861,9 @@ BALMLayout::_CalculateMaxSize()
_SolveLayout();
fSolver->SetObjectiveFunction(oldObjFunction);
if (fSolver->Result() == UNBOUNDED)
if (fSolver->Result() == kUnbounded)
return kMaxSize;
if (fSolver->Result() != OPTIMAL) {
if (fSolver->Result() != kOptimal) {
fSolver->Save("failed-layout.txt");
printf("Could not solve the layout specification (%d). "
"Saved specification in file failed-layout.txt", fSolver->Result());
@@ -885,7 +883,7 @@ BALMLayout::_CalculatePreferredSize()
_UpdateAreaConstraints();
_SolveLayout();
if (fSolver->Result() != OPTIMAL) {
if (fSolver->Result() != kOptimal) {
fSolver->Save("failed-layout.txt");
printf("Could not solve the layout specification (%d). "
"Saved specification in file failed-layout.txt", fSolver->Result());
-1
View File
@@ -9,7 +9,6 @@
#include "Column.h"
#include "ALMLayout.h"
#include "OperatorType.h"
#include "Tab.h"
-1
View File
@@ -9,7 +9,6 @@
#include "Row.h"
#include "ALMLayout.h"
#include "OperatorType.h"
#include "Tab.h"
#include <SupportDefs.h>
+9 -1
View File
@@ -1,3 +1,11 @@
/*
* Copyright 2007-2008, Christof Lutteroth, lutteroth@cs.auckland.ac.nz
* Copyright 2007-2008, James Kim, jkim202@ec.auckland.ac.nz
* Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de>
* Distributed under the terms of the MIT License.
*/
#include "LPSolveInterface.h"
@@ -160,7 +168,7 @@ LPSolveInterface::SetObjectiveFunction(int nElements, double* coefficients,
bool
LPSolveInterface::SetOptimization(OptimizationType value)
{
if (value == LinearProgramming::MINIMIZE)
if (value == kMinimize)
set_minim(fLP);
else
set_maxim(fLP);
+4
View File
@@ -1,3 +1,7 @@
/*
* Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de>
* Distributed under the terms of the MIT License.
*/
#ifndef LP_SOLVE_INTERFACE_H
#define LP_SOLVE_INTERFACE_H
+16 -16
View File
@@ -20,9 +20,9 @@
*/
LinearSpec::LinearSpec()
:
fOptimization(MINIMIZE),
fOptimization(kMinimize),
fObjFunction(new(std::nothrow) SummandList()),
fResult(ERROR),
fResult(kError),
fObjectiveValue(NAN),
fSolvingTime(NAN)
{
@@ -773,20 +773,20 @@ LinearSpec::GetString(BString& string) const
string << "\n";
}
string << "Result=";
if (fResult==-1)
string << "ERROR";
else if (fResult==0)
string << "OPTIMAL";
else if (fResult==1)
string << "SUBOPTIMAL";
else if (fResult==2)
string << "INFEASIBLE";
else if (fResult==3)
string << "UNBOUNDED";
else if (fResult==4)
string << "DEGENERATE";
else if (fResult==5)
string << "NUMFAILURE";
if (fResult == kError)
string << "kError";
else if (fResult == kOptimal)
string << "kOptimal";
else if (fResult == kSuboptimal)
string << "kSuboptimal";
else if (fResult == kInfeasible)
string << "kInfeasible";
else if (fResult == kUnbounded)
string << "kUnbounded";
else if (fResult == kDegenerate)
string << "kDegenerate";
else if (fResult == kNumFailure)
string << "kNumFailure";
else
string << fResult;
string << " SolvingTime=" << (float)fSolvingTime << "ms";
-1
View File
@@ -11,7 +11,6 @@
#include "Constraint.h"
#include "LinearSpec.h"
#include "OperatorType.h"
#include "Summand.h"
#include "Variable.h"