0
$\begingroup$

I would like to use the Differential Evolution option of NMinimize to find the "optimal" solution for the hyper-sphere function defined as follows,

f[1] = Compile[{{x, _Real, 1}}, Total[x^2]]; 

The input for the function is a vector of D real-valued components that are constrained by -100 and 100.

Is it possible to solve this (or similar) problem using NMinimize?

Many thanks.

$\endgroup$
4
  • $\begingroup$ Yes, I think it is. Of course, as I read the problem, the minimum is 0. and the use of NMinimize is unnecessary. (Perhaps more detail, or a nontrivial example, would help you get more help, if this comment is unsatisfactory.) $\endgroup$
    – Michael E2
    May 28 at 17:00
  • 1
    $\begingroup$ Example: Block[{f, d = 99, vars, x}, vars = Array[x, d]; f[1] = Compile[{{x, _Real, 1}}, Total[x^2], RuntimeOptions -> {"EvaluateSymbolically" -> False, "WarningMessages" -> False}]; NMinimize[{f[1][vars], Thread[-100 < vars < 100]}, vars, Method -> "DifferentialEvolution"] ] $\endgroup$
    – Michael E2
    May 28 at 17:06
  • $\begingroup$ Thank you so much. I agree the Sphere function is trivial but I just wanted to know how to use NMinimize with vectors and you have explained to me. Many thanks! $\endgroup$ May 28 at 18:26
  • $\begingroup$ You're welcome. This is pretty much the same problem, with a variation on the solution: mathematica.stackexchange.com/questions/125379/… $\endgroup$
    – Michael E2
    May 28 at 19:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.