ot-lab-bfs

Version 1.0.0 (45.4 KB) by Akshay
code
1 Download
Updated 20 Feb 2023

View License

clc;
close all;
a=[-1,1,1,0;1,1,0,1];
b=[1;2];
c=[1,2,0,0];
[m n] = size(a);
nCm=nchoosek(n,m);
pair=nchoosek(1:n,m);
sol=[];
for i=1:nCm
y=zeros(n,1);
B=a(:,pair(i,:));
%det zero
x=B\b;
if all(x>=0 & x~=inf &x~=-inf)
y(pair(i,:))=x;
sol=[sol y]
end
end
% solution
sol=sol';
for i=1:length(sol)
obj(i,:)=sum(sol(i,:).*c);
end
[p,loc]=max(obj);
fprintf('the optimal value is %f\n',p);
fprintf('the optimal solution is');
disp(sol(loc,:));

Cite As

Akshay (2024). ot-lab-bfs (https://www.mathworks.com/matlabcentral/fileexchange/125025-ot-lab-bfs), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2022b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0