[37] | 1 | function [F_struc,K] = addbounds(F_struc,K,ub,lb) |
---|
| 2 | %ADDBOUNDS Internal function to add variable bounds to an F_struc |
---|
| 3 | |
---|
| 4 | % Author Johan Löfberg |
---|
| 5 | % $Id: addbounds.m,v 1.3 2005/02/10 16:43:32 johanl Exp $ |
---|
| 6 | |
---|
| 7 | % Upper bounds |
---|
| 8 | finite_bounds = find(~isinf(ub)); |
---|
| 9 | if ~isempty(finite_bounds) |
---|
| 10 | p = length(finite_bounds); |
---|
| 11 | n = length(ub); |
---|
| 12 | if ~isempty(F_struc) |
---|
| 13 | F_struc = [F_struc(1:1:K.f,:);[ub(finite_bounds) -sparse(1:p,finite_bounds,ones(p,1),p,n)];F_struc(K.f+1:end,:)]; |
---|
| 14 | else |
---|
| 15 | F_struc = [ub(finite_bounds) -sparse(1:p,finite_bounds,ones(p,1),p,n)]; |
---|
| 16 | end |
---|
| 17 | K.l = K.l+p; |
---|
| 18 | end |
---|
| 19 | |
---|
| 20 | % Lower bounds |
---|
| 21 | finite_bounds = find(~isinf(lb)); |
---|
| 22 | if ~isempty(finite_bounds) |
---|
| 23 | p = length(finite_bounds); |
---|
| 24 | n = length(ub); |
---|
| 25 | if ~isempty(F_struc) |
---|
| 26 | F_struc = [F_struc(1:1:K.f,:);[-lb(finite_bounds) sparse(1:p,finite_bounds,ones(p,1),p,n)];F_struc(K.f+1:end,:)]; |
---|
| 27 | else |
---|
| 28 | F_struc = [[-lb(finite_bounds) sparse(1:p,finite_bounds,ones(p,1),p,n)];F_struc(K.f+1:end,:)]; |
---|
| 29 | end |
---|
| 30 | K.l = K.l+p; |
---|
| 31 | end |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | |
---|