Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.4K Views
|
3 Replies
|
1 Total Like
View groups...
Share
Share this post:

Solving optimization problem with matrix variable

Hello all,

I have been working on an optimization problem with a matrix variable in Mathematica, but I haven't managed to get a numerical solution, as I am receiving some error messages. Below is a simple example representing my code:

Xrs1 = RandomReal[{0, 1}, {10, 3}];
Xrs2 = RandomReal[{0, 1}, {40, 3}];
Xdr2 = RandomReal[{-5, 5}, {40, 2}];

d = DistanceMatrix[Xrs1, Xrs2];

dr[Xdr1_] := DistanceMatrix[Xdr1, Xdr2];

f[Xdr1_] := Total[(dr[Xdr1] - d)^2, 2];

FindMinimum[f[Xdr1], {Xdr1, ConstantArray[0., {10, 2}]}]

I receive several errors, despite the fact that the function f works perfectly with the initial solution or any other numerical matrix with that dimensions.

I would appreciate any help.

Thank you in advance for your time and support.

3 Replies

I guess that DistanceMatrix was designed and optimized for numerical speed. Here we are feeding it symbolic parameters, which was not intended usage.

POSTED BY: Gianluca Gorni

Thank you very much for your time and your answer.

That behavior of the DistanceMatrix function is wild, and also the way in which the variable needs to be handled for FindMinimum.

But yes! It works.

So thank you once again for the support.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard