Skip to content

Commit f83affe

Browse files
committed
Adding files to GitHub
0 parents  commit f83affe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+5470
-0
lines changed

OR tut/HelloWorld.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include<iostream.h>
2+
#include<conio.h>
3+
void main()
4+
{
5+
cout<<"Hello World";
6+
7+
}

OR tut/alternate.m

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2+
if XX(2,2,2)~=0
3+
XX(2,1,3)=XX(2,2,1);
4+
i=2;j=2;uv=2;
5+
else
6+
[e r ] = find(XX(2:cm+1,2:cn+1,2)~=0);
7+
e=e+1;
8+
r=r+1;
9+
jj=longestcontinuous(e,r)
10+
XX(e(jj,1),1,3)=XX(e(jj,1),r(jj,1),1);
11+
i=e(jj,1);j=r(jj,1);
12+
end
13+
temp=0;uv=2;%% uv is ki u and v me se agla kya set karna hai
14+
15+
while temp==0
16+
switch uv
17+
18+
case 1
19+
XX(i,1,3)=XX(i,j,1)-XX(1,j,3);
20+
21+
case 2
22+
XX(1,j,3)=XX(i,j,1)-XX(i,1,3);
23+
end
24+
uv = 0;
25+
if i<cm +1
26+
if XX(i+1,j,2)~=0
27+
uv=1;
28+
end
29+
end
30+
if j<cn+1
31+
if XX(i,j+1,2)~=0
32+
uv=2;
33+
end
34+
end
35+
if uv==2
36+
j=j+1;
37+
end
38+
if uv==1
39+
i=i+1;
40+
end
41+
42+
if uv==0
43+
temp=1;
44+
end
45+
46+
if i>cm+1 || j>cn+1
47+
temp=1;
48+
end
49+
end %%while loop ends
50+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

OR tut/bb.m

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
2+
function [io im] = bb(type,A,B,C,S)
3+
global I
4+
I =0;
5+
global O
6+
O=[];
7+
global M;
8+
M=[];
9+
global zmax ;
10+
zmax = -10000000;
11+
global zmin;
12+
zmin = 10000000;
13+
bnb(type,A,B,C,S,I,O,M,zmax,zmin)
14+
[io ind]=max(O);
15+
16+
im=M(:,ind);
17+
18+
io
19+
im
20+
21+
end
22+
23+
24+
function bnb(type,A,B,C,S,I,O,M,zmax,zmin)% 1 for max, -1 for min
25+
26+
I=I+1;
27+
I
28+
O
29+
M
30+
zmax
31+
zmin
32+
keyboard
33+
fprintf('Table number :%.0f',I)
34+
keyboard
35+
type
36+
A
37+
B
38+
C
39+
S
40+
[opt mat] = simplex(type,A,B,C,S);
41+
keyboard
42+
o=opt;
43+
m=mat;
44+
45+
if sign(o) == -1 || min(m) < 0
46+
disp('sign is -1 or m is less than 0')
47+
keyboard
48+
return
49+
end
50+
51+
index = find ( ceil(m)~=m)
52+
keyboard
53+
if length(index)==0
54+
disp('length of index is 0')
55+
O(1,I) = o % global storage
56+
M(1:length(m) :I) = m(1:length(m)) % global storage
57+
keyboard
58+
return
59+
end
60+
61+
62+
63+
64+
65+
66+
switch type
67+
case 1
68+
69+
if o<zmax
70+
fprintf('%.0f is not better than %.0f',o,zmax)
71+
keyboard
72+
return
73+
end
74+
case -1
75+
76+
if o>zmin
77+
fprintf('%.0f is not better than %.0f',o,zmin)
78+
keyboard
79+
return
80+
end
81+
end
82+
83+
index(1,1)
84+
A1(1,size(A,2))=0;
85+
A1(1,index(1,1))=1;
86+
A=[A;A1]
87+
88+
B=[B;ceil(m(index(1,1)))]
89+
S=[S;-1]
90+
disp('goinginto bnb')
91+
keyboard
92+
bnb(type,A,B,C,S,I,O,M,zmax,zmin);
93+
94+
B(length(B),:)=[];
95+
S(length(S),:)=[];
96+
B=[B;floor(m(index(1,1)))]
97+
S=[S;1]
98+
disp('goinginto bnb')
99+
keyboard
100+
bnb(type,A,B,C,S,I,O,M,zmax,zmin);
101+
102+
103+
end
104+

OR tut/bnb.m

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
function [io im] = bb(type,A,B,C,S)
2+
bnb(type,A,B,C,S);
3+
[io ind]=max(O);
4+
5+
im=M(:,ind);
6+
7+
io
8+
im
9+
10+
end
11+
12+
global I=1;
13+
global O=[];
14+
global M=[];
15+
global zmax = -10000000;
16+
global zmin = 10000000;
17+
function bnb(type,A,B,C,S)% 1 for max, -1 for min
18+
fprintf('Table number :%.0f',I)
19+
[o m] = simplex(type,A,B,C,S)
20+
21+
22+
if sign(o) == -1 || min(m) < 0
23+
24+
I=I+1;
25+
return
26+
end
27+
28+
index = find ( ceil(m)~=m);
29+
if length(index)==0
30+
I=I+1;
31+
O(1,I) = o; % global storage
32+
M(1:length(m) :I) = m(1:length(m)) ; % global storage
33+
return
34+
end
35+
36+
37+
38+
39+
40+
41+
switch type
42+
case 1
43+
44+
if o<zmax
45+
fprintf('%.0f is not better than %.0f',o,zmax)
46+
I=I+1;
47+
return
48+
end
49+
case -1
50+
51+
if o>zmin
52+
fprintf('%.0f is not better than %.0f',o,zmin)
53+
I=I+1;
54+
return
55+
end
56+
end
57+
58+
59+
A1(1,size(A,2))=0;
60+
A1(1,index(1,1))=1;
61+
A=[A;A1];
62+
63+
B=[B;ceil(m(index(1,1)))];
64+
S=[S;-1];
65+
66+
bnb(type,A,B,C,S);
67+
B(length(B),:)=[];
68+
S(length(S),:)=[];
69+
B=[B;floor(m(index(1,1)))];
70+
S=[S;1];
71+
bnb(type,A,B,C,S);
72+
73+
I=I+1;
74+
end
75+

OR tut/cycle.m

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
function [y,bout,loop1]=cycle(x,row,col,b)
2+
% [y,bout]=cycle(x,row,col)
3+
% x: current solution (m*n)
4+
% b: entering basic variables (m*n)
5+
% row,col: index for element entering basis
6+
% y: solution after cycle of change (m*n)
7+
% bout: new basic variables after cycle of change (m*n)
8+
% loop1: the cycle through which theta has to be changed
9+
bout=b;
10+
y=x;
11+
[m,n]=size(x);
12+
loop=[row col]; % describes the cycle of change
13+
x(row,col)=Inf; % do not include (row,col) in the search
14+
b(row,col)=Inf;
15+
rowsearch=1; % start searching in the same row
16+
while (loop(1,1)~=row | loop(1,2)~=col | length(loop)==2),
17+
if rowsearch, % search in row
18+
j=1;
19+
while rowsearch
20+
if (b(loop(1,1),j)~=0) & (j~=loop(1,2))
21+
loop=[loop(1,1) j ;loop]; % add indices of found element to loop
22+
rowsearch=0; % start searching in columns
23+
elseif j==n, % no interesting element in this row
24+
b(loop(1,1),loop(1,2))=0;
25+
loop=loop(2:length(loop),:); % backtrack
26+
rowsearch=0;
27+
else
28+
j=j+1;
29+
end
30+
end
31+
else % column search
32+
i=1;
33+
while ~rowsearch
34+
if (b(i,loop(1,2))~=0) & (i~=loop(1,1))
35+
loop=[i loop(1,2) ; loop];
36+
rowsearch=1;
37+
elseif i==m
38+
b(loop(1,1),loop(1,2))=0;
39+
loop=loop(2:length(loop),:);
40+
rowsearch=1;
41+
else
42+
i=i+1;
43+
end
44+
end
45+
end
46+
end
47+
% compute maximal loop shipment
48+
loop1=loop;
49+
l=length(loop);
50+
theta=Inf;
51+
minindex=Inf;
52+
for i=2:2:l
53+
if x(loop(i,1),loop(i,2))<theta,
54+
theta=x(loop(i,1),loop(i,2));
55+
minindex=i;
56+
end;
57+
end
58+
% compute new transport matrix
59+
y(row,col)=theta;
60+
for i=2:l-1
61+
y(loop(i,1),loop(i,2))=y(loop(i,1),loop(i,2))+(-1)^(i-1)*theta;
62+
end
63+
bout(row,col)=1;
64+
bout(loop(minindex,1),loop(minindex,2))=0;

OR tut/degeneracycorrect.m

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
function degeneracycorrect(X)
2+
3+
4+
[m n] = size(X);
5+
m=m-1;
6+
n=n-1;
7+
x(3:m+2,3:n+2)=X(2:m+1,2:n+1);
8+
x(1:2,1:2)=0;
9+
x(1,:)=0;x(:,1)=0;
10+
if sum(sum(x))~=sum(X(1,:))
11+
disp('not balanced')
12+
return
13+
end
14+
15+
N=m+n-1-length(find(x(3:m+2,3:n+2)~=0));
16+
if N>0
17+
for p=1:m
18+
x(p+2,2)=length(find(x(p+2,3:n+2)~=0));
19+
end
20+
for p=1:n
21+
x(2,p+2)=length(find(x(3:m+2,p+2)~=0));
22+
end
23+
24+
while(sum(x(2,:))>0&&sum(x(:,2))>0)
25+
26+
27+
28+
h=find(x(2,3:n+2)==max(x(2,3:n+2)))+2;
29+
v=find(x(3:m+2,2)==max(x(3:m+2,2)))+2;
30+
if x(2,h(1,1))>x(v(1,1),2)
31+
32+
x(1,h(1,1))=1;
33+
x(2:n+2,h(1,1))=0;
34+
35+
36+
else
37+
if x(v(1,1),2)>1
38+
x(v(1,1),1)=1;
39+
x(v(1,1),2:n+2)=0;
40+
else
41+
if sum(x(1,:))>sum(x(:,1))
42+
x(v(1,1),1)=1;
43+
x(v(1,1),2:n+2)=0;
44+
x(2:n+2,h(1,1))=0;
45+
else
46+
H=find(x(v(1,1),3:n+2)==max(x(v(1,1),3:n+2)))+2;
47+
x(v(1,1),H)=0;
48+
x(1,H)=1;
49+
x(2:m+2,H)=0;
50+
end
51+
end
52+
end
53+
for p=1:m
54+
x(p+2,2)=length(find(x(p+2,3:n+2)~=0));
55+
end
56+
for p=1:n
57+
x(2,p+2)=length(find(x(3:m+2,p+2)~=0));
58+
end
59+
end
60+
61+
62+
h=find(x(1,:)==1)-1;
63+
v=find(x(:,1)==1)-1;
64+
p=(length(v));
65+
p1=(length(h));
66+
for pqqq=1:length(h)
67+
68+
for pqqq1 = 1:length(v)
69+
70+
71+
if N>0
72+
if X(v(p,1),h(1,p1))==0
73+
X(v(p,1),h(1,p1))=0.01;
74+
N=N-1;
75+
end
76+
end
77+
p1=p1-1;
78+
end
79+
p=p-1;
80+
end
81+
82+
X
83+
84+
85+
end
86+
87+
88+
89+
end

0 commit comments

Comments
 (0)