-
Notifications
You must be signed in to change notification settings - Fork 0
/
solver.h
60 lines (56 loc) · 1.39 KB
/
solver.h
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
#ifndef SOLVER_H
#define SOLVER_H
#include <iostream>
#include <stdlib.h>
using namespace std;
class Solver
{
protected:
/*
* This class initializes the solver for solving the optimisation problem"
*/
int rowNo;
int columnNo;
double **A;
double *b;
double *C;
double *x;
double Z;
void check_answer();
public:
Solver();
int flagSolver; //This is used to handle a special case for two way simplex
Solver(int m,int n);
Solver(int m ,int n,double **A_tmp,double *b_tmp,double *C_tmp);
void print();
int solutionFlag;
double get_answer(double *);
};
class Simplex_solver:public Solver
{
void assign_tableau();
void pivot_search();
void row_divide(int row,double param);
void row_addition(int row1,int row2,double param);
void pivot_operation();
int checkZeroFeasibility();
struct Pivot
{
int row;
int column;
};
Pivot pivot;
void initializeAnswer();
public:
void solve();
double **tableau;
void printtableau();
void pivot_operation(int a,int b);
Simplex_solver(int m ,int n,double **A_tmp,double *b_tmp,
double *C_tmp):Solver(m,n,A_tmp,b_tmp,C_tmp) {}
Simplex_solver():Solver(){}
void allocate_tableau();
int tableauRowNo;
int tableauColumnNo;
};
#endif