-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLP.h
More file actions
55 lines (47 loc) · 1.35 KB
/
LP.h
File metadata and controls
55 lines (47 loc) · 1.35 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
/* This is an implementation of solvers
for linear programming methods
maximize cTx;
subjected to ATx <= b
x >= 0
A: p-by-n matrix
x: n vector
b: p vector
*/
#include <iostream>
#include <list>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <Eigen/Dense>
using namespace std;
using namespace Eigen;
class Simplex {
/* simplex
iteratively finding the pivot
useful resources:
https://jeremykun.com/2014/12/01/linear-programming-and-the-simplex-algorithm/*/
public:
/*The simplex tabuleaux
a = [A(M,N) I(M,M) b
C(1,N) 0(1,M) 0]*/
void simplexTableaux(vector<vector<double>> &A, vector<double> &b, vector<double> &c);
/* pivot function
used to scale all elements except a specific loc (p,q)*/
void pivot(int &p, int &q);
/* solve simplex */
void solve();
private:
vector<vector<double>> a;
int M, N;
};
class Kamakar {
/*Kamakar's internal point methods*/
public:
/* karmarkar's orginal algorithm
using projective transform*/
void solve_original(MatrixXd &A, VectorXd &c);
/* karmarkar variant, default solver */
void solve_default(MatrixXd &A, VectorXd &b, VectorXd &c, VectorXd &x0);
};