-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem-Forwards.h
More file actions
133 lines (133 loc) · 8.1 KB
/
Problem-Forwards.h
File metadata and controls
133 lines (133 loc) · 8.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*==============================================================================
Project: LiFe - New Linear Programming Solvers
Theme: Simplex
Module: Problem-Forwards.h (Problem Function Forwards)
Author: Leonid B. Sokolinsky
This source code has been produced with using BSF-skeleton
================================================================================*/
#include "Problem-bsfTypes.h"
#include "Problem-Types.h"
//====================== Private Functions =====================================
namespace PF {
void AddToBasis(int i, int* basis, int m_basis, bool* success, double eps_zero);
void Lambda(PT_vector_T v, PT_vector_T y, double* lambda_min, int* j_star, double eps_zero);
void LoadBasis(PT_vector_i_T basis, bool* success);
void Make_y(PT_vector_i_T basis_v, int i_star, PT_vector_T y);
void MakeBasis_v(int* neHyperplanes_v, int mne_v, int meq_basis, int* basis_v, double eps_inverse);
void MakeEquationsBasis(int* basis, int* meq_basis, double eps_zero);
void MakeRndBasis_v(int* neHyperplanes_v, int mne_v, int meq, int* edgeBasis_v, double eps_inverse);
bool NegativeNotFoundIn_u(double eps_zero);
bool PointIsVertex(PT_vector_T v, double eps_inverse, double eps_on_hyperplane);
void PreparationForIteration(PT_vector_i_T basis_v);
void SaveBasis(PT_vector_i_T basis);
}
//====================== Shared Functions ======================================
namespace SF {
unsigned long long BinomialCoefficient(int n, int k);
void Bitscale_Create(bool* bitscale, int m, int* hyperplanes, int mh);
void Bitscale_False(bool* bitscale, int m);
void Column_Zeroing(PT_vector_T u);
double Distance_PointToHalfspace_i(PT_vector_T x, int i);
double Distance_PointToHyperplane_i(PT_vector_T x, int i);
double Distance_PointToPoint(PT_vector_T x, PT_vector_T y);
double Distance_PointToPolytope(PT_vector_T x);
double DistanceSQR_PointToPoint(PT_vector_T x, PT_vector_T y);
void List_equations(bool* isEquation, int* equationsList, int* equationCount);
void List_inequalities(bool* isEquation, int* inequalitiesList, int* inequalitiesCount);
void List_neHyperplanes_v(PT_vector_T x, int* neHyperplanes, int mneh, int* neHyperplanes_x, int* mneh_x, double eps_on_hyperplane);
void MakeColumnOfNorms(PT_matrix_T A, PT_column_T norm_a);
void MakeListOfNotIncludingHalfspaces(PT_vector_T x, int* notIncludingHalfspacesList, double eps);
void MakeNeHyperplane_x(PT_vector_T x, int* neHyperplanes_all, int mneh_all, int* neHyperplanes_x, int* mneh_x, double eps_on_hyperplane);
void Matrix_Basis(int* list_i, int* mi, double eps_inverse);
void Matrix_CopyToD(int* list_i, int count);
void Matrix_Normalize(void);
void Matrix_Rank(int* list_i, int mi, int* rank, double eps_inverse);
bool MPS___Load_Problem();
bool MPS__MakeProblem(PT_MPS_row_T* row, int n_row, PT_MPS_column_T* column, int n_col, double* loBound, PT_MPS_upBound_T* upBounds, int n_up, PT_MPS_fxVariable_T* fxVariable, int n_fx);
bool MPS__ReadBounds(FILE* stream, PT_MPS_column_T* column, int n_col, double* loBound, PT_MPS_upBound_T* upBound, int* n_up, PT_MPS_fxVariable_T* fxVariable, int* n_fx);
bool MPS__ReadColumns(FILE* stream, PT_MPS_column_T* columns, int* n_col);
bool MPS__ReadKeyWord(FILE* stream, string* word, string pattern);
bool MPS__ReadRHS(FILE* stream, PT_MPS_row_T* row, int n_row);
bool MPS__ReadRows(FILE* stream, PT_MPS_row_T* rows, int* n_row);
void MPS__SetColumnIndexes(PT_MPS_column_T* column, int n_col, int* n_A);
void MPS__SkipComment(FILE* stream);
bool MPS_AddEquation(PT_MPS_name_T rowName, double RHS_value, PT_MPS_column_T* column, int n_col);
bool MPS_AddInequality_G(PT_MPS_name_T rowName, double RHS_value, PT_MPS_column_T* column, int n_col);
bool MPS_AddInequality_L(PT_MPS_name_T rowName, double RHS_value, PT_MPS_column_T* column, int n_col);
bool MPS_AddObjectiveFunction(PT_MPS_name_T rowName, PT_MPS_column_T* column, int n_col);
void MPS_CopyName(char* name_x, char* name_y);
void MPS_NewLine(FILE* stream);
bool MPS_ReadColumnLine(FILE* stream, PT_MPS_column_T* column, int* n_col);
bool MPS_ReadName(FILE* stream, char* name);
bool MPS_ReadRHS_line(FILE* stream, PT_MPS_row_T* row, int n_row, PT_MPS_name_T RHS_name);
bool MPS_ReadValue(FILE* stream, double* value);
bool MPS_SameNames(PT_MPS_name_T name_x, PT_MPS_name_T name_y);
int MPS_SearchColByName(PT_MPS_column_T* column, int j_col, PT_MPS_name_T name);
int MPS_SearchRowByName(PT_MPS_row_T* row, int n_row, PT_MPS_name_T name);
void MPS_SkipSpaces(FILE* stream);
bool MPS_UniqueRowName(PT_MPS_row_T* rows, int n_row, PT_MPS_name_T name);
bool MTX__Load_Problem();
void MTX_Conversion();
bool MTX_Load_A();
bool MTX_Load_b();
bool MTX_Load_c();
bool MTX_Load_hi();
bool MTX_Load_lo();
bool MTX_LoadVector(PT_vector_T x, string postfix);
bool MTX_LoadVector_i(PT_vector_i_T x, string postfix);
void MTX_RemoveFreeVariables(void);
bool MTX_SaveVector(PT_vector_T x, string postfix);
bool MTX_SaveVector_i(PT_vector_i_T x, string postfix);
void MTX_SkipComments(FILE* stream);
int Number_IncludingNeHyperplanes(PT_vector_T x, double eps_on_hyperplane);
double ObjF(PT_vector_T x);
void OrthogonalProjectingVectorOntoHyperplane_i(PT_vector_T x, int i, PT_vector_T p);
bool PointBelongsToFlat(PT_vector_T x, int* hyperplaneList, int hyperplaneCount, double eps_on_hyperplane);
bool PointBelongsToHalfspace_i(PT_vector_T point, int i, double eps_on_hyperplane);
bool PointBelongsToHyperplane_i(PT_vector_T z, int i, double eps_on_hyperplane);
bool PointBelongsToPolytope(PT_vector_T x, double eps_on_hyperplane);
bool PointInsideHalfspace_i(PT_vector_T x, int i, double eps_on_hyperplane);
bool PointIsBoundary(PT_vector_T x, double eps_on_hyperplane);
void Print_Constraints();
void Print_HalfspacesIncludingPoint(PT_vector_T x, double eps_on_hyperplane);
void Print_HalfspacesOutOfPoint(PT_vector_T x, double eps_on_hyperplane);
void Print_HyperplanesIncludingPoint(PT_vector_T x, double eps_on_hyperplane);
double RelativeError(double trueValue, double calculatedValue);
void Tuning_Eps_PointBelongsToFlat(PT_vector_T x, int* hyperplaneList, int hyperplaneCount, double* eps);
void Tuning_Eps_PointBelongsToPolytope(PT_vector_T x, double* eps);
int TWIDDLE__BinomialCoefficient(int n, int k, int* p);
void TWIDDLE__CodeToSubset(int code, int* a, int* c, int n, int m, int* p, bool* done);
void TWIDDLE_Make_p(int* p, int n, int m);
void TWIDDLE_Run(int* x, int* y, int* z, int* p, bool* done);
int Vector_AbsMax_j(PT_vector_T x);
void Vector_Addition(PT_vector_T x, PT_vector_T y, PT_vector_T z);
void Vector_Copy(PT_vector_T x, PT_vector_T y);
void Vector_CopyNegative(PT_vector_T x, PT_vector_T y);
void Vector_DivideByNumber(PT_vector_T x, double r, PT_vector_T y);
void Vector_DivideEquals(PT_vector_T x, double r);
void Vector_EpsZero(PT_vector_T x, double eps_zero);
bool Vector_Equal(PT_vector_T x, PT_vector_T y);
double Vector_DotProduct(PT_vector_T x, PT_vector_T y);
void Vector_i_Copy(PT_vector_i_T fromVector, PT_vector_i_T toVector);
bool Vector_i_Equal(PT_vector_i_T x, PT_vector_i_T y);
void Vector_i_Print(PT_vector_i_T x);
void Vector_MakeMinus_e(PT_vector_T minus_e);
void Vector_MinusEquals(PT_vector_T equalPoint, PT_vector_T minusVector);
void Vector_MultiplyByNumber(PT_vector_T x, double r, PT_vector_T y);
void Vector_MultiplyEquals(PT_vector_T x, double r);
void Vector_Negative(PT_vector_T x);
double Vector_Norm(PT_vector_T x);
double Vector_NormSquare(PT_vector_T x);
void Vector_PlusEquals(PT_vector_T equalVector, PT_vector_T plusVector);
void Vector_Print(PT_vector_T x, double eps_zero);
void Vector_Round(PT_vector_T x, double eps);
void Vector_SetValue(PT_vector_T x, double v);
void Vector_Subtraction(PT_vector_T x, PT_vector_T y, PT_vector_T z);
void Vector_Zeroing(PT_vector_T x);
}
//====================== Macros ================================================
#define PF_MIN(x,y) (x<y?x:y)
#define PF_MAX(x,y) (x>y?x:y)
#define PF_MAP_LIST_INDEX (BSF_sv_addressOffset + BSF_sv_numberInSublist)
#define PF_DBL_EPSILON 2.222E-16 // Machine epsilon
#define PF_INT_MAX 2147483647 // Maximum value for a variable of type int