-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimplex-test.cpp
58 lines (52 loc) · 1.81 KB
/
simplex-test.cpp
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
#include <iostream>
#include "simplex-method.cpp"
void onestage() {
double tableau[7][4] = {{1, 0, 0, 0},
{-1, 1, 2, 3},
{-0.8, 1, 1, 2},
{0, 1, 0, 0},
{0, 0, 1, 0},
{0, 0, 0, 1},
{0, 1000, 1500, 2400}};
double** pointertableau = new double*[7];
for (int i = 0; i < 7; i++) {
pointertableau[i] = new double[4];
for (int j = 0; j < 4; j++) {
pointertableau[i][j] = tableau[i][j];
}
}
std::string varnamestemp[6] = {"P", "X", "y", "s1", "s2", "s3"};
std::string* varnames = new std::string[6];
varnames = varnamestemp;
pointertableau = apply_simplex(pointertableau, 5, 3, 0, 1, varnames);
}
void twostage() {
double tableau[12][6] = {{1, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0},
{2, -2, 1, 0, 0, 2},
{0, -3, 1, 2, 0, 0},
{2, -1, 1, 1, 1, 1},
{0, 0, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 0},
{-1, 0, 0, 0, -1, 0},
{-1, 0, 0, 0, 0, -1},
{0, 0, 0, 0, 1, 0},
{0, 0, 0, 0, 0, 1},
{19, 0, 20, 22, 4, 15}};
double** pointertableau = new double*[12];
for (int i = 0; i < 12; i++) {
pointertableau[i] = new double[6];
for (int j = 0; j < 6; j++) {
pointertableau[i][j] = tableau[i][j];
}
}
std::string varnamestemp[8] = {"P", "X", "y", "Z", "s1", "s2", "s3", "s4"};
std::string* varnames = new std::string[8];
varnames = varnamestemp;
pointertableau = apply_simplex(pointertableau, 10, 4, 2, 2, varnames);
}
int main() {
//onestage();
twostage();
return 0;
}