Skip to content

Instantly share code, notes, and snippets.

@saiberz
Last active August 29, 2015 14:08
Show Gist options
  • Save saiberz/e0ab21fcc83839fe215a to your computer and use it in GitHub Desktop.
Save saiberz/e0ab21fcc83839fe215a to your computer and use it in GitHub Desktop.
function z = getCostMin(PowMin,PowMax,Cost,PowDem)
% Input Values:
% Output Values:
% See also: linprog
[n, ~ ] = size(PowMin);
z = zeros(n);
Ai = [eye(n)*(-1);eye(n)];
bi = [zeros(n,1);PowMax];
Ae = ones(1,n);
r = linprog(Cost,Ai,bi,Ae,PowDem);
aux = 1:n;
z = sortrows([Cost', r,aux']);
% a = arrayfun( @(x) linprog(Cost,Ai,bi,Ae,x), PowDem,'un',0);
% z = arrayfun( @(y) sortrows(y),a)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment