Info

此问题已关闭。 请重新打开它进行编辑或回答。

defining a constraint in fmincon

1 次查看(过去 30 天)
sensation
sensation 2018-7-16
关闭: MATLAB Answer Bot 2021-8-20
Hi guys, I want to define linear constraints of the form: A*x <= b of my S to be like: minS <= S(t) <= maxS
% My storage function is this one:
function S=storage(init_s,inFlow,x,N)
T=totalflow(x,N);
S(1) = init_s(1) + inFlow(1)-T(1);
for ii = 2:N
S(ii) = S(ii-1) + inFlow(ii)-T(ii);
end
Tried solution see below pls, but I get S after some time steps higher than my maxS. Any clue why?
%I have tried this one but Smax is exceeded almost all the time.
c1(:,i) = init_s(:,i) + cumsum(inFlow(:,i));
b2(1:N,i) = maxS(i)-c1(1:N,i); %upper storage limit
b3(1:N,i) = -minS(i)+c1(1:N,i); %lower storage limit
b = [b;b2;b3]; %addition to previous constraint
s = -1*sparse(tril(ones(N)));
s = [s s];
A = [A;s; -s];
Any idea or tip? Thanks a lot!

回答(0 个)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by