About optimization tool box question
显示 更早的评论
How can I do so that the summation in the constraint can be applied in the fmincon function which used in optimization tool box?
Plz, help and thanks a lot!!

回答(5 个)
Alan Weiss
2015-3-11
0 个投票
I am not sure that I understand the difference between p_i and p_i^h. But the constraints look like bounds and linear equality constraints.
Alan Weiss
MATLAB mathematical toolbox documentation
John D'Errico
2015-3-11
What confuses me is that if p_i is in the interval [0,1] then usually p_i^h (assuming that is a power we are talking about) is also in that interval. So those bound constraints all reduce to the simple
0 <= p_i <= 1
Again, this assumes that p_i^h is p_i raised to the power h. I suppose that superscript might be defined in any way you like, but if you want us to understand mathematics, then you need to either let us assume that your notation is consistent with standard mathematical notation, or tell us how it is not.
Next, the first equality constraint does not seem to be linear, since it also has powers of the p_i in the sum.
Finally, we don't know what values M and H take on, but there are apparently M unknowns to search over, but we see M+H equality constraints. And that ignores the bound constraints. This is a recipe for a situation with no possible solutions that satisfy the equality constraints.
Johan Löfberg
2015-3-12
Looks like a QP to me (i.e., you should not use fmincon, but quadprog, or some other quadratic programming solver)
You have two sets of variables, the vector p, and a matrix P (the one you index with i and h). You have bound constraints on all elements in P, the equality p = P*q and sum of rows equals 1, sum(P,1)=1. To get this into a numerical format for quadprog, you have to introduce a vectorized notation where your decision variables are x =[p;P(:)], and then simply write all constraints in terms of this vector.
Alternatively, you can use a MATLAB based modelling layer such as YALMIP or CVX. Here is the YALMIP code to solve the problem
p = sdpvar(M,1);
P = sdpvar(M,H,'full');
Constraints = [p == P*q, 0 <= P <= 1, sum(P,1) == 1];
Objective = p'*p;
optimize(Constraints,Objective)
value(p)
value(P)
5 个评论
Ho Chun
2015-3-14
Johan Löfberg
2015-3-14
CVX and YALMIP are two different MATLAB toolboxes for convex optimization (and many other problem classes in the case of YALMIP). The code above is YALMIP code, and you can download the toolbox from http://users.isy.liu.se/johanl/yalmip/
Ho Chun
2015-3-15
Johan Löfberg
2015-3-15
Precisely as the code I gave. To minimize Objective subject to Constraints, you do optimize(Constraints,Objective)
Please study the YALMIP Wiki with all the examples and tutorials
Karthikeyan Nainar
2019-1-16
The equality sum(P,1)=1 looks like sum of columns and not rows.
类别
在 帮助中心 和 File Exchange 中查找有关 Nonlinear Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!