<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">Il giorno mer 12 dic 2018 alle ore 18:06 Dener, Alp <<a href="mailto:adener@anl.gov">adener@anl.gov</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div style="overflow-wrap: break-word;">
Hi Stefano,
<div><br>
</div>
<div>I can’t really speak to why the entirety of TAO is disabled in complex builds. Todd can probably offer historical insight to the reason(s). </div>
<div><br>
</div>
<div>However, we do have some methods in TAO that are not tested or guaranteed to be correct for complex-valued objective functions.</div></div></blockquote><div><br></div><div>As far as I understands, TAO is clear in requiring  real objective functions, having PetscReal on the prototype for the callback</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div>The limited-memory quasi-Newton codes, for instance, currently only construct the approximate Hessian for the real
 part of the function and do not generate step directions in the complex part. I also don’t know whether any of the CG methods or line searches require any modifications to be correct in complex builds either.</div>
<div><br>
</div>
<div>In your itemized list, I agree that at minimum we should be supporting #3 even if TAO itself does not work correctly for complex-valued functions.</div>
<div><br></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div>In the meantime, TAO can test real gradients or Hessians internally with `-tao_test_gradient` or `-tao_test_hessian`. Or you can also call `TaoTestHessian()` too. It’s a finite-difference test though, and not a complex-step test.</div>
<div>
<div>
<div style="overflow-wrap: break-word;">
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<br></div></div></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div><div><div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div style="overflow-wrap: break-word;"><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">——<br>
<b>Alp Dener</b></div>
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Argonne National Laboratory</div>
<div style="text-align:start;text-indent:0px"><a href="https://www.anl.gov/profile/alp-dener" target="_blank">https://www.anl.gov/profile/alp-dener</a></div>
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<br>
</div>
</div>
</div>
</div>
<br>
<div>
<blockquote type="cite">
<div>On Dec 12, 2018, at 8:23 AM, Stefano Zampini via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank">petsc-dev@mcs.anl.gov</a>> wrote:</div>
<br class="gmail-m_7828702686796545509Apple-interchange-newline">
<div>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">If I compile PETSc with complex support, all of the TAO methods are not registered.
<div>Fare enough? not really, I can imagine at least three valid reasons to use those</div>
<div><br>
</div>
<div>1) I want to check that my code works for complex builds, even if I have pure real function evaluations. I may need complex support in other parts or the code (not when using TAO), or I just want to be a diligent PETSc developer</div>
<div>2) I want to test REAL gradients or Hessians using built-in capability, instead of writing my own</div>
<div>3) I want to use the complex differentiation trick to compute REAL gradients</div>
<div><br>
</div>
<div>Last time I checked, at least option 2) was available; However, from commit 5921d7004dad83427f45468906667b100d2e2b6e, no Tao methods are registered when PETSC_USE_COMPLEX is defined, and code like the one below fail at runtime:</div>
<div><br>
</div>
<div>TaoCreate()</div>
<div>TaoSetFromOption()</div>
<div>TaoSetObjectiveRoutine()</div>
<div>TaoTestGradient()</div>
<div>
<div>
<div>
<div><br>
</div>
<div>[0]PETSC ERROR: Unknown type. Check for miss-spelling or missing package:
<a href="http://www.mcs.anl.gov/petsc/documentation/installation.html#external" target="_blank">
http://www.mcs.anl.gov/petsc/documentation/installation.html#external</a></div>
<div>[0]PETSC ERROR: Unable to find requested Tao type lmvm</div>
</div>
<div><br>
</div>
<div><br>
</div>
-- <br>
<div dir="ltr" class="gmail-m_7828702686796545509gmail_signature">Stefano</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>

</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Stefano</div></div>