Constraint syntax of a matrix variable in optimization

4 次查看(过去 30 天)
Suppose that a function is has a vector input martri x. And x is of the form:
x(:,1)
x(:,2)
x(:,3)
how should the linear constraints be written?
A(1,:,1)=...
b(1,1)=...
My question extends also for the syntax of the nonlinear equations in the case of an matrix variable. Can the optimization functions receive matrices as inputs?

回答(3 个)

Alan Weiss
Alan Weiss 2013-1-28
Perhaps a sneak peek at some yet-to-be-released documentation will make things clearer:
-----------------
Matrix Arguments
Nonlinear solvers accept matrix initial point x0. They also accept matrix bounds lb and ub. Here's how solvers handle matrix arguments.
Internally, solvers convert matrix arguments into vectors before processing. For example, x0 becomes x0(:). For an explanation of this syntax, see the A(:) entry in colon.
For output, solvers reshape the solution x to the same size as the input x0.
When x0 is a matrix, solvers pass x as a matrix of the same size as x0 to both the objective function and to any nonlinear constraint function.
Linear constraints, though, take x in vector form, x(:). In other words, a linear constraint of the form
A*x ≤ b or Aeq*x = beq
takes x as a vector, not a matrix. Ensure that your matrix A or Aeq has the same number of columns as x0 has elements, or the solver will error.
-----------------
I hope this helps.
Alan Weiss
MATLAB mathematical toolbox documentation

Matt J
Matt J 2013-1-26
编辑:Matt J 2013-1-26
I assume you're talking about FMINCON. The documentation leads me to believe that A and Aeq are meant to operate column-wise on x
A*x(:,i)<=b(:,i)
Aeq*x(:,i)=beq(:,i)
However, that seems very strange, because then the different columns of x cannote interact in the linear constraints. I would have hoped that the linear constraints always internally unfold x into a vector, and so should be interpreted
A*x(:)<=b
Aeq*x(:)=beq
but there's nothing in the documentation to suggest that.
Since I'm sure it's one of the two, an easy way to check is just to test both cases, i.e., write a small problem in which A is M x N and see which of
N=numel(x)
or
N=numel(x(:,1))
throws an error.
  2 个评论
Teja Muppirala
Teja Muppirala 2013-1-27
When FMINCON receives matrices for x or the inequality constraints, it implements them in the following way:
A*x(:) <= b(:)
Aeq*x(:) = beq(:)
This implies size(A,2) = numel(x), and size(A,1) = numel(b)
If the sizes are inconsistent, it will result in an error.
Matt J
Matt J 2013-1-27
Is this in the documentation somewhere? I couldn't find it. Also, is it true for all the Optimization Toolbox solvers that work with linear constraints? The documentation for QUADPROG doesn't even mention that x can be a matrix.

请先登录,再进行评论。


Giorgos Papakonstantinou
编辑:Giorgos Papakonstantinou 2013-1-26
Thank you Matt for the answer. I haven't tried yet neither of the solutions you have suggested but pretty soon I will look at them and return with a feedback.
  1 个评论
Matt J
Matt J 2013-1-26
编辑:Matt J 2013-1-26
OK.
Just so you know, you should be using the Comments blocks (like I am now) to reply to people. The Answer blocks are supposed to be for people replying to your originally posted question.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by