Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
defining a constraint in fmincon
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!