forked from chashikajw/simplex-algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstruction.txt
67 lines (45 loc) · 2.01 KB
/
Instruction.txt
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
The main method is in this program itself.
Instructions for compiling=>>
my IDE codeBlocks;
Run on any gcc compiler=>>
Special***** should compile in -std=c++11 or c++14 ********* (mat be other versions syntacs can be different)
turorials point online compiler
==> go to link http://cpp.sh/ or https://www.tutorialspoint.com/compile_cpp_online.php and after go to c++ editor copy code and paste.
after that click button compile and after execute.
if you have -std=c++11 or C++14 you can run in command line;
g++ -o output Simplex.cpp
./output
if you correctly compile this Output should like this:
Output:
initial array(Not optimal)
2 1 1 1 0 0
1 3 2 0 1 0
2 1 2 0 0 1
final array(Optimal solution)
1 0 0.2 0.6 -0.2 0
0 1 0.6 -0.2 0.4 0
0 0 1 -1 0 1
Answers for the Constraints of variables(variables array)
variable1: 48
variable2: 84
variable3: 0
maximum value: 708
How to give inputs to the program =>>>
Example qution: maximize --> 6x + 5y + 4z
Subject to 2x + y + z <= 180 slack varibles 2x + y + z + s1 = 180
x + 3y + 2z <= 300 x + 3y + 2z +s2 = 300
2x + y + 2z <= 240 2x + y + 2z +s3 = 240
you can make a arryas like below from this quetion:
colSizeA = 6 // input colmn size
rowSizeA = 3 // input row size
float C[N]={-6,-5,-4,0,0,0}; //Initialize the C array with the coefficients of the constraints of the objective function
float B[M]={180,300,240};//Initialize the B array constants of the constraints respectively
//initialize the A array by giving all the coefficients of all the variables
float A[M][N] = {
{ 2, 1, 1, 1, 0, 0},
{ 1, 3, 2, 0, 1, 0 },
{ 2, 1, 2, 0, 0, 1}
};
after intialis these arrays make the Simplex class and call CalculateSimplex() method:
Simplex simplex(vec2D,b,c);
simplex.CalculateSimplex();