이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Limit on the change rate of the variable in fmincon function
조회 수: 1 (최근 30일)
이전 댓글 표시
채택된 답변
Matt J
2019년 11월 12일
편집: Matt J
2019년 11월 12일
You would build linear inequality matrices like the following.
E=diff(eye(numel(u)));
A=[E;-E]; b=[ub(:);-lb(:)]; %linear inequality matrices
댓글 수: 21
Walter Roberson
2019년 11월 13일
Is u the function being minimized, which would have to be a scalar for each point? Or is u the inputs to that function, which could be a vector? Is the question about the rate of change of the signal a question about the values of all of the elements of the Jacobian, that all of the partial derivatives are within the same lb ub pair? Is the question about the difference between adjacent locations that fmincon is permitted to examine?
Because what this proposed formulation seems to accomplish is to limit the difference between adjacent input variables, like saying in f = x^2 - y^2 as an objective function that lb <= x-y <= ub, which is not what I would understand as the rate change of a signal.
Walter Roberson
2019년 11월 13일
But he also said those do not work. Which is correct if the goal is to limit the elements of the Jacobian. If you are trying to limit the Jacobian you can only do that through linear constraints for functions that are at most quadratic.
Mohammad
2019년 11월 13일
u(t) is the design variable. How about using lb < diff(u) < ub in a nonlinear constraint as an argument of the fmincon function? Does that bound the slew rate change of u(t) such that lb < u(t+1) - u(t) < ub?
Matt J
2019년 11월 13일
You should not tell fmincon that a constraint is nonlinear when it is, in fact, linear. That prevents fmincon from recognizing and taking advantage of the linearity of the constraint.
Catalytic
2019년 11월 13일
편집: Matt J
2019년 11월 13일
You should not tell fmincon that a constraint is nonlinear when it is, in fact, linear.
The one exception to this that I can think of is when it is more computationally manageable to represent the operation A*x in operator form, similar to what pcg allows you to do. But here, I don't see any reason to do that. Note that Matt J's A,b matrices can also be constructed in sparse form if memory limits are a problem.
E=diff(speye(numel(u)));
A=[E;-E]; b=[ub(:);-lb(:)]; %linear inequality matrices
Matt J
2019년 11월 13일
편집: Matt J
2019년 11월 13일
Basically, diff(u) is not something multiplied by the variable u.
Yes, it is. E*u is the same as diff(u). That is why my original proposal is valid.
>> u=rand(5,1);
>> E=diff(speye(5));
>> E*u
ans =
-0.3930
0.2690
0.0212
0.4964
>> diff(u)
ans =
-0.3930
0.2690
0.0212
0.4964
Mohammad
2019년 11월 13일
I figured out a problem. I actually don't have u prior to run the fmincon. Hence, I cannot define E beforehand!
Walter Roberson
2019년 11월 13일
Could you confirm that what you want is that for design variables u1, u2, u3, ... that lb <= u2-u1 <= ub, and lb <= u3-u2 <= ub, and lb <= u4-u3 <= ub, and so on ? If so then that can be implemented through the A b matrix... but it is not what I would call "rate of change of the signal".
Matt J
2019년 11월 13일
I figured out a problem. I actually don't have u prior to run the fmincon. Hence, I cannot define E beforehand!
You don't need u beforehand. You just need to know the number of unknowns, N
E=diff(speye(N));
Mohammad
2019년 11월 13일
편집: Mohammad
2019년 11월 13일
@Walter and Matt: u is a vector in each sampling time t. I want to bound the slew rate of this vector ovet time, i.e., I want u(t+1) - u(t) to lie between two bounds. I don't want to put bounds on the difference of the entries of u.
Hence, I see that none of the diff(u) nor E*u don't refer to what I want which is the slew rate of the vector u ( u(t+1) - u(t) ).
Is there a way, probably defining non-linear constraint to get that?
Walter Roberson
2019년 11월 13일
Is it correct that you have a function of a single variable?
fmincon evaluates the function with different values of the input variables. fmincon cannot know ahead of time what response there will be to the different inputs, so it cannot guarantee that on two adjacent calls that the function response will change only within certain bounds no matter what the step size is. But if you want to constrain the difference between values of the design variables that are to be attempted, then you can configure https://www.mathworks.com/help/optim/ug/fmincon.html#busog7r-options DiffMaxChange DiffMinChange FiniteDifferenceStepSize
I still think that what you really want is limits on the derivative(s) of the function at function at the location to be evaluated. If I am correct then except for functions that are at most quadratic, you would need to implement this through nonlinear constraints that know how to evaluate the derivative of the function.
Matt J
2019년 11월 13일
편집: Matt J
2019년 11월 13일
Is there a way, probably defining non-linear constraint to get that?
This is still a linear constraint!
I will assume that your total matrix of unknown variables is MxN and is of the form
U=[u(1, u(2),...,u(N)]
where each u(t) is an Mx1 vector. I will assume, similarly that you have Mx(N-1) matrices LB and UB of lower and upper bounds, respectively. Then the appropriate linear inequality matrices are
E=kron(diff(speye(N)), speye(M));
A=[E;-E]
b=[UB(:);-LB(:)];
Mohammad
2019년 11월 14일
@Matt: I don't have a set of those signals like an MxN matrix. At each sampling time I have an Mx1 vector u(t) and I want to put a limit on u(t) - u(t-1).
Matt J
2019년 11월 14일
편집: Matt J
2019년 11월 14일
It sounds like you're saying that at time u(t), the values of u(t-1) are already known. Then the bounds can be rewritten
lbnew <= u(t) <= ubnew
where lbnew and ubnew are the known bound vectors
ubnew=ub+u(t-1);
lbnew=lb+u(t-1);
They are known since u(t-1) is known. So, you now have plain ordinary bounds on u(t) and there is nothing special about the way you set up the problem.
But I need to emphasize that, if you have an objective f(t,u(t)) at each time t, the approach you are pursuing will not give you the minimum of if that was your goal in all this. There is no way to do that by solving an independent problem at each t.
추가 답변 (1개)
Walter Roberson
2019년 11월 13일
참고 항목
카테고리
Help Center 및 File Exchange에서 Quadratic Programming and Cone Programming에 대해 자세히 알아보기
태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)