1
$\begingroup$

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 ?

$\endgroup$
3
  • $\begingroup$ Also check out Making Definitions for Indexed Objects $\endgroup$ Commented Dec 11, 2015 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$ Commented Dec 11, 2015 at 17:07
  • $\begingroup$ @Kuba in that case I'm retracting my vote to close. $\endgroup$ Commented Dec 11, 2015 at 17:09

1 Answer 1

1
$\begingroup$

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.

$\endgroup$
1
  • 1
    $\begingroup$ Using Unique would also be acceptable. $\endgroup$ Commented Dec 12, 2015 at 1:42

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.