Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A1=[
- 2, 3, 4, 1, 7;
- 3, 2, 5, 8, 10;
- 2, 2, 1, 10, 2;
- 3, 3, 4, 3, 1;
- 2, 1, 9, 8, 9;
- 0, 10, 20, 1, 1;
- 2, 1, 5, 3, 7
- ];
- b1=[100, 100, 103, 67, 89, 98, 39];
- B=[1, 1, 5];
- p=[1, 2, 30, 1, 10 ];
- C=[
- 2, 3, 2;
- 1, 4, 2;
- 2, 5, 1;
- 0.9, 1, 2;
- 1, 1, 4
- ];
- [m, n]=size(A1);
- [cm, cn]=size(C);
- %inequalities
- A=[A1,zeros(m,cm*cn)];
- %inequalities end
- %equalities
- Aeq_1=[];
- for i=1:cm
- Aeq_1=[Aeq_1,eye(cn)];
- end
- Aeq_1=[zeros(cn, n),Aeq_1];
- Aeq_2=[];
- k=1;
- for i=1:cm*cn
- Aeq_2(k,i)=1;
- if mod(i,cn)==0
- k=k+1;
- end
- end
- Aeq_2=[-eye(n),Aeq_2];
- Aeq=[Aeq_1;Aeq_2];
- %equalities
- f=[p,reshape(C',1,[])];
- ub=ones(1,max(size(f)))*inf;
- lb=zeros(1,max(size(f)));
- b=b1;
- beq=[B,zeros(1,n)];
- intcon=1:max(size(f));
- [x,~,eflag] = intlinprog(f,intcon,A,b,Aeq,beq,lb,ub);
- x1=x(n+1:end,:);
- a=x(1:n,:);
- res1 = reshape(x(n+1:end,:), cn, []);
- %res1=C';
- g = digraph;
- for i = 1:cn
- for j = 1:cm
- if not(res1(i,j) == 0 )
- g = addedge(g, i, j+cn, res1(i,j));
- end
- end
- end
- h = plot(g,'Layout','layered','EdgeLabel',g.Edges.Weight,'LineWidth', 4,'ArrowSize', 10, 'MarkerSize', 14, 'LineStyle', ':', 'Marker','s')
- hs = struct(h); %and ignore the warning message
- for nhl = hs.NodeLabelHandles_
- nhl.Font.Size = 25;
- end
- for nhl = hs.EdgeLabelHandles_
- nhl.Font.Size = 18;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement