I'm currently doing optimization in a high dimensional space. I was thinking of giving FindMinimum (or NMinimize not certain yet) a shot, however what bugs me is how I can state the command, given that its input a vector of size ~200.

Most examples for FindMinimum have functions of at most 2 variables.

Now I've seen this answer on StackOverflow where the user generates all his variables using

vars = Array[Symbol["x$" <> ToString[#]] &, n];

However reading the comments showed that there were certain concerns with this method:

I would not recommend doing it in a program, but it is safe to do in an interactive session.

So is this standard, or is there a more clever solution to get to it ?

  • $\begingroup$ Also check out Making Definitions for Indexed Objects $\endgroup$ – shrx Dec 11 '15 at 10:56
  • $\begingroup$ @shrx It is not about assigning. Creation of symbols is solved, comment's to linked answer are OP's concern. $\endgroup$ – Kuba Dec 11 '15 at 17:07
  • $\begingroup$ @Kuba in that case I'm retracting my vote to close. $\endgroup$ – shrx Dec 11 '15 at 17:09

The point being made in the quoted answer was to not use the name$number convention, because Module usues it, and who knows what conflicts might happen internally if you were to generate such variables. Using x$$$s in place of x$ would be fine.

  • 1
    $\begingroup$ Using Unique would also be acceptable. $\endgroup$ – Oleksandr R. Dec 12 '15 at 1:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.