I have problems with unwanted outputs of NMaximize. I tried to use the command Quiet[] and Off[] in order to turn off the warnings and unwanted outputs but no avail.
You can see the NMaximize part of my code here:
Parallelize[Do[Print[NMaximize[{Abs[
eg[1.5032*10^-4, a, b, m, s] - e1g[1.5032*10^-4, a, b, m, s]]/
eg[1.5032*10^-4, a, b, m, s], {constraint[a, b, m, s] <
1*10^-3, -20 <= a <= 20, 1 <= b <= 10,
1*10^-9 <= m <= 500*10^-9, 1*10^-9 <= s <= 500*10^-9, s < m,
0.01*m < s}}, {a, b, m, s}, MaxIterations -> 1000,
"RandomSeed" -> i]], {i, 1000}]]
Most of the time it produces reasonable outputs such as
{0.321066,{a->-11.9257,b->9.97032,m->3.96839*10^-7,s->3.50421*10^-7}}
and sometimes just the copy of the NMaximize code with chosen numbers as (see the figure above):
(kernel 1) NMaximize[{Abs[NIntegrate[myfun1[y,...
My problem is that the output that I have in another code is so huge. And I cannot run my code properly due to this unwanted output (it takes thousand lines in editor per unwanted output).
The problem is even more significant because I have many such outputs and in the end the editor is not reachable anymore and mathematica disappears.
Is there any way to tell mathematica NOT to output such unwanted outputs? Or if it must output, then to delete this output immediately right after outputing it?
If[ListQ[res = NMaximize[(* stuff *)]], Print[res]]
? $\endgroup$(* stuff *)
is whatever complicated thing you had inNMaximize[]
that I didn't want to bother writing out in full; I was assuming you'd know to try modifying the inner part of your loop to something like it. $\endgroup$