1
$\begingroup$

How can I override the AccuracyGoal parameter in NMinimize? Instead of the evaluation stopping at the required Accuracy, I want it to stop after a specific number of iterations, even if the AccuracyGoal is not reached. I tried the following example code, but it doesn't stop after 100 iterations.

NMaximize[{Norm[Array[c1, 10], Infinity]+Norm[Array[d1, 10], Infinity], 
   And @@ Table[-1 <= c1[i] <= 1, {i, 1,10}] && And @@ Table[-1 <= d1[i] <= 1, {i, 1, 10}]}, 
  Flatten[{Array[c1, 10], Array[d1, 10]}],Method -> "SimulatedAnnealing",MaxIterations -> 100];

This question is similar to my query, but is yet to be answered.

$\endgroup$
14
  • $\begingroup$ There is a typo in Table[-1 <= d1[i] <= 1, {i, 1, d10}] , change d10 to 10 and your code runs.! $\endgroup$ May 21, 2021 at 14:45
  • $\begingroup$ Yes, the code runs, but it doesn't stop after 100 iterations. $\endgroup$ May 21, 2021 at 14:56
  • $\begingroup$ That means NMaxmize doesn't need 100 iterations to find the solution! $\endgroup$ May 21, 2021 at 15:01
  • $\begingroup$ Yes for this particular toy example. But for a much more complex problem, I would like to stop the evaluation after say N iterations. $\endgroup$ May 21, 2021 at 15:06
  • $\begingroup$ NMaximize[{Norm[Array[c1, 10], Infinity] + Norm[Array[d1, 10], Infinity], And @@ Table[-1 <= c1[i] <= 1, {i, 1, 10}] && And @@ Table[-1 <= d1[i] <= 1, {i, 1, 10}]}, Flatten[{Array[c1, 10], Array[d1, 10]}], Method -> "SimulatedAnnealing", MaxIterations -> 10] performs a warning "NMaximize::cvmit: Failed to converge to the requested accuracy or precision within 10 iterations" and $\endgroup$
    – user64494
    May 21, 2021 at 17:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.