MCPcopy Create free account
hub / github.com/ShahjalalShohag/code-library / add_constraint

Function add_constraint

Math/Simplex Algorithm.cpp:96–108  ·  view source on GitHub ↗

C[] = co-efficients of the constraints (LHS), lim = limit in RHS cmp = EQUAL for C[] = lim, LESSEQ for C[] <= lim, GREATEQ for C[] >= lim

Source from the content-addressed store, hash-verified

94 /// C[] = co-efficients of the constraints (LHS), lim = limit in RHS
95 /// cmp = EQUAL for C[] = lim, LESSEQ for C[] <= lim, GREATEQ for C[] >= lim
96 inline void add_constraint(long double C[], long double lim, int cmp){
97 m++, cmp *= -1;
98 if (cmp == 0){
99 for (int i = 0; i < n; i++) ar[m][i] = C[i];
100 ar[m++][n] = lim;
101 for (int i = 0; i < n; i++) ar[m][i] = -C[i];
102 ar[m][n] = -lim;
103 }
104 else{
105 for (int i = 0; i < n; i++) ar[m][i] = C[i] * cmp;
106 ar[m][n] = lim * cmp;
107 }
108 }
109
110 inline void init(){ /// Initialization
111 for (int i = 0; i <= m; i++) basis[i] = -i;

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected