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 (한국어)