-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_LPlib_book02.m
67 lines (55 loc) · 1.44 KB
/
test_LPlib_book02.m
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
clear all;
close all;
clc;
A=[-2 -1 -4 -2; 5 3 1 2; 5 3 0 1;4 6 2 5];
c=[3; -4; 5; -2];
b=[4; 18; -13; 10];
Eqin=[-1;-1;1;0];
MinMaxLP=1;
c0=0;
% all variables is already >=0.
% section 2.3.5 is about Transformations of Constraint Ranges and Variable Constraints
[A, c, b, Eqin, MinMaxLP, c0] = general2canonical(A, c, b, Eqin, MinMaxLP, c0)
clear all;
close all;
clc;
A=[-2 -1 -4 -2; 5 3 1 2; 5 3 0 1;4 6 2 5];
c=[3; -4; 5; -2];
b=[4; 18; -13; -10];
Eqin=[-1;-1;1;1];
MinMaxLP=1;
c0=0;
% all variables is already >=0.
% section 2.3.5 is about Transformations of Constraint Ranges and Variable Constraints
[A, c, b, Eqin, MinMaxLP] = general2standard(A, c, b, Eqin, MinMaxLP)
clear all;
close all;
clc;
A=[-2 3 5; -1 -2 2];
b=[10;-5];
c=[3; -2; 2];
Eqin=[1;1];
MinMaxLP=-1;
VarConst=[2;2;2];
[DA, Dc, Db, DEqin, DMinMaxLP, DVarConst] = primal2dual(A, c, b, Eqin, MinMaxLP, VarConst);
[A, c, b, Eqin, MinMaxLP, VarConst] = primal2dual(DA, Dc, Db, DEqin, DMinMaxLP, DVarConst);
clear all;
close all;
clc;
A=[-3 4 -3; 1 -2 4; 2 -1 -2];
b=[-3;4;6];
c=[2; 4; 0];
Eqin=[0;1;-1];
MinMaxLP=1;
VarConst=[0;2;1];
[DA, Dc, Db, DEqin, DMinMaxLP, DVarConst] = primal2dual(A, c, b, Eqin, MinMaxLP, VarConst);
% can't do that
% [A, c, b, Eqin, MinMaxLP, VarConst] = primal2dual(DA, Dc, Db, DEqin, DMinMaxLP, DVarConst)
clear all;
close all;
clc;
A=[2 0 2 3; 0 -2 -2 -6];
b=[10;-6];
c=[1; 0; -1; -3];
Eqin=[0;0];
[xsol, fval, exitflag, iterations] = rsa(A, c, b, Eqin)