![]() |
Previous | Next | box_f.m |
[fk] = box_f(k, xk, params)
[fk, Fk] = box_f(k, xk, params)
lower = params.box_f_lower
upper = params.box_f_upper
index = params.box_f_index
ell = 2 * size(index, 1)
k
.
To be specific, for
p = 1 , ... , ell / 2
,
lower(p) <= xk( index(p) ) <= upper(p)
n
specifying a value for
the state vector at the current time index.
ell / 2
elements
specifying the state vector indices for which
there is a box constraints.
Each such index must be between one and
n
.
ell / 2
elements
specifying the lower limits for the box constraints.
ell / 2
elements
specifying the upper limits for the box constraints.
fk
is a column vector of length
ell
such that the condition
all( fk <= 0
is equivalent to
the constraints in the purpose
above.
Fk
is an
ell x n
matrix equal to the
Jacobian of
fk
w.r.t
xk
.
function [fk, Fk] = box_f(k, xk, params)
index = params.box_f_index;
lower = params.box_f_lower;
upper = params.box_f_upper;
ell = 2 * size(lower, 1);
n = size(xk, 1);
%
if (size(lower, 2) ~= 1) | (size(upper, 2) ~= 1) | ...
(size(xk, 2) ~= 1)
size_lower_2 = size(lower, 2)
size_upper_2 = size(upper, 2)
size_index_2 = size(index, 2)
size_xk_2 = size(xk, 2)
error('box_f: either lower, upper, index or xk not a column vector')
end
if (2 * size(upper, 1) ~= ell) | (2 * size(index, 1) ~= ell)
size_lower_1 = size(lower, 1)
size_upper_1 = size(upper, 1)
size_index_1 = size(index, 1)
error('box_f: lower, upper, or index has a different size')
end
if (max(index) > n) | (min(index) < 1)
max_index = max(index)
min_index = min(index)
error('box_f: max(index) > size(xk, 1) or min(index) < 1')
end
%
fk = zeros(ell, 1);
Fk = zeros(ell, n);
for p = 1 : (ell / 2)
j = index(p);
fk(2 * p - 1, 1) = xk(j) - upper(p);
Fk(2 * p - 1, j) = +1.;
%
fk(2 * p, 1) = lower(p) - xk(j);
Fk(2 * p, j) = -1.;
end
return
end