[R] Can DEoptim trace output be customized?
David Reiner
David.Reiner at xrtrading.com
Fri May 10 18:06:23 CEST 2013
Katharine,
Thank you for the pointer, and thanks to Josh Ulrich and William Dunlap for good suggestions.
(Also thanks to Dirk Eddelbuettel for shaming me into modifying the code.)
William's fnTracer wrapper technique doesn't require rebuilding the package, so it's easier in some ways,
especially for users who cannot build packages for some reason.
(https://stat.ethz.ch/pipermail/r-help/2013-May/353237.html)
However, I decided to make a change preserving the previous behavior,
and letting negative trace value indicate abbreviated trace output.
## When trace < 0 just print the iteration and value
$ diff ~/DEoptim/src/de4_0.c ~/DEoptim/src/de4_0.c.ORIG
527,530d526
< } else if ( trace < 0 ) {
< if( (i_iter % (-trace)) == 0 ) {
< Rprintf("Iteration: %d bestvalit: %f\n", i_iter, t_bestC);
< }
## Allow trace < 0
diff ~/DEoptim/R/DEoptim.R ~/DEoptim/R/DEoptim.R.ORIG
28,31c28,31
< # if ( trace < 0 ) {
< # warning("'trace' cannot be negative; set to 'TRUE'")
< # trace <- TRUE
< # }
---
> if ( trace < 0 ) {
> warning("'trace' cannot be negative; set to 'TRUE'")
> trace <- TRUE
> }
Feel free to ignore or incorporate this change.
Thanks to all the DEoptim developers and researchers.
This package is really great!
-- David
From: Katharine Mullen [mailto:mullenkate at gmail.com]
Sent: Thursday, May 09, 2013 2:01 PM
To: David Reiner
Cc: r-help at r-project.org
Subject: Re: Can DEoptim trace output be customized?
Dear David,
The package doesn't have an option to customize the output of the trace.
However, you can create a custom version of the package that doesn't print the
parameters. Get the package source code, uncompress it, and find the file
de4_0.c in the src/ directory. Then comment out the calls to Rprintf that
print the parameter values, to read:
Rprintf("Iteration: %d bestvalit: %f bestmemit:", i_iter, t_bestC);
// for (j = 0; j < i_D; j++)
// Rprintf("%12.6f", gt_bestP[j]);
Rprintf("\n");
Then re-build and re-install the package (instructions are at
http://cran.r-project.org/doc/manuals/r-release/R-exts.html#Checking-and-building-packages).
On Thu, May 9, 2013 at 11:27 AM, David Reiner <David.Reiner at xrtrading.com> wrote:
I'm running DEoptim - it works great!
(A HUGE THANK YOU to David Ardia, Katharine Mullen, Brian Peterson, and Joshua Ulrich, and Kris Boudt!!!).
Sometimes I set trace to a number so I can see a few intermediate points in the optimization.
However, I have a large number of variables and would like to omit the bestmemit, which hides what I'm more interested in: bestvalit.
Is there a way to customize the output of trace so it omits the best member?
Thanks,
David L. Reiner
This e-mail and any materials attached hereto, including, without limitation, all content hereof and thereof (collectively, "XR Content") are confidential and proprietary to XR Trading, LLC ("XR") and/or its affiliates, and are protected by intellectual property laws. Without the prior written consent of XR, the XR Content may not (i) be disclosed to any third party or (ii) be reproduced or otherwise used by anyone other than current employees of XR or its affiliates, on behalf of XR or its affiliates.
THE XR CONTENT IS PROVIDED AS IS, WITHOUT REPRESENTATIONS OR WARRANTIES OF ANY KIND. TO THE MAXIMUM EXTENT PERMISSIBLE UNDER APPLICABLE LAW, XR HEREBY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS AND IMPLIED, RELATING TO THE XR CONTENT, AND NEITHER XR NOR ANY OF ITS AFFILIATES SHALL IN ANY EVENT BE LIABLE FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL AND PUNITIVE DAMAGES, LOSS OF PROFITS AND TRADING LOSSES, RESULTING FROM ANY PERSON'S USE OR RELIANCE UPON, OR INABILITY TO USE, ANY XR CONTENT, EVEN IF XR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OR IF SUCH DAMAGES WERE FORESEEABLE.
More information about the R-help
mailing list